• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Capture the Flag Triggers [Reviewed: Ghan]

Level 5
Joined
May 24, 2006
Messages
38
This tutorial is for people wanting to make a Capture the Flag (CTF), but don't know how to make the triggers for it.
In case you don't know, a Capture the Flag Game is 2 people/teams attempting the take the enemy's flag (usually in their base), and bring it to their flag. If a flag is taken, the other team must try to get the flag back before it is captured.
This particular game I'm setting the amount of captures needed to 5 (you can change it in step 3)
If you follow these steps, you will have all the triggers you need to make a Capture the Flag.
[NOTE = in triggers where is says: has Team 2 Flag, this implies selecting the actual flag on the map, not the item type]

Steps:
1 - Team Setups
2 - The Flags
3 - Flag Capture (and victory/defeat)
4 - Retaking flag (team gets flag back)
5 - Multiboard (if you want 1, recommended)
NOTE = This trigger is based on a 5v5 map with 2 computer players (Player 11: Dark Green, Player 12: Brown)
---
1. Team Setups:

The first part to making a CTF is to have 2 teams that will each attempt to capture the other team's flag. Ill be using a 5v5 map with 2 computer players (the bases, as mentioned above)

The first step is to add the 5 players to each team (the alliances should already be in place; in the forces section of Scenario -> Force Properties so that 5 players and 1 computer (Dark Green) is on the first force, and 5 players and 1 computer (Brown) is on the second force).
You need 2 Variables:
---
Variable Name: Team1
Variable Type: Player Group
Array: None
Initial Value: Empty Player Group (Default)
-
Variable Name: Team2
Variable Type: Player Group
Array: None
Initial Value: Empty Player Group (Default)
---
The trigger should look like this:
  • Group
    • Events
      • Map initialization
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 1 (Red) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 1 (Red) to Team1
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 2 (Blue) to Team1
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 3 (Teal) to Team1
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 4 (Purple) to Team1
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 5 (Yellow) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 5 (Yellow) to Team1
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 6 (Orange) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 6 (Orange) to Team2
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 7 (Green) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 7 (Green) to Team2
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 8 (Pink) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 8 (Pink) to Team2
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 9 (Grey) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 9 (Grey) to Team2
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Condition
          • (Player 10 (Light Blue) slot status) Equal to Is playing
        • Then - Actions
          • Player Group - Add Player 10 (Light Blue) to Team2
        • Else - Actions
          • Do nothing
Yes I know, its very long, so heres a short version (not in trigger form):
Players 1-5 should be added to Team1 using the format above,
Players 6-10 should be added to Team2 using the format above.
---
2. The Flags

Alright, we made the teams, now we gotta make the flags. Go into the object editor and go to the 'Items' tab. Copy the Human and Night Elf flags and rename them to whatever you want them to be, but remember, each of the flags you make here will be the flags the players use in-game.

Now that you made your flags, place them in the map, one in each base (make sure the right team flag is in the right base), now its time to create 2 regions (for capturing the flag)
Go into Window -> New Palette -> Regions, and create 2 regions: one around the first flag (as big as you want the capture zone to be), and one around the other flag. Name these regions whatever you want, just remember what you called them.

Now that we made our flags and placed our regions, time to setup the flag capture triggers.
---
3. Flag Capture (& victory/defeat)

