So I'm trying to create a spawning system based upon how many of a certain building that player owns. How do I count, say, how many Barracks player 1 owns and store that to be used in multiple functions or triggers?
Events
Unit - Any Unit construction progress is Completed
Local Variables
Conditions
(Unit type of (Triggering unit)) == Barracks
(Owner of (Triggering unit)) == 1
Actions
Variable - Set Variable = (Variable + 1)
With that simple method, the Variable will = the # of Barracks.
You could also add Conditions to check other crap.
Now with that Variable you can create a trigger for spawning like this:
Events
Timer - Every 5.0 seconds of Game Time
Actions
Unit - Create Variable Zergling for player 2 at (Center of (Playable map area)) facing 270.0 degrees (No Options)
The Create Variable part would just create Zerglings = to the number of Barracks owned by Player 1.]
You could easily make a mathematical formula to work with whatever you had in mind for spawning.
One example: Create 10 + (Variable / 2) Zerglings
^ Using the Arithmetic (Integer) option in this case, 10 Zerglings + 1/2 of Variable (1/2 of Barracks owned by Player 1 in this case) will spawn. Say Player 1 has 10 Barracks, then 15 Zerglings will spawn (10 + 1/2 of 10).
Well the layout for this didn't work out, but hopefully this will still make sense :)
Just make an Integer variable and set the value to Number of Units in Unit Group and make the Unit Group refer to Units in region Matching Condition make the units Barracks, the region the entire map, and the condition 'owned by player 1'.
I think that should work.
I thought of other reasons why I do need to track deaths of the buildings as well, so the event based method is required for that part of what I'm doing, but your (Zetal) idea is excellent for another aspect of my map. So, thanks to both of you.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I'm trying to create a spawning system based upon how many of a certain building that player owns. How do I count, say, how many Barracks player 1 owns and store that to be used in multiple functions or triggers?
@Diablito816: Go
You could create something like this:
Events Unit - Any Unit construction progress is Completed Local Variables Conditions (Unit type of (Triggering unit)) == Barracks (Owner of (Triggering unit)) == 1 Actions Variable - Set Variable = (Variable + 1)
With that simple method, the Variable will = the # of Barracks. You could also add Conditions to check other crap.
Now with that Variable you can create a trigger for spawning like this: Events Timer - Every 5.0 seconds of Game Time Actions Unit - Create Variable Zergling for player 2 at (Center of (Playable map area)) facing 270.0 degrees (No Options)
The Create Variable part would just create Zerglings = to the number of Barracks owned by Player 1.] You could easily make a mathematical formula to work with whatever you had in mind for spawning.
One example: Create 10 + (Variable / 2) Zerglings
^ Using the Arithmetic (Integer) option in this case, 10 Zerglings + 1/2 of Variable (1/2 of Barracks owned by Player 1 in this case) will spawn. Say Player 1 has 10 Barracks, then 15 Zerglings will spawn (10 + 1/2 of 10).
Well the layout for this didn't work out, but hopefully this will still make sense :)
Just make an Integer variable and set the value to Number of Units in Unit Group and make the Unit Group refer to Units in region Matching Condition make the units Barracks, the region the entire map, and the condition 'owned by player 1'. I think that should work.
@Zetal: Go
I thought of other reasons why I do need to track deaths of the buildings as well, so the event based method is required for that part of what I'm doing, but your (Zetal) idea is excellent for another aspect of my map. So, thanks to both of you.