aorecomp

Anarchy Online classic in the browser

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


docs/combat-regeneration.md (20408B)


Authoritative resources and editable stats

Player health and nano now regenerate on the server using the recovered 14.9.1 client arithmetic. Quiet injured players receive absolute corrections every two seconds, so local prediction no longer accumulates independently of server state. Players at full health reconcile every ten seconds because native recovery already clamps at the maximum. Actual healing is published immediately, including the change that reaches full health. Owner nano, team resources and NPC health retain their two-second cadence. This matches the recovered client arithmetic; the unavailable original server's scheduler is not established by those rules.

Character data

The character editor at /admin/players/<id> uses labeled form fields with current values. The stats groups contain all six abilities and 69 skills under the classic UI categories: abilities, body, melee, misc weapons, ranged, speed, trade/repair, nano/aiding, spying and navigation. The arithmetic example below uses these form values:

Group Values
Stats Improvement points 1500
Abilities Strength 10, Agility 10, Stamina 60, Intelligence 10, Sense 10, Psychic 120
Body Martial arts 100, Body development 200, Nano pool 100
Speed Physical initiative 600

Fresh characters use the original breed ability baselines, raw skills 5 including Run Speed, and 1500 IP. The raw skill/IP seeds remain reconstruction policy; native defaults alone do not establish historical character creation. The arithmetic fixtures use abilities 10 and Run Speed 100 instead. Available IP persists as improvement_points and native stat 53. Native IP spending validates costs and caps, then commits IP and trained values together. Solo kill progression awards XP, levels and IP atomically; reward balance and eligibility remain provisional.

Skills here are trained/base values. Effective skill adds the integer ability contribution from the shipped resource type 1000204. Weights follow Strength, Agility, Stamina, Intelligence, Sense, Psychic:

Skill Weights
Martial Arts 100 20,50,0,0,0,30
1h Edged 103 30,40,30,0,0,0
Melee Initiative 118 0,10,0,10,60,20
Physical Initiative 120 0,10,0,10,60,20
Brawling 142 60,0,40,0,0,0
Fast Attack 147 0,60,0,0,40,0
Body Development 152 0,0,100,0,0,0
Nano Pool 132 0,0,10,10,10,70

Ability trickle is trunc(weighted_sum * float32(.01) * .25). The native percentage is 0.009999999776482582, so replacing the expression with integer division by 400 changes exact integer boundaries. The example has effective Martial Arts 110, Physical Initiative 607, Body Development 214 and Nano Pool 122. At level 1, Solitus and the current Soldier profession it produces 658 maximum HP, 380 maximum nano and one-second fist attack/recharge at centered AggDef. The client receives the base values and performs its own ability calculation.

Weapon timing also preserves the native float constants and the intermediate float store before AggDef subtraction. At effective initiative 387 and AggDef -100, recharge truncates to 170 centiseconds; the algebraically simplified division would give 171. This boundary is covered by a regression test.

Fields omitted from a submission retain their current values; explicitly saved zero skills remain zero. QL 1 Kinetic Axe attacks use Melee Initiative; unequipping restores fists and Physical Initiative. Its requirements also use the effective 1h Edged, Brawling and Fast Attack values. Saving writes explicit stats, location, resources and inventory to native SQLite fields in one transaction. Values survive editing, teleporting and restart. Routine movement saves update position fields without rewriting profile fields. Lowering resource maximums clamps current health/nano.

Every saved ability and skill is sent to the client. Martial Arts contributes to attack rating and weapon damage, while fist QL selection still uses QL1 and its original skill-to-QL rule remains unresolved. Other unsupported skill consumers and historical IP rounding remain separate from the implemented training, resource and damage calculations.

Recovery and replication

The server checks each ready player once every two seconds. A per-client counter advances by two. The check uses the native single-precision reciprocal of 30 in the interval arithmetic, then truncates the result:

percent = 200 while attacking, otherwise 100
health_interval = max(1, trunc((30 - Stamina * float32(1/30)) * percent * float32(.01)))
nano_interval = max(1, trunc((30 - Psychic * float32(1/30)) * percent * float32(.01))) & ~1
rest = 25 sitting, otherwise 100
if sitting and health_interval > 1: health_interval >>= 1
health_gain = effective_BodyDevelopment / rest + breed_HealDelta + equipment343 + nano343
nano_gain = effective_BodyDevelopment / rest + breed_NanoDelta + equipment364 + nano364

