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

Create Region - Custom Script

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Custom script: set udg_CE_Region = CreateRegion()
I tried trigger above, but it compiles an error saying "Type mismatch in assignment".
Is this the wrong native function or is there any other function that allows the creation of Regions via Custom Script ?
The thing is, I don't want to create Regions manually, I want to create Regions when I export this trigger to another map, a region is created automatically.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
There are no global variables for regions. What Global Region variable means, are actually rects in jass. So you have to create the global region variable in jass.
 
As Spartipilo said, the areas that are considered "regions" in GUI (and the ones made in the region palette) are actually rects (rectangular). To create one, you have to use the native Rect:
JASS:
native Rect                     takes real minx, real miny, real maxx, real maxy returns rect
Where (minx, miny) is the bottom left corner of the rect and (maxx, maxy) is the upper right corner of the rect.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I was wondering, is there a way to create non-rect regions? I mean, like a Triangle, or a Snake Shape, or something... Lets say, "Custom shape"
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ooomg... that's awesome. But the event "Unit enters Region" is actually "Unit enters Rect" how can I use the custom region with that event?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
New question, but related;
Does this 2 method is same ?

#1
  • Actions
    • Set TempLoc = (Position of (Triggering unit))
    • Region - Center Region 000 <gen> on TempLoc
    • Set TempReal = (Height of (Current camera bounds))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • TempReal Greater than or equal to 10.00
      • Then - Actions
      • Else - Actions
#2
  • Actions
    • Set TempLoc = (Position of (Triggering unit))
    • Custom script: set udg_TempReal = GetLocationZ(udg_TempLoc)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • TempReal Greater than or equal to 10.00
      • Then - Actions
      • Else - Actions
Are both of the method is the same to compare Terrain Height ?
I mean, do they both returns the same value ?

The first one I use Height of Region as a comparison to current terrain height.
The second one I use GetLocationZ as a comparison to current terrain height.

Basically, my map has cliffs and all, so sometimes the terrain has a large comparison and I wanna do actions to it.

My question is that, which is more efficient ?

Comparing height via Region or GetLocationZ ?

Also, what is the function to move rects ?
You know, after I created it via Rect function, how do I move it ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
A region is a collection of cells. Cells relate to some internal game engine mechanic for efficient location of units in the 2D play field.

When adding a rect to a region it adds a number of cells to make up that rect. As cells have a pre-defined shape the results may be rounded to some extent. There is also a bug in the rect to cell conversion that skips cells on the edges of rects that are inside the rect but do not get added to the region. This is why you cannot assume that a unit that has just triggered an "unit enters region" event is inside the rect that produced that region, even if that rect is rounded to the nearest entire cell. The cause is probably an "off by 1 error" where the flow control statement iterates while less than one extremity of the rect even though it should iterate while less than or equal to.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
There is no unit enters rect event...

GUI creates a dummy region, adds the rect to the region, and then does a unit enter region event.
So, Rect != Region ?
Also, if we want to create a Region, it is map-specific right ?
You can't do like Rect, like you're creating a spell and create a small rect in the middle of the map via triggers, whenever we import the variable to another map, it will automatically creates rect in the middle of the map in the new map right ?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
So, Rect != Region ?
Also, if we want to create a Region, it is map-specific right ?
You can't do like Rect, like you're creating a spell and create a small rect in the middle of the map via triggers, whenever we import the variable to another map, it will automatically creates rect in the middle of the map in the new map right ?

Creating a region is not in any way connected to coordinates. It is the rects that are map specific.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ooooh, you're right Nestharus. I was confused. I missunderstood the TriggerRegisterEnterRegion arguments. Lol... not being able to make custom shape regions (or adding several rects to the same region) was one of the main reasons for me to stop working on Gsu'h Will (signature).
 
Status
Not open for further replies.
Top