This is a very simple script that makes it very easy to edit and add new levels. No more copy pasting and repetitive, boring, eye-killing clicking!
.
..
-=-=-=-=- Global Variables -=-=-=-=-
Level = 1 <Integer>
Defines the current level. It's default number is set to "1".
Player Spawn = No Point <Point[xx]>
Defines where the player's spawn is. This can be changed to a region. This and "Player End" are the only variables that must be manually set. The array is equal to the amount of players in the game. Player 1's spawn is set as "Player Spawn[1]", Player 2 to [2], etc. (Create a new trigger and assign the points/regions at Map Initialization)
Player Spawn = No Point <Point[xx]>
Defines where the player's end zone is. This can be changed to a region. This and "Player Spawn" are the only variables that must be manually set. The array is equal to the amount of players in the game. Player 1's end zone is set as "Player End[1]", Player 2 to [2], etc. (Create a new trigger and assign the points/regions at Map Initialization)
-=-=-=-=- Initiation -=-=-=-=-
....Events
........ Game - Map initialization
....Local Variables
....Conditions
....Actions
........ Trigger - Run Start Level (Check Conditions, Don't Wait until it finishes)
........ Trigger - Turn Init Level On
........ Variable - Set Level = (Level + 1)
.
This trigger sets up and starts the wave spawning.
Trigger - Run Start Level
Runs "Run Start Level". (This sends the starting wave).
Trigger - Turn Init Level On
Turns on (not run!) "Init Level On" which starts the timer for new waves.
Variable - Set Level = (Level +1)
Sets "Level" to [Level + 1] (Sets Level to 2 to avoid spawning Level 1 twice).
.
..
-=-=-=-=- Init Level -=-=-=-=-
....Events
........ Timer - Every 30.0 seconds of Game Time
....Local Variables
....Conditions
....Actions
........ Trigger - Run Start Level (Check Conditions, Don't Wait until it finishes)
........ Variable - Set Level = (Level + 1)
.
This trigger sends a new wave every30 seconds.
Trigger - Run Start Level
Runs the send wave trigger.
Variable - Set Level = (Level +1)
Sets "Level" to [Level + 1]. If the current level is 1, the variable will be set to 2. This makes it so that on the next 30-second cycle, the next level will be sent.
.
..
-=-=-=-=- Start Level -=-=-=-=-
....Events
....Local Variables
........Unit = No Game Link <Game Link - Unit[5]>
........ Number Of Units = 0 <Integer[5]>
....Conditions
....Actions
........ Variable - Set Unit[1] = Zealot
........ Variable - Set Number Of Units[1] = 20
........ Variable - Set Unit[2] = Stalker
........ Variable - Set Number Of Units[2] = 30
........ General - If (Conditions) then do (Actions) else do (Actions)
............ If
................ Unit[Level] == Any
............Then
........ Player Group - Pick each player in (All players) and do (Actions)
............ Actions
................ Unit - Create Number Of Units[Level] Unit[Level] for player 15 at Player Spawn[(Picked player)]
................facing 270.0 degrees (No Options)
................ Unit - Order all units in (Last created units) to ( Attack targeting Player End[(Picked player)])
................(Replace Existing Orders)
............Else
........ Player Group - Pick each player in (All players) and do (Actions)
............ Actions
................Game - End game in Victory for player (Picked player) (Show dialogs, Show score screen)
.
This triggerdefinesandsends the waves.
Unit = No Game Link <Game Link - Unit[5]>
Creates a variable that holds all the wave units. The array number is set to however many levels are wanted.
Number Of Units = 0 <Integer[5]>
Creates a variable that holds the number of units to send for every wave. The array number is set to however many levels are wanted.
Variable - Set Unit[xx] = xx
Sets the level units. Example: "Variable - Set Unit[1] = Zealot" sets Level 1 to Zealots.
Variable - Set Number Of Units[xx] = xx
Sets the amount of units for the level. Example: "Variable - Set Number Of Units[1] = 20" will spawn 20 units for Level 1.
General - If (Conditions) then do (Actions) else do (Actions), If, Then, Else
Because it'd be too confusing and ridiculous to explain this part separately, I'll just explain the process.
First, it checks for Unit[Level] == Any. This is checking to make sure that the current level has a set unit.
If the current level does have a set unit, then it does Player Group - Pick each player in (All players) and do (Actions) which is doing the following actions for each player.
Unit - Create Number Of Units[Level] Unit[Level] for player 15 at Player Spawn[(Picked player)] facing 270.0 degrees (No Options)
This is a bit confusing. This creates the number of units set by the "Number of Units" and "Unit" variables mentioned earlier. By using the "Level" variable as the array number, we can dynamically spawn the type and number of the level wave.
Unit - Order all units in (Last created units) to (Move targeting Player End[(Picked player)]) (Replace Existing Orders)
This is pretty straightforward. It orders the units we just created for the wave to move to where they need to go.
However, if there is no unit set for the current level, the trigger will assume that the game has ended, and the players are victorious. Obviously this isn't perfect, but I'm sure that after reading this tutorial you'll be able to figure out the way to make this perfect. :P
Walkthrough by Sevenation
Difficulty: Intermediate
This is a very simple script that makes it very easy to edit and add new levels. No more copy pasting and repetitive, boring, eye-killing clicking!
.
. .
-=-=-=-=- Global Variables -=-=-=-=-
Level = 1 <Integer>
Defines the current level. It's default number is set to "1".
Player Spawn = No Point <Point[xx]>
Defines where the player's spawn is. This can be changed to a region. This and "Player End" are the only variables that must be manually set. The array is equal to the amount of players in the game. Player 1's spawn is set as "Player Spawn[1]", Player 2 to [2], etc. (Create a new trigger and assign the points/regions at Map Initialization)
Player Spawn = No Point <Point[xx]>
Defines where the player's end zone is. This can be changed to a region. This and "Player Spawn" are the only variables that must be manually set. The array is equal to the amount of players in the game. Player 1's end zone is set as "Player End[1]", Player 2 to [2], etc. (Create a new trigger and assign the points/regions at Map Initialization)
-=-=-=-=- Initiation -=-=-=-=-
.... Events
........ Game - Map initialization
.... Local Variables
.... Conditions
.... Actions
........ Trigger - Run Start Level (Check Conditions, Don't Wait until it finishes)
........ Trigger - Turn Init Level On
........ Variable - Set Level = (Level + 1)
.
This trigger sets up and starts the wave spawning.
Trigger - Run Start Level
Runs "Run Start Level". (This sends the starting wave).
Trigger - Turn Init Level On
Turns on (not run!) "Init Level On" which starts the timer for new waves.
Variable - Set Level = (Level +1)
Sets "Level" to [Level + 1] (Sets Level to 2 to avoid spawning Level 1 twice).
.
. .
-=-=-=-=- Init Level -=-=-=-=-
.... Events
........ Timer - Every 30.0 seconds of Game Time
.... Local Variables
.... Conditions
.... Actions
........ Trigger - Run Start Level (Check Conditions, Don't Wait until it finishes)
........ Variable - Set Level = (Level + 1)
.
This trigger sends a new wave every 30 seconds.
Trigger - Run Start Level
Runs the send wave trigger.
Variable - Set Level = (Level +1)
Sets "Level" to [Level + 1]. If the current level is 1, the variable will be set to 2. This makes it so that on the next 30-second cycle, the next level will be sent.
.
. .
-=-=-=-=- Start Level -=-=-=-=-
.... Events
.... Local Variables
........ Unit = No Game Link <Game Link - Unit[5]>
........ Number Of Units = 0 <Integer[5]>
.... Conditions
.... Actions
........ Variable - Set Unit[1] = Zealot
........ Variable - Set Number Of Units[1] = 20
........ Variable - Set Unit[2] = Stalker
........ Variable - Set Number Of Units[2] = 30
........ General - If (Conditions) then do (Actions) else do (Actions)
............ If
................ Unit[Level] == Any
............ Then
........ Player Group - Pick each player in (All players) and do (Actions)
............ Actions
................ Unit - Create Number Of Units[Level] Unit[Level] for player 15 at Player Spawn[(Picked player)] ................facing 270.0 degrees (No Options)
................ Unit - Order all units in (Last created units) to ( Attack targeting Player End[(Picked player)]) ................(Replace Existing Orders)
............ Else
........ Player Group - Pick each player in (All players) and do (Actions)
............ Actions
................Game - End game in Victory for player (Picked player) (Show dialogs, Show score screen)
.
This trigger defines and sends the waves.
Unit = No Game Link <Game Link - Unit[5]>
Creates a variable that holds all the wave units. The array number is set to however many levels are wanted.
Number Of Units = 0 <Integer[5]>
Creates a variable that holds the number of units to send for every wave. The array number is set to however many levels are wanted.
Variable - Set Unit[xx] = xx
Sets the level units. Example: "Variable - Set Unit[1] = Zealot" sets Level 1 to Zealots.
Variable - Set Number Of Units[xx] = xx
Sets the amount of units for the level. Example: "Variable - Set Number Of Units[1] = 20" will spawn 20 units for Level 1.
General - If (Conditions) then do (Actions) else do (Actions), If, Then, Else
Because it'd be too confusing and ridiculous to explain this part separately, I'll just explain the process.
First, it checks for Unit[Level] == Any. This is checking to make sure that the current level has a set unit.
If the current level does have a set unit, then it does Player Group - Pick each player in (All players) and do (Actions) which is doing the following actions for each player.
Unit - Create Number Of Units[Level] Unit[Level] for player 15 at Player Spawn[(Picked player)] facing 270.0 degrees (No Options)
This is a bit confusing. This creates the number of units set by the "Number of Units" and "Unit" variables mentioned earlier. By using the "Level" variable as the array number, we can dynamically spawn the type and number of the level wave.
Unit - Order all units in (Last created units) to (Move targeting Player End[(Picked player)]) (Replace Existing Orders)
This is pretty straightforward. It orders the units we just created for the wave to move to where they need to go.
However, if there is no unit set for the current level, the trigger will assume that the game has ended, and the players are victorious. Obviously this isn't perfect, but I'm sure that after reading this tutorial you'll be able to figure out the way to make this perfect. :P
Thanks for reading!