BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

Level authoring

A level is a folder of CON scripts and binary maps. This page walks through Battlefield 2's Strike at Karkand to show what each file does, so you can read, change or build one.

BF22142Heroes
A level editor is coming later

The original games were built with DICE's BF2Editor; its output is what you see here (the files start with rem *** Generated by BF2Editor ***). A bf2-rs level editor for all three games is a planned milestone: this page documents the format it will read and write. Until then, levels are edited by hand or with community tools. The file-by-file format matrix and the editor's plan are on Level editor plan.

The folder#

levels/<map>/server.zip Init.con entry point Heightdata.con heightmap cluster HeightmapPrimary.raw Terrain.con terrain setup StaticObjects.con buildings, props Water.con, Sky.con, Sounds.con CompiledRoads.con, Overgrowth/ AIPathFinding/ bot navigation gamemodes/gpm_cq/16|32|64/ GamePlayObjects.con what the server (and client) simulate levels/<map>/client.zip Colormaps/, Detailmaps/ Lightmaps/ (terrain, objects) terraindata.raw, Envmaps/ Hud/ minimap what only the client draws levels/<map>/Info/ <map>.desc modes, sizes, music *_menuMap.png, loadmap.png what the menus show Load order (Init.con) 1 run Heightdata.con 2 run Terrain.con 3 run Sky.con, Sounds.con 4 run CompiledRoads.con 5 Undergrowth / Overgrowth 6 run Water.con 7 gameLogic.setTeamName, setKit, ... 8 the game mode's GamePlayObjects.con
levels/<map>/: server.zip (logic), client.zip (looks), Info/ (menus), and the order Init.con loads them in.
FileHolds
Info/<map>.descXML: the name, the briefing, the loading music and the game modes with their sizes (<maptype players="16">)
server.zip / Init.conthe entry point: runs the other scripts, then sets teams and kits
Heightdata.con, Heightmap*.rawthe terrain heights: a cluster of a primary heightmap (BF2: 513 x 513, 16 bit, 2 m per sample) and lower-detail secondary maps around it
Terrain.conthe terrain renderer setup (patch size, colour / detail / light map names)
StaticObjects.conrun lines for every static object's template, then Object.create + position lines for each placed building and prop
Water.con, Sky.con, Sounds.conwater colour and fog, sky and sun, ambient sounds
CompiledRoads.con, Overgrowth/, UndergrowthAtlas.tairoads (decals), trees and grass
AIPathFinding/bot navigation meshes (.qtr, .clb) per vehicle class
gamemodes/<mode>/<size>/GamePlayObjects.concontrol points, spawn points, vehicle spawners, combat areas for one mode and size
client.zipcolour maps, detail maps, light maps, the minimap: what only the client needs

Init.con#

Init.con (shipped, Strike at Karkand, abridged)
if v_arg1 == BF2Editor
  rem ... the editor's own load path ...
else
run Heightdata.con
run Terrain.con v_arg2
run Sky.con v_arg2
run CompiledRoads.con
run Sounds.con
Undergrowth.load Levels\Strike_at_Karkand\
run Overgrowth/Overgrowth.con
run AmbientObjects.con
run Water.con
endIf

gameLogic.setTeamName 1 "MEC"
gameLogic.setTeamName 2 "US"
gameLogic.setKit 1 0 "MEC_Specops" "mec_light_soldier"
gameLogic.setKit 2 0 "US_Specops" "us_light_soldier"

gameLogic.setKit <team> <slot> <kit template> <soldier template> decides what each team can pick; this is where a new kit becomes available (add a weapon).

Terrain#

Heightdata.con (shipped, first lines)
heightmapcluster.create HeighmapCluster
heightmapcluster.setClusterSize 3
heightmapcluster.setHeightmapSize 1024
heightmapcluster.addHeightmap Heightmap 0 0
heightmap.setSize 513 513
heightmap.setScale 2/0.00457764/2
heightmap.setBitResolution 16
heightmap.loadHeightData Levels/Strike_at_Karkand/HeightmapPrimary.raw

