commit 57cd81362be9a18a498e95b7662f3772ac4a9896
parent 6c57cd885d4acdc3a9c278aaf5452d8e701ac849
Author: anon <anon@example.com>
Date: Thu, 22 Oct 2026 13:19:11 +0000
Apply native overequipping penalties to the Kinetic Axe
Diffstat:
5 files changed, 290 insertions(+), 4 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -63,12 +63,14 @@ recorded in [inventory behavior](docs/inventory.md).
invalid belt removal cannot strand installed equipment.
- [ ] Install one NCU memory. Check: available NCU changes by the item's amount
and remains correct after reconnect and removal.
-- [ ] Apply overequipping rules to one weapon. Check: dropping below a verified
+- [x] Apply overequipping rules to one weapon. Check: dropping below a verified
requirement threshold changes effectiveness at the correct boundary.
The supported Metaplast pieces, native appearance, combined AC bonuses and
server-side damage checks are recorded in [armor](docs/armor.md). These stat
bonus milestones use AC; broader skill and resource modifiers remain future work.
+The axe's requirement tiers, native field adjustment, checks and remaining
+server arithmetic limits are recorded in [overequipping](docs/overequipping.md).
## Combat calculations
diff --git a/docs/combat-attack-rating.md b/docs/combat-attack-rating.md
@@ -23,7 +23,8 @@ has no Add All Offense modifiers or mixed attack-skill weights. The server
therefore uses effective 1-Hand Edged with the axe and effective Martial Arts
with fists, without introducing a generic stat-effect interpreter.
-Normal player hits follow this order:
+Normal player hits follow this order, after any supported axe
+[overequipping adjustment](overequipping.md) to its base endpoints:
```text
minimum = base_minimum + floor(base_minimum * AR / 400)
@@ -56,8 +57,8 @@ at 10, rather than the unscaled minimum of 5.
NPC profiles still provide their unscaled catalog damage: their attack skills
and Add All Offense values are not known. Player fists receive the multiplier
but remain on the fixed QL 1 3..5 record; selecting their proper QL from Martial
-Arts is a separate TODO. Criticals, hit/miss rolls, damage additions and
-overequipping also remain separate work. These limits prevent a claim of
+Arts is a separate TODO. Criticals, hit/miss rolls and damage additions
+also remain separate work. These limits prevent a claim of
complete canonical damage balance.
## Verification
diff --git a/docs/overequipping.md b/docs/overequipping.md
@@ -0,0 +1,129 @@
+# Weapon overequipping in 14.9.1
+
+The supported QL 1 Kinetic Axe (template 209283) now loses normal-hit damage
+when any of its three effective required skills falls sufficiently far below
+the requirement. Ownership and equipment placement are retained. Restoring
+the skill restores effectiveness without re-equipping or a cached server bonus.
+
+Its action-8 requirements are stat 103 (1-Hand Edged), 147 (Fast Attack) and
+142 (Brawling), each with operator 2 and value 4. Equipping requires each
+effective skill to be greater than 4. Overequipping uses the stored value 4
+as its denominator, independently of that strict equip comparison. Effective
+skills include their existing ability trickle.
+
+## Original client evidence
+
+The original 14.9.1 `kkr.dll` has SHA-256
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
+The independently checked native bundle is retained at
+`local/reports/oe-native-1491-evidence.json` (27 records).
+
+`FUN_10090f10(8, actor)` scans every operator-2 criterion in the selected
+requirement action. It does not filter to the primary attack skill or evaluate
+the Boolean operators between criteria. It reads effective skills through the
+actor's inline stat holder at offset `0xe4`. For each ratio below one:
+
+```text
+ratio = effective_skill / requirement_value
+tier = max(tier, trunc((10 - ratio*10) * 0.5))
+tier = clamp(tier, 0, 4)
+```
+
+Assembly uses integer `FILD`/`FIDIV` and keeps the ratio in x87 registers until
+integer truncation. The decompiler's apparent float casts must not be treated
+as float32 stores. Constants 1, 10, 0.5 and 0.25 were read from the original
+binary. The exact criterion/arithmetic record is
+`ev_12efe16371f012aad98ae3486345dafb6f3b6b4c3ffb2b92ead695410d0c6e6b`.
+
+`FUN_100ab8a0` reads cached original min/max/critical bonus from WeaponBase
+offsets `0x24/0x28/0x2c`. `FUN_10062f60` applies:
+
+```text
+adjusted = original - trunc(original * tier * 0.25)
+```
+
+It writes adjusted values into WeaponItem stats 286/285/284. Subtracting the
+truncated penalty matters: original minimum 5 at tier 1 becomes 4, rather than
+3. The subtraction record is
+`ev_f2d0d04aced862c9c02a45b7c1b76a0c4c9226744db0de542319c70d4239a39a`;
+cache and writes are respectively
+`ev_ee5d5ae759c44384e37d215a68aa246717103c7cbac3ee3f9cc6e82c3059b9b6`
+and `ev_e4cfc48a96fe01836fe74b04705922cacf9b95ee8ae956418ee69d1b7fdc93cd`.
+
+`FUN_10062f80` refreshes equipped weapon slots 8 and 6, skips NPC actors, and
+is called by equipment activation and local-player refresh. Its record is
+`ev_484252f9c28a23215e6d0047e94922650e1c1d3a5a0f6e68e18fa2d8f111fd68`.
+The tier is computed, not persisted in the adjusted fields.
+
+## Supported calculation and limits
+
+All three axe requirements have denominator 4. For integer skills below 4,
+the native expression is exactly `min(4, (4-skill)*5/4)` with integer division.
+The server uses the lowest of the three effective skills and adjusts base
+endpoints before its existing attack-rating scaling and AC reduction.
+
+| Lowest required skill | Tier | Base min..max | At AR 400, before AC |
+| --- | --- | --- | --- |
+| 4 or more | 0 | 5..20 | 10..40 |
+| 3 | 1 | 4..15 | 8..30 |
+| 2 | 2 | 3..10 | 6..20 |
+| 1 | 3 | 2..5 | 4..10 |
+| 0 | 4 | 0..0 | 0..0 |
+
+The AR-400 column keeps 1-Hand Edged fixed and lowers Brawling or Fast Attack.
+The native calculation proves base-field adjustment; it does not establish
+the original server's complete OE/AR/AC integer ordering. That ordering remains
+a reconstruction policy alongside the existing endpoint and AC truncation.
+Zero effectiveness produces zero normal damage in this implementation; whether
+the original server also blocked starting or continuing attacks is unresolved.
+No additional attack-eligibility rule is inferred from the arithmetic alone.
+Critical damage is not implemented, so its native adjustment is documented
+but not used by the server. Armor OE and other item types remain separate work.
+
+The [July 2002 weapon guide](https://forums-archive.anarchy-online.com/showthread.php?37266-How-to-Choose-A-Weapon-Guide-for-the-MP=)
+describes maintaining skill within 20% of the requirement and red hatching for
+OE gear. The modern
+[AO-Universe transcription](https://www.ao-universe.com/guides/classic-ao/gameplay-guides-6/over-equipped)
+attributes 25% damage steps to an official explanation, but contradicts itself
+at exact equality and has erroneous surrounding examples. It is corroboration
+for the broad rule, not the source of the implemented boundaries or rounding.
+No primary period experiment found in this pass settles exact equality,
+special-skill inclusion, zero-effectiveness attack eligibility or server integer
+ordering. Native 14.9.1 evidence supplies the supported axe's calculation.
+
+## Verification
+
+`server/overequipping_test.go` equips through the native inventory handler,
+then independently reduces each required skill. Controlled endpoint rolls
+cover all penalty tiers, the value-4 retention boundary, the worst requirement,
+ability trickle, restoration without re-equipping, durable stats/ownership over
+two restarts, the adjusted minimum against armor, fists after removing a fully
+ineffective axe, and matching damage/HP for owner and observer. Existing
+attack-rating and equipment checks remain in place.
+
+The two-client WASM fixture is retained in `local/overequipping-smoke/`.
+Native pickup/place equips item ID 102 in right-hand slot 6. The existing
+profile editor lowers Brawling through 3, 2, 1 and 0, keeping effective
+1-Hand Edged at 400 and Fast Attack at 5. Valid abilities of 1 give zero
+trickle for this comparison. Read-only guest-memory probes confirm the table's
+adjusted min/max/critical fields at every tier; cached originals stay 5/20/5.
+The equipment window shows red hatching below the retention boundary.
+
+Native Q combat produces the expected ranges for owner and observer. Five
+zero-effectiveness attempts produce zero damage without reducing target HP;
+the client accepts the attack action. Restarting with Brawling 3 preserves
+the same axe and 8..30 normal damage. Restoring Brawling to 4 restores 5/20/5
+client fields and 10..40 server endpoints, and removes the icon's red hatching
+without removing the item. The fixture raises owner Body Development and
+target HP and resets combat/resources between encounters; these are test
+controls, not production balance rules.
+
+`tmp_verify.py` checks the six native field snapshots, all five damage tiers,
+durable identity/skills and recovery, with results in `verification.json`.
+There are zero page errors or adapter failures, and 16 expected socket
+refusals during the intentional restart. The driver's `finally` closes both
+contexts and terminates its server before regression builds.
+
+The full `go test ./server/... -count=1` suite passes. Focused race checks for
+overequipping, attack rating, character stats, armor, equipment, combat,
+inventory and reclaim also pass. Logs are retained alongside the WASM evidence.
diff --git a/server/combat.go b/server/combat.go
@@ -154,6 +154,17 @@ func (attacker *character) normalDamage(target *character, roll func(uint32) uin
rating := stats.effectiveSkill(stats.MartialArts, [6]uint32{20, 50, 0, 0, 0, 30})
if weapon != nil {
rating = stats.effectiveSkill(stats.OneHandEdged, [6]uint32{30, 40, 30, 0, 0, 0})
+
+ // The axe's three action-8 requirements are 4. Native OE checks them all.
+ // FUN_10090f10/100ab8a0: tier = trunc(5*(1-skill/requirement)).
+ brawling := stats.effectiveSkill(stats.Brawling, [6]uint32{60, 0, 40, 0, 0, 0})
+ fastAttack := stats.effectiveSkill(stats.FastAttack, [6]uint32{0, 60, 0, 0, 40, 0})
+ skill := min(rating, brawling, fastAttack)
+ if skill < 4 {
+ tier := min(4, (4-skill)*5/4)
+ minimum -= minimum * tier / 4
+ maximum -= maximum * tier / 4
+ }
}
minimum += minimum * rating / 400
maximum += maximum * rating / 400
diff --git a/server/overequipping_test.go b/server/overequipping_test.go
@@ -0,0 +1,143 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "testing"
+)
+
+func TestOverequippingAxeChecksEveryRequiredSkill(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ oneHandEdged, brawling, fastAttack uint16
+ minimum, maximum uint32
+ }{
+ {"qualified", 400, 5, 5, 10, 40},
+ {"requirement value retained", 400, 4, 4, 10, 40},
+ {"brawling 75 percent", 400, 3, 5, 8, 30},
+ {"fast attack 75 percent", 400, 5, 3, 8, 30},
+ {"one hand edged 75 percent", 3, 5, 5, 4, 15},
+ {"brawling 50 percent", 400, 2, 5, 6, 20},
+ {"fast attack 25 percent", 400, 5, 1, 4, 10},
+ {"worst requirement wins", 400, 3, 1, 4, 10},
+ {"zero one hand edged", 0, 5, 5, 0, 0},
+ {"zero brawling", 400, 0, 5, 0, 0},
+ {"zero fast attack", 400, 5, 0, 0, 0},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player := world.characters[1]
+ world.handleInventory(world.clients[1], inventoryMovePacket(1, 64, 6)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ player.stats.Strength, player.stats.Agility, player.stats.Stamina = 1, 1, 1
+ player.stats.Sense = 1
+ player.stats.OneHandEdged, player.stats.Brawling, player.stats.FastAttack = scenario.oneHandEdged, scenario.brawling, scenario.fastAttack
+
+ minimum := player.normalDamage(world.characters[1000000], func(uint32) uint32 { return 0 })
+ maximum := player.normalDamage(world.characters[1000000], func(limit uint32) uint32 { return limit - 1 })
+
+ if minimum != scenario.minimum || maximum != scenario.maximum || player.inventory.Items[0].Slot != 6 {
+ t.Fatalf("equipped axe damage: got %d..%d want %d..%d, items %+v", minimum, maximum, scenario.minimum, scenario.maximum, player.inventory.Items)
+ }
+ })
+ }
+}
+
+func TestOverequippingIncludesTrickleAndRecoversAfterRestart(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player := world.characters[1]
+ player.stats.OneHandEdged = 398
+ world.handleInventory(world.clients[1], inventoryMovePacket(1, 64, 6)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ player.stats.Brawling = 1 // Two points of ability trickle give effective Brawling 3.
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ target := world.characters[1000000]
+ maximum := func(limit uint32) uint32 { return limit - 1 }
+
+ reduced := player.normalDamage(target, maximum)
+ restarted := newTestInventoryServer(t).characters[1]
+ persisted := restarted.normalDamage(target, maximum)
+ restarted.stats.Brawling = 2 // Effective 4 removes the penalty without re-equipping.
+ restored := restarted.normalDamage(target, maximum)
+ if err := world.saveUser_locked(restarted); err != nil {
+ t.Fatal(err)
+ }
+ secondRestart := newTestInventoryServer(t).characters[1]
+
+ if reduced != 30 || persisted != 30 || restored != 40 || secondRestart.normalDamage(target, maximum) != 40 ||
+ len(secondRestart.inventory.Items) != 1 || secondRestart.inventory.Items[0].Slot != 6 {
+ t.Fatalf("OE did not follow persistent effective skills: reduced %d persisted %d restored %d items %+v", reduced, persisted, restored, secondRestart.inventory.Items)
+ }
+}
+
+func TestOverequippingAdjustedMinimumPrecedesArmor(t *testing.T) {
+ world, _ := newArmorDamageWorld(t)
+ attacker := &character{stats: defaultCharacterStats(), inventory: playerInventory{
+ Items: []ownedItem{{1, 51018, 209283, 1, 6}},
+ }}
+ attacker.stats.OneHandEdged, attacker.stats.Brawling = 398, 1
+
+ damage := attacker.normalDamage(world.characters[1], func(limit uint32) uint32 {
+ if limit != 23 {
+ t.Fatalf("OE and AR adjusted range: got %d want 23", limit)
+ }
+ return limit - 1
+ })
+
+ if damage != 8 {
+ t.Fatalf("AC crossed the OE/AR adjusted minimum: %d", damage)
+ }
+}
+
+func TestOverequippingDoesNotPenalizeFistsAfterUnequip(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player := world.characters[1]
+ world.handleInventory(world.clients[1], inventoryMovePacket(1, 64, 6)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ player.stats.Strength, player.stats.Stamina = 1, 1
+ player.stats.Brawling, player.stats.MartialArts = 0, 398
+ target := world.characters[1000000]
+ maximum := func(limit uint32) uint32 { return limit - 1 }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+
+ axe := player.normalDamage(target, maximum)
+ world.handleInventory(world.clients[1], itemMovePacket(1, 6, 111)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ fists := player.normalDamage(target, maximum)
+ restarted := newTestInventoryServer(t).characters[1]
+
+ if axe != 0 || fists != 10 || restarted.normalDamage(target, maximum) != 10 || restarted.inventory.Items[0].Slot != 64 {
+ t.Fatalf("unequipped axe retained its penalty: axe %d fists %d items %+v", axe, fists, restarted.inventory.Items)
+ }
+}
+
+func TestOverequippingNativeDamageMatchesBothObservers(t *testing.T) {
+ world, owner := newEquipmentWorld(t)
+ player, target := world.characters[1], world.characters[1000000]
+ player.stats.OneHandEdged = 398
+ world.handleInventory(world.clients[1], inventoryMovePacket(1, 64, 6)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ player.stats.Brawling = 1
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true, npcs: map[uint32]bool{1000000: true}}
+ owner.packets = nil
+
+ world.handleCombat(world.clients[1], attackPacket(1, target.id)[20:])
+ world.advanceCombat(player.nextAttack)
+ damage := binary.BigEndian.Uint32(owner.packets[1][29:33])
+ for index, packet := range owner.packets {
+ if len(observer.packets) <= index || !bytes.Equal(packet[16:], observer.packets[index][16:]) {
+ t.Fatal("observers disagree on overequipped damage")
+ }
+ }
+
+ if damage < 8 || damage > 30 || target.health != 100-damage || len(owner.packets) != len(observer.packets) ||
+ binary.BigEndian.Uint32(owner.packets[1][37:41]) != 6 {
+ t.Fatalf("native OE axe hit: damage %d HP %d packets %x", damage, target.health, owner.packets)
+ }
+}