• 🏆 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!

[Trigger] "get rect in wich unit X is currently standing" function?

Status
Not open for further replies.
Level 16
Joined
Jul 21, 2008
Messages
1,121
Here is it:

JASS:
native IsUnitInRegion               takes region whichRegion, unit whichUnit returns boolean
native RegionAddRect            takes region whichRegion, rect r returns nothing

You use it like this:
JASS:
call RegionAddRect(YourRegion, YourRect)
if IsUnitInRegion(YourRegion, YourUnit) then
       // if the unit is in region this actions should fire
endif
 
You mean like:
  • Map Initialization
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Region[1] = (<Your region0001 <gen>>)
    • Set Region[2] = (<Your region0002...)
      • and so on..
  • Trigger
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • Set Temp_Point = (Position of (<Your unit>))
    • For each (Integer A) from 1 to X
      • Loop - Actions
        • If/ Then/ Else
          • If (conditions)
            • ((Region[IntegerA]) contains Temp_Point) Equal to True
          • Then
            • ...
    • Custom script: call RemoveLocation (udg_Temp_Point)
Region variable is of type 'Region' with array ticked and the "X" on the Integer above is the maximum array number you will use, up to the number of the regions.
 
Level 9
Joined
Jan 14, 2008
Messages
366
thanks guys... but im afraid i won't be able to get it to use... my jass knowledge is just so limited...

could you do me a favour and make a script that stores the rect in wich "Temp_Unit" is currently standing in a "Temp_Rect" variable?

would be so awesome :|
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
Here you go.

  • Actions
    • Set TempPoint = (Position of (YourUnit))
    • Set TempRegion = YourRegion
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Does TempRegion contain point TempPoint) Equal to (==) True
        • Then - Actions
        • Else - Actions
    • Custom Script: call RemoveLocation(udg_TempPoint)
 
Level 9
Joined
Jan 14, 2008
Messages
366
thanks but im afraid that trigger only checks "is point X in rect X" and therefore to really determine in what rect point X is among 80 rects (wich i have) i would have to create 80
"if/then/else" functions

wich doesnt help me out :(
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
Here ya go:

  • RectInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Region[1] = No region
      • Set Region[2] = No region
      • Set Region[3] = No region
      • -------- And so on... --------
The second trigger is similar to my previous posted one, so I'll just add the changes.

  • For each (Integer A) from 1 to NumberOfRegions, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Region[(Integer A)] contains TempPoint) Equal to True
        • Then - Actions
        • Else - Actions
 
Level 9
Joined
Jan 14, 2008
Messages
366
thanks folks! sry pharaoh, i read your post,

but i figured i would have had to manually define 70 variables.

  • RectInit
  • Events
  • Map initialization
  • Conditions
  • Actions
  • Set Region[1] = No region
  • Set Region[2] = No region
  • Set Region[3] = No region
  • -------- And so on... --------
there is no way to do it without having to specifiy every region manually ?

thanks alot still everyone! highly appreciated
 
Level 9
Joined
Jan 14, 2008
Messages
366
it doenst make any sense that the world editor is not able to convert a regions name into an integer, ...

say you have one hundred regions name like this

"combat area 001"
"combat area 002"
"combat area 003"
"combat area 004"
"combat area 005"

why not give the editor the function to treat them as a group of regions (due to the similar name) enabling actions like "random region from region group" ... ?

or atleast add a function that automatically defines all those 100 regions in a varibale with 100 arrays. that would save shitloads of time and im sure such a function would be ridiculously easy to create.

=/ anyway i did it manually thank you very much everyone involved in helping a noob out
 
Status
Not open for further replies.
Top