Tower Defense Tutorial

By SD_Ryoko

Some paragraphs from other materials.

1. Introduction

2. For Beginners

3. For Intermediates

4. For Expert TD creators

1. Introduction

What is a tower defense?

TD stands for "tower defense". It is a "genre" of custom game for Warcraft III.
The TD genre was pioneered early on with such games as "TD" and "Arkguil's TD".
In a TD, the objective is usually to construct buildings to prevent units that walk along a set path from reaching an area.
TD's usually consist of multiple "levels" of gradually increasing difficulty.

Why make a tower defense?

TD maps can be extremely fun to play!
They are very challenging and are almost like a complete minigame to Warcraft III.
Even Blizzard created their own fun, secret, TD level that accompanies the expansion The Frozen Throne.
TD maps usually take a lot longer to create than any other type of map.
I mean, any map can be made in a short amount of time, even a TD.
But in my experience though, I tend to spend the most time developing a TD.
They seem to require a lot of attention and they aren't always easy for people new to TD's to get right in and make one right away.

2. For Beginners

How to make your Tower Defense original

Perhaps the most important thing you need to consider when creating a TD map is how you will differentiate it from all previous TD's.
You still want to capture the essence of a TD in your map - but you will need to do much more than simply change the models and terrain of someone else's TD.
Think about what you want your players to be thinking about while they play.
There are many things you can do to offer a unique experience for your audience.

How to make your Tower Defense fun

Another important point is that even if your TD is very original, that doesn't necessarily mean that people are going to like it.
In general, do not make the game so difficult that it is nearly impossible to win.
Game length should be limited from 30 minutes to 1 hour in length.
Your map should be virtually free of bugs - ESPECIALLY tooltips on towers, hotkeys for building towers, descriptions for towers and tower builders, etc.
Do not make the game so hard that only yourself and a minority of players can "win" - nobody likes to play games that they lose all the time.
Also, nobody wants to have to wait around in a TD because one stupid little creep got mixed up and didn't walk where he was supposed to - or one player is taking forever to finish off the creeps.
Use "periodic event" and a variable that increases itself, plus if/then/else statements that check that variable to run your levels.

The bare bones of a Tower Defense

There are many core essentials to making a TD run effectively.
You'll need to create the scenario at the start of the game.
Players will need a way to create towers and choose which race they want to play.
Variables and map functions will need to be initialized.
You will also need functions to manage the levels, and set the victory conditions.

Map Layout:

First, you need to create a layout for the creeps and players.
Most often, these are paths or lanes that the creeps walk through, and players build towers to defend against them.
Be especially careful when creating your layout, being sure that it is symmetrical for each player.


Many TD's have different races for players to choose from, and each race can build a different techtree of towers.
Races should be original and very different from each other.
Different styles of towers and abilities separate one race from another.


You will need to create towers for each race to play.
Towers should be 2x2 in size - the size of the human guard tower.
Towers start of basic and gradually become better and more expensive.
Some towers can be upgraded and have special abilities.
Towers also can have different attack types to combat different types of armor.


The easiest way to create different creeps is to copy units and modify them.
Having a basic formula for creep life, armor, and speed is the BEST way to create a balanced game.
Values start off low and increase as the game progresses.
All creeps should have a low pathing value, to prevent jamming.
All creeps should have some value for food cost, and a bounty value.
Bounty values give the players gold when the creep is killed.

Races Lanes
Most TD's allow players to choose different races. Lanes should be symmetrical for all players.

How a TD runs and Operates

All of these components need to be put together to create a working game.
Each TD works somewhat differently, but the basic order of operations is the same.
Almost every tower defense begins with choosing units, then progressing through levels of creeps throughout the game.
Below is a basic structure of how a TD operates.

Map Init:

Here you will create the scenario at the start of the game.
Define variable arrays of creeps that will be used in levels.
Define miscellaneous variables to keep track of lives, score, and winnings.

Create Units:

Players are going to need a way to choose their race and build towers.
Typically, races are chosen from a building, that disapears when a unit has been picked.
Undead workers are the most popular builders, because they don't have to stand and wait for a tower to finish construction.

Start first level:

A countdown timer that kicks off the first level.
This gives players time to choose races and build some first towers.
Typically, players can see the timer and know how much time they have until the game begins.

Spawn Creeps:

