• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Help - Unit Sequence Spawner

Level 9
Joined
Mar 17, 2016
Messages
151
Hello Hive, long time no see

I'm trying to make a trigger and I need help understanding the best way to do it, as my ideas as to do this im sure are far from optimal


Basically what I am looking to have done is spawning in units that were purchased previously in the order that they were bought by the player but done so in waves that are determined by a variable. There will also be a limit to how many units can be in each wave, with a system that is much like the Food/Supply system in WC3 that you can upgrade in game
(there are 3 waves to the units that will spawn, that will be changed by selecting certain objects)
Ideally, it would work like this, as an example;
--
  • Player buys a unit (or uses an ability that acts as a dummy) to buy 3 Ogres, 1 Gnoll, 1 Ghoul, and then 4 more Ogres
  • Floating text will appear, showing the names of each unit that was bought in the queue, with a number as well to show. As of now it would read Ogre x 7, Gnoll x 1, Ghoul x 1
  • Player selects wave 2, setting another variable, and then proceeds to buy 2 Footmen and 1 Infernal
  • Player tries to buy a ghoul for wave 2 but the food is capped out for wave 2
  • Player selects wave 1 again and buys the additional Ghoul
  • Now the text would read Ogre x 7, Gnoll x 1, Ghoul x 2 in the wave 1 location, and in the wave 2 location it would read Footman x 2, Infernal x 1
--
  • Once another trigger activates, the units begin to spawn in the order that they were bought with a timed delay that can be changed with upgrades (so the timer needs to be editable)
  • The units will begin to spawn, Ogre, ogre, ogre, gnoll, ghoul, ogre, ogre, ogre, ogre, Ghoul.
  • Once wave 2 starts, it will spawn Footman, footman, infernal.
  • (If possible, it would be the best outcome if the player can still add to the list of units to be summoned while the wave is in progress, so for this example, after wave 2 has been defeated but theres still time before the wave ends, the player buys 1 more infernal, and then it is promptly added to the game, and/or they buy it while there are still units in the queue to be spawned and it simply adds it to the queue. This is optional and not necessary but if doable that would be pretty cool)
  • Game sees that wave 3 is empty and skips it
  • Waves end, and everything is set back to 0 and any stored info destroyed so that the player can start anew for the again coming waves 1, 2 and 3.
--
--
  • Players can buy additional Supply for the waves, increasing the maximum amount
  • Players can buy an upgrade that decreases the time between each unit spawning
--


Like I said, any way that I can think of to do the bulk of this is not really a good method, so I would love some help from someone understands this stuff better than I do.
Also, It does not need to be MUI as there will only be 1 player doing any of this at any given time.



Thanks in advance, Hive.
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,379
I'm not going to go into full detail (just yet) but here's what I would do...

First create a database for your Unit-Types. You can link any data you want to these, like an Ability if that's what you use to purchase them:
  • -------- first unit --------
  • Set Variable Spawn_Type[1] = Footman
  • Set Variable Spawn_Ability[1] = Purchase Footman
  • Set Variable Spawn_Food_Cost[1] = 2
  • -------- next unit --------
  • Set Variable Spawn_Type[2] = Rifleman
  • Set Variable Spawn_Ability[2] = Purchase Rifleman
  • Set Variable Spawn_Food_Cost[2] = 3
  • -------- next unit --------
  • Set Variable Spawn_Type[3] = Gryphon Rider
  • Set Variable Spawn_Ability[3] = Purchase Gryphon Rider
  • Set Variable Spawn_Food_Cost[3] = 6
  • -------- next unit --------
  • Set Variable Spawn_Type[4] = Archer
  • Set Variable Spawn_Ability[4] = Purchase Archer
  • Set Variable Spawn_Food_Cost[4] = 1
  • -------- etc --------
  • Set Variable Spawn_Total_Types = 4
The [index] here represents the "id" of these different unit types, it's not too important, just make sure that it's ordered starting at 1 and works it's way up. I track the final [index] in Spawn_Total_Types to easily reference it in other triggers. Remember to update this Spawn_Total_Types variable when adding new additions to the database, this will allow the other triggers to incorporate these new additions as well.

