# Add a map

Source: https://aot.titan.tf/docs/maps/
Description: Run AOT on any normal TF2 map with one small file, and place robot spawns by hand when the map needs them.



Everything AOT is told about a map sits in one file, named after the map. Drop the file in and the map runs as Mann vs. Machine.

## Give the map a file [#give-the-map-a-file]

Make `addons/sourcemod/configs/aot/maps/<map>.ini` and list a mission:

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

A map with no file, or a file with no mission, stays a normal map. `mvm_` maps are never changed: they are Mann vs. Machine already.

`cp_gorge_adv_wormhole_wreck` does not need a file of its own. A mission named `<map>_<template>` uses the shared template `adv_wormhole_wreck.pop` when there is no `cp_gorge_adv_wormhole_wreck.pop`. See [Missions](/missions).

AOT ships files for more than 70 maps. Five of them list a mission: the tour's 2Fort, Badlands, Foundry, Viaduct and Upward. Almost all of the others hold robot spawns already placed by hand, so they only need a mission line.

<Callout title="Workshop maps">
  A Workshop map's file is named after the map alone, without `workshop/` and the `.ugc<id>` ending.
</Callout>

## Load it [#load-it]

Change to the map. AOT puts the robots in BLU's first spawn room and logs the mission it loaded. For most maps that is all.

To see what AOT read from the file, run `sm_aot_check` in the console:

```txt
[AOT] cp_gorge: configs/aot/maps/cp_gorge.ini
[AOT]   missions: 1, starts with cp_gorge_adv_wormhole_wreck
[AOT]   spawn points placed by hand: 0
[AOT]   removals: 0
[AOT]   navigation mesh: maps/cp_gorge.nav
[AOT] cp_gorge: ok
```

## Help the robots out, if they need it [#help-the-robots-out-if-they-need-it]

If BLU's spawn room does not suit robots (a door they cannot open, a spawn behind a gate), place spawns by hand. Stand where a robot should appear and run:

```txt
sm_aot_spawn
```

It writes the line into the map's file, under `[spawns]`. `sm_aot_spawn spawnbot_giant` saves a point under another spawn name, for missions that send their giants somewhere else. The points are used the next time the map loads.

You can also write the file yourself:

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

[spawns]
; <spawn name> = x y z, or x y z yaw
spawnbot = -1227.54 2196.81 -350.97
spawnbot_giant = -1100 2196 -350 90

[remove]
; entities taken off the map while it loads
name = door_lightblock
class = func_respawnroomvisualizer
```

| Section      | Lines                                          | What they do                                                                            |
| ------------ | ---------------------------------------------- | --------------------------------------------------------------------------------------- |
| `[missions]` | `mission = <name>`                             | The missions the map can run. The first one is the mission the map starts with.         |
| `[spawns]`   | `<spawn name> = x y z` or `x y z yaw`          | A robot spawn point. One line per point. `getpos` in the game console reads a position. |
| `[remove]`   | `name = <targetname>` or `class = <classname>` | Takes the map's entities with that name, or of that class, off the map.                 |

A spawn name nobody places gets a copy of the `spawnbot` points.

## Check a file [#check-a-file]

On a server, `sm_aot_check [map]` lists what is wrong with a map's file: lines AOT cannot read, missions with a missing file, a missing navigation mesh. AOT writes the same problems to the error log when the map loads.

Without a server, with [Bun](https://bun.sh):

```txt
bun tools/check-maps.ts
```

## Share it as a map pack [#share-it-as-a-map-pack]

A map pack is a folder laid out like `tf/`, with the map files and any missions of your own. `examples/map-pack` in the repo is one:

```txt
examples/map-pack/addons/sourcemod/configs/aot/maps/cp_gorge.ini
examples/map-pack/scripts/population/norm_first_contact.pop
```

A server owner copies the folder into `tf/`. Check a pack before you share it:

```txt
bun tools/check-maps.ts examples/map-pack
```

## What AOT does to a map [#what-aot-does-to-a-map]

While the map loads:

* takes off the entities the map's file names;
* adds Mann vs. Machine's game logic;
* adds robot spawn points for every spawn name the map's missions use, and a few for each spawn name the other mission files in `scripts/population` use (up to 32 names, `mvm_` files left out), so a mission switched to later finds its spawns;
* keeps 8 spare spawn slots (`aot_spare`) for a later mission that needs a name the map has not got;
* puts an upgrade station on every RED resupply cabinet, and on BLU's when humans may play BLU.

During play it:

* switches robot spawn points back on when a stage of the map turns them off;
* shrinks a giant that cannot get through a spawn room door, and gives it its size back outside;
* removes a robot that stood in its spawn room for a minute, so the wave can end;
* leads the robots with a marker on maps with no flag;
* builds a route for Tanks: the payload track, or the navigation mesh to the objective.

<Callout type="warn" title="Custom maps need a navigation mesh">
  Without `maps/<map>.nav` the robots cannot walk. Make one with `nav_generate` on a listen server.
</Callout>
