m9m3x3 Posted December 8, 2019 Share Posted December 8, 2019 I want to give penalty to the character's sanity recovery. (foods, items, glommer, pigman, etc...) Is there a way to control the sanity recovery level of a character? (I'm using a translator. Thank you for your time.) Link to comment Share on other sites More sharing options...
Ultroman Posted December 8, 2019 Share Posted December 8, 2019 (edited) There IS one single way to do it. It's just so daft I didn't think of it. This will make every negative change to your sanity only do 80% of the effect. local oldDoDelta = inst.components.sanity.DoDelta inst.components.sanity.DoDelta = function(self, delta, overtime) if delta < 0 then delta = delta * 0.8 end return oldDoDelta(self, delta, overtime) end There is no single way to do what you seem to mean. It would take several different approaches to cover everything. Taking care of the constant frame-by-frame sanity delta is easy, if you accept one downside. The sanity component has a variable called rate_modifier which is set to 1 (100%). If you want your character to be less affected by sanity changes, BOTH negative AND positive (that's the downside), you can set rate_modifier to, e.g., 0.8 to lower the sanity delta to 80% of the actually calculated value. If you want to only affect a negative rate, then you have to add a custom rate function, saved in a reference/variable named custom_rate_fn in the sanity component (you can see where and how it is called in the sanity component's Recalc function). You might do something like this, which will add back 20% of only negative sanity deltas/rates: inst.components.sanity.custom_rate_fn = function(inst, deltaTime) local sanityComp = inst.components.sanity if sanityComp.rate < 0 then return -sanityComp.rate * 0.2 end return 0 end That, however, does not take care of things like foods. See the "Changing Food Values Based On Foodtype (CHARACTER)" chapter of my food post here for that, and just change the code to always change the sanity value by what whatever measure you want, instead of it checking for veggies and stuff like the example shows. And again, for items, each item applies changes to your sanity in different ways. Edited December 8, 2019 by Ultroman 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