Every level of a TD, creeps will be created.
Creeps are often stored in large unit type arrays so they can be manipulated easily.
All creeps in your TD should require some amount of food, to keep track of the amount of creeps on the board.

Level Complete:

A level is finished when the creep players food becomes zero.
A trigger usually catches when a players food has dropped below 1, telling the scripts that the level has been finished.

Losing Lives:

A trigger 'catches' creeps that made it to the end of a players lane and subtracts lives from player totals.
Sometimes the creeps meet at the center of the map as well.
Creeps can also be worth different amounts of lives.

Tally Score:

A trigger keeps score of how many creeps a player has killed.
Player kills are often stored in variable arrays as well.
Kills are typically shown on a leaderboard or multiboard.

Victory Conditions:

Victory conditions determine when the game is complete.
Players can be defeated if they leaked all of their lives, or win by surviving through each level.

Team Play, Survival, or Team vs Team?

There are essentially three types of TD's out there.

Team Play:

Team play is where a group of players work together to win the game.
Either they all work to build towers to defend one location, or your map allows multiple teams, say teams of 2, to play the game (and it is non-competitive).
Classic examples: Arkguil's TD.


One type is where there are multiple runways where creeps will be ordered to move, and each player has access only to attack those creeps that come down their runway.
Classic example: Blixels TD.

Team vs Team

Where two or more players go head to head!
Either the first player or team to clear all the levels wins, or the player that survives the longest wins, or the team or player with the most points within a certain time wins - and of course there are many variations.
You can allow players to build towers that can attack the enemy teams towers (à la Tower Line Wars) or keep it simple (à la Cube Defense).

3. For Intermediates

Pathing and Lanes

Warcraft is very smart, and creeps will walk almost any distance to get to their destination.
If there is a hole in your pathing map, creeps will be able to walk around a player instead of going through their towers.

If your pathing is correct, and the player blocked the creeps' path, they will either attack the player's towers, or turn around.
But if your pathing is not solid, and there is a gap half way across the map, they will head for it.

Inside World editor, you can click on View - Pathing (ground) and check your pathing map.
The areas that ground units cannot walk will be shown in purple.
Unbuildable areas will be shown in blue.

In the first picture, the arrows show the possible paths the creeps will take.
If they cannot go straight into the left lane, they will head right instead.
Blocking the right hand side would force them to move forward.

In the second picture, a player could not build on a blue area.
This will allow the creeps to walk around the towers there.
We need to put large size pathing blockers down to prevent units from walking on those areas.

Pathing Blockers
Creeps cannot walk on purple areas. If a path is not blocked, the creeps will find a different way. Large size pathing blockers prevent creeps from walking around buildable areas.

Spawning Units

Whether you're using a loop or creating multiple units at once, the most efficient way to do this is to dump creeps into a region.
Instead of having the spawn trigger telling the units to move, have 'dump' region tell them to move.
Creating and ordering units in one giant trigger can bog the game down.

Dumping all the creeps onto the map at once can really bog the game down too.
Some TD's use loops to create units for each player.
Others dump smaller handfuls of groups at a time.
Also, when creating all the units at once, they tend to create a giant clump and get stuck.
Smooth running TDs will control the flow of incoming creeps.

You can keep track of who leaked the creeps by having multiple ending regions, or by setting the unit's custom value when it lands in the dump region.
The trigger will set the custom value, then order the unit to move.
Note that, these are still both separated from the spawning code.

Remember, if your players can maze the creeps, you MUST make the checkpoints unbuildable ground.
If a player unknowingly builds towers all over the check point, the creeps are going to destroy all the towers in the area.
How fair is that?

Create Units 1
        Time - Every 45.00 seconds of game time
        Unit - Create 3 Footman for Player 1 (Red) at (Center of SPAWN1 <gen>) facing 0.00 degrees
        Unit - Create 2 Rifleman for Player 1 (Red) at (Center of SPAWN1 <gen>) facing 0.00 degrees

        Unit - A unit enters SPAWN1 <gen>
        Unit - Order (Entering unit) to Move To (Center of SPAWN2 <gen>)

        Unit - A unit enters SPAWN2 <gen>
        Unit - Order (Entering unit) to Move To (Center of SPAWN3 <gen>)

        Unit - A unit enters SPAWN3 <gen>
        Unit - Order (Entering unit) to Move To (Center of SPAWN3 <gen>)
