dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Scripting Interactions

Details on scripting interactions with MOBILE actors.

Collaboration diagram for Scripting Interactions:

Details on scripting interactions with MOBILE actors.

Interactions allow scripted mobiles to respond to player behavior. An interaction occurs when a player faces a scripted mobile and presses the OK button. This causes the script that mobile, or "actor", is running to jump to an interaction callback defined by the INTERACT (SCRIPT_CB_TABLE_1) instruction in that mobile's script.

The index of the interaction callback that will be called is determined by the MOBILE_ICOUNT_MASK portion of MOBILE::flags, and may be from 0 through 9. This allows a mobile to "say" one thing on first interaction and then different things on subsequent interactions.

Attention
On interaction, the script execution engine will automatically push the index of the next instruction that would have otherwise been executed to MOBILE::script_stack, so that it may be returned to with RETURN and SCRIPT_ARG_STACK or SCRIPT_ARG_STACK_I.

Interactions are automatically disabled when an interaction occurs. They can be re-enabled by calling the DISABLE (SCRIPT_CB_TABLE_23) instructions with the arg 0. This is typically done before calling RETURN (SCRIPT_CB_TABLE_7) to return to the main subroutine.

Attention
Interactions will NOT be processed when the last instruction executed was a DISABLE (SCRIPT_CB_TABLE_23) with an arg 0. This gives the engine the chance to get from re-enabling interactions to a potential RETURN (SCRIPT_CB_TABLE_7) instruction without another interaction occurring.
Todo:
Expand interactions to respond to e.g. combat actions or item use.