Jump to content

How to make only tamed entities give out a sanity aura?


Recommended Posts

I am currently trying to keep working on my catcoon sanity mod, and i am trying to balance it by making catcoons only give out a sanity aura when tamed.

My current code is as follows: 

local function CalcSanityAura(inst, observer)   return GLOBAL.TUNING.SANITYAURA_SMALLendlocal function bond(inst)   inst.components.trader.onaccept = inst:AddComponent("sanityaura")   inst.components.sanityaura.aurafn = CalcSanityAura end  AddPrefabPostInit("catcoon", bond)

Also, sorry to bother you guys again. I am pretty new to this modding thing.

Link to comment
Share on other sites

  • Developer

@StretchVanb,

 

You'll need to change your bond function to assign a function to onaccept, not the result of AddComponent. Inside the function, is where you want to add the component.

 

local function CalcSanityAura(inst, observer)   return GLOBAL.TUNING.SANITYAURA_SMALLendlocal function OnGetItemFromPlayer(inst, giver, item)    inst:AddComponent("sanityaura")    inst.components.sanityaura.aurafn = CalcSanityAuraendlocal function bond(inst)    inst.components.trader.onaccept = OnGetItemFromPlayerendAddPrefabPostInit("catcoon", bond)
Hope this works out for you!
Link to comment
Share on other sites

@PeterA, your code works, but the sanity aura persists when the catcoon loses loyalty.

 

I suggest:

-- Pick one CalcSanityAura-- This is only sanity aura for the tamerlocal function CalcSanityAura(inst, observer)	if inst.components.follower and (inst.components.follower.leader == observer) then		return GLOBAL.TUNING.SANITYAURA_TINY	else		return 0	endend-- This is sanity aura for everybody when tamedlocal function CalcSanityAura(inst, observer)	if inst.components.follower and inst.components.follower.leader then		return GLOBAL.TUNING.SANITYAURA_TINY	else		return 0	endend local function cute(inst)    inst:AddComponent("sanityaura")    inst.components.sanityaura.aurafn = CalcSanityAuraend AddPrefabPostInit("catcoon", cute)

Like pigs, actually. :-)

Edited by DarkXero
Link to comment
Share on other sites

  • Developer

your code works, but the sanity aura persists when the catcoon loses loyalty

Correct :-) I should have mentioned that in my previous post. Maybe that was StretchVanb's intention. Memories of playing with my pet cat when I was kid still make me happy, so why not with this Catcoon change? :grin:

Link to comment
Share on other sites

@PeterA, your code works, but the sanity aura persists when the catcoon loses loyalty.

 

I suggest:

-- Pick one CalcSanityAura-- This is only sanity aura for the tamerlocal function CalcSanityAura(inst, observer)	if inst.components.follower and (inst.components.follower.leader == observer) then		return GLOBAL.TUNING.SANITYAURA_TINY	else		return 0	endend-- This is sanity aura for everybody when tamedlocal function CalcSanityAura(inst, observer)	if inst.components.follower and inst.components.follower.leader then		return GLOBAL.TUNING.SANITYAURA_TINY	else		return 0	endend local function cute(inst)    inst:AddComponent("sanityaura")    inst.components.sanityaura.aurafn = CalcSanityAuraend AddPrefabPostInit("catcoon", cute)

Like pigs, actually. :-)

Thanks for all your help. And yes, it was my intention to make them constantly give a sanity aura. 

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...