GroupToUnitpool
not ratedReturns a unitpool containing all the unit-types existant in the group. All the unittypes will have equal weight.
function GroupToUnitpool takes group whichGroup returns unitpool
local unitpool result = CreateUnitPool()
local unit u
local group g = CreateGroup()
local integer array id
local integer n
local integer num = 0
local boolean add
call GroupAddGroup(whichGroup, g)
loop
set u = FirstOfGroup(g)
exitwhen u == null
set add = true
set n = 0
loop
exitwhen id[n] <= 0
if ( id[n] == GetUnitTypeId(u) ) then
set add = false
exitwhen true
endif
set n = n + 1
endloop
if ( add ) then
set id[n] = GetUnitTypeId(u)
set num = num + 1
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
set n = 0
loop
exitwhen id[n] <= 0
call UnitPoolAddUnitType(result, id[n], 1.00/num)
set n = n + 1
endloop
return result
endfunctionNo comments.