Integer division truncates. Health recovery requires the counter to be divisible by its interval. Nano recovery uses the same check, or every visit when its rounded interval is zero. Maximums clamp both resources. In this client the nano gain uses Body Development too; substituting Nano Pool changes the result. Exact sources and breed coefficients are in client stats.

HealDelta343 and NanoDelta364 modifiers stack after the integer division. Sitting does not multiply those bonuses, and the deltas do not change the intervals. Equipment changes affect the next eligible check without resetting the counter. Health requires an injured actor; nano also permits a negative final NanoDelta at maximum nano. Nano changes clamp to zero and the effective maximum. Authored delta implants are all positive; signed synthetic fixtures cover the negative consumer independently of catalog admission.

The complete implant audit admits 1,628 delta-bearing definitions, including 32 complete NanoCostModifier318/HealDelta343 contracts. Implants with another unsupported effect still reject as whole items; see implants. Twelve complete ordinary delta programs support native crystal learning and casting through the same recovery consumers; six also modify maximum health. See temporary nanos and health buffs. Recovery stays in memory until a vitals checkpoint; equipping or removing these implants persists placement immediately without forcing unrelated vitals updates when the resource caps are unchanged.

Actual GPU WASM checks used a Solitus fixture with Stamina/Psychic780 and effective Body Development199. Its standing intervals were3: health recovered every third two-second check and nano every check after rounding the interval down to2. Baseline gains4/4 became12/11 with the three implants listed in implants, and seated gains became18/17. Removing the mixed implant reduced seated gains to15/15. The same instances and12/11 standing gains survived server restart. Both resources clamped at their caps; all four test items survived removal and rejected installation. The separate cost implant checks verify the complete179201 contract, including its+5 HealDelta companion. Browser errors were empty. Native stats, authoritative wire windows, SQLite snapshots and the checked report are retained in local/regeneration-delta-smoke/verification.json; native evidence identity and getter semantics are in local/regeneration-delta-research/native/.

For the old default Solitus stats, standing recovery is 3 HP at counter 58, and 3 nano at counters 28 and 56. Sitting halves the health interval from 29 to 14. Attacking recalculates intervals to 59, with health at counter 118 and nano every 58. Stopping an attack changes the interval without restarting the counter. The edited example's standing interval is 27, not 28, because the native float reciprocal places the result just below the integer boundary.

Dead, offline, loading and NPC characters do not receive this player recovery. A new connection resets the prediction counter and posture; stopping an attack or sitting does not. Late scheduler visits advance one native-style check, without replaying an offline/stalled backlog. The two-second deadline stays anchored to its original phase, so small scheduling delays do not accumulate. The supported Leet's separate recovery rule and its server-policy limits are recorded in NPC health recovery.

World entry clears the connecting actor's live sitting state before publishing its snapshot or accepting item use. A saved sitting=1 may remain in SQLite until the next position/vitals checkpoint; it does not authorize seated-only treatment after reconnect. Public connection regressions cover reconnect, process restart and transport replacement, standing treatment rejection without a debit, the normal posture checkpoint, and successful treatment after an acknowledged sit. This establishes the reconstruction's current entry behavior; the original Funcom server's login posture policy is not independently recovered.

Other actors retain their posture when an observer enters. Their spawn vehicle blob supplies the physical mode and preserves preferred ground mode 2/3 in its trailing control state. Separate raw425/430 updates preserve rest even when water has replaced sitting8 with swimming4 or ground2/3. See water and retained rest. The exact 14.9.1 reader kkr.dll!FUN_10049220 reads velocity before FUN_10047160 calls FUN_100496b0 for ten control bytes and then reads the saved ground mode. FUN_100447c0 maps the sit movement command 28 to mode 8 and restores the saved mode for normal stand command 33; command31 is water exit. REA evidence is retained in local/posture-research/native-evidence.json (reader ev_afb34fc6c7a69b4461fb5a992dd641c1d68bcbbed3a366af495817d263c9a72b, controls ev_09164768a836a3815c36e78e9a1a756f811dd853981e43a56ba70bba7fa1a05e, decode ev_3972785e3b3aabc7bed848cb4fc292304d6701e8197dcb3c62808cef57620c9b, state machine ev_cb87381e23709fde42ed0193fb4f535d6056a1db069f5ac16ec5203b5600769e). The evidence identifies client parsing and transitions, not a historical server capture. Observer entry tests cover seated/standing actors with both ground preferences, without changing the existing actor's live state.

