SZTEFEN Posted July 2, 2024 Share Posted July 2, 2024 Hi everyone, I'm working on a character mod for DST and need some assistance. The character typically has 2x speed (I know it seems overpowered, but I've balanced it by nerfing other stats). However, I want to add a mechanic where the character's speed decreases based on the damage absorption percentage of the armor they wear. Specifically, I want the character's speed to be reduced such that with an armor that absorbs around 80% of damage, the character's speed drops to 0.75x (compared to Wilson's standard speed). How can I implement this mechanic in my mod? Thanks in advance for your help! Link to comment https://forums.kleientertainment.com/forums/topic/157831-need-help-with-character-mod-adjusting-speed-based-on-armor/ Share on other sites More sharing options...
alainmcd Posted July 5, 2024 Share Posted July 5, 2024 Welcome to the forums! Something like this should do the trick: -- Somewhere in your character .lua file, before the master_postinit function: local function onequip(inst, data) if data.components.armor ~= nil then local absorb_percent = data.components.armor.absorb_percent local speed_multiplier = 1 - absorb_percent * .5 -- Here your logic to modify the speed. inst.components.locomotor:SetExternalSpeedMultiplier( inst, "mycharacter_armor_" .. data.eslot, -- We want to distinguish head gear and body armour, so we know which multiplier to remove when unequipping a piece of armour. speed_multiplier ) end end local function onunequip(inst, data) if data.components.armor ~= nil then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "mycharacter_armor_" .. data.eslot) end end -- In the master_postinit function your character .lua file: inst:ListenForEvent("equip", onequip) inst:ListenForEvent("unequip", onunequip) Wolfgang has a good chuck of the logic you want, just organised a little differently. Hope this helps! Disclaimer: untested. Happy modding! Link to comment https://forums.kleientertainment.com/forums/topic/157831-need-help-with-character-mod-adjusting-speed-based-on-armor/#findComment-1732936 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