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!
Okey tried to follow a tutorial about group iterations but it doesn't work..
JASS:
private function OnTimerEnd takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(playerHungryUnits[pNum])
exitwhen u == null
call GroupRemoveUnit(playerHungryUnits[pNum], u)
if UnitAlive(u) then
call BJDebugMsg("readded")
call GroupAddUnit(swap, u)
endif
if pNum == 0 then
call BJDebugMsg(GetUnitName(u))
endif
endloop
call BJDebugMsg("--------------")
set temp = playerHungryUnits[pNum]
set playerHungryUnits[pNum] = swap
set swap = temp
if pNum < 12 then
set pNum = pNum + 1
else
set pNum = 0
endif
endfunction
It runs twice for player 0 then there apears to be no more units in the group...
Until they're removed from the game, they're certainly not.
Try use a pick units in an area, it still count dead units (tested this on my map a while back). Of course, if you put a parameter to exclude them they don't get counted
Until they're removed from the game, they're certainly not.
Try use a pick units in an area, it still count dead units (tested this on my map a while back). Of course, if you put a parameter to exclude them they don't get counted
even removed unit stay inside groups, there is no way for them to be removed, because the underlying representation of unit has no idea about anything called group, and to automatically remove unit from all groups, the unit would need to know all the groups it is in, and then remove itself proprely from them
As edo said, shadow references will stay in the unit group's memory. They won't be enumerated with ForGroup(), but FirstOfGroup() loops will eventually hit them--and the unit handle will return null, causing a premature exit. However, you can use something similar to GroupRefresh (link) to get rid of those references.
You can modify GroupRefresh to remove dead units as well. Dead units aren't considered shadow references--not until the game removes them (e.g. after corpse decay), so you can tweak the refresh to remove them sooner.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.