Jump to content

New to scripting need a little help with a few things I would like to do for a character


Recommended Posts

I am creating a character that I would like to make it so she losses no sanity around Catoon, beefalo, birds, and chester the frog thing. I would also like to make it so she losses sanity more quickly while being around spiders. I am not sure if such a script could be made but If so I would love to know how to create a script like this. 

 

Thanks. - Xavier

Link to comment
Share on other sites

First of all. How does sanity drain aura work:

Sanity drain is caused by sanityaura component on the given PREFAB towards OBSERVER. That means if you want catcoon to give you sanity, then you have to:

1. AddPrefabPostInit("catcoon", ...)
2. check if catcoon has sanityaura component
2.2. if he does not - call AddComponent("sanityaura") on him
3. perform assignment inst.component.sanityaura.aurafn = YourSanityAuraFunction

To see an example you can open prefabs/spiderqueen.

The point is spider queen gives has sanity aura that affects everyone except webber, whats so special about webber? He has "spiderwhisperer" tag.

Thus, add a custom tag to your character aka "animalhater"

And within YourSanityAuraFunction, add the same stuff that prefabs/spiderqueen:CalcSanityAura function has:

local function YourSanityAuraFunction(inst, observer)
    return observer:HasTag("animalhater") and -TUNING.SANITYAURA_MEDIUM or 0
end

 

This way only your character will suffer sanity aura drain.

Edited by IvanX
Link to comment
Share on other sites

Note also, that you have to check if the animal already HAS some sort of inst.component.sanityaura.aurafn.

Incase it does you should do something like this:

local old_aurafn = inst.components.sanityaura.aurafn
local new_aurafn = function(inst, observer)
	return observer:HasTag("animalhater") and -TUNING.SANITYAURA_MEDIUM or old_aurafn
end
inst.components.sanityaura.aurafn = new_aurafn

 

Edited by IvanX
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...