I did a search on those forums and couldn't find anything explaining how to properly manage a Variable Region with the 'Unit enters Region' Event.
This is a workaround (as you will see, the main Trigger does not use a proper 'Variable' Region). But it's a rather clean workaround, and it can be useful for 200 or more region management within the triggers.
I'll list the steps but I also should have uploaded a tutorial map, so feel free to take a look at it.
UnitEntersVariableRegionEventsUnit-AnyUnitEntersMainRegionLocalVariablesIteration=0<Integer>Conditions------- Just to be sure the neutral beacon does not trigger this event(Ownerof(Triggeringunit))!=0ActionsGeneral-ForeachintegerIterationfrom0to500withincrement1,do(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If((Triggeringunit)isinRegionComponents[Iteration])==trueThenUI-Display((Text(Iteration)))for(Allplayers)toSubtitleareaGeneral-BreakElse
To summarize the Entering part: This is just the management of a constant Empty region (The empty does matter a lot, a 'No-Region' constant will not be processed).
Any Regions can be added to this constant and a Region Array keeps track of the added Regions.
2/ Unit leaves (Variable Region)
Use everything above and add a variable:
LeavingRegionTest=NoRegion<Region>
Trigger the Main Region leaving Event:
UnitLeavesVariableRegionEventsUnit-AnyUnitLeavesMainRegionLocalVariablesIteration=0<Integer>ConditionsActionsGeneral-ForeachintegerIterationfrom0to500withincrement1,do(Actions)ActionsVariable-SetLeavingRegionTest=(Emptyregion)Region-AddaPositivecirclecenteredat(CenterofRegionComponents[Iteration])withradius1.5toLeavingRegionTestGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If((Triggeringunit)isinLeavingRegionTest)==trueThenUI-Display("The Stalker goes out of : "+(Text(Iteration)))for(Allplayers)toSubtitleareaGeneral-BreakElse
To summarize the Leaving part: This is a test when any unit leaves the encompassing Main Region. For each Region component it is checked if the unit within on a wider Region placed at the location of this Region component. If it's the case the unit has effectively just left this particular Region component (It might be buggy when Two Regions are overlapping).
So it is possible to work on a large number of Regions, create them on the fly, and manage units entering and leaving those specific Regions, without having to create an enormous amount of specific triggers!
Have you actually tried this for like 200 regions (and let the 200th region be the right one)?
I'd think it lags because of so many calls.
Oh and one more little thing:
If you declare an array of size 500 in GUI then it's actually 501 large. So you can use 0-500 and don't have to use 0-499.
I just tested it out by adding more Stalker to my test map and blinking like no tomorrow, the regions went up to 386 and so far so good. I couldn't notice any laginess.
It would require testing on a less than average computer and with a more complex map though, but it can't be worth than actually checking the Events in 300 different triggers, can it ?
I also did found out how to manage the Unit leaves (Variable Region) and I will update my post as soon as I can.
edit: oh and I didn't know for the array size, thanks for that!
Hi everyone,
I did a search on those forums and couldn't find anything explaining how to properly manage a Variable Region with the 'Unit enters Region' Event.
This is a workaround (as you will see, the main Trigger does not use a proper 'Variable' Region). But it's a rather clean workaround, and it can be useful for 200 or more region management within the triggers.
I'll list the steps but I also should have uploaded a tutorial map, so feel free to take a look at it.
1/ Unit Enters (Variable Region)
To summarize the Entering part: This is just the management of a constant Empty region (The empty does matter a lot, a 'No-Region' constant will not be processed). Any Regions can be added to this constant and a Region Array keeps track of the added Regions.
2/ Unit leaves (Variable Region)
To summarize the Leaving part: This is a test when any unit leaves the encompassing Main Region. For each Region component it is checked if the unit within on a wider Region placed at the location of this Region component. If it's the case the unit has effectively just left this particular Region component (It might be buggy when Two Regions are overlapping).
So it is possible to work on a large number of Regions, create them on the fly, and manage units entering and leaving those specific Regions, without having to create an enormous amount of specific triggers!
And here's the Variable Region Tutorial Map !
Have you actually tried this for like 200 regions (and let the 200th region be the right one)? I'd think it lags because of so many calls.
Oh and one more little thing: If you declare an array of size 500 in GUI then it's actually 501 large. So you can use 0-500 and don't have to use 0-499.
@s3rius: Go
Hi,
I just tested it out by adding more Stalker to my test map and blinking like no tomorrow, the regions went up to 386 and so far so good. I couldn't notice any laginess. It would require testing on a less than average computer and with a more complex map though, but it can't be worth than actually checking the Events in 300 different triggers, can it ?
I also did found out how to manage the Unit leaves (Variable Region) and I will update my post as soon as I can.
edit: oh and I didn't know for the array size, thanks for that!
I updated the first post with the leaving management; I also have it on a .SC2Map along with the 'Any Unit dies' management if it's needed!
As I said, this mechanism needs testing on a large and complex map, but it wasn't lagging so far (even with the leaving management).