Jump to content

Recommended Posts

    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)

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 by HarryPPP
  • Like 1

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
×
  • Create New...