Jump to content

Character code help: Sanity from battle


Recommended Posts

Hello!
I'm kind of a noob in this area...
I'm trying to make a character with two perks:
1. Slow healt autoregeneration.
2. Gain sanity from battle (like Wigfrid).

So:

  • I hope I have the "regen" part of the code... what you think?
  • But I can't figure out how to do the sanity thing... anyone?

Thanks for the advices :)

Quote

-- This initializes for the host only
local master_postinit = function(inst)

    -- choose which sounds this character will play
    inst.soundsname = "wilson"
    -- Stats    
    inst.strength = "minregen"
    
    inst.components.health:SetMaxHealth(120)
    inst.components.health:StartRegen(1, 2)
    inst.components.hunger:SetKillRate(5)
    inst.components.hunger:SetMax(200)
    inst.components.sanity:SetMax(200)
    inst.components.combat.damagemultiplier = 1
    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)
    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)
    
    inst:ListenForEvent("healthdelta", onhealthchange)
    inst:ListenForEvent("hungerdelta", updatestats)
    
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
end

 

 

Link to comment
Share on other sites

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
 Share

×
  • Create New...