Jump to content

Making my character lose sanity when hit.


Recommended Posts

I am making a player mod for my friends. This character gets really upset when hurt so I wanted to make him lose sanity when hurt like Walter.
I looked into Walter's code and tried copying some of the code into my player.lua, but it didn't work. 
Little help? (Note: I have no coding experience AND I'm really dumb so this might be the wrong code.)
 

local function OnHealthDelta(inst, data)
    if data.amount < 0 then
        inst.components.sanity:DoDelta(data.amount * ((data ~= nil and data.overtime) and TUNING.WALTER_SANITY_DAMAGE_OVERTIME_RATE or TUNING.WALTER_SANITY_DAMAGE_RATE) * inst._sanity_damage_protection:Get())
    end
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...