Skip to main content

The engine in ten minutes

Home · The engine · Glossary

In brief​

This page follows the program from the moment it starts to the moment it returns to DOS, and points at the chapter that explains each step. It states nothing that the chapters do not; read it first, then follow the links.

Starting the program​

The introduction plays, then the start menu appears. It loads a saved game, starts a new party, transfers a party from Eye of the Beholder I, replays the introduction or exits to DOS; see the start menu.

A new party is made of four characters, each with a race, a class, an alignment, rolled attributes and a portrait. When the player chooses to play, each character gets food, starting items chosen by class and, for a mage, nine known spells; see creating the party. A new game then loads level 4, sublevel 0, and places the party at [11:05] facing south; see level 4.

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

Loading a level​

A level is a grid of 32 × 32 blocks. The game reads the level's INF file, decodes its container and selects a sublevel record, which names the map and the graphics, palette and sounds to load. The map gives each block its four walls; the INF file gives the doors, the kinds of monsters, the wall properties, the scripts and the events each block accepts. The items do not come from the level files: the game keeps every item of every level in one table for the whole game. When the party comes back to a level, its walls and monsters come from the level record stored when it left. See loading a level and, for the files themselves, from files to the game.

The loop​

The game then runs one loop as fast as it can. Each pass checks that someone in the party can still act, reads the player's input, runs every timed update that is due (flying objects, monster groups, character timers, doors, food), redraws the view once if anything changed and plays the pending sound; see the game loop. Time is counted in ticks of about 55 ms, and it stops while the camp menu is open; see the game clock and timed updates.

A step forward​

When the player steps, the game looks at the wall of the block ahead that faces the party. If that wall lets the party pass and no monster stands there, the party moves; see moving the party. Leaving one block and entering the next send block events: a block with a script that accepts the event runs it at once, and the script can open doors, give messages, place monsters or move the party; see how the systems connect and scripts. After the move, monsters may notice the party.

Monsters and combat​

A monster does not see the party: it remembers a destination block. Once it has noticed the party, it tries a ranged attack, then a melee attack, and moves only if it could do neither; see monsters. A character attacks with the item in one hand: a roll of a twenty-sided die decides the hit, and the damage is then reduced by the monster's saving throw, evasion and immunities; see combat. Spells are memorized while resting and cast from the spell book; see magic.

The camp, and saved games​

The camp menu stops the clock. There the party rests, which moves the clock forward hour by hour, memorizes spells, and saves or loads a game; see resting. A saved game is a snapshot of the whole adventure: the characters, the party's position, every item, the script flags, the options and one record per level visited; see saving and restoring.

Changing level​

Scripts move the party to another level. Before leaving, the game settles the level, so objects in flight land or vanish and doors finish moving, and stores its walls, monsters and temporary walls in its level record; then it loads the new level; see changing level.

The end​

The program returns to DOS when the player exits from the camp menu, when a defeated party does not load a game, after the ending, or on an error. Killing the second form of the final opponent on level 16 writes FINAL.SAV and plays the ending; see how the game ends.

Where to go next​

To understandRead
The loop, time and eventsThe engine
Levels, walls and doorsThe world
Characters, resting, creationThe party
Monsters and fightsMonsters, combat
Items and spellsItems, magic
Level scriptsScripts, the levels
What the player seesThe dungeon view, the interface
The filesFrom files to the game
Terms used everywhereGlossary

Sources​

This page summarizes the chapters it links to, where each statement has its sources.