Dranix Posted March 1, 2019 Share Posted March 1, 2019 (edited) I'm trying to make a custom character but I don't know how to code some parts. One of those parts is changing the damage multiplier and the speed multiplier based on the percentage of sanity the character has. I thought of a way to make this but I don't know how to translate this to code that DST can use. I also want to add the visual effect from the ancient walking cane when sanity is very low but I don't know how. I posted some unusable code down below to make it a bit more clear what I am trying to achieve. (Most of the multiplier values used below will most likely change after play testing.) Any help will be greatly appreciated. if (Current.SANITY <= 10% && Current.SANITY >= 0%) { speedmultiplier = 0.5 damagemultiplier = 1.75 add ancient walking cane effect } if (Current.SANITY <= 25% && Current.SANITY > 10%) { speedmultiplier = 0.8 damagemultiplier = 1.25 remove ancient walking cane effect } if (Current.SANITY <= 75% && Current.SANITY > 25%) { speedmultiplier = 1 damagemultiplier = 1 } if (Current.SANITY <= 90% && Current.SANITY > 75%) { speedmultiplier = 1.2 damagemultiplier = 0.75 } if (Current.SANITY <= 100% && Current.SANITY > 90%) { speedmultiplier = 1.60 damagemultiplier = 0.45 } Edited March 1, 2019 by Dranix Link to comment Share on other sites More sharing options...
CarlZalph Posted March 1, 2019 Share Posted March 1, 2019 (edited) local speedsource = "this_is_something_unique_that_you_should_change" inst:ListenForEvent( "sanitydelta", function(inst, data) local sanitypercent = inst.components.sanity:GetPercent() if sanitypercent <= 0.1 then inst.components.combat.damagemultiplier = 1.75 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 0.5) --[[ if <doesn't have sfx> then <apply sfx> end ]]-- else --[[ if <has sfx> then <remove sfx> end ]]-- if sanitypercent <= 0.25 then inst.components.combat.damagemultiplier = 1.25 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 0.8) elseif sanitypercent <= 0.75 then inst.components.combat.damagemultiplier = 1.0 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.0) elseif sanitypercent <= 0.90 then inst.components.combat.damagemultiplier = 0.75 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.2) else inst.components.combat.damagemultiplier = 0.45 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.6) end end end ) As for using Klei's skin sfx asset I'd recommend making your own instead. It starts going into gray area territory for skins and such. Edited March 1, 2019 by CarlZalph 'else if' -> 'elseif' Link to comment Share on other sites More sharing options...
Dranix Posted March 1, 2019 Author Share Posted March 1, 2019 32 minutes ago, CarlZalph said: local speedsource = "this_is_something_unique_that_you_should_change" inst:ListenForEvent( "sanitydelta", function(inst, data) local sanitypercent = inst.components.sanity:GetPercent() if sanitypercent <= 0.1 then inst.components.combat.damagemultiplier = 1.75 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 0.5) --[[ if <doesn't have sfx> then <apply sfx> end ]]-- else --[[ if <has sfx> then <remove sfx> end ]]-- if sanitypercent <= 0.25 then inst.components.combat.damagemultiplier = 1.25 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 0.8) elseif sanitypercent <= 0.75 then inst.components.combat.damagemultiplier = 1.0 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.0) elseif sanitypercent <= 0.90 then inst.components.combat.damagemultiplier = 0.75 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.2) else inst.components.combat.damagemultiplier = 0.45 inst.components.locomotor:SetExternalSpeedMultiplier(inst, speedsource, 1.6) end end end ) As for using Klei's skin sfx asset I'd recommend making your own instead. It starts going into gray area territory for skins and such. Thanks for the quick answer! Everything seems to work and not using Klei's sfx is a good call. Now I just need to balance and playtest this. Figuring out how to do effects is going to be a fun task but it will a task for another day. Link to comment Share on other sites More sharing options...
CarlZalph Posted March 2, 2019 Share Posted March 2, 2019 (edited) 8 hours ago, Dranix said: Figuring out how to do effects is going to be a fun task but it will a task for another day. You'll probably end up making a new prefab that has the sfx you'll be using and then having the code above create it, parent it, and keep tabs on it somewhere for quick removal. I'd personally recommend doing it like an aura effect- an animation of sorts that plays at the feet of the person. You can see it in this video here: Spoiler Functions that are useful: AnimState's :: SetOrientation, SetLayer, SetSortOrder, SetBuild, SetBank, PlayAnimation This was my crude remake of it and first time using Spriter. I'm not an artist nor am I familiar enough with Spriter to make it look decent. In fact, I scrapped Spriter entirely and made a script generate out the motion and had the autocompiler make it happen. Spriter's evil. vigorremake.mp4 Edited March 2, 2019 by CarlZalph 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