commit be1c1b09be604371b0957f3543df5979c221ca78
parent 2cae7ab0eb93883afa933b337b291bcb33290913
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 01:12:15 +0000
Support Burst for starter and stocked SMGs
Diffstat:
12 files changed, 558 insertions(+), 19 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -139,6 +139,10 @@ research separately. More screenshots and test cases do not count as new gamepla
Martial Artist's issued [Jab of the Snake](docs/jab-of-the-snake.md) now
executes its reusable unarmed attack, nano cost and MA cooldown, with atomic
damage/rewards and native inventory/reconnect checks at level one.
+ [Burst](docs/burst.md) now executes for the issued Solar SMG and stocked
+ Kerans, retaining ammunition under the pre-15.5 policy and committing its
+ damage/rewards with a persistent cooldown. Brawl/Dimach and Aimed Shot remain
+ explicit weapon-special gaps.
Remaining profession essentials stay open. The
[bounded earned affordability sample](docs/early-shop-stock.md#earned-affordability-sample-november-5)
now completes an ordinary level-two Omni mission, buys and wears gloves,
diff --git a/docs/aleph.md b/docs/aleph.md
@@ -19,8 +19,8 @@ Attack uses100% SMG114 against100% Dodge Ranged154. Both endpoints retain
attack100cs, recharge280cs, equip100cs, range32m, Ranged Initiative119,
Projectile damage90, mesh21148, resource35543 and icon9013. The70-round clip
requires type2 Bullets21605. The right-hand-only mask is64. Authored Burst
-capability/requirements are retained; this change does not establish new Burst
-timing or damage rules.
+capability/requirements are retained; execution uses the shared
+[Burst timing and damage rules](burst.md).
| QL | Damage | Critical bonus | Value | Minimum SMG | Minimum Burst |
| --- | --- | --- | --- | --- | --- |
diff --git a/docs/burst.md b/docs/burst.md
@@ -0,0 +1,82 @@
+# Burst on starter and stocked weapons
+
+Burst (148) now executes for a supported main-hand weapon with its original Can
+bit 11. This includes the issued Solar Powered Submachinegun (121571) and the
+QL5/10 Kerans (160476) stock. Previously the shared secondary-special handler
+ignored 148. Existing Fast Attack (147) and Fling (150) remain separate actions.
+
+## Evidence and explicit alpha rules
+
+The original Solar SMG tip instructs the player to equip it and use its special
+from the Command View. Its item record has Burst capability and unlimited ammo;
+its only equip requirement is Fixer. The Kerans record has a 120-round bullet
+clip, PoisonAC96 damage, 145cs recharge and BurstCycle374=1500.
+
+The original `kkr.dll` SHA256 is
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
+REA evidence `ev_9ddecd111919ceef3733fcf70d11a5547aeab67f5f26124f4607d199ff810f2b`
+contains focused decompilation of `100aaf10` (Can-bit selection) and `100ab060`
+(recharge arithmetic). The complete record is retained in
+`local/alpha-burst/native-evidence.json`. The lifted instructions in
+`client/game/kkr.dll/lifted-0050.c`, `sub_360AB060`, also show the Burst branch
+loading its 800cs floor before the integer conversion.
+
+The server uses `(RechargeDelay210 * 20 + BurstCycle374 - Burst148 * 4)`
+centiseconds, floors at 800 and rounds up to whole seconds. It then applies the
+shared SkillLockModifier382 conversion. The original client helper's observed
+caller discards its result, so using it for authoritative server timing and the
+whole-second rounding are explicit provisional choices, not recovered server
+code. For a QL1 Kerans at effective Burst 10 this is 44 seconds; high skill reaches
+the 8-second floor. The Solar weapon has no BurstCycle contribution.
+
+Damage is the sum of three independent noncritical ordinary weapon rolls,
+capped at target HP. Each roll uses the existing attack rating, overequipping,
+matching armor and damage bonuses. This distribution is explicit alpha policy;
+the original server's Burst distribution has not been recovered. This retains
+the existing [pre-15.5 special policy](fling-shot.md#target-era-evidence): no
+defensive hit check or ammunition deduction. A finite clip must contain at least
+one round, including when it contains fewer than three; unlimited weapons return
+ammo -1 in the result. Empty-clip admission remains provisional.
+
+## Shared lifecycle
+
+Burst uses the existing range/visibility, alive/ready-owner, equipped-weapon,
+reload, posture and lock checks. It does not reset normal attack/recharge or
+nano clocks. A matching active fight receives the native special action before
+the named SpecialAttackInfo result and skill lock. Idle use retains the shared
+special handler's existing presentation limits; dual wield remains outside the
+implemented main-hand path.
+
+Lock 148, damage, contribution, corpse/loot and XP commit together before any
+success is sent. Failure leaves the live and durable state unchanged. Repeated
+requests, weapon changes and reconnect cannot bypass the deadline. Expiry uses
+the existing memory-only lock cleanup and native action 164 notification.
+
+## Verification scope
+
+`TestBurst*` covers independent bullet rolls without critical/defense draws,
+native result fields, no ammo loss, recharge/skill/floor inputs, unlimited ammo,
+invalid requests, duplicate/reuse clocks, cold recovery, and rejected/ignored
+lock, damage, loot and XP writes followed by retry.
+
+`TestBrowserBurst` uses real inventory equip, targeting, Q and the native M
+binding, then checks damage and clip state against the server. It reconnects
+with the lock active, waits for ordinary expiry and uses Burst again before
+cold loading. The Solar case uses ordinary level-one Fixer creation without
+training or item grants. The Kerans case uses the established cap-checked
+level-ten fixture and a stocked QL10 weapon with three rounds. Both use a nearby
+controlled Leet with 1000 HP and hold ordinary swings, isolating Burst. This is not
+an earned progression or purchase-affordability run.
+
+November 5: all 35 selected server roots pass, including existing Fast Attack,
+Fling, special presentation and skill-lock regressions. Both native cases pass:
+Solar deals 18 per Burst and Kerans deals 126 under deterministic maximum rolls;
+their exact inventories and remaining cooldowns survive reconnect and cold
+loading. The browser run took 99.25 seconds. Its evidence is under
+`local/alpha-burst/20261105-171018/{solar,kerans}/`, with `verification.json`,
+screenshots and native traces. Logs are `local/alpha-burst/regressions.log` and
+`browser.log`. JavaScript syntax, diff checks and `go vet ./server` also pass.
+The test browser/server sessions and the REA native session were closed.
+
+This completes the demonstrated Burst rejection within A5. It does not close
+the remaining Brawl/Dimach/Aimed Shot gaps or A7's faction/profession matrix.
diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md
@@ -213,9 +213,10 @@ Prices precede Computer Literacy discounts. Original family audits and consumer
coverage are in [M-10 pistols](catalog-weapons.md), [E-Beamers](e-beamer.md),
[Vektors](vektor-shotguns.md), [Sledgehammers](sledgehammer.md),
[Gripo rifles](gripo-rifles.md) and [Kerans SMGs](kerans.md). All six support ordinary
-attacks. M-10/E-Beamer Fling uses the existing handler. Sledgehammer Brawl/Dimach,
-Gripo Aimed Shot and Kerans Burst remain unimplemented shared actions; stock does
-not complete them. The Kerans also applies its original +2 Sense wear bonus.
+attacks. M-10/E-Beamer Fling and [Kerans Burst](burst.md) use the shared special
+handler. Sledgehammer Brawl/Dimach and Gripo Aimed Shot remain unimplemented
+shared actions; stock does not complete them. The Kerans also applies its
+original +2 Sense wear bonus.
Unfinished profession essentials remain outstanding. These funded checks do not
establish that ordinary early rewards can pay the listed prices.
@@ -290,7 +291,8 @@ subdirectories `c005049f`, `c026049c` and `c01204a2`. The three-shop run took
`regressions.log`. `go vet ./server`, JavaScript syntax and diff checks also pass
(`vet.log`). Test servers and Chromium processes were closed. The remaining
A5 work is profession essentials; the earned affordability sample is above.
-Aimed Shot/Burst are still explicit combat gaps.
+Aimed Shot remains an explicit combat gap. [Burst now executes](burst.md), with
+separate starter Solar SMG and stocked Kerans native checks.
## Basic nano crystals
diff --git a/docs/fast-attack.md b/docs/fast-attack.md
@@ -64,7 +64,7 @@ in a mirror; the original official article remains unavailable.
## Server behavior and limits
-The shared handler accepts147/150 only for a ready authenticated owner, visible
+The shared handler accepts147/148/150 only for a ready authenticated owner, visible
living creature in range and supported right-hand weapon with the relevant
capability. Sitting, vehicles, equip/reload activity and an active lock reject
the request without damage or success feedback. Several action gates remain
diff --git a/docs/fling-shot.md b/docs/fling-shot.md
@@ -72,8 +72,9 @@ Fresh REA evidence is in `local/fling-shot-research/native-evidence.json`:
## Server behavior and limits
-The shared weapon-special handler accepts Fling150 with Can bit 12 and
-Fast Attack147 with Can bit 18 on a supported right-hand weapon. Unlimited-ammo
+The shared weapon-special handler accepts Fling150 with Can bit 12,
+Fast Attack147 with Can bit 18 and [Burst148](burst.md) with Can bit 11 on a
+supported right-hand weapon. Unlimited-ammo
weapons, including the solar shotgun, send result ammunition -1; see
[catalog weapons](catalog-weapons.md). Fling requires the authenticated, ready
14.9.1 owner and a visible living creature in range. It rejects
diff --git a/docs/kerans.md b/docs/kerans.md
@@ -5,7 +5,8 @@ OT Kerans Automatic Grinner 160478/160479 admits QL99..199 through the shared
quality, wear, weapon, price and native delivery paths. Previously a qualified
QL2 instance stayed carried after a native wear request. The production change
is two explicit family rows; Quality OT Kerans 160480 remains fixed at QL200.
-Burst requirements are checked, but the separate Burst attack remains open.
+Burst requirements are checked, and the shared [Burst attack](burst.md) now
+executes with persistent cooldown and explicit provisional damage/timing rules.
## Original contracts
@@ -19,7 +20,7 @@ Sense (20): two for Cheap, four for regular and six for fixed QL200.
All retain minimum damage1, attack150cs, recharge145cs, equip350cs, range27m,
Ranged Initiative (119), Poison damage (96), mesh21147, resource21128 and
icon9013. The 120-round clip uses ammunition type2, supplied by Bullets21605.
-The authored Burst cycle1500 is retained without claiming a working special.
+The authored Burst cycle1500 contributes to the shared special's cooldown.
| QL | Maximum | Critical bonus | Value | Minimum SMG | Minimum Burst | Sense |
| --- | --- | --- | --- | --- | --- | --- |
diff --git a/docs/nova-flow.md b/docs/nova-flow.md
@@ -19,8 +19,8 @@ Attack uses67% Assault Rifle116 and33% Ranged Energy133, with100% Dodge
Ranged154 defense. Both endpoints retain attack150cs, recharge250cs, equip50cs,
range20m, Ranged Initiative119, Energy damage92, mesh33144, resource35564
and icon9013. Their20-round clip takes Energy Ammo21609. Burst and Fling
-capabilities and requirements are preserved; this admission does not recover
-Burst execution or establish new special timing rules.
+capabilities and requirements are preserved; execution uses the shared
+[Burst](burst.md) and [Fling](fling-shot.md) handlers and their provisional rules.
| QL | Damage | Critical bonus | Value | Minimum Assault Rifle | Minimum Ranged Energy | Minimum Burst | Minimum Fling |
| --- | --- | --- | --- | --- | --- | --- | --- |
diff --git a/server/browser_burst_test.go b/server/browser_burst_test.go
@@ -0,0 +1,111 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserBurst(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for native starter and stocked Burst weapons")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-burst", time.Now().Format("20060102-150405"))
+ for _, name := range []string{"solar", "kerans"} {
+ t.Run(name, func(t *testing.T) {
+ world := newTestServer(t)
+ fields := creationForm()
+ fields.Set("profession", "4")
+ if response := creationRequest(world, accountVisitor(t, world), fields); response.Code != http.StatusNoContent {
+ t.Fatal(response.Code, response.Body.String())
+ }
+ player := world.characters[2]
+ damage := 18
+ if name == "kerans" {
+ // The stocked QL10 upgrade uses the existing cap-checked checkpoint.
+ trainBasicShopWeaponFixture(t, player)
+ player.inventory.Items[3].Template, player.inventory.Items[3].Quality, player.inventory.Items[3].Ammo = 160476, 10, 3
+ damage = 126
+ }
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("burst")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ var target *character
+ for _, actor := range world.characters {
+ if actor.npc && actor.playfield == 950 && actor.monsterData == 17655 && actor.level == 1 && actor.combatProfile != nil && (target == nil || actor.id < target.id) {
+ target = actor
+ }
+ }
+ if target == nil {
+ t.Fatal("original Leet unavailable")
+ }
+ forward, _ := bodyAxes(player.rotation)
+ target.position = [3]float32{player.position[0] + 2*forward[0], player.position[1], player.position[2] + 2*forward[2]}
+ target.health = 1000
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ json.NewEncoder(w).Encode(map[string]any{"target": target.id, "health": target.health, "fighting": player.fighting,
+ "locked": time.Now().Before(player.skillLocks[148]), "inventory": player.inventory, "level": player.level,
+ "ip": player.stats.ImprovementPoints, "damage": damage, "weapon": player.inventory.Items[3].Template})
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ defer closeTestSessions(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ ticker := time.NewTicker(20 * time.Millisecond)
+ defer ticker.Stop()
+ for {
+ select {
+ case now := <-ticker.C:
+ // Isolate Burst from ordinary swings while using normal equip/lock updates.
+ world.advanceEquipment(now)
+ world.advanceItemEffects(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_burst.mjs"), host.URL, filepath.Join(output, name))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ cancel()
+ <-stopped
+ closeTestSessions(t, world)
+ t.Logf("Browser artifacts: %s", filepath.Join(output, name))
+ if err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+ if cold.characters[target.id].health != uint32(1000-2*damage) || !reflect.DeepEqual(cold.characters[2].inventory, player.inventory) ||
+ !cold.characters[2].skillLocks[148].Equal(player.skillLocks[148]) || cold.characters[2].skillLocks[148].IsZero() {
+ t.Fatal("native Burst damage, ownership or lock changed on cold recovery")
+ }
+ })
+ }
+}
diff --git a/server/burst_test.go b/server/burst_test.go
@@ -0,0 +1,237 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "testing"
+ "time"
+)
+
+func burstRequest(owner, target uint32) []byte {
+ request := flingShotRequest(owner, target)
+ binary.BigEndian.PutUint32(request[len(request)-4:], 148)
+ return request
+}
+
+func TestBurstRollsEachBulletWithoutCriticalOrDefenseChecks(t *testing.T) {
+ world, _ := newBurstWorld(t)
+ target := world.characters[1000000]
+ target.stats.Speed.DodgeRanged = 10000
+ rolls := 0
+ world.combatRoll = func(limit uint32) uint32 {
+ if limit != 27 || rolls >= 3 {
+ t.Fatal("Burst used a critical/defense roll or wrong damage range", limit, rolls)
+ }
+ value := []uint32{0, 13, 26}[rolls]
+ rolls++
+ return value
+ }
+
+ err := world.handleWeaponSpecial(world.clients[1], burstRequest(1, target.id)[20:])
+
+ if err != nil || rolls != 3 || target.health != 958 {
+ t.Fatal("Burst did not sum three independent ordinary hits", rolls, target.health, err)
+ }
+}
+
+func TestBurstWeaponAndSkillInputsSetItsOwnCooldown(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ template uint32
+ skill uint16
+ seconds int
+ }{
+ {"Kerans", 160476, 10, 44},
+ {"skill", 160476, 25, 43},
+ {"floor", 160476, 1000, 8},
+ {"solar", 121571, 10, 20},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ world, output := newBurstWorld(t)
+ player := world.characters[1]
+ player.stats.Ranged.Burst = scenario.skill
+ player.inventory.Items[0].Template = scenario.template
+ if scenario.template == 121571 {
+ player.inventory.Items[0].Ammo = 0
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ start := time.Now()
+
+ err := world.handleWeaponSpecial(world.clients[1], burstRequest(1, 1000000)[20:])
+
+ if err != nil || player.skillLocks[148].Before(start.Add(time.Duration(scenario.seconds)*time.Second)) ||
+ player.skillLocks[148].After(time.Now().Add(time.Duration(scenario.seconds)*time.Second)) ||
+ !player.skillLocks[150].IsZero() || !player.skillLocks[147].IsZero() {
+ t.Fatal("wrong independent Burst deadline", player.skillLocks, err)
+ }
+ if scenario.template == 121571 && binary.BigEndian.Uint32(output.packets[0][37:41]) != ^uint32(0) {
+ t.Fatal("solar Burst published finite ammunition")
+ }
+ })
+ }
+}
+
+func TestBurstRejectsInvalidUseWithoutDamageOrLock(t *testing.T) {
+ for _, scenario := range []string{"empty", "weapon", "stored", "reload", "locked", "sitting", "hidden", "range", "unready", "owner", "dead"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, output := newBurstWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ request := burstRequest(1, 1000000)[20:]
+ switch scenario {
+ case "empty":
+ player.inventory.Items[0].Ammo = 0
+ case "weapon":
+ player.inventory.Items[0].Template = 123742
+ case "stored":
+ player.inventory.Items[0].Slot = 65
+ case "reload":
+ client.reloadUntil = time.Now().Add(time.Minute)
+ case "locked":
+ player.setSkillLock_locked(148, time.Now().Add(time.Minute))
+ case "sitting":
+ player.sitting = true
+ case "hidden":
+ delete(client.npcs, 1000000)
+ case "range":
+ world.characters[1000000].position[0] = 1000
+ case "unready":
+ client.ready = false
+ case "owner":
+ binary.BigEndian.PutUint32(request[8:], 2)
+ case "dead":
+ player.health = 0
+ }
+ before, deadline := player.inventory, player.skillLocks[148]
+
+ err := world.handleWeaponSpecial(client, request)
+
+ if err != nil || world.characters[1000000].health != 1000 || !player.skillLocks[148].Equal(deadline) ||
+ !reflect.DeepEqual(player.inventory, before) || len(output.packets) != 0 {
+ t.Fatal("rejected Burst changed state or feedback", err)
+ }
+ })
+ }
+}
+
+func TestBurstRetriesShareLockAndPreserveNormalAttackClock(t *testing.T) {
+ world, output := newBurstWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory.Items[0].Ammo = 1
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleCombat(client, attackPacket(1, 1000000)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ attack, recharge := player.nextAttack, player.rechargeUntil
+ output.packets = nil
+
+ for range 2 {
+ if err := world.handleWeaponSpecial(client, burstRequest(1, 1000000)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cold := newTestInventoryServer(t)
+
+ if world.characters[1000000].health != 919 || player.inventory.Items[0].Ammo != 1 ||
+ player.nextAttack != attack || player.rechargeUntil != recharge || cold.characters[1].skillLocks[148].IsZero() {
+ t.Fatal("Burst retry changed the shot, ammo or normal attack clock")
+ }
+ if binary.BigEndian.Uint32(output.packets[0][16:20]) != 0x51492120 || binary.BigEndian.Uint32(output.packets[1][16:20]) != 0x754f1115 {
+ t.Fatal("matching fight omitted native action before result")
+ }
+ world.advanceItemEffects(player.skillLocks[148])
+ if err := world.handleWeaponSpecial(client, burstRequest(1, 1000000)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if world.characters[1000000].health != 838 || player.inventory.Items[0].Ammo != 1 {
+ t.Fatal("unlocked Burst did not execute once with a one-round clip")
+ }
+}
+
+func TestBurstFailedKillRollsBackLockLootAndExperience(t *testing.T) {
+ for index, failure := range []string{
+ "BEFORE INSERT ON skill_locks BEGIN SELECT RAISE(IGNORE); END",
+ "BEFORE UPDATE OF health ON characters WHEN NEW.id=1000000 BEGIN SELECT RAISE(FAIL,'target'); END",
+ "BEFORE INSERT ON items BEGIN SELECT RAISE(FAIL,'loot'); END",
+ "BEFORE UPDATE OF experience ON characters WHEN NEW.id=1 BEGIN SELECT RAISE(IGNORE); END",
+ } {
+ t.Run(fmt.Sprint(index), func(t *testing.T) {
+ world, output := newBurstWorld(t)
+ player, target := world.characters[1], world.characters[1000000]
+ target.health = 1
+ world.combatRoll = func(uint32) uint32 { return 0 }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := world.db.Exec("CREATE TRIGGER fail_burst " + failure); err != nil {
+ t.Fatal(err)
+ }
+
+ err := world.handleWeaponSpecial(world.clients[1], burstRequest(1, 1000000)[20:])
+ cold := newTestInventoryServer(t)
+
+ if err == nil || target.health != 1 || target.corpse != nil || !player.skillLocks[148].IsZero() || player.experience != 0 ||
+ cold.characters[1].experience != 0 || !cold.characters[1].skillLocks[148].IsZero() || cold.characters[1000000].health != 1 || len(output.packets) != 0 {
+ t.Fatal("failed Burst retained partial kill effects", err)
+ }
+ if _, err := world.db.Exec("DROP TRIGGER fail_burst"); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleWeaponSpecial(world.clients[1], burstRequest(1, 1000000)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cold = newTestInventoryServer(t)
+ if target.health != 0 || target.corpse == nil || len(target.corpse.items) != 1 || target.corpse.credits != 1 || player.experience != 100 ||
+ cold.characters[1].experience != 100 || cold.characters[1].skillLocks[148].IsZero() || cold.characters[1000000].corpse == nil ||
+ cold.characters[1].inventory.Items[0].Ammo != 3 {
+ t.Fatal("retried Burst kill did not commit exactly once")
+ }
+ })
+ }
+}
+
+func newBurstWorld(t *testing.T) (*server, *combatTestConn) {
+ t.Helper()
+ world, output := newKillExperienceWorld(t, "fling")
+ player := world.characters[1]
+ player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1}
+ player.stats.Ranged.SubmachineGun, player.stats.Ranged.Burst = 20, 10
+ world.characters[1000000].health = 1000
+ player.inventory.Items[0].Template = 160476
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ return world, output
+}
+
+func TestBurstUsesThreeNoncriticalHitsAndPreservesPre155Ammo(t *testing.T) {
+ world, output := newBurstWorld(t)
+ player, target := world.characters[1], world.characters[1000000]
+ inventory := player.inventory
+ started := time.Now()
+
+ err := world.handleWeaponSpecial(world.clients[1], burstRequest(1, target.id)[20:])
+ cold := newTestInventoryServer(t)
+
+ if err != nil || target.health != 919 || !reflect.DeepEqual(player.inventory, inventory) ||
+ !reflect.DeepEqual(cold.characters[1].inventory, inventory) || cold.characters[target.id].health != 919 ||
+ !cold.characters[1].skillLocks[148].Equal(player.skillLocks[148]) ||
+ player.skillLocks[148].Before(started.Add(44*time.Second)) || player.skillLocks[148].After(time.Now().Add(44*time.Second)) {
+ t.Fatalf("Burst damage/ammo/cooldown: HP %d, locks %v, error %v", target.health, player.skillLocks, err)
+ }
+ if len(output.packets) == 0 || binary.BigEndian.Uint32(output.packets[0][16:20]) != 0x754f1115 ||
+ binary.BigEndian.Uint32(output.packets[0][33:37]) != 81 || binary.BigEndian.Uint32(output.packets[0][37:41]) != 3 ||
+ binary.BigEndian.Uint32(output.packets[0][49:53]) != 148 {
+ t.Fatal("native Burst result missing or incorrect")
+ }
+}
diff --git a/server/weapon_special.go b/server/weapon_special.go
@@ -4,13 +4,20 @@ import (
"ao/server/gamedata"
"encoding/binary"
"fmt"
+ "math/rand/v2"
"time"
)
func (player *character) weaponSpecialLockSeconds(weapon *gamedata.Item, skill uint32) uint32 {
+ value, _ := player.effectiveStat(skill)
+ if skill == 148 {
+ // kkr.dll 100ab060: recharge * 20 + BurstCycle - Burst * 4, floor 800cs.
+ // Using the client helper for server timing is provisional; see docs/burst.md.
+ centiseconds := int64(itemStat(weapon, 210))*20 + int64(itemStat(weapon, 374)) - int64(value)*4
+ return uint32((max(800, centiseconds) + 99) / 100)
+ }
// February 2003 formula: attack delay * 15 - special skill / 100.
// Whole-second rounding and the minimum are provisional; see docs/fling-shot.md.
- value, _ := player.effectiveStat(skill)
centiseconds := int64(itemStat(weapon, 294))*15 - int64(value)
return uint32(max(1, (centiseconds+99)/100))
}
@@ -26,7 +33,7 @@ func (server *server) handleWeaponSpecial(client *worldClient, body []byte) erro
skill := binary.BigEndian.Uint32(body[24:28])
if server.clients[client.id] != client || !client.target || !client.ready || client.loading || player.health == 0 ||
binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id ||
- binary.BigEndian.Uint32(body[16:20]) != 50000 || (skill != 147 && skill != 150) {
+ binary.BigEndian.Uint32(body[16:20]) != 50000 || (skill != 147 && skill != 148 && skill != 150) {
server.mutex.Unlock()
return nil
}
@@ -39,10 +46,12 @@ func (server *server) handleWeaponSpecial(client *worldClient, body []byte) erro
server.mutex.Unlock()
return nil
}
- // WeaponItem 100aaf10: Fast Attack uses capability bit18, Fling bit12.
+ // WeaponItem 100aaf10: Fast Attack bit18, Burst bit11, Fling bit12.
capability := uint32(1 << 12)
if skill == 147 {
capability = 1 << 18
+ } else if skill == 148 {
+ capability = 1 << 11
}
var item *ownedItem
for index := range player.inventory.Items {
@@ -51,14 +60,27 @@ func (server *server) handleWeaponSpecial(client *worldClient, body []byte) erro
break
}
}
- if item == nil || item.templateStat(30)&capability == 0 || skill == 150 && item.usesAmmo() && item.Ammo == 0 {
+ if item == nil || item.templateStat(30)&capability == 0 || skill != 147 && item.usesAmmo() && item.Ammo == 0 {
server.mutex.Unlock()
return nil
}
// Prepare a detached result so a failed transaction changes no live actor.
seconds := player.weaponSpecialLockSeconds(player.attackWeapon(), skill)
- damage, _ := server.weaponHit_locked(player, target)
+ var damage uint32
+ if skill == 148 {
+ // Three independent noncritical hits; no later defensive checks or ammo debit.
+ roll := server.combatRoll
+ if roll == nil {
+ roll = rand.Uint32N
+ }
+ for range 3 {
+ damage += player.weaponDamage(target, false, roll)
+ }
+ damage = min(damage, target.health)
+ } else {
+ damage, _ = server.weaponHit_locked(player, target)
+ }
candidate := server.prepareWeaponDamage_locked(player, target, damage, now)
award, err := server.saveSpecialAttack_locked(player, &candidate, skill, now.Add(time.Duration(player.skillLockSeconds(seconds))*time.Second), now)
if err != nil {
@@ -77,7 +99,7 @@ func (server *server) handleWeaponSpecial(client *worldClient, body []byte) erro
var result []byte
death := uint32(0)
ammunition := ^uint32(0)
- if skill == 150 && item.usesAmmo() {
+ if skill != 147 && item.usesAmmo() {
ammunition = item.Ammo
}
if target.health == 0 {
diff --git a/tools/client/test_burst.mjs b/tools/client/test_burst.mjs
@@ -0,0 +1,79 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'burst', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const waitServer = (label, predicate) => game.waitFor(label, async () => predicate(await server()));
+ const checkNative = async health => game.wait('native Burst HP and ammunition agree', state =>
+ state.actors.find(actor => actor.type === 50000 && actor.id === evidence.initial.target)?.stats[27] === health &&
+ game.local(state).weapons.some(weapon => weapon.slot === 6 && weapon.loadedAmmo === (evidence.initial.weapon === 121571 ? -1 : 3)));
+ await page.goto(url);
+ await game.ready();
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.key('KeyI');
+ evidence.initial = await server();
+ const cell = game.state.grids.flatMap(grid => grid.cells).find(cell => cell.identity[0] === 104 && cell.identity[1] === 51 && !cell.dummy);
+ assert(cell, 'issued or stocked SMG is visible');
+ await game.click((cell.bounds[0]+cell.bounds[2])/2, (cell.bounds[1]+cell.bounds[3])/2, 'right');
+ await waitServer('SMG equipped normally', state => state.inventory.Items.some(item => item.ID === 4 && item.Slot === 6));
+ await game.wait('native equipped weapon ready', state => game.local(state).weapons.some(weapon => weapon.slot === 6));
+ evidence.equipped = await server();
+ await game.key('Tab');
+ await game.wait('original Leet selected', state => state.selected[0] === 50000 && state.selected[1] === evidence.initial.target);
+ await game.key('KeyQ');
+ await waitServer('normal fight started', state => state.fighting === evidence.initial.target);
+ await game.key('KeyM');
+ await waitServer('Burst damage and lock committed', state => state.health === 1000-state.damage && state.locked);
+ await checkNative(1000-evidence.initial.damage);
+ evidence.first = await server();
+ assert.deepEqual(evidence.first.inventory, evidence.equipped.inventory);
+ await game.save(output + '/first');
+
+ await game.key('KeyM');
+ assert.equal((await server()).health, evidence.first.health);
+ await page.reload();
+ await game.ready();
+ evidence.reconnected = await server();
+ assert(evidence.reconnected.locked);
+ assert.equal(evidence.reconnected.health, evidence.first.health);
+ assert.deepEqual(evidence.reconnected.inventory, evidence.first.inventory);
+ await checkNative(evidence.first.health);
+ await game.save(output + '/reconnected');
+
+ // Wait for the real server deadline and native unlock rather than shortening it.
+ await game.wait('native Burst unlock received', () => game.events.some(event => {
+ if (event.direction !== 'framereceived' || event.opcode !== '5e477770') return false;
+ const packet = Buffer.from(event.hex, 'hex');
+ return packet.readUInt32BE(29) === 164 && packet.readUInt32BE(45) === 148;
+ }), 60000);
+ assert(!(await server()).locked);
+ await game.click(...await game.pick(50000, evidence.initial.target));
+ await game.key('KeyQ');
+ await waitServer('fight resumed', state => state.fighting === evidence.initial.target);
+ await game.key('KeyM');
+ await waitServer('second Burst commits after expiry', state => state.health === 1000-2*state.damage && state.locked);
+ await checkNative(1000-2*evidence.initial.damage);
+ evidence.second = await server();
+ assert.deepEqual(evidence.second.inventory, evidence.first.inventory);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS:', evidence.initial.weapon, 'native equip, Burst, unchanged ammo, cooldown, reconnect and repeat');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}