Justintime235 Posted May 5, 2015 Share Posted May 5, 2015 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. Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/ Share on other sites More sharing options...
Kzisor Posted May 6, 2015 Share Posted May 6, 2015 @Justintime235, this doesn't seem like it's be too difficult to do. The event you're wanting to listen for is "sanitydelta". Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/#findComment-634862 Share on other sites More sharing options...
Maris Posted May 6, 2015 Share Posted May 6, 2015 What character? You already made the art? Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/#findComment-634868 Share on other sites More sharing options...
Justintime235 Posted May 6, 2015 Author Share Posted May 6, 2015 What character? You already made the art?Deadpool and yes. Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/#findComment-634894 Share on other sites More sharing options...
Justintime235 Posted May 6, 2015 Author Share Posted May 6, 2015 (edited) @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 May 6, 2015 by Justintime235 Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/#findComment-634896 Share on other sites More sharing options...
DarkXero Posted May 6, 2015 Share Posted May 6, 2015 @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. Link to comment https://forums.kleientertainment.com/forums/topic/53560-health-regen-depending-on-sanity/#findComment-634989 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now