Skip to main content

Building a New World

What it takes to load a world Far Cry 2 does not ship, reached by console, portal or menu. This page lists every file a world is made of, says which ones the tools can read, write and generate, and lays out the steps to a player standing in a new world, with props and soldiers in it.

A new world has been loaded in game (proven): DevTools' test range builds testrange, tmpla's flat plain under a new name with cover walls and a generated navmesh, and soldiers spawned there move and fight. It is the worked example for the sections below.

JackAll does every step on this page: New map on the Map tab or jackall-cli world new makes the files, the map editor places objects, and jackall-cli world pack builds the sector files, the entity library, the sector flags and the navmesh. See Make a new world. A script for two smaller experiments, a renamed clone and a one-sector tile, is in the history as mods/new-world, since removed; neither was loaded. The test sheet has the commands for the test range.

Marks: (proven) seen in a running game; (RE-verified) read in FarCry2_server's code; (seen in data) read in the retail files; (inferred); (untested). The mechanism is in entering a world.

What is still missing​

No tool or format is missing for a world built from tmpla, the editor's template. It is flat, empty and complete (tmpla). Two questions stood before the first launch:

  1. Does the engine load a single-player world it does not ship? Nothing enumerates or whitelists worlds (RE-verified). Yes (proven): testrange, tmpla's 8 × 8 grid under a new name, loads by travel and the player arrives standing on its ground (DevTools' test range).
  2. Is a one-sector grid enough? CWorld::Create checks no minimum (RE-verified), but nothing after it was read.

Where the player lands is settled, and it follows world 2, not world 1 (where the player arrives, RE-verified):

  • A new game in world 1 spawns the player at the spawn point marked bWorldStart, moved down to the ground.
  • Travel, which is how world 2 is entered, spawns the player at the named spawn point's stored position, with no ground snap.

Both retail start points are stored at ground level: 3 cm and 62 cm above the terrain under them. So a new world reached by travel needs a spawn point placed on its ground. newworld_tile's is 44 cm above. tmpla's only spawn point sits 16 m below its ground, so travel there puts the player under the terrain.

Anything beyond a flat world with props and soldiers runs into gaps that do have names: terrain heights cannot be generated. See the checklist.

Every file a world is made of​

Needed says what CXGame::LoadWorld does without the file (what the loader requires).

  • Read and Write refer to JackAll codecs.
  • Generate means making the file for a new world without starting from a retail copy.
  • "via XML" means hand-written XML that JackAll encodes. Nothing builds those files from parameters.
  • Tile is where the one-sector test world, newworld_tile, takes the file from.

The world: worlds\<w>\​

FileWhat it holdsNeededReadWriteGenerateTile
generated\<w>.game.xmlthe grid, the level windows into it, environment presets, terrain layer table, missionsyes: no descriptor, no load✓ rml decode, or plain text✓by editing a template, as the editor's own ExportWorld doestmpla's, with the map name and grid edited
generated\<w>.mapsdata.fcbspawn points, road, river and path splines, map markersyes: opened with no null check✓ fcb, WorldSplines✓via XML; spline bounds and arc tables are not recomputed (splines)tmpla's: group renamed, spawn point raised to 16.5 m
generated\entitylibrary.fcbevery archetype the world can spawn, the player includedloaded regardless; an empty library has no archetypes✓✓✗ copy onlytmpla's, the same file as ige_map's
generated\<w>.managers.fcbworld managersskipped if absent✓✓✗ copy onlytmpla's
generated\<w>.omnis.fcbomnipresent entities, including the master Domino graphskipped if absent✓✓via XMLtmpla's, empty
generated\<w>.sectorsdep.fcbper sector: has a descriptor, detail mask, accessible, and which of the sector's files the game loadsskipped if absent✓✓via XMLtmpla's, cut to sector 0
generated\<w>_depload.datresource dependency tree for streamingskipped if absent✓✓✓ depload addtmpla's
generated\<w>_deploadnewparticles.rmlparticle dependenciesnot traced✓✓✗tmpla's
generated\moviedata.xmlcinematicsnot establishedtexttexttexttmpla's
generated\nv\sectors\nv.nvmnavmesh grid and extent declaration (.nvm)not traceddocumented, no reader✗✓ the header is fixed; the script writes a 1 × 1 onewritten for 1 × 1, 108 bytes
mapcompass.xbt, _mip0the world map texturenot traced✓✓✓ xbt build; the _mip0 companion is not madetmpla's

Each level: levels\<l>\​

A level is one window of the grid named by a Map element in the descriptor. A small world has one level, named after the world.

