Campaign Gamemode Prefab

Campaign Gamemode Prefab V1

  • Site Migration: See bugs? Report them here. Want something changed or have an idea? Suggest it here.
  • Something not downloading? Download authors read this.


Super Gay Developer
Aug 9, 2018
Campaign Gamemode Prefab - The most complex gamemode logic

Campaign Gamemode

The goal of campaign mode is similar to TC, taking over the map non-linearly. What is different is that CM has 1 round to capture the final point or hold the most points by the end of the time (no overtime, no time is added on cap).

The main gimmick of this gamemode is that if you penetrate you have the potential to capture multiple points at once! With a single capture it is possible to hold 3/7 points to hold 6/7, but be warned, to be in a position to capture more than 1 point at once you are vulnerable to being cut off yourself.

What is supplied in this download

Inside cm_logic.vmf you will find all 226 entities with all 1901 outputs needed for this gamemode. There are optional relays not included but can be used if needed (will be covered later). There is also cm_logic_unabridged.vmf with BSP that contains a full example with annotated logic if you wish to make any edits. There is also a folder called Prefabs which contains essential prefabs split between 4 folders (merge this folder with Team Fortress 2\bin\Prefabs to use in Hammer), in alphabetical order:
  • Connector Doors : This contains doors that go between the main area and the A-B & D-E areas. These are super fancy multi-modal true one way doors.
  • Control Points : Control points, some of these are super fancy and contain capture areas for multiple points.
  • Misc : This contains spawns (with visualiser and teleport), stun (covered later), and core logic (same as cm_logic but as a prefab - place 2 in one map and you will crash).
  • Spawn Doors : Spawn doors for each spawn position and direction (diagram below) in both short and long area between the shutters and the door.
The multiple capture mechanic

An interactive diagram can be found at

Points are linked together as shown in the interactive diagram above and the spawns and doors diagram below. For a point to be cappable there needs to be different points on either end of the link. Points must also be connected through other points to their main point. Severing a connection between points and home means those seperated points are captured.

How this works is on A, B, D, and E there is an extra capture area which is linked to a bonus point. Depending on if for instance blu capturing A will result in capturing D (currently owned by red) because blu has B, upon capturing A the second capture area is enabled and the bonus point is renamed (details about renaming points below) and captured. This will show in the killfeed as capturing A then capturing D and the map will show that blu owns all but red's home. This also works with 2 bonus points, same example but red owns C capturing A will capture A, C, and D, and will show in the killfeed. Something to note is that it is possible for a bonus control point cap to be blocked, the capture time is immediate however each bonus capture takes around 200ms. It is also possible for players to leave the bonus capture area (but after a second everything is reset so there's no lingering bonus capture area active).

Connector doors, the why and the how

With so many control points teams will end up being spread out, which leaves certain areas unprotected like final control point and home connector (A-B for red, D-E for blu). So there are connector doors which are really fancy they act as a one way for one team and two way for the other; but that's not all, they act as a true one way, even if a defender holds the door open attackers cannot sneak in (there's a nodraw respawn visualiser that is enabled and disabled); on top of that they can be held open for when the area is unlocked and nothing gets screwed when the doors are reset to be one and two way with someone in the triggers.

The idea is that while teams have spawns they also have home areas. The main area is locked off and has a stun with a hurt which is activated 15 seconds after doors lock just to clear out the area, this area is opened when both base points are held by the enemy. There is also a home connector which is between the 2 base points, this area is locked off when the defenders have both base points (if blu captures A, regardless of B, the connector is opened up allowing blu to travel between A and B), buildings can be built in this home connector.

Spawn doors are another issue, below.

Spawns and you

Each team has 3 spawns: rear, middle, and forward.
  • Rear is occupied when the team is forced back when they only have only their main control point.
  • Middle is when a team owns any 2-5 control points
  • Forward is occupied when the other team is in rear/when the team owns all but the opponant's main control point.
Those in forward are teleported back to middle when forward spawn is lost.

Rear and middle can be merged into a single spawn room.

How do you get out of spawn rooms? Spawn doors!

Spawn doors is the largest prefab folder with 16 different prefabs across 4 positions, for 2 teams, with 2 "styles".

