• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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,928
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