aorecomp

Anarchy Online classic in the browser

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


docs/research-notes/hit-miss-research/native/ledger.md (5917B)


Original weapon attack and defense rating evidence

The target is anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. The file digest and REA open identity agree. Original image base is 0x10000000; maintained lifted C uses 0x36000000. The candidate local/client/game-14.9.1/images/kkr.dll has SHA-256 241b2e665dcd127399b7686cddda8a5b0876d9cde9b3af7a73940dd0b86ecaa7, and local/client/client/kkr.dll has SHA-256 b0e0173b5dbe129c6ad53eadd4467a0f53796993e613fecb9b2aaa6fc9a403ac. They were not used for original binary claims. An initial attempt to open the first candidate with the original snapshot was correctly rejected for identity mismatch. The original snapshot was then reused against the matching original.

Verified observations

Question Result Original assembly Evidence ID
Attack section 1008f1f0 iterates item section 12, pairs of stat and integer percentage ev_7026d5f7e10d5268d9e7ad962a2ccc331994225e4114f01c7a11be33a078d863
Defense section 1008f2f0 iterates section 13 with identical weighted arithmetic ev_161c10edc8ac499943d486141110d64b407093c42c098a80f0bd4f1ec59ac162
Getter mode 1006dfb0 mode 2 reads the stored stat array directly; mode 0 calls effective getter 10075ca0 ev_74652ec491811d2dbb9348174f59fabc0739128af4fc0567877aee64d3b28a0e

Both rating functions multiply each signed skill by its authored percentage, divide that product by 100 with truncation toward zero, then add to the signed sum. Division is per term. The original signed multiplication by 0x51eb851f, arithmetic shift and sign adjustment establish the signed division rather than an unsigned or floor calculation. Products are 32-bit native IMUL values; extreme overflowing skill values are not covered by the fixture.

Only if the weighted sum is strictly positive does attack add stat 276 or defense add stat 277. The modifier getter always uses mode 0. There is no floor after adding it: a positive sum plus sufficiently negative modifier returns a negative rating. Empty lists, zero or negative weighted sums do not query the modifier. A null actor returns zero. Empty sections trigger the existing lazy section population loop over section IDs 1 through 35 before reading again.

Actor flag byte +0x1b4 chooses skill getter mode 2 when nonzero and mode 0 when zero. For NPC raw values, do not run player trickle or direct skill modifier addition again. Mode 0's effective path is separately traced in docs/research-notes/signed-stat-research/ledger.md; it adds the native base/trickle and modifier. The NPC flag interpretation comes from the actor model and existing client documentation; the byte and selected modes are directly observed.

These facts establish the client-side rating ingredients. They do not establish the original server's hit probability, NPC population stat values, AggDef effect on hit chance, or any all-off/all-def formula beyond the client's additive modifier and gating above. No probability expression is derived here.

The original extracted fist records 43712 (QL1), 144745 (QL100) and 43713 (QL500) each author attack section 12 as Martial Arts stat100 at100% and defense section 13 as Evade Close Combat stat155 at100%. Sources are server/gamedata/items/items_002.yaml and items_065.yaml. QL1 payload SHA-256 is 8081990ac19d682aab12be9d3eee65a6b612093d81692745319a7526bf23a27f. The other evade stat bindings are Dodge Ranged154 and Duck Explosions153; Run Speed is156. The mixed defense fixture uses155 and154, synthetic50/50 weights rather than a claim about the fist's actual100%155 defense.

Contract test and limits

client/tests/weapon_rating.c runs the maintained lifted rating functions and the actual lifted stat getter. Section lookup, absent-section population and the mode-0 effective provider are explicit fixture boundaries. The test proves NPC raw lookup by making effective skill values differ by +100, and proves modifier mode 0 by making the raw modifier 999 while effective modifier is 7. It covers 18 hardcoded cases, including 12550% twice yielding 124, 333% twice yielding zero, -3*50% truncating to -1, a zero mixed sum, a negative final result, NPC reads, missing actors and empty sections. The fixture does not execute the original Windows DLL or full effect lifetime.

Linux (whole maintained translation units) and WASM (the three exact bodies, newline-normalized) pass with identical output in linux-results.txt and wasm-results.txt. tmp_audit.py verifies every original assembly instruction address occurs in its maintained body: 96, 94 and 44 instructions respectively. Instruction provenance coverage is not a proof of every translator semantic. focused-evidence.json retains the five focused pseudocode/assembly records; rating-evidence.json and kkr.snapshot.json retain the complete session. The owned REA session was closed. No game, server or browser was started.

From the repository root, the Linux build recipe is:

gcc -Iclient/runtime -Iclient/game -Iclient/data -DRECOMP_PORTABLE -O2 \
  -fno-strict-aliasing -ffunction-sections -fdata-sections \
  client/tests/weapon_rating.c client/game/kkr.dll/lifted-0042.c \
  client/game/kkr.dll/lifted-0033.c client/runtime/guest_memory.c \
  client/runtime/recomp_state.c -Wl,--gc-sections -lm \
  -o local/hit-miss-research/native/weapon-rating
local/hit-miss-research/native/weapon-rating

For the WASM check, run python3 local/hit-miss-research/native/tmp_audit.py, use toolchains/emsdk/upstream/emscripten/emcc with the same flags, replace the two whole lifted files with local/hit-miss-research/native/lifted_rating.c, and name the output local/hit-miss-research/native/weapon-rating.js. Run that output using the bundled Node executable. The full Linux compile and extracted WASM compile both use unmodified maintained arithmetic bodies.