Next let's create our Hashtables which are used to store complex data, each User needs one of each:
  • Player Group - Pick every player in (All players that are Users) and do (Actions)
    • Loop - Actions
      • Set Variable PN = (Player number of (Picked player))
      • Hashtable - Create a hashtable
      • Set Variable Player_Data_Hash[PN] = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Variable Spawn_Data_Hash[PN] = (Last created hashtable)
1) Player_Data_Hash -> Contains each player's current food, food cap, and spawn interval rates, with separate data for each Wave.
2) Spawn_Data_Hash -> Contains the different types of units spawned and their total amounts, with separate data for each Wave.

Then create a trigger for detecting when one of the units from out database is purchased:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • ((Triggering unit) is a Spawn Thingy
  • Actions
    • Set Variable PN = (Player number of (Triggering player))
    • Set Variable Ability_Cast = (Ability being cast)
    • -------- --------
    • -------- Find the [index] associated with the ability cast --------
    • For each integer (Spawn_Index) from 1 to Spawn_Total_Types do (Actions)
      • Loop - Actions
        • If all conditions are true then do (Actions)
          • If - Conditions
            • Ability_Cast Equal to Spawn_Ability[Spawn_Index]
          • Then - Actions
            • -------- This custom script ends the For Loop early --------
            • Custom script: exitwhen true
          • Else - Actions
    • -------- --------
    • -------- Spawn_Index is now equal to either 1, 2, 3, or 4 (you can use it to access any Spawn_ data you want) --------
    • -------- Next let's load our player's Food data and see if they have enough to purchase this new unit --------
    • Set Variable Food_Current = (Hashtable - Load 1 of Player_Wave[PN] in Player_Data_Hash[PN])
    • Set Variable Food_Cap = (Hashtable - Load 2 of Player_Wave[PN] in Player_Data_Hash[PN])
    • If all conditions are true then do (Actions)
      • If - Conditions
        • (Food_Current + Spawn_Food_Cost[Spawn_Index]) Greater than Food_Cap
          • Then - Actions
          • -------- If this is true then they don't have enough Food, refund them and end the trigger early --------
          • Skip remaining actions
        • Else - Actions
    • -------- --------
    • -------- From this point on we can pay costs and track the newly purchased unit --------
    • -------- --------
    • -------- Save your newly updated current Food value --------
    • Hashtable - Save (Food_Current + Spawn_Food_Cost[Spawn_Index]) as 1 of Player_Wave[PN] in Player_Data_Hash[PN]
    • -------- --------
    • -------- Save how many Unit-Types you have in general --------
    • Set Variable General_Total = (Hashtable - Load 0 of Player_Wave[PN] in Spawn_Data_Hash[PN])
    • Set Variable General_Total = (General_Total + 1)
    • Hashtable - Save General_Total as 0 of Player_Wave[PN] in Spawn_Data_Hash[PN]
    • -------- --------
    • -------- Save the actual Unit-Type (it's "id" that it uses in our database) --------
    • Hashtable - Save Spawn_Index as General_Total of Player_Wave[PN] in Spawn_Data_Hash[PN]
    • -------- --------
    • -------- Save how many Unit-Types you have of this specific Unit-Type --------
    • Set Variable Specific_Total = (Hashtable - Load (Spawn_Index + Spawn_Total_Types) of Player_Wave[PN] in Spawn_Data_Hash[PN])
    • Set Variable Specific_Total = (Specific_Total + 1)
    • Hashtable - Save Specific_Total as (Spawn_Index + Spawn_Total_Types) of Player_Wave[PN] in Spawn_Data_Hash[PN]
This trigger isn't finished but it should get you on the right track.

You can remove some of the "magic numbers" from the triggers by referencing custom "KEYS". These are Integer variables with a unique value that have a naming pattern that helps you understand what they do.

You would define these KEYS during Map Initialization.
  • Set Variable KEY_FOOD_CURRENT = 1
  • Set Variable KEY_FOOD_CAP = 2
Then use them like so:
  • Hashtable - Save 0 as KEY_FOOD_CURRENT of Player_Wave[PN] in Player_Data_Hash[PN]
  • Hashtable - Save 100 as KEY_FOOD_CAP of Player_Wave[PN] in Player_Data_Hash[PN]
You should hopefully be able to understand what I'm doing in the above example based solely on the variable names. PN is short for Player Number which would've been set beforehand.

Lastly, here's an example of how to use all of this data. This will spawn all of Player 3's units stored for Wave 2:
  • Actions
    • Set Variable PN = (Player number of (Player 3 (Teal))
    • Set Variable Player_Wave[PN] = 2
    • Set Variable Player_Spawn_Total[PN] = (Hashtable - Load 0 of Player_Wave[PN] in Spawn_Data_Hash[PN])
    • For each integer (X) from 1 to Player_Spawn_Total[PN] do (Actions)
      • Loop - Actions
        • Set Variable Spawn_Index = (Hashtable - Load X of Player_Wave[PN] in Spawn_Data_Hash[PN])
        • Unit - Create 1 Spawn_Type[Spawn_Index] at (Some position) for Player(PN)
This will spawn the units in the correct order, but all at once. You can use a Timer to spread this effect out over time, which would use your Interval logic for it's duration. The interval could be saved in Player_Data_Hash beforehand using the same pattern that I used for Food.
 
Last edited:
Level 9
Joined
Mar 17, 2016
Messages
151
Thank you for this, it never ceases to amaze me the amount of helpfulness this website provides.

After countless hours of staring blankly into the all-white abyss of the trigger editor, beating my head against it until i understand whats going on, ive finally gotten this thing to work the way im looking for it to work.


I have a few problems as it stands,

1) Sometimes, It will skip the first unique unit type; I just tried making 7 Peasants and then 7 Footmen, both for wave 1, 1st peasant didnt show up but i have a print function for the "Units remaining" and it showed 7 but the first one was skipped, and same with the Footman, should be total of 14 ended up total of 12. When I try other times, it does not do this. Then it does again, then it doesnt. I don't get it.

2) Every now and then, usually at the 5th, 6th or 7th, it will come out incorrectly. In the same test as above, the 7th unit meant to be a Peasant spawned in a Knight. I have not bound that unit to a skill yet, right now its on "Silence" as a placeholder, which I have no units that can cast. Sometimes they come out as the Batrider or Murloc as well, but right now the only 2 im testing with are footmen and peasants so there shouldnt be anything else spawning.

All in all, its working very well for the most part, but the bugs I am not sure where to look or how to correct them. Maybe the Frankensteining i did to make what you wrote fit what i was aiming for messed something up.

(also sorry to be so needy, i have no real programming knowledge of any kind so im at a loss)

These are the triggers I have so far:
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------- --------
      • -------- SpawnVariable Unit Type Data --------
      • -------- --------- --------
      • -------- - --------
      • -------- - --------
      • Set VariableSet PlusOne = (PlusOne + 1)
      • Set VariableSet SpawnUnitType[PlusOne] = Peasant
      • Set VariableSet SpawnAbility[PlusOne] = Charge Gold and Lumber 1
      • Set VariableSet SpawnUnitGoldCost[PlusOne] = 5
      • Set VariableSet SpawnUnitLumberCost[PlusOne] = 0
      • Set VariableSet SpawnFoodCost[PlusOne] = 1
      • -------- - --------
      • Set VariableSet PlusOne = (PlusOne + 1)
      • Set VariableSet SpawnUnitType[PlusOne] = Footman
      • Set VariableSet SpawnAbility[PlusOne] = Charge Gold and Lumber 2
      • Set VariableSet SpawnUnitGoldCost[PlusOne] = 10
      • Set VariableSet SpawnUnitLumberCost[PlusOne] = 1
      • Set VariableSet SpawnFoodCost[PlusOne] = 2
      • -------- - --------
      • Set VariableSet PlusOne = (PlusOne + 1)
      • Set VariableSet SpawnUnitType[PlusOne] = Knight
      • Set VariableSet SpawnAbility[PlusOne] = Silence (Neutral Hostile)
      • Set VariableSet SpawnUnitGoldCost[PlusOne] = 25
      • Set VariableSet SpawnUnitLumberCost[PlusOne] = 0
      • Set VariableSet SpawnFoodCost[PlusOne] = 3
      • -------- - --------
      • Set VariableSet PlusOne = (PlusOne + 1)
      • Set VariableSet SpawnUnitType[PlusOne] = Batrider
      • Set VariableSet SpawnAbility[PlusOne] = Roar (Morph)
      • Set VariableSet SpawnUnitGoldCost[PlusOne] = 25
      • Set VariableSet SpawnUnitLumberCost[PlusOne] = 0
      • Set VariableSet SpawnFoodCost[PlusOne] = 3
      • -------- - --------
      • Set VariableSet PlusOne = (PlusOne + 1)
      • Set VariableSet SpawnUnitType[PlusOne] = Murloc Tiderunner
      • Set VariableSet SpawnAbility[PlusOne] = Death Coil (Neutral Hostile)
      • Set VariableSet SpawnUnitGoldCost[PlusOne] = 1
      • Set VariableSet SpawnUnitLumberCost[PlusOne] = 0
      • Set VariableSet SpawnFoodCost[PlusOne] = 3
      • -------- - --------
      • -------- --------- --------
      • -------- Change this to the number of total unit types --------
      • Set VariableSet Spawn_Total_Types = 5
  • UnitQueueing
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is in SpawnerGroup.) Equal to True
      • (Ability being cast) Not equal to Select Wave 1
      • (Ability being cast) Not equal to Select Wave 2
      • (Ability being cast) Not equal to Select Wave 3
      • (Ability being cast) Not equal to startWave
    • Actions
      • Set VariableSet SpawnAbilityCast = (Ability being cast)
      • -------- Find [Index] associated with ability cast --------
      • For each (Integer Spawn_Index) from 1 to Spawn_Total_Types, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SpawnAbilityCast Equal to SpawnAbility[Spawn_Index]
            • Then - Actions
              • Custom script: exitwhen true
            • Else - Actions
      • -------- Spawn_Index is now set (you can use it to access any Spawn_ data you want) --------
      • Game - Display to (All players) the text: (|cffaaa0ff + ((String(Spawn_Index)) + |r))
      • -------- check active wave # --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpawnSelectedWave Less than Spawner_Active_Wave
        • Then - Actions
          • Game - Display to (All players) the text: wave already passed
          • Skip remaining actions
        • Else - Actions
      • -------- check food cost --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SpawnFoodCurrent[SpawnSelectedWave] + SpawnFoodCost[Spawn_Index]) Greater than SpawnFoodCap
        • Then - Actions
          • Game - Display to (All players) the text: no food
          • Skip remaining actions
        • Else - Actions
      • -------- check gold cost --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) Current gold) Less than SpawnUnitGoldCost[Spawn_Index]
        • Then - Actions
          • Game - Display to (All players) the text: no gold
          • Skip remaining actions
        • Else - Actions
          • Game - Display to (All players) the text: has enough gold
      • -------- check lumber cost --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) Current lumber) Less than SpawnUnitLumberCost[Spawn_Index]
        • Then - Actions
          • Game - Display to (All players) the text: no lumber
          • Skip remaining actions
        • Else - Actions
          • Game - Display to (All players) the text: has enough lumber
      • -------- - --------
      • -------- Change Gold/Lumber Value --------
      • -------- - --------
      • Player - Set (Owner of (Triggering unit)).Current gold to (((Owner of (Triggering unit)) Current gold) - SpawnUnitGoldCost[Spawn_Index])
      • Player - Set (Owner of (Triggering unit)).Current lumber to (((Owner of (Triggering unit)) Current lumber) - SpawnUnitLumberCost[Spawn_Index])
      • -------- - --------
      • -------- update food current --------
      • -------- - --------
      • Set VariableSet SpawnFoodCurrent[SpawnSelectedWave] = (SpawnFoodCurrent[SpawnSelectedWave] + SpawnFoodCost[Spawn_Index])
      • Player - Set (Owner of (Triggering unit)).Food used to (((Owner of (Triggering unit)) Food used) + SpawnFoodCost[Spawn_Index])
      • Game - Display to (All players) the text: (String(SpawnFoodCurrent[SpawnSelectedWave]))
      • -------- - --------
      • -------- Save how many unit types you have in general --------
      • -------- - --------
      • Set VariableSet General_Total = (Load 0 of SpawnSelectedWave from Spawn_Data_Hash.)
      • Set VariableSet General_Total = (General_Total + 1)
      • Hashtable - Save General_Total as 0 of SpawnSelectedWave in Spawn_Data_Hash.
      • -------- - --------
      • -------- Save the actual UnitType (ID that is used in database) --------
      • Hashtable - Save Spawn_Index as General_Total of SpawnSelectedWave in Spawn_Data_Hash.
      • -------- - --------
      • -------- Save how many unit-types you have of this specific unit-type --------
      • Set VariableSet Specific_Total = (Load (Spawn_Index + Spawn_Total_Types) of SpawnSelectedWave from Spawn_Data_Hash.)
      • Set VariableSet Specific_Total = (Specific_Total + 1)
      • Hashtable - Save Specific_Total as (Spawn_Index + Spawn_Total_Types) of SpawnSelectedWave in Spawn_Data_Hash.
      • -------- - --------
      • -------- Units Remaining In Wave Counter --------
      • Set VariableSet SpawnUnitsRemaining[SpawnSelectedWave] = (SpawnUnitsRemaining[SpawnSelectedWave] + 1)
      • Game - Display to (All players) the text: ((String(SpawnUnitsRemaining[SpawnSelectedWave])) + Stored Units)
  • WaveStartTest
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to startWave
    • Actions
      • -------- Set Active Wave --------
      • Set VariableSet Spawner_Active_Wave = 1
      • Countdown Timer - Start WaveSpawnTimer as a One-shot timer that will expire in 3.00 seconds
      • Game - Display to (All players) the text: wavestart
  • SpawningSequence
    • Events
      • Time - WaveSpawnTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpawnUnitsRemaining[Spawner_Active_Wave] Greater than 0
        • Then - Actions
          • Set VariableSet X = (X + 1)
          • Set VariableSet SpawnUnitTotal = (Load 0 of Spawner_Active_Wave from Spawn_Data_Hash.)
          • Set VariableSet Spawn_Index = (Load X of Spawner_Active_Wave from Spawn_Data_Hash.)
          • Unit - Create 1 SpawnUnitType[Spawn_Index] for Player 9 (Gray) at (Center of RCentralHub <gen>) facing SpawnActiveArenaPoint
          • Set VariableSet SpawnUnitsRemaining[Spawner_Active_Wave] = (SpawnUnitsRemaining[Spawner_Active_Wave] - 1)
          • Game - Display to (All players) the text: (String(SpawnUnitsRemaining[Spawner_Active_Wave]))
          • Countdown Timer - Start WaveSpawnTimer as a One-shot timer that will expire in 1.00 seconds
        • Else - Actions
          • Set VariableSet X = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Spawner_Active_Wave Less than 3
            • Then - Actions
              • Set VariableSet Spawner_Active_Wave = (Spawner_Active_Wave + 1)
              • Countdown Timer - Start WaveSpawnTimer as a One-shot timer that will expire in 6.00 seconds
              • Game - Display to (All players) the text: ((String(Spawner_Active_Wave)) + Timer Started!)
            • Else - Actions
              • Set VariableSet Spawner_Active_Wave = 0
              • Game - Display to (All players) the text: Round Over!
              • -------- Cleanup --------
              • Set VariableSet SpawnUnitsRemaining[1] = 0
              • Set VariableSet SpawnUnitsRemaining[2] = 0
              • Set VariableSet SpawnUnitsRemaining[3] = 0
              • Set VariableSet SpawnFoodCurrent[1] = 0
              • Set VariableSet SpawnFoodCurrent[2] = 0
              • Set VariableSet SpawnFoodCurrent[3] = 0
              • Set VariableSet SpawnSelectedWave = 1
              • Player - Set Player 1 (Red).Food used to SpawnFoodCurrent[SpawnSelectedWave]
              • Player - Set Player 1 (Red).Current gold to 0
              • Player - Set Player 1 (Red).Current lumber to 0
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,379
Well, from a quick glance it looks like you're forgetting to reset data stored within the Hashtable.
  • Hashtable - Clear Spawn_Data_Hash
