• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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