Guide - Tower Defense


The Silent Pandaren Helper
Reaction score
Give a meaning to your TD - Theoretical part​

Introduction: The trigger part is mainly for a Tower Defense meant for 1 or 2 teams. Some tweakage is required by you, if you wish to make a TD, where every players defends for himself/herself.

Frozen Throne Required

Before we are going to make some real triggers, you have to know, what you are planning to create – creeps, towers, abilities and/or special features, twists. I am going to give a few tips how to do that.

Step 1 - Planning Creeps

Firstly, open Excel (I tend to create my notes, plans in excel or in word, but pencil and paper or text editing programs will do, too.) and create 6 columns named creep, level, HP, special features, movement speed and armor.


Then leave one row blank and start filling the table. It makes your life a lot easier: You can put down notes, even if you are not able to use WE. (Maybe you are at work, on vacation with a laptop, etc.)


Step 2 – Planning Towers

For planning towers, open sheet 2. Now create 7 columns named tower, cost, damage, attack, cooldown, upgrades to and special features.


Now remains only the issue of thinking out the towers, and filling the table. (I find thinking out things as amusing as creating them in WE for real).


Step 3 – Planning Pathing

The keyword for team defenses is symmetry. You want to give all the players equal opportunities, which makes game play fair. Before starting, decide how many players your TD is going to have.

The one in this tutorial will have 8 players.

After deciding that, I'll make a sketch drawing of the pathing map, considering it has to be symmetrical for 8 players.


I used Excel, so no drawing skills required to do this simple sketch (Row and cell width are the same).

As you see, I have marked the starting positions and end point. Now, being happy with the result, I'll make it for real, in WE.

If you are viewing this from the world-editor-tutorials, then click here to continue to Part II - Object Editor and Part III - Triggerwerkz.
Object Editor

Step 1 – Creating and Modifying a Tower

Alright, lets start constructing a basic tower for our Tower Defense (referenced as TD from now).

Firstly, we need to choose a base tower from the existing ones to modify. Lets choose the “Guard Tower”. Select it and make a copy out of it.

TIP: It’s recommended, that all the towers have the same pathing map – the green square you see when trying to place it somewhere when looking a place for it to construct it. The “Scout Tower” has a pathing map 2x2 and it’s very suitable for TD’s.​

You have followed me quite nicely. The first thing we need to change is the damage of our tower.

It's up to you and your maps balance which the values will be.




As you can see from these fields, there is no such things as minimal and maximum damage. Just some dice and die, but actually, it’s very easy to manipulate them, if you follow the formula below.


After that, lets change the damage type and cooldown of our tower.



Now, lets get rid of the building requirements to allow our builder to build it, and, might as well the upgrades used by it.



Lastly, you might want to change the appearance of the tower. The general appeal. Change the fields below to your liking.




Step 2 – Building and Upgrading a Tower Into Another

To allow your custom builder to build the tower, add the base tower to the structures built list.


Now, if you want your builder to be able to build many towers at a time (like the "Acolyte"), then, change the builders race to "Undead".


After that, change the cost of the tower to suit your needs.

Note: Cost of the tower = cost to upgrade it (for upgrades).



Upgrading a tower into another is very simple. You just need the base tower (the one we created in step 1) and a slightly stronger version of it.

You now know the basics how to create a tower, so, make a copy out of the base tower and alter it to make it stronger.

After done that, select the base tower and add the stronger version to the upgrade listing.


Lastly, you might want to change the building time to be shorter.


Step 3 - Creeps modification

By now, you should be done with towers. Proceed to modifying creeps.

You should have a generic plan, an idea how many levels of creeps you will have and how many bosses etc.

It's hard to give any pointers how to balance a TD - you just have to test, test and test!

Usually, the creeps in the beginning have lower health points, armor, movement speed.




TIP: The best way to avoid creeps attacking your towers is by removing their ability to attack.


