Tutorial Creating A Simple Tower Defense

chop_knife

New Member
Reaction score
0
Hey!There i am going to show you how to create a simple and easy tower defense map

Trigger 1
Variables Used
Unit_Type(unit type variable)
Unit_Number(integer variable)
Trigger:
  • Events
    • Map initialization
    • Conditions
    • Actions
      • Set unit_type[1] = Footman
      • Set unit_type[2] = Knight
      • Set unit_type[3] = Rifleman
      • Set unit_type[4] = Bandit
      • Set unit_type[5] = Ghoul
      • Set unit_type[6] = Timber Wolf
      • Set unit_type[7] = Grunt
      • -------- d --------
      • Set Unit_Number[1] = 3
      • Set Unit_Number[2] = 3
      • Set Unit_Number[3] = 3
      • Set Unit_Number[4] = 6
      • Set Unit_Number[5] = 7
      • Set Unit_Number[6] = 8
      • Set Unit_Number[7] = 9


We used this trigger to set the number and type of the units you will be spawning for later.

Trigger 2

Trigger:
  • Events
    • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit - Kill Footman 0007 <gen>
      • Game - Display to (All players) the text: welcome to my game!...



I will tell you why we used this trigger in the next trigger,and don't forget to set your peasant in the map

Trigger 3
Variable used here
Level_Amount (Integer variable\set the number for this variable to the number of levels you are going to make in your TD map)
Level (integer Variable)
Countdown Timer (Timer Variable)

Trigger:
  • Events
    • Player - Player 2 (Blue)'s Food used becomes Equal to 0.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • level Equal to level_amount
        • Then - Actions
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) for 3.00 seconds the text: <Empty String>
        • Else - Actions
      • Set level = (level + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • level Equal to 1
        • Then - Actions
          • Countdown Timer - Start timer as a One-shot timer that will expire in 40.00 seconds
          • Game - Display to (All players) the text: You will have an ex...
        • Else - Actions
          • Countdown Timer - Start timer as a One-shot timer that will expire in 25.00 seconds
          • Game - Display to (All players) for 2.00 seconds the text: The Game will start...
      • Countdown Timer - Create a timer window for timer with title Next Level...


We used trigger 2 so that when the peasant gets killed the amount of food of player2(blue) will turn zero triggering this trigger...

Trigger 4
Spawning
Variables used here
tmpPoint (point variable)

Trigger:
  • Events
    • Time - timer expires
    • Conditions
    • Actions
      • Set Temp_Group = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
      • Player Group - Pick every player in Temp_Group and do (Actions)
        • Loop - Actions
          • Set tmpPoint = ((Picked player) start location)
          • For each (Integer A) from 1 to Unit_Number[level], do (Actions)
            • Loop - Actions
              • Unit - Create (Integer A) unit_type[level] for Player 2 (Blue) at tmpPoint facing Default building facing degrees
          • Custom script: call RemoveLocation( udg_tmpPoint )
          • Game - Display to (All players) the text: level has begun!!!


we used this trigger to spawn the units you set earlier

Trigger 5
Moving
Variable Used Here
TmpPoint (point variable)

Trigger
Trigger:
  • Events
    • Unit - A unit enters Region 004 <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set tmpPoint = (Center of Region 001 <gen>)
      • Unit - Order (Entering unit) to Move To tmpPoint
      • Custom script: call RemovLoaction (udg_tmpPoint)


do this everytime a unit enters region

Trigger 6
variables used here
Lives 100
Variable Set
Trigger:
  • Events
    • Map initialization
    • Conditions
    • Actions
      • Set Lives = 100


Leaderboard


Trigger:
  • Events
    • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Leaderboard - Create a leaderboard for (All players) titled <Empty String>
      • Leaderboard - Add Player 2 (Blue) to (Last created leaderboard) with label Lives Left and value Lives
      • Leaderboard - Show (Last created leaderboard)


Losing Lives...
Variables used here
Unit_Group(unit group variable)

Trigger:
  • Events
    • Unit - A unit enters Main Region <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set unit_group = (Units in Main Region <gen> owned by Player 2 (Blue))
      • Unit Group - Pick every unit in unit_group and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to (Lives - 1)
      • Set Lives = (Lives - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Lives Equal to 0
        • Then - Actions
          • Set Temp_Group = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
          • Player Group - Pick every player in Temp_Group and do (Actions)
            • Loop - Actions
              • Game - Defeat (Picked player) with the message: Defeat!
        • Else - Actions


this only happens when a unit enters a region where the the castle or anything you need to defend is.

that is all you have to do

if some of my triggers leak please notify me as early as possible so that i can provide the most accurate
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
Trigger:
  • Events
    • Unit - A unit enters Main Region <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set unit_group = (Units in Main Region <gen> owned by Player 2 (Blue))
      • Unit Group - Pick every unit in unit_group and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to (Lives - 1)
      • Set Lives = (Lives - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Lives Equal to 0
        • Then - Actions
          • Set Temp_Group = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
          • Player Group - Pick every player in Temp_Group and do (Actions)
            • Loop - Actions
              • Game - Defeat (Picked player) with the message: Defeat!
        • Else - Actions

Um.. You make the unit group but don't destory it? Why not.
 

UndeadDragon

Super Moderator
Reaction score
447
All you are doing is showing us some triggers. Try and explain them more.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Trigger:
  • Events
    • Unit - A unit enters Region 004 <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 2 (Blue)
    • Actions
      • Set tmpPoint = (Center of Region 001 <gen>)
      • Unit - Order (Entering unit) to Move To tmpPoint
      • Custom script: call RemovLoaction (udg_tmpPoint)
I'm happy to graveyard this simply because basic mazing allows this pathing to be screwed up. I'd hate to play a TD where this is implemented, and the order of where units go can be bugged, it's really disappointing.

Please update it with attaching the unit's next enterable rect to the unit, for starters...
(As well as removing the leak mentioned.)
 

WilliamPa

Active Member
Reaction score
51
All these leaks are just horrible. Anyways, i believe there is a TD tutorial MUCH better than this one.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top