Skip to main content

Scripts

Home · The engine in ten minutes · Script virtual machine · The levels

In brief​

Stairs, teleporters, secret walls, doors that close behind the party and conversations with the people the party meets are all driven by level scripts. Each level's INF file carries a block of script code and binds pieces of it to blocks of the map. When something happens in a bound block — the party steps in, an item is dropped or thrown into it, a wall is clicked, a timer expires — the game runs that block's script, provided the block is set to react to that kind of event. A script tests conditions, then changes the world, and runs to completion before the game continues.

Positions are written [XX:YY]: column XX and row YY, counted from 00, for block index YY × 32 + XX.

How level scripts work. An event reaches a block: party enters or leaves, item put down or taken, item used, flying object arrives, wall clicked, timer expires, step count reached, monster enters or leaves, spell cast. If the block has a script and accepts the event, a run starts at that script. The run tests conditions and executes commands until it stops; the commands change walls and doors, the party, monsters, items, characters and flags, messages, dialogues, sounds, another level. The run ends before the game goes on.
Every change a script makes starts from an event sent to a block.

What scripts can do​

The commands are grouped by what they change; each links to its instruction page for the exact encoding.

What changesCommandsPage
Walls and doorsSet or toggle walls; open, close or toggle a doorScripted walls and doors
The party, monsters, items, the levelMove, turn, change level; place or provoke a monster; create, remove, identify or drop itemsScripted movement, monsters and items
Characters, flags, what the player sees and hearsDamage, heal, award experience; set and clear flags; messages, dialogues, sounds, waits; launches, special events, sequencesScripted characters, flags and messages

The pages of this chapter​

PageWhat it covers
Events that start scriptsThe events, activating walls, keyboard and monster events, which events a block accepts.
How a script runsA run, conditions, what they test, scripts and the game's state.
Scripted walls and doorsSetting and toggling walls; door requests and their timing.
Scripted movement, monsters and itemsMoving and turning, changing level, monsters, items.
Scripted characters, flags and messagesCharacters, flags and resting, messages and dialogue, special events.
Script virtual machineThe encoding of the script language and its 30 instructions.

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references. Statements about the original levels come from decoding the scripts of the 16 reference INF files listed in the file inventory.