Jump to content

Recommended Posts

So I want to implement a stat making my character have different health regeneration depending on his sanity. I was looking at abigail's damage upon time of day to see if I could base it around that. I can't seem to get the code right. How do I do it?

Thanks in advance.

@Justintime235, this doesn't seem like it's be too difficult to do. The event you're wanting to listen for is "sanitydelta".

Okay I have that but now he doesn't regenerate health at all. Also I am still learning lua.
local function updatestats (inst, data)	if inst.components.sanity.current <= 15 then		inst.components.health:StartRegen(5,2)	elseif inst.components.sanity.current > 15 then		inst.components.health:StartRegen(10,8)	endend--in master_postinit = function(inst)	inst:ListenForEvent("sanitydelta", updatestats)
Edited by Justintime235

@Justintime235, every sanity delta regen will overwrite the one before it.

 

StartRegen params are:

(amount_to_heal, period_of_time_between_each_heal, interrupt_current_regen)

 

So with inst.components.health:StartRegen(5,2) you will:

Heal 5 health every 2 seconds, and if another StartRegen occurs, then it will be canceled.

(So if you do a StartRegen every 1 second, you will never heal anything.)

 

Try using inst.components.health:StartRegen(5, 2, false). :-) Warning, they will stack.

Try learning how StartRegen works, using a periodic task to do DoDelta repeatedly, and implement your own regeneration.

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...