Spawn doors comprise of 2 main parts, the door, and the locking shutter. When a spawn door is too adventageous or the spawn room is disabled the locking shutter, locks (don't try to jam yourself in it, you'll die, but dw it's slow), the inner door is also locked. These doors come in 2 styles which changes the distance between the door and the shutter either normal, with minimal distance, and extended with a space (don't worry you can't get stuck there).

There are spawn doors for (Red/Blu) A/D, B/E, A-B/D-E, and C/C.

Here's a diagram for spawns and doors

Click to view larger

Control points' names

Due to how the bonus point works control point names are duplicated in order for the killfeed to show it correctly. You will need to open up the VMF in a text editor that has find and replace. Control points are named in the format $point_0_name where the 0 can be a number between 0 and 6 inclusive. From 0 to 6 you will rename 1,3,3,9,3,3,1 times. Be warned, it is very unlikely but if you name your control point something like classname or something that exists already in the VMF if you try to rename it again it will rename important details. However you can rename a point to classname as long as you don't then rename classname. Renaming points to letters is safe but when renaming rather than rename A you rename "A" and include quotation marks in the output name, such as "New A".


Hooks are a brand new features to gamemodes, but no gamemode has been complex enough to need them. These hooks do not exist in any of the prefabs, but their outputs do, they are made by you and use a standard naming system which are called when needed.

These Hooks come in 2 flavours, relays, and props. Relays are fully featured and props need some custom props.
  • (Relay) own_{point}_to_{point}_{team} e.g. own_0_to_1_red (red owns red main to A). This is fired to tell the relay that that team owns the route between 2 points. The points are smallest to larger. 1_to_4 yes, 4_to_1 no.
  • (Relay) direction_{point}_to_{point}_{team} e.g. direction_3_to_4_blu (blu can go from C to D to capture a point, this relay exists at C. 4_to_3 exists at D and red will be triggered). This is used to set custom props such as arrows to tell players "You're blu, you can go here to go to a point" while directions that lead to their point will be set to "none" but own_ will have fired - the intended use is to have arrows for direction, and plain colour for own. Relays for both directions exist.
  • (Prop) prefer_{point}_to_{point}_{team}* e.g. prefer_3_to_4_blu (skin 4, means that if standing between C and D signs for control point should show "E"). This takes into account location and what is the best move, in this case blu owns C and E, if red captures E they lose C as a bonus point, so should capture D to protect C.
Last edited:


Super Gay Developer
Aug 9, 2018
How does this work

You do not need to understand how, but if you are curious. This logic is based almost entirely on chains of relays that are enabled or disabled to control flow, it is not the only way, it is not the most compact way, but it is the easiest to reason with and generate programatically (spoiler).

State manager

This game has 17 states, the initial state and then 16 states where there are no points without links to main point. The control point layout is the small endian binary of the points where red is 0 and blu is 1 plus 1 (so state 1 is 0,0,0,0,0 red owns all, and 7 is 0,0,1,1,0) because the initial state where the middle is contested is state 0, I regret not making it state 16 and doing binary for others, but it's done now. To determine the state there are 5 relays for each state which just look at the middle 5 points (the main points don't matter because if a team doesn't own their point the game is over and no logic relies on knowing who won). These 5 relays are in the format state_check_{control point number}_{team}_{state number}, they relay onto the next control point (if enabled, if disabled the state is not true), if for instance red captures point 1 relays state_check_1_red_* are enabled, state_check_1_blu_* are disabled. Then the initial relay for all states is triggered state_check_1_* and 1 and only 1 state has the valid combination of red and blu relays all set to enabled.

state_{state number} carries the bulk of the logic, it controls which points are locked and unlocked, which points result in bonus captures and line it up, all of the hooks which are told which team owns which route, if team 1 are at control point A which way should they go to be most helpful (it changes depending on where you are), as well as hooks for changing arrow model skins, and maps. Each of these 17 state relays contains around 80 outputs. This also manages setting ownership of bonus control point captures.

Control points

After every capture, after the capture has been processed, the state above is called to then make modifications to the control point logic. The majority of the function is general control point logic like setting control point skins, but in 4 of the 12 possible captures bonus points are possible. Bonus points can only be achieved by either team by capturing both of the home control points, so blu capturing both A-B and D-E for red. This means that only those captures need to check for bonus captures. Bonus capture possibilities for each of the 4 possible capture positions is 1 double, and 2 singles. These are enabled by the State manager.

Bonus points

While visually this map has 7 control points, it actually has the maximum of 8 (you'll notice there's an extra one provided with the core logic). This 8th point acts as every bonus point. Whenever a valid bonus point is triggered the bonus point is renamed and the trigger on that point enabled, the cappers get 2 or 3 captures. For double bonus points the bonus point capture trigger fires off for a part 2 and if it is the case for double bonus points it will be renamed and the capture area enabled for a third capture. If for whatever reason the captures do not happen the bonus points system is reset after a second, it's possible for a bonus point capture to be visually blocked or to leave the trigger immediately after a capture to not cap a bonus point (the window is tiny but the system is as fast as it can go and it's around 200ms per bonus point).

