MangoMars Posted August 10, 2022 Share Posted August 10, 2022 Hi there! I'm making my first character mod, and he's a weird little man, so I was wondering if there was a way to code him gaining sanity by killing humanoid things like that? It's probably simple, but my brain just isn't working lately, and this is the last thing I need to do for him, coding wise. Link to comment https://forums.kleientertainment.com/forums/topic/142517-sanity-gain-by-killing-pigs-merms-or-bunny-men/ Share on other sites More sharing options...
Goregonzola Posted August 11, 2022 Share Posted August 11, 2022 Hey-hey! I have a similar perk used in of my mods. It looks like this: Spoiler -- Kill penalty local function OnKill(victim,inst) if victim and victim.prefab then if victim.prefab == "rabbit" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "butterfly" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "pigman" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "bunnyman" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "rocky" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "catcoon" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "mole" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "lightninggoat" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "deer" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "grassgekko" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "fruitdragon" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "chester" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end end end inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end ) Add or remove certain mobs if you want and change the TUNING.SPINELKILL to the value you want to get by the killing. This code belongs into the character's lua file, inside the master_postinit section. Cheers! Link to comment https://forums.kleientertainment.com/forums/topic/142517-sanity-gain-by-killing-pigs-merms-or-bunny-men/#findComment-1593665 Share on other sites More sharing options...
MangoMars Posted August 11, 2022 Author Share Posted August 11, 2022 10 hours ago, C_Thun said: Hey-hey! I have a similar perk used in of my mods. It looks like this: Hide contents -- Kill penalty local function OnKill(victim,inst) if victim and victim.prefab then if victim.prefab == "rabbit" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "butterfly" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "pigman" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "bunnyman" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "rocky" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "catcoon" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "mole" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "lightninggoat" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "deer" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "grassgekko" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "fruitdragon" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end if victim.prefab == "chester" then inst.components.sanity:DoDelta(TUNING.SPINELKILL) end end end inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end ) Add or remove certain mobs if you want and change the TUNING.SPINELKILL to the value you want to get by the killing. This code belongs into the character's lua file, inside the master_postinit section. Cheers! Hi! Thank you so so much! It works perfectly! You're a life saver! Seriously, thanks! 1 Link to comment https://forums.kleientertainment.com/forums/topic/142517-sanity-gain-by-killing-pigs-merms-or-bunny-men/#findComment-1593784 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