You store regions in an array, following the order of travel: if you enter 2, you want units to go to 3. So, is this possible? (very simple code so you understand, would need a matching inside and more stuff to make sense):
Unit enters region
Issue order unit move to region[triggering region + 1]
I think it isn't, or at least I haven't found a proper way to do so... any ideas if it's possible?
Something like this? I didn't test it but the idea is there.
Global variables
RegionArray = No Region <Region[6]>
Wave = (Empty unit group) <Unit Group>
Triggers
Initialize Regions
Events
Game - Map initialization
Local Variables
Conditions
Actions
Variable - Set RegionArray[0] = Region 001
Variable - Set RegionArray[1] = Region 002
Variable - Set RegionArray[2] = Region 003
Variable - Set RegionArray[3] = Region 004
Variable - Set RegionArray[4] = Region 005
Variable - Set RegionArray[5] = Region 006
Enter Region
Events
Unit - Any Unit Enters Region 001
Unit - Any Unit Enters Region 002
Unit - Any Unit Enters Region 003
Unit - Any Unit Enters Region 004
Unit - Any Unit Enters Region 005
Unit - Any Unit Enters Region 006
Local Variables
RegionIndex = 0 <Integer>
Conditions
Actions
General - For each integer RegionIndex from 0 to 5 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Triggering region) == RegionArray[RegionIndex]
Then
General - Break
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
RegionIndex < 5
Then
Unit - Order all units in Wave to ( Move targeting (
Center of RegionArray[(RegionIndex + 1)])) (Replace Existing Orders)
Else
The above post is a simple way of doing it, but the way I'm doing it is quite simple too and should work depending on your requirements.
The pathing trigger is basically:
Unit enters region (spawn)
Unit belongs to (computer)
Issue order to move to next region
This only has to be made once and probably takes the same amount of time as the above method. It's also quick to copy/paste each sequential path and just modify the region #
You search the region in the array, save the index and make the units go to index+1.
With Warcraft 3, there was a for that already included variables A,B as the meter, so it was pretty simple to do.
The thing now is... what is more efficient, checking 6 different ifs, or using the for? (we have break to exit it before time, so the for is not that inefficient, nope?)
Anyway, could explain your idea better, Maul2? I don't understand it. I suppose you're using nested ifs, but perhaps I'm just wrong.
It doesn't matter which one is more efficient because they are both efficient enough. Also instead of doing six different ifs, it would be clearer to use a Switch. Of course it's more "efficient" to use six different ifs because you don't need to do the variable increase, but there's just no point optimizing something like this especially if you have like 100 regions and you'd need to do 100 different ifs. What if you later have to change something? You'd have to change it in all the 100 ifs. With the for loop, you'd only need to do it once.
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." —Donald Knuth
Maul2's method is simply just one trigger for each region.
On the other hand, you could just issue the order to the units as a queued order (like you do in-game by holding shift). Though there's a limit of how long the order queue can be... Anyway just order the first move and then the next move with the setting "After existing orders" instead of "Replace existing orders".
Ah, yeah, you used "after existent orders", but I don't like that model, because you can't change the path in-game and you can't split the path of the units. I prefer the original way, but thanks anyway ;).
Yeah, the simple way, but when you have 24 different regions, then the "switch" is way better, you know xDDD.
Anyway, I'll write the code later (breakfast time now :P) and post it here, just so everyone can see it (and use it, too, if they're lazy to write it themselves or aren't too much into programming.
Or perhaps I should make a small tutorial. I think there isn't any :P.
Yeah, your version is fine for some things, like straight paths or paths where units go back :).
Anyway, I wrote the code now that A1win enlightened my with the for use (dunno break existed, thanks man) I've written my own version of the code. Is exactly the same as A1win's, only that it works in loop. It has 8 regions, and in the 9th slot, I've the first region stored for a second time, so it returns to the beginning once again.
Also, I have 3 different sets, so my region variable is more like a table than an array. In the beginning, I was going to give it 2 for, but later I realized it would be more efficient to have each set separated from the others. Well, really, the most efficient thing would be to create a trigger for each region, but laziness is laziness :P.
I'm gonna go test it now, if it works, I'll post it :).
Here it is. Note that I have a Spanish editor, so I'm writing it with my own words:
Initial values:
Set RegionArray[1] = Region 001
Set RegionArray[2] = Region 002
Set RegionArray[3] = Region 003
Set RegionArray[4] = Region 004
Set RegionArray[5] = Region 005
Set RegionArray[6] = Region 006
Set RegionArray[7] = Region 007
Set RegionArray[8] = Region 008
Set RegionArray[9] = Region 001
Events:
Any Unit Enters Region 001
Any Unit Enters Region 002
Any Unit Enters Region 003
Any Unit Enters Region 004
Any Unit Enters Region 005
Any Unit Enters Region 006
Any Unit Enters Region 007
Any Unit Enters Region 008
Conditions:
(Owner of (Entering Unit)) == Player 9
Actions:
General - For each integer RegionIndex from 1 to 8 with increment 1, do (Actions)
Actions:
If (Triggering region) == RegionArray[RegionIndex] Then Break
Order (Entering Unit) to (Move targeting (Center of RegionArray[(RegionIndex + 1)])) (Replace Existing Orders)
That's it, and it works perfectly. Another option to avoid that 9th folder would be to create a duplicate array for the values, instead of using the current array + 1.
Anyway, I'm writing this here now, but I already started building a new code mixing regions with points. Will try to show it later in that small tutorial :P.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
You store regions in an array, following the order of travel: if you enter 2, you want units to go to 3. So, is this possible? (very simple code so you understand, would need a matching inside and more stuff to make sense):
I think it isn't, or at least I haven't found a proper way to do so... any ideas if it's possible?
It would reduce coding work for TD waves a lot.
Something like this? I didn't test it but the idea is there.
Global variables
Triggers
The above post is a simple way of doing it, but the way I'm doing it is quite simple too and should work depending on your requirements.
The pathing trigger is basically:
Unit enters region (spawn)
Unit belongs to (computer)
Issue order to move to next region
This only has to be made once and probably takes the same amount of time as the above method. It's also quick to copy/paste each sequential path and just modify the region #
@A1win: Go
Yes, exactly that.
You search the region in the array, save the index and make the units go to index+1.
With Warcraft 3, there was a for that already included variables A,B as the meter, so it was pretty simple to do.
The thing now is... what is more efficient, checking 6 different ifs, or using the for? (we have break to exit it before time, so the for is not that inefficient, nope?)
Anyway, could explain your idea better, Maul2? I don't understand it. I suppose you're using nested ifs, but perhaps I'm just wrong.
It doesn't matter which one is more efficient because they are both efficient enough. Also instead of doing six different ifs, it would be clearer to use a Switch. Of course it's more "efficient" to use six different ifs because you don't need to do the variable increase, but there's just no point optimizing something like this especially if you have like 100 regions and you'd need to do 100 different ifs. What if you later have to change something? You'd have to change it in all the 100 ifs. With the for loop, you'd only need to do it once.
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." —Donald Knuth
Maul2's method is simply just one trigger for each region.
@Lonami: Go
Here's my map:
http://www.1y100k.com/sc2/mtd.SC2Map
To see how the spawning + pathing works look at these triggers in the waves folder:
Types
Pathing
Pathing 1
Pathing 2
Pathing 3
@A1win: Actually it's only 1 trigger with x amount of actions for the actual pathing and 1 trigger with x amount of unit type variables being set.
On the other hand, you could just issue the order to the units as a queued order (like you do in-game by holding shift). Though there's a limit of how long the order queue can be... Anyway just order the first move and then the next move with the setting "After existing orders" instead of "Replace existing orders".
Same as Maul2's map, nope?
@Maul2: Go
Ah, yeah, you used "after existent orders", but I don't like that model, because you can't change the path in-game and you can't split the path of the units. I prefer the original way, but thanks anyway ;).
@A1win: Go
Yeah, the simple way, but when you have 24 different regions, then the "switch" is way better, you know xDDD.
Anyway, I'll write the code later (breakfast time now :P) and post it here, just so everyone can see it (and use it, too, if they're lazy to write it themselves or aren't too much into programming.
Or perhaps I should make a small tutorial. I think there isn't any :P.
Oh well, we all have different needs :P I'm sure such a tutorial will be helpful to a lot of people so good stuff
@Maul2: Go
Yeah, your version is fine for some things, like straight paths or paths where units go back :).
Anyway, I wrote the code now that A1win enlightened my with the for use (dunno break existed, thanks man) I've written my own version of the code. Is exactly the same as A1win's, only that it works in loop. It has 8 regions, and in the 9th slot, I've the first region stored for a second time, so it returns to the beginning once again.
Also, I have 3 different sets, so my region variable is more like a table than an array. In the beginning, I was going to give it 2 for, but later I realized it would be more efficient to have each set separated from the others. Well, really, the most efficient thing would be to create a trigger for each region, but laziness is laziness :P.
I'm gonna go test it now, if it works, I'll post it :).
Here it is. Note that I have a Spanish editor, so I'm writing it with my own words:
Initial values:
Events:
Conditions:
Actions:
That's it, and it works perfectly. Another option to avoid that 9th folder would be to create a duplicate array for the values, instead of using the current array + 1.
Anyway, I'm writing this here now, but I already started building a new code mixing regions with points. Will try to show it later in that small tutorial :P.