Jump to content

[Solved] Way to make character not take sanity penalty from wetness?


Recommended Posts

Hello, if someone can help me out with this that'd be great :D!

So, basically like the title I'm wondering if there's a way to make a character not take sanity penalty from wetness, thanks for your time have a good time :wilson_flower:!

Edited by SuperDavid
Link to comment
Share on other sites

Hmm... so is giving my character a 

inst.components.sanity.dapperness = TUNING.DAPPERNESS_LARGE

when they're wet the way to go about this? Probably not but that's all I can think of though.. bump :D!

Link to comment
Share on other sites

If you want an accurate way to do it, you could just add this code to your custom_rate_fn

--Taken from sanity.lua component from Sanity:Recalc fn
local moisture_delta = easing.inSine(inst.components.moisture:GetMoisture(), 0, -TUNING.MOISTURE_SANITY_PENALTY_MAX, inst.components.moisture:GetMaxMoisture())
--add moisture_delta to your returned rate if you have it already or simply return it if you don't
--By default TUNING.MOISTURE_SANITY_PENALTY_MAX is a negative number so we double negative it to make it gain sanity.

 

Edited by IronHunter
Link to comment
Share on other sites

So is this how code should look like?

local function sanityfn(inst)
	local delta = 0
	
	local moisture_delta = easing.inSine(inst.components.moisture:GetMoisture(), 0, -TUNING.MOISTURE_SANITY_PENALTY_MAX, inst.components.moisture:GetMaxMoisture())
	--add moisture_delta to your returned rate if you have it already or simply return it if you don't
	--By default TUNING.MOISTURE_SANITY_PENALTY_MAX is a negative number so we double negative it to make it gain sanity.
 
    return delta
end

--inside masterpostinit

inst.components.sanity.custom_rate_fn = sanityfn

 

Edited by SuperDavid
Link to comment
Share on other sites

local easing = require("easing")--line 1~ similar to willow

local function sanityfn(inst)
	local delta = 0
	local moisture_delta = easing.inSine(inst.components.moisture:GetMoisture(), 0, -TUNING.MOISTURE_SANITY_PENALTY_MAX, inst.components.moisture:GetMaxMoisture())
	-- in the event you have other delta modifiers you can add them to the rest of the delta
	delta = delta + moisture_delta
	return delta
end
--master_postinit
inst.components.sanity.custom_rate_fn = sanityfn

more like this

If you want  to prevent sanity loss from equippables as well

local easing = require("easing")--line 1~ similar to willow

local function sanityfn(inst)
	local delta = 0
	local moisture_delta = easing.inSine(inst.components.moisture:GetMoisture(), 0, -TUNING.MOISTURE_SANITY_PENALTY_MAX, inst.components.moisture:GetMaxMoisture())
	-- in the event you have other delta modifiers you can add them to the rest of the delta
	for k, v in pairs(inst.components.inventory.equipslots) do
		if v.components.equippable ~= nil and v:GetIsWet() then
			moisture_delta = moisture_delta - TUNING.WET_ITEM_DAPPERNESS --double negative again
		end
	end
	delta = delta + moisture_delta
	return delta
end
--master_postinit
inst.components.sanity.custom_rate_fn = sanityfn

 

Edited by IronHunter
equippables added
Link to comment
Share on other sites

1 hour ago, Lokoluna said:

I've tried this, keeps stating that self is not declared.

I derped up the copy and paste I guess, updated the code. The self is from the moisture component, as this is suppose to be used in the inst instead.

Link to comment
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
 Share

×
×
  • Create New...