Before we can start working on the triggers and data, we need to build the actual terrain. So fire up the galaxy editor and make a new map file. Make sure you use campagin dependencies so you have access to the campagin-only models. Set the map bounds and tile set to whatever you feel like- you can always change those settings later.
Hit okay and you're new map terrain will be generated. Right now its going to be a flat piece of ground. You need to set up lanes for the creeps to travel through.
1. Press "T" to switch to your terrain pallet if your not already there. Push the button that shows the cliff with the little green arrow to switch to cliff editing mode.
2. You can now use the 'raise cliff' and 'lower cliff' tools to build some walls for your creeps to travel through. Your towers will be constructed on the raised walls, so make sure they are thick enough for a building to be on top.
3. Now press P to switch to the points tab. Place 2 points on your terrain- one for the start point, and one for the exit point.
4. Now press R to swap to the regions tab. Make a region around the exit point and call it 'exit region'.
5. The final important piece for terrain is setting the pathing. Press H to use the pathing editor. Select 'add pathing' and 'no build zone'. Then paint this pathing over the area the creeps will walk down. This will prevent the player from building towers inside the walkway.
Moving on to data
Now we have the terrain done and out of the way. Obviously when your map is finished, you should probably 'pretty it up' a little.
6. Press F6 to open the trigger editor. Heres a picture of the trigger editor with the parts labeled so you will know they're called when I refer to them later.
7. Click on the melee initialization trigger that is there by default. Delete the 4 default actions in the actions list to the right, since we dont need them.
8. Now we're going to set up some variables that we will need in the future. Right click the trigger window and choose 'new variable' to make a new variable. You will need to make the following variables for now:
Current Wave (integer)
Wave Type (unit type)
Wave Count (integer)
To change the variable type from integer to unit type, just click on the variable and use the drop down menu next to where it says 'type'. We need Wave Type and Wave Count to be arrays (you will see why later). To make them arrays, just select one, check the box that says 'array', and set the first value next to 'size' to 100.
9. Now we have the variables we will need set up. Name a new trigger (right click in the 'triggers& variables' window and choose 'new trigger'). name it "set up".
10. Right click in the actions area and pick 'new event' and choose "Map initialization". This will make it so that this trigger runs right when the map starts.
11. Right click and choose new action. Pick set variable and hit ok. Now click on 'variable' in the action editor area and set it to 'wave type'. When you hit ok, you will see the text 'variable' has changed to 'wave type [0]'. Click on the 0 and set it to 1. Then set the value to the drone unit.
12. Add the same action again (set variable). This time, set 'wave count [1]' to 10.
It's Explaining Time!
What the heck was the point of that trigger? We will use these 2 variables to determine which units spawn in our tower defense. Wave type is which type of unit will spawn and wave count is how many of that unit will spawn. The number inside the brackets [ ] is which wave the variable applies to. So say we wanted 9 zerglings to spawn on wave 4. We would set 'wave type[4]' to zerglings and 'wave count[4]' to 9. So in this trigger, you need to set up all your waves in the same way we just set up the first wave.
The Spawning Trigger
13. Make a new trigger called 'spawn waves'. Set the event to map initialization, just like before.
14. Add the event 'modify variable'. Make sure you pick modify variable (integer) and NOT set variable. They are different actions. Set the variable to 'current wave' and leave the operation at +1.
15. Heres where it gets a little tricky. Add the action 'repeat' This will make an action appear with a little subsection that says 'action' below it. First click on the actual repeat action and click on the value '10' in the action editor area. Set that to 'enemies per wave'. Then set the value in the brackets of 'enemies per wave' to the 'wave count' variable. Then Right click on that little 'action' icon below 'repeat' and pick 'add action'. Pick 'create units with default facing'.
That step was a little confusing so make sure your screen looks like mine before moving on.
16. Click on unit in the action editor area and set it to wave type. Then set the value inside the brackets to 'current wave'. Set the player to 15. Set the point to your starting point you made earlier.
17. Add a new action. Pick "issue order to unit". Make sure you place this action 'inside' the repeat action from earlier, just like with the create unit action. Click on 'triggering unit' and change it to 'last created unit'. Now click on the parentheses " ( " symbol to the left of 'ability command' and pick 'order targeting point'. Click on the ability command and set it to move. Make sure you choose the correct 'move' in the list, since there are two. The move you don't want to pick says 'beacon' in the column next to it. Finally, set the target point to your exit point that you created earlier.
18. Now add the action 'wait' after 'issue order to unit'. Once again, make sure it is inside the repeat action. Set it to wait 1.5 game time seconds.
19. Okay. Now add the action 'wait' againand set it to 30 game time seconds. Make sure this one is outside the 'repeat' action. This is the time it will take in between waves, so if you have a larger map than me, you will need to set this value higher. Keep in mind most games are run at the fastest speed. In these games, 1 second of real life is about 1.5 seconds in game time.
20. It's time to add the last action. Add 'run trigger'. Set the trigger to 'spawn trigger'.
21. Now we need to make sure everything is working properly. Go back to the terrain editor by pressing F5. Place some units for player 1 so that you can see whats going on, and then test the map (control + F9)
Now its time for the last part for this tutorial. You may have noticed that the units bunch up at your exit point. Thats not what we want at all, though. Units that make it to the end should be removed from the game. So...
22, Make a new trigger called 'unit exit'. Set the event to any unit enters region. Change the region from 'entire map' to the exit region you made earlier. Add a new condition (right click + new condition) . A window will pop up, but just hit ok. The default condition is 'owner of triggering unit == 1'. Luckily for us, this is exactly the condition we need. Just change the 1 at the end to 15. The only action you need to add is 'remove unit'.
Thats it for now!
Sad face :( Hopefully you learned something remotely useful from this tutorial. The next part will cover how to make a builder unit and towers. But what will you do while you wait for the next part to come out? I know !! Since the next part deals with data, unit duplication, and ability modification, I highly recommend you look at my 'getting started' tutorial (in my signature below this). Data and Unit Duplication is a bit more tricky than this, and I may not go over it in great detail. Luckily for you, I DO go over unit duplication in my getting started tutorial.
Please PM me any questions, comments, or suggestions you have.
How to make a TD Wave System
What this tutorial will cover
Setting Up the Terrain
Before we can start working on the triggers and data, we need to build the actual terrain. So fire up the galaxy editor and make a new map file. Make sure you use campagin dependencies so you have access to the campagin-only models. Set the map bounds and tile set to whatever you feel like- you can always change those settings later.
Hit okay and you're new map terrain will be generated. Right now its going to be a flat piece of ground. You need to set up lanes for the creeps to travel through. 1. Press "T" to switch to your terrain pallet if your not already there. Push the button that shows the cliff with the little green arrow to switch to cliff editing mode.
2. You can now use the 'raise cliff' and 'lower cliff' tools to build some walls for your creeps to travel through. Your towers will be constructed on the raised walls, so make sure they are thick enough for a building to be on top.
3. Now press P to switch to the points tab. Place 2 points on your terrain- one for the start point, and one for the exit point.
4. Now press R to swap to the regions tab. Make a region around the exit point and call it 'exit region'.
5. The final important piece for terrain is setting the pathing. Press H to use the pathing editor. Select 'add pathing' and 'no build zone'. Then paint this pathing over the area the creeps will walk down. This will prevent the player from building towers inside the walkway.
Moving on to data
Now we have the terrain done and out of the way. Obviously when your map is finished, you should probably 'pretty it up' a little.
6. Press F6 to open the trigger editor. Heres a picture of the trigger editor with the parts labeled so you will know they're called when I refer to them later.
7. Click on the melee initialization trigger that is there by default. Delete the 4 default actions in the actions list to the right, since we dont need them.
8. Now we're going to set up some variables that we will need in the future. Right click the trigger window and choose 'new variable' to make a new variable. You will need to make the following variables for now:
To change the variable type from integer to unit type, just click on the variable and use the drop down menu next to where it says 'type'. We need Wave Type and Wave Count to be arrays (you will see why later). To make them arrays, just select one, check the box that says 'array', and set the first value next to 'size' to 100.
9. Now we have the variables we will need set up. Name a new trigger (right click in the 'triggers& variables' window and choose 'new trigger'). name it "set up".
10. Right click in the actions area and pick 'new event' and choose "Map initialization". This will make it so that this trigger runs right when the map starts.
11. Right click and choose new action. Pick set variable and hit ok. Now click on 'variable' in the action editor area and set it to 'wave type'. When you hit ok, you will see the text 'variable' has changed to 'wave type [0]'. Click on the 0 and set it to 1. Then set the value to the drone unit.
12. Add the same action again (set variable). This time, set 'wave count [1]' to 10.
It's Explaining Time!
What the heck was the point of that trigger? We will use these 2 variables to determine which units spawn in our tower defense. Wave type is which type of unit will spawn and wave count is how many of that unit will spawn. The number inside the brackets [ ] is which wave the variable applies to. So say we wanted 9 zerglings to spawn on wave 4. We would set 'wave type[4]' to zerglings and 'wave count[4]' to 9. So in this trigger, you need to set up all your waves in the same way we just set up the first wave.
The Spawning Trigger
13. Make a new trigger called 'spawn waves'. Set the event to map initialization, just like before.
14. Add the event 'modify variable'. Make sure you pick modify variable (integer) and NOT set variable. They are different actions. Set the variable to 'current wave' and leave the operation at +1.
15. Heres where it gets a little tricky. Add the action 'repeat' This will make an action appear with a little subsection that says 'action' below it. First click on the actual repeat action and click on the value '10' in the action editor area. Set that to 'enemies per wave'. Then set the value in the brackets of 'enemies per wave' to the 'wave count' variable. Then Right click on that little 'action' icon below 'repeat' and pick 'add action'. Pick 'create units with default facing'.
That step was a little confusing so make sure your screen looks like mine before moving on.
16. Click on unit in the action editor area and set it to wave type. Then set the value inside the brackets to 'current wave'. Set the player to 15. Set the point to your starting point you made earlier.
17. Add a new action. Pick "issue order to unit". Make sure you place this action 'inside' the repeat action from earlier, just like with the create unit action. Click on 'triggering unit' and change it to 'last created unit'. Now click on the parentheses " ( " symbol to the left of 'ability command' and pick 'order targeting point'. Click on the ability command and set it to move. Make sure you choose the correct 'move' in the list, since there are two. The move you don't want to pick says 'beacon' in the column next to it. Finally, set the target point to your exit point that you created earlier.
18. Now add the action 'wait' after 'issue order to unit'. Once again, make sure it is inside the repeat action. Set it to wait 1.5 game time seconds.
19. Okay. Now add the action 'wait' againand set it to 30 game time seconds. Make sure this one is outside the 'repeat' action. This is the time it will take in between waves, so if you have a larger map than me, you will need to set this value higher. Keep in mind most games are run at the fastest speed. In these games, 1 second of real life is about 1.5 seconds in game time.
20. It's time to add the last action. Add 'run trigger'. Set the trigger to 'spawn trigger'.
21. Now we need to make sure everything is working properly. Go back to the terrain editor by pressing F5. Place some units for player 1 so that you can see whats going on, and then test the map (control + F9)
Now its time for the last part for this tutorial. You may have noticed that the units bunch up at your exit point. Thats not what we want at all, though. Units that make it to the end should be removed from the game. So...
22, Make a new trigger called 'unit exit'. Set the event to any unit enters region. Change the region from 'entire map' to the exit region you made earlier. Add a new condition (right click + new condition) . A window will pop up, but just hit ok. The default condition is 'owner of triggering unit == 1'. Luckily for us, this is exactly the condition we need. Just change the 1 at the end to 15. The only action you need to add is 'remove unit'.
Thats it for now!
Sad face :( Hopefully you learned something remotely useful from this tutorial. The next part will cover how to make a builder unit and towers. But what will you do while you wait for the next part to come out? I know !! Since the next part deals with data, unit duplication, and ability modification, I highly recommend you look at my 'getting started' tutorial (in my signature below this). Data and Unit Duplication is a bit more tricky than this, and I may not go over it in great detail. Luckily for you, I DO go over unit duplication in my getting started tutorial.
Please PM me any questions, comments, or suggestions you have.
Reserved for space.
PM me any questions, comments, or suggestions you have.
Nice Tutorial