Warcraft III resources & community, 2003–2006 · archived

GetRectContainingGroup

not rated
Submitted by YoumaFunctions0 downloads
Takes a unit group and returns the smallest possible rect (square region) containing all units in the group.

Not sure if I have cleaned up the leaks propperly, am a bit of a JASS-newb.

Source

function GetRectContainingGroupExec takes group gtemp returns rect
   local unit utemp = FirstOfGroup(gtemp)
   local rect r = null
   call GroupRemoveUnitSimple(utemp, gtemp)
   if ( FirstOfGroup(gtemp) == null ) then
       call DestroyGroup(gtemp)
       set r = Rect(GetUnitX(utemp),GetUnitY(utemp),GetUnitX(utemp),GetUnitY(utemp))
       return r
   endif
   set r = GetRectContainingGroupExec(gtemp)
   set r = Rect(RMinBJ(GetUnitX(utemp),GetRectMinX(r)), RMinBJ(GetUnitY(utemp),GetRectMinY(r)), RMaxBJ(GetUnitX(utemp),GetRectMaxX(r)), RMaxBJ(GetUnitY(utemp),GetRectMaxY(r)))
   return r
endfunction

function GetRectContainingGroup takes group g returns rect
    local group gtemp = CreateGroup()
    call GroupAddGroup(g, gtemp)
    return GetRectContainingGroupExec(gtemp)
endfunction

Comments

0

No comments.