aorecomp

Anarchy Online classic in the browser

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


docs/combat-client-reconstruction.md (17061B)


Reconstructing combat from the 14.9.1 client

This investigation targets the original pre-Shadowlands 14.9.1 client. Its purpose is to recover the client/server combat contract and distinguish rules the client calculates from decisions it receives. Matching a client timer is not proof of the original server's scheduler or random rolls.

Sources and search boundary

The primary engine image is anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Original addresses use image base 0x10000000; generated C uses 0x36000000. The matching eer.dll interface and ddr.dll GUI are additional entry-point evidence. Generated code is disassembly-derived, not original Funcom source; REA decompilation and assembly checks establish the important arithmetic and branches independently.

The retained discovery files are:

Period player experiments are supplementary evidence, especially for rules the client does not calculate. Later CellAO behavior is a useful comparison, but does not override conflicting shipped-client evidence or establish a 14.9.1 server formula.

Investigation checklist

The detailed reports maintain exact symbols, pseudocode, evidence and remaining unknowns for each area:

Area Questions Detailed report
Attack controller Start/stop, phase transitions, queued results, interrupts, multiple weapons, target changes State machine
Spatial checks Item range, physical extents, target availability, playfield and line of sight State machine
Numeric rules Initiative/AggDef, item interpolation, attack/defense weights, overequipping, health/nano and regeneration Stats and items
Results Normal hits, criticals, misses, reflects, shields, absorbs, full auto, health changes and death Protocol
Specials and nanos Requests, client eligibility, skill codes, locks, cast/recharge/cancel and result channels Protocol, stats
Data and creation defaults Base skills, trickle, breed/profession/title data and the fixture's limitations Starting stats
Effects Client prediction versus server results; all 47 observed locally admitted IDs and 25 rejected IDs Overview, handler map
Requirements All 18 observed operators, subject context, getter modes and client-only shortcuts Requirement interpreter
Effect replication SpellList/ApplySpells envelopes, six typed effect bodies, add/remove direction and actual skill locks Spell streams
Current server Implemented behavior versus recovered rules and unresolved authority Coverage ledger below
Resource synchronization and editable stats Persistent base stats, derived resources, posture, recovery and safe correction timing Regeneration implementation
Creature balance research Local wiki search, shipped Leet Bite endpoints and historical HP gaps NPC balance evidence
XP and progression Absolute XP updates, level-up handler fields and unresolved reward rules Character progression

Current server coverage

