FrontierHero Posted January 15, 2018 Share Posted January 15, 2018 I am working on a mod for a character, but I need help. I need to have the character lose sanity around ponds, but I do not know all the coding to do it. I know parts of what it would need, but I do not know the exact coding to have them lose sanity around a certain object. If anyone knows the coding needed on how to do this, I would really appreciate it! Thank you so much! Link to comment Share on other sites More sharing options...
CarlZalph Posted January 15, 2018 Share Posted January 15, 2018 At the bottom of my post there lies code that will do what you want with some very minor tweaking. Link to comment Share on other sites More sharing options...
pickleplayer Posted January 16, 2018 Share Posted January 16, 2018 I have a character that does exactly this! You can use the code from his modmain, it should work with yours too. local function CalcSanityAura(inst, observer) if observer.prefab == "kaji" then return -TUNING.SANITYAURA_HUGE else return 0 end end function AddSanityAura(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = CalcSanityAura end AddPrefabPostInit("pond", AddSanityAura) AddPrefabPostInit("pond_mos", AddSanityAura) AddPrefabPostInit("pond_cave", AddSanityAura) This takes the three different pond prefabs in the game and adds a negative sanity aura around them (like monsters have) but it ONLY drains sanity if their character prefab is Kaji (Clearly, you would switch Kaji to whatever your character's name is.) "-TUNING.SANITYAURA_HUGE" is an existing variable in the game, and there are others like _SMALL or others like that at the end of them. But you can also just throw in any regular old number in there instead. Link to comment Share on other sites More sharing options...
FrontierHero Posted January 16, 2018 Author Share Posted January 16, 2018 On 1/15/2018 at 1:39 PM, CarlZalph said: At the bottom of my post there lies code that will do what you want with some very minor tweaking. thank you very much for this!! much appreciated! I will save this as a sanity-drain default code to change up a bit whenever I need to for other mods; thank you! 23 hours ago, pickleplayer said: I have a character that does exactly this! You can use the code from his modmain, it should work with yours too. local function CalcSanityAura(inst, observer) if observer.prefab == "kaji" then return -TUNING.SANITYAURA_HUGE else return 0 end end function AddSanityAura(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = CalcSanityAura end AddPrefabPostInit("pond", AddSanityAura) AddPrefabPostInit("pond_mos", AddSanityAura) AddPrefabPostInit("pond_cave", AddSanityAura) This takes the three different pond prefabs in the game and adds a negative sanity aura around them (like monsters have) but it ONLY drains sanity if their character prefab is Kaji (Clearly, you would switch Kaji to whatever your character's name is.) "-TUNING.SANITYAURA_HUGE" is an existing variable in the game, and there are others like _SMALL or others like that at the end of them. But you can also just throw in any regular old number in there instead. thank you SO MUCH for sharing all this with me, very helpful! thank you for the tips on changing the aura-area size as well! much appreciated!! Link to comment Share on other sites More sharing options...
CarlZalph Posted January 17, 2018 Share Posted January 17, 2018 @pickleplayer I'd recommend checking out my posting, as the code I posted in the other thread will be more compatible with other mods should multiple mods try to add their own custom rates in it. As it stands if anyone else does the same for yours, then the last loaded mod will override the function for the prefab. Link to comment 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