GAM File Format

GAM files are text files that define initial integer variables. Fallout uses one game-wide GAM file for global variables and optional per-map GAM files for map variables. The files are not save files by themselves; they seed runtime arrays that are later stored inside saved game data and saved maps.

Locations

FileSection headerRuntime arrayUsed by
data\vault13.gamGAME_GLOBAL_VARS:Game global variables.global_var and set_global_var script operations.
maps\*.gamMAP_GLOBAL_VARS:Current map's map-variable array.map_var and set_map_var script operations.

The map GAM filename is derived from the map filename. For example, when loading a clean maps\MYMAP.MAP, Fallout 2 CE also looks for maps\MYMAP.GAM and reads its MAP_GLOBAL_VARS: section.

Text syntax

The parser searches for the requested section header, then reads each following line as one variable entry. The variable's list index is its position in this parsed order, starting at zero. Scripts refer to variables by this numeric index, not by the source name.

MAP_GLOBAL_VARS:
//MAP VAR                              NUMBER

SecDoor_open            := 0;           // (0)
armory_access           := 0;           // (1)
revolting               := 1;           // (2)
dummyvar                := 0;           // (3)
map_runs                := 0;           // (4)
rebels_leave_date       := 100;         // (5)
Syntax elementBehavior
Section headerThe engine scans until the requested 16-character header prefix matches, such as GAME_GLOBAL_VARS: or MAP_GLOBAL_VARS:.
Blank linesLines whose first character is a newline are skipped.
// linesLines beginning with // are skipped.
Variable nameUseful to humans and tools, but ignored by the engine's value parser.
=The parser searches for an equals sign and reads a signed decimal integer after it with sscanf("%d").
;If present, the semicolon terminates the parsed part of the line. Text after it is ignored.
Missing =The variable entry still counts as a variable, but its value defaults to 0.

Although many examples use Pascal-style :=, Fallout 2 CE only looks for the = character when parsing the initial value. The colon is part of the conventional syntax, not the part that makes the value parse.

Keep lines short. Fallout 2 CE reads GAM lines into a fixed buffer and requests at most 258 characters per line. The older practical editing rule is still good: keep each line under 256 characters so an overlong line cannot spill into the following logical entry in older tools or engines.

Parser quirks

The CE parser is simple and line-oriented. A compatible tool should mimic these quirks when it needs engine-equivalent results:

QuirkConsequence
Section matching uses strncmp(..., 16).The requested header prefix is matched by its first 16 characters. Use the canonical section lines anyway.
Only lines whose first character is \n are treated as blank.Whitespace-only lines are not skipped by that blank-line test.
Only lines starting with // are skipped as comments.Indented // comments are not skipped by the comment test and can become zero-valued variable entries.
The semicolon is removed before parsing the value.Trailing comments after ; do not affect the value.
The parser searches for =, not :=.name = 1; and name := 1; both provide a parseable value.
Values are read with decimal sscanf("%d").Use plain signed decimal initial values for maximum compatibility.
A non-skipped line without = still increments the variable count.Formatting or comments in the wrong place can shift all later variable indexes.

Index stability

Variable names are documentation; variable positions are the ABI. Inserting, deleting, or reordering lines changes the numeric indexes used by scripts. This can silently retarget every later global_var, map_var, or local editor reference that expects the old order.

Game global variables

At game initialization and reset, Fallout 2 CE reads data\vault13.gam with the GAME_GLOBAL_VARS: section and builds the game-global integer array. Scripts access this array through game-global opcodes. Some engine systems also use hard-coded global variable indexes for reputation, addiction, car state, timers, and game progression.

The Pip-Boy quest and holodisk tables are another GVAR consumer. data\quests.txt uses GVAR thresholds to decide when quest descriptions appear and when they are drawn as completed. data\holodisk.txt uses non-zero GVAR values to decide which DATA entries are known.

During save-game writing, the current game-global array is written into SAVE.DAT as big-endian 32-bit integers. Fallout 2 CE's load/save handler table stores the game-global array twice: the first copy is loaded back into the live array, and the second copy is read and discarded. This is save-file behavior, not GAM text-file behavior.

SAVE.DAT variable blocks

