AgentX Posted October 26, 2023 Share Posted October 26, 2023 How do i increase my modded characters speed as his health decreases? Link to comment Share on other sites More sharing options...
_zwb Posted October 27, 2023 Share Posted October 27, 2023 (edited) -- In your character's file local function set_speed(inst) local percent = inst.components.health:GetPercent() -- This sets your character's speed to default speed * (1 / health percentage) inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * (1 / percent) end -- Your character's main function local function fn() inst:ListenForEvent("healthdelta", set_speed) end Edited October 27, 2023 by _zwb fixed math Link to comment Share on other sites More sharing options...
AgentX Posted October 28, 2023 Author Share Posted October 28, 2023 (edited) where in my file, and how does it work, because i want my speed multiplyer to go up .1 every ten health he loses, and his speed multiplyer defaultly is 1.25, this is my characterwhirlwind.luas prefab @_zwb Edited October 28, 2023 by AgentX Link to comment Share on other sites More sharing options...
_zwb Posted October 29, 2023 Share Posted October 29, 2023 (edited) --snip-- local function set_speed(inst) --[[ Use inst.components.health.maxhealth instead of GetMaxwithPenalty would give your character speed boost, if they have penalty and health is at full --]] local health_lost = inst.components.health:GetMaxWithPenalty() - inst.components.health.currenthealth -- Used math.floor so that your character only get speed boost every 10 hp lost, rather than continuous boost inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whirlwind_speed_mod", 1.25 + 0.1 * math.floor(health_lost/10) ) end local master_postinit = function(inst) -- snip -- inst:ListenForEvent("healthdelta", set_speed) inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("whirlwind", prefabs, assets, common_postinit, master_postinit, prefabs) Edited October 29, 2023 by _zwb Link to comment Share on other sites More sharing options...
AgentX Posted October 31, 2023 Author Share Posted October 31, 2023 thanks, and do you know if there is a way to make him take double overheating damage? @_zwb Link to comment Share on other sites More sharing options...
_zwb Posted October 31, 2023 Share Posted October 31, 2023 1 hour ago, AgentX said: if there is a way to make him take double overheating damage? local master_postinit = function(inst) --snip-- inst.components.temperature:SetOverheatHurtRate(2.0) --snip-- end Link to comment Share on other sites More sharing options...
AgentX Posted November 1, 2023 Author Share Posted November 1, 2023 (edited) thanks, and one more thing, he can craft and read the wickerbottom books, but how do i make it so he takes double sanity drain, just from the books Edited November 1, 2023 by AgentX Link to comment Share on other sites More sharing options...
AgentX Posted November 4, 2023 Author Share Posted November 4, 2023 the speed thing is not working, could you edit that file above with the speed thing and please send it back to me @_zwb Link to comment Share on other sites More sharing options...
_zwb Posted November 5, 2023 Share Posted November 5, 2023 @AgentXwhirlwind.lua Link to comment Share on other sites More sharing options...
AgentX Posted November 6, 2023 Author Share Posted November 6, 2023 (edited) Thanks for all your help, but is there any way for him to take double sanity depletion from items, such as the rods @_zwb Edited November 6, 2023 by AgentX Link to comment Share on other sites More sharing options...
_zwb Posted November 6, 2023 Share Posted November 6, 2023 (edited) 8 hours ago, AgentX said: Thanks for all your help, but is there any way for him to take double sanity depletion from items, such as the rods @_zwb By rods you mean staff like star caller staves? You can do it like this: Spoiler function master_postinit(inst) inst:AddComponent("staffsanity") inst.components.staffsanity:SetMultiplier(2) -- double sanity drain Edited November 6, 2023 by _zwb Link to comment Share on other sites More sharing options...
AgentX Posted November 8, 2023 Author Share Posted November 8, 2023 (edited) im getting this error, havent been able to play dst till today @_zwb whirlwind11-9-23.zip Edited November 9, 2023 by AgentX 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