I imagine you'd want to do this during your Cleanup phase so that General_Total and Specific_Total load 0 on your next purchase rather than loading the previously stored data.

Edit:
Oh, and ensure that Charge Gold and Lumber uses a unique Base Order Id for each ability! You never want a unit to have 2+ abilities with the same Order Id.

Edit 2:
It looks like you don't even need the Hashtable since your map only allows one Player to use these variables at a time. For example, General_Total and Specific_Total can be changed to Arrays where the [index] represents the current selected wave, just like you're doing with SpawnUnitsRemaining.

I figured your map was like -> Planning Phase (all players setup their waves at the same time) -> Battle Phase (all waves spawn over time while players sit back and watch the action). I must've missed or forgotten the fact that you said "only one player at any given time", oops.

Edit 3:
Make sure that your Unit that casts the Charge Gold/Lumber ability doesn't have other abilities that will cause the UnitQueuing trigger to run.
 
Last edited:
Level 9
Joined
Mar 17, 2016
Messages
151
So when i tried the command "clear parent hashtable" it stopped working altogether starting from round 2, so I figured i'd just change it to not having the hashtable

Is this the correct way to convert it over?
  • UnitQueueing Test2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Actions
      • -------- Save how many unit types you have in general --------
      • -------- - --------
      • Set VariableSet General_TotalA[SpawnSelectedWave] = (General_TotalA[SpawnSelectedWave] + 1)
      • -------- - --------
      • -------- Save the actual UnitType (ID that is used in database) --------
      • Set VariableSet Spawn_Index = General_TotalA[SpawnSelectedWave]
      • -------- - --------
      • -------- Save how many unit-types you have of this specific unit-type --------
      • Set VariableSet Specific_TotalA[SpawnSelectedWave] = ((Spawn_Index + Spawn_Total_Types) + 1)
      • -------- - --------
      • -------- Units Remaining In Wave Counter --------
      • Set VariableSet SpawnUnitsRemaining[SpawnSelectedWave] = (SpawnUnitsRemaining[SpawnSelectedWave] + 1)
      • Game - Display to (All players) the text: ((String(SpawnUnitsRemaining[SpawnSelectedWave])) + Stored Units)