FileWhat it holdsNeededReadWriteGenerateTile
mapcompass.xbt, _mip0the area mapnot traced✓✓✓ xbt buildtmpla's
generated\moviedata.xmlcinematicsnot establishedtexttexttexttmpla's

Each sector: levels\<l>\generated\​

FileWhat it holdsNeededReadWriteGenerateTile
sdat\sd<n>.sdatterrain: 65 × 65 heights, normals, holes, surface types, LOD tables (.sdat)campaign worlds lack some✓ SdatSectorFile✓ Encode, used only by tests✗ the mask tables, normals and bounds are not derivedtmpla's sd0, flat at 16.06 m, unchanged
sdat\sd<n>_shadow.xbtbaked sun shadownot traced✓✓✓ from a DDStmpla's
sdat\atlas<a>_{diffuse,mask,color}.xbtterrain textures for a 2 × 2 block of sectorsfalls back to sector-named files✓✓✓ from a DDStmpla's atlas0
worldsectors\sector<n>.desc.fcbdetail texture mask, the list of other sectors with flags, terrain-detail resourcesnot traced✓ SectorDetailLayers✓via XMLtmpla's, with the other sectors removed from its list
worldsectors\sector<n>.srlsound regions: 32 × 32 bytes (.srl/.zsr)not traced✗✗trivial: fixed-size, no headertmpla's
worldsectors\zonesector<n>.zsrzones, 64 × 64 bytesnot traced✗✗trivialtmpla's
worldsectors\worldsector<n>.data.fcbentities by mission layerno: tmpla ships none. Loaded only where sectorsdep sets HasMainSectorData✓ WorldLoader✓ Map tab, fragments onto a retail filevia XML (placing entities) or the Map tabnone
worldsectors\landmarkfar_<n>.data.fcbvegetation (VegetationData): RealTrees, some rocks; far LODno: tmpla ships none. Loaded only where sectorsdep sets HasLandmarkFar✓ decoded (vegetation)✓ VegetationZone✓ world pack: the trees of a vegetation plan, flag includednone
worldsectors\landmarknear<n>.data.fcbvegetation too, a near light-vegetation grid, some mission contentno. Loaded only where sectorsdep sets HasLandmarkNear✓✓ VegetationZone✓ world pack: the grass and meshes of a vegetation plan, flag includednone
nv\sectors\nv_<n>.nvmnavmesh for AIno, but AI crashes without it. Loaded only where sectorsdep sets HasNavMesh✓ NvmSector✓ NvmSector✓ navmesh build, any terrain and collision (AI in a new world)none, so no AI
sector<n>.preload_x.fcb, beside generated\streaming preload, campaign levels onlyno✓✓✗none

Other parts of a world live elsewhere:

  • Environment (sky, fog, light, wind) is a set of preset GUIDs in the descriptor's Environment element (environment presets).
  • Roads are splines in mapsdata.fcb.
  • Missions are three things: MissionsDef in the descriptor, mission layers inside the .fcb files, and Domino graphs, which are plain Lua in patch.dat (authoring a mission).
  • Streaming comes from the depload files, sectorsdep.fcb, the preload files and the landmark LODs. Its rings are set in the engine config, not per world.

Which sector files the game loads​

A sector's own files are not looked for on disk. Each entry of <w>.sectorsdep.fcb carries one boolean per optional file, and the game requests only the files whose boolean is set. The file names below are under levels\<l>\generated\.

FlagFile it loadsHow it is known
HasMainSectorDataworldsectors\worldsector<n>.data.fcb, the entitiesseen in data: in mp_16_airbase the 30 flagged sectors are exactly the 30 files. Without it, testrange's walls never appeared (proven)
HasLandmarkNearworldsectors\landmarknear<n>.data.fcbseen in data: 43 flags, the 43 files
HasLandmarkFarworldsectors\landmarkfar_<n>.data.fcbseen in data: 99 flags, the 99 files
HasNavMeshnv\sectors\nv_<n>.nvmRE-verified and proven (how the game finds a sector file)

tmpla sets none of the four, because it ships none of those files. So every file a new world adds to a sector needs its flag added to that sector's entry, or the file is silently ignored. A flag is one more child of the entry, written as retail writes it:

<object type="CWorldSector">
<value name="SectorId" type="Int32">28</value>
<value name="HasDescriptor" type="Bool">True</value>
<value name="HasMainSectorData" type="Bool">True</value>
<value name="DetailMask" type="Int32">268435455</value>
<value name="isSectorAccessible" type="Bool">True</value>
<value name="HasNavMesh" type="Bool">True</value>
</object>

None of these files is listed in a depload. The flags are the only thing that makes the game stream them.

Placing entities in a new world​

