Skip to main content

Run a sequence

SCRIPT_RUN_SEQUENCE · opcode 0xe6 · 2 bytes

Script virtual machine · Opcode list · Scripted sequences

Starts one of the game's built-in sequences: a conversation with a character who may join the party, the portal animation, or the copy-protection question.

Encoding​

The instruction is two bytes: the opcode and a signed ScriptSequenceSelector byte.

OffsetTypeFieldMeaning
0u8opcode0xe6
1s8sequenceSelector, sign-extended before the call.
SelectorSigned valueInstruction bytes
SCRIPT_SEQUENCE_PORTAL−2e6 fe
SCRIPT_SEQUENCE_PASSWORD_CHECK−1e6 ff
SCRIPT_SEQUENCE_NPC_INSAL0e6 00
SCRIPT_SEQUENCE_NPC_CALANDRA1e6 01
SCRIPT_SEQUENCE_NPC_SHORN2e6 02

An editor should preserve an unrecognized selector byte as found.

Behavior​

The handler passes the selector to a sequence dispatcher. The script continues with the next instruction only if the sequence returns. A sequence can start a dialogue, play an animation or ask for a protection answer. Before any sequence, the dispatcher closes the inventory panel and the spell book and redraws the scene. Afterwards it makes the message area the active text window. The portal path also restores the selected inventory slot.1

Conversations with characters​

The three character selectors share a presentation: they load the OUTTAKE picture, draw the character's figure over the dungeon view, run a dialogue with two answer buttons, then restore the play field. The figure is one of three cut from OUTTAKE — 40 × 57 pixels for Insal, 40 × 79 for Calandra, 48 × 43 for Shorn — centred on the 176-pixel view and standing on row 104. The selector names reflect the character presets used by the recruitment routine. The button labels are strings of the executable.2

SelectorFirst answerSecond answer
SCRIPT_SEQUENCE_NPC_INSAL"yes": accept recruitment; SCRIPT_GLOBAL_FLAG_INSAL_JOINED is set."no": refuse recruitment; the flag is not set.
SCRIPT_SEQUENCE_NPC_CALANDRA"talk": a recruitment dialogue is offered."leave": set SCRIPT_GLOBAL_FLAG_5_UNKNOWN.
SCRIPT_SEQUENCE_NPC_SHORN"release him": at random, either entry 9 of TEXT.DAT with an "OK" button or a recruitment dialogue; then set SCRIPT_GLOBAL_FLAG_SHORN_RELEASED."leave": set the party's direction to the direction value zero.

For Insal, the two answers are those of the recruitment dialogue itself, whose buttons read "yes" and "no" for every character. For Calandra and Shorn, they are the answers of an earlier dialogue, whose text is entry 4 or 8 of TEXT.DAT. On Shorn's path the flag is set after either random outcome, even if recruitment is declined. The flags belong to ScriptGlobalFlags: Shorn's stops his scripts on level 2 and Insal's is tested on level 15; Calandra's has no known reader, so its effect is unknown.2

Joining a full party​

When recruitment is accepted, the game counts the occupied character slots. If all six are occupied, the player chooses an existing character to remove, or cancels. Cancelling prevents the new character from joining; otherwise the chosen character is removed first. With a free slot, there is no such choice. Accepting and joining are distinct: for SCRIPT_SEQUENCE_NPC_INSAL, the global flag is set even when the replacement choice is cancelled.3

Before the new character is set up, the recruitment path removes matching items from the eligible members' inventories and, in one control state, from the hand; the match uses an item type and a value derived from the character's preset. A removed character's inventory, including the separate inventory item chain, is dropped in the party's current block. The new character is created from a preset, with copies of its nonempty initial inventory entries; the full steps are under recruiting and dismissing characters.3

Portal animation​

