#How to check if a modifier is dispellable?

1 messages · Page 1 of 1 (latest)

hushed lintel
#

How can I check whether a modifier is dispellable or not?

This doesn't work because IsPurgable is a CDOTA_Modifier_Lua function

local modifiers = enemy:FindAllModifiers()
if #modifiers > 0 then
    for _,modifier in pairs(modifiers) do
        if not modifier:IsDebuff() and modifier:IsPurgable() then
            if caster:GetHealth() > hp_cost_per_modifier then
                caster:SetHealth(caster:GetHealth() - hp_cost_per_modifier)
                modifier_count = modifier_count + 1
                modifier:Destroy()
            end
        end
    end
end

This is for an ability that dispels an enemy target at the cost of the caster's hp for each debuff, so it stops dispelling when hp gets too low

Is there a way to do this without manually creating a list of dispellable modifiers?

lethal wing
#

probably not.
checking for modifier.IsPurgable and modifier:IsPurgable() should work for any custom modifier, but not for valves.

slate elk
#

Or use npc.purge(...) and check if the modifier is removed...

lethal wing
#

unless you want to change the ability to just dispel all and cost hp based on that instead of stopping when hp gets low

versed shell
#

the way I did it is by checking all the modifiers, Purge, then check again

lethal wing
slate elk
hushed lintel
hushed lintel
# slate elk Or use `npc.purge(...)` and check if the modifier is removed...

this messes with abilities that have timed effects like Cursed Crown, and causes modifiers that have effects when getting created to apply those effects again, like Shadow Strike's initial damage, so that's not an option

Guess I'll have to rework the ability then, too lazy to do a manual list of modifiers

lethal wing
#

they didnt say to reapply the modifiers. just to count the difference before and after purging.
but yeah, for what you want you'd need a list

#

unless you want to change how the ability works

hushed lintel
#

I saw Dota Imba went through that hassle of creating a list