Guide - Tower Defense

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
PART I
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.

Excel.jpg

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.)

Excel2.jpg

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.

Excel3.jpg

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).

Excel4.jpg

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.

Excel5.jpg

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.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
PART II
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.

P2_dmgBASE.jpg


P2_dmgdice.jpg


P2_dmgDIE.jpg


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.

P2_DamageFormula.jpg

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

P2_atackType.jpg


P2_cooldown.jpg

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

P2_req.jpg


P2_upg.jpg


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

P2_icon.jpg


P2_model.jpg


P2_projart.jpg


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.

P2_struct.jpg

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".

P2_race.jpg


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

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

P2_goldcost.jpg


P2_lumbercost.jpg


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.

4Upgradesto.jpg

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

P2_builtime.jpg

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.

P2_HP.jpg


P2_def.jpg


P2_movspeed.jpg

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

P2_attacksnone.jpg

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

P2_bounty.jpg
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
PART III
Triggerwerkz

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

_variable.gif
– If a trigger contains variables, this indicates what type the variable is.
_leakRemoval.gif
– Custom script leaks removal. Important.
_comment.gif
– 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?

variableInitialization.gif

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
http://www.thehelper.net/forums/showthread.php?t=51960

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?

elapsedTime00.gif

The leaderboard.

_leaderboard.gif

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.

_pathing.gif



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.

td_regionss.jpg



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.

exampleRegion.gif

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.

creepAmountInitialization.gif

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

spawnInitialization.gif

The timer window

_timer.gif

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.​

spawnCreeps.gif

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.

loseLives.gif

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.

killsUpdate.gif

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.

playerLeaves.gif

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.

3pointvalue.jpg

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.

sellfunction.jpg

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.

kickSystem.gif

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

corpseCleanUp.gif

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.

CLICK HERE FOR DOWNLOAD
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
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.

P4_table.jpg

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:

P4_BuildingDisplay.jpg


P4_Tower.jpg

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.

dist.jpg


dist2.jpg
 
M

moneyman7652

Guest
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
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Wow man wow! :eek: Great Job on this tutorial!

+rep! <3
 

lh2705

Just another Helper
Reaction score
111
Really good Tutorial...
Must have taken you quite a while to get all those Pictures :p
 
M

moneyman7652

Guest
this is an AMAZING tutorial.. i was able to make the whole map using this :D
 

Tonks

New Member
Reaction score
160
How did you manage to get transparent pictures of the trigger codes? With just the text / icons / lines showing?
 
M

moneyman7652

Guest
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
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Well, actually, they are not transparent, but they have the same background colour as Thehelper.net so I kind of cheated. (Using transparent pictures [.gif] doesn't give so good quality as jpeg.)
 
M

moneyman7652

Guest
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?
 

Tonks

New Member
Reaction score
160
Well, actually, they are not transparent, but they have the same background colour as Thehelper.net 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
Code:
 tags and pictures of 'em with white backgrounds. :)
 
M

moneyman7652

Guest
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
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
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.
 
T

tHE_ghOsT

Guest
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?
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
They are just point variables named temppoint. They are used for cleaning up leaks.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Lives

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.
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top