Rule or behavior Evidence status Current server
Attack, stop and basic hit layouts Native reader/writer/activation plus runtime Implemented and covered by native-wire tests
Health/death presentation and ordering Native handlers plus browser encounters Implemented for basic PvE; native player resurrection uses a provisional starter return
Weapon initiative/AggDef formulas Exact native arithmetic and integer conversion QL 1 fists, editable Physical Initiative and ability trickle; 250 ms resolution tick
AggDef request and stat update Native request/serializer plus real slider request Implemented; scheduled swing keeps its deadline
QL 1 fist damage endpoints Shipped item record Base 3..5, scaled by effective MA; distribution and always-hit policy are local
Player attack-rating damage Period AR/400 rule and native skill selection Axe/fist normal endpoints and minimum floor scale; fractional truncation is provisional; damage notes
Player max/current health and nano Native formula, breed/title resources, browser 37/37 Derived from editable abilities and base Body Development/Nano Pool; Soldier profession
Martial Arts selecting fist QL Tentative period MA/2 report; server pairing/caps unresolved Server damage remains QL 1; native initial item uses actor level and the supplied pair; selection research
NPC health, damage and weapons Level-1 Leet weapon data verified; binding and actor stats provisional Exact-level Leet profile with replicated bite weapon; other NPCs retain prototype values
Metaplast chest armor (QL 1/200) and boots (QL 1) Shipped wear effects and native packets, owner/observer WASM checks Persistent equip/unequip, appearance and AC modifiers; armor notes
Armor damage reduction and damage-type selection Period AC/10 observations and shipped damage types Normal hits respect the weapon minimum; fractional integer ordering is provisional; armor notes
Evade/critical rolls and damage modifiers Client data/handlers do not alone establish authoritative calculation Not implemented
Range and physical extents Native predicate and extent construction recovered; WASM player/Leet extents verified Catalog radius at scale 100; 9m player-to-Leet and 10m reverse boundary checks; original server tolerance unknown
Line of sight Client checks cannot establish original server validation Not implemented on the server
Dual wield, ammunition/reload, specials and nanos Scheduling, core effect streams and skill-lock contract recovered; full effect semantics remain partial Not implemented
Resource regeneration Native prediction formulas and injured-client probes Authoritative player recovery; absolute quiet corrections reconcile prediction
Corpse loot Native handlers and real combat/loot encounters Fixed-item transfer persists; level-1 Leet corpses expire after a provisional 180 seconds; production drop tables remain unimplemented
Creature respawn Explicit provisional level-1 Leet delay; historical district units unresolved One fresh replacement after 100 seconds; see respawn
Player resurrection Native action 152 and Resurrect handler Automatic native return with provisional location/resources; see player resurrection
Insurance return point Shipped Omni-Med scanner and native Use/success response One persistent saved scanner; arrival offset and free fee policy provisional; see insurance
Item reclaim Native level boundary, NoDrop cleanup and private container packets Level-10 ordinary items persist in private reclaim; delay and retention policies provisional; see reclaim
XP and insurance fees Separate rules and state required Not implemented

Implementation order and acceptance checks

The recovered boundary is:

flowchart LR
    A[Client action request] --> B[Server validation]
    B --> C[Authoritative action clock]
    C --> D[Server outcome and health]
    D --> E[Ordered result messages]
    E --> F[Client result queue]
    F --> G[Animation keyframe and displayed health]
    H[Item and stat data] --> C
    H --> I[Client timers and prediction]

Client timers and prediction are compatibility requirements. They do not authorize the request or produce the server outcome. The next implementation steps should follow this order:

  1. Stat and weapon foundations. Use the shipped endpoint/QL records, base skills, ability trickle, rating weights and temporary modifiers. Editable base abilities and four combat skills now feed timing and resources; keep the Soldier profession and missing IP progression explicit. Verify with native item endpoints, interpolation boundaries, separate weighted-term truncation and modifier removal/clamping.
  2. One action controller per actor. Represent attack/recharge and the coordination between weapons, nanos, item use and reload. Multiple weapons share attack scheduling; simply giving each weapon an independent repeating timer would contradict the client controller. Verify phase ordering, stop/restart, weapon swaps, interruption and late ticks. Keep client startup randomness separate from the unresolved original-server first-hit policy.
  3. Resource/effect state. Maintain authoritative health/nano, active effects, modifier addition/removal, expiration and regeneration. Match the recovered prediction where validated and replicate absolute corrections coherently. Verify injured idle and fighting actors, odd interval phase, sitting/rest behavior, expiry and lowered maximums; do not apply player formulas to NPCs.
  4. Outcome resolution. Add the correct miss/critical/special/type channels, then armor, absorb, reflect and shields once their arithmetic/order has evidence. The client supplies result interpretation, not a recovered hit- chance or full damage equation. Period research and any original-server captures are needed for those gaps; do not label an emulator formula proven.
  5. Full replication and lifecycle. Exercise every result's actor/target and absolute-versus-delta semantics in the real client, including absent actors, late observers, transport resume, death and resurrection. Full Auto's bullet count and absorb feedback do not independently apply health damage.

The current prototype remains intentionally limited while this contract is used to guide changes. This report is a broad source-backed pass, not a claim that every effect handler, criteria context, inventory transaction, combat feedback code or historical server rule has been completely recovered. Each specialist report identifies the concrete remaining searches and limitations.

Validation already retained

