StretchVanb Posted April 29, 2015 Share Posted April 29, 2015 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 https://forums.kleientertainment.com/forums/topic/53348-how-to-make-only-tamed-entities-give-out-a-sanity-aura/ Share on other sites More sharing options...
Developer PeterA Posted April 29, 2015 Developer Share Posted April 29, 2015 @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 https://forums.kleientertainment.com/forums/topic/53348-how-to-make-only-tamed-entities-give-out-a-sanity-aura/#findComment-633205 Share on other sites More sharing options...
DarkXero Posted April 29, 2015 Share Posted April 29, 2015 (edited) @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 April 29, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/53348-how-to-make-only-tamed-entities-give-out-a-sanity-aura/#findComment-633210 Share on other sites More sharing options...
Developer PeterA Posted April 29, 2015 Developer Share Posted April 29, 2015 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? Link to comment https://forums.kleientertainment.com/forums/topic/53348-how-to-make-only-tamed-entities-give-out-a-sanity-aura/#findComment-633238 Share on other sites More sharing options...
StretchVanb Posted April 30, 2015 Author Share Posted April 30, 2015 @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 https://forums.kleientertainment.com/forums/topic/53348-how-to-make-only-tamed-entities-give-out-a-sanity-aura/#findComment-633386 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now