Warcraft III resources & community, 2003–2006 · archived

GetUnitsSelectedInCondition

not rated
Submitted by AltSubmitterFunctions0 downloads
This is to get around a small TFT bug. If you call GetUnitsSelectedAll, the built-in bj function, inside a condition, the condition won't finish executing and your trigger won't run. This is because GetUnitsSelectedAll calls SyncSelections(), which for some reason doesn't work inside condition functions. This function uses the common.j function IsUnitSelected so it actually works inside conditions. It uses IterateGroup, but it has been inlined.

Source

function GetUnitsSelectedInCondition takes player whichPlayer returns group
    local group playerunits = GetUnitsOfPlayerAll(whichPlayer)
    local group returngroup = CreateGroup()
    local unit tempunit = null

    loop
        set tempunit = FirstOfGroup(playerunits)
        exitwhen tempunit == null

        if(IsUnitSelected(tempunit, whichPlayer)) then
            call GroupAddUnitSimple(tempunit, returngroup)
        endif

        call GroupRemoveUnitSimple(tempunit, playerunits)
        set tempunit = null
    endloop

    call DestroyGroup(playerunits)

    return returngroup
endfunction

Comments

0

No comments.