# Missions

Source: https://aot.titan.tf/docs/missions/
Description: How AOT finds a mission's .pop file, how one template serves many maps, and the checks that keep a broken mission off your server.



A mission is a normal TF2 Mann vs. Machine population file (`.pop`), the same format Valve's `mvm_` maps use. Anything a popfile can do, an AOT mission can do.

## How AOT finds the file [#how-aot-finds-the-file]

A map's file lists the missions the map can run (see [Add a map](/maps)). Missions are named `<map>_<template>`, for example `ctf_2fort_adv_overclock`, with letters, digits, `_` and `-` only. AOT loads:

1. `scripts/population/<map>_<template>.pop`, a mission made for that map, when it exists;
2. otherwise the shared template `scripts/population/<template>.pop`.

So one template can serve every map. Write `adv_wormhole_wreck.pop` once, then list it in as many map files as you like. Make a map its own copy only when it needs different waves.

## More than one mission on a map [#more-than-one-mission-on-a-map]

A map file can list several missions. The first is the one the map starts with. The others can be switched to while the map runs:

```ini title="configs/aot/maps/cp_gorge.ini"
[missions]
mission = cp_gorge_norm_first_contact
mission = cp_gorge_adv_wormhole_wreck
```

`sm_aot_missions` lists them, and `sm_aot_mission <name>` switches to one. A plugin does the same with `AOT_LoadMission`.

To run one mission on every map, set `aot_popfile` to its name. `auto`, the default, runs each map's own.

## Spawn names [#spawn-names]

Each `WaveSpawn` and `Mission` says where its robots come out with `Where`. On a normal map AOT makes those spawn points while the map loads, for every name the map's missions use. Most missions use `spawnbot`. A name nobody placed by hand gets a copy of the `spawnbot` points.

## Base files [#base-files]

A mission can share templates with `#base`:

```txt title="scripts/population/ctf_2fort_adv_overclock.pop"
#base robot_aot_overclock.pop

population
{
    StartingCurrency    1500
    ...
}
```

AOT follows `#base` up to 4 levels deep.

## The safety check [#the-safety-check]

TF2 crashes on the next round start when a mission file or one of its `#base` files is missing. So before it loads a mission, AOT checks that every file exists. Templates inside the game's own files, such as `robot_standard.pop` and `robot_giant.pop`, count as present. If one is missing, AOT leaves the map a normal map and logs which file is missing. `sm_aot_check` and `bun tools/check-maps.ts` find the same problem before the map loads.

## Tanks [#tanks]

A Tank needs a route. On a payload map it follows the cart's track. On other maps AOT builds a route over the navigation mesh to the objective. `sm_aot_tank_route` shows the route on the current map.

The five tour missions send no Tanks. The shared templates `adv_wormhole_wreck` and `exp_outworld_oppression` do, so a map that uses one of them gets Tanks.

## The shipped missions [#the-shipped-missions]

| Map          | Mission                             |
| ------------ | ----------------------------------- |
| ctf_2fort    | `ctf_2fort_adv_overclock`           |
| cp_badlands  | `cp_badlands_adv_machine_massacre`  |
| cp_foundry   | `cp_foundry_adv_bone_shaker`        |
| koth_viaduct | `koth_viaduct_exp_cataclysm`        |
| pl_upward    | `pl_upward_int_big_apple_barricade` |

The repo also keeps the original hand-made AOT templates in `assets/_popfiles/popfiles`. `bun tools/generate-popfiles.ts` copies them into `scripts/population` for a server that wants all of them.

## Switching missions from a plugin [#switching-missions-from-a-plugin]

A plugin can read a map's missions with `AOT_GetMapMissionCount` and `AOT_GetMapMission`, change the mission mid-map with `AOT_LoadMission`, and name a mission ahead of time with `AOT_OnPlanMission` so its spawn points come with the map. See [Plugin API](/plugin-api).
