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

[Trigger] Combining 'region' Triggers

Status
Not open for further replies.
Level 4
Joined
Dec 31, 2014
Messages
68
Hello all, another thread about combining triggers.
In my level I have 100's of 'Region' based triggers and if possible I would like to merge them into 1 or a few triggers to hopefully save some memory, Ideally I would like something to the extent of;

  • Events - A Unit Enters ANY region
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Region is Named Bob
      • Then - Actions
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Region is Named Fred
      • Then - Actions
      • Else - Actions
Does anyone have any ideas? Also as there are many many of these triggers - the simpler it can be to do the better!

Thanks
 
Store all regions in a region variable array. When the trigger fires loop through all regions.

like this

event
- map init
confition
-
action
-set regions[1] = rect1
-set regions[2] = rect2
so on...

then another trigger
event
- unit enters region
condition
-
action
- for integer x from 1 to number of regions do
- if positionx of unit is in regions[x] = true and positiony of unit is in region[x] = true then
- your actions
else
-

if i remember correctly this should work properly.
 
Level 4
Joined
Dec 31, 2014
Messages
68
Thanks for your reply both, hmm doing it as an array will probably take me a very long time for all of them - I can see myself getting quite confused by the workflow. I may do it for some select region triggers though so thanks for that, a shame there isn't an easier way to do it but oh well.
Also Empirean you typed 'Unit Enters Region' did you mean 'Unit enters <Specific Region>' or is there a way to do it as a simple generic event? (does that make sense?)

Bribe, yeah it sounds like it could be difficult, the issue is that I have.. 200-300 as an guesstimate for these sorts of triggers. Iv been trying to fix leaks with my map for a long time now and I'm starting to run out of ideas of how to further fix my level. In other triggers not relating to regions I have managed to merge them and the leaking did improve.. but region based ones don't seem to be a good option - I'm not even sure if I did spend the time to do all of them it would even help fully.. hmm.

Would you say that even though there are 200-300 I should keep them as individual triggers? What do you think?
Many of them are move unit/teleportation triggers and they do have point variables in place so they are leak free, but the amount of them..?
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
You'll still need to use several region, that usual take example of the Creep Spawn they take several region and can not be done inside on trigger, otherwise, instead of using many region make for example '' A unit come within 255 from Triggering Unit ''
But merging all region inside one trigger might be difficult and not a total guarenty of success though !
 
Level 4
Joined
Dec 31, 2014
Messages
68
Alright, thanks all. Yeah.. on review and what you guys have replied to me.. It seems like it would be very difficult and time consuming to attempt and little reason to believe it will actually work. A shame as I thought it might be the last thing left that would be causing the leaking.. oh well going to keep reviewing my triggers to see if there is something else.
Thanks again
 
Actually... what you describe are rects, not regions. The problem is that GUI uses the term "region" for what in JASS is called a "rect".
The actual "regions" in JASS work by combining multiple rects into areas (which are then called regions), which will all fire the entering event.

Why am I telling you this?
Simple: because "regions" in the JASS sense do exactly what you want: it allows you to combine multiple rects into one area.

The natives for that (that you could use in GUI by custom script) are:

RegionAddRect
TriggerRegisterEnterRegion


Basicly, what you can do is make a simple trigger with the initialization event, then add the following custom script to it's action part (for this example, add a trigger variable to the variable editor called "RegionTrigger_Bob" and set it's initial value):

  • Custom Script: local region r = CreateRegion()
  • Custom Script: RegionAddRect(r, gg_rct_RECT1)
  • Custom Script: RegionAddRect(r, gg_rct_RECT2)
  • ...
  • Custom Script: RegionAddRect(r, gg_rct_RECT999)
  • Custom Script: TriggerRegisterEnterRegion(udg_RegionTrigger_Bob, r)
  • Custom Script: set r = null
RECT1, RECT2, ... RECT999 is what your regions are called in the GUI. As you can see it always adds "gg_rct_" in front of each. Only replace what comes behind the second underscore.

Now that you have the event set up, simply add a triggeraction to this trigger as normal by using
  • Trigger - Add Action
 
Status
Not open for further replies.
Top