[Lua] Getting the max HP of a unit breaks my code

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,921
I'm creating a bossfight and I wanna make the boss more aggressive reducing the check interval from 2 seconds to 1 when its life becomes lower, but for some reason this trigger breaks my code and i don't know why, this is the code (Not entirely):
Lua:
OnMapInit(function ()
    local boss = gg_unit_O060_0442 ---@type unit
    -- The chances of casting increases when has low hp
    local halfHP = BlzGetUnitMaxHP(boss) / 2
    lowHP = CreateTrigger()
    TriggerRegisterUnitLifeEvent(lowHP, boss, LESS_THAN_OR_EQUAL, halfHP)
    TriggerAddAction(function ()
        INTERVAL = 1.
        currentTimer:remove()
        currentTimer = Timed.echo(BossFightActions, INTERVAL)
        DisableTrigger(lowHP)
    end)
end)
 
Status
Not open for further replies.
Top