aorecomp

Anarchy Online classic in the browser

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


docs/combat-client-stats.md (23207B)


Combat calculations in the 14.9.1 client

The shipped client calculates item stats, skill ratings, action deadlines, range checks and local health/nano updates. These calculations provide strong evidence for reproducing its behavior. They do not recover the original server's hit, critical, armor or damage rolls.

This report uses the original anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0, and the database shipped with that client. Addresses below use its original image base 0x10000000; generated C symbols use base 0x36000000. FUN_10074560, for example, corresponds to generated sub_36074560. Integer division and trunc mean truncation toward zero. Floating-point constants and x87 operation order matter at boundaries.

Evidence and entry points

Calculation Original symbols Generated source Evidence
Default skills, ability trickle, health/nano foundations 10072760, 10073fa0, 10075c60, 10075910 client/game/kkr.dll/lifted-0034.c Starting stats; original rules evidence bundle
Weighted attack/defense ratings 1008f1f0, 1008f2f0, 1007c120 lifted-0042.c, lifted-0036.c Decompile batch 1 and original rules bundle
Damage tooltip and skill percentage strings 10024300, 100271b0, 100272d0 lifted-0015.c Decompile batch 1
Weapon damage cache/type/OE adjustment 100ab920, 100ab7b0, 100ab8a0, 10090f10, 10062f60 lifted-0051.c, lifted-0042.c, lifted-0029.c Decompile batches 1 and 3; generated assembly for OE arithmetic
Item construction and QL interpolation 100894c0, 100f1200, 100f00a0, 100eff20, 100f0c80 lifted-0040.c, lifted-0070.c Original rules bundle
Weapon initiative/AggDef deadlines 1007ab40, 1007ac10, 1007aa30, 1007aad0 lifted-0035.c Rules; original rules bundle
Nano casting deadline 100650f0 lifted-0030.c Decompile batch 5; assembly at 100651b4 through 1006526b
Nano cost eligibility and interrupted-cast refund 100646a0, 10098bd0, 10066b20 lifted-0030.c, lifted-0046.c Decompile batch 20; assembly at 10064839 through 1006488d
Weapon/nano range 100aae10, 10098c10; spatial caller 10078cb0 lifted-0051.c, lifted-0046.c, lifted-0035.c Original rules bundle and decompile batch 5
Regeneration intervals/deltas/update 10074560, 10074690, 1006ea50, 10059bd0 lifted-0034.c, lifted-0033.c, lifted-0027.c Decompile batch 3; generated assembly for floating-point math and nano clamp
Clock gating regeneration GameTime_t::RunFunction, 1000c3c0 lifted-0004.c Generated assembly at 1000c487 through 1000c516

Local evidence files are local/reports/combat-rules-1491-evidence.json and local/reports/combat-client-decompiles-*.json. Batch 1 has evidence ID ev_54c8e5911c3ccf91ab6ce87b5b2df8506f06ab9850e3ae78da5b0cb38fc13d7c, batch 3 ev_839516fbf9737749e969200bc7698259fa6decf43f39b3025dc440c60acd95f3, and batch 5 ev_9081c9ee969a3f64c9cfb5aec6a5d90477aa638090d6ed38e5791a3d0d58eeda. Batch 18 confirms the OE criterion traversal and nano clamp, evidence ID ev_2e782b554a0744a2121ba66adcdbff1f2ad2d35876b1d82851d18fbd718368d1. Batch 20 confirms nano cost and clock gating, evidence ID ev_b222a29a2449ed800e75228fac8a9ad597f8c73dce740b461b7fae780389796b. Some requested addresses are interior aliases: the update requested as 1006f0a0 or 1006ee30 is the canonical function 1006ea50. Generated aliases may likewise contain a larger shared body.

Character snapshot ability fields

The player branch of SimpleCharFullUpdate 271b3a6b contains three DWORDs and four signed shorts immediately after the NUL-terminated name. Reader 10082da0 loads the shorts at 1008315a through 10083184; activation 100821d0 sign-extends them at 10082550 through 10082594 into these stats:

