Forts
138 ratings
The Forts Map Editor
By EarthWork Games and 4 collaborators
This is a comprehensive guide to creating and editing maps in Forts. We'll add screenshots and videos as we have time to make things clearer.

Warning: don't upload maps to the workshop that contain copyright material such as music or sounds and images from other games or movies. Doing so will result in a ban.

Version française du guide ici : https://steamcommunity.com/sharedfiles/filedetails/?id=927525825
2
2
3
2
   
Award
Favorite
Favorited
Unfavorite
Starting Up
The Forts map editor is built right into the game, making it easy for everyone to build levels! Some work needs to be done to make it more user friendly. Feel free to make feature requests. For now, here are the basics.

First select 'Map Editor' from the main menu. From the editor menu you can create a new map with a specific name, or chose to edit or copy an existing map. There are template maps to copy to get you started quickly.

The Map Folder, Mission Script, and Display Name
When the map is created or copied, a new folder is created under data/maps to contain it. That folder contains a script, which specifies basic properties of the map, such as enabled mods, where it should appear in the game, and is it symmetrical, as well as any custom logic to make an interesting mission. This is where the campaign missions do their work. It can contain dialogue between characters, player instruction, AI configuration, disabling of items, custom HUD elements, special events and custom win conditions.

The rest of this guide will refer to this as the 'mission script', so you should know how to find it, as well as other files related to the map.

Right click on Forts in Steam, then properties, then the local files tab. Browse local files, then navigate to data/maps and then find the folder for the map you are creating. It will either have the name you gave it at creation, or something like playermap1 if you used non-ANSI characters or other problematic characters such as slashes and periods. In there will be a .lua file with the same name. That's the mission script.

You will also see a displayname.lua, which can be edited to change what people see, including in non-English languages. The map itself is made of an .spr file, which contains all structures and devices, and a .fwe file which contains the environment setting, ground and props. A few preview jpg images are used to show the map in the menu. If you have scripted an AI for the map they will appear here as .lua files starting with "fort". If you have already uploaded your map you will see publishedfileid.lua which just tells the game which Workshop item this map relates to.
Enabling Mods and DLCs
When you create a new map you are asked to select the mods you want to force on, including the built-in mods for the DLCs, and player made Workshop mods. If you select any of these the player must have access to the DLC or subscribe to the Workshop mod. If you are not giving the starting forts items from these mods, or in some other way need them, you should not select them, since it will limit the players able to use your map. Additional mods can always be selected at runtime, so don't force them on just because you like them.

The selected mods are written into the initial mission script's Mods table. Without any mods selected the table will be empty.

Mods = {}

If you change your mind after creating the map the mission script can be edited. You can see some of the mods that are available in the data/mods folder. Some of these are special use mods, starting with language-, commander-, keyboard-, and faction-. The others can be enabled on a map-by-map basis. For example, to supply unlimited resources, change the line to:

Mods = { "unlimited-metal", "unlimited-energy" }

Any number of mods can be added to this list.

If you have made a map which starts with weapons or tech buildings from Tons of Guns, you will need to add the weapon_pack mod to your Mods list. This forces Tons of Guns on. You could otherwise be missing items if it wasn't manually activated.

The DLC mods are hidden inside pack files. The important DLC mods are:

  • "weapon_pack": Tons of Guns (free DLC available to everyone)
  • "dlc1": Moonshot blastdoor material
  • "dlc1_capture_high": Increases the points required to open capture mode blastdoors by 50%
  • "dlc1_capture_low": Reduces the points required to open capture mode blastdoors by 50%
  • "dlc1_portal": Moonshot portal material
  • "dlc1_weapons": Moonshot weapons
  • "dlc2": High Seas materials, devices and weapons
  • "dlc2_ammo_control": High Seas control ammo

To force on Workshop mods you will need to discover their published file id, which is a long number found in the mod's URL, visible when you use the Workshop Share button. It can also be found in Steam's workshop directory for Forts (C:\Program Files (x86)\Steam\steamapps\workshop\content\410900 by default). For example, to make sure Large Sandbags are available in your map:

Mods = { "1293804859" }

To make it easier to understand, you could write it like this instead:

sandbags_large = "1293804859" Mods = { sandbags_large }
Keyboard Layout and the Console
All key bindings listed in this guide are for the QWERTY keyboard layout. On other keyboard layouts the key will be in the same physical position as on QWERTY. For example on the QWERTZ layout Undo is Ctrl + Y and Redo is Ctrl + Z. You can query the actual key bindings in the game using the proflist and keylist console commands listed below. Keys can be rebound in Options menu -> Input tab -> All Keys tab.

