Is it possible to make a region array?

sevensc

New Member
Reaction score
8
I understand that the GUI "region" global variable type is for rects and that there is no type for JASS regions.

That being said, is there a way to can take a series of rects and turn them into an array of JASS regions?

Could it be faked with a vars handler? Or a script of sorts?

Any help is appreciated.
 
N

no0by

Guest
I suppose this is what you want:
Code:
    local region array myregions
    set myregions[0]=CreateRegion()
    call RegionAddRect(myregions[0],theRect)
theRect is the GUI region (rect) you want 'cloned' as a jass region
 

phyrex1an

Staff Member and irregular helper
Reaction score
446
Yes, that whould be for locals.

>Could it be faked with a vars handler?
Yes, but it isn't needed.

If you use the normal world editor then you have to edit the war3map.j file and add the line
region array <name>
to the globals block.

If you use some world editor that allows you to define global blocks anywhere in the script then adding a global block containing that line is enough.
 

sevensc

New Member
Reaction score
8
How do I go about accessing the war3map.j to edit and save?

The only info i can find on the war3map.j has to do with unprotecting a protected map.
 

sevensc

New Member
Reaction score
8
I found World Editor Helper which is supposed to let me declare globals in a block, but the thing just gives me errors.

Any help on how to access the "war3map.j"?

Even a link to a tutorial would do since I really only ask questions when I can't find info after hours of searching.
 

SFilip

Gone but not forgotten
Reaction score
633
Get WinMPQ from the Useful Tools topic.
Open your map in it.
Extract war3map.j.
Change it as you wish.
Reopen the map with WinMPQ and import the new version of war3map.j you edited.

Note though that this process is reversed as soon as you save the map with the world editor. I recommend that you use WEHelper (or Grimoire if you installed 1.21 patch) and JassHelper for this cause (again the useful tools topic).
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
an easy-to-go solution I have been using for my maps is about the following:
open your map with any jass-editing tool, e.g. JSP, then check out the globals block and retrieve the rect coordinates, i.e. all you have to do is replace the "set gg_rct_generatedrectname=Rect(..."
with "set myrectarray[index]=Rect(..."
I do this in a rather final stage of map making, or at least when I'm sure that the generated rects won't need to be modified any more. After creating your rect index, you can delete your GUI generated rects.
If you're badly needing regions instead of rects, you'll of course have to add the RegionAddRect as mentioned above. I personally don't see much advantage in regions anyway.

summing up:
pros: it's easy
cons: it's harder to modify your regions afterwards
 

sevensc

New Member
Reaction score
8
Ok, new issue:

When I was using "call TriggerRegisterEnterRectSimple" as an event flag in a function with rects, (GUI Regions) everything was working.

Then I converted all the rects to global JASS regions and started using "call TriggerRegisterEnterRegionSimple" and the event NEVER gets triggered.

Is there another trick to getting regions to work?

This is how I set them up (at map init):
globals
region array udg_regionsLeft
endglobals

set udg_regionsLeft[1] = CreateRegion()
call RegionAddRect(udg_regionsLeft[1], gg_rct_Red_Left)

set udg_regionsLeft[2] = CreateRegion()
call RegionAddRect(udg_regionsLeft[2], gg_rct_Blue_Left)

set udg_regionsLeft[3] = CreateRegion()
call RegionAddRect(udg_regionsLeft[3], gg_rct_Teal_Left)

set udg_regionsLeft[4] = CreateRegion()
call RegionAddRect(udg_regionsLeft[4], gg_rct_Purple_Left)

And this is the event in the function:
Code:
function InitTrig_Left_Regions takes nothing returns nothing
    set gg_trg_Left_Regions = CreateTrigger(  )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[1] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[2] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[3] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[4] )    
    call TriggerAddAction( gg_trg_Left_Regions, function Trig_Left_Regions_Actions )
endfunction

The code compiles, but the trigger doesn't fire.
 
N

no0by