The maintained Go packages pass. The full go test -race ./server/... run passed (server 441.553 seconds, gamedata 106.782 seconds). Additional focused race checks cover duplicate cookies, replaced-session movement/posture/loading, and actual socket write timeouts. There are now 63 combat, stat, regeneration and output tests. These include simultaneous attackers, one killing blow, target changes, recharge preservation, stale sessions, zoning, disconnects, late observers, malformed slider requests, and breed/title health boundaries. After manual teleports were brought under the same snapshot/commit lock, the maintained suite passed again (server 68.688 seconds), and focused profile, stat-persistence and automatic/manual zoning race checks passed in 111.453 seconds.

Lifecycle and queue stress passed 25 runs under the race detector, including 10,000 packets from concurrent producers. Every live world and chat connection uses the same bounded FIFO writer, so socket writes do not hold shared locks. Queue overflow, write timeout and short write disconnect the affected recipient. State changes and packet enqueue batches share one update lock, with candidate profile saves and old-playfield fight cancellation before character replacement. The resource design documents lock order, session ownership, join ordering and shutdown behavior. The shared world/chat writer and asynchronous disconnect checks pass with the maintained suite (server 68.185 seconds) and focused race checks (105.120 seconds). Three isolation regressions passed 100 repetitions each: unread vicinity recipient, unread Global recipient with subsequent sender request, and replacement while the old transport's Close operation is blocked.

Browser checks use the published Chromium/WASM client in isolated fixtures: native Q/Tab, punches/kicks, weapon text, health bars, corpse/death presentation, and the aggression slider. One two-client run had the second player join an injured NPC, reconnect both browser transports, continue attacking and kill the NPC after the first player's death. No page errors were observed. That run used the earlier 100-HP player fixture; it is transport/ordering evidence, not validation of the final health formula.

A separate run verified the corrected 37/37 player display, native attack rating 7, and slider value +71 reaching server state and changing cadence. It stopped with server player health 7 and NPC health 3; client health changes remain delayed until the queued weapon animation resolves. Local screenshots, packet captures and summaries are under local/combat-smoke/, notably health-before-fix.png, multi-health-fixed.png, multi-native-canonical-health-fight.png, multiclient-first-summary.json and multiclient-summary.json. Test clients and temporary servers were closed.

These checks establish the described behavior in the tested fixtures. They do not establish historical NPC balance, original server RNG, outdoor collision validation, or complete combat-system correctness.

An additional idle-client probe initialized player health to 20/37, put the NPC outside melee range, and made no attacks. Screenshots separated by roughly 30 seconds showed client health 20, 20, 23, 23 and nano 3, 6, 9, 12, while the server remained at 20 HP throughout. This corroborates local resource prediction and demonstrates current server/client drift without authoritative regeneration in that earlier implementation. It does not independently establish the exact initial counter phase or original server cadence. The retained images are local/combat-smoke/injured-regeneration-sequence.png and multi-injured-regen-{0,30,60,90}.png, with injured-regeneration-events.json. The browser/server were closed afterward.

The recovered spell stream was also exercised directly. An exact 88-byte SpellList container added 5 to Martial Arts; the native skill panel changed from 7 to 12. The matching ApplySpells removal restored 7. Two add/remove rounds were captured without page errors. This validates the tested modifier stream, while the stats summary's attack rating remained 7 and needs a separate refresh/binding investigation. Captures and screenshots are retained as local/combat-smoke/effect-modifier-{events,summary}.json and multi-effect-probe-body-{before,add,removed}.png. Test resources were closed.

Authoritative regeneration and editable stats are now implemented. A default idle probe ended with server and client both at 26/37 HP and 12/35 nano. An edited profile verified effective skills and 658/380 resource maximums, then standing/sitting recovery and a sustained fight. Combat accounting included 310 incoming damage and 5 recovered HP. After walking out of melee range, both sides matched at 122/658 HP and 42/380 nano, with zero page errors. See regeneration verification for captures and limits.