Jump to content

no sanity drop around spiders but retain hostility


Recommended Posts

Hello!

 

Im working on a new character that isnt afraid of spiders, and therefore wont have a sanity drop around them. I am using the line

	inst:AddTag("spiderwhisperer")

(under master_postinit, got the code from webbers lua) to do this, and it works; there is no sanity drop. however spiders are not hostile towards the character. is ther any code that will remove the sanity drop but keep the hostility? spider still leave their den when approaching but dont attack, and just go back into their nest. Im looking for (I guess "Hoping for" is a better statement) for something simple to copy and paste, though if its a more complex thing than that then im willing to learn :) thank you very much for the help! if i need to post anything from my mod then I can.

Link to comment
Share on other sites

You could override the sanity aurafn of all of the spiders and add a new tag to your character.

local spiders = { -- Every spider in a table
	"spider",
	"spider_warrior",
	"spider_hider",
	"spider_spitter",
	"spider_dropper",
	"spider_moon",
	"spiderqueen"
}

for i, v in pairs(spiders) do -- For statement for every spider in the table
	AddPrefabPostInit(v, function(inst) -- Override the prefab
		if inst.components.sanityaura then
			if inst.prefab == "spiderqueen" then -- Spider queen has a higher sanity drain so you need a different function for it
				local function CalcSanityAura(inst, observer)
					return (observer:HasTag("spiderwhisperer") or observer:HasTag("nospiderbooboo")) and 0 or -TUNING.SANITYAURA_HUGE -- Overriding the CalcSanityAura by adding a check for a new tag (you can name the tag whatever you want)
				end
				
				inst.components.sanityaura.aurafn = CalcSanityAura
			else -- Every other spider
				local function CalcSanityAura(inst, observer)
					return (observer:HasTag("spiderwhisperer") or observer:HasTag("nospiderbooboo")) and 0 or inst.components.sanityaura.aura
				end
				
				inst.components.sanityaura.aurafn = CalcSanityAura
			end
		end
	end)
end

 

And add the new tag to your character:

inst:AddTag("nospiderbooboo")

 

  • Like 2
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...