I'm lost, I've been writing and rewriting this for an hour, I dont get what is wrong here >.<. This should find a unit in a small terrain block and return a handled id.
Here's my code to give it an id:
This always returns -1. It doesnt matter if the unit is created on the x/y coord used to find it. I'm baffled, what did I do wrong here?
Here's my code to give it an id:
JASS:
//blah
set cnt = CreateUnit(Player(11), 'h006', x, y, 90)
call RegisterWheel(cnt)
//blah
function RegisterWheel takes unit u returns nothing
local gamecache g = LocalVars()
local integer I = GetHandleInt(g, "Wheels")
call SetHandleInt(u, "Wheelid", I)
call SetHandleHandle(g, "Wheel" + I2S(I), u)
call SetHandleInt(g, "Wheels", I + 1)
endfunction
JASS:
function IsWheelAtPoint takes real x, real y returns integer
local group g = CreateGroup()
local unit u = null
call GroupEnumUnitsInRange(g, x, y, 64.0, null)
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g, u)
if(GetUnitTypeId(u) == 'h006')then
call DestroyGroup(g)
set g = null
call BJDebugMsg("vomg")
return GetHandleInt(u, "Wheelid")
endif
exitwhen(u == null)
endloop
call DestroyGroup(g)
set g = null
return -1
endfunction
This always returns -1. It doesnt matter if the unit is created on the x/y coord used to find it. I'm baffled, what did I do wrong here?