Warcraft III resources & community, 2003–2006 · archived

TriggerRegisterGroupDeathEvent

not rated
Submitted by KaTTaNaCalculations0 downloads
Runs the given trigger every time the entire group is dead. Even if the contents of the group you entered changes, it will still work.

Note that it uses a group object, not a group variable. If you assign the variable in which the group was formerly stored to another group, the trigger will not register the death of the new group.

As an example, this can be used in Tower Defenses to notice when to launch the next wave of units. But it requires that the units are kept in the same group at all times.

Source

function TriggerRegisterGroupDeathEvent_Child takes nothing returns nothing
    local trigger t = bj_meleeVisibilityTrained
    local group   g = bj_groupAddGroupDest
    local boolean dead = IsUnitGroupDeadBJ(g)
    loop
        exitwhen (g == null) or (t == null)
        if IsUnitGroupDeadBJ(g) then
            if not dead  then
                call TriggerExecute(t)
            endif
            set dead = true
        else
            set dead = false
        endif
        call TriggerSleepAction(0.1)
    endloop
endfunction

function TriggerRegisterGroupDeathEvent takes trigger trig, group whichGroup returns nothing
    local trigger t = CreateTrigger()
    local trigger temp = bj_meleeVisibilityTrained
    set bj_meleeVisibilityTrained = trig
    
    call TriggerAddAction(t, function TriggerRegisterGroupDeathEvent_Child)
    set bj_groupAddGroupDest = whichGroup
    call TriggerExecute(t)
    call DestroyTrigger(t)
    
    set bj_meleeVisibilityTrained = temp
    set temp = null
    set t = null
endfunction

Comments

0

No comments.