Offset after name Stat Value supplied by the server
12 Swimming 138 Native starting base 5
14 Strength 16 Saved base Strength
16 Agility 17 Saved base Agility
18 Stamina 18 Saved base Stamina

The original name table identifies Swimming at 10037ff2; initializer 100728c6 sets its base to 5. Swimming is not currently editable in player profiles. Intelligence, Sense and Psychic are absent from this compact block; the owner's FullCharacter separately supplies all six abilities. The NPC branch skips these player setters and uses its own fields.

The source and original-byte audit is retained in local/scfu-ability-research/native-source-audit.json. The regression test TestTargetCharacterSnapshotPreservesPhysicalAbilities failed against the previous serializer, which supplied Strength/Agility/Stamina/Intelligence in these four fields. Unequal abilities expose that displacement.

Two WASM clients reproduced the old mapping and verified the correction using players with abilities 11/22/33/44/55/66 and 70/80/90/100/110/120. Read-only native probes confirmed both local and remote physical abilities and Swimming 5 after the change, including both clients reloading after a full server restart. The native Skills window showed the owner's six saved abilities, and ordinary forward movement still reached the server. The run passed 47 checks in local/scfu-ability-smoke/verification.json. Shared packet traces are explicitly distinguished from native object reads. All temporary clients and servers were closed before the full test runs.

The focused layout tests passed in 7.561 seconds, and the full go test ./server/... run passed (server 115.760 seconds). Five repeated race runs of the compact ability and player/NPC weapon-layout tests passed in 94.622 seconds. Logs are retained under local/scfu-ability-research/.

Skills and attack/defense ratings

The server's signed calculation and consumer checks are documented in signed effective stats, including original getter fixtures.

Ability trickle is a weighted sum divided by four, converted to integer before adding the base skill. The database supplies six integer ability percentages per skill, resource type 1000204. Defaults and exact weights for the current fixture are in starting stats. This yields Martial Arts 7 and Physical Initiative 7 for its six abilities of 10.

The exact final scaling is weighted_sum * float32(.01) * .25 before truncation. The first constant is 0.009999999776482582 (0x10170894), so an integer division by 400 changes exact boundary results. A live edited-stat probe confirmed effective Body Development 214 and Nano Pool 122 where that integer simplification predicted 215 and 123. See resource synchronization for the implementation and local/reports/combat-trickle-float-constants.json for original image bytes.

1008f1f0 reads item section 12, a sequence of (skill stat, percentage) pairs. 1008f2f0 does the same for section 13:

rating = sum(trunc(skill_value * percentage / 100))
if rating > 0:
    rating += modifier

The attack modifier is stat 276, defense modifier 277. Each term is divided separately; rounding the final sum would change results. For player characters these functions request getter mode 0 for skills. An NPC flag at actor offset +0x1b4 selects mode 2 instead. The modifiers use mode 0 in both branches. A missing actor returns zero; an empty or nonpositive weighted sum does not gain the modifier. The item lists can be populated lazily before iteration.

WeaponItem's vtable at 101745cc connects offsets +0x84 and +0x88 to these functions. 1007c120 selects weapon slot 6, then slot 8, and computes attack rating through +0x84. Without a weapon it uses Martial Arts 100 plus modifier 276, then stores attack rating in stat 22. The exported attack/defense string functions format the item weights; they do not run an evade or hit roll.

Native skill-name tables independently establish the special skill IDs:

Skill Stat Name-table store in 10036490
Brawling 142 10036974
Riposte 143 100369d8
Dimach 144 100369a6
Parry 145 10036b9a
Sneak Attack 146 10036bcc
Fast Attack 147 10036c30
Burst 148 10036eba
Fling Shot 150 10036e56
Aimed Shot 151 10036e88
Full Auto 167 10036eec

These are stat IDs, separate from action codes and packet opcodes. The long and short skill tables agree; exact string addresses are retained in local/reports/combat-client-special-stat-names.json. Descriptive skill text is not evidence that its historical prose accurately specifies server math.

Item QL and damage fields