A new world's sectors have no retail worldsector<n>.data.fcb to start from, so a mod fragment, the way adding an NPC places one, has nothing to merge onto. mod build merges a fragment only into a file some archive already provides. Write the whole file instead, then set HasMainSectorData on its sector.

The smallest file is a sector header and a main mission layer, which is always on:

<object type="WorldSector">
<value name="Id" type="UInt32">28</value>
<value name="X" type="UInt32">4</value>
<value name="Y" type="UInt32">3</value>
<object type="MissionLayer">
<value name="text_PathId" type="String">main</value>
<value name="PathId" type="Hash">BF28CD64</value>
<!-- Entity nodes go here -->
</object>
</object>
  • Which sector: an entity belongs to the sector its position falls in. With 64 m sectors and a grid side sectors wide, X = floor(x / 64), Y = floor(y / 64) and Id = X + side × Y.
  • The entity: copy a retail instance of the archetype you want. A placed prop is a tplCreatureType naming the archetype, plus whatever the instance overrides. Give it:
    • a new hidName
    • a new disEntityId, unique in the world
    • hidPos and hidPos_precise, both global, with z on the ground
    • the yaw in degrees as hidAngles' z
  • Collision comes with the archetype. testrange's walls are copies of CoverObjects.WallBarrier01_BK.Multi_0 from mp_16_airbase and CoverObjects.WallEroded10_BK.Multi_0 from mp_07_m_dogon.
  • Encode the XML with jackall-cli fcb encode.

mods\DevTools\range\build-layer.ps1 does all of this for the range's walls, and they stand in the game where they were placed (proven).

Place entities before generating the navmesh, so the navmesh is cut around them.

AI in a new world​

AI needs a navmesh, and retail Dunia.dll carries no generator of its own: the editor's CNavmeshGenerator survives only in FarCry2_server. JackAll writes one instead:

jackall-cli navmesh build <layer>\mods --level <l>

It writes nv\sectors\nv_<n>.nvm for every sector of the level and sets HasNavMesh on every sector's entry. The mesh lies on the terrain and on every walkable face of the placed entities' collision: floors, roofs, ramps, stairs and bridges. It leaves out slopes over 45°, steps over 0.3 m and anything with less than 1.6 m of headroom. It lays cover points along walls and props, and gives water its own floor for boats. The world's own nv.nvm index can stay as tmpla's, its grid and extent edited to match. The method and how it compares with retail are in generating a navmesh.

(proven) In testrange, soldiers spawned at run time move and shoot on the earlier, flat-only generator's navmesh. In editor maps with no navmesh, AI crashed the engine about 30 s after loading.

Ground off the terrain that nothing could reach is dropped, such as a rooftop or the top of a rock. Place a soldier, an animal or a smart-terrain point on it to keep it.

Soldiers can be placed as entities like any prop, or spawned at run time with SpawnEntityFromArchetype. DevTools' Spawner tab spawns a squad of either faction, or of Ubisoft's enemy_archetypes.MercTest test soldiers, in front of the player.

The entity library​

A world's archetypes come from its own generated\entitylibrary.fcb. tmpla's is the same file as the editor's ige_map's: a superset of world 1's archetypes. It has every soldier class of both factions and the MercTest soldiers, which world 1's lacks.

A mod's archetype edits target a path, usually worlds\world1\generated\entitylibrary.fcb, so they do not reach a new world's library (inferred). A world built on tmpla's library plays plugin-only mods unchanged, but not, for example, a mod that ships weapon data as archetype edits.

The smallest world​

newworld_tile is one 64 m sector of flat ground at 16.0625 m. It has no entities except SpawnPoint_0 at (28, 32, 16.5), and no AI. It takes 23 files: everything is tmpla's, renamed, and five are edited:

FileChange
newworld_tile.game.xmlGridMapSectors and the one Map set to 1 × 1; the map renamed to Levels\newworld_tile\newworld_tile.nomad
newworld_tile.mapsdata.fcbthe map's group renamed from tmpla; the spawn point's z set to 16.5
newworld_tile.sectorsdep.fcbthe group renamed; sector 0 kept
nv\sectors\nv.nvmextent 64, grid 1 × 1, one sector
sector0.desc.fcbthe other 63 sectors removed from its list (untested guess)

The engine finds a map's group in mapsdata and sectorsdep by the map's name, hashed as CRC32 like every FCB name (newworld_tile is D748CFA2). That is why the groups are renamed.

The layer also holds newworld_clone, which is tmpla renamed and nothing else: its spawn point stays at z 0. It tells "a name the engine has never seen" apart from "content it has never seen".

The plan​

Step 1: travel to tmpla​

No files. tmpla ships a complete world and level tree, so this tests only whether single-player loads a world the campaign never visits. Use world 2 as the control: it is known to load. Both commands name a spawn point.

