• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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