System Easy GUI Wave Spawn System

Bogrim

y hello thar
Reaction score
154
This is an easy-to-implement spawn system which allows a great deal of customization in wave spawns by using hashtables as a double array indexing system to determine unit types and level of difficulty. It is entirely GUI and no Jass knowledge is required to create triggers with the system.

wave.jpg

How It Works​

The system spawns unit waves which numbers and variation of unit types can be customized entirely to fit progression. For instance, the 1st wave might spawn 3 Footmen and 1 Priest, while the 27th wave could spawn 7 knights, 3 Sorceress and 2 Mortar Teams.

- Unit Types

The system saves different types of unit to a hashtable in the map initialization, which are then later used for spawning units in a systematic order.

- Difficulty

The system uses levels of difficulties to slowly and automatically increase the strength of units.


How To Implement​

Download: View attachment Spawn System.w3x

Copy all triggers from Map Initialization and Map Triggers into your map. Make sure that your preferences are set to automatically generate unknown variables while pasting trigger data.

- Editing Variables

You have to update the following variables:

“SpawnPoint” and “SpawnAttack”: Change these variables to match the points in your map.
"Player 2": In the Spawn trigger, change Player 2 to whichever computer player that is controlling the spawn units.

- Adding Spawns

To add spawns to your map, you need to save them to the Hashtable trigger with the following actions:
Trigger:
  • Actions
    • Set Temp_Type = Your Unit Type
    • Custom script: set udg_Temp_Integer = udg_Temp_Type
    • Hashtable - Save Temp_Integer as 0 of 0 in (Last created hashtable)


Modify the unit type to the unit type you wish to add.

You need to change “as 0” to an index that’s not already in use, and avoid spaces between indexes. For instance, if you save 3 different unit types, save them as 0, 1, and 2.

“of 0” is the level of difficulty at which the unit types are created.

Example:
To create a Footman as the first unit type spawned at difficulty 0:
Trigger:
  • Actions
    • Set Temp_Type = Footman
    • Custom script: set udg_Temp_Integer = udg_Temp_Type
    • Hashtable - Save Temp_Integer as 0 of 0 in (Last created hashtable)

And a Knight at difficulty 1:
Trigger:
  • Actions
    • Set Temp_Type = Knight
    • Custom script: set udg_Temp_Integer = udg_Temp_Type
    • Hashtable - Save Temp_Integer as 0 of 1 in (Last created hashtable)

- Setting Spawn Numbers:

To modify the number of units created, adjust the variables in the triggers “Variables” and in any difficulty level triggers.

The variable SpawnNumber[Index] controls how many units are created of each index (“as 0”) in the current level of difficulty. You need to set the specifics for this variable to vary the amount of units created.

Example:
A Footman is saved as index 0, a Rifleman as index 1 and a Priest as index 2:
Trigger:
  • Actions
    • Set SpawnNumber[0] = 4
    • Set SpawnNumber[1] = 2
    • Set SpawnNumber[2] = 1

The wave would then spawn 4 Footmen, 2 Riflemen and 1 Priest.

- Setting Spawn Waves:

The variable “SpawnWaves” is how many waves there are left before the difficulty increases.

“SpawnIncrement[Index]” controls how many waves there are at each level of difficulty.

Example:
To create 10 waves at difficulty 1 and 14 waves at difficulty 2, simply set the variable to the following values in the Variables trigger:
Trigger:
  • Actions
    • Set SpawnIncrement[1] = 10.00
    • Set SpawnIncrement[2] = 14.00

Modifying Difficulty Levels​

To vary the number of units and unit-types created at each level of difficulty, simply create a trigger to update the variables:

Trigger:
  • Difficulty 1
    • Events
      • Game - Difficulty becomes Equal to 1.00
    • Conditions
    • Actions
      • Set SpawnTypes = 3
      • Set SpawnNumber[0] = 3
      • Set SpawnNumber[1] = 2
      • Set SpawnNumber[2] = 1
      • Set SpawnNumber[3] = 1

The events picks up on when the difficulty is increased.

- SpawnTypes determine how many different types that are created in the wave, from the unit-types you set in the hashtable at the current level of difficulty.

- Update SpawnNumber to the numbers of each type you wish to be spawned.

Create Your Own Wave Spawn Trigger​

The “Begin Game” and “Wave End” triggers are just examples of the frequency at which you can create waves. You might want to create a periodic time event trigger to run the spawn trigger every X seconds. This completely depends on how you want your spawn system to be.

Example:
Trigger:
  • Spawn Waves
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
    • Actions
      • Trigger - Run Spawn <gen> (ignoring conditions)

