Skip to main content

Convert game files on the command line

Most of jackall-cli turns one of Far Cry 2's file formats into something you can edit, and back. The usual chain is: pull a file out of an archive, decode it, change it, encode it again, and put the result in a mod layer at the file's own game path under mods\. Then build the layer like any other mod (Manage mods from the command line).

The format commands work on loose files, so only the ones that take --game need the game installed. Below, game\ holds files pulled out of the install with the first command, and the output is what each command printed.

Nothing to confirm in game

These commands convert files. What a changed file does in game depends on the change.

Archives​

The game's files sit in .fat/.dat pairs under Data_Win32, such as common.fat, worlds\worlds.fat and sound.fat. archive extract unpacks one. --names turns the archive's hashes back into paths, and --filter keeps only the entries whose path contains a piece of text:

> jackall-cli archive extract "C:\Games\Far Cry 2\Data_Win32\worlds\worlds.fat" --names --filter ak47.xbg --out-dir game
Extracted 1 file(s) into game

The Files tab finds a file across every archive at once; see Finding any file.

Models​

xbg export writes a model's geometry as a Wavefront .obj, the most detailed LOD unless you pass --lod or --all-lods:

> jackall-cli xbg export game\graphics\weapons\primary\ak47\ak47.xbg --out ak47.obj
Wrote ak47.obj

To change a model, use a .fc2model pack and the Blender add-on; see Edit a model in Blender. fc2model export makes a pack from a game path, and fc2model inspect lists what a pack holds and what has been changed in it:

> jackall-cli fc2model inspect ak47-longer-mag.fc2model
graphics\weapons\primary\ak47\ak47.xbg
┌──────────┬────────┬─────────┬────────────────────────────────────────────────┐
│ kind │ role │ changed │ path │
├──────────┼────────┼─────────┼────────────────────────────────────────────────┤
│ mesh │ owned │ yes │ graphics\weapons\primary\ak47\ak47.xbg │
│ material │ shared │ │ GRAPHICS\_MATERIALS\SDORE2-M-2007073066669286. │
│ │ │ │ xbm │
│ texture │ shared │ │ graphics\weapons\special\m249saw\m249_bullet_m │
│ │ │ │ .xbt │
…
│ rig │ owned │ │ graphics\weapons\primary\ak47\ak47_ref.skeleto │
│ │ │ │ n │
└──────────┴────────┴─────────┴────────────────────────────────────────────────┘

fc2model extract writes the changed files out as a mod layer:

> jackall-cli fc2model extract ak47-longer-mag.fc2model --out ak47-longer-mag
Wrote 1 file(s) under ak47-longer-mag

Materials​

xbm show prints a material's shader and every property, as text the other commands take back. xbm new writes a new material, a copy of another under a new name or empty on a shader; xbm set sets and removes properties, checked against the shader; xbm lint reports what the game would silently ignore:

> jackall-cli xbm new body.xbm --name AK47_BODY --from game\graphics\_materials\jpcormier-m-2007100950589039.xbm
Wrote body.xbm
> jackall-cli xbm set body.xbm SpecularPower=150 "DiffuseColor1=0.2" -g "C:\Games\Far Cry 2"
set SpecularPower = 150
set DiffuseColor1 = 0.2, 0.2, 0.2
set DiffuseColor1Clean = 0.2, 0.2, 0.2
Wrote body.xbm
> jackall-cli xbm lint body.xbm -g "C:\Games\Far Cry 2"
ok body.xbm

A single number fills every component of a colour. On a weapon or a vehicle, setting a colour also sets its Clean twin, which is what the game shows; --no-link sets the colour alone.

To draw a model with a new material, add it to the model's pack and move the clusters of a part onto it. inspect --materials lists the materials by index:

> jackall-cli fc2model add-material ak47.fc2model graphics\weapons\primary\ak47\ak47_body.xbm --from GRAPHICS\_MATERIALS\JPCORMIER-M-2007100950589039.xbm --name AK47_BODY
Added graphics\weapons\primary\ak47\ak47_body.xbm as material 3. Move clusters onto it with assign-material.
> jackall-cli fc2model assign-material ak47.fc2model --from 1 --to 3 --part FRAME
Moved 5 cluster(s).

--part FRAME covers the part at every level of detail and damage state. fc2model extract then writes both the mesh and the new material.