Two published WASM clients reproduced the missing observer posture before the change: the owner and live server were sitting while the entering observer saw mode 3. With the corrected snapshot both clients saw mode 8 after late join and observer reload. Standing restored mode 3 when running and mode 2 when walking; another observer reload preserved sitting with the walking preference too. Reconnecting the seated owner reset both clients and live server to standing mode 2. The original running preference was restored afterward, no items or placements changed, and both test clients were closed. There were no page or adapter errors. Captures and checked results are retained in local/posture-research/verification.json.

Actual health recovery publishes an absolute snapshot to the owner and ready observers, including during incoming or outgoing combat. The maintained receiver records received weapon results already included in that HP; their later keyframes retain animation, feedback and ammunition without subtracting damage again. Subsequent hits still apply normally. Withholding the recovery instead can leave a living player displayed at zero HP after the next hit.

Unchanged periodic health corrections still wait until neither the player nor an enemy targeting that player is attacking. StopFight flushes queued weapon outcomes before that quiet correction. Current nano remains private to its owner. Publication does not reset recovery counters or attack clocks. Independent client prediction phases can still differ temporarily; the next quiet snapshot settles that drift. Original server publication cadence remains unestablished.

Quiet health uses HealthDamage (0x3710256c) with four uint32 fields: absolute HP, zero signed change, zero damage type and zero death reason. The native reader client/game/kkr.dll/lifted-0052.c sub_360B09C0 reads those fields; sub_360B0A50 assigns absolute health and uses the separate change field for feedback. Zero change makes sub_3601D0B0 return before chat or floating text. This corrects prediction drift without announcing a new hit or heal. The reader and handler are retained in REA record ev_8687fd6e603c302e4ab3fee7b405ea3e5c9a615e0f56bff18dd20ff949da8d4c. The generic 0x2b333d6e stat handler derives HP feedback from the local difference and is unsuitable for quiet reconciliation. Nano retains its existing private absolute-stat update.

Two published WASM clients verified forced downward (922 to 800) and upward (800 to 850) corrections without hit or healing feedback. A subsequent fight recorded 26 Leet bites totaling 163 damage. After the kill, the owner's stats showed the authoritative 693/922 HP, with normal melee messages and no phantom nanobot damage or floating correction text. The observer's target bar also reconciled silently. Screenshots and fixture state are retained in local/quiet-health-smoke/. Reconnecting retained the authoritative current health and continued receiving quiet corrections without feedback.

State and delivery ordering

The state lock protects actors and current session ownership. The update lock is acquired before the state lock and covers each state change through its packet enqueue batch. Combat, recovery, movement, posture, joining, disconnects and zoning use this order. A joining actor's spawn is queued to existing observers before another update can announce that actor's combat or resources. Manual teleport snapshots and automatic portal selection keep this lock through their commit so an intervening profile edit cannot be overwritten by an older location-change snapshot.

Every live world and chat connection starts one output writer before becoming visible to other sessions. Both use the same bounded writer implementation. Sending copies packet bytes, applies the recipient's protocol conversion and identity, then enqueues them in FIFO order under the connection lock. Socket writes run outside both world locks, with a five-second write deadline. Pending output is bounded at 8 MiB per connection plus one packet in flight; overflow or a failed/short write closes that connection. A stalled recipient therefore cannot hold up combat or regeneration for other players. Accepted output drains when the reader session ends; connection cleanup cancels combat and releases world locks before waiting for its writer. Forced disconnects instead discard pending output and wake the writer, which also owns socket shutdown. An in-flight write has the existing five-second deadline. Shared work and replacement sessions do not wait for a transport's close handshake.

