GroupEnumUnitsInQuad
not ratedSimilar to the GroupEnumUnitsInRect native, this function is used to put the units in a quad in a group. The quad is given by the locations of its vertices.
Uses IsLocInQuad
Uses IsLocInQuad
function GroupEnumUnitsInQuad takes group g, location l1, location l2, location l3, location l4, boolexpr filter returns nothing
local location lmin = Location(RMinBJ(RMinBJ(RMinBJ(GetLocationX(l1), GetLocationX(l2)), GetLocationX(l3)), GetLocationX(l4)), RMinBJ(RMinBJ(RMinBJ(GetLocationY(l1), GetLocationY(l2)), GetLocationY(l3)), GetLocationY(l4)))
local location lmax = Location(RMaxBJ(RMaxBJ(RMaxBJ(GetLocationX(l1), GetLocationX(l2)), GetLocationX(l3)), GetLocationX(l4)), RMaxBJ(RMaxBJ(RMaxBJ(GetLocationY(l1), GetLocationY(l2)), GetLocationY(l3)), GetLocationY(l4)))
local group hg = CreateGroup()
local rect r = RectFromLoc(lmin, lmax)
local unit u = null
local location l = null
call GroupEnumUnitsInRect(hg, r, filter)
loop
set u = FirstOfGroup(hg)
exitwhen u == null
set l = GetUnitLoc(u)
if IsLocInQuad(l, l1, l2, l3, l4) then
call GroupAddUnit(g, u)
endif
call RemoveLocation(l)
call GroupRemoveUnit(hg, u)
endloop
call DestroyGroup(hg)
call RemoveRect(r)
call RemoveLocation(lmin)
call RemoveLocation(lmax)
set hg = null
set r = null
set lmin = null
set lmax = null
set l = null
endfunctionNo comments.