- Joined
- Apr 27, 2011
- Messages
- 272
looping through a group of units using the FirstOfGroup function or conventionaly enuming units?
function Start takes integer a, integer b returns nothing
loop
set u = FirstOfGroup(g)
exitwhen (u == null)
call GroupRemoveUnit(g, u)
//actions
endloop
endfunction
function Enum takes nothing returns nothing
local integer a = A
local integer b = B
//actions
endfunction
function Start takes integer a, integer b, code c returns nothing
set A = a
set B = b
call ForGroup(g, c)
endfunction
loop
set target=FirstOfGroup(affected)
exitwhen target==null
call GroupRemoveUnit(affected,target)
if(IsUnitEnemy(target,pl))then
call SetUnitX(caster,GetUnitX(target))
call SetUnitY(caster,GetUnitY(target))
call IssueTargetOrder(caster,orderstr,target)
endif
endloop
Well the caster shouldn't be issuing the order there, because the
order won't execute in sufficient time to deal it out to every single
picked.
loop
set target=FirstOfGroup(affected)
exitwhen target==null
call GroupRemoveUnit(affected,target)
if(IsUnitEnemy(target,pl))then
call UnitAddAbility(caster,spellid)
call SetUnitX(caster,GetUnitX(target))
call SetUnitY(caster,GetUnitY(target))
call IssueTargetOrder(caster,orderstr,target)
call UnitRemoveAbility(caster,spellid)
endif
endloop