Hey there.
I was wondering if anyone knows what could be the problem.
I made a loop, and for some reason it's not corresponding correctly and it might even be an infinite loop, but I don't see why.
The only debug messages that show up ingame are "passed the spellcheck" and "inside loop:". So I know that the code doesn't get beyond the loop for some reason...
Here's my code:
I was wondering if anyone knows what could be the problem.
I made a loop, and for some reason it's not corresponding correctly and it might even be an infinite loop, but I don't see why.
The only debug messages that show up ingame are "passed the spellcheck" and "inside loop:". So I know that the code doesn't get beyond the loop for some reason...
Here's my code:
JASS:
private function Actions takes nothing returns boolean
local integer SpellId = GetSpellAbilityId()
local unit u = GetTriggerUnit()
local integer id = GetUnitId(u)
local player p = GetOwningPlayer(u)
local integer x = Unit_X[id]
local integer y = Unit_Y[id]
local group g
local unit t
local integer id2
local boolean check = true
local integer spot
/// Summon Bear ///
if SpellId == 'A007' then
call BJDebugMsg("passed the spellcheck")
set g = NewGroup()
call GroupEnumUnitsInRect(g, Field[x][y], null)
set t = FirstOfGroup(g)
set id2 = GetUnitId(t)
loop
exitwhen t == null
call BJDebugMsg("inside loop:")
if GetUnitTypeId(t) != 'H025' and GetUnitTypeId(t) != 'H024' then
set check = false
call BJDebugMsg("unit is not h025 or h024")
endif
if Unit_Reg_Spot[id2] > 5 then
set check = false
call BJDebugMsg("unit reg spot is > 5")
elseif Unit_Reg_Spot[id2] >= spot then
set spot = Unit_Reg_Spot[id2]
call BJDebugMsg("Spot = "+I2S(spot))
endif
call GroupRemoveUnit(g, t)
set t = FirstOfGroup(g)
set id2 = GetUnitId(t)
if t == null then
call BJDebugMsg("t = null")
endif
endloop
call ReleaseGroup(g)
call BJDebugMsg("released the group")
if check == true then
call BJDebugMsg("check = true")
if spot == 2 then
set spot = 1
endif
set t = CreateUnit(p, 'H025', GetRectCenterX(Field[x][y]), GetRectCenterY(Field[x][y]),270. - (I2R(id)*180.))
set Unit_Reg_Size[GetUnitId(t)] = 6
set Unit_Reg_Size[id] = 6
set Unit_Reg_Spot[GetUnitId(t)] = spot
set Unit_Reg_Spot[id] = 2
set Unit_Swimming[GetUnitId(t)] = true
set Unit_X[GetUnitId(t)] = x
set Unit_Y[GetUnitId(t)] = y
set Unit_Steps[GetUnitId(t)] = GetHeroInt(t, true)
call UnitLineUp(t)
endif
endif
set u = null
set t = null
set p = null
return false
endfunction