Textures​

xbt extract splits a texture into a .dds image and an .xml header; xbt build puts an edited .dds back together with that header:

> jackall-cli xbt extract game\graphics\weapons\primary\ak47\ak47_state01_m.xbt --out-dir texture
Wrote texture\ak47_state01_m.dds
Wrote texture\ak47_state01_m.xml

> jackall-cli xbt build texture\ak47_state01_m.dds --out ak47_state01_m.xbt
Wrote ak47_state01_m.xbt

Without a header next to the .dds, xbt build writes a new one, and the .dds must then carry its whole mip chain. See Replace a texture and Texturing a weapon.

Music and sound banks​

Music and speech are .sbao files around an Ogg Vorbis stream. sbao build doesn't convert audio, so the replacement must already be .ogg:

> jackall-cli sbao extract game\soundbinary\004b177b.sbao --out-dir music
Wrote music\004b177b.ogg
Wrote music\004b177b.sbaoheader

> jackall-cli sbao build music\004b177b.ogg --out 004b177b.sbao
Wrote 004b177b.sbao

Sound effects are .spk banks. spk list shows what a bank holds, spk decode writes it as XML with its audio beside it, spk encode builds the XML back into a bank, and spk verify checks that a bank rebuilds unchanged:

> jackall-cli spk list game\soundbinary\004bf5e9.spk
004bf5e9.spk — 3 record(s)
0x004bf5e9 Sound event -> 0x004bf5f1
0x004bf5f1 Sample -> audio 0x004bf5f3 - 44100 Hz
0x004bf5f3 Audio Stereo - 44100 Hz - IMA-ADPCM - 9.5 KB

> jackall-cli spk decode game\soundbinary\004bf5e9.spk --out bank
Wrote bank\004bf5e9.xml

> jackall-cli spk encode bank\004bf5e9.xml --out 004bf5e9.spk
Wrote 004bf5e9.spk

> jackall-cli spk verify 004bf5e9.spk
OK - 004bf5e9.spk rebuilds byte for byte

spk import replaces one record's audio in place, and spk new starts a bank from your own .wav or .ogg files. spk label --game <dir> writes the sound labels the Files tab shows, one tab-separated line per bank: path, category, detail, how it was found (usage, linked, folder or hand) and the files naming it. --hand <file> merges labels written by hand in the same columns; they replace found labels, and every hand row already in the output is kept when you run it again. See Replace music and speech, Replace a sound effect and Editing sound banks.

Game data and text​

.fcb files hold the game's objects and values: entity libraries, world sectors, and more. fcb decode writes one as XML and fcb encode builds it back:

> jackall-cli fcb decode game\levels\w1_c_3\generated\worldsectors\worldsector3160.data.fcb --out worldsector3160.xml
Wrote worldsector3160.xml

> jackall-cli fcb encode worldsector3160.xml --out worldsector3160.data.fcb
Wrote worldsector3160.data.fcb

A whole .fcb in a mod replaces every other mod's copy of the same file instead of merging with them. The app saves a change as a fragment of the file, which merges; see The value editor in depth.

rml decode and rml encode do the same for .rml documents, such as the game's text in languages\<language>\oasisstrings.rml. A mod shouldn't ship that whole table, though. After you change strings in the XML and encode it again, rml fragments compares it with the game's own table and writes only the strings you changed, as the oasisstrings.fragment.xml a mod stages. Here the AK-47 is renamed:

> jackall-cli rml decode game\languages\english\oasisstrings.rml --out oasisstrings.xml
Wrote oasisstrings.xml

> jackall-cli rml encode oasisstrings.xml --out oasisstrings-drum.rml
Wrote oasisstrings-drum.rml

> jackall-cli rml fragments oasisstrings-drum.rml --base game\languages\english\oasisstrings.rml
oasisstrings-drum.rml: 2 string(s) differ from vanilla, in 2 section(s)
Challenges;ak47 AK-47 Drum
Items;ak47 AK-47 Drum
wrote 2 edit(s) (210 B) to oasisstrings.fragment.xml
stage it as mods\languages\<language>\oasisstrings.fragment.xml

Rename a weapon writes the same file by hand.

.mgb files are the HUD and menus. mgb decode writes one as XML and mgb encode builds it back. mgb verify checks a package, and mgb fragments writes only the parts that differ from the game's own, for a mod to ship:

