GAM file format
Applies to:
BG2, BG2: ToB, BG:EE, BG2:EE, IWD:EE
General Description
This file format is used to hold game information in save games. The GAM file does not store area, creature or item information, instead, it stores information on the party members and the global variables which affect party members.
Detailed Description
Overall structure:
Offset | Size (datatype) | Description |
---|---|---|
0x0000 | 4 (char array) | Signature ('GAME') |
0x0004 | 4 (char array) | Version ('V2.0') |
0x0008 | 4 (dword) | Game time (300 units == 1 hour) |
0x000c | 2 (word) | Selected formation |
0x000e | 2 (word) | Formation button 1 |
0x0010 | 2 (word) | Formation button 2 |
0x0012 | 2 (word) | Formation button 3 |
0x0014 | 2 (word) | Formation button 4 |
0x0016 | 2 (word) | Formation button 5 |
0x0018 | 4 (dword) | Party gold |
0x001c | 2 (word) | Use active area from party member (0=Player1, 1=Player2, ... 5=Player6, -1=Not in party). This overrides current area at offset 0x0058. |
0x001e | 2 (word) | Weather bitfield
|
0x0020 | 4 (dword) | Offset to NPC structs for party members |
0x0024 | 4 (dword) | Count of NPC structs for party members (including Protagonist) |
0x0028 | 4 (dword) | Offset to party inventory |
0x002c | 4 (dword) | Count of party inventory |
0x0030 | 4 (dword) | Offset to NPC structs for non-party members |
0x0034 | 4 (dword) | Count of NPC structs for non-party members |
0x0038 | 4 (dword) | Offset to GLOBAL namespace variables |
0x003c | 4 (dword) | Count of GLOBAL namespace variables |
0x0040 | 8 (resref) | Main area |
0x0048 | 4 (dword) | Offset to Familiar Extra |
0x004c | 4 (dword) | Count of journal entries |
0x0050 | 4 (dword) | Offset to journal entries |
0x0054 | 4 (dword) | Party reputation (*10) |
0x0058 | 8 (resref) | Current area |
0x0060 | 4 (dword) | GUI flags
|
0x0064 | 4 (dword) | Loading progress
|
0x0068 | 4 (dword) | Offset to familiar info |
0x006c | 4 (dword) | Offset to stored locations |
0x0070 | 4 (dword) | Count of stored locations |
0x0074 | 4 (dword) | Game time (real seconds) |
0x0078 | 4 (dword) | Offset to pocket plane locations |
0x007c | 4 (dword) | Count of pocket plane locations |
0x0080 | 4 (dword) | EE: Zoom level (in percent), 0 or 100: default zoom level, >100: zoomed out, <100: zoomed in. |
0x0084 | 8 (resref) | EE: Random encounter area set by script action ForceRandomEncounter() or ForceRandomEncounterEntry(). |
0x008c | 8 (resref) | EE: Current worldmap |
0x0094 | 8 (char array) | EE: Current campaign (e.g. "SOD" for Siege of Dragonspear) |
0x009c | 4 (dword) | EE: Familiar owner (0=Player1, 1=Player2, ..., 5=Player6), used in IWDEE |
0x00a0 | 20 (char array) | EE: Random encounter entry set by script action ForceRandomEncounterEntry(). |
Offset | Size (datatype) | Description |
---|---|---|
0x0000 | 2 (word) | Character selection
|
0x0002 | 2 (word) | Party order (0x0-0x5 = PlayerXFill, 0xFFFF = not in party) |
0x0004 | 4 (dword) | Offset (from start of file) to CRE resource data for this character |
0x0008 | 4 (dword) | Size of CRE resource data for this character |
0x000c | 8 (bytes) | Character Name |
0x0014 | 4 (dword) | Character orientation |
0x0018 | 8 (resref) | Characters current area |
0x0020 | 2 (word) | Character X coordinate |
0x0022 | 2 (word) | Character Y coordinate |
0x0024 | 2 (word) | Viewing rectangle X coordinate |
0x0026 | 2 (word) | Viewing rectangle Y coordinate |
0x0028 | 2 (word) | Modal action |
0x002a | 2 (word) | Happiness |
0x002c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0030 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0034 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0038 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x003c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0040 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0044 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0048 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x004c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0050 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0054 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0058 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x005c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0060 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0064 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0068 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x006c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0070 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0074 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0078 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x007c | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0080 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0084 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x0088 | 4 (dword) | NumTimesInteracted NPC count (unused) |
0x008c | 2 (word) | Index into slots.ids for Quick Weapon 1 (0xFFFF = none) |
0x008e | 2 (word) | Index into slots.ids for Quick Weapon 2 (0xFFFF = none) |
0x0090 | 2 (word) | Index into slots.ids for Quick Weapon 3 (0xFFFF = none) |
0x0092 | 2 (word) | Index into slots.ids for Quick Weapon 4 (0xFFFF = none) |
0x0094 | 2 (word) | Quick weapon slot 1 ability (0/1/2 or -1 disabled) |
0x0096 | 2 (word) | Quick weapon slot 2 ability (0/1/2 or -1 disabled) |
0x0098 | 2 (word) | Quick weapon slot 3 ability (0/1/2 or -1 disabled) |
0x009a | 2 (word) | Quick weapon slot 4 ability (0/1/2 or -1 disabled) |
0x009c | 8 (resref) | Quick Spell 1 resouce |
0x00a4 | 8 (resref) | Quick Spell 2 resouce |
0x00ac | 8 (resref) | Quick Spell 3 resouce |
0x00b4 | 2 (word) | Index into slots.ids for Quick Item 1 (0xFFFF = none) |
0x00b6 | 2 (word) | Index into slots.ids for Quick Item 2 (0xFFFF = none) |
0x00b8 | 2 (word) | Index into slots.ids for Quick Item 3 (0xFFFF = none) |
0x00ba | 2 (word) | Quick Item 1 slot ability (0/1/2 or -1 disabled) |
0x00bc | 2 (word) | Quick Item 2 slot ability (0/1/2 or -1 disabled) |
0x00be | 2 (word) | Quick Item 3 slot ability (0/1/2 or -1 disabled) |
0x00c0 | 32 (bytes) | Name |
0x00e0 | 4 (dword) | Talkcount |
0x00e4 | 116 bytes | character stats for this character |
0x0158 | 8 bytes | Voice Set |
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 4 (strref) | "Most powerful vanquished" - Name |
0x0004 | 4 (dword) | "Most powerful vanquished" - XP Reward |
0x0008 | 4 (dword) | Time in party (1/15 seconds) |
0x000c | 4 (dword) | Time Joined (1/15 seconds) |
0x0010 | 1 (byte) | Party member (0 = Not in party, 1 = In party) |
0x0011 | 2 (word) | Unused |
0x0013 | 1 (byte) | First letter of CRE resref (changed to *) |
0x0014 | 4 (dword) | Kills - XP Gained (chapter) |
0x0018 | 4 (dword) | Kills - Number (chapter) |
0x001c | 4 (dword) | Kills - XP (game) |
0x0020 | 4 (dword) | Kills - number (game) |
0x0024 | 4*8 (resref array) | Favourite spells |
0x0044 | 4*2 (word array) | Favourite spell count |
0x004c | 4*8 (resref array) | Favourite weapons |
0x006c | 4*2 (word) | Favourite weapon time (time equipped in combat - 1/15 seconds) |
Note the format specification allows variables of differing types, however the engine implementation only reads and writes INT variables.
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 32 (char array) | Variable name |
0x0020 | 2 (type) | Type
|
0x0022 | 2 (word) | Ref value |
0x0024 | 4 (dword) | Dword value |
0x0028 | 4 (dword) | Int value |
0x002c | 8 (double) | Double value |
0x0034 | 32 (char array) | Script name value |
This section stores the strref, chapter and time for any entry added to the journal.
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 4 (strref) | Journal text |
0x0004 | 4 (dword) | Time (seconds) |
0x0008 | 1 (byte) | Current chapter number |
0x0009 | 1 (byte) | Read by character x |
0x000a | 1 (byte) | Journal section
|
0x000b | 1 (byte) | Location flag (0x1F = external TOT/TOH, 0xFF = internal TLK) |
The familiar (summoned by the Find Familiar spell) is dependent on the alignment of the caster. This section contains the mapping between caster alignment and the CRE file to summon.
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 8 (resref) | Lawful Good Familiar |
0x0008 | 8 (resref) | Lawful Neutral Familiar |
0x0010 | 8 (resref) | Lawful Evil Familiar |
0x0018 | 8 (resref) | Neutral Good Familiar |
0x0020 | 8 (resref) | Neutral Familiar |
0x0028 | 8 (resref) | Neutral Evil Familiar |
0x0030 | 8 (resref) | Chaotic Good Familiar |
0x0038 | 8 (resref) | Chaotic Neutral Familiar |
0x0040 | 8 (resref) | Chaotic Evil Familiar |
0x0048 | 4 (dword) | Offset to familiar resources |
0x004c | 4 (dword) | LG level 1 familiar count |
0x0050 | 4 (dword) | LG level 2 familiar count |
0x0054 | 4 (dword) | LG level 3 familiar count |
0x0058 | 4 (dword) | LG level 4 familiar count |
0x005c | 4 (dword) | LG level 5 familiar count |
0x0060 | 4 (dword) | LG level 6 familiar count |
0x0064 | 4 (dword) | LG level 7 familiar count |
0x0068 | 4 (dword) | LG level 8 familiar count |
0x006c | 4 (dword) | LG level 9 familiar count |
0x0070 | 4 (dword) | LN level 1 familiar count |
0x0074 | 4 (dword) | LN level 2 familiar count |
0x0078 | 4 (dword) | LN level 3 familiar count |
0x007c | 4 (dword) | LN level 4 familiar count |
0x0080 | 4 (dword) | LN level 5 familiar count |
0x0084 | 4 (dword) | LN level 6 familiar count |
0x0088 | 4 (dword) | LN level 7 familiar count |
0x008c | 4 (dword) | LN level 8 familiar count |
0x0090 | 4 (dword) | LN level 9 familiar count |
0x0094 | 4 (dword) | CG level 1 familiar count |
0x098 | 4 (dword) | CG level 2 familiar count |
0x009c | 4 (dword) | CG level 3 familiar count |
0x0100 | 4 (dword) | CG level 4 familiar count |
0x0104 | 4 (dword) | CG level 5 familiar count |
0x0108 | 4 (dword) | CG level 6 familiar count |
0x010c | 4 (dword) | CG level 7 familiar count |
0x0110 | 4 (dword) | CG level 8 familiar count |
0x0114 | 4 (dword) | CG level 9 familiar count |
0x0118 | 4 (dword) | NG level 1 familiar count |
0x011c | 4 (dword) | NG level 2 familiar count |
0x0120 | 4 (dword) | NG level 3 familiar count |
0x0124 | 4 (dword) | NG level 4 familiar count |
0x0128 | 4 (dword) | NG level 5 familiar count |
0x012c | 4 (dword) | NG level 6 familiar count |
0x0130 | 4 (dword) | NG level 7 familiar count |
0x0134 | 4 (dword) | NG level 8 familiar count |
0x0138 | 4 (dword) | NG level 9 familiar count |
0x013c | 4 (dword) | TN level 1 familiar count |
0x0140 | 4 (dword) | TN level 2 familiar count |
0x0144 | 4 (dword) | TN level 3 familiar count |
0x0148 | 4 (dword) | TN level 4 familiar count |
0x014c | 4 (dword) | TN level 5 familiar count |
0x0150 | 4 (dword) | TN level 6 familiar count |
0x0154 | 4 (dword) | TN level 7 familiar count |
0x0158 | 4 (dword) | TN level 8 familiar count |
0x015c | 4 (dword) | TN level 9 familiar count |
0x0160 | 4 (dword) | NE level 1 familiar count |
0x0164 | 4 (dword) | NE level 2 familiar count |
0x0168 | 4 (dword) | NE level 3 familiar count |
0x016c | 4 (dword) | NE level 4 familiar count |
0x0170 | 4 (dword) | NE level 5 familiar count |
0x0174 | 4 (dword) | NE level 6 familiar count |
0x0178 | 4 (dword) | NE level 7 familiar count |
0x017c | 4 (dword) | NE level 8 familiar count |
0x0180 | 4 (dword) | NE level 9 familiar count |
0x0184 | 4 (dword) | LE level 1 familiar count |
0x0188 | 4 (dword) | LE level 2 familiar count |
0x018c | 4 (dword) | LE level 3 familiar count |
0x0190 | 4 (dword) | LE level 4 familiar count |
0x0194 | 4 (dword) | LE level 5 familiar count |
0x0198 | 4 (dword) | LE level 6 familiar count |
0x019c | 4 (dword) | LE level 7 familiar count |
0x0200 | 4 (dword) | LE level 8 familiar count |
0x0204 | 4 (dword) | LE level 9 familiar count |
0x0208 | 4 (dword) | CN level 1 familiar count |
0x020c | 4 (dword) | CN level 2 familiar count |
0x0210 | 4 (dword) | CN level 3 familiar count |
0x0214 | 4 (dword) | CN level 4 familiar count |
0x0218 | 4 (dword) | CN level 5 familiar count |
0x021c | 4 (dword) | CN level 6 familiar count |
0x0220 | 4 (dword) | CN level 7 familiar count |
0x0224 | 4 (dword) | CN level 8 familiar count |
0x0228 | 4 (dword) | CN level 9 familiar count |
0x022c | 4 (dword) | CE level 1 familiar count |
0x0230 | 4 (dword) | CE level 2 familiar count |
0x0234 | 4 (dword) | CE level 3 familiar count |
0x0238 | 4 (dword) | CE level 4 familiar count |
0x023c | 4 (dword) | CE level 5 familiar count |
0x0240 | 4 (dword) | CE level 6 familiar count |
0x0244 | 4 (dword) | CE level 7 familiar count |
0x0248 | 4 (dword) | CE level 8 familiar count |
0x024c | 4 (dword) | CE level 9 familiar count |
This struct is filled by the StorePartyLocations() action and cleared by the RestorePartyLocations() action. There is one record for each member of the party at the time the action was called.
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 8 (resref) | Area |
0x0008 | 2 (word) | X coordinate |
0x000a | 2 (word) | Y coordinate |
This struct is filled by the Spell Effect: Area Switch [298] effect and cleared by the ExitPocketPlane effect. There is one record for each member of the party at the time the effect was called.
Offset | Size (data type) | Description |
---|---|---|
0x0000 | 8 (resref) | Area |
0x0008 | 2 (word) | X coordinate |
0x000a | 2 (word) | Y coordinate |
This is a table of resefs related to familiars. The table count is the sum of the level entries in the familiar section.
Offset | Size (data type) | Description |
---|---|---|
... | 8 (resref) | Familiar resref |