Also, I do not know how to convert this part in the spawning trigger over regarding the way you used the Unit Index. What I have just goes linearly from units defined until it runs out and then does nothing and I'm not sure what to do to change that.
  • SpawningSequence Test2
    • Events
      • Time - WaveSpawnTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpawnUnitsRemaining[Spawner_Active_Wave] Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: (String(SpawnUnitsRemaining[Spawner_Active_Wave]))
          • Set VariableSet X = (X + 1)
          • Set VariableSet SpawnUnitTotal = General_TotalA[Spawner_Active_Wave]
          • Set VariableSet Spawn_Index = X
          • Unit - Create 1 SpawnUnitType[Spawn_Index] for Player 9 (Gray) at (Center of RCentralHub <gen>) facing SpawnActiveArenaPoint
          • Set VariableSet SpawnUnitsRemaining[Spawner_Active_Wave] = (SpawnUnitsRemaining[Spawner_Active_Wave] - 1)
          • Countdown Timer - Start WaveSpawnTimer as a One-shot timer that will expire in 1.00 seconds
        • Else - Actions
          • Set VariableSet X = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Spawner_Active_Wave Less than 3
            • Then - Actions
              • Set VariableSet Spawner_Active_Wave = (Spawner_Active_Wave + 1)
              • Countdown Timer - Start WaveSpawnTimer as a One-shot timer that will expire in 6.00 seconds
              • Game - Display to (All players) the text: ((String(Spawner_Active_Wave)) + Timer Started!)
            • Else - Actions
              • Set VariableSet Spawner_Active_Wave = 0
              • Game - Display to (All players) the text: Round Over!
              • -------- Cleanup --------
              • Set VariableSet General_TotalA[1] = 0
              • Set VariableSet General_TotalA[2] = 0
              • Set VariableSet General_TotalA[3] = 0
              • Set VariableSet Specific_TotalA[1] = 0
              • Set VariableSet Specific_TotalA[2] = 0
              • Set VariableSet Specific_TotalA[3] = 0
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,379
There's also the option to clear Children of the Hashtable, perhaps that was the correct choice.

Anyway, all you need to do now is fill an Array with Units (or rather their indexes):

Planning Phase:
Unit was purchased -> Increase Y by 1 -> Set UnitToSpawn[Y] = (Purchased unit's index)

Battle Phase:
Timer expires -> Increase X by 1 -> Create UnitToSpawn[X]

Once you reach the cleanup step, reset X and Y.
 
Last edited:
Top