GHOST_3O5 Posted July 19, 2021 Share Posted July 19, 2021 So I'm trying to mod one of my ocs into Don't Starve (this is my first time btw). And I want her to become weaker when she's wet. Can anyone help me? Link to comment https://forums.kleientertainment.com/forums/topic/131971-character-perk-weaker-when-wet/ Share on other sites More sharing options...
GearBull Posted July 19, 2021 Share Posted July 19, 2021 inst:DoTaskInTime( 0.1, function(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / 2 end end end) Try something like this, put it into master_postinit which can be found in character's prefab file (yourcharactername.lua) Link to comment https://forums.kleientertainment.com/forums/topic/131971-character-perk-weaker-when-wet/#findComment-1480112 Share on other sites More sharing options...
HarryPPP Posted July 19, 2021 Share Posted July 19, 2021 (edited) 6 hours ago, GearBull said: inst:DoTaskInTime( 0.1, function(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / 2 end end end) Try something like this, put it into master_postinit which can be found in character's prefab file (yourcharactername.lua) First of all, that code is not very good. It is unecessary processing taken, checking every 0.1 seconds. Also, the "inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / 2" would make so every time the game checks, your damage would get 50% lower. Meaning that it would be 1, 0.5, 0.25 and going lower... A more efficient and optimized way to do that would be: -- Place this under master_postinit. inst:ListenForEvent("moisturedelta", function() local m = inst.components.moisture:GetMoisture() -- Get your current moisture. if m > 0 then -- If moisture is higher than that number, do: inst.components.combat.damagemultiplier = .75 -- This makes your damage 25% weaker. Value can be whatever. else inst.components.combat.damagemultiplier = 1 -- Your normal damage. end end) The code above happens only when your moisture changes, instead of constantly repeating itself. And also, when you are not wet, it'll change your character's damage back to normal (1 in this example). Hope I helped! If you have any more questions, don't mind asking! Edited July 19, 2021 by HarryPPP 1 Link to comment https://forums.kleientertainment.com/forums/topic/131971-character-perk-weaker-when-wet/#findComment-1480172 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