Checkpoints Maze
Creeps walk from checkpoint to checkpoint, until they reach the center. If players can maze, you MUST make checkpoints unbuildable ground.

Creeps keep Attacking?

The pathing computer isn't always perfect, and creeps do get mildly jammed up inside a complex maze.
We don't want to prevent this, but control it instead.

The first thing is the collision size of the creeps.
We have experimented with many sizes, and concluded the size should be ONE.
We only want creeps to attack if a player blocked them in solid.
Your tower defense should detect an attack, then re-issue the movement order.
Creeps won't continue moving on their own.
You will probably need multiple triggers if you have multiple way points as well.

Here is an example:

Control Creeps Red
        Unit - A unit owned by Player 1 (Red) Is attacked
        (Owner of (Attacking unit)) Equal to Player 11 (Dark Green)
        ((Attacked unit) is A structure) Equal to True
        Wait 1.00 seconds
        Unit - Order (Attacking unit) to Move To (Center of Point 4 <gen>)

Another reason creeps will attack is from being provoked.
This includes abilities like bash, stun, and splash damage.
If you really must use these abilities in your TD, you will have to develop a workaround.

Towers with Abilities

You may want some of the towers in your map to have special abilities.
Here are some examples of abilities that towers can have.

  • Critical Strike
  • Poison Attack
  • Frost Attack
  • Slow
  • Multiple Shot
  • Splash Damage (see notes)
  • Bash (see notes)

Using custom abilities is a way to make towers significantly different from one another.
If you have multiple themed races, you will need more abilities to make each race unique.
You can also add abilities like the Freezing Breath ability that Frost Wyrms have to slow and damage groups of enemies.
You can also create towers with special abilities, like Shockwave and Farie Fire.

Note that if a unit becomes bashed you will often make the creep attack your tower.
A solution is instead to create the stun effect on the overhead of a unit manually through a trigger when it is attacked by that tower, and pause the unit for an amount of time.
This way, the unit keeps its original orders.
Splash damage will also provoke creeps to attack as well.

You can create towers that use abilities like Shockwave through triggers.
Make the ability's cooldown slightly less than the tower's attack cooldown.
Then have a trigger event controlling the tower.
Note that, this trigger should be disabled before a tower of that type is built, to prevent useless trigger events.


A unit owned by player 5 (creeps) is attacked
Attacking unit is (lightning tower)
Order (attacking unit) to cast (chain lightning) on (attacked unit)

Different projectiles and abilities make towers original.


A leaderboard is useful for displaying the title of your map, how many lives players have left, and what level the game is on.

Typically, a leaderboard is created about five seconds after the map's initialization.
You cannot create a leaderboard right when the map starts.
You can divide players into team lives, or individually for a survival TD.
If you wish to have more than just player lives, you will need to create a multiboard instead.

Please also see the 'Leaderboards' tutorial for more information on this topic.

Unit varieties

One of the easiest ways to pick which units you would like to use is to create them inside world editor.
Slamming down 50-100 units and comparing them can give you a good idea of what your line up is going to be.
Then shift the units around into groups or rows in which you would like them to appear.
This trick is also really handy for creating your towers as well.

Each level of creeps will need their own unique hit points, defense types, and abilities.
Not every level has to have special abilities, but it can spice things up a bit.

As each level progresses, creeps should be getting harder and harder.
Here are few suggested ways of making creeps unique:

High defense

Adding extra defense to a set of creeps.
  levels 01-10:  3 def
  levels 11-20:  5 def
  levels 21-30:  7 def
  levels 31-40:  9 def
  levels 41-50: 12 def
  levels 51-60: 15 def
  levels 61-70: 18 def
  levels 71-80: 20 def


Bosses should also have higher defense than normal creeps, and have much more life.


Give'em flying and create towers that attack both ground and air, or towers that do way better against air only.


Change their pathing to 0 in their unit properties menu so they can walk right through towers as if they were flying, but they aren't.


You use triggers within the waypoints around the map as well as in the trigger that initially tells the units to start moving after they have spawned to make this group attack-to instead of move-to.


Give these guys increasingly fast speeds and at the highest levels give them the ability endurance aura too for added mayhem.


Beware: making creeps that are invisible and NOT letting players know that there will be invisible creeps - or not easily allowing players to create towers that can detect invisible creeps - is a sure way to make players really angry at you.
Invisible creeps should be reserved for TDs only if you want to make them extremely challenging.


