• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to count units in a group?

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Just using 'Count Units in UnitGroup' is best I guess

Alright. Does it cause leak if using it like this?
JASS:
call GroupEnumUnitsInRange(g,x,y,800.,function groupfilter)
set z=I2R(CountUnitsInGroup(g))
set damm=dam/z
loop
  set u=FirstOfGroup(g)
  exitwhen u==null
  call GroupRemoveUnit(g,u)
  call UnitDamageTarget(target,u,damm,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEMOLITION,null)
endloop
call DestroyGroup(g)    
set g=null
set dam=0
 
Level 11
Joined
Oct 11, 2012
Messages
711
I guess, if you use your own (already existing) UnitGroup, it wont leak.

But if you create a new one it will I think,.. like Count all Units in Playable Map area (so you create a new group)

Edit: but I'm not quite sure for that, only my thoughts

Yea, thats what confuses me. Whether using an already existing group would cause leak.
Thanks anyway. +Rep

Edit:
@TriggerHappy, thanks for the clarification.
One more question: whether using an already existing group would cause leak? Like the one in the script I posted above?
 
Status
Not open for further replies.
Top