Also, lower level creeps should give less bounty. The bounty works the same way as the damage dice/side, the same formula.


Before I start introducing You some triggers, I would like to explain few things. So, here we go!

– If a trigger contains variables, this indicates what type the variable is.
– Custom script leaks removal. Important.
– Comments. Pay attention to these, too.

Step 1 – Variable setup

Before we can do anything at all, we have to initialize a few variables. How on earth are You going to create a spawning trigger, if you haven’t got any creeps to spawn?


Note: Player colours.

|c00ff0303 – Red
|c000042ff – Blue
|c001ce6b9 – Teal
|c00540081 – Purple
|c00fffc01 – Yellow
|c00feba0e – Orange
|c0020c000 – Green
|c00e55bb0 - Pink
|c00e55bb0 - Gray

Users request: additional colour codes

Step 2 – Game Setup

It’s nice to have a thing of some sort, which keeps tracks of kills and players, who are currently playing. Lets use a leaderboard for that. Also, it’s kind of annoying, if you pre-place builders for all players. What if player green is not in the game? It is better to pick all the players, who are currently playing and create them their builders, isn’t it?


The leaderboard.


Step 3 – Pathing

To make the creeps move on the lane, which the players have to defend, you need to create regions via the region palette at and order the creeps to move from one region to another. It is best to use the minimal amount of regions, placing them only in the turning points.


Note: When you have a really long straight line, the creeps tend to curve to the side, when walking from the checkpoint at the start to the checkpoint in the end. To prevent that, place (a few) a region(s) in the middle of the lane too.​

Making a trigger for every region is very annoying. Lets skip that and use the creeps custom value and some region arrays to make the pathing system as economical as possible. Start setting your regions into arrays.


Note: You must begin setting the array indexes from 0, not 1. Units' custom values are 0 by default, not 1.

After that, you just need to order them to move from one region to another. Basically, the custom value is there to keep track of the regions the unit has entered, so it can order it to move the next correct region.


Step 4 – Spawning creeps

To get started, place your players’ starting locations on top of the spawn region. It’s to shorten the code and to, yet again, make everything as efficient as possible.
To trigger the next wave, lets use the creeps food count to determine when all of them are dead and when it’s safe to launch a new wave of ugly creeps.

Firstly, set the amount of creeps you want to spawn in each wave.


Note: This spawning trigger requires that every creep costs at least 1 food.


The timer window


To put it simple, it initializes the next wave and gives the players some bonus gold&time to prepare for the wave. If the last wave has been defeat, it will pick all the players, who are playing and shows them the victory message.

And the trigger, which takes care of the spawning:

Note: A players starting location must be placed on top of his spawn region, so that the trigger creates the creeps in the right position.​


Step 5 – Keeping track of kills and lives

The basic concept of a tower defence is to defeat all the waves of creeps without losing your “lives”. A lot of these TD’s use a periodic event to determine when the “lives” variable has reached zero. That is completely unneeded.


As for keeping track of the kills, that is rather simple. You just have to update the leaderboard and the “killsCount” variable every time a players kills a creep.


Step 6 – Final touch

When a player leaves, you should remove him/her from the “inGamePlayers” variable, to prevent spawning creeps for non-existent player, which tends to ruin the game from everyone else. Also, in my honest opinion, it’s nice to remove all the units owned by the left player.


It’s useful, when players have the ability to sell built towers.

Firstly, make a dummy spell instant target spell, like “thunder Clap”. Set all the fields to do nothing, give it a nice thematic icon and add the ability to all of the towers.

After that, you need to mess with the towers point values.


Lets say you have a tower with 3 upgrades: the base tower and upgrades from I to III . The base tower costs 100 coins, upgrade I costs 150 coins, upgrade II 200 coins and upgrade III 250 costs coins.
The basic idea is to add the next upgrade cost to the previous upgrade costs. The base tower costs 100 coins, change it's point value to 100(it should be that by default, already), upgrade I costs 150 coins. Add that to the base value, 100 + 150 = 250. And know, just do the same with upgrade II and III - upgrade II costs 200 coins => 250(base value + upg. I) + 200 = 450, upgrade III costs 250 coins => 450(base value + upg. I + upg II) + 250 = 700.