Create a region where, if the creeps reach it,they will have their health changed to 100%.

Boss Levels

As I mentioned earlier, TDs can have "boss" levels.
In my TDs, I tend to have them every 10 levels.
To do this, simply have an if/then/else check should creeps make it to the final location in their route around the map.
If the unit type matches one of your bosses then make the player or players lose the game - or lose a lot of lives - whichever you prefer.
Boss monsters should have high defense and lots of life to compensate for the fact that there's only one of them.
Boss levels make the game more challenging and they give the game a sense of urgency on some levels.
Blizzard has boss type monsters in their TFT TD.

Sellable Towers

Ever TD should have sellable towers, and towers should be sellable in a user friendly way.
Here's a trick from Ryoko that works great for selling towers.
1. Create a new ability called 'Sell Tower' based on the Windwalk ability.
2. Change all the values for your new Windwalk to zero. The casting cost, durations, cooldown, every value inside the ability.
3. Change the hotkey for the new ability to something unique. I like to use 'X'.
4. Change all the tool tips for the new ability, and icon. I like to use the treasure chest or gold icon.
5. Add the ability to all your towers.
6. Finally, create a trigger that looks like this. Any time a tower uses the 'Sell Tower' ability, a trigger will sell the tower for half its value, create a nice special effect above it, and destroy it. Note that it does not have to be half the value; it can be whatever you prefer.

Sell Towers
        Unit - A unit Begins casting an ability
        (Ability being cast) Equal to Sell Tower
        Player - Add ((Point-value of (Casting unit)) / 2) to (Owner of (Casting unit)) Current gold
        Special Effect - Create a special effect at (Position of (Casting unit)) using ...
        Unit - Remove (Casting unit) from the game

I like to use Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl

Terrain Design

Yes, even a TD map can benefit from having interesting terrain.
Make good use of setting up a custom list of terrain variations in the advanced menu.
It is quite a challenge to make a game with a strict grid-like layout look natural.
But if you need an example, look no further than your AOS/DOTA/TOB type games.
When you think about it, these games are all carefully measured out to make sure there is the same distance everywhere that the units are made to move.
But the maps feel quite natural.
There are often rivers and shallow water, shorelines, and plenty of trees.
Use the "bumps" tool to change your land from flat and boring to a bit varied.
And liberal use of doodads can sometimes spruce the place up a bit.

The starting and ending location for your creeps should at the very least be nicely decorated in some way.

Upgradeable Towers

You may have seen in some TD games towers which you can upgrade to other towers.
Here I will explain how to create these types of towers.
First you will need to create two or more variations of the same tower - that is, you'll need one separate unit for each tower level.
Change the damage, attack speed, whatever you desire for the upgraded version of the tower.
Then take a look in the properties menu at "upgrades to".
Select the level 2 version of the tower.
Remember to price the upgrade appropriately - and fine tune the building time.

To take things even further, give players, or allow them to build, a structure that they can upgrade if they have enough gold.
Then make the upgraded unit require that structure in order to be created.
This is pretty much like Warcraft III: you need a Castle before you can build certain buildings.
I prefer to allow players to build if they have enough gold - but you can restrict players to be able to build after a certain level by giving players 1 lumber each at, say, level 20, and then requiring 1 lumber for the upgrade.
If you do this, and in general, do not allow players to give one another lumber ;)

Reducing lag in your TD

Although some might argue, you can destroy your initialization triggers (on map initialization).
You know, the ones you'll never need again 100% for sure once they execute properly the first time.

You can also remove corpses of creeps - unless you have towers that can raise the dead in which case you might want to rethink that, but for the most part, removing corpses is amazing for anti-lag purposes.
Simply create a trigger that runs whenever a unit owned by the creep player dies, wait 2 seconds, and then remove the unit from the game, corpse and all.

However, the largest anti-lag issue relates to creating large numbers of units at one time, and ordering them to move.
Try to limit how many creeps appear per level to 20 or so.

4. For Expert TD creators

Player controlled spawning

This is a relatively new concept in TDs.
Players can make purchases from a building very similar to my custom spell - a devilseeds building sell code - and instead the action is to create a bunch of units and order them to move or attack to a location.
In this way, players can time their attacks.
The biggest downfall of using this is that you should definitely make the creeps that are spawned not controlled by the player that created them.
Use a new player owned by a computer instead.
Otherwise the player can stop the units and mass them up - a current large problem that I noticed in that new Gold TD map that everyone seems to be enjoying lately ;)

