aorecomp

Anarchy Online classic in the browser

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


commit ec714f5898c7395e7532148b64e651639f35d111
parent 644bbc739fe0e03b1ec7fc869f056326ddd2f815
Author: anon <anon@example.com>
Date:   Thu, 29 Oct 2026 19:51:45 +0000

Admit regular starter Rollerrats, snakes and Malles

Diffstat:
MTODO.md | 22++++++++++++++++++++++
Mdocs/npc-profile-eligibility.md | 3++-
Mdocs/starter-boss.md | 2+-
Adocs/starter-fauna.md | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/load.go | 10++++++++--
Mserver/gamedata/npc_combat.go | 3++-
Mserver/gamedata/npc_combat.yaml | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mserver/gamedata/npc_combat_test.go | 14++++++++------
Mserver/gamedata/types.go | 8+++++---
Mserver/npc_shared_pursuit_test.go | 3++-
Mserver/reet_test.go | 2+-
Mserver/starter_boss_test.go | 2+-
Aserver/starter_fauna_test.go | 185+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/tiny_stalker_test.go | 2+-
14 files changed, 457 insertions(+), 22 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -740,6 +740,22 @@ for exact records, protocol, tests and remaining reconstruction assumptions. A corpse expired before the observer's attempted use; foreign-looter rejection remains part of the broader loot audit rather than a claimed native result. See [starter Reets](docs/reet-progression.md). +- [x] [P0] Admit and verify three additional regular starter families through + shared profiles: RR01 Rollerrats, SN01/SN02 Giant Snakes and ML01 Malles. + Preserve original population ranges and uncertain species bindings; audit + original attack endpoints and keep attack selection, growth and loot balance + explicitly provisional. Support exact template-code lists without species + branches. Verify selected-quality attacks, shared rewards/pursuit, rejected + bindings, ordinary native fights and pickup, two-client replication and cold + conservation. The complete Go suite (16,851 results), focused/race checks, + vet and build pass. Six full-health ordinary native fights retain475XP, + 19credits and three picked-up parts across the two fighters. Both pairs + reconstruct all56 owned instances, charges, qualities, equipment and private + progress after page/cold reconnects. The sole preview retains all global + earned state. Transient player-HP ordering and foreign-looter verification + remain in their broader audit tasks; neither is claimed resolved here. + See [starter fauna](docs/starter-fauna.md). Other codes, families and higher + levels remain part of the broader progression task above. - [x] Make the next supported enemy level available through ordinary starter play. Check: a new player can reach and identify supported level-1 and level-2 enemies without admin placement. Resolve the generator's minimum-only choice @@ -1166,6 +1182,12 @@ replay/failure tests and WASM checks are recorded in [IP training](docs/ip-train engine actor, registry actor, health mirror, actual HUD text and rendered digits; the broader incoming-hit/healing ordering remains open. See [health display verification](docs/health-hud-verification.md). + The ordinary starter-fauna pair also records transient final-hit/recovery + differences at raw Body Development10: Clan17's owner/live + HP is69/59 after the two Rat fights while observer19 reads73/63. They agree + after settling and at full recovery. Correlate those native snapshots with + their captured absolute health packets before attributing this to transport. + See [starter fauna](docs/starter-fauna.md). - [x] Use one nano-restoring item. Check: nano recovery, consumption and its lock match that item rather than inheriting the health item's behavior. - [x] Use one sitting treatment kit. Check: it works in the permitted posture diff --git a/docs/npc-profile-eligibility.md b/docs/npc-profile-eligibility.md @@ -4,7 +4,8 @@ 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 a generic species/level combat profile. An explicitly template-bound profile also accepts `best_effort` evidence for -its exact code and matching body. The shared data rule applies when allocating, +an exact member of its `template_codes` list and matching body. The shared data +rule applies when allocating, loading and replacing an NPC; names never establish profile eligibility. See [the current mapping integration](npc-mapping-integration.md). diff --git a/docs/starter-boss.md b/docs/starter-boss.md @@ -10,7 +10,7 @@ unique name remain unresolved. ## Production profile and evidence boundary The profile is restricted to MonsterData 30354, level 4 and template code BSML. -A profile's optional `template_code` narrows the existing species/level rule: +A profile's optional `template_codes` list narrows the existing species/level rule: ordinary salamanders sharing its body do not acquire boss rewards. Startup requires a matching admitted original population. Spawn, cold load and replacement all resolve through the same evidence and code checks. Existing Leet profiles diff --git a/docs/starter-fauna.md b/docs/starter-fauna.md @@ -0,0 +1,141 @@ +# Additional regular starter fauna + +| Body | Admitted codes | Levels | Selected original attack | +| --- | --- | --- | --- | +| Rollerrat 17687 | RR01 | 1..2 | Faceroll 121050/121051 | +| Giant Snake 30252 | SN01, SN02 | 1..4 | GiantserpentBite 120846/120847 | +| Malle 17660 | ML01 | 1..4 | MalleBite 120922/120923 | + +These are bounded profiles for the existing inferred species bindings. Names, +bodies, authored levels, positions and confidence remain unchanged. Matching +bodies with different codes, including ROLL and the weaker DZRA assignment, +do not inherit these profiles. Other regular starter families and later levels +remain open. + +## Original data and limits + +An independent reread of resource 1000020 matches all 21 complete original +weapon/equipper records for Rollerrat Faceroll/Spray, Giantserpent Bite/Spit +and Malle Bite/Claw/Tail. Raw payloads, offsets, hashes and decoded fields are +retained in `local/starter-fauna/original-items.json` and adjacent binaries. +The original database index SHA256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. + +All three selected attacks span QL1..400 and use Martial Arts100 against +Evade Close155, MeleeAC91 and range2. QL1 damage is 6..12 with critical bonus6. +Faceroll's attack/recharge phases are 320 cs each; both selected bites use +235 cs. Shared native item rounding gives QL2 Faceroll 7..14 and QL2 bites +6..13; QL3/4 bites resolve to 7..15 and 7..16. Choosing these variants instead +of the other attacks is provisional, not a recovered original equipment or +alternation rule. + +A format-aware reread of original population resource 1000014 matches the six +relevant training groups: twelve authored positions and two Malle fallback +placements. The fallback group's original level range is 1..3; the authored +Malle group is 2..4. The two SN01 groups retain 1..2 and 1..1; SN02 retains 2..4; +RR01 retains 1..2. Original per-position allocation and the fallback positions +remain reconstruction policy. Sources and checks are in +`local/starter-fauna/original-groups.json` and `tmp_audit.py`. + +The [February 26, 2003 patch report](https://worthplaying.com/article/2003/2/26/news/8473-anarchy-online-update-patch-available-now/) +relays changes to training-creature armor drops and the new Secondhand Peddler. +It supplies no species-specific item pool or probability. Later island guides +are not used to import their expansion-era drops into these populations. + +## Shared reconstruction policy + +Levels 1/2 use 100 HP, 100 solo XP and raw MA/evades/Nano Resist 5. Levels 3/4 use +125/150 HP and XP with raw ratings 10/15. Explicit anchors bound the range; +the shared loader interpolates level 3 without extrapolating. Initiative 0 and +AggDef 75 retain the original weapon delays. + +Cash 1..5, 50% Monster Parts, selected QL1 at level 1 and nearby inclusive QL +intervals 1..3, 2..4, 3..5 at levels 2..4 are provisional biological-loot choices. +Respawn 100 seconds and corpse lifetime 180 seconds use the existing starter +policy. None of these numbers establishes a universal historical growth or +loot formula. There are no inferred armor, quest or later island drops. + +The optional `template_codes` list admits exact reviewed codes alongside the +existing body/evidence check. Snake codes share one profile; the loader rejects +empty/duplicate list entries and incompatible anchor identities. Interpolated +profiles own their code lists, stat maps and loot. Spawn, cold restoration and +replacement use the same admission rule. No species-specific runtime handler +is added. + +## Verification + +Public-handler tests cover all six starter groups, selected levels and weapon +endpoints, cold restoration, code/body/evidence/range rejection, original attack +phases and selected-quality damage. Six direct killing actions cover every +family, selected Monster Parts qualities, cash, XP and retained cold corpse +ownership. Existing shared pursuit/return checks cover all ten admitted +species/level combinations. Controlled one-hit fixtures establish transactions, +not ordinary player balance. + +The focused run passed 31 roots/257 results. The finalized race selection passed +17 roots/161 results. The complete maintained Go suite passed 1,719 roots and +16,851 results across all three started packages, with no failed or skipped +individual tests. Vet and the server build passed. + +## Ordinary native play + +Two sequential headless Chromium pairs used GPU OpenGL and the sole LAN +preview. All actions were ordinary walking, Tab selection, native T inspection, +combat, corpse use, pickup and bought/issued recovery kits. No grants, health or +position edits, forced loot rolls or enemy resets were used. Each fight required +full native and live owner health, full native target health and a matching +recent absolute server health packet. Both clients confirmed the selected +weapon endpoints, QL, damage and phases before combat. + +| Fighter | Targets killed | XP gained | Credits collected | Parts picked up | +| --- | --- | --- | --- | --- | +| Clan17, level1 | RR01 levels1/2 | 200 | 6 | Instance224, QL2 | +| Omni5, earned level5 | SN01 level1, ML01 levels2/4, SN02 level3 | 275 | 13 | Instances232/233, QL1/3 | + +The level1 and level2 Omni kills award no XP under the current provisional grey +cutoff. The level4 Malle and level3 Snake award150 and125. This does not establish +the original server's grey eligibility rule. Native T inspections load normally. +The first Rat also generated a QL1 part223, which expired before pickup; it was +never player-owned. An attempted foreign use hit terrain, so it does not prove +foreign-looter rejection. The level2 Malle and level3 Snake rolled no item. + +All original player items remain, including replaced equipment, the earned QL7 +bat and worn QL6 glove. Clan's laboratory180 used two charges, leaving18; Omni's +bought laboratory144 used three, leaving22. Raw skills, IP, ammunition and both +observers' items/credits/XP remain unchanged. Both fighters recovered fully. + +The Rat final-hit captures show a transient owner/live versus observer HP +difference:69 versus73, then59 versus63. Settled snapshots and full recovery +agree. Omni's final Malle capture agrees at123 on both clients. These recordings +extend the existing player-HP ordering audit; they do not claim to resolve it. +NPC weapon/health replication and private rewards passed in this bounded run. +`local/starter-fauna/ordinary-fights-verified.json` records all six full-health +fights; screenshots, packet traces, complete private ledgers and audit scripts +are retained beside it. + +## Page and cold recovery + +Both Omni pages were reloaded after combat. With all owned browsers closed, the +single preview was stopped, its flushed SQLite database preserved, and the same +candidate restarted. Every global player row, wallet, item, item location, +mission, encounter and learned nano matched the stopped snapshot exactly. +Integrity and foreign-key checks passed. + +Both native pairs then reconnected; the Clan pair also reloaded both pages after +cold loading. All56 owned instances matched SQLite by ID, slot, quantity, QL and +template endpoints. Full health, cash, XP/IP and raw skills were retained. The +Clan fighter has9 items,600XP,1265IP and36credits. The Omni fighter has34 items, +600 current/11750 cumulativeXP,14645IP and216credits. Observers19/21 retain their +6/7 issued items and zero XP/credits. No WASM page error or abort was recorded. + +Both cold clients in each zone also confirm the available nine reviewed +species/level combinations, including ordinary replacements of the killed +actors. The three same-body ROLL controls retain their prototype weapons and +do not acquire the RR01 profile. Snake level4 is covered by automation; the +current authored point allocation exposes levels2/3 in that group. + +`tmp_verify_native.py`, `cold-restart.json` and `cleanup-verified.json` retain +the exact audits under `local/starter-fauna/`. All four owned browser profiles +are closed. The sole requested LAN preview remains on HTTPS8443 and the other +default ports. The broader progression, historical balance, foreign-looter and +player-HP ordering tasks remain open. diff --git a/server/gamedata/load.go b/server/gamedata/load.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "io/fs" + "slices" "sort" "go.yaml.in/yaml/v3" @@ -253,7 +254,12 @@ func init() { } } // Template-specific encounters must match an admitted original population. - if profile.TemplateCode != "" { + if len(profile.TemplateCodes) != 0 { + for index, code := range profile.TemplateCodes { + if code == "" || slices.Contains(profile.TemplateCodes[:index], code) { + panic(fmt.Errorf("NPC combat profile %d/%d has an empty or duplicate template code", monster, level)) + } + } matched := false for _, group := range NPCGroups { if group.SupportsCombatProfile(monster, profile) && @@ -263,7 +269,7 @@ func init() { } } if !matched { - panic(fmt.Errorf("NPC combat profile %d/%d has no admitted population for %s", monster, level, profile.TemplateCode)) + panic(fmt.Errorf("NPC combat profile %d/%d has no admitted population for %v", monster, level, profile.TemplateCodes)) } } first, second := ItemTemplates[profile.Weapon[0]], ItemTemplates[profile.Weapon[1]] diff --git a/server/gamedata/npc_combat.go b/server/gamedata/npc_combat.go @@ -16,7 +16,7 @@ func interpolateNPCProfiles(profiles map[uint32]map[uint16]*NPCCombatProfile) er continue } first, second := levels[low], levels[high] - if first.TemplateCode != second.TemplateCode || first.Weapon != second.Weapon || + if !slices.Equal(first.TemplateCodes, second.TemplateCodes) || first.Weapon != second.Weapon || first.Initiative != second.Initiative || first.AggDef != second.AggDef || first.RespawnSeconds != second.RespawnSeconds || first.CorpseSeconds != second.CorpseSeconds || first.Credits != second.Credits || len(first.Loot) != len(second.Loot) { @@ -34,6 +34,7 @@ func interpolateNPCProfiles(profiles map[uint32]map[uint16]*NPCCombatProfile) er return first + (second-first)*int64(level-low)/int64(high-low) } profile := *first + profile.TemplateCodes = slices.Clone(first.TemplateCodes) profile.Health = uint32(interpolate(int64(first.Health), int64(second.Health))) profile.Experience = uint32(interpolate(int64(first.Experience), int64(second.Experience))) profile.Skills, profile.Modifiers = maps.Clone(first.Skills), maps.Clone(first.Modifiers) diff --git a/server/gamedata/npc_combat.yaml b/server/gamedata/npc_combat.yaml @@ -82,7 +82,7 @@ 30365: 1: &reet # RT01's name is an original client reference; its complete template is inferred. - template_code: RT01 + template_codes: [RT01] # Provisional starter balance, not a recovered species growth or loot formula. health: 100 experience: 100 @@ -108,7 +108,7 @@ 17708: 2: &tiny_stalker # SR01's species binding is medium-confidence; see docs/tiny-stalker.md. - template_code: SR01 + template_codes: [SR01] # Explicit provisional balance, not an original species growth formula. health: 100 experience: 100 @@ -135,11 +135,85 @@ quality: [3, 5] chance: 50 +17687: + 1: &starter_rollerrat + # Original RR01 starter population; the full species binding remains inferred. + template_codes: [RR01] + # Shared provisional starter baseline, not historical species statistics. + health: 100 + experience: 100 + skills: {100: 5, 153: 5, 154: 5, 155: 5, 168: 5} + # Original Faceroll endpoints. Selection instead of Spray is provisional. + weapon: [121050, 121051] + initiative: 0 + agg_def: 75 + respawn_seconds: 100 + corpse_seconds: 180 + credits: [1, 5] + # Provisional biological loot, chance and level-relative selected quality. + loot: + - template: 42640 + quality: [1, 1] + chance: 50 + 2: + <<: *starter_rollerrat + loot: + - template: 42640 + quality: [1, 3] + chance: 50 + +30252: + 1: &starter_snake + <<: *starter_rollerrat + # Both original training codes use this inferred Giant Snake body. + template_codes: [SN01, SN02] + # Original GiantserpentBite; selection instead of Spit remains provisional. + weapon: [120846, 120847] + 2: + <<: *starter_snake + loot: + - template: 42640 + quality: [1, 3] + chance: 50 + 4: + <<: *starter_snake + # Explicit provisional upper anchor; shared interpolation resolves level 3. + health: 150 + experience: 150 + skills: {100: 15, 153: 15, 154: 15, 155: 15, 168: 15} + loot: + - template: 42640 + quality: [3, 5] + chance: 50 + +17660: + 1: &starter_malle + <<: *starter_snake + # ML01 includes original authored levels 2..4 and a level-1..3 fallback group. + template_codes: [ML01] + # Original MalleBite; Claw/Tail selection and later variants remain unresolved. + weapon: [120922, 120923] + 2: + <<: *starter_malle + loot: + - template: 42640 + quality: [1, 3] + chance: 50 + 4: + <<: *starter_malle + health: 150 + experience: 150 + skills: {100: 15, 153: 15, 154: 15, 155: 15, 168: 15} + loot: + - template: 42640 + quality: [3, 5] + chance: 50 + 30369: 4: # Only the authored Omni Training BNMO uses this level/body/code combination. # The Aquaan identity is low-confidence; see docs/omni-training-boss.md. - template_code: BNMO + template_codes: [BNMO] # Provisional level-4 early balance, not a recovered boss template. health: 150 experience: 150 @@ -163,7 +237,7 @@ 30354: 4: # The original Clan Training fixed boss; ordinary salamanders do not inherit it. - template_code: BSML + template_codes: [BSML] # Provisional early-profile baseline; no historical boss multipliers recovered. health: 100 experience: 100 diff --git a/server/gamedata/npc_combat_test.go b/server/gamedata/npc_combat_test.go @@ -2,13 +2,14 @@ package gamedata import ( "maps" + "slices" "testing" ) func TestNPCLevelAnchorsResolveBoundedIndependentProfiles(t *testing.T) { - first := &NPCCombatProfile{Health: 125, Experience: 125, Skills: map[uint32]int32{100: 10}, + first := &NPCCombatProfile{TemplateCodes: []string{"SN01", "SN02"}, Health: 125, Experience: 125, Skills: map[uint32]int32{100: 10}, Modifiers: map[uint32]int32{276: 3, 277: -3}, Loot: []NPCLoot{{Template: 42640, Quality: [2]uint32{2, 4}, Chance: 50}}} - second := &NPCCombatProfile{Health: 175, Experience: 175, Skills: map[uint32]int32{100: 20}, + second := &NPCCombatProfile{TemplateCodes: []string{"SN01", "SN02"}, Health: 175, Experience: 175, Skills: map[uint32]int32{100: 20}, Modifiers: map[uint32]int32{276: 8, 277: -8}, Loot: []NPCLoot{{Template: 42640, Quality: [2]uint32{4, 6}, Chance: 50}}} profiles := map[uint32]map[uint16]*NPCCombatProfile{17655: {3: first, 5: second}} @@ -19,9 +20,10 @@ func TestNPCLevelAnchorsResolveBoundedIndependentProfiles(t *testing.T) { profile.Skills[100] != 15 || profile.Modifiers[276] != 5 || profile.Modifiers[277] != -5 || profile.Loot[0].Quality != [2]uint32{3, 5} { t.Fatal("bounded interpolation changed numeric rounding or omitted a foundation", profile, err) } - profile.Skills[100], profile.Modifiers[276], profile.Loot[0].Quality[0] = 99, 99, 99 + profile.Skills[100], profile.Modifiers[276], profile.Loot[0].Quality[0], profile.TemplateCodes[0] = 99, 99, 99, "other" if first.Skills[100] != 10 || second.Skills[100] != 20 || first.Modifiers[276] != 3 || second.Modifiers[276] != 8 || - first.Loot[0].Quality != [2]uint32{2, 4} || second.Loot[0].Quality != [2]uint32{4, 6} { + first.Loot[0].Quality != [2]uint32{2, 4} || second.Loot[0].Quality != [2]uint32{4, 6} || + !slices.Equal(first.TemplateCodes, []string{"SN01", "SN02"}) || !slices.Equal(second.TemplateCodes, []string{"SN01", "SN02"}) { t.Fatal("resolved profile shares mutable data with an anchor") } } @@ -34,7 +36,7 @@ func TestNPCLevelAnchorsRejectAmbiguousIntermediateIdentity(t *testing.T) { second := *first switch change { case "template": - second.TemplateCode = "other" + second.TemplateCodes = []string{"other"} case "weapon": second.Weapon = [2]uint32{120910, 120911} case "initiative": @@ -87,7 +89,7 @@ func TestProductionNPCGrowthRetainsBaselineAndStopsAtReviewedBoundary(t *testing t.Fatal("production profile changed the declared bounded growth", index+1, profile) } } - if len(profiles) != 10 || profiles[0] != nil || profiles[11] != nil || len(NPCCombatProfiles[30354]) != 1 || NPCCombatProfiles[30354][4].TemplateCode != "BSML" { + if len(profiles) != 10 || profiles[0] != nil || profiles[11] != nil || len(NPCCombatProfiles[30354]) != 1 || !slices.Equal(NPCCombatProfiles[30354][4].TemplateCodes, []string{"BSML"}) { t.Fatal("growth extrapolated beyond its reviewed range or changed boss scope") } } diff --git a/server/gamedata/types.go b/server/gamedata/types.go @@ -1,5 +1,7 @@ package gamedata +import "slices" + type ShopItem struct { Template uint32 `yaml:"template"` Quality uint32 `yaml:"quality"` @@ -62,7 +64,7 @@ type NPCData struct { } type NPCCombatProfile struct { - TemplateCode string `yaml:"template_code"` + TemplateCodes []string `yaml:"template_codes,flow"` Health uint32 `yaml:"health"` Experience uint32 `yaml:"experience"` Skills map[uint32]int32 `yaml:"skills"` @@ -139,8 +141,8 @@ func (group *NPCGroup) SupportsCombatProfile(monster uint32, profile *NPCCombatP if profile == nil || group.MonsterData != monster { return false } - if profile.TemplateCode != "" { - return profile.TemplateCode == group.TemplateCode && + if len(profile.TemplateCodes) != 0 { + return slices.Contains(profile.TemplateCodes, group.TemplateCode) && (group.AppearanceStatus == "inferred_species" || group.AppearanceStatus == "best_effort") } return group.AppearanceStatus == "inferred_species" diff --git a/server/npc_shared_pursuit_test.go b/server/npc_shared_pursuit_test.go @@ -11,7 +11,8 @@ func TestAdmittedNPCProfilesSharePursuitAndReturn(t *testing.T) { for _, profile := range []struct { monster uint32 level uint16 - }{{17655, 1}, {17655, 2}, {30365, 1}, {30365, 2}, {17708, 2}, {17708, 3}, {17708, 4}, {30354, 4}} { + }{{17655, 1}, {17655, 2}, {30365, 1}, {30365, 2}, {17708, 2}, {17708, 3}, {17708, 4}, {30354, 4}, + {17687, 1}, {17687, 2}, {30252, 1}, {30252, 2}, {30252, 3}, {30252, 4}, {17660, 1}, {17660, 2}, {17660, 3}, {17660, 4}} { for _, roaming := range []bool{false, true} { t.Run(fmt.Sprintf("%d/%d/roaming=%t", profile.monster, profile.level, roaming), func(t *testing.T) { world, _, start := newNPCPursuitWorld() diff --git a/server/reet_test.go b/server/reet_test.go @@ -26,7 +26,7 @@ func TestReetStarterPopulationsRetainProfilesAndNativeWeapons(t *testing.T) { for index := range data.Playfields[0].Districts[0].Groups[0].Positions { npc := current.characters[1000000+uint32(index)] if npc.name != "Reet of Paradise" || npc.monsterData != 30365 || npc.level < 1 || npc.level > 2 || - npc.combatProfile == nil || npc.combatProfile.TemplateCode != "RT01" || npc.maximumHealth() != 100 || + npc.combatProfile == nil || !slices.Equal(npc.combatProfile.TemplateCodes, []string{"RT01"}) || npc.maximumHealth() != 100 || npc.health != 100 || npc.attackRating() != 5 || itemStat(npc.attackWeapon(), 286) != 4 || itemStat(npc.attackWeapon(), 285) != uint32(8+npc.level) { t.Fatal("original Reet population lost its bounded profile, level or weapon", npc.id, npc.level, npc.combatProfile) diff --git a/server/starter_boss_test.go b/server/starter_boss_test.go @@ -400,7 +400,7 @@ func TestStarterBossProfileRequiresItsCodeSpeciesLevelAndEvidence(t *testing.T) if err != nil || len(spawns) != 1 || (spawns[0].combatProfile != nil) != scenario.accepted { t.Fatal("boss profile leaked across its binding or lost the existing species rule", err, spawns) } - if scenario.monster == 17655 && spawns[0].combatProfile != nil && spawns[0].combatProfile.TemplateCode != "" { + if scenario.monster == 17655 && spawns[0].combatProfile != nil && len(spawns[0].combatProfile.TemplateCodes) != 0 { t.Fatal("a Leet acquired template-specific boss combat") } }) diff --git a/server/starter_fauna_test.go b/server/starter_fauna_test.go @@ -0,0 +1,185 @@ +package main + +import ( + "ao/server/gamedata" + "encoding/binary" + "fmt" + "slices" + "testing" + "time" +) + +func TestStarterFaunaPopulationsRecoverProfilesAndNativeWeapons(t *testing.T) { + for _, scenario := range []struct { + group string + monster uint32 + weapon [2]uint32 + levels []uint16 + damage [][2]uint32 + }{ + {"952/district/4/group/2/authored_point", 17687, [2]uint32{121050, 121051}, []uint16{1, 2}, [][2]uint32{{6, 12}, {7, 14}}}, + {"950/district/1/group/2/authored_point", 30252, [2]uint32{120846, 120847}, []uint16{1, 2, 1, 2}, [][2]uint32{{6, 12}, {6, 13}, {6, 12}, {6, 13}}}, + {"950/district/2/group/2/authored_point", 30252, [2]uint32{120846, 120847}, []uint16{1}, [][2]uint32{{6, 12}}}, + {"950/district/4/group/2/authored_point", 30252, [2]uint32{120846, 120847}, []uint16{2, 3}, [][2]uint32{{6, 13}, {7, 15}}}, + {"950/district/4/group/1/authored_point", 17660, [2]uint32{120922, 120923}, []uint16{2, 3, 4}, [][2]uint32{{6, 13}, {7, 15}, {7, 16}}}, + {"950/district/5/group/1/district_center_fallback", 17660, [2]uint32{120922, 120923}, []uint16{1, 2}, [][2]uint32{{6, 12}, {6, 13}}}, + } { + t.Run(scenario.group, func(t *testing.T) { + data := testNPCData() + data.Playfields[0].Districts[0].Groups[0] = *gamedata.NPCGroups[scenario.group] + data.PlacementStatuses["district_center_fallback"] = gamedata.NPCs.PlacementStatuses["district_center_fallback"] + 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, level := range scenario.levels { + npc := current.characters[1000000+uint32(index)] + if npc.monsterData != scenario.monster || npc.level != level || npc.combatProfile != gamedata.NPCCombatProfiles[scenario.monster][level] || + npc.health != []uint32{100, 100, 125, 150}[level-1] || npc.attackRating() != []int32{5, 5, 10, 15}[level-1] || + itemStat(npc.attackWeapon(), 286) != scenario.damage[index][0] || itemStat(npc.attackWeapon(), 285) != scenario.damage[index][1] || + !slices.Contains(npc.combatProfile.TemplateCodes, data.Playfields[0].Districts[0].Groups[0].TemplateCode) { + t.Fatal("starter population lost its authored level, identity or shared profile", npc.id, npc.level, npc.combatProfile) + } + packet := targetPacket(characterPacket(npc)) + end := int(binary.BigEndian.Uint16(packet[6:8])) + if binary.BigEndian.Uint32(packet[end-16:end-12]) != scenario.weapon[0] || + binary.BigEndian.Uint32(packet[end-12:end-8]) != scenario.weapon[1] || binary.BigEndian.Uint32(packet[end-4:end]) != uint32(level) { + t.Fatal("native starter weapon lost its original endpoints or selected quality") + } + } + } + }) + } +} + +func TestStarterFaunaRejectsUnreviewedCodesBodiesEvidenceAndLevels(t *testing.T) { + for _, species := range []struct { + code string + monster uint32 + outside uint16 + }{{"RR01", 17687, 3}, {"SN01", 30252, 5}, {"SN02", 30252, 5}, {"ML01", 17660, 5}} { + for _, change := range []string{"code", "body", "placeholder", "level"} { + t.Run(species.code+"/"+change, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.TemplateCode, group.MonsterData, group.Levels, group.AppearanceStatus = species.code, species.monster, [2]uint16{1, 1}, "inferred_species" + switch change { + case "code": + group.TemplateCode = "OTHER" + case "body": + group.MonsterData = 30365 + case "placeholder": + group.AppearanceStatus = "placeholder_creature" + case "level": + group.Levels = [2]uint16{species.outside, species.outside} + } + useNPCData(t, data) + world := newTestServer(t) + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + + cold := newTestInventoryServer(t) + + if world.characters[1000000].combatProfile != nil || cold.characters[1000000].combatProfile != nil { + t.Fatal("unreviewed identity or quality inherited an admitted starter profile") + } + }) + } + } +} + +func TestStarterFaunaCombatUsesOriginalDamageAndTiming(t *testing.T) { + for _, scenario := range []struct { + code string + monster uint32 + phase time.Duration + }{{"RR01", 17687, 3200 * time.Millisecond}, {"SN01", 30252, 2350 * time.Millisecond}, {"SN02", 30252, 2350 * time.Millisecond}, {"ML01", 17660, 2350 * time.Millisecond}} { + t.Run(scenario.code, func(t *testing.T) { + data := testNPCData() + group := &data.Playfields[0].Districts[0].Groups[0] + group.TemplateCode, group.MonsterData, group.Levels, group.AppearanceStatus = scenario.code, scenario.monster, [2]uint16{1, 1}, "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 = func(limit uint32) uint32 { + if limit == 100 { + return 50 + } + return 0 + } + + 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(scenario.phase - time.Nanosecond)) + if player.health != 34 { + t.Fatal("starter attack landed before its original attack phase") + } + world.advanceCombat(start.Add(scenario.phase)) + + if player.health != 28 || world.characters[1000000].nextAttack != start.Add(3*scenario.phase) { + t.Fatal("starter attack changed original damage, attack or recharge timing", player.health) + } + }) + } +} + +func TestStarterFaunaDeathsRetainSharedRewardsAcrossKillingActions(t *testing.T) { + for _, attack := range []string{"unarmed", "axe", "pistol", "fling", "fast", "nano"} { + for _, scenario := range []struct { + group string + monster uint32 + level uint16 + quality uint32 + xp uint32 + }{ + {"952/district/4/group/2/authored_point", 17687, 1, 1, 100}, + {"952/district/4/group/2/authored_point", 17687, 2, 3, 100}, + {"950/district/1/group/2/authored_point", 30252, 1, 1, 100}, + {"950/district/4/group/2/authored_point", 30252, 2, 3, 100}, + {"950/district/4/group/2/authored_point", 30252, 4, 5, 150}, + {"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}, + } { + t.Run(fmt.Sprintf("%s/%d/%d", attack, scenario.monster, scenario.level), func(t *testing.T) { + world, _ := newKillExperienceWorld(t, attack) + target := world.characters[1000000] + target.monsterData, target.level, target.npcDefinitionID = scenario.monster, scenario.level, scenario.group + target.combatProfile = gamedata.NPCCombatProfiles[scenario.monster][scenario.level] + world.combatRoll = func(limit uint32) uint32 { + if limit == 3 { + return 2 + } + return 0 + } + identity := world.nextItem + 1 + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + + attackForExperience(t, world, attack) + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + npc := current.characters[1000000] + if npc.health != 0 || npc.corpse == nil || npc.corpse.credits != 1 || current.characters[1].experience != scenario.xp || + !slices.Equal(npc.corpse.items, []ownedItem{{ID: identity, Type: 51005, Template: 42640, Quality: scenario.quality, Count: 1}}) || + current.nextItem != identity || npc.combatProfile != gamedata.NPCCombatProfiles[scenario.monster][scenario.level] { + t.Fatal("starter death lost shared XP, credits, selected-quality loot or its cold profile", npc.corpse) + } + } + }) + } + } +} diff --git a/server/tiny_stalker_test.go b/server/tiny_stalker_test.go @@ -30,7 +30,7 @@ func TestTinyStalkerPopulationProfilesRecoverNativeWeapons(t *testing.T) { }{{2, 100, 5, 4, 10}, {3, 125, 10, 4, 11}, {4, 150, 15, 4, 12}, {2, 100, 5, 4, 10}} { npc := current.characters[1000000+uint32(index)] if npc.name != "Tiny Stalker" || npc.monsterData != 17708 || npc.level != expected.level || npc.health != expected.health || - npc.combatProfile == nil || npc.combatProfile.TemplateCode != "SR01" || npc.attackRating() != expected.rating || + npc.combatProfile == nil || !slices.Equal(npc.combatProfile.TemplateCodes, []string{"SR01"}) || npc.attackRating() != expected.rating || itemStat(npc.attackWeapon(), 286) != expected.low || itemStat(npc.attackWeapon(), 285) != expected.high { t.Fatal("authored Stalker population lost its bounded profile or weapon quality", index, npc) }