Profile edits save a candidate before changing the live actor. On success, both sides of the old fight receive StopFight in the original playfield before despawn and reconnect. Current resources are preserved up to their new maximums. A failed save leaves the actor, resources and fight intact. Replaced sessions cannot move, change posture or finish loading for the current session. A second world cookie on an initialized connection is rejected rather than resetting its actor or recovery clock.

These are ordering guarantees for the basic PvE implementation. They do not establish historical NPC balance or a general action controller for equipment, special attacks and nanos.

Verification

TestBrowserPlayerCombatRecovery checks the false-zero failure with two native clients at each of raw Body Development10 and80, using a controlled level20 Enforcer. The increased case uses Stamina41 and explicitly checks recovered ability/level caps. Two real eight-point Leet results surround a three-point recovery. The fixture advances one real scheduler check at counter58/56 instead of waiting for the full interval. Previously both clients showed0 while server HP was3. The recovery snapshot now supplies11 with the first result still intact, its impact retains11, and the later real hit leaves3. The NPC's target and attack/ recharge deadlines do not change. StopFight, quiet correction, both page reloads and cold database loading retain3. These are controlled incoming-combat checks, not earned progression or complete target-switch/phase coverage. Accepted captures: local/player-combat-recovery/20261102-212600/10/ and local/player-combat-recovery/20261102-213014/80/.

Tests cover default and edited abilities, standing/sitting/combat intervals, phase preservation when stopping attacks, minimum intervals, both resource maximums, incoming-only fights, owner/observer correction layouts, dead/loading/ offline/NPC exclusions, native posture requests, FullCharacter base stats and profile persistence. The maintained package suite and race checks are recorded in the reconstruction index.

Lifecycle regressions cover old-playfield cancellation, failed profile saves, replaced-session actions, duplicate world cookies, scheduler jitter and a live recipient that stops reading. Output tests cover FIFO order, independent packet ownership, concurrent producers, queue overflow, short writes, actual write timeouts and draining accepted output during shutdown. The queue/lifecycle stress selection passed 25 runs under the race detector, including 10,000 packets from concurrent producers. Chat regressions also leave one recipient unread while checking that vicinity and Global messages still reach a healthy recipient and the sender can issue and receive its next request. Login and history enqueue before live delivery. A replacement-session regression deliberately blocks the old transport's Close operation and verifies that the new session can finish independently. These three isolation regressions passed 100 repetitions each after the shared writer and asynchronous disconnect changes.

An isolated browser run with the default profile ended at server and client health 26/37 and nano 12/35 after two health recoveries. Earlier the same kind of probe left server health at 20 while the client healed itself. The new capture is local/combat-smoke/regeneration-default-events.json, with multi-regen-fixed-{start,30,end}.png. Client and temporary server were closed.

The edited-profile probe verified the native ability/skill panels at effective Body Development 214, Nano Pool 122, Physical Initiative 607 and attack rating 110. Standing server/client resources matched at 405/658 HP and 10/380 nano; sitting matched at 416/658 and 21/380 after an 11-point recovery. A sustained fight delivered 310 incoming damage and recovered 5 HP authoritatively during combat. Walking out of range stopped both actors; server and client then matched at 122/658 HP and 42/380 nano. No page errors were recorded.

The capture and checked accounting are local/combat-smoke/regeneration-variable-{events,summary}.json. Screenshots include multi-regen-variable-fixed-{resources,speed,idle-healed}.png, multi-regen-variable-sitting.png, multi-regen-variable-combat-recovery.png and multi-regen-variable-reconciled.png. The fixture used a local 1000-HP creature to sustain the encounter; it is not evidence of historical leet balance. Test client and server were closed afterward.

A further two-client probe joined an ongoing fight, then changed the attacker's base Body Development from 200 to 250 through the actual profile editor route. The observer received both participant spawns before combat replay, both StopFight messages before the player's despawn, and the player's new spawn after reconnect. Seventy incoming damage reduced the player from 405 to 335 HP. The edit preserved 335 HP and 10 nano while raising maximum HP from 658 to 808; the native display matched 335/808 HP and 10/380 nano. No page errors were recorded. Captures are local/combat-smoke/lifecycle-{events,summary}.json, with multi-lifecycle-{joined,reconnected,observer}.png. Both clients and the temporary server were closed after the probe.