This has probably been asked before, but how do you tell which rect a unit has entered?
Say I have this trigger:
How would I replace the r = with something that... works?
Well now, there is no native to do this it seems, so I rulled that out. I tried a crack with this function:
The GetHandleRect is merely to cut down on the cycled rects, it should be iterating through about 8 predefined enterable rects. (For each rect added to my trigger, an instance of the added rect is put into this gamecache handle. This is Kattana's handle var's btw.) Basicaly the function checks if the given x/y coords are in the rect. The x/y coords are from the unit that entered the rect. But alas, it doesnt work! And maybe it doesnt work, I dont know. What I do know, is I need some sort of way to get what rect a unit entered.
Anyone know of a good way? Thank you in advance.
Say I have this trigger:
JASS:
function ExampleTrigger takes nothing returns nothing
local unit u = GetEnteringUnit()
local region r = ... ... .. uhhh........?
endfunction
function InitTrig_ExampleTrigger takes nothing returns nothing
//initiation garbage
endfunction
Well now, there is no native to do this it seems, so I rulled that out. I tried a crack with this function:
JASS:
function GetEnteredRect takes real x, real y returns rect
local gamecache g = LocalVars()
local rect r = null
local integer I = 0
loop
set r = GetHandleRect(g, "PRA" + I2S(I))
exitwhen(r == null)
if(GetRectMinX(r) <= x) and (x <= GetRectMaxX(r)) and (GetRectMinY(r) <= y) and (y <= GetRectMaxY(r))then
return r
endif
set I = I + 1
set r = null
endloop
return null
endfunction
Anyone know of a good way? Thank you in advance.