Skip to main content

Global script flags

ScriptGlobalFlags · bits of the 32-bit global flag value used by flag operations

Scripted characters, flags and messages · Run a sequence

Scripts remember story progress in flags. Unlike the level flags, the global flags keep their value from one level to the next. The bits listed here are the ones the examined code or reference scripts use; others may exist.1

Bits 5, 18, 19 and 27 are written but have no direct reader: the code that reads the flag value directly is the script test, which no reference script applies to these bits, the defeat-scene check (bit 20) and the portrait drawing (bit 31).

typedef enum ScriptGlobalFlags {
SCRIPT_GLOBAL_FLAG_SHORN_MET = 0x00000002, /* Bit 1: the party has spoken with Shorn on level 2; cleared when Insal leaves. */
SCRIPT_GLOBAL_FLAG_SHORN_BONES_PLACED = 0x00000004, /* Bit 2: Shorn's bones have been placed on level 2; cleared with bit 1. */
SCRIPT_GLOBAL_FLAG_SHORN_RELEASED = 0x00000008, /* Bit 3: set by Shorn's conversation; stops his scripts on level 2. */
SCRIPT_GLOBAL_FLAG_CALANDRA_DIALOGUE_RUN = 0x00000010, /* Bit 4: Calandra's dialogue on level 2 has run. */
SCRIPT_GLOBAL_FLAG_5_UNKNOWN = 0x00000020, /* Can be set by Calandra's dialogue. */
SCRIPT_GLOBAL_FLAG_INSAL_JOINED = 0x00000040, /* Bit 6: set after Insal's invitation is accepted; tested on level 15. */
SCRIPT_GLOBAL_FLAG_18_UNKNOWN = 0x00040000, /* Set when a provoked peaceful monster of type index 7 turns its group. */
SCRIPT_GLOBAL_FLAG_19_UNKNOWN = 0x00080000, /* Set and cleared by level 15; no direct reader. */
SCRIPT_GLOBAL_FLAG_KHELBEN_VISION = 0x00100000, /* Bit 20: from Khelben's vision on level 12 until the next entry there or the skull scene; selects the defeat scene. */
SCRIPT_GLOBAL_FLAG_27_UNKNOWN = 0x08000000, /* The same as bit 18 for type index 12. */
SCRIPT_GLOBAL_FLAG_DARKMOON_SOUTH_APPROACH = 0x10000000, /* Bit 28: the party last approached the temple entrance from the south. */
SCRIPT_GLOBAL_FLAG_PUNISHED_ON_LEVEL_7 = 0x20000000, /* Bit 29: set by the punishment of level 7; tested on level 8. */
SCRIPT_GLOBAL_FLAG_TEMPLE_STAIRS_DESCENDED = 0x40000000, /* Bit 30: the party has arrived on level 1 by the temple stairs down. */
SCRIPT_GLOBAL_FLAG_DARKMOON_MARK = 0x80000000 /* Bit 31: the mark of Darkmoon, given on level 9; tested on level 6 and by the portrait drawing. */
} ScriptGlobalFlags;

What each bit does​

  • Bits 1 to 3 record Shorn's story on level 2: bit 1 once the party has spoken with him, bit 2 once his bones have been placed, bit 3, set by his conversation, once he is released. Bits 1 and 2 are also cleared when Insal leaves the party after a rest; see Insal leaves and ANOMALY-120.2
  • Bits 5 and 6 are set by the character dialogues; bit 6, set when Insal's invitation is accepted, is tested on level 15. Bit 5 has no direct reader.1
  • Bit 4 is set by one script of level 2, right after it runs Calandra's dialogue, and keeps that script from running the dialogue again.3
  • Bit 19 is set and cleared by level 15; it has no direct reader.
  • Bit 20 is set by Khelben's vision on level 12 and cleared by the next entry into that block or by the skull scene. When the whole party is defeated while it is set, the game first plays a short scene with the KHELDRAN picture; see when the party is defeated.3
  • Bit 29 is set by the punishment of level 7 and tested on level 8.
  • Bit 31 is set by the pedestal of level 9 and tested by a face of level 6, which lets the bearer of the mark of Darkmoon pass. While it is set, the portrait drawing shows another picture for an empty first hand.4
  • Bits 18 and 27 are written only by monster behavior, never by the reference scripts, and no monster of the reference levels can trigger them; see provoked monsters.
  • Bit 28 is set and cleared by two scripts of the forest level and tested by the temple entrance scripts of level 5; see level 4 and level 5.5
  • Bit 30 is set on level 1 at the arrival point of the stairs down from level 5. Level 5 then places clerics periodically and closes its front door; see returning clerics.6

Sources​

Locations refer to the game executable reference.

Footnotes​

  1. Character dialogues; the global flags are stored together and changed by the set flags and clear flags handlers. ↩ ↩2

  2. Insal leaves. ↩

  3. Decoded scripts of the reference LEVEL2.INF (script-buffer offsets 2999 to 3014) and LEVEL12.INF (Khelben's vision and the skull); the party status check, the global flags and the defeat scene. ↩ ↩2

  4. The character portrait part of the routines that draw the portraits, and the global flags; the level scripts are described on their pages. ↩

  5. Decoded scripts of the reference LEVEL4.INF (script-buffer offsets 365 and 372) and LEVEL5.INF (offsets 120 and 168), identified in the file inventory. ↩

  6. Decoded scripts of the reference LEVEL1.INF (offset 59) and LEVEL5.INF (offsets 52 and 1206). ↩