Jump to content

Recommended Posts

Use custom_rate_fn in your character's master_postinit:

inst.components.sanity.custom_rate_fn = sanityfn

Define a sanityfn in your character file that uses TheSim:FindEntities:

TheSim:FindEntities(x, y, z, radius, MUSTHAVETAGS, CANTHAVETAGS, MUSTHAVEONETAG)

MUSTHAVETAGS, CANTHAVETAGS and MUSTHAVEONETAG should be tables containing all tags to look for (and, not and or respectively).

So something like:

local function sanityfn(inst)
	local x, y, z = inst.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"mole"})
	local delta = 0
	for k, v in pairs(ents) do
		local distsq = math.max(inst:GetDistanceSqToInst(v), 1)
		delta = delta - TUNING.SANITYAURA_SMALL / distsq
	end
	return delta
end

 

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
×
  • Create New...