Jump to content

Recommended Posts

On 5/25/2024 at 9:03 PM, Bandit_Boyo said:

I wanna make a character who deals more damage the less sanity he has. Anyone got ideas on how I could achieve this?

 

local function checksanity(inst)
    local sanity = inst.components.sanity:GetPercent()
    if sanity ~= nil and not inst.components.health:IsDead() then
        if sanity == 1 then
            inst.components.combat.externaldamagemultipliers:RemoveModifier(inst, "damage_from_sanity")
        else
            local damage_multiplier = 2 * (1 - sanity)
            inst.components.combat.externaldamagemultipliers:SetModifier(inst, damage_multiplier, "damage_from_sanity")
        end
    end
end

In master_postinit

inst:ListenForEvent("sanitydelta", checksanity)

 

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