Skip to main content

Changing level

The world · Sublevels · Level records and level changes · SCRIPT_LOAD_LEVEL_OR_MONSTERS

In brief​

The game loads a level when a new game starts, when a saved game is loaded, and when a script asks for it. No wall, block flag or timer changes level by itself: stairs, pits and portals are all scripts. Before leaving a level, the game settles it and stores its walls, monsters and temporary walls in its level record; when the party comes back, that record replaces the map and the initial monsters.

Positions are written [XX:YY], column then row, both counted from 00; the block index is YY × 32 + XX.

The steps of a level change. A script asks for another level; the game settles the current level, with flying objects landing and doors finishing their move, writes its record to LEVELS.TMP, then loads the new level's INF file and sublevel. If a record exists for the new level, its walls, monsters and temporary walls come from it; otherwise the walls come from the map and the monsters from the INF file. In both cases the party is then placed.
A level met before comes back from its record; a new one from its files.

When the game loads a level​

The game loads a level in four situations:1

SituationLevel loadedParty position
A new party has been created, or an EOB I party transferredLevel 4, sublevel 0[11:05], facing south
A saved game is loaded from the start-up screenThe saved level and sublevelThe saved block and facing
A saved game is loaded during playThe saved level and sublevelThe saved block and facing
A script runs SCRIPT_LOAD_LEVEL_OR_MONSTERSThe level and sublevel it namesIts block, and its facing or the current one

The first two are decided when the game starts, by a selector that the start-up screen sets: zero after a party is created or transferred, nonzero after a saved game has been read. A load from the start-up screen restores the saved game but leaves the level to the start of the game; a load during play loads the level at once. No wall, block flag or timer changes level by itself: stairs, pits and portals are all scripts.

Level changes in the original levels​

The scripts of the original levels contain 143 level-change instructions. They fall into a few kinds, each with its own trigger; the figure of the world shows which levels they connect.2

KindInstructionsWhat triggers itWhere the party arrives
Stairs, ladders, forest exits50The party steps into the block facing the stairs (48). Facing another way, it gets a message and is moved back. Items dropped or thrown into the block are sent to the arrival block. The two exits of the forest ask the player to confirm instead.A fixed block and facing.
Pits73The party steps into an open pit (32), or a pit opens under it (41): moving pits driven by a timer on levels 11, 12 and 14, a lever on level 1, a trap during a conversation on level 13. Every fall but that trap deals 2d6 damage first.The current facing, in most cases at the same position below.
Portals12On levels 3, 6 and 14, the player activates the portal wall while holding a portal key; the key's value chooses the destination.A fixed block and facing.
Teleporters to the other sublevel2On level 11, the party steps into the block.A fixed block and facing.
Switch in place3On level 8, the party enters [12:14] the first time: a door closes, monsters move, and the level's second sublevel is loaded.The same block, facing south.
Scenes3A conversation on level 9, a scripted move on level 6, a wall puzzle on level 15.A fixed block; the facing is kept on level 15.

Four stairs, two on level 1 and two on level 6, also run the game's password check the first time one of them is taken on that level. The fall damage carries SCRIPT_DAMAGE_RING_NEGATES: a character wearing a ring of value 3 takes none.

Returning to a level​

The game keeps a record of each level the party has left in LEVELS.TMP: the level's walls, its monsters and its temporary walls. On a level change it first lets flying objects land and doors finish, then writes the current level's record and loads the new level. If the new level has a record, the map loader restores its walls, monsters and temporary walls from it instead of using the map and the level's initial monsters. The items lying in each block are rebuilt from the shared item table, and the level's scripts, cell bindings and timed events are read again from its INF file. Level records and level changes gives the full order and what each kind of state becomes.3

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references.

Footnotes​

  1. The INF level loader and its four callers: the new-game start, choose between a new game and the current level with the level start selector, the saved-game reader and the script command that loads a level. ↩

  2. Decoding of the scripts reachable from the cell bindings of the 16 INF files, with the instructions of the script virtual machine. ↩

  3. The script command that loads a level; settle the level; pack and unpack a level record; write a level record; read a LEVELS.TMP record; the map reader and rebuild the block item chains. ↩