> jackall-cli mgb decode game\ui\localized\pc\eng\ui\hud.mgb --out hud.xml
Wrote hud.xml

> jackall-cli mgb verify hud.xml
hud.xml: MAGMA v0x1EAB90, 166 type-table entries, page 1024x768, 69 material(s), 0/0/0 font records, 107 area(s), 190,532 bytes
OK - 699 local reference(s) resolve

> jackall-cli mgb fragments hud.xml --base game\ui\localized\pc\eng\ui\hud.mgb --list
hud.xml: 110 units, 0 differ from vanilla (0 new)
nothing to stage - this file matches the base

See Edit the HUD and menus.

Fonts​

The game's fonts are .mft files under ui\fonts\, each with pages of drawn glyphs beside it. mft decode writes one as XML, a row per glyph, and mft encode builds it back:

> jackall-cli mft decode game\ui\fonts\farcry2_25.mft --out farcry2_25.xml
Wrote farcry2_25.xml

mft faces lists the fonts a TrueType or OpenType file holds, and a variable font's design axes:

> jackall-cli mft faces Caveat.ttf
65536 Caveat Regular
131072 Caveat Bold
axis wght (Weight): 400 to 700, 400 by default

mft build draws one of them into a mod layer. --face picks it by index or style, --axis sets an axis, --size is the pixel size and --name what the game knows it by. --no-cyrillic leaves the Cyrillic characters out for a smaller page, so Russian text draws as nothing. With --game it is also added to every fonts.mgb and UI dependency list as fragments, and --preview writes sample text set in it:

> jackall-cli mft build Caveat.ttf --axis wght=600 --size 40 --name Caveat_40 --out fontmod --game "C:\Games\Far Cry 2" --preview caveat.png
Caveat_40: Caveat Regular wght=600 at 40 px, 457 characters on 1 page(s), 40 file(s) written.
The font lacks 75 of the game's characters, which draw as nothing: U+017F U+037E U+0384 U+0385 U+0386 U+0387 U+0388 U+0389 U+038A U+038C U+038E U+038F U+0390 U+0391 U+0392 U+0393 U+0394 U+0395 U+0396 U+0397 U+0398 U+0399 U+039A U+039B ...

See Add a font.

Animations​

graphics\move\movemgr.bin decides which animation plays when. move clips lists the clips one weapon plays, here the AK-47 (weapon 2), and --shared-only keeps the ones another weapon plays too, which a change would also reach:

> jackall-cli move clips game\graphics\move\movemgr.bin --weapon 2 --shared-only
game\graphics\move\movemgr.bin: weapon 2 plays 63 clips (60 exclusive, 3 shared)
0E1937D3 17x graphics\characters\_common\animations\weapons\primary\ak47\3rdge_fulb_jamcycle_nodir_prak4_i1.mab shared with 5, 7, 8, 15, 16, 18, 19, 21, 23, 25, 26, 27, 29, 30, 39, 40
76C825BC 3x graphics\characters\_common\animations\weapons\primary\ak47\3rdge_uppb_reload_nodir_prak4_i1.mab shared with 12
A4E84FA5 2x graphics\characters\_common\animations\weapons\primary\ak47\1stge_uppb_reload_+000fw_prak4_i1.mab shared with 12

move decode and move encode turn the graph into XML and back, move repoint points one weapon at other clips, and move fragments writes a changed graph out as the per-situation pieces the app saves. See Change which animation plays and MOVE.

Dependencies, brains and missions​

depload validate checks a world's dependency list, the index of what to load with what:

> jackall-cli depload validate game\worlds\world1\generated\world1_depload.dat
9718 parents, 29723 children.
OK

depload add registers a new resource in it; see depload.

ai lint lists parameters a brain sets that the game never reads:

> jackall-cli ai lint game\scripts\game\newbrains\mercbrain.ai.rml
13,583 nodes; 799 parameter values the engine never reads:
799 CTaskUpdateBlackboard.UpdateWho (the engine reads updateWho)

ai unpack writes a brain's source out as XML, and ai verify checks that brains recompile unchanged. See Tune the AI.

ai fragments writes an edited brain, or the source it is compiled from, as the instances that differ from the game's, which a mod stages at the brain's path; see Fragments:

