- Joined
- Aug 7, 2008
- Messages
- 14
I'm working on a TD map ATM, and having some issues doing the wave-spawning "my way".
First and foremost, the way spawning *should* work is something similar to Green Circle TD; where it doesn't just dump all the units at once and send them on their way, rather it has some kind of wait interval between creating the units.
However after examining an unprotected Green Circle TD, I noticed there's a trigger each for each wave that sets up the spawning routine; sets the unit to spawn, how many, etc.
That all is just way too much to handle, takes up a lot of space, and it too annoying to fiddle with finer points if after testing I find I need to adjust some numbers around.
So I built a nested series of loops. They go something like this (most of the udg variables should be self defining enough in name).
I only want it to spawn units at player points where there are people playing.
Then verify to only run the next loop if the current wave is equal to the loop-integer. This to prevent it from spawning, say wave 20 units on round 12.
Then make sure it hasn't already spawned enough units, and as long as it hasn't reached that threshold, define the point, create the unit, destroy the point, and add 1 to the counter tracking number of units spawned.
Just looking at it I can see I'll have to rearrange where it resets the units spawned counter; lest an entire game full of 8 people only gets 3 units each to kill (currently outside of the trigger code block, thinking of putting it in one of the loops). And also where to (or whether to) include the "wait .25 seconds" at the end of the loop to make sure it doesn't spawn them all at once.
I'd really rather keep the wave spawning like this to one trigger (like this), instead of needing to spread it out thin amongst 50+ triggers that would essentially do the same thing, just take the more space.
weee for loops in loops in loops.
-- edit --
Also looking at it, I could probably simply take out the 'if then' checking the CurrentWaveSpawnCounter, since that's a number used in the group, and looped as many times as the MobsToSpawn[] integer is... wee.
First and foremost, the way spawning *should* work is something similar to Green Circle TD; where it doesn't just dump all the units at once and send them on their way, rather it has some kind of wait interval between creating the units.
However after examining an unprotected Green Circle TD, I noticed there's a trigger each for each wave that sets up the spawning routine; sets the unit to spawn, how many, etc.
That all is just way too much to handle, takes up a lot of space, and it too annoying to fiddle with finer points if after testing I find I need to adjust some numbers around.
So I built a nested series of loops. They go something like this (most of the udg variables should be self defining enough in name).
-
Player Group - Pick every player in PlayingPlayersGrp and do (Actions)
-
Loop - Actions
-
For each (Integer WaveSpawnIntegerA) from 1 to 50, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Wave_CurrentWave Equal to WaveSpawnIntegerA
-
Then - Actions
-
For each (Integer WaveSpawnIntegerB) from 1 to MobsToSpawnPerWave[WaveSpawnIntegerA], do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CurrentWaveSpawnCounter Less than MobsToSpawnPerWave[WaveSpawnIntegerA]
-
Then - Actions
- Set TempPoint = (Random point in PlayerSpawnRegions[(Player number of (Picked player))])
- Unit - Create 1 Wave_UnitTypes[WaveSpawnIntegerA] for Player 9 (Gray) at TempPoint facing Default building facing degrees
- Custom script: call RemoveLocation (udg_TempPoint)
- Set CurrentWaveSpawnCounter = (CurrentWaveSpawnCounter + 1)
- Wait 0.25 game-time seconds
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer WaveSpawnIntegerB) from 1 to MobsToSpawnPerWave[WaveSpawnIntegerA], do (Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer WaveSpawnIntegerA) from 1 to 50, do (Actions)
-
Loop - Actions
I only want it to spawn units at player points where there are people playing.
Then verify to only run the next loop if the current wave is equal to the loop-integer. This to prevent it from spawning, say wave 20 units on round 12.
Then make sure it hasn't already spawned enough units, and as long as it hasn't reached that threshold, define the point, create the unit, destroy the point, and add 1 to the counter tracking number of units spawned.
Just looking at it I can see I'll have to rearrange where it resets the units spawned counter; lest an entire game full of 8 people only gets 3 units each to kill (currently outside of the trigger code block, thinking of putting it in one of the loops). And also where to (or whether to) include the "wait .25 seconds" at the end of the loop to make sure it doesn't spawn them all at once.
I'd really rather keep the wave spawning like this to one trigger (like this), instead of needing to spread it out thin amongst 50+ triggers that would essentially do the same thing, just take the more space.
weee for loops in loops in loops.
-- edit --
Also looking at it, I could probably simply take out the 'if then' checking the CurrentWaveSpawnCounter, since that's a number used in the group, and looped as many times as the MobsToSpawn[] integer is... wee.