Fallout 2 CE saves and loads SAVE.DAT through a fixed handler table. The game-global variable array appears twice in that sequence. The duplicate is historical/engine behavior; CE reads the first copy into the live array and skips the second copy.

Handler indexSave handlerLoad handlerMeaning
2scriptsSaveGameGlobalVarsscriptsLoadGameGlobalVarsPrimary game-global variable array.
3_GameMap2Slot_SlotMap2GameSaved maps, party-member PRO snapshots, automap transfer, and current map restoration.
4scriptsSaveGameGlobalVarsscriptsSkipGameGlobalVarsDuplicate game-global variable array, discarded on load.

A save editor should update both global-variable copies if it rewrites SAVE.DAT in place. A reader that only wants current values can read handler 2 and ignore handler 4, as CE does.

Map variables

Map variables are map-wide values for the currently loaded map. The MAP file contains a global_vars_count field and a serialized array of map variables immediately after the header. For a clean, non-saved map, Fallout 2 CE later reloads the matching maps\*.gam file and replaces the map-variable array with the text-defined initial values.

For a saved map, the saved-map flag is set in the MAP header, and the serialized map-variable array from the saved MAP/SAV data is preserved. In that case the map GAM file is not used to reset the current runtime values.

SituationMap-variable source
Clean mapper-authored mapInitial values from maps\NAME.GAM, section MAP_GLOBAL_VARS:, after the MAP structure is read.
Saved map stateSerialized map-variable array stored inside the saved MAP/SAV data.
Missing or unreadable map GAMThe MAP's serialized map-variable array remains the available source; tools should tolerate this case.

Map load lifecycle

StepClean mapSaved map
Read MAP headerReads global_vars_count, local_vars_count, and flags.Same.
Read serialized map variablesReads the map-variable array stored after the header.Reads the saved runtime map-variable array.
Read serialized local variablesReads the local-variable array stored after map variables.Reads the saved runtime local-variable array.
Check saved-map flagFlag 0x00000001 is clear.Flag 0x00000001 is set.
Load matching maps\NAME.GAMCE derives the GAM path from the map filename, reads MAP_GLOBAL_VARS:, replaces the current map-variable array, and updates global_vars_count.Skipped; saved runtime map variables are preserved.
Script localsNot loaded from GAM. Clean-map script local counts can be rebuilt from scripts.lst metadata.Not loaded from GAM. Saved script local values and offsets are preserved from the MAP/SAV data.

Local variables

Script local variables are related but are not defined by GAM files. Script local counts come from scripts\scripts.lst metadata such as local_vars=N, and the actual local values are stored in the MAP local-variable array. A script record points into that array with local_vars_offset and local_vars_count.

This distinction matters when comparing files: MAP_GLOBAL_VARS: defines map variables used by map_var; local_vars=N in scripts.lst defines how much local storage a script wants; the MAP file stores both map-variable values and local-variable values as separate arrays.

Save metadata

Save-slot metadata is stored in SAVE.DAT, not in a GAM file. It is included here because global variables and map variables are saved alongside this metadata, and tools that inspect save state often need both.

Save header fieldSize or typeDescription
signaturechar[24]Save signature, normally beginning with FALLOUT SAVE FILE.
version_minorint16Minor version stored in the save header.
version_majorint16Major version stored in the save header.
version_releaseuint8Release/build byte in the save header.
character_namechar[32]Player character name shown in the load/save UI.
descriptionchar[30]User-entered save description.
file_month, file_day, file_year, file_timedate/time fieldsReal-world save timestamp metadata.
game_month, game_day, game_year, game_timedate/time fieldsIn-game date and game-time tick.
elevationint16Current elevation for the save preview/state.
mapint16Current map index.
file_namechar[16]Current map file name used when restoring the saved map.

Save slots also carry compressed saved maps, party member PRO snapshots, automap data, the player object, critter data, queue data, worldmap state, interface state, and other subsystems. GAM text files provide initial variables; the save slot preserves current variables and broader runtime state.

Editing notes

Source References

History

2026-05-05 - Expanded with Fallout 2 CE source-backed notes by OpenAI

2020-01-16 - Ported from Vault-Tec Labs GAM File Format