Jump to content

Recommended Posts

Hi. I'm trying to make the character take more damage. Several years ago I made a mod in which I managed to do this. But I lost this mod and now I don't remember how I did it. I try to do it with this:

inst.components.health.absorb = -0.5

But "absorb" doesn't seem to work anymore to increase damage, only to decrease.

Edited by sjtdhiqbwczfzpu
solved
2 hours ago, Combustiblemon said:

inst.components.health.externalabsorbmodifiers:Set(-0.5)

maybe this?

absorb and playerabsorb are deprecated, as written in health.lua.

I already tried this, the game just crashes

"absorb" and "playerabsorb" are deprecated, but it still work for absorb damage

local function HealthDeltaPlus(inst, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb)
    if not ignore_invincible and (self.invincible or self.inst.is_teleporting) then
        return 0
    elseif amount < 0 and not ignore_absorb then
        amount = amount * math.clamp(1 - (self.playerabsorb ~= 0 and afflicter ~= nil and afflicter:HasTag("player") and self.playerabsorb + self.absorb or self.absorb), 0, 1) * math.clamp(1 - self.externalabsorbmodifiers:Get(), 0, 1) * 1.5
    end

    local old_percent = inst.components.health:GetPercent()
    inst.components.health:SetVal(inst.components.health.currenthealth + amount, cause, afflicter)
    local new_percent = inst.components.health:GetPercent()

    inst:PushEvent("healthdelta", { oldpercent = old_percent, newpercent = new_percent, overtime = overtime, cause = cause, afflicter = afflicter, amount = amount })

    if inst.components.health.ondelta ~= nil then
        inst.components.health.ondelta(inst, old_percent, new_percent)
    end
    return amount
end

================================

inst.components.health.redirect = HealthDeltaPlus

You're right, absorb/playerabsorb/externalmodifiers can only "absorb" damage(because they has math.clamp), so I had to redirect entire healthdelta.

  • Thanks 1
5 hours ago, Combustiblemon said:

You're right, absorb/playerabsorb/externalmodifiers can only "absorb" damage(because they has math.clamp), so I had to redirect entire healthdelta.

Yes, I suspected that this was the cause of the problem, but my knowledge was not enough to solve it. I replaced all "self" to "inst.components.health" and now it works for me.

Thanks.

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