Spawns, doors, and team areas

When State changes spawns and door logic is set and is then run after any control point capture.


There are 2 main circuits, one handles when spawns should move and after firing is disabled so it doesn't fire again, then the other deals with telling the spawns to enable/disable and flick the teleporter.

Spawn doors

On top of the Spawns logic there are doors, red middle spawn should have MIDDLE - A door disabled if blu captures A. There is a pair per door for open and close.

Connector doors

Connector doors and main area doors are triggered by the State and do repeat even if their mode doesn't change but it doesn't matter. Signs above doors change team alliance depending on state.

Team areas

This circuit is seperated from the other logic as it is the only logic that can be edited manually. It is the 2 columns in the smaller skip opposite the bonus control point. This handles when a main area (the area around main) is locked and unlocked, but in addition there are additional relays for 5, 15, and 30 seconds after (feel free to edit the timings if you need, the timing is in the bottommost relay). By default the stun and hurt triggers exist in the 15 second relay. These delayed relays are cancelled if it goes between locked and unlocked, or vice versa. Signs above doors change team alliance and name depending on state.


What overtime? Overtime for a map where so many control points can be unlocked at once is not good. So there is no overtime, and as a bonus there is no added time on capture. The gamemode expects that not all points will be won in a round and it doesn't result in stalemate.

One trick, and if you learn anything is that you can't add an OnFinished output from the timer expecting it to fire once the time ends because OnFinished fires after overtime. The trick is to use On1SecRemain, then delay whatever you need by a second. Although in this case by 0.85 seconds due to timing, so 0.15 seconds before finish, all capture points are locked, 0.15s later the timer runs out and sees all control points are locked and the game ends (weirdness happens if there isn't enough time between locking the points and the timer ending, it can't be done too close together). This does mean that the actual timer for the gamemode is 07:59:85 and not 8 minutes. But if not all points are captured it should be a draw, but when the timer finishes a counter is compared and this counts the points red has over blu (first point is +1 or -1, all other captures are +2/-2, as long as the first point is captured the value is never 0). This runs into 3 round wins for red, blu, or both teams are useless and they didn't cap the 1 point that was unlocked in 8 minutes and should be eternally shamed AKA none.

How was this made?

This gamemode has a complex net of 226 entities and over 1'900 outputs (over by 1), and I made this within the first 24 hours. What did I do to manage to make sure I got all 1'900 outputs correct and in the correct entity without messing up? This gamemode was generated programatically, almost all of the outputs (I did around 30 manually) were generated based on a simple set of rules and while I didn't write a full VMF generator it gave me the outputs that I merged with relays.

It is my intention to create a full logic library. Which allows you to programatically create complex logic by using an actual programming language. For instance you could make something that looks like this:

const cp_prop = new PropDynamic({
const cp = new ControlPoint({
cp.onRedCap(cp_prop, e => e.setSkin(Team.Red)/*,{delay:1}*/);
cp.onBluCap(cp_prop, e => e.setSkin(Team.Blu));
//cp.on(`red cap`, cp_prop, e => e.setSkin(1)); //Does same as onRedCap()

const bell_ring = new AmbientGeneric({
  `start any`,
  e =>,
    cancel:[`break any`, `end any`]
); //Play sound if capping uninterrupted for 4 seconds
Last edited: