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

[JASS] Regions Problem

Status
Not open for further replies.
Level 6
Joined
Jun 30, 2006
Messages
230
Sometimes you wish to relate regions to particular players. In my case, I need 1 region per player that only his units can trigger. Each of these regions does the same thing, only they do them for the player related to the region. Using normal GUI regions, you cannot do a reasonable test to see which region was triggered without creating a trigger for each region. I'm doing the same thing, but all that is changing is a player and a region? Psh, in my mind that screams for a 1 trigger.

So I set out to make a mini-system which used global region arrays to be able to adequately determine which region belongs to which player. If region[0] belongs to Player(0) and so forth through all players, this should work. Before I set out to do this... I just experimented with global regions, as using local regions would require a handle system...

Now... unless I missed something crucial... the attached map should work, yet it does not....

Edit: I am beginning to believe that TriggerRegisterEnterRegion does not even work... TriggerRegisterEnterRectSimple is as follows:
JASS:
function TriggerRegisterEnterRectSimple takes trigger trig, rect r returns event
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion, r)
    return TriggerRegisterEnterRegion(trig, rectRegion, null)
endfunction

So in theory, I could make my own regions, add a rect to it, and then use it globally... Unless my logic is wrong in my map, it proves you cannot do this, which sucks. It means you cannot efficiently relate Regions and Players...

Someone please prove me wrong.
 

Attachments

  • RegionsTest.w3m
    12.8 KB · Views: 59
Level 6
Joined
Jun 30, 2006
Messages
230
What was the point of making GetTriggeringRegion if it cannot be used? You can test to see what the entering unit was, all this stuff, but not for which region was triggered? Well, you actually can using handle systems, and even then only sort of...
 
Level 5
Joined
Oct 27, 2007
Messages
158
If you want to make global use of a region array and catch if a specific player enters his region you could do this with a single region event trigger.

With GetTriggeringRegion you can get the region for the triggered event. Then you can check if it's a player region. Then determine which player and determine the unit's owner.

I assume that's what you're trying to accomplish...

Correction... You want to be able to determine region/unit/player relation for every player. You can't do that without creating a region event for every player that has a region. Setting up global regions for players should work just fine in that case. I don't see why you should use local handle vars for this. Since you only want to know if a player enters/leaves his region. I assume you keep the regions throughout the game.
 
Level 6
Joined
Jun 30, 2006
Messages
230
Important Update: When I first did this test, over a year ago, I kept the map. I just opened that same map, saved it so I could test it, and it worked! The only thing different was the JassNewGen version and the wc3 version, and I'm not sure what the original versions of either are. I'm not sure why my test map I posted here fails, but the old map works... I'm going to play around with when the region array is defined and stuff, and see if I can manage to find out why the first map posted here fails. Man, that blue is a good looking color... :)

I do not want to do 1 trigger per region... that is worthless because all I am doing is changing which region, and which player.

Also, Drone, had you tested my map and looked at the code, you would see using global regions is fine... although, you can't trigger a region for whatever reason and then use GetTriggeringRegion to get the region which triggered it, not by name, at least.

Did anyone who downloaded my test map look to see how it is setup? Why doesn't it work? Using Rects works fine, but not Regions...

Edit: I discovered using GetTriggeringRegion is useful if you have a trigger which has a unit enters rect event, then you can on the fly create a unit leaves trigger... However, I cannot get it to do a comparison... GetTriggeringRegion == Region[0], for example... This map uses the GetTriggeringRegion to determine which region was entered... in this case, we don't really care which region it is, meaning we do the same thing no matter which region is being left. And yes, this code attached to this post is really used... with a few bugs removed and a little be more optimization, though.
 
Last edited:
Status
Not open for further replies.
Top