aorecomp

Anarchy Online classic in the browser

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


docs/nano-periodic-damage.md (9098B)


Template-driven periodic nano damage

Ordinary hostile single-Hit programs share the direct-damage contract reader and the existing cast, requirement, reservation and NPC outcome paths. The template supplies the Hit arguments, count, interval, lifetime, strain, NCU priority, range, cost and casting/recharge times. No spell identity selects damage constants or a scheduling branch.

The original-record census admits 60 complete programs and 59 ordinary single-program crystals. These include Doctor, Nano-Technician and Agent programs. Attack/defence dictionaries and their default entries are read independently of serialized entry order. Unknown effects and unsupported selectors remain rejected as complete contracts; supporting Hit alone does not grant the Hit portion of a mixed, unfinished spell.

Tick and lifetime mechanics

One scheduler selects due ticks in deadline order within each recipient. Each tick uses the original negative HP Hit range and damage type. It advances the authored count and deadline, rather than estimating the count from elapsed duration. Independent strains keep separate clocks. Same-strain refresh and stronger replacement create a fresh count and phase; weaker replacement is rejected through the shared strain-priority check. Hostile programs consume no NCU, including during replacement.

Prototype Biotoxin 43376 describes eight 3-point poison hits at 750 centiseconds within a 6,000-centisecond lifetime. Hidden Killer 81939 instead describes nine 17-point melee hits at 450 centiseconds within 4,500 centiseconds. Its last scheduled tick precedes icon expiry by 450 centiseconds. Tick count and effect lifetime therefore remain separate state. The admitted complete sequence must fit within the lifetime; contracts that would outlive it remain unverified.

The scheduler stages all overdue ticks for one target and commits their HP, tick progress, damage contributions and any death/reward in one transaction. Only then are damage packets published. A failed required write or COMMIT keeps live state and pending ticks unchanged. Retry applies that batch once. Lethal damage clamps to the target's remaining HP, clears all active effects and joins the existing corpse, loot, respawn and reward handling.

active_nanos stores remaining lifetime, remaining tick count and signed time to the next tick. A negative next-tick delay preserves an overdue visit, including when a checkpoint happened after lifetime expiry but before damage was processed. NPC ticks continue after load and with an offline caster; an offline caster is not restarted as the NPC's combat target. In-memory timers cause no writes between ticks. Significant tick outcomes save immediately; other simulation state retains its periodic checkpoint cadence.

Original client delivery and reconstruction limits

CharacterAction 177 installs the native active record and icon. Damage is sent separately through HealthDamage; explicit 65 removes the finished effect. The original Hit53002 executor is gated out before its timing branch, and its otherwise unreachable handler is a stub. The client cannot supply periodic HP damage from 177 alone.

The original generic function queue loads count and clears elapsed time on installation. Admitted function visitors add 200 centiseconds before comparing the interval, under a nominal two-second character pulse. Refresh removes matching queued functions and initializes new clones. These are useful client semantics, but Hit never reaches that timing code. They do not prove the historical server's first-tick phase, quantization, backlog or refresh policy.

The current server waits one authored interval before the first tick, schedules against successive deadlines, catches up overdue ticks and resets phase on refresh. These are explicit reconstruction choices. A correlated original server recording is still needed to verify them. The retained native ledger is docs/research-notes/nano-dot-research/native/README.md, with 25 complete matching original evidence records and maintained-source hashes. No fresh binary analysis session or client change was needed.

The existing direct-damage PvE policy remains in force: this does not establish resistance, damage mitigation/scaling, player damage, line of sight or every interruption/targeting rule. The same open lifecycle questions apply to offline wall-clock time and secondary effects. Izgimmer's Death of a Thousand Cuts 28615 has no ordinary single-program uploader in the scanned original item catalog; test provisioning does not establish acquisition.

Verification

server/testdata/periodic-damage-nanos.json is an independent original-record oracle for all admitted programs and crystals. The catalog tests compare the complete set and authored fields, then upload/cast each program and count its entire damage sequence, debit, contribution, expiry and cold restore. Shared requirement tests cover every authored skill boundary and wrong profession.

Focused lifecycle tests cover exact boundaries, no writes between ticks, concurrent visitors, multiple strains in deadline order, refresh/upgrade/weaker rejection, a finished sequence with remaining lifetime, offline-caster restore, and checkpoints that preserve unprocessed overdue ticks. Fault injection covers HP, NPC state, contribution and timer writes, including ignored statements and deferred COMMIT failure. An ignored contribution insertion reproduced a partial outcome; the shared NPC outcome writer now requires each insertion and the final contribution count to agree before commit.

Catalog payload hashes, source records, native findings, test logs and current WASM checks are retained under local/nano-dot-research/ and local/nano-dot-smoke/. The full server/data-export run plus focused reruns cover 5,489 tests and subtests. The full run's only failures were the two weapon-special expectations that excluded loading observers; both now require ordered delivery and passed the focused rerun. Loading/output and weapon-special checks passed three repetitions under the race detector. go vet and the server build passed.

Two headed WASM clients on the GPU exercised native crystal uploads, casting, one-time cost debits, refresh, independent strains, complete expiry and a periodic kill with corpse ownership and effect removal. The initial shared sequence delivered 23 identical damage packets to both clients; the owner received 55 across the complete warm run. Read-only database receipts at cast completion and damage delivery confirmed committed timer, HP and death state. The static fixtures initially used idle regeneration outside melee range; subsequent checks moved into range for sustained combat.

A fresh native cast was then stopped with all eight ticks pending and a 3.957-second partial interval. After restart, a fresh WASM client received the remaining effect, observed six subsequent damage packets and explicit expiry, and agreed with saved HP after expiry. Two ticks elapsed before the client became ready. The warm lifecycle used the 59-program build; the final build additionally admits Hidden Killer through the same scheduler, covered by the final Go suite. No client adapter change was needed.

The initial late-observer check exposed a health reconciliation defect: actor and effect replay succeeded, but a 4-point hit during loading was omitted from that observer's stream. Its native HP stayed four points above the owner and server, including after effect expiry.

The shared output paths now deliver combat/effect packets and resource maxima as soon as the actor snapshot has been queued, including while the observer's own actor is finishing native loading. The update lock and output queue retain snapshot-before-update ordering. NPC interest checks still exclude unknown actors; loading players remain unable to act or become combat targets. This uses the ordinary event stream without a second snapshot or replay buffer.

Regression tests cover a loading observer's weapon timeline, periodic expiry and death, idle NPC healing and trained resource maxima with each observer's modifier basis. Existing tests cover unready, wrong-zone and unseen observers, loading-player action guards and ordered output. In the native replay, the observer received a 4-point tick between spawn and its ready message. Both clients received the same complete eight 3-point and ten 4-point sequences, and both ended at the saved 39 HP after expiry. Active probes also matched their committed HP; a further tick between captures accounts for their different capture-time values.

Separate timed native reloads put the final Prototype Biotoxin tick and explicit expiry inside the loading interval, then did the same for a lethal Repeated Cellular Trauma tick, effect removal, death/reset and corpse creation. Both clients agreed with saved outcomes and reported no errors on the GPU. Evidence is retained under local/world-loading-smoke/ and local/world-loading-boundaries/. Original-server timing and the other policy limits above remain open.