Jump to content

Recommended Posts

Hello! I am making my first character mod, but I have some issues with introducing the character´s perks (damage boost when insane)

What i want is the character to get a damage multiplier when at 30 sanity (out of 100). I am going for wilson´s base damage multiplier, so it would be a X2 multiplier when at 30 or less sanity. I also want the character to announce when they reach the 30 or less sanity ("I am the madness!"), and also say something again when above 40 sanity. Is this possible at all? I have found a few strings for DST, but when i paste them into the prefab.lua of my character for DS it crashes the game. 

 

the string i found was:

Spoiler

 

local function lowsanity(inst)
            inst.components.combat.damagemultiplier = 2
end

local function highsanity(inst)
            inst.components.combat.damagemultiplier = 1
end
            

local function onsanitychange(inst, data)
        if inst.components.sanity.current <= 30 then
        if not inst.isBody then
        lowsanity(inst)
            inst.components.talker:Say("I am the madness!")
        inst.isBody = true    
            end
        elseif inst.components.sanity.current >= 40 then
        if inst.isBody then
        highsanity(inst)
        inst.components.talker:Say("have i gone mad?",3)
        inst.isBody = false    
        end
            
        end    

inst.isBody = false
    
    inst:ListenForEvent("sanitydelta", onsanitychange)


end

 

I would greatly appreciate it if anyone could help me with this. thank you in advance.

Edited by Magalise

Here:

local function onsanitychange(inst)
    if inst.components.sanity:GetPercent() <= .30 then
    inst.components.combat.damagemultiplier = 2
     inst.components.talker:Say("I am the madness!")
    elseif inst.components.sanity:GetPercent() >= .40 then
        inst.components.combat.damagemultiplier = 1
        inst.components.talker:Say("have i gone mad?")
        else
        inst.components.combat.damagemultiplier = 1
    end
end

local fn = function(inst) --reference on where it goes this is your main for your character

inst:DoPeriodicTask(5, onsanitychange, nil, inst) --the 5 is in seconds, its change-able

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...