Dranix Posted October 4, 2017 Share Posted October 4, 2017 I need some code for a idea I made but I"m not really well know with the code of DST. What I want is for a character mod and is this: When SANITY is ≥70% -set SPEED 1.3 When SANITY is <70% and >40% -set SPEED 1 When SANITY is <40% -set SPEED 0.8 -set DAMAGE 1.5 -Add Ancient_Cane_FX When above 40% Ancient_Cane_FX should be gone. Thank you for viewing and helping ! Link to comment Share on other sites More sharing options...
RedHairedHero Posted October 4, 2017 Share Posted October 4, 2017 This function must be placed somewhere above your common_postinit function inside your prefab file. local function boost(inst) if inst.components.sanity.current >= 70% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 + .30 ) else if inst.components.sanity.current < 70% of your max sanity and inst.components.sanity.current >= 40% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 ) else if inst.components.sanity.current < 40% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 - .20 ) inst.components.combat.damagemultiplier = 1.50 end end This goes into your master_postinit function inside your prefab file. inst:ListenforEvent("sanitydelta", boost) Just replace the parts I bolded and italicized and I don't have the game files available so I can't help with the ancient cane effect. Link to comment Share on other sites More sharing options...
Dranix Posted October 5, 2017 Author Share Posted October 5, 2017 (edited) 17 hours ago, RedHairedHero said: This function must be placed somewhere above your common_postinit function inside your prefab file. local function boost(inst) if inst.components.sanity.current >= 70% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 + .30 ) else if inst.components.sanity.current < 70% of your max sanity and inst.components.sanity.current >= 40% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 ) else if inst.components.sanity.current < 40% of your max sanity then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "yourcharactername_speed_mod", 1 - .20 ) inst.components.combat.damagemultiplier = 1.50 end end This goes into your master_postinit function inside your prefab file. inst:ListenforEvent("sanitydelta", boost) Just replace the parts I bolded and italicized and I don't have the game files available so I can't help with the ancient cane effect. Thank you for the code, I will check if it works as soon as i get home but i do have 1 problem. I wanted a % because my character has changing max sanity during the seasons. Is there a code for % or should I just do pure numbers? Edited October 5, 2017 by Dranix Autocorrect in An other language is stupid Link to comment Share on other sites More sharing options...
ptr Posted October 5, 2017 Share Posted October 5, 2017 you can use inst.components.sanity:GetPercent() instead 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