aorecomp

Anarchy Online classic in the browser

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


commit 21758db1dea2d349447e9536b41786e254963603
parent a9b337fb402eb9b89cd3c15594b0d7bbdd39eb16
Author: anon <anon@example.com>
Date:   Wed,  4 Nov 2026 04:22:50 +0000

Admit bounded MB01 Minibull profiles with original Headbutt

Diffstat:
MTODO.md | 9+++++++++
Mdocs/combat-npc-balance.md | 1+
Adocs/minibull.md | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/browser_minibull_test.go | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/gamedata/minibull_test.go | 18++++++++++++++++++
Mserver/gamedata/npc_combat.yaml | 44++++++++++++++++++++++++++++++++++++++++++++
Aserver/minibull_test.go | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/starter_fauna_test.go | 3+++
Atools/client/test_minibull.mjs | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 451 insertions(+), 0 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -1107,6 +1107,15 @@ for exact records, protocol, tests and remaining reconstruction assumptions. scanner travel, fatal retaliation, saved return and cold collection conserve all 24 reclaim instances, including charged supplies and the bound mission key. See [later earned-level regression](docs/character-progression.md#later-earned-level-regression). +- [x] [P0] Admit bounded early MB01 Minibull combat through shared data rules. + Original Headbutt endpoints and actor QL replace the generic weapon fallback + at levels1..10. HP/XP/ratings, attack choice and loot remain explicitly + provisional; all four source groups retain their positions and ranges to37. + Handler checks cover admission boundaries, phases, six killing actions and + cold rewards. A short controlled two-client WASM check verifies normal + Headbutt23, real attack/corpse pickup, QL5 loot, ammunition and page/cold + ownership. It is not earned balance or XP-eligibility evidence. The broader + progression/loot tasks remain open; see [Minibulls](docs/minibull.md). - [ ] [P1] Recover ordinary NPC attack selection and authored attack procs. Verify original loadouts, choice/scheduling, damage types and complete effects for one admitted family through shared rules and native combat. Period diff --git a/docs/combat-npc-balance.md b/docs/combat-npc-balance.md @@ -5,6 +5,7 @@ not supply a complete set of historical creature health, ratings and armor. The server admits Leet levels 1..10 through the bounded profiles below and [mapped Tiny Stalkers at levels 2..4](tiny-stalker.md). Unprofiled creatures retain prototype 100 HP, 5 damage and one-second attack/recharge phases. +The [MB01 Minibull range](minibull.md) uses original Headbutt endpoints at levels1..10. The [Omni training boss](omni-training-boss.md) now uses an explicit level-4 profile and original Aquaan attack endpoints; its identity and balance remain provisional. The separate Clan boss retains its existing independent profile. diff --git a/docs/minibull.md b/docs/minibull.md @@ -0,0 +1,55 @@ +# Bounded early Minibull combat + +MB01 Minibulls using original body30360 now have explicit level1..10 combat +profiles. Other codes, including MB02 and INIB, do not inherit this admission. +The original population groups, counts, positions, identity confidence and +level ranges remain unchanged. Higher levels retain the existing unprofiled +fallback; they are not extrapolated from the admitted range. + +## Original resources + +The format-aware original database reread matches all six complete Headbutt, +Kick and equipper records120961..120966, including decoded fields, raw payload +hashes and file offsets. Original index SHA256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. +Headbutt endpoints120961/120962 span QL1..400, use Martial Arts100 against +Evade Close155, MeleeAC91, range2 and235-centisecond attack/recharge phases. +QL1 normal damage is9..16 with critical bonus9; shared native rounding gives +QL4 normal12..23 and QL10 normal18..36. Choosing Headbutt rather than Kick is +provisional; the original server's selection/loadout is not established. + +Original population resource1000014 also confirms MB01 in four maintained +groups: three in Athen Shire550, with ranges4..37,3..37 and1..37, and one in +Wailing Wastes551 at6..37. All30 maintained placements are retained. Their +spread positions remain the existing reconstruction policy. The body/code +association remains inferred species evidence, rather than an exact original +NPC template. The original records, source/maintained group hashes and a local +wiki snapshot are retained under `local/minibull-profile/`. + +## Reconstruction boundaries + +Explicit anchors at1,2,4 and10 use the existing early-combat balance subset: +100HP/XP at1/2,150 at4 and300 at10, with raw MA/evades/Nano Resist5,15 and45. +The shared loader interpolates within those bounds. Initiative0, AggDef75, +100-second respawn,180-second corpse retention,1..5 credits and50% Monster +Parts with nearby QL intervals are provisional. These are not original species +resource measurements, loot membership/chance evidence or a universal growth +formula. No new item family, social/proximity aggression or Virulent variant +behavior is inferred from the later wiki description. + +## Focused verification + +Public-handler checks preserve the full source group's13 positions and levels, +including unprofiled11..16, through cold loading. They protect code/body/evidence +and level boundaries, native Headbutt endpoints/actor QL, the exact23-point +normal QL4 hit and both235-centisecond phases. Six direct killing actions at +levels1/4/10 retain selected Monster Parts, cash, XP and exact cold corpse +ownership through the shared transaction. + +The two-client WASM fixture controls position, a level4 full-health Minibull, +player gear/skills, simulation checkpoints and lethal/loot rolls. It first +observes the original normal Headbutt separately from the forced outcome. +The player's real native attack, corpse opening and item pickup exercise +delivery and physical ownership. This is not earned progression, original +resource balance, critical probability or XP eligibility evidence. The broader +P0 progression/loot tasks remain open. diff --git a/server/browser_minibull_test.go b/server/browser_minibull_test.go @@ -0,0 +1,129 @@ +package main + +import ( + "ao/server/assets" + "ao/server/gamedata" + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "runtime" + "slices" + "testing" + "time" +) + +func TestBrowserMinibullProfile(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for the focused Minibull encounter") + } + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/minibull-profile", time.Now().Format("20060102-150405")) + data := testNPCData() + group := *gamedata.NPCGroups["550/district/4/group/8/spread_authored_point"] + group.Levels, group.Positions, group.PlacementStatus = [2]uint16{4, 4}, [][3]float32{{960, 16.5, 514}}, "fixed_point" + data.Playfields[0].ID, data.Playfields[0].Districts[0].Groups[0] = 705, group + useNPCData(t, data) + useResources(t, assets.Files) + world := newTestServer(t) + npc := world.characters[1000000] + for index := range 2 { + player := world.newCharacter() + player.name = fmt.Sprint("Minibull", index) + player.playfield, player.position = 705, [3]float32{960 + float32(index*2), 16.5, 512} + player.rotation = [4]float32{0, 0, 0, 1} + player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprint("minibull-", index)))) + if index == 0 { + player.level, player.profession = 100, 7 + player.stats.Abilities = characterAbilitiesStats{200, 200, 200, 200, 200, 200} + player.stats.Body.BodyDevelopment, player.stats.Ranged.Shotgun = 100, 300 + if player.trainingMaximum(152) < 100 || player.trainingMaximum(115) < 300 { + t.Fatal("controlled combat skills exceed their training caps") + } + } + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.savePosition_locked(player); err != nil { + t.Fatal(err) + } + } + player := world.characters[1] + if granted, err := world.grantItem_locked(player, 124261); err != nil || !granted { + t.Fatal(granted, err) + } + inventory := player.inventory + inventory.Items[0].Quality, inventory.Items[0].Slot, inventory.Items[0].Ammo = 75, 6, 13 + if err := world.saveInventory_locked(player, inventory); err != nil { + t.Fatal(err) + } + player.health = player.maximumHealth() + if err := world.savePosition_locked(player); err != nil { + t.Fatal(err) + } + world.combatRoll = landedCombatRoll + 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{"npc": npc.id, "health": npc.health, "maximum": npc.maximumHealth(), + "owner_health": player.health, "owner_target": player.fighting, "inventory": player.inventory, "experience": player.experience}) + }) + // Advance one original Headbutt before the owner's real native attack. + mux.HandleFunc("POST /test-headbutt", func(w http.ResponseWriter, r *http.Request) { + world.updateMutex.Lock() + world.mutex.Lock() + updates := make(map[*worldClient][][]byte) + world.startAttack_locked(npc, player, time.Now(), updates) + deadline := npc.nextAttack + world.mutex.Unlock() + world.sendCombatUpdates(updates) + world.updateMutex.Unlock() + world.advanceCombat(deadline) + }) + mux.HandleFunc("POST /test-owner-swing", func(w http.ResponseWriter, r *http.Request) { + world.mutex.Lock() + deadline := player.nextAttack + // Force the lethal/loot checkpoint independently of the normal Headbutt. + world.combatRoll = func(limit uint32) uint32 { + if limit == 10000 || limit == 100 { + return 0 + } + return limit - 1 + } + world.mutex.Unlock() + world.advanceCombat(deadline) + }) + host := httptest.NewServer(mux) + t.Cleanup(host.Close) + closeTestBrowserStreams(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_minibull.mjs"), host.URL, output) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + err := command.Run() + + t.Logf("Browser artifacts: %s", output) + if err != nil { + t.Fatal(err) + } + cold := newTestInventoryServer(t) + expected := []ownedItem{{ID: 1, Type: 51018, Template: 124261, Quality: 75, Slot: 6, Count: 1, Ammo: 12}, + {ID: 2, Type: 51005, Template: 42640, Quality: 5, Slot: 64, Count: 1}} + for _, current := range []*server{world, cold} { + if !slices.Equal(current.characters[1].inventory.Items, expected) || current.characters[1].inventory.Credits != 5 || + current.nextItem != 2 || current.characters[1000000].health != 0 || current.characters[1000000].corpse == nil || + len(current.characters[1000000].corpse.items) != 0 || current.characters[1000000].corpse.credits != 0 || + current.characters[1000000].combatProfile != gamedata.NPCCombatProfiles[30360][4] { + t.Fatal("Minibull encounter lost profile, ammunition, cash or exact loot ownership") + } + } +} diff --git a/server/gamedata/minibull_test.go b/server/gamedata/minibull_test.go @@ -0,0 +1,18 @@ +package gamedata + +import ( + "slices" + "testing" +) + +func TestMinibullProfilesUseBoundedOriginalHeadbutt(t *testing.T) { + profiles := NPCCombatProfiles[30360] + + first, last := profiles[4], profiles[10] + + if len(profiles) != 10 || first == nil || last == nil || first.Health != 150 || last.Health != 300 || + first.Experience != 150 || last.Experience != 300 || first.Weapon != [2]uint32{120961, 120962} || + !slices.Equal(first.TemplateCodes, []string{"MB01"}) || profiles[0] != nil || profiles[11] != nil { + t.Fatal("Minibull profiles lost their explicit bounded anchors or original weapon", profiles) + } +} diff --git a/server/gamedata/npc_combat.yaml b/server/gamedata/npc_combat.yaml @@ -79,6 +79,50 @@ quality: [9, 11] chance: 50 +30360: + 1: &minibull + # MB01 is an inferred species binding; other Minibull codes stay unreviewed. + template_codes: [MB01] + # Explicit provisional resources/ratings/loot, not historical species measurements. + health: 100 + experience: 100 + skills: {100: 5, 153: 5, 154: 5, 155: 5, 168: 5} + # Original Headbutt endpoints; choosing it instead of Kick remains provisional. + weapon: [120961, 120962] + initiative: 0 + agg_def: 75 + respawn_seconds: 100 + corpse_seconds: 180 + credits: [1, 5] + loot: + - template: 42640 + quality: [1, 1] + chance: 50 + 2: + <<: *minibull + loot: + - template: 42640 + quality: [1, 3] + chance: 50 + 4: + <<: *minibull + health: 150 + experience: 150 + skills: {100: 15, 153: 15, 154: 15, 155: 15, 168: 15} + loot: + - template: 42640 + quality: [3, 5] + chance: 50 + 10: + <<: *minibull + health: 300 + experience: 300 + skills: {100: 45, 153: 45, 154: 45, 155: 45, 168: 45} + loot: + - template: 42640 + quality: [9, 11] + chance: 50 + 30365: 1: &reet # RT01's name is an original client reference; its complete template is inferred. diff --git a/server/minibull_test.go b/server/minibull_test.go @@ -0,0 +1,113 @@ +package main + +import ( + "ao/server/gamedata" + "encoding/binary" + "slices" + "testing" + "time" +) + +func TestMinibullPopulationRetainsAuthoredRangeAndNativeWeapon(t *testing.T) { + data := testNPCData() + data.Playfields[0].ID = 550 + group := *gamedata.NPCGroups["550/district/4/group/8/spread_authored_point"] + data.PlacementStatuses[group.PlacementStatus] = gamedata.NPCs.PlacementStatuses[group.PlacementStatus] + data.Playfields[0].Districts[0].Groups[0] = group + useNPCData(t, data) + world := newTestServer(t) + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + for index, position := range group.Positions { + npc := current.characters[1000000+uint32(index)] + level := uint16(index + 4) + if npc.monsterData != 30360 || npc.level != level || npc.position != position || npc.npcDefinitionID != group.ID { + t.Fatal("Minibull admission changed the authored population", npc) + } + if level > 10 { + if npc.combatProfile != nil { + t.Fatal("Minibull profile extrapolated beyond its supported range", level) + } + continue + } + if npc.combatProfile != gamedata.NPCCombatProfiles[30360][level] || npc.health != 150+25*uint32(index) || + npc.attackRating() != 15+5*int32(index) || !slices.Equal(npc.combatProfile.TemplateCodes, []string{"MB01"}) { + t.Fatal("Minibull population lost its bounded profile", npc.id, npc.combatProfile) + } + packet := targetPacket(characterPacket(npc)) + end := int(binary.BigEndian.Uint16(packet[6:8])) + if binary.BigEndian.Uint32(packet[end-16:end-12]) != 120961 || binary.BigEndian.Uint32(packet[end-12:end-8]) != 120962 || + binary.BigEndian.Uint32(packet[end-4:end]) != uint32(level) { + t.Fatal("native Minibull spawn lost original Headbutt endpoints or actor QL") + } + } + } +} + +func TestMinibullAdmissionRejectsOtherCodesBodiesEvidenceAndLevels(t *testing.T) { + for _, scenario := range []string{"level1", "level10", "level11", "other code", "other body", "placeholder"} { + t.Run(scenario, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.TemplateCode, group.MonsterData, group.Levels, group.AppearanceStatus = "MB01", 30360, [2]uint16{1, 1}, "inferred_species" + switch scenario { + case "level10": + group.Levels = [2]uint16{10, 10} + case "level11": + group.Levels = [2]uint16{11, 11} + case "other code": + group.TemplateCode = "MB02" + case "other body": + group.MonsterData = 17687 + case "placeholder": + group.AppearanceStatus = "placeholder_creature" + } + useNPCData(t, data) + + world := newTestServer(t) + + npc := world.characters[1000000] + if scenario == "level1" || scenario == "level10" { + if npc.combatProfile != gamedata.NPCCombatProfiles[30360][group.Levels[0]] { + t.Fatal("supported Minibull boundary lost its profile") + } + } else if npc.combatProfile != nil { + t.Fatal("unreviewed Minibull binding inherited the profile", scenario) + } + }) + } +} + +func TestMinibullHeadbuttUsesOriginalDamageAndPhases(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.TemplateCode, group.MonsterData, group.Levels, group.AppearanceStatus = "MB01", 30360, [2]uint16{4, 4}, "inferred_species" + useNPCData(t, data) + world := newTestServer(t) + player := world.newCharacter() + player.position = group.Positions[0] + world.clients[player.id] = &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} + world.combatRoll = landedCombatRoll + + if err := world.handleCombat(world.clients[player.id], attackPacket(player.id, 1000000)[20:]); err != nil { + t.Fatal(err) + } + start := player.nextAttack + world.advanceCombat(start) + world.advanceCombat(start.Add(2350*time.Millisecond - time.Nanosecond)) + if player.health != 34 { + t.Fatal("Headbutt landed before its catalog attack phase ended", player.health) + } + world.advanceCombat(start.Add(2350 * time.Millisecond)) + + npc := world.characters[1000000] + if itemStat(npc.attackWeapon(), 286) != 12 || itemStat(npc.attackWeapon(), 285) != 23 || + player.health != 11 || npc.nextAttack != start.Add(7050*time.Millisecond) { + t.Fatal("Headbutt lost catalog damage or attack/recharge phases", player.health, npc.nextAttack.Sub(start)) + } +} diff --git a/server/starter_fauna_test.go b/server/starter_fauna_test.go @@ -151,6 +151,9 @@ func TestStarterFaunaDeathsRetainSharedRewardsAcrossKillingActions(t *testing.T) {"950/district/5/group/1/district_center_fallback", 17660, 1, 1, 100}, {"950/district/4/group/1/authored_point", 17660, 3, 4, 125}, {"950/district/4/group/1/authored_point", 17660, 4, 5, 150}, + {"550/district/4/group/8/spread_authored_point", 30360, 1, 1, 100}, + {"550/district/4/group/8/spread_authored_point", 30360, 4, 5, 150}, + {"550/district/4/group/8/spread_authored_point", 30360, 10, 11, 300}, } { t.Run(fmt.Sprintf("%s/%d/%d", attack, scenario.monster, scenario.level), func(t *testing.T) { world, _ := newKillExperienceWorld(t, attack) diff --git a/tools/client/test_minibull.mjs b/tools/client/test_minibull.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']}); +const games = [], evidence = {}; +const actor = (game, type, id) => game.state.actors.find(actor => actor.type === type && actor.id === id); +try { + for (let index = 0; index < 2; index++) { + const context = await browser.newContext({viewport: {width: 1024, height: 768}}); + await context.addCookies([{name: 'ao_client', value: 'minibull-' + index, url}]); + const page = await context.newPage(), game = await GameTest.attach(page); + games.push(game); + await page.goto(url); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + await game.snapshot(); + } + const [owner] = games; + const server = async () => (await owner.page.request.get(url + '/test-state')).json(); + evidence.initial = await server(); + const npc = evidence.initial.npc; + assert.equal(evidence.initial.maximum, 150); + assert.equal(evidence.initial.health, 150); + await Promise.all(games.map(game => game.wait('full-health Minibull visible to both clients', () => + actor(game, 50000, npc)?.stats[27] === 150))); + await Promise.all(games.map((game, index) => game.save(output + '/spawn-' + index))); + + // Deterministic incoming combat isolates the original Headbutt presentation. + assert((await owner.page.request.post(url + '/test-headbutt')).ok()); + evidence.headbutt = await server(); + assert.equal(evidence.initial.owner_health - evidence.headbutt.owner_health, 23); + await Promise.all(games.map(game => game.wait('both clients consume the Headbutt result', () => + actor(game, 50000, 1).stats[27] === evidence.headbutt.owner_health && + actor(game, 50000, npc).weapons.every(weapon => weapon.pending.length === 0)))); + await Promise.all(games.map((game, index) => game.save(output + '/headbutt-' + index))); + + // A real native attack kills the full-health target through the shared outcome. + await owner.click(...await owner.pick(50000, npc)); + const sequence = owner.sequence; + await owner.key('KeyQ'); + await owner.wait('real native attack request', () => owner.events.some(event => event.sequence > sequence && + event.direction === 'framesent' && event.opcode === '28494070')); + assert.equal((await server()).owner_target, npc); + assert((await owner.page.request.post(url + '/test-owner-swing')).ok()); + await Promise.all(games.map(game => game.wait('Minibull corpse visible', () => actor(game, 51050, npc)))); + evidence.killed = await server(); + assert.equal(evidence.killed.health, 0); + await owner.click(...await owner.pick(51050, npc), 'right'); + await owner.wait('selected-quality part in native corpse window', state => state.grids.some(grid => + grid.cells.some(cell => cell.identity[0] === 107 && cell.identity[1] === 0 && !cell.dummy))); + const source = owner.state.grids.flatMap(grid => grid.cells).find(cell => cell.identity[0] === 107 && cell.identity[1] === 0 && !cell.dummy); + await owner.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2); + await owner.wait('exact Monster Part collected', state => owner.local(state).inventory.some(item => item.id === 2 && item.slot === 48 && item.quality === 5)); + evidence.collected = await server(); + assert.equal(evidence.collected.inventory.Credits, 5); + assert.deepEqual(evidence.collected.inventory.Items.map(item => [item.ID, item.Template, item.Quality, item.Slot, item.Ammo]), + [[1, 124261, 75, 6, 12], [2, 42640, 5, 64, 0]]); + await Promise.all(games.map((game, index) => game.save(output + '/collected-' + index))); + await owner.page.reload(); + await owner.ready(); + await owner.page.waitForFunction(() => touchRegion(500, 400)?.world === true); + await owner.snapshot(); + assert.deepEqual(owner.local().inventory.map(item => [item.id, item.slot, item.quality]), [[1, 6, 75], [2, 48, 5]]); + assert.deepEqual(await server(), evidence.collected); + assert(games.every(game => game.errors.length === 0)); + console.log('PASS: original Minibull Headbutt, two-client combat/corpse, exact selected loot and ammunition through page/cold replay'); +} finally { + try { + await fs.mkdir(output, {recursive: true}); + await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n'); + await Promise.all(games.map((game, index) => game.save(output + '/final-' + index))); + } finally { await browser.close(); } +}