For that matter, don't call your maps Platinum edition, Gold edition, or any other useless name like that because nobody can tell which is the most recent version.

Also it's your choice whether you want to "protect" your map.
You have to realize that protecting your map will only keep complete newbies from messing with your map and adding their own hidden cheats and messing with game balance etc.
I personally do protect my maps - but in all my loading screens I say if people want the unprotected version they can email me and I give my email address.
In this way I kinda protect my map from stupid people and help anyone that really wants to see how I did something at the same time.

Overall difficulty and "breakpoints"

As I alluded to earlier, it is important that your game, overall, is not insanely difficult.
At least, for the majority of time that players spend in it.
The final level, and to a lesser degree the approximately 9 levels before that final level, should be *quite* challenging.
I mean lets face it - nobody likes a game if they can win all the time.

A "breakpoint" is my term for the point or level in the game when you start to lose unless you have specific types of towers.
For example, at level 60 in my game you start to encounter invisible creeps.
If you don't have the vision upgrade by this level, your towers won't hit any of those creeps making your chances of winning drop off almost entirely.
Another example is an air level.
Don't have any good AA towers and you can expect to lose.
Make sure that you put breakpoints at levels that are fair for your users.
For example, don't put invisible flyers on level 5.
People that have never played before aren't likely to enjoy your game if you do that.

Hybrid TD's

If you like, you can incorporate a TD into another type of game.
For example, the game I am creating right now allows you to pick heroes and level them up like an RPG, gaining added revenue from their efforts.
You use this revenue to build your towers and stop waves of enemies from breaching your base.
To make things interesting there are two teams competing and not only can you use your hero to creep - you can use him to attack the other teams' heroes and their base - and defend your base as well.
This is but one example.

Multiple objective TD's

In general, if your TD has multiple ways to win, it will be more interesting.
For example, in my TD you can win by destroying the enemy base or by surviving the longest against the waves of creeps.
You can also win by taking out the computer base where the creeps spawn - though this is quite difficult.

How to balance your TD

My gosh - I guess I could write an entire guide just on this topic but here are the BASICS:

+ Make sure your "breakpoints" are set up fairly.
+ Test the game! Release an "alpha" version and let players test it.

Then adjust the damage etc of your towers.
The goal is to make it so that players are not forced to build towers of a specific type in order to win.
In other words, make sure that your players are not relying on one and only one tower.
Otherwise having 50 different types of towers is redundant if players only want to use the one.

Managing Difficulty

I don't really like games that have difficulty levels that one person has to select from at the beginning.
I also don't like games where there is an unnecessary vote at the beginning of the game on the game difficulty.
So instead, I wrote something that would *automatically* ramp up the difficulty for a player based on how good they were doing in-game.

The concept is simple really.
We want to measure how *good* a player is doing.
If they are doing really good we can give monsters more HP, armor, make them faster, increase the number of monsters that spawn, etc - the sky is the limit.
And how we do this is up to you.
Since my levels happen periodically every 60 seconds I can do a quick check at the 30 second mark to see if there are still creeps alive.
Then change a variable called "numberperspawn".

This trigger is off by default but you turn it on 30 sec after the map initialization so it happens at 1min30sec, 2min30sec, etc.

event: periodic event: every 60 seconds
player: select all units owned by player 12 (creeps) and for each picked unit do set variable: creepsalive = (creepsalive +1 ).
if creepsalive is equal to 0, set variable numberperspawn = (numberperspawn + 1)
if creepsalive is greater than 0, set variable numberperspawn = (originalnumberperspawn)

I can also use team lives as a good indicator.
If a team has already lost half their lives before level 11 rolls around, I can scale the difficulty level down a bit.
Right before level 11 rolls around I can check the variable for team lives and respond to that by changing a variable like numberperspawn, etc.

Arguably, increasing the number of creeps per spawn is not ideal as it allows players to mass more gold than you may have originally intended.
A much more *balanced* way to increase difficulty is to select all the creep units and change their movement speed or health.

Be careful on boss levels to modify the script a bit.
Boss levels should use a different variable or just set it to 1.
You should never have negative amounts of creeps spawning.

Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.