Sign in to follow this  
Lues

[Help] Increase Sanity loss during Rain

Recommended Posts

Lues    0

Hello, I've been having trouble figuring out how to make my character lose more sanity during rain. I've got some of the others perks working (move faster at certain healths, lose hunger quicker, etc) but I can't seem to figure this one, so much that I chucked what I had the other day. Any help would be appreciated.

Share this post


Link to post
Share on other sites
Jjmarco    54

@Lues, Use custom_sanity_rate_fn. It's a function of the sanity component that you can assign yourself to add a custom sanity drain/gain to your character.

You could do something like this in your char's master_postinit:

inst.components.sanity.custom_rate_fn = function(inst)    if TheWorld.state.israining then -- if it's raining        return <Your custom sanity rate to add to the current one>    end    return 0 -- else, return nothingend

You can even use TheWorld.state.precipitationrate to make your custom rate vary with the rate of the precipitations:

return <Your custom sanity rate do add to the current one>*TheWorld.state.precipitationrate
Edited by Jjmarco

Share this post


Link to post
Share on other sites
Lues    0

 

@Lues, Use custom_sanity_rate_fn. It's a function of the sanity component that you can assign yourself to add a custom sanity drain/gain to your character.

You could do something like this in your char's master_postinit:

inst.components.sanity.custom_rate_fn = function(inst)    if TheWorld.state.israining then -- if it's raining        return <Your custom sanity rate to add to the current one>    end    return 0 -- else, return nothingend

You can even use TheWorld.state.precipitationrate to make your custom rate vary with the rate of the precipitations:

return <Your custom sanity rate do add to the current one>*TheWorld.state.precipitationrate

Thank you very much! It worked like a charm!

 

@Lues, Use custom_sanity_rate_fn. It's a function of the sanity component that you can assign yourself to add a custom sanity drain/gain to your character.

You could do something like this in your char's master_postinit:

inst.components.sanity.custom_rate_fn = function(inst)    if TheWorld.state.israining then -- if it's raining        return <Your custom sanity rate to add to the current one>    end    return 0 -- else, return nothingend

You can even use TheWorld.state.precipitationrate to make your custom rate vary with the rate of the precipitations:

return <Your custom sanity rate do add to the current one>*TheWorld.state.precipitationrate

Thank you very much! It worked like a charm!

Share this post


Link to post
Share on other sites

 

@Lues, Use custom_sanity_rate_fn. It's a function of the sanity component that you can assign yourself to add a custom sanity drain/gain to your character.

You could do something like this in your char's master_postinit:

inst.components.sanity.custom_rate_fn = function(inst)    if TheWorld.state.israining then -- if it's raining        return <Your custom sanity rate to add to the current one>    end    return 0 -- else, return nothingend

You can even use TheWorld.state.precipitationrate to make your custom rate vary with the rate of the precipitations:

return <Your custom sanity rate do add to the current one>*TheWorld.state.precipitationrate

 

How can you utilize this function to just change the sanity rate at all times? For instance, I want my character to have a low max sanity but faster regen rate to offset it

Share this post


Link to post
Share on other sites
DarkXero    2889

The max sanity you get with

inst.components.sanity:SetMax(100)

Now what do you mean faster regen rate?

You have an invisible top hat equipped all the time giving you sanity, or you boost positive regeneration values?

Or you boost positive AND negative values?

Share this post


Link to post
Share on other sites

Boost positive and negative values. Basically the equivalent of wearing an invisible top hat yeah. I want his max sanity to be 50 and night time and other negative factors drain faster, but to offset it, he gains sanity twice as fast as a normal character.

Share this post


Link to post
Share on other sites
DarkXero    2889

@RomanticRedGeek,

 

-- night time and other negative factors drain faster, he gains sanity twice as fast as a normal character

 

-- Boost positive and negative values

This means that if you have a -5 sanity rate, you would have, for example, -10.

And if you have +5, then it would be +10.

 

-- Basically the equivalent of wearing an invisible top hat

Means that you have a constant +3.3/min sanity summed up to your rate

During night (-5/min), you would have -1.7.

During day, +3.3.

 

Do you want both things, only one, or want to rethink what you especifically want?

I assume you want the positive and negative boost, so no invisible top hat is needed.

 

Use

inst.components.sanity.rate_modifier = 2

Share this post


Link to post
Share on other sites

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
Sign in to follow this