FireBurnsRed Posted June 17, 2016 Share Posted June 17, 2016 Hi... There probably is a post on this somewhere else in the forum but I was wondering... How do I make it so that a characters sanity will increase at night but decrease in the day? I've looked in other places and tried the current characters (I'm also making a character that gains sanity from fire, so I took that out of Willow's code) but haven't found anything as yet. But anyway, I could really use the help, Thank you. -(FireBurns)Red Link to comment https://forums.kleientertainment.com/forums/topic/68271-night-sanity/ Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 (edited) local function sanityfn(inst) local light_delta = 0 local lightval = inst.LightWatcher:GetLightValue() local day = GetClock():IsDay() and not GetWorld():IsCave() if day then -- Day gain, we make it same as night drain -- Day sanity is 0, so 0 plus drain equals drain light_delta = TUNING.SANITY_NIGHT_MID else local highval = TUNING.SANITY_HIGH_LIGHT local lowval = TUNING.SANITY_LOW_LIGHT if lightval > highval then -- Standing near a light source during the night -- Minus negative, so it's positive -- Make it double so it counteracts the drain and ends up positive light_delta = -TUNING.SANITY_NIGHT_LIGHT * 2 elseif lightval < lowval then -- Total dark is still uncomfortable -- Make it a 0 so 0 plus heavy night drain is heavy night drain light_delta = 0 else -- Standing in some light during the night -- Same as the first one, invert it and multiply it light_delta = -TUNING.SANITY_NIGHT_MID * 2 end end return light_delta end inst.components.sanity.custom_rate_fn = sanityfn Edited June 17, 2016 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/68271-night-sanity/#findComment-785334 Share on other sites More sharing options...
FireBurnsRed Posted June 17, 2016 Author Share Posted June 17, 2016 Thank you, much appreciated Link to comment https://forums.kleientertainment.com/forums/topic/68271-night-sanity/#findComment-785335 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