> jackall-cli ai fragments mercbrain.source.xml --base vanilla\mercbrain.ai.rml --out layer\mods\scripts\game\newbrains\mercbrain.ai.rml
mercbrain.source.xml: 13611 units, 46 differ from vanilla (28 new)

domino check looks for what would break a mission script in game:

> jackall-cli domino check game\domino\user\a1sm01_townescape.a1sm01_mission.lua
┌────────────────────┬──────────┬──────────┐
│ Rule │ Severity │ Findings │
├────────────────────┼──────────┼──────────┤
│ unfired-out-anchor │ Info │ 6 │
└────────────────────┴──────────┴──────────┘
1 graph(s); twin: 1/1 clean, 288/288 traced fires matched (23 named by the twin)
box IDs: Slot 126, Twin 23, Wire 111
No errors

See Read a mission.

navmesh build makes the AI's navmesh for a level of your own, from its terrain and the collision of what is placed on it. Point it at a folder laid out like the game's data, such as a mod layer's mods folder, and at the game, which holds the collision of every retail object:

> jackall-cli navmesh build mods\DevTools\layer\mods --level testrange --game "C:\Games\Far Cry 2"
64 sectors, 19,068 triangles, 120 covers, 33 colliding objects.
HasNavMesh set on 64 of 64 sectors in worlds\testrange\generated\testrange.sectorsdep.fcb.

It writes each sector's nv_<id>.nvm and turns on the flag that makes the game load them. The mesh covers any terrain, and the floors, roofs, ramps and stairs of what stands on it. It leaves out slopes over 45° and steps over 0.3 m, and lays cover points along walls and props. Without --game, an object whose collision is not in the folder is left out, and the command says which. See .nvm.

world new writes a new world's files, made from tmpla, into a folder, and world pack turns a layer holding new worlds into the form a mod ships: each world's sector files, entity library, sector flags and navmesh built from its pieces, everything else copied:

> jackall-cli world new myworld --side 8 --game "C:\Games\Far Cry 2" --out myworld-layer
myworld: 382 files, 8 x 8 sectors.
> jackall-cli world pack myworld-layer --game "C:\Games\Far Cry 2" --out myworld-packed
myworld: 2,070 archetypes kept of 5,735
myworld: navmesh over 64 sectors and 14 colliding objects
511 files, 0 plugin files.

--base names a mod the packed one builds on, such as the mod whose world it changes. See Make a new world.

References​

xref build indexes every reference between the game's files, once:

> jackall-cli xref build --game "C:\Games\Far Cry 2"
Indexed 213,879 files in 11.7s
edges : 2,985,587
definitions : 39,369
file refs resolve: 1,012,633/1,169,618 (86.6%)
written to : …\.xrefs (58.4 MB)
217 file(s) come from patch.dat/mods and are indexed per session, not persisted
8 file(s) failed to decode
…

Then xref from lists what a file uses, here the AK-47's main material and its textures:

> jackall-cli xref from graphics\_materials\sdore2-m-2008050631030648.xbm --game "C:\Games\Far Cry 2"
references site kind
──────────────────────────────────────────────────────────────────────────────
graphics\weapons\primary\ak47\ak47_state01_ MaskTexture1 XbmTexture
m.xbt
graphics\weapons\primary\ak47\ak47_state02_ MaskTextureBroken XbmTexture
m.xbt
graphics\_textures\diffuse\metal\dirtrust_0 DiffuseTexture2 XbmTexture
3_d.xbt
graphics\_textures\specular\infra_bridges_m SpecularTexture1 XbmTexture
etal_s.xbt
graphics\_textures\diffuse\metal\metalbrush DiffuseTexture1 XbmTexture
ed_d.xbt

xref to lists everything that uses a file, and xref reach sorts every file into used and unused. --index pointed at JackAll's own data\.xrefs shares one index with the app. See What uses this file?.

More​

  • shader extract, shader build and shader index: see Replacing a shader. shader label --game <dir> writes the shader labels the Files tab shows, one tab-separated line per Direct3D 9 object: path, category, detail, how it was found (index or hand) and the settings that decide its presets with one of its permutations. --hand <file> works as it does for spk label.
  • sav list and sav clean: the command-line side of Savegames.
  • depload decode and depload encode, move verify, move assemble and move names: see the format pages for depload and MOVE.

Every command has --help with its options and an example.