Item construction receives a packed QL and two template identities. 100894c0 selects the nearer template by absolute distance between requested low-16-bit QL and endpoint stat 54. An equal distance chooses the second endpoint. This selects the base template for properties that are not interpolated. Stats 702 and 703 retain the endpoints; stat 701 retains packed QL. This is not a recovered rule for selecting fist QL from Martial Arts.

100f1200 replaces stat 701 with 1 when its low 16 bits are zero or above 511. It loads resource type 1000020 endpoints, copies a single endpoint when both identities match, and otherwise invokes 100f00a0. That routine checks endpoint QLs and list compatibility before interpolating supported fields. This generic loading path does not establish a fist-QL cap. The initial weapon-list path uses 100f11d0 -> 100f0f50, constructs a WeaponItem with actor Level 54, and invokes interpolation separately. Its final row parameter is not established as QL. See fist selection research. 100eff20 performs the scalar operation:

if v1 == v2 or q1 == q2 or q == q1: return v1
if q == q2: return v2
if v1 < v2:
    return v1 + trunc((q-q1) * (v2-v1) / (q2-q1) + 0.5)
return v2 + trunc((q-q2) * (v1-v2) / (q1-q2) + 0.5)

This is floating-point interpolation with a 0.5 offset before integer conversion. It should not be replaced indiscriminately with language-default rounding, especially for descending endpoints or negative values. Scalar stat dispatch 100f0c80 supports IDs 1, 2, 26, 27, 36, 45, 73, 74, 75, 101, 134, 210, 211, 212, 236, 250, 284, 285, 286, 287, 289, 294, 297, 299, 341 and 422. Stat 74 receives an additional bit-mask transformation in 100f1320. Other sections have their own interpolation processing in 100f00a0.

Weapon fields are minimum damage 286, maximum damage 285 and critical damage 284. 100ab920 caches them. N3Msg_GetDamageString (10024300) formats these fields for a weapon, including the critical field in parentheses. Its nano branch formats negative health-effect ranges from effect data. Neither path combines attack rating, target armor, evade or critical chance into an outcome. The shipped QL 1 fist endpoints and interpolation evidence are also described in combat rules.

The client does calculate an overequipping adjustment. 100ab8a0 asks 10090f10 to examine requirement section 8, then adjusts each cached damage field with 10062f60:

tier = 0
for requirement with operator code 2:
    ratio = effective_skill / requirement_value
    if ratio < 1:
        tier = max(tier, trunc((10 - ratio*10) * 0.5))
tier = clamp(tier, 0, 4)
adjusted_field = cached_field - trunc(cached_field * tier * 0.25)

The client uses effective getter mode 0 for these skills. Arithmetic and tier boundaries follow x87 floating-point operations, not a substituted modern percentage rule. This establishes a client item-field adjustment; it still does not establish the server's full damage formula or when it recalculates OE.

Damage type comes from item stat 436 in 100ab7b0. Accepted values are armor stat IDs 90 through 97 and 168; other values fall back to 90. This selects a type. It does not show how much armor subtracts or which order reflect, absorb, shields and added damage take. Result presentation and queued damage application are covered in the protocol report. WeaponItem constructor 10091560 initializes stat 436 to Melee 91 before loading the template. The fist records omit this stat and retain that default; omission is different from an explicitly invalid value.

Weapon and nano timing

Weapon attack and recharge use the initiative selected by item stat 440. Attack 1007ab40 passes that stat directly to the actor getter; recharge 1007ac10 substitutes Melee Initiative 118 when it is negative or above 1200. Live WeaponItem constructor 100abb20 defaults the field to Ranged Initiative 119; authored data overrides it. The admitted server weapons select valid Melee 118 or Ranged 119; tests also cover Physical 120 and the omitted-field default. With I the effective initiative:

effective_init = I if I <= 1200 else 1200 + (I-1200)/3
attack_cs   = max(100, ItemDelay294 + 75 - effective_init/6 - AggDef51)
recharge_cs = max(100, RechargeDelay210 + 75 - effective_init/3 - AggDef51)

The scheduler converts the positive centisecond results to integers by truncation. These functions and initial phase scheduling are traced in combat rules and the state machine. For 125-centisecond fists, initiative 7 and centered AggDef 0 this gives 198-centisecond attack and 197-centisecond recharge. Client deadlines do not establish server tick resolution.

