- Added initialization of startup processes in flex_archive_tests to ensure proper setup before teleporter operations. - Updated assertions to verify the correct allocation and state of processes during teleporter execution. - Introduced new tests in map_renderer_tests to validate shape rendering, including isolated shape rendering and player sprite integration. - Enhanced map_sorter_tests with additional checks for occlusion handling and boundary conditions in render order resolution.
12 KiB
Hypothetical Player-Usable Grenade Family
Status: Design sketch, not recovered retail code and not ready to compile
Targets: No Remorse shapes 0x034E (CONCUSSION GRENADE), 0x034F (NERVE GAS GRENADE), and 0x0350 (EMP GRENADE)
Design basis: The surviving Remorse GRENADE class (0x0343), not BLASTPAC or FUSPAC
Goal
Give all three removed grenade shapes separate player use paths while keeping the surviving old GRENADE behavior intact. Give each shape its own class record selected by the runtime shape selector, based on the surviving GRENADE callbacks, and add event-slot 0x01 handlers. Do not change the existing 0x0343 class until the new paths have been tested.
This separates three things that otherwise look deceptively similar:
- The retail name table preserves all three labels:
CONCUSSION GRENADE,NERVE GAS GRENADE, andEMP GRENADE. - Current map metadata marks all three as terrain and
invitem: false; the labels do not make them ordinary inventory objects. - The local Remorse USECODE indexes have a
GRENADEclass for0x0343, but no separate class/body for these three shapes.
Verified Base Behavior
The extracted Remorse GRENADE class is class id 0x0343 (entry 184). It has two non-empty common event bodies and no use body:
function grenade_hit()
{
set_info(0x020B, *(arg_06));
process_exclude();
return;
}
function grenade_gotHit()
{
set_info(0x020C, *(arg_06));
process_exclude();
return;
}
These bodies assign process-info values and exclude their current process. Preserve them byte-for-byte in the first copied-class experiment. Their downstream meaning is not fully established here; do not treat 0x020B or 0x020C as explosion-type constants.
The vending-machine evidence is creation, not player-use behavior. PEPSINS::use and PEPSIEW::use each have a random branch that attempts Item.legalCreateAtPoint(..., 0x0343, item); the scripts do not add a GRENADE::use event. The supplied enemy-use observation is consistent with a non-player producer, but the specific enemy creation path still needs an independently traced callsite before being treated as closed evidence.
References: removed-item investigation, GRENADE hit body, GRENADE gotHit body, PEPSINS use body, and PEPSIEW use body.
Proposed Class/Event Shape
Use the executable's regular-shape class selector to determine each shape's class id; do not assume an archive class id solely from the shape number. Each new class record should contain:
| Event slot | Proposed content |
|---|---|
0x01 (use) |
Variant-specific player-use wrapper described below. |
0x05 (hit) |
Copy the current GRENADE::hit body unchanged for the initial test. |
0x06 (gotHit) |
Copy the current GRENADE::gotHit body unchanged for the initial test. |
Create independent rows for 0x034E, 0x034F, and 0x0350; do not point all three selectors at one mutable class record. All other rows can remain absent unless testing shows a native caller requires them. Each class/event row is six bytes: retain its unknown leading word and write a valid code offset for each new body. The archive's class object index is derived from the class id; rebuild the class/event offsets and FLEX directory consistently.
Item_Use requests event 0x01. The native dispatcher first resolves the item's class selector, then checks the owner-row event capability bits before creating an event process. A body without the corresponding use capability will not run. The current format specification describes this dispatch model.
Specific Player-Use Handlers
These are source-level usecode sketches, not recovered or compilable retail bodies. Each is a distinct slot-0x01 event. They call a proposed GrenadeFx.playerUse native helper because the local corpus does not establish a complete script-level throw, fuse, area-target, and actor-status API. The helper and its ordinal do not exist yet; do not encode these calls as intrinsic 0x0017.
function concussion_grenade_use()
{
GrenadeFx.playerUse(this, GRENADE_KIND_CONCUSSION);
return;
}
function nerve_grenade_use()
{
GrenadeFx.playerUse(this, GRENADE_KIND_NERVE);
return;
}
function emp_grenade_use()
{
GrenadeFx.playerUse(this, GRENADE_KIND_EMP);
return;
}
GRENADE_KIND_* are proposed dispatch tags, not the exptype argument to Item::I_explode. Keep the kind-to-effect mapping out of the explosion-type field: the converter calls Item::I_explode(Item *, exptype, destroy_item) a hint, and the compatibility implementation uses that field for ordinary explosion presentation/damage scaling, not nerve or EMP semantics.
Shared Launch Contract
The proposed GrenadeFx.playerUse(item, kind) must:
- Resolve the controlled actor from the native
Item_Useevent context and confirm this exact item is in that actor's inventory. - Compute a facing/aim-based landing point and reject an illegal launch without consuming the item.
- Remove only this item from inventory, create one world projectile, and attach the existing-style fuse/impact lifecycle. Never call
Item::I_explodeon the inventory-resident item: the explosion must use the projectile's world position. - On impact or fuse expiry, dispatch exactly one variant effect below, then destroy the projectile. Failed launch leaves the inventory item untouched.
The launch/fuse routine is shared behavior; the target filters and detonation effects remain variant-specific. Usecode alone may be able to orchestrate part of this, but no verified Remorse implementation for the complete contract has been identified.
Variant Effects
| Shape | First-playtest behavior | Target policy |
|---|---|---|
0x034E Concussion |
Standard grenade blast damage, retaining the engine's ordinary hit reaction rather than adding a custom status. Use the normal Crusader explosion path (Item::explode(projectile, 0, true) in the compatibility implementation). |
Ordinary blast radius; affects any damageable actor in range, including the player. |
0x034F Nerve gas |
On impact, create a gas cloud for 6 seconds, pulsing once per second. Each pulse deals 2 damage and interrupts eligible actors. These are starting balance values, not recovered values. | Hostile human actors only. Exclude androids, the player, allies, and neutral humans. |
0x0350 EMP |
On impact, emit one pulse: 20 damage plus an 8-second inhibitor-like lock that interrupts attacks and prevents movement/attacks. These are starting balance values, not recovered values. | Hostile android actors only. Organic actors receive no EMP damage or lock. |
Nerve and EMP need target enumeration, hostility/species classification, and timed status effects. Implement those operations in a new native helper/process or prove an existing retail process can do them before assigning USECODE opcodes. Do not emulate a timed lock by setting an actor's activity once; that does not establish a persistent stun or a reliable recovery timer.
There is a useful but limited compatibility-runtime clue for EMP: ScummVM's Crusader Actor::receiveHitCru has a special interruption branch for hit types 0x0F and 7; it includes shape 899 (commented as Android), 0x338, 0x385, and 0x4E6, and can pause an attack process for a randomized 8-17 seconds. This supports testing an Android interruption effect, but it does not prove those values are the original retail inhibitor mechanic or cover every Android variant. Prefer a deterministic, explicitly reversible EMP lock for the first custom implementation, then compare its behavior with the original inhibitor if that executable path is recovered.
The standard Item::explode compatibility path applies ordinary splash damage through FireType 4; it has no Nerve-vs-EMP target filter. Thus only the concussion variant should use it unchanged. Reusing it for Nerve or EMP would also damage non-targets and would not create the requested status effects.
Work Required To Make It Usable In-Game
- Enable normal inventory treatment. Update the actual item/shape definitions so
0x034E,0x034F, and0x0350are carryable inventory bombs, not just terrain-shaped map objects. Check each inventory family, icon/frame, weight/stack behavior, and pickup flags. Update map metadata separately if the viewer should present them as inventory-capable. - Add three class records. Resolve the runtime-selected class id for each shape and create an independent record for each, preserving the existing
0x0343GRENADErecord. Copy the knownhitandgotHitrows as the first compatibility baseline. - Add event
0x01to each class. Write the three variant-specific wrapper bodies, fix each class-local code offset/body bound, and ensure every loaded owner row advertises theusecapability bit. Preserve each unknown event-row word unless its meaning is established. - Implement the shared native launch helper. Add and register
GrenadeFx.playerUse(item, kind)or prove an existing helper has the required contract. Verify event actor context, inventory transfer, legal launch, projectile ownership, fuse timing, single consumption, and cancellation behavior. Assign an intrinsic ordinal only after checking the target build's table and ABI. - Implement and tune the three effects. Keep concussion on the normal blast path. Add human-hostile filtering and timed gas damage for Nerve, and android-hostile filtering plus a reversible inhibitor-like lock for EMP. Validate the actor taxonomy against the complete target executable; the trial damage values/durations above are gameplay knobs.
- Expose each item to the player. Add all three through a legitimate inventory/loadout/map source and test ordinary pickup. Forced pickup alone does not test the
invitem/inventory configuration. - Rebuild and validate a disposable game copy. Check pickup, inventory rendering/name, one-use behavior, each target filter, player/friendly/neutral exclusions, damage/status expiry, collision callbacks, blocked launch, save/load, and that legacy vending/enemy uses of
0x0343remain unchanged.
The repository's current USECODE tooling does not yet provide a complete compiler and archive writer. The source-level handler and class-record sketches cannot be installed by editing pseudocode alone; implementing the new native helper also requires rebuilding the native executable. A lossless USECODE assembler/rebuilder and a carefully validated executable patch workflow are required. See the round-trip roadmap.
Confidence Summary
- Verified:
GRENADEis class0x0343; onlyhitandgotHithave bodies; both set process info and exclude the process; Pepsi vending scripts create shape0x0343on a branch; the retail name table preserves the three removed grenade names; current map metadata marks all three as non-inventory terrain. - Supported design choice, not proven: separate class records with copied
hit/gotHitand newuseevents are the least invasive way to preserve the old0x0343behavior while adding three player items. - Hypothetical: the
GrenadeFx.playerUseAPI, launch/fuse path, Nerve target filter and gas status, EMP Android classifier and inhibitor-like lock, and all first-playtest balance values. NormalItem::I_explodeis a candidate only for the concussion variant; verify its exact behavior against the target retail build before installing.