Some functions require issuing commants into the console. Drop the console by using the ~/` (tilde/grave) key, usually left of the 1 key, or F3. Commands start with a backslash. Tab will autocomplete the current contents. A few useful commands are:

\cmdlist => shows a list of commands
\proflist => shows a list of key profiles
\keylist [id] => shows a list of keys in key profile [id] taken from \proflist
\cvarlist => shows a list of console variables
Undo/Redo
There is unlimited undo/redo functionality so don't be worried about making mistakes.

Ctrl + Z => Undo
Ctrl + Y => Redo

Remember that key bindings given in this guide is for QWERTY keyboards. On QWERTZ keyboards these keys are swapped.
Editor Modes
There are five editing modes:
  1. Structure
  2. Device/Weapon
  3. Terrain
  4. Surfaces
  5. Props
The tabs on the HUD will switch to the appropriate mode. In some situations you can switch to structure and device/weapon mode by left clicking on items in the world. Z, X, and V can still used to cycle between materials, devices and weapons respectively. C doesn't cycle technology since this tab is disabled in the map editor for space reason. Technology items are included in the device tab instead.
Terrain Mode
This mode allows you to create and manipulate ground 'blocks' and set properties of the world. These are the polygons that the players build on and projectiles can hit. The texture can be changed in the Terrain tab, but for now there is only one useful texture. The other is for special blocks.

Selection of Blocks

You can select a single block by right clicking on it, or using [] to cycle between them. Single block selection is necessary to manipulate the nodes (vertices) of a block. Multiple blocks can be selected to copy or manipulate many blocks at once. Right click in open space will deselect all blocks.

Right mouse => select block under mouse or deselect all (in empty space)
Ctrl + Right mouse => add or remove the block under the mouse to/from the selection
Alt + Right mouse => remove block under the mouse from the selection
Shift + Left mouse + drag => add area selected blocks to the selection *
Alt + Left mouse + drag => remove area selected blocks from the selection

* when a single block is already selected this will select the block's nodes instead

Each block is made up of a number of 'nodes', or vertices. With a single block selected you can left click on nodes to select them individually. Ctrl + A will select all nodes, and Ctrl + D will select none. Ctrl + Left Mouse allows you to add nodes to a selection. Shift+Left Mouse Drag allows you to add nodes in a rectangular region to the selection. Alt + Left Mouse Drag allows you to subtract nodes from the selection under a region.

With one or more nodes selected you can left click on one and drag them all. The one you dragged will snap to nodes and edges of other blocks.

Creation of Blocks

Lose any selection by right clicking in open space, and then left click to start placing new nodes in a clockwise order. The white lines in the middle of each edge should point outwards, these are the normals of the surface. If you get it wrong, just press Shift + F to flip the normals.

You can left click on an edge to add a new node any time after the block is made.

Manipulation of Blocks

There are several keyboard and mouse shortcuts for manipulating blocks. Remember that you can use Ctrl+Z to undo anything.

Ctrl + A => select all nodes
Left mouse => select node under mouse (with block already selected)
Left mouse + drag => move the selected nodes
Alt + Arrow Keys => nudge selected nodes
Shift + Left mouse => add single node to selection
Shift + Left mouse + drag => add area selected nodes to selection
Alt + Left mouse => remove single node from selection
Alt + Left mouse + drag => remove area selected nodes from selection
Ctrl + C => copy the currently selected block
Ctrl + V => paste copied block at the mouse position
H => mirror selected block horizontally
Shift + V => mirror selected block vertically
Page Up => adjust the render order of the block up (toward the background)
Page Down => adjust the render order of the block down (toward the foreground)
Backspace/Delete => delete selected nodes

Alt + X => Split a group between two selected non-adjacent nodes
J + Left mouse => Join the group under the mouse at two selected nodes. Selected nodes must be adjacent and correspond to adjacent nodes in the merge target.

Deletion of Blocks

Ctrl + Backspace => delete the currently selected block.
Ctrl + Delete => delete all blocks. Be careful! Remember Ctrl+Z.

The Environment & Terrain Style

To make environments feel distinct, we have made our official maps with a certain style, consistent for each environment. Maps that use the fields environment all have rolling hills, for example.

You can improve the quality of your maps by following the same style, described in the Map Editor Style Guide.

Optimisation for Collisions

When a block is selected you can see a faint orange circle surrounding it. This is the bounding circle. When the game is looking for collisions with a projectile, beam, or structure, it is used to quickly disregard blocks which are not nearby.

Ideally, the size and shape of the block will closely match that of the bounding circle. Put another way, you want to minimise the amount of empty space which projectiles and beams can pass through before hitting the block. This is because once the object is inside the bounding circle, the game must check each edge of the block to see if there is a collision.

To reduce the work the game must do and make your map faster to play, avoid making long blocks, especially if the surface has many nodes. Instead it's better to break them into smaller blocks placed next to each other.

If the bounding circle overlaps other blocks or space where colliding objects can't exist (e.g. under the ground surface) then it's not a problem.

World Extents

In Terrain mode you can adjust the size of the visible world. Regions Inaccessible to the camera are shaded in green. Placing the mouse to the desired location, and pressing Ctrl + an arrow key corresponding to the desired extent. Blocks should extend a little beyond the world extents so that when the camera shakes you don't see cracks.

You can also use Ctrl + Home to set the extents based on the current view.

There is also an easy way to expand and contract the extents and all the contents of the world horizontally to make the map wider or narrower. Place the cursor where you would like the expansion or contraction to take place, and press the following key combinations. Avoid placing the cursor in the middle of a structure.

Alt + Minus => contract world at cursor
Alt + Plus => expand world at cursor

Screen Positions

The initial view of players is set using the following keys while the Terrain tab is selected:

Ctrl + 1 (numpad) for team 1
Ctrl + 2 (numpad) for team 2
Ctrl + 3 (numpad) will save the overview perspective (full map) from the current view.

The map preview images are taken using these screen positions when it is saved. They must be set properly for the map to be presented well and for players to not be disoriented.

Block Ownership

You can allocate ground blocks to specific teams, or otherwise, using the following keys:

1 => Team 1
2 => Team 2
3 => Any team
4 => No team (unbuildable)
5 => Background (unbuildable)

In order to allow ropes to be pegged to non-foundation blocks, you should set the owner to Any team, but disable foundations and mines (see next).

Ground Properties

The following keys allow you to set various properties of a ground group:

Alt + F => Toggle allow foundations
Alt + M => Toggle allow mines
Alt + W => Toggle wind floor (used to determine efficiency of wind turbines)
Alt + V => Toggle view floor (used to determine size of weapon aiming circles)
Alt + D => Toggle no draw
Alt + E => Toggle no draw edges
Alt + P => Toggle pass projectiles
Alt + B => Toggle pass beams
Alt + H => Toggle hazard
Alt + N => Toggle no splash damage
Alt + C => Toggle no build
Alt + O => Toggle can build over
Alt + L => Toggle sets water level (High Seas only)
Alt + I => Toggle draw edge with fill

Wind floors and view floors are typically have their Background and No-Draw properties set.
Surfaces Mode
This is really a sub-mode of the Terrain editor. Each surface of a block can have a different 'edge set' applied. Each node in a block controls the surface in the clockwise direction. To change a node's edge set, select the node and then hit the desired edge set graphic on the HUD. You can select multiple nodes to change them all at once.

Edge-sets can have some rules about what's drawn depending on the orientation of the surface (e.g. grass on top, rocky crags on the under surface). Or they can be all the same. The scripts that set the rules are found in data/environment/<theme>/surfaces/surfaces.lua.

The convention for the game is that surfaces that can be built on use the light brown rocky edge set, while non-buildable surfaces use the grassy/craggy set.

When the surface is buried underground and adjacent to other blocks then there should be no edge set applied, applied with the blank, left-most button on the HUD.
Making Water Maps for High Seas
The High Seas DLC, released in March 2022, added buoyancy physics, dynamic terrain, splash effects, backgrounds and more, to allow rich ocean based environments. Creating maps which take advantage of water requires a little more care than regular Forts maps.

We have provided a template map to make starting your own High Seas maps easy. Just open the Map Editor menu, go to the Edit tab, check the 'Copy' box, and scroll down to find the map 'dlc2_template (-template-)', and select it. Enter a name for your new map, and then press the Copy button. You will see two ships facing each other on water.



You can edit your new copy of the template as you wish, add land, and additional ships and forts, and change the background as you like. To understand how the water is configured, please read on.

Multi-level water physics
A new block property was added called 'Sets water level', toggled by default with Alt + L. You can apply this to any block at various heights to change the water level that pushes structures up to emulate buoyancy. It is indicated by a purple line. 'dlc2_WaterLevel' is depricated.

Visual & gameplay layers
There are 4 terrain layers that make up the water maps. The map will look and play best with all of these present, and the top edge of layers 1-3 are coincident, but you are free as a map maker to exclude or move any of them. Only the physics water level mentioned above is necessary for the structures to actually float.
  • 1. overlay & surface
  • 2. sunbeams
  • 3. background
  • 4. no-build zones


1. overlay & surface
This is the top visual layer of water. It is drawn over structures and projectiles and solid terrain to make it look as if they're under water. Assign it the translucent grey or blue textures provided.

The top edge should have the 'whitecaps' surface applied, shown below. This will automatically subdivide the edge and animate it to look like water. Projectiles and beams will collide with this to make splashes and fade them out. Note that the animated water won't be shown within the map editor.



Other edges should be blank. The block must have the CanBuildOver flag set so it does not interfere with structures or construction.

2. sunbeams
This layer is simply to give some interest to the water near the surface. Assign the appropriate texture, and give the top edge the 'whitecaps' surface. The NoDrawEdges flag is set, which prevents the edge being visible, but it animates the block to make it match the waves correctly.

Also set the Pass projectiles and Pass beams flags, to ignore collisions with projectiles (this is layer 1's job). CanBuildOver is set too.

This can be above or below layer 1, depending on how bright you want the sunbeams to be.

You can also adjust the height to change the length of the sunbeams, but make sure the texture doesn't wrap within the block. This will put limits on where you can have your water level.

3. background
This is an opaque layer drawn under layer 1 and 2 to block the map's background and give the feeling of a vast ocean. Give the top edge the 'whitecaps' surface to match the layers above it, but set NoDrawEdges.

Assign Background as the Owner so it is drawn under structures. This will automatically make it dark. If you want to adjust that, use the \set_ground_colour R G B A command in the console. The example below will set it to 90% solid grey:

\set_ground_colour 0.9 0.9 0.9 1

4. no-build zones
These zones put limits on how big the player can build their ship. They are optional of course, but without them you may find that matches go on for a long time or turn into a stalemate. We typically give enough horizontal space to build around 12 propellers, but maybe less for small 1v1 maps.

Assign it the yellow and red 'no-build' texture, set the Owner to 'Background', and set the 'No draw' and 'No build' flags. With the No draw flag set, the zone will remain unseen until the player's cursor gets close enough, and then it will appear around the cursor.

At the moment the visualisation will not handle corners or complex shapes, it will just find the nearest edge and assume the zone nearby is flat. We recommend keeping the zone simple, with large vertical or sloping edges.



If the checkered utility texture is applied to a no-build block, then it will never be visible, as is done for the capture maps in the Moonshot DLC. In the context of High Seas this would be confusing.

Solid Ground
You can add ground blocks as normal to prevent construction, collide with projectiles, and provide solid ground for players to build on.

Adjust the order of the blocks so they are under the water layers. If the background layer (3) of the water is set to the Background Owner then it will be drawn behind this solid ground automatically.

Keep in mind that if the ground's owner is set to Any then the player will be able to attach ropes under water, which may allow the deep water propeller exploit.



Starting new ships
Since you can't make a new joint in mid air (or water), starting a brand new ship is a little tricky. One way to achieve it is by creating a block supporting foundations, making a foundation, and then building out to shape the ship. Once it's started you can delete the foundation and block.



Another way is to copy and delete parts of an existing ship to rebuild it into something new. If the ship has already had the simulation run on it then it will bring some deformation to the new structure.

See the section 'Standard Ships for High Seas' to learn about using the ships we have built.

Once you have made the new ship, you can move it into the approximate position by selecting a joint and holding M. Then enable the simulation using Ctrl + Space to let it settle into position as normal.

Ship movement
We found during development that firing weapons would make boats move backwards, due to recoil. This was problematic as the ships would hit the back of the map, other ships, or overlap the no-build zones. To counter this, the High Seas mod, dlc2, automatically applies a small re-centering force to the platform of each reactor, to get it back to the position it was found at when the match started.

If for some reason this is not the behaviour you want for your map, you can override it. To remove it completely, just execute the following command in your mission script:

ExecuteInScript("mods/dlc2/script.lua", -1, "data.reactors = nil")

To make a ship move, you can use the SetReactorPos(id, pos, maxDelta) function of dlc2's script.lua. The pos parameter is the target position, and maxDelta limits the effective distance to it, and so limits the force magnitude. If you know or find reactorId, call it like this to, for example, move it to the left:

local scriptCall = "SetReactorPos(" .. tostring(reactorId) .. ", Vec3(-100000, 0), 250)" ExecuteInScript("mods/dlc2/script.lua", -1, scriptCall)

High Seas dependency
Once you use the dlc2_WaterLevel variable, use one of the dlc2_oceans_* environments, or add "dlc2" to the Mods table, your map will become dependent on High Seas. You will need to set the following variable to the mission script for the Workshop upload to succeed:
RequiresHighSeas = true
Procedural Terrain and Transformation
It's possible to create several shapes and patterns without clicking out each vertex precisely. To do this use the \terraform console command. The first parameter to this command is the path to a script. The second parameter (the remainder of the line) is arbitrary Lua code to execute in that script. There is an included script called shapes.lua, which has built in documentation, accessed like so:

\terraform scripts/shapes.lua Help()

This will show you the names of available functions to create shapes and manipulate them, which can be passed to the Help function to give further details. For example, Help("Circle"). Each function has default parameters so you can see what it does and what parameters are sensible. You can undo after the command if the result is unwanted.

The shapes and waves will create the new terrain blocks at the cursor. The transformation functions will operate on the current selection, relative the cursor position.

Shapes

Rectangle(width, height)
Creates a rectangle at the cursor position. If height is absent it creates a square.

Circle(radius, step, solid)
Creates a circle at the cursor position. The step parameter sets how many vertices are used (a lower value means more vertices). If the solid parameter is set to Hollow it will make a cave of the given size.

Ellipse(a, b, step, solid)
Creates an ellipse at the cursor position, where a is the horizontal extent and b is the vertical extent. The step parameter sets how many vertices are used (a lower value means more vertices). If the solid parameter is set to Hollow it will make a cave of the given size.

\terraform scripts/shapes.lua Ellipse(800, 600, 60, Hollow)



Polygon(sides, radius)
Creates a regular polygon with the specified number of sides and radius.

Star(points, radiusOuter, radiusInner)
Creates a regular star with the specified number of points and inner and outer radius values.

Cog(verticesPerTooth, teeth, radiusOuter, radiusInner)
Creates a cog/gear shape. The verticesPerTooth defines how high the resolution is.

\terraform scripts/shapes.lua Cog(4, 6, 800, 600)



Waves

SineWave(amplitude, wavelength, step, cycles)
Creates a sine wave in segments. The step parameter sets how many vertices are used (a lower value means more vertices). The number of segments is set by the cycles parameters.

\terraform scripts/shapes.lua SineWave(300, 1000, 60, 4)



StepWave(stepLength, stepHeight, levels, cycles)
Creates a progressive step wave (terraces) in segments. The number of segments is set by the cycles parameters.

TeethWave(flatLength1, stepLength, stepHeight, flatLength2, cycles)
Creates a repeating pattern of bevelled teeth in segments. The number of segments is set by the cycles parameters.

\terraform scripts/shapes.lua TeethWave(400, 100, 200, 300, 4)



Transformations

Rotate(angleDegrees)
Rotate the current selection of blocks around the cursor by angleDegrees.

\terraform scripts/shapes.lua StepWave(200, 150, 3, 4) \terraform scripts/shapes.lua Rotate(45)



Scale(x, y)
Scale the current selection of blocks around the cursor by x horizontally, and y vertically.

Translate(x, y)
Translate the current selection of blocks by x units horizontally, and y units vertically.
Prop Mode
The prop mode is for placing detail in the world, such as metal ore deposits, trees, rocks, grass, and dinosaur bones. Texture selection is done by the HUD.

These do not interact with anything during the game, but can be turned on and off by the mission script.

Placement
Left click in open space to create a new prop using the current texture. Left click on it again to select it. Once selected you can left click anywhere to move it. Left click selects other props, and right click deselects.

Layer and Render Order
There are three layers which control when props are rendered relative to background blocks, foreground blocks and structures. 1 = Background, 2 = Midground, 3 = Foreground.

Within these layers the props can be ordered with the Ctrl+, (comma) and Ctrl+. (period) keys.

Tile Mode (currently broken)
To allow rapid placement of grass, rocks, etc. Use the T key to toggle tile mode. In this mode, you can click a sequence to create the props. You can snap to ground nodes to fix it to the surface. Right click will end the sequence.

Manipulation
Rotate prop => Hold the R key and move the mouse cursor.
Resize prop => Hold the Ctrl+X key and move the mouse cursor.
Remove prop => The Delete key will delete the current prop.
Structure and Device Modes
Building structures, and devices (which includes weapons), is the same as in the normal game, with the following additions:

Alt + 0 => Create for Team None (the neutral team)
Alt + 1 => Create for Team 1
Alt + 2 => Create for Team 2
Ctrl + Space => Toggle the simulation
Ctrl + Delete => Delete all structures

Once a joint is selected you can perform operations on the structure connected to that node:

Backspace => Delete selected structure
H => Mirror selected structure horizontally
Ctrl + C => Copy selected structure to clipboard
Ctrl + V => Paste clipboard to mouse position
M (hold) => Move selected structure to mouse position
Changing the Environment
You can change the environmental theme for a map after creation by using the following command in the console (for example):

\set_background alpine

The available environments are currently:
  • alpine
  • canyon
  • desert
  • fields
  • midwest
  • Polluted
  • TrainingGround

You can use a Workshop environment mod in the same way. Just use the published Workshop id of the mod instead of one of the above built-in environments. For example:

\set_background 1308302446

Some props may be broken by this command, if a texture with the same name is not found in the new background.

The Moonshot DLC added several new environments that are hidden within pack files. These can be set in the same way using the names below. Using them will make your map Moonshot dependent, showing a blue icon and requiring the player or host to own the DLC.
  • dlc1_indo
  • dlc1_japan
  • dlc1_newzealand
  • dlc1_oz
  • dlc1_oznight

The High Seas DLC includes a large number of ocean based environments. These are also in pack files, and can be set using the names below. Using them will make your map High Seas dependent, showing a dark blue icon with a yellow anchor, and requiring the player or host to own it.
  • dlc2_oceans_battleskies
  • dlc2_oceans_clear
  • dlc2_oceans_hazy
  • dlc2_oceans_hazystorm
  • dlc2_oceans_island
  • dlc2_oceans_islets
  • dlc2_oceans_oilfields
  • dlc2_oceans_ominousskies
  • dlc2_oceans_rain
  • dlc2_oceans_sepia
  • dlc2_oceans_smokestack
  • dlc2_oceans_storm
  • dlc2_oceans_stormhorizon
  • dlc2_oceans_sunbeam
  • dlc2_oceans_sunset
  • dlc2_oceans_sunsetorange
  • dlc2_oceans_volcano
Setting map details
By default a map will show up in sandbox, skirmish and multiplayer. To show up in skirmish mode, however, you must record at least one AI fort for at least one side - see the section below.

If you want to restrict the map to only certain modes, open the maps mission Lua script and edit the following flags to false as appropriate.

Sandbox = true Skirmish = true Multiplayer = true

You can also give the map a different display name using wide characters by setting the DisplayName value in the displayname.lua script as below. Beware that map names may not display correctly depending on the characters used and the language loaded. Ordinary alpha-numeric characters will always display correctly.

DisplayName = L"Vanilla"

If you want to give the map names for different languages, you can set the variable like below. Supported languages can be found in the data/mods folder with the language- prefix.

DisplayName = { ['English'] = L"Vanilla", ['Chinese'] = L"香草", }

An author and description can be be specified using the following variables. These will show up in the map selection screen.

Author = L"[DEV] BeeMan" DescLine1 = L"A fast and frantic 3v3" DescLine2 = L"There are extra mines in a difficult position"
Supporting Skirmish & Multiplayer
Recording AI Forts

The AI follows a pattern you record while building a fort. To record a new AI fort for a custom map, go to the main menu and select Sandbox. Select the map and start, then follow these steps:

For Co-op (records a script to control all forts)

  1. Left click on a joint owned by the team you want to make the fort for
  2. Make sure nothing is selected by right clicking in space
  3. Drop the console by using the ~ (tilde) key, usually left of the 1 key, or F3
  4. Type \record and hit enter. This will start a new AI fort and assign it an unused number.
  5. Build your fort as you like, in a sensible order.
  6. Quit out of Sandbox

For Team Death Match (records a script to control one fort)

  1. Follow the same instructions except have a joint of the fort you want to build for selected when you type \record.
  2. Set up the FortGroups table in the map's mission script if there is more than one fort configuration. By putting identical forts in the same group they will randomly select their shared AI fort scripts. See Stalactites 4v4 for an example (below). The first parameter to TeamFort is the team, the second is the fort number shown at the top left of each fort in the map editor.

FortGroups = { { TeamFort(1, 1), -- low forts team 1 TeamFort(1, 2), TeamFort(2, 1), -- low forts team 2 TeamFort(2, 2), }, { TeamFort(1, 3), -- high forts team 1 TeamFort(1, 4), TeamFort(2, 3), -- high forts team 2 TeamFort(2, 4), }, }

You can test it by going to Skirmish and putting the player on the other side. Better yet, restart Sandbox, select a joint of the same fort, and enter \build_fort [name] into the console, where [name] is the number or name assigned to the fort on \record. Typically \build_fort 1, if it's the first fort, for example.

Here are some tips for making good AI forts:

  • Build as if you are playing a battle
  • Defend the reactor against AP snipers immediately if necessary
  • Be more defensive than usual (sniper and mg nests early)
  • Try to keep the structure stable at all times
  • Avoid making anything that falls off
  • Put cross braces in low and early
  • There is no time pressure, so don't rush, but...
  • Remember to build enough resource generation
  • Use Ctrl + KeyPadPlus, Ctrl + KeyPadMinus to speed up/slow down time

Supporting Both the Classic Game and Tons of Guns

Tons of Guns is implemented as a mod to the classic game, called weapon_pack. Because of the many differences, we have made the AI fort scripts work only for the mode they were recorded in (classic or Tons of Guns).

If you want the AI to work in both the classic game, and with the Tons of Guns mod enabled, you'll need to record fort scripts with weapon_pack on and off. You can do this by setting or clearing the Tons of Guns mod when entering Sandbox. The game will write RequiredMods = { "weapon_pack" }; into the AI fort script to indicate that it only works when Tons of Guns is enabled.

Map and AI Fort Refinement

Once you have recorded an AI fort, deleting any joints or devices referenced by that fort will cause problems for it. Additions are usually fine, except that new devices can obstruct the AI during play.

If you want to change part of the AI fort after recording you can run it in Sandbox mode by selecting the appropriate team and using \build_fort [name]. [name] is the alphanumeric string given to the recording. This can just be an auto-assigned number (e.g. 1). When you get to the point you want to intervene, use the \record command again and start building where the AI left off. Quit the Sandbox to save the changes. Ctrl+KeyPadPlus/Minus can be used to speed up and slow down time.

Renaming and Deleting AI Forts

When you use the \record command a Lua file will be created or overwritten in the map's folder. If you make a mistake you can delete the files you created, or rename the suffix (the last part of the filename). Using \record with the same name (suffix) will overwite the old file.

As an example, if I use \record in Sandbox with a fort selected, a file such as this will appear when I quit:

fort-t1f1-Ledge Grab-1.lua

The second part tells the game which team it was recorded for, and which specific fort, the third part is the mission name, and the suffix is the script name. This last part can be renamed to something that means something to you, perhaps a description of which weapons it uses:

fort-t1f1-Ledge Grab-2Cannon1Laser.lua

Symmetrical Maps

If your map and structures are pretty much symmetrical, you can make your AI forts mirror automatically. You need to navigate to the data/maps folder and edit the mission lua file in the map's directory. For example maps/data/Vanilla/Vanilla.lua. add the following line:

Symmetrical = true

If you now save the map and it's not symmetrical it will tell you if it's not, and what's causing the problem. You can also use \check_symmetric in the console to do the same without saving. It will list up to 10 differences and highlight all suspect positions briefly.

To make sure ground devices and weapons are symmetrical you can create them all for one side, then select each one and press Ctrl+M to create a mirror for the other side.

Importing Standard Forts and AI fort scripts

Making a variety of AI fort scripts for your unique starting forts can be quite a lot of work. If you do not need or want to design your own, you can use the ones we included with the game. This will give your forts one or more AI patterns in both the classic game, and Tons of Guns. When we add new fort scripts, they'll automatically be used by your map.

This is the process:

  1. Use the \import console command to copy in the prefabricated forts that you want
  2. Set the pasted ground texture to make it conform, if necessary
  3. Arrange the map as usual, copying, moving, mirroring, and changing the team of the imported forts as appropriate. Do not edit the imported forts!
  4. Group the identical forts using the FortGroups table in the mission script (see above)
  5. In each sub-table of the FortGroup table, add the relative paths to the shared AI fort scripts that you want to use

The available forts that can be imported are the subfolders found in the ai/forts folder. Each folder has a preview image of fort's design. For example \import ai/forts/vanilla will paste the common standing fort used in Vanilla 4v4 and many others, plus the surrounding ground. Try not to add ground close to the fort, as this may block the AI as it's building.

An example FortGroup table can be seen below. This is from the Meat Shield 3v3 Workshop map where there are three different standard forts imported in a symmetrical map. You'll notice the path added includes a subdirectory of the fort with a category based on range. There are mid and long categories. This is so, for example, in a long range map you don't have the AI building mortars that can't reach. In mid range maps you can typically add both the mid and long categories, since the weapons in the long forts are still useful at midrange.

FortGroups = { { TeamFort(1, 1), -- ledge forts team 1 TeamFort(2, 1), -- ledge forts team 2 "ai/forts/ledge/long", }, { TeamFort(1, 2), -- hanging forts team 1 TeamFort(2, 2), -- hanging forts team 2 "ai/forts/hanging/long", }, { TeamFort(1, 3), -- vanilla forts team 1 TeamFort(2, 3), -- vanilla forts team 2 "ai/forts/vanilla/long", }, }

Fort Order in Team Death Match

When there are more forts than players in team death match the surplus forts will be deleted. You can determine which by setting up a FortOrder table in the mission script. This basically tells the game which forts to put players and AI into first.

FortOrder = { { 1, 4, 3, 2 }, -- team 1 fort order { 1, 4, 3, 2 }, -- team 2 fort order }
Standard Ships for High Seas
If you would like to use the ships we have built for the High Seas campaign and skirmish maps, you can use the \import console command. For example:

\import mods/dlc2/ai/forts/Battleship

The following paths are accepted:
  • mods/dlc2/ai/forts/Battleship
  • mods/dlc2/ai/forts/Carrier
  • mods/dlc2/ai/forts/DefenceTug
  • mods/dlc2/ai/forts/Dreadnought
  • mods/dlc2/ai/forts/FortMid
  • mods/dlc2/ai/forts/FortShafts
  • mods/dlc2/ai/forts/Gunboat
  • mods/dlc2/ai/forts/MissileShip
You are also able to apply the AI scripts we have made for these, using the following paths within the appropriate FortGroups table.

mods/dlc2/ai/forts/Battleship/long/easy/fort-t1f5-dlc2Template-Battleship-easy.lua mods/dlc2/ai/forts/Battleship/long/fort-t1f5-dlc2Template-Battleship.lua mods/dlc2/ai/forts/Battleship/long/fort-t1f5-dlc2Template-Battleship2.lua mods/dlc2/ai/forts/Battleship/long/fort-t1f5-dlc2Template-Battleship3.lua mods/dlc2/ai/forts/Battleship/runway/fort-t1f1-dlc2 Skirmish 16-1.lua mods/dlc2/ai/forts/Carrier/long/easy/fort-t1f4-dlc2Template-Carrier-easy.lua mods/dlc2/ai/forts/Carrier/long/fort-t1f4-dlc2Template-Carrier.lua mods/dlc2/ai/forts/DefenceTug/long/easy/fort-t1f4-DefenceTug-Easy.lua mods/dlc2/ai/forts/DefenceTug/long/hard/fort-t1f4-DefenceTug-Hard.lua mods/dlc2/ai/forts/DefenceTug/long/normal/fort-t1f4-DefenceTug-Normal.lua mods/dlc2/ai/forts/DefenceTug/mid/fort-t1f2-dlc2Template-DefenceTug.lua mods/dlc2/ai/forts/Dreadnought/long/easy/fort-t1f6-dlc2Template-Dreadnought-easy.lua mods/dlc2/ai/forts/Dreadnought/long/fort-t1f6-dlc2Template-Dreadnought.lua mods/dlc2/ai/forts/FortMid/long/easy/fort-t1f4-dlc2 Skirmish 14-Munitions-easy.lua mods/dlc2/ai/forts/FortMid/long/fort-t1f4-dlc2 Skirmish 14-Factory.lua mods/dlc2/ai/forts/FortMid/long/fort-t1f4-dlc2 Skirmish 14-Munitions.lua mods/dlc2/ai/forts/FortMid/low/easy/fort-t1f2-dlc2Template-firebeam-easy.lua mods/dlc2/ai/forts/FortMid/low/fort-t1f1-dlc2Template-cannon.lua mods/dlc2/ai/forts/FortMid/low/fort-t1f1-dlc2Template-cannon20mm.lua mods/dlc2/ai/forts/FortMid/low/fort-t1f2-dlc2Template-firebeam.lua mods/dlc2/ai/forts/FortShafts/long/easy/fort-t1f1-dlc2 Skirmish 12-DG-easy.lua mods/dlc2/ai/forts/FortShafts/long/fort-t1f1-dlc2 Skirmish 12-DG.lua mods/dlc2/ai/forts/FortShafts/long/fort-t1f1-dlc2 Skirmish 12-OL.lua mods/dlc2/ai/forts/Gunboat/long/easy/fort-t1f3-dlc2Template-Gunboat-easy.lua mods/dlc2/ai/forts/Gunboat/long/fort-t1f3-dlc2Template-Gunboat.lua mods/dlc2/ai/forts/Gunboat/long/fort-t1f4-dlc2Template-20mm.lua mods/dlc2/ai/forts/Gunboat/long/fort-t1f4-dlc2Template-Cannon.lua mods/dlc2/ai/forts/Gunboat/long/fort-t1f4-dlc2Template-Deckgun.lua mods/dlc2/ai/forts/MissileShip/mid/fort-t1f1-dlc2Template-1.lua

These AI scripts can now be randomly selected within a difficulty folder, like this:

FortGroups = { { TeamFort(1, 1), TeamFort(2, 1), { "mods/dlc2/ai/forts/DefenceTug/long/easy", "mods/dlc2/ai/forts/DefenceTug/long/normal", "mods/dlc2/ai/forts/DefenceTug/long/hard", }, }, }
136 Comments
Sceptus Dec 18, 2023 @ 5:42pm 
Under 'Structure and Device Modes' the operation 'Shift + V => Mirror selected structure vertically' is missing
the笑笑 Dec 13, 2023 @ 11:52am 
ai会强制取消拆除钢板
AI will forcibly cancel the dismantling of steel plates
BalllerWithBalls Nov 12, 2023 @ 8:51am 
how do you make it force gravity?
CauseTripod Oct 15, 2023 @ 5:11am 
So the ship movement code example for moving the ship left doesn't work or I am misunderstanding something.
Gamer90006 Jan 27, 2023 @ 7:02am 
@A V.O.I.D Representative there can be only 2 teams
DeltaWing Oct 29, 2022 @ 3:51am 
Is there a way to stop the game from trying to move ships back into position? If not, what's the algorithm so I can make one that perfectly counters it?
Red Commando Oct 28, 2022 @ 7:43pm 
it will not let me change the order of the props, it is stuck in foreground, i am pressing control plus comma and control plus period
A V.O.I.D Representative Oct 16, 2022 @ 11:44am 
how do you make the bases have dif teams. every time i try to do it, it just ends up making side 2 side 1
Sam Aug 14, 2022 @ 3:59pm 
NoNoinAction you have to set it to Coop. no problems with your modding :)
NoNoInAction Jul 28, 2022 @ 12:50pm 
I'm trying to make a 1v1 Map but both player have two forts (both of the forts have an own Core) can i somehow connect the two forts? because right now when I start the Map half of the Forts are missing because they got no players assigned to them.