aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


docs/npc-respawn.md (6615B)


Creature respawn

The exact-level Leet profiles (MonsterData 17655, levels 1 and 2) respawn 100 seconds after death. This delay is provisional. It is an explicit reconstruction value, not a verified 14.9.1 Leet timer or an interpretation of district time units. Unlisted creatures have no respawn policy.

Evidence and limits

The original district resources contain respawn chance and time fields, as described in game data. District and fixed-spawn time fields have different widths. Their units and selection rules remain unresolved; the runtime does not convert either field into a timer.

A bounded online search for backyard/Leet respawn observations did not establish a 14.9.1 delay. The January 2004 spawn discussion distinguishes fixed and probabilistic named-creature schedules. It concerns other creatures after the target version and cannot establish this Leet's delay, chance or clock origin. A dated capture identifying the creature, death/despawn times and subsequent spawn is still needed.

The current policy is deterministic: one replacement, with the delay measured from the authoritative killing blow. It does not implement chance rolls, district population refill, alternate species or a timer starting at corpse removal. The 250 ms world tick may delay publication until its next visit.

Lifecycle and identities

The death transition queues one pending respawn when the profile has a nonzero respawn_seconds. Repeated combat ticks cannot queue another death for that life. The pending queue is protected by the normal update/state lock order. It advances even without connected observers and is processed before roaming and combat in the world tick.

Each replacement receives a fresh character identity and the same definition. Its profile is resolved again from that definition's species evidence and the selected MonsterData/level; a cached profile is not copied to an unresolved identity. It starts at full health with empty combat/recharge state. A roaming creature returns to its authored home with a fresh roaming state. Its entry in the roaming roster is replaced or recreated if the corpse has already expired, so successive deaths do not add roaming workers. Fixed creatures remain at their fixed post. Normal interest handling sends the new actor before its native weapon profile, only to eligible nearby observers.

The replacement retains its selected level. Population groups preserve their authored inclusive levels range; the initial placement allocation is described in game data. Persisted lives and their pending replacements do not reroll or collapse to the range minimum during restart. This level retention is a reconstruction policy, not recovered historical evidence for whether the original server rerolled replacements.

The previous corpse retains its original identity and contents. An open loot window remains attached to that corpse; requests using the dead actor cannot attack the replacement. Taking an old item uses the existing durable inventory transfer, and repeating that request cannot manufacture a new drop. Corpse expiration uses the profile's independent provisional 180-second lifetime; see corpse expiry.

NPC lives, corpses and pending timers are stored in SQLite. A replacement's creation, retirement of its source's pending deadline and reservation of its fresh identity commit together before the new actor reaches clients. A failed transaction retains the pending deadline for retry and publishes nothing. Restart loads the committed replacement and cannot replay the consumed timer. This significant transition saves immediately; routine movement still uses periodic checkpoints.

If the source corpse is still present, its identity, contents and loot rights remain intact. If it has expired, the transaction removes its remaining item ownership and contents along with the source. A backpack already transferred to a player retains its contents. The cleanup also works when a checkpoint has already removed the expired loot.

Verification

server/respawn_test.go covers the exact deadline, repeated and concurrent ticks, two successive kills, old loot after replacement, fresh home/resources and combat state, identical owner/observer spawn packets, observer-free respawning, interest reentry, restart and exclusion of unprofiled creatures.

server/respawn_durability_test.go reads SQLite during the first outgoing actor packet to verify that the replacement, consumed timer and identity reservation are already committed. It covers failures in the source update, replacement character/NPC writes, identity reservation and commit; repeated failure and retry; expiry before and after a checkpoint; filled-container cleanup; preserved transferred backpacks; and rollback of failed item/source deletion.

Two published WASM clients also exercised the SQLite failure/retry path on the normal HTTPS preview. A trigger rejected only the fixture's replacement for multiple ticks after its normal 100-second deadline; no actor was published. Removing the trigger produced one replacement, ID 1068610, at 100 HP. A SQLite read during the first received actor frame found that life committed, the old deadline cleared and the allocator at 1068611. Both clients saw that same idle life; repeating the attack key after death left it unharmed and ammunition at 17. An ungraceful server stop followed by reconnect retained the same identity and full health without another replacement. Both runs had no page errors. The original fixture profiles, NPC, items and placements were restored. Evidence is in local/respawn-durability-research/.

Two published WASM clients exercised two full-health kills with the existing QL 1 Kinetic Axe and two timed replacements. The live identities progressed from 1000000 to 1068609 to 1068610; each replacement started at 100 HP without attacking until a new request. Both observers saw the new living creature and the old remains. The first corpse's window stayed open across respawn, and its fixture item transferred once afterward. That item remained in the native inventory after page reconnect and server restart. That earlier run exercised the runtime lifecycle before SQLite NPC persistence. There were no page errors; connection-refused logs occurred during the intentional restart. Screenshots, per-step states and the isolated fixture are retained in local/respawn-smoke/.