- Updated the USECODE Tool Improvement Plan to focus on the map-viewer decompiler/editor, emphasizing its role as the primary development target for USECODE editing and recompilation. - Revised the tooling comparison document to include the newer map-viewer decompiler, clarifying its purpose and distinguishing it from the Python parser. - Introduced a new ClearAvatarInStasisProcessEntry structure in the entity dispatch entry header, along with related process creation and execution logic in the ProcessKernel. - Implemented the setItemShape method in LiveFixedMapItems to allow dynamic shape updates for items. - Enhanced the teleporter process to handle avatar stasis and integrated it into the game main loop, ensuring proper process management and state handling. - Added tests for the new functionality, including shape setting and teleporter process behavior, to ensure correctness and stability.
6.4 KiB
avatarStoleSomething (slot 0x13) in Crusader
Conclusion
The event name is inherited from Ultima's theft vocabulary, but Crusader's shipped usecode uses the slot mostly as an item-movement notification for environmental objects. The common handler records the passed item id in the running process's metadata under event type 0x022E, then excludes the process. The inspected handlers do not accuse the avatar, raise an alarm, start combat, or otherwise implement a crime response.
There are 23 non-empty slot-0x13 bodies in the inspected Remorse corpus and 18 in Regret. They belong mainly to electrical walls, shock objects, lights, sliding walls, doors, and a sliding floor, rather than dialogue-oriented NPC classes. Two Remorse MDOOR handlers launch a door-component cleanup path; SLIDEFLR waits for a frame transition and a specific sound state. This makes avatarStoleSomething a useful repurposed hook for world-object bookkeeping and synchronization, despite its theft-oriented name.
Native dispatch contract
Ghidra identifies Item_AvatarStoleSomething at 10a0:2fda as intrinsic 0x0B1. It checks whether the receiving item is an NPC; if so, it suppresses the event when that NPC is dead. Otherwise it calls Usecode_ItemCallEvent with mask 0x80000, slot UC_AvatarStoleSomething (0x13), and the supplied word argument. The native wrapper therefore establishes the receiver, liveness filter, and payload, but does not itself test ownership or decide whether a move is a theft.
The event signature is one word, and the Crusader handlers consistently treat it as an item reference. The corresponding ScummVM implementation describes the legacy outer trigger in Item::movedByPlayer: avatar-owned items are not stolen; otherwise, nearby living actors are notified with the moved item's id. That source helps explain the inherited label and dispatch convention, but it is cross-implementation evidence, not proof of every original NE movement call site.
ScummVM's item.h has a stale comment calling this event 14; its implementation and converter table use 0x13, matching the Remorse native dispatcher and the Crusader event table. Use 0x13 as the ordinal.
Corpus-wide pattern
Every one of the 41 inspected Remorse and Regret handlers executes set_info(0x022E, *(arg_06)) followed by process_exclude(). In the local VM model, opcode 0x77 routes those operands to process metadata as (eventType, sourceItem), and ProcessKernel::setProcessInfo stores those fields on the running process. The strongest supported reading is therefore that each callback tags its process with event type 0x022E and the item id that prompted the callback.
No get_info(0x022E) reads were found in the inspected usecode exports. Treat 0x022E as an opaque process-event tag; its higher-level consumer or meaning has not been established. In particular, the handlers do not show that this is a global theft flag or alarm state.
The broad classes and variant structure are consistent across both games:
- Remorse has 23 handlers: two WSHOCK, two EWALL, two ETWALL, eight L_* lights, two MDOOR, six SL_* sliding walls, and one SLIDEFLR.
- Regret has 18 handlers: two WSHOCK, two EWALL, eight L_* lights, and six SL_* sliding walls.
- Apart from MDOOR and SLIDEFLR, the handlers only set the process info and exclude the process; no speech, alarm, attack, or stolen-item punishment appears in their bodies.
Specialized handlers
MDOOR
MDOOR_E::avatarStoleSomething and MDOOR_N::avatarStoleSomething both store the moved-item id under 0x022E, exclude the current process, spawn DOOR.slot_22 with that item id, and suspend while the child process runs. The east variant also creates two helper items, shapes 0x02F1 and 0x04CE, at coordinates derived from the moved item before launching the door process; the north variant goes directly to the child process.
There is an extraction discrepancy worth preserving: the simplified Crusader_Decomp MDOOR_E pseudocode lists the helper locals but omits their create/position calls. Those calls are present in the Remorse site-data export and the raw Crusader usecode disassembly under MDOOR_E::AvatarStoleSomething. The helper-item detail above relies on those corroborating representations.
DOOR::ordinal22 (0A06:0022) records the passed item as process info type 0x0001, reads its QLo and QHi values, scans door/roof-related shape sets, and iterates shape 0x04F8 candidates. It destroys candidates whose QLo matches both values from the passed item. The class's loop metadata is only partly reconstructed, so the exact roles of every scanned shape remain uncertain; the verified behavior is a quality-keyed search and removal of matching door-associated pieces. This is a concrete environmental cleanup path, not a social theft reaction.
SLIDEFLR
SLIDEFLR::avatarStoleSomething first performs the common 0x022E process-info write. If the passed item is at frame 9, it polls every four ticks until the frame changes. It then polls every two ticks until sound effect 81 is playing for that item. The handler does not start the sound itself. Its visible role is to synchronize with an existing floor animation/audio transition.
Interpretation and limits
The most defensible Crusader-specific description is item-movement notification and environmental state coordination. The payload identifies the moved item; ordinary handlers record that identity, while the MDOOR and SLIDEFLR variants use it to coordinate related world pieces. The event name describes its inherited origin better than its present scripted effects.
This conclusion is about the authored handlers and the native per-receiver dispatcher. The exact condition that calls the dispatcher in the original executable is not established by this function alone. The ScummVM movement routine is useful corroboration for the legacy trigger, but should not be silently treated as a byte-for-byte native call-site proof.
Simplified explanation
Think of slot 0x13 as: “An item just moved; here is its id.” Most Crusader objects simply record that id. A few doors and floors use it to clean up or synchronize related pieces. In practice, it behaves more like an environmental update hook than a theft alarm.