The primary map's setScale x/y/z is metres per sample horizontally and the height of one raw unit (16-bit samples x 0.00457764 m gives 0-300 m). The eight secondary maps (HeightmapSecondary_L1U1.raw ...) extend the world beyond the playable area at a coarser scale. bf2-rs reads them in crates/bf2-terrain (notes/formats/terrain.md).

Water#

Water.con (shipped)
renderer.waterScroll 0.1/0.1
renderer.waterColor 0.254902/0.180392/0.027451
renderer.waterFogStartEndAndBase 10.00/250.00/1.00/0.50
terrain.waterSunIntensity 0.8

These lines set how the water looks (scroll, colour, specular, fog).

Static objects#

StaticObjects.con first runs the .con of every template it uses, then places instances:

the pattern (positions are examples)
run /objects/staticobjects/_middle-east/city/city_architecture/gas_station/gas_station.con
Object.create gas_station
Object.absolutePosition -146.453/161.298/-268.604
Object.rotation 0.000/0.000/0.000

Game modes: control points, spawns, vehicles#

Each mode and size has its own GamePlayObjects.con. It creates templates local to the level (spawners, spawn points, control points) and places them, tying everything to a control point id:

GamePlayObjects.con (shipped, gpm_cq 16, abridged)
ObjectTemplate.create ObjectSpawner CPNAME_SK_16_gasstation_Jeep
ObjectTemplate.setObjectTemplate 1 JEP_VODNIK
ObjectTemplate.setObjectTemplate 2 USJEP_HMMWV
Object.create CPNAME_SK_16_gasstation_Jeep
Object.absolutePosition -133.487/161.298/-291.850
Object.setControlPointId 45

ObjectTemplate.create SpawnPoint CPNAME_SK_16_hotel_1
ObjectTemplate.setSpawnPositionOffset 0/1.25/0
ObjectTemplate.setControlPointId 27
Object.create CPNAME_SK_16_hotel_1
Object.absolutePosition -189.879/155.901/26.337
  • A ControlPoint object has a team, a capture radius and an id; spawn points and spawners follow its owner.
  • A SpawnPoint is where soldiers appear (setSpawnPositionOffset lifts them off the ground).
  • An ObjectSpawner creates a vehicle per team (setObjectTemplate <team> <template>) and respawns it after minSpawnDelay..maxSpawnDelay seconds.
  • Combat areas outline where each team may go before the out-of-bounds timer starts.

What a spawner's vehicle is made of (its template tree, mesh, collision mesh, textures and sounds) is shown with the Heroes village jeep on What goes into an object; the level on one screen is What goes into a level.

The rules of the mode itself (tickets, bleed, capture scoring) are Python: game/gamemodes/gpm_cq.py, see the Python layer.

Running a level in bf2-rs#

Add it to a server's map list (mapList.append <folder name> gpm_cq 16) and start the server (the codebase). The server loads server.zip; the client loads both archives. The bf2-rs level viewer (level_viewer in crates/bf2-render) shows a level without a server.

Per game#

  • 2142 levels have the same layout; Titan mode adds Titan and silo objects, and spawns can be pods.
  • Heroes levels live under mods/bfheroes/levels/ with the same files; their game modes are gpm_cq, gpm_ctf, gpm_cdm, gpm_hoth and the tutorial (notes/bfheroes/levels.md).

How it is tested#

  • What the editor writes is what the game reads: the editor's test programs save a level and read it back through the game's own readers (crates/bf2-editor/tests), and export a package whose baked light maps the renderer loads.
  • The terrain's formats are rebuilt byte for byte from their sources (terrain).
  • A level in play: scenarios start a server and a client on a level; a level that does not load fails them.

The steps on this page were followed by hand when it was written.

In the code#

The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):

CrateWhat it is
crates/bf2-editorPROGRAM bf2_editor: the web editor's engine host (wasm for the page, native for tests)
crates/bf2-renderthe wgpu renderer
crates/bf2-terrainterrain and level data formats
Source: docs/dev/levels/authoring.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.