MAP File Format

The MAP File Format contains the information for a map used in the game. A map consists of a grid that the player walks on, plus all the associated walls, scenery, critters, and objects in Fallout and

Introduction
A MAP file may contain up to 3 separate levels, typically used for representing different elevations. Each level contains a 200 by 200 hex grid, for a total of 40000 possible positions on the grid. The format for locations on the grid is: 00 00 XX YY, where XX is the horizontal coordinate [0 .. 199], and YY is the vertical coordinate [0 .. 199].

Format
The MAP file format consists of 5 parts:


 * 1) Header of the MAP file
 * 2) Global and Local Variables
 * 3) Tiles
 * 4) MAP Scripts
 * 5) MAP Objects

PID
The PID is a fundamental type used in the MAP file. It is an identifier for describing objects. It consists of a 4 byte integer of the form 0xaa00bbbb. The byte aa is the type of the object, while the 2 bytes bbbb are the id of the object. The id is typically an index into a LST file. Valid types include:

 Note: for PIDs that refer to critter FRM files, the PID format is more complex. 
 * 00: items
 * 01: critters
 * 02: scenery
 * 03: walls
 * 04: tiles
 * 05: misc
 * 06: intrface
 * 07: inven
 * 08: heads
 * 09: background

Global and Local Variables
The global and local variables used by the map scripts are stored here in arrays.

Tiles
Each level of the map consists of tile data for both the roof and floor. These tiles are on an isometric grid, which is independent of the hexagonal grid used for critters, scenery, objects etc. The grid size is 100 by 100, which gives a total of 20000 tiles for each level (including both floor and roof). For each elevation that exists in the MAP file, there is the following tile information.

MAP Scripts
This section of the file stores information about the scripts connected to objects in this map. This section is not really understood very well.

There are 5 types of scripts found in the MAP file. The type of the script is found in the PID.

Scripts in this section are always grouped in multiples of 16, rounding up. After each group of 16 scripts is a check integer.

Here is some sample C code used to skip over the script section. /* read in each sequence of scripts */ for (i = 0; i &lt; 5; i++) {

/* number of scripts used in this sequence */ count = read_int32_big_endian(stream); if (count &gt; 0) {

/* loop counter must be modulo 16 (rounded up) */ loop = MODULO_16(count);

check = 0;

/* read in all the scripts of this sequence */ for (j = 0; j &lt; loop; j++) { read_script(stream);

/* after every 16 scripts is the check block */ if ((j % 16) == 15) { v = read_int32_big_endian(stream); check += v;

/* don't know what this is for, so ignore it for now */ v = read_int32_big_endian(stream); }     }      if (check != count) { set_error_message(&quot;error reading scripts: check is incorrect&quot;); okay = FALSE; break; }  } }

return okay; The read_script function reads in a script of the following format.

MAP Objects
The objects contain the scenery, walls, items, containers, keys and critters that appear on the map. There is an array of objects for each elevation of the map.


 * 4 byte integer containing total number of objects on all levels
 * for each of the three levels
 * 4 byte integer containing number of objects on this level
 * array on map objects