Alright, we set up the teams, made the flags, placed them, and made the regions, now we need to make the triggers that add a point to each team when they bring the enemy flag to their flag (the region in their base)
You need 2 variables for this part:
---
Variable Name: Flag1
Variable Type: Integer
Array: None
Initial Value: 0 (Default)
-
Variable Name: Flag2
Variable Type: Integer
Array: None
Initial Value: 0 (Default)
---
OK the variables are made, now the trigger for the team 1 capturing the flag should look like this:
  • Team 1 Flag
    • Events
      • Unit - A unit enters [the region around Team 1's flag] <gen>
    • Conditions
      • ((Entering unit) belongs to an ally of Player 11 (Dark Green)) Equal to True
      • ((Entering unit) is A Hero) Equal to True
      • ((Entering unit) has [Team 2 Flag]) Equal to True
    • Actions
      • Game - Display to (All players) the text: Team 1 Scored!
      • Item - Move (Item carried by (Entering unit) of type Team 2 Flag) to (Center of [region of team 2 flag])
      • Set Flag1 = (Flag1 + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Flag1 Equal to 5
        • Then - Actions
          • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
          • Game - Victory Player 2 (Blue) (Show dialogs, Show scores)
          • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
          • Game - Victory Player 4 (Purple) (Show dialogs, Show scores)
          • Game - Victory Player 5 (Yellow) (Show dialogs, Show scores)
          • Game - Victory Player 11 (Dark Green) (Show dialogs, Show scores)
          • Game - Defeat Player 6 (Orange) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 7 (Green) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 8 (Pink) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 9 (Grey) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 10 (Light Blue) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 12 (Brown) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
        • Else - Actions
The same should be made for team 2, but with a slight change (instead of team 1 region, team 2, and switch the victory and defeat players) if you want an example check this out, if not, just scroll down past this to the next step.
  • Team 2 Flag
    • Events
      • Unit - A unit enters [the region around Team 2's flag] <gen>
    • Conditions
      • ((Entering unit) belongs to an ally of Player 12 (Brown)) Equal to True
      • ((Entering unit) is A Hero) Equal to True
      • ((Entering unit) has Team 1 Flag) Equal to True
    • Actions
      • Game - Display to (All players) the text: Team 2 Scored!
      • Item - Move (Item carried by (Entering unit) of type Team 1 Flag) to (Center of [region of team 1 flag])
      • Set Flag2 = (Flag2 + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Flag2 Equal to 5
        • Then - Actions
          • Game - Victory Player 6 (Orange) (Show dialogs, Show scores)
          • Game - Victory Player 7 (Green) (Show dialogs, Show scores)
          • Game - Victory Player 8 (Pink) (Show dialogs, Show scores)
          • Game - Victory Player 9 (Grey) (Show dialogs, Show scores)
          • Game - Victory Player 10 (Light Blue) (Show dialogs, Show scores)
          • Game - Victory Player 12 (Brown) (Show dialogs, Show scores)
          • Game - Defeat Player 1 (Red) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 2 (Blue) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 3 (Teal) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 4 (Purple) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 5 (Yellow) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
          • Game - Defeat Player 11 (Dark Green) with the message: The Enemy Have Captured The Flag 5 Times U Lost .....
        • Else - Actions
Awesome, now the game will keep track of the flag captures and set the victory/defeat when a team captures 5 flags. Now, lets take care of the simple trigger that puts the flag back to its base when a team members picks up their own flag.
---
4. Retaking the Flag
OK, now lets make the very small simple trigger of return the flag back to its base when a team members picks up their own flag.
The trigger should look like this:
  • Get it Back
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Hero manipulating item) has Team 2 Flag) Equal to True
      • ((Hero manipulating item) belongs to an ally of Player 12 (Brown)) Equal to True
    • Actions
      • Item - Move Team 2 Flag to (Center of [Region around Team 2 Flag])
OK, we made the trigger for team 2 returning the flag, now to make it for team 1.
  • Get it Back 2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Hero manipulating item) has Team 1 Flag) Equal to True
      • ((Hero manipulating item) belongs to an ally of Player 11 (Dark Green)) Equal to True
    • Actions
      • Item - Move Team 1 Flag to (Center of [Region around Team 1 Flag])
Great! Now each team can return their flag to their base if the flag carrier dies.
Now just 1 more step, its not required, but it will improve the map and make it easier for players to keep track of how many flag captures each team has; the Multiboard.
---
5.The Multiboard

