aorecomp

Anarchy Online classic in the browser

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


commit 5d66b1f8f742eac6c54b48aa216b81dd6cda0ea3
parent f79547444f38eebcc7c1c1dc9a7dda0462bf222a
Author: anon <anon@example.com>
Date:   Tue, 27 Oct 2026 02:19:11 +0000

Require species evidence before binding NPC profiles

Resolve profiles from stable population definitions during spawn, cold loading
and replacement. Serialize native initial weapons from the admitted profile,
so unresolved Leet stand-ins cannot inherit Leet combat, rewards or lifecycle.

Cover colliding bodies, rewards, changed definitions and replacement evidence.
Identify intended Leets in cold-recovery fixtures. Two RTX WASM clients checked
Leet, Good Time Party Mixer and Carbonrich Rock before and after restart.
Preserve the full-run fixture failures and their corrected retests in the
validation report; keep unresolved NPC behavior and progression gaps open.

Diffstat:
MTODO.md | 9++++++++-
Mdocs/combat-npc-balance.md | 15+++++++++++++--
Mdocs/npc-loot.md | 4+++-
Adocs/npc-profile-eligibility.md | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/npc-respawn.md | 6++++--
Mserver/fling_crash_test.go | 1+
Mserver/kill_experience_test.go | 1+
Mserver/npc_combat_test.go | 3+++
Mserver/npc_data_test.go | 18+++++++++++++++---
Mserver/npc_levels_test.go | 1+
Mserver/npc_population_levels_test.go | 2++
Aserver/npc_profile_evidence_test.go | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/npcs.go | 10+++++++++-
Mserver/respawn.go | 2+-
Mserver/respawn_test.go | 1+
Mserver/target_protocol.go | 20++------------------
Mserver/team_loot_test.go | 1+
Mserver/world.go | 8++++++++
Mserver/world_store.go | 3+--
19 files changed, 318 insertions(+), 31 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -542,11 +542,18 @@ for exact records, protocol, tests and remaining reconstruction assumptions. establish the distribution within authored ranges, including fixed spawns, and whether replacements retain or reroll their level. Replace the provisional placement cycle and level retention only when supported by evidence. -- [ ] [P1] Separate species profile eligibility from placeholder rendering. Check: +- [x] Separate species profile eligibility from placeholder rendering. Check: an unresolved code using a Leet body cannot acquire Leet combat, XP or loot merely through MonsterData 17655. Apply the same evidence rule to initial allocation, native weapon initialization, cold loading and replacements. Cover a real Leet and an unresolved code sharing its visible body. + Stable definitions now require species evidence and matching MonsterData before + binding a profile; native serialization uses that same admitted profile. + Two WASM clients verified a real Leet, Good Time Party Mixer and Carbonrich + Rock before and after cold restart. Unresolved bodies retain prototype behavior + without Leet-specific rewards or lifecycle settings; their proper behavior and + the remaining mapping integration stay open. See + [profile eligibility](docs/npc-profile-eligibility.md). - [ ] [P0] Verify a viable starter fight and recovery route. Check: a normally created character can train appropriate skills, equip its issued weapon, kill a starter enemy, recover and repeat without admin changes. Audit provisional diff --git a/docs/combat-npc-balance.md b/docs/combat-npc-balance.md @@ -57,8 +57,10 @@ one unsupported rule with another. ## Explicit Leet profiles `server/gamedata/npc_combat.yaml` selects MonsterData 17655 separately at levels -1 and 2. The spawner binds that exact profile and initializes health from it; -other species and levels retain their existing prototype behavior. Catalog +1 and 2. The spawner binds that exact profile only when the stable population +definition has `inferred_species` evidence and matching MonsterData. It then +initializes health from the profile. Other species, unresolved identities and +unsupported levels retain their existing prototype behavior. Catalog loading rejects missing species, missing/nonweapon endpoints, an actor level outside their QL range, zero health, and AggDef outside -100..100. @@ -94,6 +96,15 @@ No creature health, XP or loot-quality curve follows from weapon interpolation. ### Population identity boundary +Profile eligibility is independent of the visible placeholder. Initial +allocation, cold loading and replacements resolve the stable group definition +through the same rule. Native initial weapons are serialized from the admitted +actor profile; the wire converter does not infer them again from the body. +An unresolved NPC with MonsterData 17655 therefore keeps its marked stand-in +without acquiring Leet Bite, Leet XP, loot or lifecycle settings. Existing +committed corpse contents and rewards remain owned after a definition changes. +See [profile eligibility verification](npc-profile-eligibility.md). + The two handoff assignments that otherwise collide with the new profile are retained verbatim in `server/testdata/npc-level-population-assignments.json`, including the complete input catalog's digest, context groups, reasons, diff --git a/docs/npc-loot.md b/docs/npc-loot.md @@ -1,6 +1,8 @@ # NPC corpse rewards -Normal deaths generate rewards from the exact MonsterData/level combat profile. +Normal deaths generate rewards from the admitted species/level combat profile. +Species evidence in the stable definition is required; a matching placeholder +body alone does not qualify. See [profile eligibility](npc-profile-eligibility.md). The current production profiles are level 1 and level 2 Leets. Each configured loot row rolls independently, creates one item at its catalog template's authored quality, and places it in a free corpse slot. Cash is selected inclusively from the configured diff --git a/docs/npc-profile-eligibility.md b/docs/npc-profile-eligibility.md @@ -0,0 +1,79 @@ +# NPC profile eligibility + +A visible Leet stand-in does not identify a Leet. The stable population group +must have `inferred_species` appearance evidence and MonsterData matching the +actor before the server selects its exact species/level combat profile. +The rule uses the maintained group data, with no template-code or NPC-name +exceptions. It applies when allocating, loading and replacing an NPC. + +Initial native weapons now come from that admitted actor profile in character +serialization. The target wire converter only adapts the packet layout; it no +longer selects a bite from the rendered MonsterData and level. Supported Leets +retain their original 120910/120911 bite endpoints and actor quality. Unresolved +stand-ins retain the existing prototype 43712/43713 weapon initialization. + +This removes unintended Leet-specific health, combat, XP, Monster Parts, cash, +respawn delay and corpse lifetime from unresolved groups. It does not implement +their proper behavior: prototype combat and ordinary corpse handling still +apply. In particular, Carbonrich Rock's resource-object rendering and harvesting +remain open. Previously committed rewards, contents and lifecycle deadlines are +not reversed when loading a changed definition; replacement profile eligibility +is checked again for the new life. + +The maintained population audit finds 850 placements in 831 unresolved groups +currently selecting levels 1 or 2 with the stand-in MonsterData. These include +140 Carbonrich Rock groups and Good Time Party Mixer. The 181 placements with +supported species evidence retain their profiles. These counts describe the +current inclusive-range placement policy, not historical population allocation. +The complete group evidence is retained in +`local/npc-profile-eligibility/population-audit.json`. + +Four regression roots cover shared body/name with different evidence, ordinary +attack/death rewards, missing or mismatched cold definitions, and live/cold +replacement eligibility. A negative baseline reproduced eight failures with +two positive controls passing. Supported Leets retain one committed reward and +lifecycle; rejected stand-ins generate no Leet rewards or item identities. +Changing evidence does not reverse an already committed kill. Existing native +spawn/weapon tests verify both supported levels across restart. + +## Native checks + +Two headed GPU WASM clients inspected an existing level-1 Leet in Omni +Training, Good Time Party Mixer in Reet Retreat, and Carbonrich Rock in +Parnassos. Only the owned characters' locations were changed through the +control panel. No NPCs, combat stats, rewards or inventory were provisioned. +These are controlled identity/initialization checks, not proof of ordinary +travel or progression. + +Both clients bound Leet Bite 120910/120911 at QL 1 for the real Leet and +43712/43713 for both unresolved stand-ins. Captured initial spawn lists and +read-only native holder/item probes agree. The real Leet receives its later +profile packet; neither unresolved NPC receives one. All three retain their +names, MonsterData 17655 and native creature appearance. Tab selection and T +inspection completed without a loading loop or page error. + +Both clients closed before the single preview restarted. Reconnecting and +repeating all three inspections preserved the same distinction. All fourteen +issued item instances, XP, IP, level and cash stayed unchanged. Screenshots, +packet streams, probe samples and assertions are retained in +`local/npc-profile-eligibility/runtime-verification.json`. + +## Automated verification and scope + +The complete server run exercised 1,388 roots. Its two failing roots were the +process-crash and team-loot restart fixtures, which constructed unidentified +NPCs while expecting Leet profiles after cold loading. Those fixtures now +supply their intended stable Leet definition. The original failures remain in +the report; the final related retest is recorded separately, rather than +presenting the original run as a clean single-binary suite pass. +The corrected related retest passed. Together, the full run and final fixture +retests cover all 1,388 roots / 14,722 distinct passing results; no failure +remains unresolved. The audit is retained in +`local/npc-profile-eligibility/verification.json`. + +The focused regressions passed 104 roots, and the targeted race run passed +104 roots / 311 results. All 18 gamedata tests, eleven Python population/parser +tests and `go vet ./server/...` passed. Production code did not change after +the native-verified preview build; later changes only identify test fixtures. +The evidence directory retains both test binaries, source hashes, full logs, +negative baseline, corrected fixture runs and native verification artifacts. diff --git a/docs/npc-respawn.md b/docs/npc-respawn.md @@ -32,8 +32,10 @@ life. The pending queue is protected by the normal update/state lock order. It advances even without connected observers and is processed before roaming and combat in the world tick. -Each replacement receives a fresh character identity, the same definition and -combat profile, full profile health, and empty combat/recharge state. A roaming +Each replacement receives a fresh character identity and the same definition. +Its profile is resolved again from that definition's species evidence and the +selected MonsterData/level; a cached profile is not copied to an unresolved +identity. It starts at full health with empty combat/recharge state. A roaming creature returns to its authored home with a fresh roaming state. Its entry in the roaming roster is replaced or recreated if the corpse has already expired, so successive deaths do not add roaming workers. diff --git a/server/fling_crash_test.go b/server/fling_crash_test.go @@ -50,6 +50,7 @@ func runFlingCrashChild(t *testing.T, mode string) { } target := world.characters[1000000] target.health, target.monsterData, target.level = 100, 17655, 1 + target.npcDefinitionID = "950/district/2/group/0/authored_point" target.combatProfile = gamedata.NPCCombatProfiles[17655][1] if strings.HasSuffix(mode, "/kill") { target.health = 1 diff --git a/server/kill_experience_test.go b/server/kill_experience_test.go @@ -28,6 +28,7 @@ func newKillExperienceWorld(t *testing.T, attack string) (*server, *combatTestCo } player.health = 25 target.health, target.monsterData, target.level = 1, 17655, 1 + target.npcDefinitionID = "950/district/2/group/0/authored_point" target.position = [3]float32{1, 0, 0} target.combatProfile = gamedata.NPCCombatProfiles[17655][1] if err := world.saveUser_locked(player); err != nil { diff --git a/server/npc_combat_test.go b/server/npc_combat_test.go @@ -14,6 +14,7 @@ func TestNPCProfileNativeSpawnUsesLeetBiteAfterRestart(t *testing.T) { for _, level := range []uint16{1, 2} { t.Run(fmt.Sprint(level), func(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{level, level} useNPCData(t, data) world := newTestServer(t) @@ -81,6 +82,7 @@ func TestNPCProfileNativeSpawnUsesLeetBiteAfterRestart(t *testing.T) { func TestNPCProfileCombatUsesCatalogTimingAndDamageForBothObservers(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{1, 1} useNPCData(t, data) world := newTestServer(t) @@ -138,6 +140,7 @@ func TestNPCProfileDoesNotApplyToOtherLevelsOrSpecies(t *testing.T) { } { t.Run(scenario.name, func(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].MonsterData = scenario.monster data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{scenario.level, scenario.level} useNPCData(t, data) diff --git a/server/npc_data_test.go b/server/npc_data_test.go @@ -10,7 +10,10 @@ import ( func testNPCData() gamedata.NPCData { return gamedata.NPCData{ - AppearanceStatuses: map[string]gamedata.Evidence{"placeholder_creature": {Confidence: "placeholder", Comment: "Identity unresolved."}}, + AppearanceStatuses: map[string]gamedata.Evidence{ + "placeholder_creature": {Confidence: "placeholder", Comment: "Identity unresolved."}, + "inferred_species": {Confidence: "inferred", Comment: "Selected species mapping."}, + }, PlacementStatuses: map[string]gamedata.Evidence{ "fixed_point": {Confidence: "authored", Comment: "Exact authored XYZ."}, "authored_point": {Confidence: "approximate", Comment: "Inferred allocation."}, @@ -26,8 +29,17 @@ func testNPCData() gamedata.NPCData { func useNPCData(t *testing.T, data gamedata.NPCData) { t.Helper() - previousNPCs, previousResources := gamedata.NPCs, resources + previousNPCs, previousGroups, previousResources := gamedata.NPCs, gamedata.NPCGroups, resources gamedata.NPCs = data + gamedata.NPCGroups = make(map[string]*gamedata.NPCGroup) + for _, playfield := range data.Playfields { + for _, district := range playfield.Districts { + for index := range district.Groups { + group := &district.Groups[index] + gamedata.NPCGroups[group.ID] = group + } + } + } resources = fstest.MapFS{ "terrain.bin": {Data: append([]byte("AOTERR02"), 0, 0, 0, 0)}, "zone_links.yaml": {Data: []byte("original: {}\ntarget: {}\n")}, @@ -35,7 +47,7 @@ func useNPCData(t *testing.T, data gamedata.NPCData) { "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.dat": {}, } t.Chdir(t.TempDir()) - t.Cleanup(func() { gamedata.NPCs, resources = previousNPCs, previousResources }) + t.Cleanup(func() { gamedata.NPCs, gamedata.NPCGroups, resources = previousNPCs, previousGroups, previousResources }) } func useDiskResources(t *testing.T) { diff --git a/server/npc_levels_test.go b/server/npc_levels_test.go @@ -60,6 +60,7 @@ func TestNPCLevelPopulationAssignmentsRetainHandoffEvidence(t *testing.T) { func TestNPCLevelTwoUsesInterpolatedBiteForBothObservers(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{2, 2} useNPCData(t, data) world := newTestServer(t) diff --git a/server/npc_population_levels_test.go b/server/npc_population_levels_test.go @@ -75,6 +75,7 @@ func TestNPCPopulationRangesIncludeExtendedLevelsWithoutChangingPlacement(t *tes } { t.Run(fmt.Sprint(scenario.levels), func(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].Levels = scenario.levels data.Playfields[0].Districts[0].Groups[0].Positions = [][3]float32{{52, 14, 56}, {54, 14, 56}, {56, 14, 56}, {58, 14, 56}} useNPCData(t, data) @@ -119,6 +120,7 @@ func TestNPCPopulationRejectsInvalidLevelRanges(t *testing.T) { func TestNPCPopulationSecondLevelRetainsSelectedLifeThroughRespawn(t *testing.T) { data := testNPCData() + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{1, 2} data.Playfields[0].Districts[0].Groups[0].Positions = [][3]float32{{52, 14, 56}, {54, 14, 56}} useNPCData(t, data) diff --git a/server/npc_profile_evidence_test.go b/server/npc_profile_evidence_test.go @@ -0,0 +1,165 @@ +package main + +import ( + "ao/server/gamedata" + "encoding/binary" + "testing" + "time" +) + +func TestNPCProfileSeparatesSpeciesEvidenceFromMatchingBodies(t *testing.T) { + for _, status := range []string{"inferred_species", "placeholder_creature", "placeholder_human"} { + t.Run(status, func(t *testing.T) { + data := testNPCData() + data.AppearanceStatuses["placeholder_human"] = gamedata.Evidence{Confidence: "placeholder"} + group := &data.Playfields[0].Districts[0].Groups[0] + group.Name, group.Levels, group.AppearanceStatus = "Leet", [2]uint16{1, 1}, status + useNPCData(t, data) + + world := newTestServer(t) + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + npc := current.characters[1000000] + if npc.monsterData != 17655 || npc.appearance != 229 || npc.name != "Leet" || npc.npcDefinitionID != "test/npc" { + t.Fatal("profile admission changed the visible placeholder or stable definition") + } + profile := status == "inferred_species" + if (npc.combatProfile != nil) != profile { + t.Fatal("visible body or name substituted for species evidence", status, npc.combatProfile) + } + packet := targetPacket(characterPacket(npc)) + end := int(binary.BigEndian.Uint16(packet[6:8])) + weapon := binary.BigEndian.Uint32(packet[end-16 : end-12]) + if profile && weapon != 120910 || !profile && weapon != 43712 { + t.Fatal("native initialization disagrees with profile eligibility", weapon) + } + } + }) + } +} + +func TestNPCPlaceholderDeathDoesNotGenerateLeetRewards(t *testing.T) { + for _, status := range []string{"inferred_species", "placeholder_creature"} { + t.Run(status, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.Levels, group.AppearanceStatus = [2]uint16{1, 1}, status + useNPCData(t, data) + world := newTestServer(t) + world.combatRoll = func(uint32) uint32 { return 0 } + player := world.newCharacter() + player.position = group.Positions[0] + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + world.characters[1000000].health = 1 + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} + world.clients[player.id] = client + + if err := world.handleCombat(client, attackPacket(player.id, 1000000)[20:]); err != nil { + t.Fatal(err) + } + world.advanceCombat(player.nextAttack) + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + npc := current.characters[1000000] + if npc.health != 0 || npc.corpse == nil || npc.corpse.looter != player.id { + t.Fatal("profile rejection disabled the ordinary death or corpse contract") + } + if status == "inferred_species" { + if current.characters[player.id].experience != 100 || current.nextItem != 1 || len(npc.corpse.items) != 1 || npc.corpse.items[0].Template != 42640 || npc.corpse.credits != 1 || len(current.npcRespawns) != 1 { + t.Fatal("a supported Leet lost its production rewards or lifecycle") + } + } else if current.characters[player.id].experience != 0 || current.nextItem != 0 || len(npc.corpse.items) != 0 || npc.corpse.credits != 0 || len(current.npcRespawns) != 0 || !npc.corpse.expiresAt.IsZero() { + t.Fatal("a placeholder acquired Leet XP, items, cash or lifecycle settings", npc.corpse) + } + } + }) + } +} + +func TestNPCProfileColdLoadingRechecksDefinitionEvidence(t *testing.T) { + for _, scenario := range []string{"missing definition", "different monster", "placeholder evidence"} { + t.Run(scenario, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.Levels, group.AppearanceStatus = [2]uint16{1, 1}, "inferred_species" + useNPCData(t, data) + world := newTestServer(t) + switch scenario { + case "missing definition": + world.characters[1000000].npcDefinitionID = "unresolved" + case "different monster": + group.MonsterData = 17627 + case "placeholder evidence": + group.AppearanceStatus = "placeholder_creature" + } + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + + cold := newTestInventoryServer(t) + + if cold.characters[1000000].monsterData != 17655 || cold.characters[1000000].combatProfile != nil { + t.Fatal("cold loading inferred a species profile from saved rendering data", scenario) + } + }) + } +} + +func TestNPCReplacementRechecksSpeciesEvidence(t *testing.T) { + for _, restart := range []bool{false, true} { + name := "live source" + if restart { + name = "cold source" + } + t.Run(name, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.Levels, group.AppearanceStatus = [2]uint16{1, 1}, "inferred_species" + useNPCData(t, data) + world := newTestServer(t) + player := world.newCharacter() + player.position = group.Positions[0] + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + world.characters[1000000].health = 1 + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true, npcs: map[uint32]bool{1000000: true}} + world.clients[player.id] = client + if err := world.handleCombat(client, attackPacket(player.id, 1000000)[20:]); err != nil { + t.Fatal(err) + } + death := player.nextAttack + world.advanceCombat(death) + group.AppearanceStatus = "placeholder_creature" + if restart { + world = newTestInventoryServer(t) + } + + world.advanceNPCRespawns(death.Add(100 * time.Second)) + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + npc := current.characters[1000001] + if npc == nil || npc.combatProfile != nil || npc.monsterData != 17655 || npc.appearance != 229 || npc.npcDefinitionID != "test/npc" || npc.health != 100 { + t.Fatal("replacement copied an ineligible cached profile", npc) + } + if current.characters[player.id].experience != 100 || current.characters[1000000].corpse == nil { + t.Fatal("profile admission reversed an already committed kill") + } + } + }) + } +} diff --git a/server/npcs.go b/server/npcs.go @@ -5,6 +5,14 @@ import ( "fmt" ) +func npcCombatProfile(definition string, monster uint32, level uint16) *gamedata.NPCCombatProfile { + group := gamedata.NPCGroups[definition] + if group == nil || group.AppearanceStatus != "inferred_species" || group.MonsterData != monster { + return nil + } + return gamedata.NPCCombatProfiles[monster][level] +} + func readNPCSpawns() ([]character, error) { data := gamedata.NPCs @@ -32,7 +40,7 @@ func readNPCSpawns() ([]character, error) { id: 1000000 + uint32(len(spawns)), name: group.Name, playfield: playfield.ID, position: position, rotation: [4]float32{0, 0, 0, 1}, appearance: group.Appearance, monsterData: group.MonsterData, level: level, npc: true, - combatProfile: gamedata.NPCCombatProfiles[group.MonsterData][level], + combatProfile: npcCombatProfile(group.ID, group.MonsterData, level), npcDefinitionID: group.ID, } spawn.health = spawn.maximumHealth() diff --git a/server/respawn.go b/server/respawn.go @@ -30,7 +30,7 @@ func (server *server) advanceNPCRespawns(now time.Time) { playfield: respawn.npc.playfield, position: respawn.npc.position, rotation: [4]float32{0, 0, 0, 1}, appearance: respawn.npc.appearance, monsterData: respawn.npc.monsterData, level: respawn.npc.level, npc: true, - combatProfile: respawn.npc.combatProfile, npcDefinitionID: respawn.npc.npcDefinitionID, + combatProfile: npcCombatProfile(respawn.npc.npcDefinitionID, respawn.npc.monsterData, respawn.npc.level), npcDefinitionID: respawn.npc.npcDefinitionID, } npc.health = npc.maximumHealth() if respawn.npc.roaming != nil { diff --git a/server/respawn_test.go b/server/respawn_test.go @@ -12,6 +12,7 @@ func newRespawnWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() data := testNPCData() data.Playfields[0].Districts[0].Groups[0].Levels = [2]uint16{1, 1} + data.Playfields[0].Districts[0].Groups[0].AppearanceStatus = "inferred_species" data.Playfields[0].Districts[0].Groups[0].PlacementStatus = "authored_point" useNPCData(t, data) world := newTestServer(t) diff --git a/server/target_protocol.go b/server/target_protocol.go @@ -1,7 +1,6 @@ package main import ( - "ao/server/gamedata" "bytes" "encoding/binary" "time" @@ -65,29 +64,14 @@ func targetPacket(packet []byte) []byte { packet = append(converted, packet[cursor:]...) } // Three empty byte-counted groups separate the final encoded lists. - tail = append([]byte(nil), packet[len(packet)-4:]...) - packet = append(packet[:len(packet)-4], 0, 0, 0) + tail = append([]byte(nil), packet[len(packet)-24:]...) + packet = append(packet[:len(packet)-24], 0, 0, 0) packet = append(packet, tail...) - // Supply the initial weapon before the native holder binds slot 0. - weaponLow, weaponHigh, weaponParameter := uint32(43712), uint32(43713), uint32(1) if flags&1 != 0 { // Tab targeting requires NPC stat 194 (InPlay), supplied by flag bit 1. flags |= 2 - level := uint16(packet[nameEnd]) - monsterOffset := nameEnd + 9 - if flags&0x1000 != 0 { - level = binary.BigEndian.Uint16(packet[nameEnd:]) - monsterOffset++ - } - if profile := gamedata.NPCCombatProfiles[binary.BigEndian.Uint32(packet[monsterOffset:])][level]; profile != nil { - weaponLow, weaponHigh, weaponParameter = profile.Weapon[0], profile.Weapon[1], uint32(level) - } } binary.BigEndian.PutUint32(packet[37:41], flags|0x100) - // Initial QL comes from actor stat 54; the final row parameter is unresolved. - for _, value := range []uint32{2018, weaponLow, weaponHigh, 100, weaponParameter} { - packet = binary.BigEndian.AppendUint32(packet, value) - } case 0x29304349: // FullCharacter has seven encoded lists before its stats. inventoryCount := int(binary.BigEndian.Uint32(packet[40:44])/1009 - 1) diff --git a/server/team_loot_test.go b/server/team_loot_test.go @@ -380,6 +380,7 @@ func TestTeamLootContributionsAndAwardSurviveRestart(t *testing.T) { formTestTeam(t, world, 2, 3) npc := world.characters[1000000] npc.health, npc.level = 7, 1 + npc.npcDefinitionID = "950/district/2/group/0/authored_point" world.handleCombat(world.clients[2], attackPacket(2, npc.id)[20:]) world.advanceCombat(world.characters[2].nextAttack) world.handleCombat(world.clients[2], stopFightPacket(2)[20:]) diff --git a/server/world.go b/server/world.go @@ -159,6 +159,14 @@ func characterPacket(character *character) []byte { } body = binary.BigEndian.AppendUint32(body, 1009) body = binary.BigEndian.AppendUint32(body, 1009) + // Initial native weapons follow admitted gameplay profiles, not visible stand-ins. + low, high, quality := uint32(43712), uint32(43713), uint32(1) + if character.npc && character.combatProfile != nil { + low, high, quality = character.combatProfile.Weapon[0], character.combatProfile.Weapon[1], uint32(character.level) + } + for _, value := range []uint32{2018, low, high, 100, quality} { + body = binary.BigEndian.AppendUint32(body, value) + } return n3Packet(0x271b3a6b, 50000, character.id, body) } diff --git a/server/world_store.go b/server/world_store.go @@ -1,7 +1,6 @@ package main import ( - "ao/server/gamedata" "database/sql" "maps" "math/rand/v2" @@ -186,7 +185,7 @@ func (server *server) loadNPCs() (bool, error) { npc := state.Character.character() npc.npc, npc.npcDefinitionID = true, state.Definition npc.stats, npc.profession = state.Character.Profile.Stats, state.Character.Profile.Profession - npc.combatProfile = gamedata.NPCCombatProfiles[npc.monsterData][npc.level] + npc.combatProfile = npcCombatProfile(npc.npcDefinitionID, npc.monsterData, npc.level) npc.leadingContributor = state.LeadingContributor if state.HasRoaming { npc.roaming = &npcRoaming{state.Roaming.Home, state.Roaming.Destination, state.Roaming.NextMove, state.Roaming.Moving, state.Roaming.Returning}