• 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.

Get Rect's Min/Max X/Y

Status
Not open for further replies.
JASS:
GetRectMinX()
GetRectMaxX()
GetRectMinY()
GetRectMaxY()
All of these seems to return an incorrect result when the rect in question is the size of the world. On a 32x32 map with 0,0 being the middle of the map the furthest coordinate is +/-2048. Using the aforementioned functions I get a value of +/-2016. Anyone else know anything about this?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
are you using "Playable Map Area"? If so, you should use Entire World Map(GetWorldBounds()) because Playable Map Area is smaller by the size of the unpathable area around the map(the map boundaries)

Keep in mind that whenever you call GetWorldBounds() it creates entirly new Rect, so you should store it in global variable when you init the map so you only create it once.

If you are using vJass, dont initialize global variable in global block with it, it will crash your map after reloading, initialize it in init block
 
Um. No. I am using a manually created rect that is initialized in the globals block to Rect(-2048,-2048,2048,2048) and have the constant reals on the next four lines set to the min/max x/y of the rect I just created.
JASS:
globals
    constant rect           World                      =Rect(-2048.0,-2048.0,2048.0,2048.0)
    constant real           MinX                       =GetRectMinX(World)
    constant real           MinY                       =GetRectMinY(World)
    constant real           MaxX                       =GetRectMaxX(World)
    constant real           MaxY                       =GetRectMaxY(World)
    constant real           CenterX                    =GetRectCenterX(World)
    constant real           CenterY                    =GetRectCenterY(World)
    constant real           Width                      =MaxX-MinX
    constant real           Height                     =MaxY-MinY
    region                  WorldRegion                =null
endglobals
In the function main I set up WorldRegion and add unit entered events with it and so on. The no was two fold; no to using GetWorldBounds or "Playable Map Area" and also no to the fact that my globals block crashes anything.

Edit: Cool, reloading crashes. That doesn't matter because of various reasons. Also, not using vjass.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Global block only works in JNGP because vJASS bangs it into the main global block. JASS only allows one global block in the map script.

Try with smaller rects and see patterns in the inaccuracy. It could be that there is some internal restriction on rect bound accuracy that causes it to create rects not exactly the provided size.
 
I figured it was due to the rect being at or beyond the map's edge. Also. I'm using an imported war3map.j file; hence how I have access to the globals block. Another option is to edit the triggerdata.txt file and friends.

Edit: Using this:
JASS:
globals
    constant rect           World                      =Rect(-2048.0,-2048.0,2048.0,2048.0)
    constant rect           World2                     =Rect(-1024.0,-1024.0,1024.0,1024.0)
endglobals

function Test takes nothing returns nothing
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"----")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Min X (-1024): "+I2S(R2I(GetRectMinX(World2)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Min Y (-1024): "+I2S(R2I(GetRectMinY(World2)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Max X ( 1024):  "+I2S(R2I(GetRectMaxX(World2)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Max Y ( 1024):  "+I2S(R2I(GetRectMaxY(World2)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"----")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Min X (-2048): "+I2S(R2I(GetRectMinX(World)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Min Y (-2048): "+I2S(R2I(GetRectMinY(World)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Max X ( 2048):  "+I2S(R2I(GetRectMaxX(World)))+".")
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Max Y ( 2048):  "+I2S(R2I(GetRectMaxY(World)))+".")
endfunction
Calling Test() prints out 0 for the expected negative numbers, 1024 for the World2 and 2016 for the World printouts respectively.

Edit 2: No matter what I've done for setting the rect's bounds it will never allow me to have the upper bounds of 2048, the negative side works. It's impossible to have a rect beyond the map's edge. The only rect that has the map's true bounds is returned by GetWorldBounds(), odd Blizzard is odd.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Even if you set the map bounds to the full size of the map, it will still not be the full map. Some of the edge nodes will still be known as map bounds. I noticed this when examining the w3e files of maps that some of the nodes were being treated as boundary even though there should be none. Specifically it seemed to affect only some sides (which matches your results).
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
If you want to get the biggest rect you can have without using GetWordlBounds, you can use SetRect function after creating your rect.


JASS:
function Display takes rect r returns nothing
    call BJDebugMsg("Max X: "+R2S(maxx(r))+", Max Y: "+R2S(maxy(r)))
    call BJDebugMsg("Min X: "+R2S(minx(r))+", Min Y: "+R2S(miny(r)))
endfunction
     

function Trig_Melee_Initialization_Actions takes nothing returns nothing
    call Display(GetWorldBounds())
    set R = Rect(0,0,0,0)
    call SetRect(R, -4096.00, -4096.00, 4096.00, 4096.00)
    call Display(R)
endfunction

This prints
4096 4096
-4096 -4096
4064 4064
-4096 -4096
for me
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
It is default map which is created by world editor when you first open it(as default, if you didn't change)
64x64
 
Status
Not open for further replies.
Top