To recap:
Base Towers point value – 100
Upgrade 1 point value – 100 + 150 = 250
Upgrade 2 point value – 250 + 200 = 450
Upgrade 3 point value – 450 + 250 = 700
Lastly, you need a trigger, which turns the towers point value into gold, with a slight interest decrease, of course.


Sometimes, there is a need to kick annoying players. Usually, player red has the authorities to do that. The following trigger checks whether player red has typed in the name of the player he/she wishes to kick correctly, after the “-kick “ substring. If he/she has, the player will be kicked.


To put the icing on the cake, a small trigger, which takes care of lag, by removing the corpses.


Tower Defense Template

Version 1.4

- Symmetrical terrain.
- Tower templates.
- Trigger templates from spawning creeps to counting kills.
- Lag and memory leak free.
- 8 player playability.
- Easy to manipulate and change to your needs.

Tower Defence FAQ

Q: My Aura Tower doesn't target my structures, what to do?
A: Have you set the fields, shown below, for the aura? That's all you need to do.


Q: Why doesn't my towers show the little buff status icon?
A: You have to go to Advanced Gameplay constants and set the following field to true:



Q: The creeps in my Tower Defense simply walk back to the starting point and ignore the given orders. How to remove it?
A: The problem lies in the gameplay constants - the creeps are ordered to move back to their guarding "spot" if they get too far.

To "remove" this nasty feature from your map, open gameplay constants by selecting "Advanced" from the menu.

Next, just modify the "Creeps - Guard Return Distance" and "Creeps - Guard Return Time" fields.

Insert something big, 99999.0 would do excellent.


ok so i got all the variables at the start (playeringame, creep_array, Cc_start, Cc_player, and player_creep) but when i go to make that actions for them like set playeringame= (all players matching (((matching player)slot status) equal to is playing) and (((matching player)controller) equal to user))) idk where to find that and i was wondering if u could help me
if u could email me at [email protected] thanks
Wow man wow! :eek: Great Job on this tutorial!

+rep! <3
Really good Tutorial...
Must have taken you quite a while to get all those Pictures :p
this is an AMAZING tutorial.. i was able to make the whole map using this :D
How did you manage to get transparent pictures of the trigger codes? With just the text / icons / lines showing?
ya i was just wondering if anyone had a link on a tutorial on how to edit objects. i couldnt find one on the forums
Well, actually, they are not transparent, but they have the same background colour as so I kind of cheated. (Using transparent pictures [.gif] doesn't give so good quality as jpeg.)
ok so i cant get the corpse clean up code to work for my TD. i copyed and pasted the code but it wont let the code initilize. can u help me out?
Well, actually, they are not transparent, but they have the same background colour as so I kind of cheated. (Using transparent pictures [.gif] doesn't give so good quality as jpeg.)

Oh, nice. They look a lot better than
 tags and pictures of 'em with white backgrounds. :)
hey i made a td and i tested it and my towers only build a tenth of the way and they stop. (ex: my tower has 50 max hp and it builds to 5) anyone know what might be wrong
Please, when you have a problem, make a new thread or use the search function.

The problem might lie in the fact, that you based your towers off human buildings and your builder doesn't have the repair ability. Change your workers race to human and add him repair ability.
temp variables

alright i got all of the variables right... but i dont understand the temp_point, temp_location, ect... how do i make temp variables? or do i make my own variables?
They are just point variables named temppoint. They are used for cleaning up leaks.

On the trigger that makes you lose lives there's one action saying Set Lives_amount = (Lives Amount - 1) but I cant find that - 1, where can I find it?

<edit> found it, I made the Lives_amount variable to multiboard instead of integer.</edit>
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online


      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.