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.
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#
| File | Holds |
|---|---|
Info/<map>.desc | XML: the name, the briefing, the loading music and the game modes with their sizes (<maptype players="16">) |
server.zip / Init.con | the entry point: runs the other scripts, then sets teams and kits |
Heightdata.con, Heightmap*.raw | the 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.con | the terrain renderer setup (patch size, colour / detail / light map names) |
StaticObjects.con | run lines for every static object's template, then Object.create + position lines for each placed building and prop |
Water.con, Sky.con, Sounds.con | water colour and fog, sky and sun, ambient sounds |
CompiledRoads.con, Overgrowth/, UndergrowthAtlas.tai | roads (decals), trees and grass |
AIPathFinding/ | bot navigation meshes (.qtr, .clb) per vehicle class |
gamemodes/<mode>/<size>/GamePlayObjects.con | control points, spawn points, vehicle spawners, combat areas for one mode and size |
client.zip | colour maps, detail maps, light maps, the minimap: what only the client needs |
Init.con#
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#
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.rawThe 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#
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.8These 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:
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.000Game 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:
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 (
setSpawnPositionOffsetlifts them off the ground). - An ObjectSpawner creates a vehicle per team (
setObjectTemplate <team> <template>) and respawns it afterminSpawnDelay..maxSpawnDelayseconds. - 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 aregpm_cq,gpm_ctf,gpm_cdm,gpm_hothand 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):
| Crate | What it is |
|---|---|
crates/bf2-editor | PROGRAM bf2_editor: the web editor's engine host (wasm for the page, native for tests) |
crates/bf2-render | the wgpu renderer |
crates/bf2-terrain | terrain and level data formats |
docs/dev/levels/authoring.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.