• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Getting an entered rect?

Status
Not open for further replies.
Level 3
Joined
Feb 20, 2007
Messages
32
This has probably been asked before, but how do you tell which rect a unit has entered?

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
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:

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
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.
 
Status
Not open for further replies.
Top