function GetUnitsOfTypeIdAll takes integer unitid returns group
local group result = CreateGroup()
local group g = CreateGroup()
local integer index
set index = 0
loop
set bj_groupEnumTypeId = unitid
call GroupClear(g)
call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
call GroupAddGroup(g, result)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call DestroyGroup(g)
return result
endfunction