Persistent visitor body sprites#
BOUNCE and scripted WALK bodies consume a visitor-owned body player, rather than an animation step computed from ride elapsed time. This implements a bounded part of HEADS-007. It does not establish original rendered equivalence or retire that register entry.
Program and wrapper rules#
VisitorSpritePlayer has an active/requested template, a current program, the next FRAME index, a signed 32-bit due timestamp, an interval and an optional last emitted (slot, frame). The next-FRAME cursor is a normalized representation of the decoded programs, not a raw original program counter.
Creation uses interval 62 ms and unchecked
due = now + 62. There is no visible output before the first FRAME.A scheduler opportunity emits at most one frame, only when signed
now > due. Equality does nothing. After emission, due becomesnow + interval, with signed 32-bit wrap; missed intervals are not replayed.Templates 1 and 2 loop frames 0–7 in walk and run slots 1 and 2. Template 3 loops stand slot 0/frame 0. These reuse
StaffScriptsdata without changing the staff player.Template 4 emits
[0,0,1,1]four times in slot 14. Templates 5, 6, 7 and 8 emit frames 0–3 in slots 12, 11, 6 and 4 respectively. These finite prefixes jump to stand. The jump changes the execution program, not the active/requested identity, so a matching body request does not replay a completed cheer.Applying a template restarts its cursor but preserves interval, due and last output. Applying an interval does not move an existing due timestamp; zero means no change.
VisitorSpriteState separately owns the optional player and pending template/interval. Guest begin-turn applies template then interval and clears the requests, even when the player is absent. State-entry requests are unconditional. The walk caller compares the active template only. Body-pose requests compare active or pending; matching the active template does not cancel a different pending request. Deleting a player preserves wrapper requests. Only a new person/full teardown resets the wrapper.
The decoded anchors are creation 0x4758F0, scheduler 0x475360, FRAME 0x476940, request 0x4F9E60, pending application 0x4D4190, state entry 0x501DB0, navigation caller 0x4FA2A0 and deletion 0x4D4170.
Host phases and lifetime#
The original scheduler is called on even 31 ms substeps before the guest turn, and samples its own timer. OpenTPW keeps its established fixed-60Hz host clock: a running tick samples floor((parkTick + 1) * 1000 / 60) milliseconds, reduced to signed 32 bits. Its even-substep opportunities run after object/tour work and before a pooled guest sweep. Headless calls use the same path. This is an explicit clock approximation: native catch-up opportunities can sample the same timer, whereas separate host ticks have separate deterministic samples. The non-pooled fallback retains its previous guest-before-object order and therefore does not claim native scheduler-before-guest ordering.
After each positive-elapsed, unpaused AdvanceSimulation batch, a single shared pose phase processes BOUNCE then scripted WALK. It positions bodies, queues requests or performs decoded explicit hides; it neither advances a player nor applies pending requests. Zero elapsed (including HUD/scene pause) skips that phase. Rendering zero, one or two times only reads the cached poses. A hidden renderer does not stop the scheduler. A lost park continues eligible body scheduling and pose calls while skipped guest turns do not apply pending requests. Direct calls to GuestSimulation.Tick alone are guest updates, not a replacement host scheduler.
Ownership begins at guest creation, before any ride. Existing integer navigation results feed walk requests only for WalkResult.Walking, with no second step or random draw. The run predicate is unsigned ToiletBonus > 0. Integer delta squares/addition remain unchecked int32, followed by square root, multiplication by the original float constant and a float rounding before doubling for walk. The final 62/speed quotient is widened before truncation, matching the lack of a float store before the original ftol call. Negative squared distance/nonfinite or nonpositive speed produces a zero/no-change request as an explicit defensive host policy; it is not a newly established original overflow rule.
Explicit semantic hooks cover ordinary state entry, activity/queue interludes, guard capture and set-down, boarding, release and attraction removal. Temporary placement state writes, such as ReturnToPath, do not replay state-entry effects. Boarding uses the inherited UsageInfo.RideHandlesSprite: retain and queue stand, or delete. A retained body stays in view through the use, whatever the object (shop, sideshow, toilet or ride): the walk and bounce poses draw it where the script moves it, and otherwise it stands where it was last placed (docs/GUESTS.md, "Kept bodies"). All four shipped bounce rides retain the existing player. BOUNCE insertion or a missing bounce node does not reset/delete it. Scripted hidden WALK actions 1, 2 and 4 delete; a later hide also removes an earlier BOUNCE pose for the same body. Unknown actions and missing nodes do not invent deletion.
Release effects run in their existing order. A retained body queues walk and keeps its copied appearance category. A missing body is created after effects and copies the person's then-current category. Kid/costume rendering chooses exactly one consumer for this body. Host bank/variation selection remains the existing approximation and takes no additional world-random draws.
Saves, tests and remaining boundaries#
Optional guest presentation fields save player, output, cursor, pending requests, copied category and reconstruction status together with the host clock epoch. The copied-category and reconstruction booleans default to false when absent; these are OpenTPW presentation additions, not decoded original save fields. Validation rejects unsupported programs, impossible cursor/output/interval values and partial history without its epoch. Loading preserves absolute due times. Older own-format saves and original-save imports cannot restore this shared history: they explicitly reconstruct a fresh player at the load epoch, with interval 62 and no emitted frame, or preserve an absent-body state. Bounce start time is never used to reconstruct it.
Only the new presentation fields stay outside the existing gameplay hashes. State, movement, ride walker state and RNG remain hashed as before. WALK heading was already presentation-only, neither saved nor hashed; moving its update to the shared pose phase does not expand hash exclusions.
VisitorSpriteStateTests and VisitorSpriteIntegrationTests use synthetic programs, clock samples, guests, bridges and a synthetic CPU model. They cover strict due/wrap, finite transitions, request ordering, lifetime, copied appearance, hidden/missing poses, host batching/pause/lost paths, read-only render consumption, save validation and gameplay/hash/RNG controls. They are not captures of the original executable.
HEADS-007 remains bounded by current host inputs: queue move-up still lacks the original ToiletBonus reset, and queue interludes do not fully represent the original saved activity state. This change does not alter those gameplay decisions. The wrapper/slot/program/clock history of an imported guest comes from the Scripts block's sprite record (SAVE-013, SavedSpriteScripts.Visitor: the program position, the next frame, the interval and the due time rebased onto the host clock), a guest with no handle has no player, and a record the bounded player cannot represent is rebuilt fresh and noted in the import evidence; a rider is posed from the saved bounce and walk entries of its ride (SAVE-002). swimming and generic teleport/control callbacks are outside the proved history. Scripted WALK consumes the last emitted frame in the existing host pose phase, including initial invisibility, preserved output during queued template changes and finite-program stand tails. Provider-free geometry helpers retain their elapsed-time fallback. This does not change WALK movement, terrain height handling or the host clock approximation. Ordinary walking frame selection retains its previous rendering; staff retains its existing scheduler. Those independent approximations need separate work.
Source: docs/VISITOR-SPRITES.md in the project repository.