2DA file format

Applies to:
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2

General Description
2DA ("2-Dimensional Array") files contain a two-dimensional array of data. They are used to hold information in tables, often relating to the game rules, e.g. THAC0 progression.

Detailed Description
2DA files are generally plain text files, unless the first two bytes are 0xff, in which case the file is encrypted. Values in 2da files are white space separated, as a result values cannot contain spaces.

2DA files should always contain at least four rows;
The first row contains the file signature, "2DA V1.0", which may be preceeded by white space.
The second row contains the "default value" for the file.
The third row contains column headings.
Subsequent rows consist of row data.
Any cell (i.e. row/column intersection) which does not contain a value is assumed to have the "default value".

A sample file appears below.

2DA V1.0
    1234
            NAME    VALUE   WEIGHT
    A       alpha
    B
    C       beta    2345    123
    

In this example, row A has the values { alpha, 1234, 1234 }. Row B has the values { 1234, 1234, 1234 }. Row C has the values {beta, 2345, 123 }.

Encryption
NB. Some files are encrypted as detailed on the encryption page.