Hello! I have several points throughout my map which spawn 3,2, or only 1 unit.
This is setup as a periodic event, that fires every 60 seconds. The issue I'm having is that since it's a simple 'create unit' for player 15 trigger, that they begin to add up if they're not killed off, every 60 seconds.
My goal is to make it so that they still spawn every 60 seconds, but will not become more than the default number of units intended.
For example, you can see that they spawn at the 1 minute mark of the game, and come back 3 minutes later, and the same number of units should still be present.
Second example, depicting a separate scenario: You see that 3 units spawn at the 1 minute mark of the game, kill all of them within 30 seconds, and have 3 of the same type of unit respawn at the next 60 second increment of the game.
Assign all units spawned at each point to a unit group (add them to the group). Before spawning new units, check if there is space in the unit group (number of living units in unit group < X where X is the number of units you want). This why no more than X can exist at a time.
You may need to flush dead units from the groups from time to time, I am uncertain if SC2 does this automatically and if not it could possibly be a leak of sorts.
You could also assign an integer to each spawn point to buffer "over spawns" so that you can spawn them at a later time if you wanted but that could change the dynamics of your game.
Ultimately making it some form of data driven system would be great. That way all spawns could be run from the same triggers and new spawns or spawn removal would be as easy as setting some variables. One approach for such a system would be an array of structs (forget what they are called in GUI) which each index represents a spawner. You set all indicies up at map initialization and then periodically check through each one spawning when appropriate. To spawn all you need is a location (where the spawn is), a group (the number of currently alive spawns) and possibly an integer (how many ticks until spawn) and another integer (how many ticks until respawn, the period). For over spawn support you would need an integer (how many spawns could not be spawned but wanted to).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello! I have several points throughout my map which spawn 3,2, or only 1 unit.
This is setup as a periodic event, that fires every 60 seconds. The issue I'm having is that since it's a simple 'create unit' for player 15 trigger, that they begin to add up if they're not killed off, every 60 seconds.
My goal is to make it so that they still spawn every 60 seconds, but will not become more than the default number of units intended.
For example, you can see that they spawn at the 1 minute mark of the game, and come back 3 minutes later, and the same number of units should still be present.
Second example, depicting a separate scenario: You see that 3 units spawn at the 1 minute mark of the game, kill all of them within 30 seconds, and have 3 of the same type of unit respawn at the next 60 second increment of the game.
How should I go about accomplishing this?
Assign all units spawned at each point to a unit group (add them to the group). Before spawning new units, check if there is space in the unit group (number of living units in unit group < X where X is the number of units you want). This why no more than X can exist at a time.
You may need to flush dead units from the groups from time to time, I am uncertain if SC2 does this automatically and if not it could possibly be a leak of sorts.
You could also assign an integer to each spawn point to buffer "over spawns" so that you can spawn them at a later time if you wanted but that could change the dynamics of your game.
Ultimately making it some form of data driven system would be great. That way all spawns could be run from the same triggers and new spawns or spawn removal would be as easy as setting some variables. One approach for such a system would be an array of structs (forget what they are called in GUI) which each index represents a spawner. You set all indicies up at map initialization and then periodically check through each one spawning when appropriate. To spawn all you need is a location (where the spawn is), a group (the number of currently alive spawns) and possibly an integer (how many ticks until spawn) and another integer (how many ticks until respawn, the period). For over spawn support you would need an integer (how many spawns could not be spawned but wanted to).