Success: a loading screen, and the game still running a minute later. The player arrives at z 0, 16 m under the flat plain: expect to fall or be stuck under it. DevTools' noclip lifts them out to see the plain.

Step 2: the same world under a new name​

newworld_clone. Success: exactly what step 1 showed. A failure here, after step 1 worked, means the engine knows its worlds by name somewhere this research has not read.

Step 3: one sector, standing on it​

newworld_tile. Success: the player stands on flat ground with a 64 m square of terrain around them, and the game keeps running. This is the goal state. If step 2 works and this one does not, the cause is the grid size or the descriptor edit. Rebuild with sector0.desc.fcb left as it was to tell which.

Step 4: back to world 1​

#GameChangeWorld("world1", "2056971616016942572"), which is OpeningSequence_SpawnPoint, the only world 1 spawn point marked as a world start. Success: world 1 with the player's state intact.

Step 5: save and load inside the new world​

A save stores the world's name as a string (savegame), but LoadState also holds a "world1" literal. Save in newworld_tile, quit to the menu, load. (untested)

Step 6: reach it without the console​

  • A portal is data and a script. Put a trigger entity in world 1 and add a Domino graph that runs the stock ProximityTrigger box into a ChangeWorld box with World and SpawnPoint set, as master_world1 does for world 2. The bus stations are the retail pattern for a trigger you choose to use (interactive objects). The way back is a Domino omni entity in the new world's omnis.fcb, the way the campaign attaches its master graph (campaign).
  • A menu entry needs code. The New Game button hardcodes "world1" in CFCXStoryAvatarSelectionPage::LaunchGame. A plugin could route a new Magma button through the same travel call, or DevTools could gain a launch option alongside its -load.

Step 7: own content​

In order of what is ready:

  • Entities and props: whole worldsector files plus their HasMainSectorData flag (placing entities). The Map tab edits them once they exist.
  • Textures and map art: xbt build.
  • Terrain heights: SdatSectorFile.Encode can write a sector. A flat sector's tables can be reused, but real relief needs its normals, LOD masks and bounds derived, and nothing does that yet. Sector edges are shared, so neighbouring sectors must agree.
  • Vegetation: a vegetation plan, which world pack grows into each sector's landmarknear file.
  • Roads: need the spline bounds and arc tables recomputed.
  • AI: jackall-cli navmesh build (AI in a new world).

The test sheet​

The script reads the extracted retail worlds archive in tmp\gamefiles\worlds\worlds, and the layer is not committed. mod build replaces the whole patch, so build in every layer the install already carries, with this one after them:

.\mods\DevTools\range\build-layer.ps1
tools\JackAll\src\JackAll.Cli\bin\Release\net10.0\jackall-cli.exe mod build --game "C:\Games\Far Cry 2" --layer <installed layers> --layer mods\DevTools\layer

The build was checked against a scratch copy of the vanilla patch archive: 406 entries added, none overridden. The descriptor reads back byte-identical from its path hash. Nothing was built into the install.

Each run is one launch. Load a world 1 save, press ~, and enter the line:

RunConsole lineLook for
1, control#GameChangeWorld("world2", "2051908267268899174")world 2 at its act 2 start
2#GameChangeWorld("tmpla", "2054037628277228842")a load, with the player 16 m under a flat plain; noclip up to see it
3#GameChangeWorld("testrange", "2054037628277228842")standing on a plain, cover walls around you; spawned soldiers fight. Seen

DevTools' Change world command takes the same two arguments.

After each run, bin\fcse.log holds what the plugins saw. A crash or a hang on the loading screen is a result: note at which run it happened.

If run 1 does nothing, the Lua binding may not take the id as a string from the console, though the ChangeWorld box passes it that way. Try #GameChangeWorldDefaultSpawnPoint("world2") to see whether the call itself works.

To go back, build the installed layers alone.

Open questions​

  • What does the engine do with a player spawned under the terrain: fall forever, or stand on nothing? Run 2 shows it.
  • Is a one-sector grid accepted past CWorld::Create? The streaming rings clamp to the world, sound sets up a 32 × 32 cell grid per sector, and CAIEngine::LevelLoaded was not read.
  • Was emptying the sector descriptor's list right, and what is its leading value (123, member 56F4F69B)?
  • tmpla's managers come from the editor's template. They are enough for soldiers to fight (proven). Does the single-player game need managers they lack, such as weather or the economy?
  • JackAll writes mapsdata.fcb 47 bytes longer than retail, because it does not share repeated objects. It decodes identically. Mod fragments are written the same way.
  • Saving and loading inside a new world (step 5).