Level 4: reference tables
Level 4 · The levels · Level data (INF)
In brief
The details of level 4: the data of the level, how to read the script details, every scripted place and encounter as the scripts run it, the cell bindings, the level flags and the monster types, with its sublevel records when it has two. Its story page tells the same places and encounters in a few sentences each.
Level data
The level has one sublevel record. It uses the maze LEVEL4.MAZ and the
forest graphics, sets a step threshold of 22 for BLOCK_EVENT_STEP_COUNT,
defines one script timer and starts with five monsters. Its only monster
graphics resource is wolf; the three monster types that its scripts place are
all drawn with it.1
This page covers every reachable script of the reference file: 16 cell bindings, 18 script entry points including two shared subroutines, and 184 instructions. The decoding leaves no unreached script byte and no unknown operand layout. Message colors are palette colors (Print a message).2
Reading this page
- Coordinates. A position
[XX:YY]gives the columnXXand the rowYY, counting from00. The block index used by the files and the instructions isYY × 32 + XX, as in INF and MAZ. - Directions. 0 = north (decreasing row), 1 = east, 2 = south and
3 = west; see
Direction. - Script offsets count from the start of the INF
script_datafield, which becomes the runtime script buffer; in the reference file it begins at decoded payload offset 681. Cell bindings store these offsets. - Messages and texts. Message numbers index the level's 17 strings; text
numbers index
TEXT.DAT(seeSCRIPT_DIALOGUE). They are summarized here, not quoted. - Speakers. A message containing a character name is attributed to the
character found by the last
SCRIPT_EXPR_FIND_CHARACTER_*test, or else to a randomly chosen eligible character.3 - Level flags are bits of this level's flag word (
SCRIPT_FLAG_TARGET_LEVEL); their names below are descriptive.
Wolves
Where they appear
Two scripts place monsters with SCRIPT_SPAWN_MONSTER,
whose checks can refuse a placement. Because every type of this level has
occupancy class 1, a placement succeeds only on a block that holds no monster
and is not the party's block. When all 30 monster slots are alive, a placement
replaces the living monster farthest from the party.2
- Every 23rd move ([00:00], offset 288): the step-triggered script runs when the party's move counter exceeds 22. It places a monster of type 0 at position 0 of [10:11], then one of type 1 at position 1 of the same block. The second placement never succeeds: after the first one the block is occupied, and when the first one is refused the second is refused for the same reason. Each event therefore adds at most one monster, of type 0.
- On the timer ([21:13], offset 319): a monster of type 2 at [21:11], one of type 2 at [21:12] and one of type 1 at [21:13], all at position 4. Each is placed only if its block holds no monster and is not the party's block, so each event adds up to three monsters, and none while all three blocks are occupied.
The five monsters present at the start are all of type 1, at [14:07], [13:08], [13:10], [16:15] and [18:15].1
How often the timer fires
The level's only timed block script sends
BLOCK_EVENT_TIMER to [21:13] with an interval of 180, that is
180 × 18 = 3 240 ticks of the game clock, about 178 seconds: just under three
minutes of game time. In detail:4
- The count starts when level 4 is loaded: at a new game, at each arrival from level 1 or level 5, and when a saved game on this level is loaded. Leaving the level stops it; returning starts a full period again.
- The event is sent at the first check after the deadline has passed, and the next deadline counts from that moment, so a late check never makes it fire twice. The check runs once per pass of the game loop, never while a script is running, such as during a dialogue.
- Time does not count during pauses: while the camp menu is open, while a level loads and during a few animations. A rest moves the clock forward by its hours, so the timer is overdue when the camp closes and fires once.
- No script changes or stops the timer: as long as the party is on level 4, it keeps firing at this period.
The old woman
Entering [19:10] or [12:11] calls the dialogue at offset 2, but only while level flag 0 is clear; the script sets it first, so the encounter happens once. The dialogue:2
- Opens the dialogue screen, fades in the upper-left region of
SOUT1withSCRIPT_DIALOGUE_BITMAP_TRANSITION, plays sound 52 and shows text 14: an old woman appears and offers help. The player chooses between three answers (messages 0–2: inquire, attack, leave). - Leave (answer 3): a party member greets her (message 3); the screen closes after a prompt.
- Attack (answer 2): text 21 says that she is easily killed and carried a
scroll.
SCRIPT_CREATE_ITEMcopies the parchment template 28, with value 14, into the current block (SCRIPT_ITEM_DESTINATION_CURRENT_BLOCK). Reading a parchment of value 14 showsTEXT.DATtext 15: an order to send travelers to Darkmoon, paid in silver, with a promise that the bearer's family will be returned. No dialogue of the level shows that text. Without the new value, the copy would keep the template's value −1, which shows a part of the map instead.5 - Inquire (answer 1): text 16, where the party asks about a lost friend, and
a second question with two answers (messages 5 and 6).
- Accept her guidance: the screen closes and the party is moved to [15:14], turned to direction 0, then moved northwards through [15:13], [15:12] and [15:11], with a redraw and a delay of 15 after each move. The dialogue screen then reopens, level flag 6 is set, text 17 says that this is the temple and that she leaves, and the party is moved to the entrance at [15:10].
- Decline: text 19, a farewell, then the screen closes.
Because moving the party dispatches block events, the last move runs the entrance script inside this dialogue, and the walk through [15:11] sets the south-approach flags.
Temple entrance
[15:11] (south of the entrance) and [16:10] (east of it) record the approach when the party enters them: [15:11] sets level flag 5 and global bit 28; [16:10] clears both.2
The entrance [15:10] reacts to three events:
- Party enters. The script opens the dialogue screen unless level flag 6
says it is already open, clears flag 6, draws the full-width
DARKMOONpicture, plays sound 54 and asks with text 18 whether to enter.- Yes: message 12 announces the temple, and
SCRIPT_LOAD_LEVEL_OR_MONSTERSloads level 5, sublevel 0, position [14:09], direction 3. - No: the party is moved back to [15:11] if flag 5 is set (clearing it), or to [16:10] otherwise, and the screen closes.
- Yes: message 12 announces the temple, and
- Item placed or flying object. Every item at [15:10] is moved to level 5
[14:09], with
SCRIPT_MOVE_ITEMS: items dropped or thrown into the entrance follow into the temple.
The global bit serves the way back. The level 5 front-door scripts at offsets 120 and 168 test it: when it is set, they return the party to level 4 [15:11] facing 2, or send items there; otherwise they use [16:10], facing 1.6
Hidden stairway
On entering [17:15], a party member remarks that the bushes to the south look
strange (message 13, sound 79). The script tests two candidates in turn and
gives the remark once (level flag 1): a character whose race_and_sex shifted
right once equals 1, then a CHARACTER_CLASS_THIEF
(CharacterClassMask). The first test
selects an elf: race_and_sex is 2 × race + sex, and race 1 is the elf
(CharacterRace).2
[17:16], the bushes south of it, reacts to three events:
- Party enters. The dialogue screen shows the lower-left region of
SOUT1, plays sound 53 and asks with text 13 whether to take the stairway found behind the bushes. Yes loads level 1, sublevel 0, position [29:15], direction 3; no moves the party back to [17:15] and closes the screen. - Item placed or flying object. Every item at [17:16] is moved to level 1 [29:15].
Graves
The graves at [17:04], [19:04], [16:06], [21:06] and [20:07] have wall reference
60 on all four sides. This
level maps references 60 and 61 to graves with
INF_WALL_SPECIAL_DECORATION_SCRIPT (InfWallSpecialType),
so activating a grave dispatches BLOCK_EVENT_WALL_DECORATION to that block's
script. All five scripts follow the same pattern:7
- If side 2 of the block already holds reference 61, show message 14: a desecrated grave. Nothing else happens.
- Otherwise call the digging question at offset 201. It clears level flag 7,
plays sound 55 and asks whether to dig (message 8, yes or no). Yes sets flag 7.
Then, if the party has a
CHARACTER_CLASS_CLERICor aCHARACTER_CLASS_PALADIN, that character protests (message 11) and the question is asked again; answering no this time clears flag 7. - If flag 7 is set,
SCRIPT_SET_BLOCK_WALLSchanges all four sides to reference 61 and bones are created in the block; then flag 7 is cleared.
| Grave | Items created (template, position) |
|---|---|
| [17:04] | femur 33 at 1, skull 32 at 0 |
| [19:04] | femur 33 at 0, femur 33 at 0, skull 32 at 1 |
| [16:06] | femur 33 at 3, femur 33 at 3, skull 32 at 2 |
| [21:06] | femur 33 at 1, femur 33 at 3 |
| [20:07] | femur 33 at 2 |
Two positions near the graves trigger a one-time remark by a member of a given
class, with sound 79: [16:05], a CHARACTER_CLASS_CLERIC (message 15, level
flag 2), and [20:06], a CHARACTER_CLASS_FIGHTER (message 16, level flag 3).
Sounds
A sound number selects an entry of the
sound-effect table,
which comes from the level's sound file: FOREST.ADL with sound driver 1,
FOREST.SND with drivers 2 and 3. The entries used by this level's
scripts:8
| Sound | Played by this level | FOREST.ADL | FOREST.SND | Also played by the game itself |
|---|---|---|---|---|
| 52 | The old woman appears | 103 | 16 | — |
| 53 | The stairway behind the bushes | 110 | 16 | At the start of the conversation with Calandra |
| 54 | The temple entrance | 113 | 16 | In the dream sequence that can replace a rest on level 3 |
| 55 | The digging question | 121 | 16 | At the start of the conversation with Shorn |
| 79 | The party members' remarks | 29 | 16 | With the warnings of spells, and when Aid is cast on a character who already has it |
With driver 1, the five numbers select five different programs of the ADL file. Programs 103, 110, 113 and 121 are tunes of six, two, seven and four voices, lasting 27.5, 0.8, 5.0 and 1.7 seconds; program 29 is a single note of 0.9 seconds (measured by running the driver's code, ADL). With drivers 2 and 3, the five numbers all start program 16 of the SND file: ten short notes falling from about 4,187 Hz to 1,329 Hz and back, 0.1 second in all. On the PC speaker it plays once; on the Tandy sound chip it is echoed twice, more quietly, 0.12 and 0.24 second later. The old woman, the stairway, the temple entrance, the digging question and the party's remarks therefore all sound alike with these drivers.9
Bindings
The bindings give each scripted block its enabled events and script. Blocks
whose flags are zero can still receive the events that need no enabling bit:
the step event ([00:00]), the timer event (its target) and
BLOCK_EVENT_WALL_DECORATION (activated walls).1
| Position | Enabled events | Script | Purpose |
|---|---|---|---|
| [00:00] | none (BLOCK_EVENT_STEP_COUNT) | 288 | Wolves, every 23rd move |
| [21:13] | none (BLOCK_EVENT_TIMER) | 319 | Wolves, on the timer |
| [19:10] | BLOCK_EVENT_PARTY_ENTER | 508 | The old woman |
| [12:11] | BLOCK_EVENT_PARTY_ENTER | 525 | The old woman |
| [15:10] | BLOCK_EVENT_PARTY_ENTER, BLOCK_EVENT_ITEM_PLACED, BLOCK_EVENT_FLYING_OBJECT | 379 | Temple entrance |
| [16:10] | BLOCK_EVENT_PARTY_ENTER | 372 | Temple entrance, east approach |
| [15:11] | BLOCK_EVENT_PARTY_ENTER | 365 | Temple entrance, south approach |
| [17:15] | BLOCK_EVENT_PARTY_ENTER | 542 | Hidden stairway, hint |
| [17:16] | BLOCK_EVENT_PARTY_ENTER, BLOCK_EVENT_ITEM_PLACED, BLOCK_EVENT_FLYING_OBJECT | 611 | Hidden stairway |
| [17:04] | none (BLOCK_EVENT_WALL_DECORATION) | 698 | Graves |
| [19:04] | none (BLOCK_EVENT_WALL_DECORATION) | 817 | Graves |
| [16:06] | none (BLOCK_EVENT_WALL_DECORATION) | 754 | Graves |
| [21:06] | none (BLOCK_EVENT_WALL_DECORATION) | 880 | Graves |
| [20:07] | none (BLOCK_EVENT_WALL_DECORATION) | 936 | Graves |
| [16:05] | BLOCK_EVENT_PARTY_ENTER | 985 | Graves, hint |
| [20:06] | BLOCK_EVENT_PARTY_ENTER | 1015 | Graves, hint |
Two subroutines are reached only by SCRIPT_CALL:
the old woman's dialogue at offset 2 and the grave-digging question at offset 201.
Level flags
| Bit | Set by | Cleared by | Meaning (descriptive) |
|---|---|---|---|
| 0 | [19:10], [12:11] | — | The old woman has appeared. |
| 1 | [17:15] | — | The stairway hint has been given. |
| 2 | [16:05] | — | The cleric's graveyard remark has been made. |
| 3 | [20:06] | — | The fighter's graveyard remark has been made. |
| 5 | [15:11] | [16:10]; refusing to enter after coming from the south | The party last approached the entrance from the south. |
| 6 | The old woman's guidance | The entrance script | The dialogue screen is already open on arrival. |
| 7 | A confirmed grave digging | The grave scripts, after use | Temporary answer of the digging question. |
Bit 5 is mirrored by the global flag
SCRIPT_GLOBAL_FLAG_DARKMOON_SOUTH_APPROACH.
Monster types
The level defines three monster types, 0 to 2, and one monster image, wolf
(WOLF.CPS, with no decoration file). Every monster of the level, placed at
the start or by a script, uses that image, and no type selects a decoration,
so the three types look the same. The game stores no name for a monster type;
the types are known by their number, their image and their properties:10
| Property (INF field) | Types 0 and 1 | Type 2 |
|---|---|---|
Armour class (armor_class) | 7 | 5 |
Hit chance (hit_chance) | 19 | 18 |
Level for saving throws (level) | 3 | 6 |
Hit points (hit_points_dice) | 2d8 + 2 | 6d8 |
| Melee attacks: count and damage | 1, 1d4 + 1 | 1, 2d4 |
MonsterCapabilityFlags | MONSTER_CAP_ALT_FRAME_TABLE | MONSTER_CAP_LARGE, MONSTER_CAP_ALT_FRAME_TABLE |
MonsterImmunityFlags | none | none |
Type flags (type_flags) | Hold Monster can affect it | Hold Monster can affect it |
Experience (experience) | 65 | 975 |
Occupancy class (occupancy_class) | 1 | 1 |
Attack and step sounds (sound_1, sound_2) | 37, 36 | 37, 36 |
| Ranged attacks | none | none |
Turn resistance, evasion (turn_resistance, damage_modifier) | −1, 0 | −1, 0 |
Types 0 and 1 are identical in every field. Type 2 has three times as many
hit dice and fifteen times the experience of the others, and
MONSTER_CAP_LARGE makes weapons roll their second damage profile against
it.
Sources
Locations refer to the game executable reference; the reference files are identified in the file inventory.