Magalise Posted February 28, 2018 Share Posted February 28, 2018 (edited) Hello! I am making my first character mod, but I have some issues with introducing the character´s perks (damage boost when insane) What i want is the character to get a damage multiplier when at 30 sanity (out of 100). I am going for wilson´s base damage multiplier, so it would be a X2 multiplier when at 30 or less sanity. I also want the character to announce when they reach the 30 or less sanity ("I am the madness!"), and also say something again when above 40 sanity. Is this possible at all? I have found a few strings for DST, but when i paste them into the prefab.lua of my character for DS it crashes the game. the string i found was: Spoiler local function lowsanity(inst) inst.components.combat.damagemultiplier = 2 end local function highsanity(inst) inst.components.combat.damagemultiplier = 1 end local function onsanitychange(inst, data) if inst.components.sanity.current <= 30 then if not inst.isBody then lowsanity(inst) inst.components.talker:Say("I am the madness!") inst.isBody = true end elseif inst.components.sanity.current >= 40 then if inst.isBody then highsanity(inst) inst.components.talker:Say("have i gone mad?",3) inst.isBody = false end end inst.isBody = false inst:ListenForEvent("sanitydelta", onsanitychange) end I would greatly appreciate it if anyone could help me with this. thank you in advance. Edited March 1, 2018 by Magalise Link to comment https://forums.kleientertainment.com/forums/topic/88163-solved-help-please-with-coding/ Share on other sites More sharing options...
K1NGT1GER609 Posted March 1, 2018 Share Posted March 1, 2018 Here: local function onsanitychange(inst) if inst.components.sanity:GetPercent() <= .30 then inst.components.combat.damagemultiplier = 2 inst.components.talker:Say("I am the madness!") elseif inst.components.sanity:GetPercent() >= .40 then inst.components.combat.damagemultiplier = 1 inst.components.talker:Say("have i gone mad?") else inst.components.combat.damagemultiplier = 1 end end local fn = function(inst) --reference on where it goes this is your main for your character inst:DoPeriodicTask(5, onsanitychange, nil, inst) --the 5 is in seconds, its change-able Link to comment https://forums.kleientertainment.com/forums/topic/88163-solved-help-please-with-coding/#findComment-1009765 Share on other sites More sharing options...
Magalise Posted March 1, 2018 Author Share Posted March 1, 2018 @K1NGT1GER609 thank you so much! It works like a charm! Link to comment https://forums.kleientertainment.com/forums/topic/88163-solved-help-please-with-coding/#findComment-1009828 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