Capture the Flag games usually have a Multiboard, a little box located at the top right of the map that displays the number of flag captures of each team.
Unlike a Leaderboard, we will be using a Multiboard, which can have a set amount of rows and columns.
We will also put your name on it (created by:___) and the name of the map

If you want to put in a Multiboard, follow these triggers, if not, skip the remaining steps and your finished!

Alright, the whole Multiboard can be created in 1 simple trigger, however, will require another trigger to update it when a player captures the flag.
You will need to create 1 new variable for the multiboard (as well as Flag1 and Flag2 from before)
---
Variable Name: M2
Variable Type: Multiboard
Array: None
Initial Value: None
---
The Multiboard creation trigger should look like this:
  • Multiboard Create
    • Events
      • Time - Elapsed Game time is 2.00
    • Conditions
    • Actions
      • Multiboard - Create a multiboard with 2 columns and 4 rows, titled Capture The Flag
      • Set M2 = (Last created multiboard)
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row1 to Team 1
      • Set Flag1 = 0
      • Set Flag2 = 0
      • Multiboard - Set the text for (Last created multiboard) item in column 2, row 1 to (String(Flag1))
      • Multiboard - Set the text for (Last created multiboard) item in column 2, row 2 to (String(Flag2))
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 2 to Team 2
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 3 to Map made by [your name]
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 4 to [your game name]
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 3 to 100.00% of the total screen width
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 4 to 100.00%of the total screen width
      • Multiboard - Set the color for (Last created multiboard) item in column 1, row 1 to (100.00%, 0.00%, 0.00%) with 0.00% transparency
      • Multiboard - Set the color for (Last created multiboard) item in column 1, row 2 to (0.00%, 0.00%, 100.00%) with 0.00% transparency
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 2 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 3 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 4 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 2, row 1 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 2, row 2 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 2, row 3 to Show text and Hide icons
      • Multiboard - Set the display style for (Last created multiboard) item in column 2, row 4 to Show text and Hide icons
      • Multiboard - Show (Last created multiboard)
Now, that trigger may seem VERY annoying to create (it is), but it is worth it! OK, 1 last trigger and we are done here!
This trigger will update the multiboard whenever a player captures the flag, and should look like this:
  • Team 1 Update
    • Events
      • Unit - A unit enters [Team 1 Flag Region]
    • Conditions
      • ((Entering unit) belongs to an ally of Player 11 (Dark Green)) Equal to True
      • ((Entering unit) is A Hero) Equal to True
      • ((Entering unit) has Team 2 Flag) Equal to True
    • Actions
      • Multiboard - Set the text for M2 item in column 2, row 1 to (String(Flag1))
Now just more for the other team (basically the same with a few changes)
  • Team 2 Update
    • Events
      • Unit - A unit enters [Team 2 Flag Region]
    • Conditions
      • ((Entering unit) belongs to an ally of Player 12 (Brown)) Equal to True
      • ((Entering unit) is A Hero) Equal to True
      • ((Entering unit) has Team 1 Flag) Equal to True
    • Actions
      • Multiboard - Set the text for M2 item in column 2, row 2 to (String(Flag2))
---
AND WERE DONE! I know it was a long process but now you have all the triggers you need to make a great capture the flag game! ENJOY!!!

~Sorccerer
[Special Thanks to: Holloweye]
 
Last edited:
Level 22
Joined
Feb 26, 2008
Messages
891
Ok, I think this tutorial needs some work. Also, it's more of a How-To than a tutorial.

1. Your first trigger could be vastly improved by using a loop or two instead of manually entering each player with their own If condition. Also, there is no need for Do Nothing. It's not doing anything anyway.

2.
  • Item - Move (Item carried by (Entering unit) of type Team 2 Flag) to (Center of [region of team 2 flag])
This leaks. Along with some other things.... You should fix that.

3. Wouldn't it be much simpler to put the multiboard update actions in the same trigger that fires when someone brings the flag in?
 
Top