| 04-05-2007, 05:25 PM | #1 |
For some reason, about 10~ minutes into my game, FirstOfGroup in one of my functions fails. It just stops working. According to my second DebugMsg, the number of units in AttackForce1 is always > 1, which leads me to my question of why would FirstOfGroup return a null to a group that has generally around 20~ units. Here is the function if anyone is interested: JASS:function IssueOrder takes nothing returns nothing local unit u = FirstOfGroup(AttackForce1) local location l = XYAttack('u003', "a") local location l2= XYAttack('h00D', "u") local real x = GetLocationX(l) local real y = GetLocationY(l) if u == null then call BJDebugMsg("u == null") call BJDebugMsg(I2S(CountUnitsInGroup(AttackForce1)) + " units in AttackForce1") endif if CountUnitsInGroup(AttackForce1) > 8 then loop exitwhen u == null set u = FirstOfGroup(AttackForce1) call GroupRemoveUnit(AttackForce1, u) call IssuePointOrder(u, "attack", x, y) endloop endif set x = GetLocationX(l2) set y = GetLocationY(l2) set u = FirstOfGroup(AttackForce2) if u == null then call BJDebugMsg("u == null") call BJDebugMsg(I2S(CountUnitsInGroup(AttackForce2)) + " units in AttackForce2") endif if CountUnitsInGroup(AttackForce2) > 8 then loop exitwhen u == null set u = FirstOfGroup(AttackForce2) call GroupRemoveUnit(AttackForce2, u) call IssuePointOrder(u, "attack", x, y) endloop endif call RemoveLocation(l) call RemoveLocation(l2) set l = null set l2= null set u = null endfunction |
| 04-05-2007, 05:56 PM | #2 |
uhm, is AttackForce a global variable? if yes you forgot to make the "udg_" before the name, if it's a local, where did you init it? I almost 100% sure, that it's a problem with the variable not the Function. |
| 04-05-2007, 06:02 PM | #3 |
If a unit inside a group dies or is removed then FirstOfGroup might return null sometimes or even ghosts. But ForGroup should actually fix it. My lucky guess here is that somewhere else you are setting bj_wantDestroyGroup to true but forget to actually call a function that uses it. |
