Warcraft III resources & community, 2003–2006 · archived

Count Units in a Group

not rated
Submitted by Nantuko_HuskCalculations0 downloads
Counts the number of units in a given group!

Source

///////////////////////////////////////////////////////////////////
//***************************************************************//
//                                                              *//
//  For more Jass Functions visit us at http://www.wc3jass.com  *//
//                                                              *//
//***************************************************************//
///////////////////////////////////////////////////////////////////
function CountUnitsInAGroup takes group g returns integer
local unit u
local integer i=0
local group g2
set g2=g
set u=FirstOfGroup(g2)
loop
exitwhen g2==null or u==null
if u!=null then
loop
exitwhen u==null or g2==null
set u=FirstOfGroup(g2)
set i=i+1
call GroupRemoveUnit(g2,u)
endloop
else
set i=1
set g2=null
endif
endloop
set u=null
call DestroyGroup(g2)
return i-1
endfunction   

Comments

3
What's the point of this? , Blizzard's function does the same and it would actually be faster than this


:? however i hadnt notice yet that blizzard had a similiar func! :(
What's the point of this? , Blizzard's function does the same and it would actually be faster than this
Oh, after DestroyGroup(g2) add a "set g2 = null". If not the function will still leak.

~Daelin