Jump to content

Recommended Posts

I hope some seniors can help me with this code
I am creating a character mod and am having trouble adding the ability to see in the dark (like when using Moggles) when below 70 Sanity
Using an attack weapon when below 70 Sanity will lose 1% durability but when testing my weapon always loses 1% regardless of whether it is below 70 Sanity or not. Here is my weapon code:


local function OnAttack(inst, attacker, target)
    if attacker and attacker.prefab == "blake" then
        local sanity = attacker.components.sanity and attacker.components.sanity.current or 0
        if sanity < 70 then
            inst.components.finiteuses:Use(1)
        else
            inst.components.finiteuses:Use(0)
        end
    end
    
    if inst.components.finiteuses:GetPercent() <= 0 then
        inst.components.weapon:SetDamage(1)
    else
        inst.components.weapon:SetDamage(inst._original_damage or 36)
    end
    
end

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...