Guest
Im not sure but IntTrig's are executed before any triggers so it might be registering a null region (before you init gets to set them up)
So set them up in the IntTrig part
Code:
function InitTrig_Left_Regions takes nothing returns nothing
    local integer i=1
    set gg_trg_Left_Regions = CreateTrigger(  )
    set udg_regionsLeft[1] = CreateRegion()
    call RegionAddRect(udg_regionsLeft[1], gg_rct_Red_Left)
    set udg_regionsLeft[2] = CreateRegion()
    call RegionAddRect(udg_regionsLeft[2], gg_rct_Blue_Left)
    set udg_regionsLeft[3] = CreateRegion()
    call RegionAddRect(udg_regionsLeft[3], gg_rct_Teal_Left)
    set udg_regionsLeft[4] = CreateRegion()
    call RegionAddRect(udg_regionsLeft[4], gg_rct_Purple_Left) 
    loop
        exitwhen i>4
        call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[i] )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_Left_Regions, function Trig_Left_Regions_Actions )
endfunction

Ofcorse you dont need to use the loop and do it like:
Code:
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[1] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[2] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[3] )
    call TriggerRegisterEnterRegionSimple( gg_trg_Left_Regions, udg_regionsLeft[4] )
 

sevensc

New Member
Reaction score
8
Well I think that got it.

I wasn't exactly sure what you meant by "So set them up in the IntTrig part" so I'll show you what i did (and it seems to work). If your way is better/different though, I wouldn't mind at all if you could clarify - I love to learn.

Now when I set each region up, I do it like:
Code:
    set udg_regionsLeft[1] = CreateRegion()
    call RegionAddRect(udg_regionsLeft[1], gg_rct_Red_Left)
    call TriggerRegisterEnterRegion( gg_trg_Left_Regions, udg_regionsLeft[1], null )

Just having the call TriggerRegisterEnterRegion there at the declaration makes the 2nd call work in the Left_Regions function.
 
N

no0by

Guest
What i ment by the InitTrig part is the code world editor makes to create the trigger at map startup (e.g. when the loading screen is seen)
Code:
function Mytrigger_Main takes nothing returns nothing
call DisplayTextToPlayer(Player(0),0,0,"Mytrigger has been executed!")
endfunction

[COLOR="Red"]function InitTrig_Mytrigger takes nothing returns nothing
set gg_trg_Mytrigger=CreateTrigger()
call TriggerRegiser....blahblahblah
call TriggerAddAction(gg_trg_Mytrigger,function Mytrigger_Main)
endfunction[/COLOR]

The red part is what i mean (I freehand typed it ok so this trigger might not work)
 

chobibo

Level 1 Crypt Lord
Reaction score
48
I was wondering what the differences of RECTS and REGIONS are, When you make them its like both of them are the same. Can anyone tell me thier difference tnx.
 

sevensc

New Member
Reaction score
8
From what I understand:

A rect (also called region in GUI) is what you draw using the region palette - they only store the 4 numbers that make up the coordinates of the top-left corner and bottom-right corner of a rectangle.

Even though it's called a region palette, they are NOT regions. And when you look in the variable dialog, the region type variable is actually still a rect type.

You can thank Blizzard for the stupidity.

In Jass, regions (talking about actual regions now, not rects) are similar to rects in their use but have a few major differences:
1) Regions are complex data structures that can be any shape, or combination of shapes - not just rectangles.
2) Regions can have information attached to them using a vars handler system.
3) If you have multiple regions that all call the same trigger, you can use GetTriggeringRegion() to see which one made the call.
 

Chocobo

White-Flower
Reaction score
409
1) Regions are complex data structures that can be any shape, or combination of shapes - not just rectangles.

-> An assemble of rects.


2) Regions can have information attached to them using a vars handler system.

-> What sort then? I2H->H2I :p


3) If you have multiple regions that all call the same trigger, you can use GetTriggeringRegion() to see which one made the call.

Yes, you can. IF you used a Region event.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
Btw., if you wonder why there is only a IsUnitInRegion, and no "IsUnitInRect", and you'd prolly need a IsUnitInRect, then you can very simply write your own function into the custom script section to do the exact same thing:

Code:
function IsUnitInRect takes unit u, rect r returns boolean
    return GetUnitX(u) > GetRectMinX(r)-32 and GetUnitX(u) < GetRectMaxX(r)+32 and GetUnitY(u) > GetRectMinY(r)-32 and GetUnitY(u) < GetRectMaxY(r)+32
endfunction

A little extra-space can be quite important when a unit happens to be just-on-the-threshold, so you're on the safe side. I made it 32 as you can see.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top