TelloSnap Posted March 4, 2015 Share Posted March 4, 2015 Does anyone know how to make my character lose sanity when her hunger gets too low? like maybe when her hunger level reaches something like 20 her sanity starts going down more? Link to comment Share on other sites More sharing options...
mouse Posted March 5, 2015 Share Posted March 5, 2015 This will watch your character's hunger. When her hunger is below 20, once a second it will drop her sanity. How much sanity it drops increases as her hunger decreases.inst:DoPeriodicTask(1, function(inst) if inst.components.hunger.current < 20 then inst.components.sanity:DoDelta((inst.components.hunger.current/inst.components.hunger.max)-1) endend)My suggestion is to change it so instead of waiting for her hunger to drop below a specific number, have it drop when below a certain percent. This makes it easy to adjust her stats without having to adjust when the sanity debuff will be applied. For example, this will apply the debuff when her hunger drops below 15%:inst:DoPeriodicTask(1, function(inst) if inst.components.hunger.current/inst.components.hunger.max < .15 then inst.components.sanity:DoDelta((inst.components.hunger.current/inst.components.hunger.max)-1) endend) Link to comment Share on other sites More sharing options...
rezecib Posted March 6, 2015 Share Posted March 6, 2015 @TelloSnap, The best way to do this is probably to add this to your master_postinit:inst.components.sanity.custom_rate_fn = function(inst) return inst.components.hunger:GetPercent() < 0.2 and -TUNING.SANITYAURA_TINY or 0end Link to comment Share on other sites More sharing options...
TelloSnap Posted March 11, 2015 Author Share Posted March 11, 2015 This will watch your character's hunger. When her hunger is below 20, once a second it will drop her sanity. How much sanity it drops increases as her hunger decreases.inst:DoPeriodicTask(1, function(inst) if inst.components.hunger.current < 20 then inst.components.sanity:DoDelta((inst.components.hunger.current/inst.components.hunger.max)-1) endend)My suggestion is to change it so instead of waiting for her hunger to drop below a specific number, have it drop when below a certain percent. This makes it easy to adjust her stats without having to adjust when the sanity debuff will be applied. For example, this will apply the debuff when her hunger drops below 15%:inst:DoPeriodicTask(1, function(inst) if inst.components.hunger.current/inst.components.hunger.max < .15 then inst.components.sanity:DoDelta((inst.components.hunger.current/inst.components.hunger.max)-1) endend)Thanks! I took your suggestion and it worked great! Link to comment 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