For exact boundary behavior, retain the native single-precision constants and intermediate store before AggDef subtraction. The original instructions use init * .5, then the float constant for 1/3 or 2/3; above 1200 the first expression becomes 600 + (init-1200) * float32(1/6). At initiative 387 and AggDef -100, the recharge intermediate falls just below 71 before adding 100, so truncation yields 170 cs. The server regression preserves this case.

Nano casting has a separate calculation in 100650f0. It uses Nano Initiative 149 in mode 0 and AggDef 51 in mode 2:

effective_init = I if I <= 1200 else 1200 + (I-1200)/3
cast_seconds = ItemDelay294/100 - effective_init/200 - trunc(AggDef51/100)
deadline = GameTime.GetNormalTime() + cast_seconds

AggDef division here is integer division. Within the ordinary signed -100 to 100 slider range, only its extremes contribute -1 or +1 to that term. The recovered function does not apply the weapon one-second floor. Item flag 0x80000 overrides the stored deadline to zero. The surrounding cast controller and restrictions still matter; this expression alone does not prove every nano can execute with a negative duration or that recharge uses Nano Initiative.

Nano eligibility in 100646a0 calculates trunc(effective_stat318 * base_cost407 * 0.01) and requires at least that much current nano 214. 10098bd0 reads item stat 407. There is no reduction cap in this arithmetic. 10066b20, accompanied by the interrupted-execution message, adds the same cost back to current nano; this refund path writes the stat directly without invoking the regeneration clamp. The exported N3Msg_GetRechargeTime (10026240) returns the nano object's float field +0x88, or zero if the object is absent. This display getter does not itself derive recharge from initiative. Complete cost/stat caps and initialization of that recharge field require their own call-chain proof.

Range and physical extent

100aae10 computes weapon range from item 287 and effective actor stat 380; 10098c10 computes nano range using effective actor stat 381:

range = min(40, trunc(item_range + item_range * range_modifier * 0.01))

The minimum is not clamped in these helpers. A weapon's controller range check 10078cb0 compares 3D center distance with effective weapon range plus twice the attacker's physical extent and once the target's extent. Its extent input comes from the actor helper at +0x188, field +0x30. Reproducing that field for every model needs the spatial construction trace; a flat four-meter center-distance rule is only an approximation. The exported optimum-range getter uses half the unmodified item range for its selected weapon. Further target and line-of-sight checks are in the state-machine report. Nano admission10064af8..10064b19 first truncates its 3D distance, then invokes 10066310, whose second gate compares a binary32 distance directly against the signed range result. Nano range records the complete shared consumer, percentage boundaries and server-policy limits.

Health, nano and regeneration

10075910 builds the health stat 1 and maximum nano stat 221:

health = breed600 + level * breed601 + effective_BodyDevelopment152 * breed602
         + level * profession_title_health_bonus
max_nano = breed603 + level * breed604 + effective_NanoPool132 * breed605
           + level * profession_title_nano_bonus

The profession/title row's health coefficient is at +8, nano coefficient at +4; missing rows contribute zero. Breed resource 1000203 supplies stats 600 through 605. The function only recalculates for the local player and skips NPCs, so applying the player formula to all creatures would be unjustified. Full health data, Soldier title thresholds and missing-breed fallback are in starting stats. Nano coefficients are:

Breed resource Base nano 603 Per level 604 Per Nano Pool 605
Solitus 1 10 4 3
Opifex 2 10 3 3
Nanomage 3 15 5 4
Atrox 4 8 2 2
Resource 5 50 2 1

10074560(percent) recalculates intervals only for the local player:

HealInterval342 = max(1, trunc((30 - Stamina18 * (float)(1/30)) * percent * 0.01))
NanoInterval363 = max(1, trunc((30 - Psychic21 * (float)(1/30)) * percent * 0.01))

The literal reciprocal is the single-precision value 0.03333333507180214. Initialization and equipment refresh pass 100. Attack start at 10079093 passes 200; stop at 10079405 restores 100. 10074690 seeds HealDelta343 from breed coefficient 602 and NanoDelta364 from 605. Its NPC branch uses breed resource 4 for these two defaults; that does not recover creature archetype regeneration.

