Scupake Posted May 4, 2019 Share Posted May 4, 2019 I've been working on a character mod and I gave him health regeneration and it's pretty op , I wanted to make scale with hunger and I didn't figure it out I'm still pretty new to modding so it's probably an easy thing to do Link to comment https://forums.kleientertainment.com/forums/topic/105689-how-to-make-a-stat-scale-with-hunger/ Share on other sites More sharing options...
Kitty Cat Meow Posted May 4, 2019 Share Posted May 4, 2019 An easy way to handle this would be to multiply the health regeneration value by 1% of your character's hunger percentage. You can get that hunger value with YourCharacter.components.hunger:GetPercent()*0.01 Link to comment https://forums.kleientertainment.com/forums/topic/105689-how-to-make-a-stat-scale-with-hunger/#findComment-1189133 Share on other sites More sharing options...
Scupake Posted May 4, 2019 Author Share Posted May 4, 2019 (edited) 31 minutes ago, ToastyStoat said: An easy way to handle this would be to multiply the health regeneration value by 1% of your character's hunger percentage. You can get that hunger value with YourCharacter.components.hunger:GetPercent()*0.01 I think I screwed up something health regeneration isn't working at all right now inst.components.health:StartRegen(5, 1) then I changed it to inst.components.health:StartRegen(inst.components.hunger:GetPercent()*0.01, 1) also I'm using Singleplayer don't starve EDIT: I tried this and the game just crashes inst.components.hunger:GetPercent(inst.components.health:StartRegen(1, 1)*0.01 Edited May 4, 2019 by Scupake Link to comment https://forums.kleientertainment.com/forums/topic/105689-how-to-make-a-stat-scale-with-hunger/#findComment-1189136 Share on other sites More sharing options...
Kitty Cat Meow Posted May 4, 2019 Share Posted May 4, 2019 (edited) inst.components.health:StartRegen(5 * inst.components.hunger:GetPercent()*0.01,1) Let me know if this helps any. I have a feeling this would only scale the regeneration from the hunger value the character would spawn in with. You might want to try something a bit more dynamic if you'd like the regen to constantly scale with hunger: local,hu,he = inst.components.hunger,inst.components.health local amount_healed = 1 local interval_in_seconds = 1 inst:DoPeriodicTask(interval_in_seconds,function() if hu and he and not he:IsDead() then he:DoDelta(amount_healed * hu:GetPercent()*0.01,false,"regen") end end) amount_healed and interval_in_seconds are just for demonstration purposes. Edited May 4, 2019 by ToastyStoat Link to comment https://forums.kleientertainment.com/forums/topic/105689-how-to-make-a-stat-scale-with-hunger/#findComment-1189138 Share on other sites More sharing options...
Scupake Posted May 4, 2019 Author Share Posted May 4, 2019 36 minutes ago, ToastyStoat said: inst.components.health:StartRegen(5 * inst.components.hunger:GetPercent()*0.01,1) Let me know if this helps any. I have a feeling this would only scale the regeneration from the hunger value the character would spawn in with. You might want to try something a bit more dynamic if you'd like the regen to constantly scale with hunger: local,hu,he = inst.components.hunger,inst.components.health local amount_healed = 1 local interval_in_seconds = 1 inst:DoPeriodicTask(interval_in_seconds,function() if hu and he and not he:IsDead() then he:DoDelta(amount_healed * hu:GetPercent()*0.01,false,"regen") end end) amount_healed and interval_in_seconds are just for demonstration purposes. I did some changes to the first one and it's working perfectly Thanks for the help Link to comment https://forums.kleientertainment.com/forums/topic/105689-how-to-make-a-stat-scale-with-hunger/#findComment-1189141 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