Skip to main content

Monsters in the view

The dungeon view · Spots and wall decorations · Monsters

In brief​

Monsters are drawn in the 15 blocks ahead of the party, up to five per block, far spots first. The frame comes from a table indexed by the animation step, the party's facing and the monster's facing: from the front, from behind, or from a side, mirrored on one side. Decorations follow the monster, a damaged monster flashes in one colour, and a petrified one is drawn in another.

For a party facing north, at animation step 0 of the normal frame table: a monster facing north, away from the party, shows frame 4; facing east, frame 2 mirrored; facing south, towards the party, frame 1; facing west, frame 3. Reading frame 1 as the front view, 4 as the back and 2 and 3 as the sides is inferred from the frame tables.
The frame depends on how the monster faces compared with the party.

Drawing a monster​

Monsters are drawn for the 15 blocks ahead of the party. Up to five share a block, one per spot; they are drawn far spots first and the centre last. A monster whose type has MONSTER_CAP_HIDDEN is skipped unless MONSTER_RUNTIME_REVEALED is set on it or the party has SPELL_EFFECT_DETECT_INVISIBLE or SPELL_EFFECT_TRUE_SEEING (SpellEffectFlags, MonsterCapabilityFlags, MonsterRuntimeFlags).

steps = 2, 1 or 0 for three, two or one step ahead
table = alternate if MONSTER_CAP_ALT_FRAME_TABLE else normal
f = table[anim_step × 16 + party_facing × 4 + monster_facing]
if steps == 0 and the monster is attacking: f = attack counter + 7 # frames 5 and 6
spot = centre if position 4 else spot of the position
x = 88 + spot_x; y = 127 + spot_y
if the monster type's occupancy class is 1:
if |f| is 1 or 4 or more: y = 127 + far-left spot y + lift[steps]
else: x = 88 + centre spot x
shape = monster frame |f| reduced `steps` times, mirrored if f < 0
x = x − 4 × width + (idle_offset >> 4); y = y − height + (idle_offset & 15)

lift is 20, 12 and 4 at the centre and 4, 2 and 0 elsewhere, for 0, 1 and 2 steps. The normal frame table starts as follows:

Animation stepParty facingMonster facing northeastsouthwest
0north4−213
0east34−21
1north4−312

The pattern rotates with the party's facing. Frame 1 is shown when the monster faces the party, frame 4 when it faces away and frames 2 and 3 from the side, mirrored on one side; what each frame shows is inferred from the frame tables. The alternate table instead mirrors the front and back views on every other animation step. Each decoration of a monster (its DCR data, entry f of each group the type selects; see monster images) is drawn at the monster's position plus its offset, the offset being multiplied by 2/3 for each scale step.

The drawing looks at a block's occupants, not at its walls. A monster that a script has placed inside a block with walls on every side is drawn like any other, at its spot and scale, over the walls already in the view. The block's own front face does not clip it, except in the outer blocks 00, 06, 07 and 11, whose objects are hidden by any front wall in the view but that of block 16, their own included.1

The lookup does not limit the monster's facing. A script that moves monsters gives each one its position as its facing, so a monster on position 4 gets a facing of 4; the scripts of levels 7, 8 and 9 move monsters placed there. The lookup then reads the entry after the row, which is the first of the next row, and the monster shows that frame until its facing changes:2

TableAnimation stepParty facing northeastsouthwest
Normal031−24
Normal121−30
Alternate031−2−4
Alternate12−1−34

Anomaly

ANOMALY-156 — A facing of 4 can read past the frame table. With the normal table, animation step 1 and the party facing west, the lookup reads the first byte after the table, 0, and there is no frame 0: the body shape comes from the entry before the monster's first shape. For a monster of graphics slot 1 that is the last of the 18 entries of slot 0, which is always empty, so the monster is drawn as a released shape. For graphics slot 0 it is a far pointer made of the two words before the shape table, the second one being the block of the current event, so the driver is given a meaningless address (inferred: stray pixels or none). Whether this happens in play is not established. The facing comes from ANOMALY-25. A faithful reimplementation may draw nothing for frame 0.

A monster damaged in view is drawn once with every nonzero colour replaced by colour 15: its flash draws the view while the monster has MONSTER_RUNTIME_REVEALED, then clears it. A monster with MONSTER_RUNTIME_TURNED_TO_STONE is always drawn with colour 13 instead. Its decorations are drawn the same way. Either table replaces the monster's colour variant. The result is a flat silhouette in one colour (inferred: what colours 15 and 13 look like depends on the palette in use).3

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references. The figures are drawn from the values listed on these pages, with no game graphics, by make_view_figures.py.

Footnotes​

  1. Draw the objects of the visible blocks, which tests only the block's occupant count before the monster drawing, clip a block's objects and its clipping tables. ↩

  2. Draw the monsters of a visible block, its frame tables, the monster shapes and the handler for 0xfa. The scripts come from decoding the 16 INF files of the file inventory. ↩

  3. Draw a monster shape, with the two colour tables it installs through driver slot 11 (DS:0x23a8, DS:0x23b8; the drivers' replacement colour table: VGA, EGA), the colour variant tables and the flash of a damaged monster. ↩