Map Triggers (Large)
Trigger:
  • Hashtable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Read Trigger Comment on how to add units to the hashtable --------
      • Hashtable - Create a hashtable
      • Set SpawnTable = (Last created hashtable)
      • -------- Unit Types are saved to the Hashtable --------
      • -------- difficulty 0 --------
      • Set Temp_Type = Dark Troll
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 0 of 0 in (Last created hashtable)
      • Set Temp_Type = Dark Troll Shadow Priest
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 1 of 0 in (Last created hashtable)
      • Set Temp_Type = Dark Troll Trapper
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 2 of 0 in (Last created hashtable)
      • -------- difficulty 1 --------
      • Set Temp_Type = Furbolg
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 0 of 1 in (Last created hashtable)
      • Set Temp_Type = Furbolg Shaman
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 1 of 1 in (Last created hashtable)
      • Set Temp_Type = Furbolg Tracker
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 2 of 1 in (Last created hashtable)
      • Set Temp_Type = Furbolg Champion
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 3 of 1 in (Last created hashtable)
      • -------- difficulty 2 --------
      • Set Temp_Type = Giant Wolf
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 0 of 2 in (Last created hashtable)
      • Set Temp_Type = Satyr Shadowdancer
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 1 of 2 in (Last created hashtable)
      • Set Temp_Type = Satyr Soulstealer
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 2 of 2 in (Last created hashtable)
      • Set Temp_Type = Dark Troll Warlord
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 3 of 2 in (Last created hashtable)
      • Set Temp_Type = Dire Wolf
      • Custom script: set udg_Temp_Integer = udg_Temp_Type
      • Hashtable - Save Temp_Integer as 4 of 2 in (Last created hashtable)
Trigger:
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Difficulty controls the set of units created. The variable automatically increases when the spawn waves for a previous set has been defeated. --------
      • Set Difficulty = 0.00
      • -------- SpawnTypes equals the number of different unit-types that are created each wave. --------
      • Set SpawnTypes = 2
      • -------- SpawnNumber is the number of units that will be spawned of each type. The index equals the spawn type, and the value the number of units. --------
      • Set SpawnNumber[0] = 4
      • Set SpawnNumber[1] = 2
      • Set SpawnNumber[2] = 1
      • -------- SpawnPoint is where the units are created, and SpawnAttack is where the units will go. These variables should be replaced with whichever point variables your map uses. --------
      • Set SpawnPoint = (Center of Spawn Rect <gen>)
      • Set SpawnAttack = (Center of End Rect <gen>)
      • -------- SpawnWaves sets the initial amount of waves before the difficulty increases --------
      • Set SpawnWaves = 4.00
      • -------- Spawn Increment sets how many waves that runs per difficulty, each array index equals a difficulty --------
      • Set SpawnIncrement[1] = 6.00
      • Set SpawnIncrement[2] = 8.00
Trigger:
  • Spawn
    • Events
    • Conditions
    • Actions
      • -------- The loop spawns a set number of unit groups, each of a different type. Integer A is used to load the different indexes from the Hashtable. --------
      • For each (Integer A) from 0 to SpawnTypes, do (Actions)
        • Loop - Actions
          • Set Temp_Integer = (Load (Integer A) of (Integer(Difficulty)) from SpawnTable)
          • Custom script: set udg_Temp_Type = udg_Temp_Integer
          • Unit - Create SpawnNumber[(Integer A)] Temp_Type for Player 2 (Blue) at SpawnPoint facing Default building facing degrees
          • Set Temp_Group = (Last created unit group)
          • Unit Group - Add all units of Temp_Group to SpawnGroup
          • Custom script: call DestroyGroup( udg_Temp_Group )
      • Unit Group - Pick every unit in SpawnGroup and do (Unit - Order (Picked unit) to Attack-Move To SpawnAttack)
      • Set SpawnWaves = (SpawnWaves - 1.00)
Trigger:
  • Difficulty Increase
    • Events
      • Game - SpawnWaves becomes Equal to 0.00
    • Conditions
    • Actions
      • Set Difficulty = (Difficulty + 1.00)
      • Set SpawnWaves = SpawnIncrement[(Execution count of (This trigger))]
Trigger:
  • Difficulty 1
    • Events
      • Game - Difficulty becomes Equal to 1.00
    • Conditions
    • Actions
      • Set SpawnTypes = 3
      • Set SpawnNumber[0] = 3
      • Set SpawnNumber[1] = 2
      • Set SpawnNumber[2] = 1
      • Set SpawnNumber[3] = 1
Trigger:
  • Difficulty 2
    • Events
      • Game - Difficulty becomes Equal to 2.00
    • Conditions
    • Actions
      • Set SpawnTypes = 4
      • Set SpawnNumber[0] = 4
      • Set SpawnNumber[1] = 2
      • Set SpawnNumber[2] = 2
      • Set SpawnNumber[3] = 1
      • Set SpawnNumber[4] = 1
Note: The trigger comments further explains the triggers' functionality.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top