The 1006ea50 actor update runs regeneration when GameTime flag +0x1d is set. GameTime_t::RunFunction sets a one-second flag +0x1c and alternates +0x1d and +0x1e on those ticks; normal regeneration is therefore checked every two seconds. The actor's counter advances by two at each such check. This is not an independent timer restarted after each heal.

For players, the health branch reads final interval 342 and delta 343. When RestModifier425 equals 25 it halves an interval above 1 using an integer right shift. If injured, enabled and counter % interval == 0, it applies:

health_gain = trunc(effective_BodyDevelopment152 / base_RestModifier425)
              + final_HealDelta343
health = min(final_health_stat1, current_health + health_gain)

The nano branch rounds final NanoInterval363 down to an even integer with interval & ~1. An interval of zero passes every check; otherwise it requires counter % interval == 0. When below maximum nano, or when the delta is negative, the change is:

nano_gain = trunc(effective_BodyDevelopment152 / base_RestModifier425)
            + final_NanoDelta364
nano214 = clamp(nano214 + nano_gain, 0, final_MaxNano221)

10059bd0 implements that nano clamp. Both regeneration paths are disabled by actor flag 0x10 at +0x11c. The default RestModifier is 100 in 10072760; value 25 changes both the integer skill contribution and health interval. The source explicitly uses Body Development in the nano gain as well. Substituting Nano Pool would change native behavior.

Counter phase and odd intervals matter: an unmodified interval of 29 does not simply schedule one event every 29 seconds when tested against a counter that increases by two. An isolated idle-client probe showed health 20, 20, 23, 23 and nano 3, 6, 9, 12 in snapshots roughly 30 seconds apart, while server health remained 20. This corroborates local prediction; it does not determine the initial counter phase or validate original-server correction cadence. Evidence is linked from the reconstruction index. The NPC update also contains separate combat-state/stat-519 branches and must not be reduced to the player formula. None of this establishes original server regeneration authority.

Bounded unresolved questions

Question What was checked Result and limit
Attack versus defense hit probability Weighted getters, attack-rating setter, attack/defense UI strings and queued result handling Ratings recovered; no authoritative probability formula recovered in these paths.
Normal damage scaling and critical amount Item interpolation, damage cache, OE adjustment, damage tooltip, type getter and queued damage application Fields and OE recovered; no demonstrated AR-to-damage multiplier, damage RNG or critical-outcome equation.
Armor, added damage, reflect, shield and absorb order Numeric stat push scan across all generated kkr C, followed by inspected damage/type/result paths; protocol report covers message handlers No complete arithmetic/order trace. Generic data-driven accesses and other modules remain outside the negative claim.
Critical chance Same scan for candidate stats 379 and 391, plus inspected attack/defense and damage getters No literal pushes for those two IDs in that scan; this does not prove their absence from dynamic item/effect logic.
Martial Arts selecting fist QL Item/template constructor, interpolation and unarmed attack-rating paths Packed QL consumption recovered; no native MA-to-fist-QL selection recovered.
Nano recharge and cost caps Cast deadline, eligibility, interrupted-execution refund, recharge getter, nano resource update and range helper Cast timing, cost multiplication, refund, pool clamp and range cap recovered. A complete recharge/cost reduction/cap chain remains unresolved here.
Original server health and regeneration Player foundation, breed/profession resources and local actor update Client formulas recovered. Historical creature profiles, authoritative correction cadence and live regen confirmation remain unresolved.

The retained literal scan is local/reports/combat-client-stat-constant-scan.json. It deduplicates exact push immediate instruction addresses and found 108 armor candidates, 6 reflect candidates, 16 shield candidates, 11 absorb candidates, 4 added-damage candidates, 0 critical candidates, 26 regeneration candidates, 63 initiative candidates and 98 offense/defense candidates. These are discovery counts, not all confirmed stat reads: immediate values can instead be lengths, opcodes or unrelated constants. Symbol names and negative search results must not be promoted into server rules without a concrete calculation trace.