SCRIPT_SEQUENCE_PORTAL first releases the level's door, monster and decoration shapes, as the end of the game does, then plays a timed, sound-accompanied animation from the PORTALA and PORTALB pictures, driven by a sequence of frame pairs, releases its temporary graphics and returns. The animation opens with two sounds; the dungeon view is copied to work page 2, four portal shapes are drawn over it, and that 144 × 104 area at (24, 0) is brought onto the screen with the pixel dissolve; after a pause of 30 ticks the frame pairs are drawn directly on the screen. It does not change level and does not load the released shapes again; only the level change that follows reloads them.4

In the three reference scripts that use it, on levels 3, 6 and 14, the sequence runs only when the item in hand is of type 37, and the script then tests the item's value and changes level accordingly: value 1 leads to level 6 from level 3 and to level 3 from levels 6 and 14, value 2 to level 14, or to level 6 from level 14, value 4 to level 16, and on level 6 value 0 to level 6 itself.4

Without a level change​

For any other value, 3 and 5 among them, the script stops without changing level, and the level goes on with its door, monster and decoration shapes released until the next level load reads them again. The view is then drawn without doors, door switches, wall decorations or monster decorations, because the drawing routines skip a released shape; walls, items and flying objects are drawn as usual. A monster one step ahead is not drawn either. A monster two or three steps ahead is drawn from the first bytes of memory instead of its picture (the resulting image is inferred: what that memory holds is unknown), an anomaly of the monster drawing; see released shapes.

This cannot happen with the original data. The game's data provide three items of type 37: a Stone Gem of value 1 lying on level 3, a Stone Dagger of value 2 on level 13, and a Stone Cross of value 4 that a script of level 16 creates. ITEM.DAT also holds a Stone Sphere of value 3 and a Stone Necklace of value 5, but only as template items, which no script, monster or other routine of the game copies. Every portal reached in play is therefore followed by a level change.5

Protection check​

SCRIPT_SEQUENCE_PASSWORD_CHECK asks the player for the answer to a randomly selected question and compares the input, after removing trailing spaces, with the expected answer. A correct answer restores the display and returns; after three wrong answers the DOS program exits. Input cancellation and answer normalization are not fully established.6

Other selector values​

Values not named by ScriptSequenceSelector enter the common presentation of the character sequences: they load the conversation picture and texts and save and restore the view, but draw no figure and run no dialogue; the play screen is then rebuilt.1

Observed use​

The reference scripts use SCRIPT_SEQUENCE_PASSWORD_CHECK 4 times, SCRIPT_SEQUENCE_PORTAL 3 times and each character selector once.

Sources​

Footnotes​

  1. Handler for 0xe6 and the overlay sequence dispatcher. Comparative source: oeob_sequence in REF-SCUMM-003. Statistics come from decoding the scripts reachable in the 16 reference INF files. ↩ ↩2

  2. Overlay routines for the character sequence, its figure, which cuts and draws one of the three, the three character dialogues, the choice menu and the global flags. Comparative source: DarkMoonEngine::runNpcDialogue and EoBCoreEngine::npcSequence in REF-SCUMM-009. ↩ ↩2

  3. Overlay routines for the shared join, making room and character setup; resident routines for the inventory search, item deletion and character removal. Comparative source: npcJoinDialogue, prepareForNewPartyMember, removeCharacterFromParty and initNpc in REF-SCUMM-009. ↩ ↩2

  4. Overlay portal animation, which calls the overlay routines that release the door shapes, the monster shapes and the decoration shapes. The scripts come from decoding the reference INF files. Comparative source: EoBCoreEngine::seq_portal in REF-SCUMM-009. ↩ ↩2

  5. The shape drawing routines, the drawing of doors, wall decorations, monsters and their decorations, the shape reduction. The items come from ITEM.DAT, the decoded reference INF files (scripts, monster drops and monster ranged weapons) and the callers of the item duplication, among them the party transfer filter. ↩

  6. Overlay password check and the process exit. Comparative source: EoBCoreEngine::checkPassword in REF-SCUMM-009. ↩