---
title: "DLG file format"
---
DLG file format
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2, BGEE
DLG files contain the structure of conversations, in what is effectievly a state machine. Dialogs contains string references into the TLK file that make up the actual words of the conversation. Dialogs bear similarities to scripts; each state may have a series of trigger conditions, and effect a series of actions. If the any of the triggers for a state evaluate to false, the state is skipped and the triggers in the next state are evaluated - this occurs when entering into a dialog state, and when presenting a list of responses.
state 0:
trigger: NumTimesTalkedTo(0)
Text: "Hello, sailor!"
state 1:
trigger: NumTimesTalkedToGT(5)
Text: "Go away, already!"
state 2:
Text: "Hail and well met, yada yada yada."
Dialog always attempt to start at state 0. The first time this sample dialog is entered the trigger in state 0 is true, hence the character responds "Hello, sailor!". Subsequent times the dialog is entered the trigger in state 0 will be false, and state 1 is evaluated - this trigger also fails and so state 2 is evaluated. This state evaluates true, and get the associated message is displayed. If the dialog is initiaed five or more times, the trigger in state 1 will evaluate to true and the message associated with that state will be displayed.
In addition to the triggers outlined above, states present a list of responses (aka transitions). Each response may have a series of behaviours associated with it; the response text, a journal entry or an action.
Offset |
Size (data type) |
Description |
0x0000 |
4 (char array) |
Signature ('DLG ') |
0x0004 |
4 (char array) |
Version ('V1.0') |
0x0008 |
4 (dword) |
Number of states |
0x000c |
4 (dword) |
Offset of state table from start of
file |
0x0010 |
4 (dword) |
Number of transitions |
0x0014 |
4 (dword) |
Offset of transition table from
start of file |
0x0018 |
4 (dword) |
Offset of state trigger table
from start of file |
0x001c |
4 (dword) |
Number of state triggers |
0x0020 |
4 (dword) |
Offset of transition trigger table
from start of file |
0x0024 |
4 (dword) |
Number of transition triggers |
0x0028 |
4 (dword) |
Offset of action table from start of
file |
0x002c |
4 (dword) |
Number of actions |
0x0030 |
4 (dword) |
Flags specifying what the creature does when the dialog is interrupted by a hostile action from a EA < GOODCUTOFF creature.
- Bit 0: Enemy()
- Bit 1: EscapeArea()
- Bit 2: nothing (but since the action was hostile, it behaves similar to bit 0)
In addition, all these bits trigger the not-pause behaviour.
Hostile action is something like an effect from a spell with the hostile flag, damage effect, a simple attack or a failed pickpocket action.
Note: This field does not exist in DLG files used in BG1.
|
Offset |
Size (data type) |
Description |
0x0000 |
4 (strref) |
Actor response text (i.e. what the non-player character says to the
party) |
0x0004 |
4 (dword) |
Index of the first transition corresponding to this state (i.e. the
index in the transition table of the
first potential response the party can make in this state). |
0x0008 |
4 (dword) |
Number of transitions
corresponding to this state (i.e. how many possible responses are there
to this state). A consecutive range of transitions in the transition
table are assigned to this state, starting from 'first', as given by
the previous field, ranging up to (but not including) 'first'+'count'. |
0x000c |
4 (dword) |
Trigger for this state (as index into the state
trigger table), or 0xFFFFFFFF if no trigger is used for this state. |
Offset |
Size (data type) |
Description |
0x0000 |
4 (dword) |
Flags:
- bit 0: 1=Associated text, 0=no associated text
- bit 1: 1=Trigger, 0=no trigger
- bit 2: 1=Action, 0=no action
- bit 3: 1=Terminates dialog, 0=has "next node" information
- bit 4: 1=Journal entry, 0=no journal entry
- bit 5: Interrupt
- bit 6: Add Unsolved Quest Journal entry (BG2)
- bit 7: Add Journal note (BG2)
- bit 8: Add Solved Quest Journal entry (BG2)
- bit 9: 1=Immediate execution of script actions, 0=Delayed execution of script actions (BGEE)
- bit 10: Clear actions (BGEE)
|
0x0004 |
4 (strref) |
If flags bit 0 was set, this is the text associated with the
transition (i.e. what the player character says) |
0x0008 |
4 (strref) |
If flags bit 4 was set, this is the text that goes into your journal
after you have spoken. |
0x000c |
4 (dword) |
If flags bit 1 was set, this is the index of this transition's trigger
within the transition trigger table. |
0x0010 |
4 (dword) |
If flags bit 2 was set, this is the index of this transition's action
within the action table. |
0x0014 |
8 (resref) |
If flags bit 3 was not set, this is the resource name of the DLG resource
which contains the next state in the
conversation. |
0x001c |
4 (dword) |
If flags bit 3 was not set, this is the index of the next state within the
DLG resource specified by the previous field. Control transfers to that
state after the party has followed this transition. |
This section is a series of pairs of (offset,count) of string data within the
DLG file. This string data is composed of the state triggers. Note that the
strings referenced by this section are NOT zero terminated. Also, the strings
are typically at the very end of the file. For information on triggers, see the
BG documents on writing AI scripts.
Offset |
Size (data type) |
Description |
0x0000 |
4 (dword) |
Offset from start of file to state trigger string. |
0x0004 |
4 (dword) |
Length in bytes of the state trigger string. |
This section is a series of pairs of (offset,count) of string data within the
DLG file. This string data is composed of the transition triggers. Note that the
strings referenced by this section are NOT zero terminated. Also, the strings
are typically at the very end of the file. For information on triggers, see the
BG documents on writing AI scripts.
Offset |
Size (data type) |
Description |
0x0000 |
4 (dword) |
Offset from start of file to transition trigger string. |
0x0004 |
4 (dword) |
Length in bytes of the transition trigger string. |
This section is a series of pairs of (offset,count) of string data within the
DLG file. This string data is composed of the actions. Note that the strings
referenced by this section are NOT zero terminated. Also, the strings are
typically at the very end of the file. For information on actions, see the BG
documents on writing AI scripts; specifically, see the section on
"responses".
Offset |
Size (data type) |
Description |
0x0000 |
4 (dword) |
Offset from start of file to the action string. |
0x0004 |
4 (dword) |
Length in bytes of the action string. |