Jump to content

Changing speed and damage according to sanity NEED CODE!


Recommended Posts

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

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

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 by Dranix
Autocorrect in An other language is stupid
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...