aorecomp

Anarchy Online classic in the browser

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


commit 4b608055e1ee0041c54bcfe0148098d012d76e72
parent abb880abfcfbfadce70390dea297d13d514adbe6
Author: anon <anon@example.com>
Date:   Sun,  8 Nov 2026 21:00:18 +0000

Expose loot evidence and inferred chances with starter drop expansion

Diffstat:
MTODO.md | 7+++++++
Mdocs/npc-loot.md | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mdocs/shop-stock-expansion.md | 6++++++
Mserver/gamedata/item_families.yaml | 8++++++++
Mserver/gamedata/load.go | 2+-
Mserver/gamedata/npc_combat.go | 4++--
Mserver/gamedata/npc_combat.yaml | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/npc_combat_test.go | 8+++++++-
Mserver/gamedata/types.go | 8+++++---
Mserver/item_pages.go | 8+++++---
Mserver/item_source_pages.go | 6++++++
Mserver/item_sources.go | 47++++++++++++++++++++++++++++++++++++++---------
Mserver/kill_experience_test.go | 5++++-
Mserver/npc_levels_test.go | 8+++++++-
Mserver/npc_loot_range_test.go | 12++++++------
Aserver/npc_loot_sources_test.go | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/npc_loot_test.go | 6+++---
Mserver/npc_profile_evidence_test.go | 2+-
Mserver/omni_training_boss_test.go | 5++++-
Mserver/starter_boss_test.go | 15+++++++++++----
Mtools/client/test_item_sources.mjs | 13+++++++++++++
21 files changed, 403 insertions(+), 39 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -183,6 +183,13 @@ research separately. More screenshots and test cases do not count as new gamepla shops. The [acquisition audit](docs/shop-stock-expansion.md) confirms six configured loot families versus 3,363 shop families; the filter exposes existing drops and does not expand loot tables or change probabilities. + The subsequent [loot expansion](docs/npc-loot.md) adds YAML evidence/inference + fields, visible per-roll chances and provenance in the catalog, and seven + additional loot families from AORebirth candidate data with explicit inferred + rates/assignments. Six previously unsourced gem/jewelry families now have + training-boss sources; Leets can drop useful Low-Tech gloves. CellAO's examples + provide no compatible starter rows. This completes the requested acquisition + visibility/content extension, not recovery of the full historical loot table. November 5: [the finite terminal inventory](docs/early-shop-stock.md) lists all 190 placements in training grounds 950/952/954 and basic shops 1180/1183/1186. The four empty training terminals now carry seven original QL1 diff --git a/docs/npc-loot.md b/docs/npc-loot.md @@ -21,12 +21,70 @@ choices from the recovered weapon values and population identities. The first table uses original Monster Parts 42640, QL 1, with a **provisional 50% chance and 1..5 credits**. Those probabilities and cash amounts are reconstruction values, not recovered 14.9.1 formulas. The independent-row/uniform-cash policy is -also provisional. Equipment membership is declared only for the two admitted -training bosses, not inferred from another creature's name or level. The Omni +also provisional. Equipment membership is declared explicitly for admitted +profiles. Leets also have the inferred glove drop described below. The Omni profile selects supported QL3..5 gloves/pistols; the Clan profile retains fixed QL4. Broader useful pools, variable quantities, historical distributions and a universal loot-quality rule remain open in TODO. +## Configured acquisition evidence and first expansion + +`npc_combat.yaml` keeps drop eligibility on the creature's `loot` rows, with +`template`, inclusive `quality`, and integer percent `chance`. Each row also has +`evidence` (what a source actually establishes) and `inference` (our assignment, +probability or QL assumptions). At least one of these descriptions is required. +Level interpolation preserves both descriptions and rejects conflicting anchor +evidence. The decoded original item YAML remains an account of original records. + +The admin catalog shows each family's distinct configured chances per roll and +whether inference is involved. Item details show the evidence, inferred choices, +NPC levels, offered QLs and map links. A family-level source does not imply that +every QL drops. An item without a configured drop is not declared historically +ineligible. The source index is built from the same admitted profiles used by +corpse generation. + +The first expansion uses the pinned AORebirth observed-loot CSV linked below: + +| Local source | Added item | Chance per independent roll | Offered QL | +| --- | --- | --- | --- | +| Admitted Leets, levels 1..10 | Low-Tech Armor Gloves 70562/85597 | 10% | 1 at level 1; level +/- 1 thereafter | +| Omni training boss | Golden Sphere 136642/136643; Pearl of Rubi-Ka 136646/136647 | 5% each | 3..5 | +| Clan training boss | Ruby 136626/136627; Ember 136628/136629 | 5% each | 4 | +| Neutral training boss | Snake Ring 136610/136611; Bracelet of Ka 136618/136619 | 5% each | 3..5 | + +The glove observation was one of eight later Beach Leet bodies. The boss items +were observed on later starter-island bosses, not these local bosses. Their +membership guides this selection; all local assignments, rates and expanded QL +ranges are inferred. Single-body observations are not imported as guaranteed +drops. Two independent 5% rows give a 9.75% chance of at least one new item per +boss. Existing equipment, Monster Parts, Robot Junk and cash rates are unchanged. +Existing provisional rows now explicitly describe their inference in the UI. + +CellAO's 25 example rows contain no applicable early-level original items; its +compatible nano/disc entries require higher QLs. The other entries include later +expansion items absent from our catalog. Accordingly no CellAO starter membership +or probabilities were fabricated. Its separate NPC assignment and item/QL model +supports keeping these fields on loot rows. Later-only seashells, spinal sections +and corundums from AORebirth are excluded as well. + +The six new gem/jewelry pairs match AORebirth's explicit low/high IDs. Both original +endpoints were checked: QL1..200, matching type/capabilities/placement, no effect +sections, and only price/weight/level variation. The gems are carry/sale items; +the ring and bracelet are decorative equipment without stat bonuses. Their +original prices are retained. This adds seven configured loot families (six +previously unsourced), taking the total from six to thirteen; it does not assign +all internal, quest or high-level catalog definitions to arbitrary vendors. +At a 5% shop buyback modifier and zero Computer Literacy, the QL3..5 gems/bracelet +sell for 201/203/206 credits and the ring for 161/163/165, using the existing +curved price interpolation. Combined with the configured rates, the new rows +add about 18..20 expected sale credits per boss kill, before literacy modifiers. + +Focused verification covers production probability boundaries, typed rewards, +pickup and cold recovery; catalog family lookup, evidence and inferred labels; +anchor consistency; and browser navigation without nested scrolling. Existing +transaction and equipment tests use explicit small fixtures to keep their +ownership/failure assertions independent of the production pool's size. + ## Item metadata and emulator comparison, November 8 Question: can the original item catalog supply loot eligibility or probabilities, @@ -89,6 +147,8 @@ no configured drops. Perfectly Formed Seashell (259990) and Spinal Section (248323) are absent from our 14.9.1 catalog and must not be imported. The six unsourced candidates still need effect/usage and target-era membership review; this comparison does not establish their loot rates or authorize all their QLs. +The implementation section above records the subsequent endpoint review and +explicitly inferred assignments for this shortlist. The useful design direction is small reusable item pools assigned explicitly to reviewed species/bosses, with separate probabilities and supported QL ranges. @@ -156,7 +216,8 @@ Typed fixture coverage does not establish those items as historical Leet drops. ## Selected item qualities -Each loot row requires `template`, inclusive `quality: [low, high]` and `chance`. +Each loot row requires `template`, inclusive `quality: [low, high]`, `chance`, and +an `evidence` or `inference` description. Startup rejects missing/zero or reversed bounds, unknown templates and intervals outside the template's reviewed family. Fixed-QL items accept only their authored quality as both bounds. Quality is sampled after successful membership; fixed diff --git a/docs/shop-stock-expansion.md b/docs/shop-stock-expansion.md @@ -162,6 +162,12 @@ with configured NPC drops, using the catalog's reviewed family grouping: | Rusty OT M-10 Flechette Pistol | The three training bosses | 25% | These are provisional configured probabilities, not recovered historical rates. +The subsequent [loot expansion](npc-loot.md) raises configured loot coverage to +thirteen families, including six previously unsourced gem/jewelry families and +shop-sold Low-Tech gloves. The audit below describes the pre-expansion snapshot. +The catalog now also lists distinct per-roll chances and whether they involve +inference; the detail page separates source evidence from inferred assignments. + The catalog's `Loot: N` counts NPC groups, not percentage chance; the item detail page gives chances and QL ranges. Shop and loot coverage overlap. Of 82,264 catalog family keys, 78,859 have no indexed acquisition source; this includes diff --git a/server/gamedata/item_families.yaml b/server/gamedata/item_families.yaml @@ -54,6 +54,14 @@ - [42640, 42641] # Robot Junk: reviewed QL1/400 records and native pickup; docs/starter-fauna.md. - [42620, 42619] +# Gems and decorative jewelry: AORebirth observed pairs, checked original endpoints; +# no effect sections, only price/weight/QL differ. See docs/npc-loot.md. +- [136610, 136611] +- [136618, 136619] +- [136626, 136627] +- [136628, 136629] +- [136642, 136643] +- [136646, 136647] # Low-Tech armor: complete original descriptor audits; docs/early-armor.md. - [70558, 85640] - [70559, 85689] diff --git a/server/gamedata/load.go b/server/gamedata/load.go @@ -332,7 +332,7 @@ func init() { panic(fmt.Errorf("NPC combat profile %d/%d has invalid corpse cash", monster, level)) } for _, drop := range profile.Loot { - if drop.Chance > 100 || drop.Quality[0] > drop.Quality[1] || + if drop.Chance > 100 || drop.Quality[0] > drop.Quality[1] || drop.Evidence == "" && drop.Inference == "" || !ItemQualitySupported(drop.Template, drop.Quality[0]) || !ItemQualitySupported(drop.Template, drop.Quality[1]) { panic(fmt.Errorf("NPC combat profile %d/%d has invalid loot %d", monster, level, drop.Template)) } diff --git a/server/gamedata/npc_combat.go b/server/gamedata/npc_combat.go @@ -23,8 +23,8 @@ func interpolateNPCProfiles(profiles map[uint32]map[uint16]*NPCCombatProfile) er return fmt.Errorf("NPC combat anchors %d/%d..%d change noninterpolated settings", monster, low, high) } for index, drop := range first.Loot { - if drop.Template != second.Loot[index].Template || drop.Chance != second.Loot[index].Chance { - return fmt.Errorf("NPC combat anchors %d/%d..%d change loot identity or chance", monster, low, high) + if drop.Template != second.Loot[index].Template || drop.Chance != second.Loot[index].Chance || drop.Evidence != second.Loot[index].Evidence || drop.Inference != second.Loot[index].Inference { + return fmt.Errorf("NPC combat anchors %d/%d..%d change loot identity, chance or evidence", monster, low, high) } } diff --git a/server/gamedata/npc_combat.yaml b/server/gamedata/npc_combat.yaml @@ -28,6 +28,13 @@ - template: 42640 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - &leet_gloves + template: 70562 + quality: [1, 1] + chance: 10 + evidence: "AORebirth ObservedLiveLootSeed.csv: Low-Tech gloves on 1 of 8 level-1 Beach Leets." + inference: "Applied to local Leets; 10% chance and level-adjacent QLs are inferred, not measured 14.9.1 rates." 2: # Provisional starter health and solo reward, not historical measurements. health: 20 @@ -46,6 +53,9 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - <<: *leet_gloves + quality: [1, 3] # Bounded provisional growth: +10 HP, +25 XP and +5 raw skills per level from 2. # This is a gameplay choice, not a recovered historical formula. Level 4 is interpolated. @@ -58,6 +68,9 @@ - template: 42640 quality: [2, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - <<: *leet_gloves + quality: [2, 4] 5: <<: *leet health: 50 @@ -67,6 +80,9 @@ - template: 42640 quality: [4, 6] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - <<: *leet_gloves + quality: [4, 6] # Explicit provisional upper anchor for the next early progression range. # HP/XP/skills and loot remain balance choices, not original server measurements. @@ -80,6 +96,9 @@ - template: 42640 quality: [9, 11] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - <<: *leet_gloves + quality: [9, 11] 30360: 1: &minibull @@ -100,12 +119,14 @@ - template: 42640 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *minibull loot: - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *minibull health: 40 @@ -115,6 +136,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 10: <<: *minibull health: 100 @@ -124,6 +146,7 @@ - template: 42640 quality: [9, 11] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 30365: 1: &reet @@ -144,12 +167,14 @@ - template: 42640 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *reet loot: - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 3: &starter_reet <<: *reet @@ -162,6 +187,7 @@ - template: 42640 quality: [2, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_reet health: 40 @@ -171,6 +197,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 17708: 2: &tiny_stalker @@ -192,6 +219,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *tiny_stalker health: 40 @@ -201,6 +229,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 17687: 1: &starter_rollerrat @@ -222,12 +251,14 @@ - template: 42640 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *starter_rollerrat loot: - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 3: &starter_roll <<: *starter_rollerrat @@ -240,6 +271,7 @@ - template: 42640 quality: [2, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_roll health: 40 @@ -249,6 +281,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 30252: 1: &starter_snake @@ -263,6 +296,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_snake # Explicit provisional upper anchor; shared interpolation resolves level 3. @@ -273,6 +307,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 17660: 1: &starter_malle @@ -287,6 +322,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_malle health: 40 @@ -296,6 +332,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 22794: 1: &starter_lizard @@ -311,6 +348,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_lizard health: 40 @@ -320,6 +358,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 40075: 1: &starter_blubbag @@ -334,6 +373,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 3: <<: *starter_blubbag health: 30 @@ -343,6 +383,7 @@ - template: 42640 quality: [2, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 17649: 1: &starter_android @@ -355,12 +396,14 @@ - template: 42620 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *starter_android loot: - template: 42620 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_android health: 40 @@ -370,6 +413,7 @@ - template: 42620 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 30258: 1: &starter_biofreak @@ -383,6 +427,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_biofreak health: 40 @@ -392,6 +437,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 38387: 1: &starter_clawfinger @@ -405,6 +451,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 3: <<: *starter_clawfinger health: 30 @@ -414,6 +461,7 @@ - template: 42640 quality: [2, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 17653: 2: &starter_eye_mutant @@ -425,6 +473,7 @@ - template: 42640 quality: [1, 3] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 4: <<: *starter_eye_mutant health: 40 @@ -434,6 +483,7 @@ - template: 42640 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 30369: 4: &starter_boss @@ -456,9 +506,21 @@ - template: 85596 quality: [3, 5] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. - template: 123742 quality: [3, 5] chance: 25 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - template: 136642 + quality: [3, 5] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Golden Sphere on Burneye, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." + - template: 136646 + quality: [3, 5] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Pearl of Rubi-Ka on Burneye, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." 45873: 4: @@ -467,6 +529,25 @@ template_codes: [BOMJ] # Original JunkbotOnearmslash; selecting it over Twoarmslash is provisional. weapon: [125256, 125257] + loot: + - template: 85596 + quality: [3, 5] + chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - template: 123742 + quality: [3, 5] + chance: 25 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - template: 136610 + quality: [3, 5] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Snake Ring on Burneye, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." + - template: 136618 + quality: [3, 5] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Bracelet of Ka on Writhetongue, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." 30354: 4: @@ -489,9 +570,21 @@ - template: 85596 quality: [4, 4] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. - template: 123742 quality: [4, 4] chance: 25 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. + - template: 136626 + quality: [4, 4] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Ruby on Writhetongue, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." + - template: 136628 + quality: [4, 4] + chance: 5 + evidence: "AORebirth ObservedLiveLootSeed.csv: Ember on Writhetongue and Slithertongue, one observed body." + inference: "Assigned to this local training boss; 5% independent chance and QL range are inferred." # Six reviewed training human populations only. Their template codes are reused # outside these routes. Combat/rewards are provisional; original BRW1 fist data @@ -513,6 +606,7 @@ - template: 82102 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *training_human @@ -525,6 +619,7 @@ - template: 82912 quality: [1, 1] chance: 50 + inference: NPC assignment, chance and QL range are provisional reconstruction choices. 2: <<: *training_functionary diff --git a/server/gamedata/npc_combat_test.go b/server/gamedata/npc_combat_test.go @@ -31,7 +31,7 @@ func TestNPCLevelAnchorsResolveBoundedIndependentProfiles(t *testing.T) { } func TestNPCLevelAnchorsRejectAmbiguousIntermediateIdentity(t *testing.T) { - for _, change := range []string{"template", "group", "weapon", "initiative", "aggdef", "respawn", "corpse", "cash", "loot count", "loot template", "loot chance", "skill count", "skill identity", "modifier identity"} { + for _, change := range []string{"template", "group", "weapon", "initiative", "aggdef", "respawn", "corpse", "cash", "loot count", "loot template", "loot chance", "loot evidence", "loot inference", "skill count", "skill identity", "modifier identity"} { t.Run(change, func(t *testing.T) { first := &NPCCombatProfile{Health: 100, Skills: map[uint32]int32{100: 5}, Modifiers: map[uint32]int32{276: 5}, Loot: []NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}}} @@ -59,6 +59,12 @@ func TestNPCLevelAnchorsRejectAmbiguousIntermediateIdentity(t *testing.T) { second.Loot = []NPCLoot{{Template: 85596, Quality: [2]uint32{1, 1}, Chance: 50}} case "loot chance": second.Loot = []NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 100}} + case "loot evidence": + second.Loot = slices.Clone(first.Loot) + second.Loot[0].Evidence = "different observation" + case "loot inference": + second.Loot = slices.Clone(first.Loot) + second.Loot[0].Inference = "different assumption" case "skill count": second.Skills = nil case "skill identity": diff --git a/server/gamedata/types.go b/server/gamedata/types.go @@ -79,9 +79,11 @@ type NPCCombatProfile struct { } type NPCLoot struct { - Template uint32 `yaml:"template"` - Quality [2]uint32 `yaml:"quality,flow"` - Chance uint32 `yaml:"chance"` + Template uint32 `yaml:"template"` + Quality [2]uint32 `yaml:"quality,flow"` + Chance uint32 `yaml:"chance"` + Evidence string `yaml:"evidence"` + Inference string `yaml:"inference"` } type NPCPlayfield struct { diff --git a/server/item_pages.go b/server/item_pages.go @@ -152,16 +152,18 @@ func (server *server) itemCatalogPage(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "<option value='%s'%s>%s</option>", option.value, selected, option.label) } fmt.Fprint(w, "</select></label> <button>Filter</button> <a href='admin/items/catalog'>Clear filter</a></form>") + fmt.Fprint(w, "<p>Loot chances are per independent roll at the sources listed on each item page. They apply to the offered QLs, not every QL in the family. No configured drop means no current server rule; it does not establish historical loot eligibility.</p>") var entries []adminTableRow for _, definition := range matches { summary := itemSourceSummary(sources[itemFamily(definition.ID)]) + chances, basis := itemLootSummary(sources[itemFamily(definition.ID)]) entries = append(entries, adminTableRow{ - values: []string{"", adminName(definition.Name), fmt.Sprint(definition.ID), fmt.Sprint(*definition.Quality), summary, ""}, - markup: fmt.Sprintf("<tr><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td><button name='template' value='%d'>Create</button></td></tr>", itemIcon(definition), catalogItemLink(definition.ID), definition.ID, *definition.Quality, html.EscapeString(summary), definition.ID), + values: []string{"", adminName(definition.Name), fmt.Sprint(definition.ID), fmt.Sprint(*definition.Quality), summary, chances, basis, ""}, + markup: fmt.Sprintf("<tr><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td><button name='template' value='%d'>Create</button></td></tr>", itemIcon(definition), catalogItemLink(definition.ID), definition.ID, *definition.Quality, html.EscapeString(summary), html.EscapeString(chances), html.EscapeString(basis), definition.ID), }) } fmt.Fprint(w, "<form method='post' action='admin/items'>") - adminTable(w, r, []string{"Icon", "Name", "Template", "QL", "Sources (family)", "Actions"}, entries) + adminTable(w, r, []string{"Icon", "Name", "Template", "QL", "Sources (family)", "Loot chances / roll", "Loot basis", "Actions"}, entries) fmt.Fprint(w, "</form></main></body></html>") } diff --git a/server/item_source_pages.go b/server/item_source_pages.go @@ -81,6 +81,12 @@ func (server *server) itemTemplatePage(w http.ResponseWriter, r *http.Request) { } if source.kind == "Loot" { fmt.Fprintf(w, "<tr><th scope='row'>Chance per roll</th><td>%d%%</td></tr><tr><th scope='row'>NPC levels</th><td>%d-%d</td></tr>", source.chance, source.level[0], source.level[1]) + if source.evidence != "" { + fmt.Fprintf(w, "<tr><th scope='row'>Evidence</th><td>%s</td></tr>", html.EscapeString(source.evidence)) + } + if source.inference != "" { + fmt.Fprintf(w, "<tr><th scope='row'>Inferred</th><td>%s</td></tr>", html.EscapeString(source.inference)) + } } if source.shop != 0 { fmt.Fprintf(w, "<tr><th scope='row'>Access</th><td>%s</td></tr>", html.EscapeString(shopAccess(gamedata.ItemTemplates[source.shop]))) diff --git a/server/item_sources.go b/server/item_sources.go @@ -17,6 +17,8 @@ type itemSource struct { ingredients [2]uint32 quality [2]uint32 chance uint32 + evidence string + inference string level [2]uint16 locations []itemSourceLocation } @@ -69,7 +71,11 @@ func (server *server) itemSources() map[uint32][]itemSource { } } // Use only profiles admitted for this group at levels it can actually spawn at. - drops := make(map[[2]uint32]itemSource) + type dropKey struct { + family, chance uint32 + evidence, inference string + } + drops := make(map[dropKey]itemSource) for _, level := range slices.Sorted(maps.Keys(gamedata.NPCCombatProfiles[group.MonsterData])) { profile := gamedata.NPCCombatProfiles[group.MonsterData][level] if level < group.Levels[0] || level > group.Levels[1] || !group.SupportsCombatProfile(group.MonsterData, profile) { @@ -81,10 +87,10 @@ func (server *server) itemSources() map[uint32][]itemSource { } family := itemFamily(drop.Template) // Keep distinct probabilities separate rather than inventing an aggregate drop rate. - key := [2]uint32{family, drop.Chance} + key := dropKey{family, drop.Chance, drop.Evidence, drop.Inference} source, exists := drops[key] if !exists { - source = itemSource{kind: "Loot", name: group.Name + " (" + id + ")", quality: drop.Quality, chance: drop.Chance, level: [2]uint16{level, level}} + source = itemSource{kind: "Loot", name: group.Name + " (" + id + ")", quality: drop.Quality, chance: drop.Chance, evidence: drop.Evidence, inference: drop.Inference, level: [2]uint16{level, level}} for _, position := range group.Positions { source.locations = append(source.locations, itemSourceLocation{group.Name, npcSourcePlayfield(id), position}) } @@ -97,14 +103,11 @@ func (server *server) itemSources() map[uint32][]itemSource { } } keys := slices.Collect(maps.Keys(drops)) - slices.SortFunc(keys, func(a, b [2]uint32) int { - if a[0] != b[0] { - return cmp.Compare(a[0], b[0]) - } - return cmp.Compare(a[1], b[1]) + slices.SortFunc(keys, func(a, b dropKey) int { + return cmp.Or(cmp.Compare(a.family, b.family), cmp.Compare(a.chance, b.chance), cmp.Compare(a.evidence, b.evidence), cmp.Compare(a.inference, b.inference)) }) for _, key := range keys { - sources[key[0]] = append(sources[key[0]], drops[key]) + sources[key.family] = append(sources[key.family], drops[key]) } if group.StaticMesh != 0 && len(group.Positions) > 0 { template := gamedata.NPCNames.Templates[group.TemplateCode].ItemTemplate @@ -222,3 +225,29 @@ func itemSourceSummary(sources []itemSource) string { } return strings.Join(parts, "; ") } + +func itemLootSummary(sources []itemSource) (string, string) { + chances := make(map[uint32]bool) + basis := make(map[string]bool) + for _, source := range sources { + if source.kind != "Loot" { + continue + } + chances[source.chance] = true + if source.inference != "" { + basis["Inferred"] = true + } else if source.evidence != "" { + basis["Evidence recorded"] = true + } else { + basis["Unspecified"] = true + } + } + if len(chances) == 0 { + return "No configured drop", "" + } + var rates []string + for _, chance := range slices.Sorted(maps.Keys(chances)) { + rates = append(rates, fmt.Sprintf("%d%%", chance)) + } + return strings.Join(rates, ", "), strings.Join(slices.Sorted(maps.Keys(basis)), ", ") +} diff --git a/server/kill_experience_test.go b/server/kill_experience_test.go @@ -30,7 +30,10 @@ func newKillExperienceWorld(t *testing.T, attack string) (*server, *combatTestCo 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] + // Keep transaction fixtures to one drop; production tables have separate coverage. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} + target.combatProfile = &profile if err := world.saveUser(player); err != nil { t.Fatal(err) } diff --git a/server/npc_levels_test.go b/server/npc_levels_test.go @@ -103,7 +103,13 @@ func TestNPCLevelTwoDeathRetainsProductionRewardsAcrossColdPickup(t *testing.T) world, _ := newKillExperienceWorld(t, "unarmed") target := world.characters[1000000] target.level, target.combatProfile = 2, gamedata.NPCCombatProfiles[17655][2] - world.combatRoll = func(uint32) uint32 { return 0 } + // Select Monster Parts without the independent equipment drop. + world.combatRoll = func(limit uint32) uint32 { + if limit == 100 { + return 10 + } + return 0 + } if err := world.flushWorld(); err != nil { t.Fatal(err) } diff --git a/server/npc_loot_range_test.go b/server/npc_loot_range_test.go @@ -43,11 +43,11 @@ func TestProductionLootQualityRangeBoundaries(t *testing.T) { quality uint32 lastBounds []uint32 }{ - {1, 0, false, 1, []uint32{5, 100}}, - {2, 0, false, 1, []uint32{5, 100, 3}}, - {2, 1, false, 2, []uint32{5, 100, 3}}, - {2, 2, false, 3, []uint32{5, 100, 3}}, - {2, 2, true, 0, []uint32{5, 100}}, + {1, 0, false, 1, []uint32{5, 100, 100}}, + {2, 0, false, 1, []uint32{5, 100, 3, 100, 3}}, + {2, 1, false, 2, []uint32{5, 100, 3, 100, 3}}, + {2, 2, false, 3, []uint32{5, 100, 3, 100, 3}}, + {2, 2, true, 0, []uint32{5, 100, 100}}, } { t.Run(fmt.Sprintf("%d/%d/empty=%t", scenario.level, scenario.qualityRoll, scenario.empty), func(t *testing.T) { world, _ := newKillExperienceWorld(t, "unarmed") @@ -82,7 +82,7 @@ func TestProductionLootQualityRangeBoundaries(t *testing.T) { if len(corpse.items) != 0 || current.nextItem != identity-1 { t.Fatal("empty roll allocated an item") } - } else if !slices.Equal(corpse.items, []ownedItem{{ID: identity, Type: 51005, Template: 42640, Quality: scenario.quality, Count: 1}}) || current.nextItem != identity { + } else if !slices.Equal(corpse.items, []ownedItem{{ID: identity, Type: 51005, Template: 42640, Quality: scenario.quality, Count: 1}, {ID: identity + 1, Type: 51022, Template: 70562, Quality: scenario.quality, Slot: 1, Count: 1}}) || current.nextItem != identity+1 { t.Fatal("quality range did not persist its selected instance", corpse.items) } } diff --git a/server/npc_loot_sources_test.go b/server/npc_loot_sources_test.go @@ -0,0 +1,110 @@ +package main + +import ( + "ao/server/gamedata" + "encoding/binary" + "fmt" + "net/http/httptest" + "slices" + "strings" + "testing" +) + +func TestProductionLootExpansionRollsAndPersists(t *testing.T) { + for _, scenario := range []struct { + group string + level uint16 + roll uint32 + templates []uint32 + }{ + {"950/district/2/group/0/authored_point", 1, 9, []uint32{42640, 70562}}, + {"950/district/2/group/0/authored_point", 1, 10, []uint32{42640}}, + {"950/district/6/fixed/0", 4, 4, []uint32{85596, 123742, 136642, 136646}}, + {"950/district/6/fixed/0", 4, 5, []uint32{85596, 123742}}, + {"952/district/5/fixed/0", 4, 4, []uint32{85596, 123742, 136626, 136628}}, + {"952/district/5/fixed/0", 4, 5, []uint32{85596, 123742}}, + {"954/district/5/fixed/0", 4, 4, []uint32{85596, 123742, 136610, 136618}}, + {"954/district/5/fixed/0", 4, 5, []uint32{85596, 123742}}, + } { + t.Run(fmt.Sprintf("%s/%d", scenario.group, scenario.roll), func(t *testing.T) { + world, _ := newKillExperienceWorld(t, "unarmed") + group := gamedata.NPCGroups[scenario.group] + target := world.characters[1000000] + target.npcDefinitionID, target.monsterData, target.level = scenario.group, group.MonsterData, scenario.level + target.combatProfile = gamedata.NPCCombatProfiles[group.MonsterData][scenario.level] + world.combatRoll = func(limit uint32) uint32 { + if limit == 100 { + return scenario.roll + } + return 0 + } + before := world.nextItem + + attackForExperience(t, world, "unarmed") + cold := newTestInventoryServer(t) + + for _, current := range []*server{world, cold} { + corpse := current.characters[1000000].corpse + if corpse == nil || len(corpse.items) != len(scenario.templates) || current.nextItem != before+uint32(len(scenario.templates)) { + t.Fatal("production drop boundary or durable allocation failed", corpse) + } + for index, template := range scenario.templates { + item := corpse.items[index] + if item.Template != template || item.Type != gamedata.ItemTemplates[template].HeaderWords[0] || item.Quality != target.combatProfile.Loot[index].Quality[0] || current.itemPlacements[item.ID] != (itemPlacement{Corpse: target.id, Slot: uint32(index)}) { + t.Fatal("production loot changed type, quality or ownership", item) + } + } + } + + // Collect every selected item through the normal corpse transfer path. + if err := world.handleLootUse(world.clients[1], lootUseRequest(1)); err != nil { + t.Fatal(err) + } + for slot := range scenario.templates { + request := lootTakeRequest() + binary.BigEndian.PutUint32(request[20:24], uint32(slot)) + if err := world.handleInventory(world.clients[1], request); err != nil { + t.Fatal(err) + } + } + cold = newTestInventoryServer(t) + if len(cold.characters[1000000].corpse.items) != 0 || len(cold.characters[1].inventory.Items) != len(scenario.templates) || !slices.Equal(world.characters[1].inventory.Items, cold.characters[1].inventory.Items) { + t.Fatal("production loot pickup did not survive restart") + } + }) + } +} + +func TestItemCatalogShowsLootChanceAndEvidence(t *testing.T) { + world := newTestServer(t) + handler := adminTestHandler(world) + for _, scenario := range []struct{ template, chance, evidence string }{ + {"70562", "10%", "1 of 8 level-1 Beach Leets"}, + {"136627", "5%", "Ruby on Writhetongue"}, + {"136629", "5%", "Ember on Writhetongue"}, + {"136643", "5%", "Golden Sphere on Burneye"}, + {"136647", "5%", "Pearl of Rubi-Ka on Burneye"}, + {"136611", "5%", "Snake Ring on Burneye"}, + {"136619", "5%", "Bracelet of Ka on Writhetongue"}, + } { + t.Run(scenario.template, func(t *testing.T) { + listing, detail := httptest.NewRecorder(), httptest.NewRecorder() + handler.ServeHTTP(listing, httptest.NewRequest("GET", "/admin/items/catalog?source=loot&catalog="+scenario.template, nil)) + handler.ServeHTTP(detail, httptest.NewRequest("GET", "/admin/items/catalog/"+scenario.template, nil)) + + for _, expected := range []string{"value='" + scenario.template + "'>Create", "<td>" + scenario.chance + "</td>", "<td>Inferred</td>"} { + if listing.Code != 200 || !strings.Contains(listing.Body.String(), expected) { + t.Fatal("catalog omitted loot availability, configured chance or inferred basis", expected) + } + } + for _, expected := range []string{scenario.chance, "AORebirth", scenario.evidence, "inferred", "admin/map?playfield="} { + if detail.Code != 200 || !strings.Contains(detail.Body.String(), expected) { + t.Fatal("item details omitted evidence, inference or map link", expected) + } + } + if strings.Contains(detail.Body.String(), "<div data-world-map") { + t.Fatal("item details reintroduced the duplicate map") + } + }) + } +} diff --git a/server/npc_loot_test.go b/server/npc_loot_test.go @@ -261,10 +261,10 @@ func TestNPCLootRespawnAndCheckpointDoNotRegenerateOldRewards(t *testing.T) { attackForExperience(t, world, "unarmed") before := world.nextItem deadline := world.npcRespawns[0].at - if len(world.characters[1000000].corpse.items) != 1 { + if len(world.characters[1000000].corpse.items) != 2 { t.Fatal("the first life did not generate its loot") } - item := world.characters[1000000].corpse.items[0] + items := slices.Clone(world.characters[1000000].corpse.items) world.advanceNPCRespawns(deadline) if err := world.checkpointWorld(deadline); err != nil { @@ -272,7 +272,7 @@ func TestNPCLootRespawnAndCheckpointDoNotRegenerateOldRewards(t *testing.T) { } cold := newTestInventoryServer(t) - if cold.characters[1000001] == nil || cold.characters[1000001].corpse != nil || cold.characters[1000000].corpse.credits != 1 || !slices.Equal(cold.characters[1000000].corpse.items, []ownedItem{item}) || world.nextItem != before || cold.nextItem != before { + if cold.characters[1000001] == nil || cold.characters[1000001].corpse != nil || cold.characters[1000000].corpse.credits != 1 || !slices.Equal(cold.characters[1000000].corpse.items, items) || world.nextItem != before || cold.nextItem != before { t.Fatal("respawn/checkpoint regenerated or lost the prior life's loot") } } diff --git a/server/npc_profile_evidence_test.go b/server/npc_profile_evidence_test.go @@ -75,7 +75,7 @@ func TestNPCPlaceholderDeathDoesNotGenerateLeetRewards(t *testing.T) { 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 { + if current.characters[player.id].experience != 100 || current.nextItem != 2 || len(npc.corpse.items) != 2 || npc.corpse.items[0].Template != 42640 || npc.corpse.items[1].Template != 70562 || 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() { diff --git a/server/omni_training_boss_test.go b/server/omni_training_boss_test.go @@ -89,7 +89,10 @@ func newOmniTrainingBossKillWorld(t *testing.T, attack string) *server { world, _ := newKillExperienceWorld(t, attack) target := world.characters[1000000] target.monsterData, target.level, target.npcDefinitionID = 30369, 4, "950/district/6/fixed/0" - target.combatProfile = gamedata.NPCCombatProfiles[30369][4] + // Isolate equipment quality/transaction scenarios from additional sale-only drops. + profile := *gamedata.NPCCombatProfiles[30369][4] + profile.Loot = slices.Clone(profile.Loot[:2]) + target.combatProfile = &profile if err := world.flushWorld(); err != nil { t.Fatal(err) } diff --git a/server/starter_boss_test.go b/server/starter_boss_test.go @@ -20,10 +20,14 @@ func TestStarterBossAuthoredSpawnHasUsefulSelectedQualityLoot(t *testing.T) { if spawn.npcDefinitionID != "952/district/5/fixed/0" { continue } + loot := slices.Clone(spawn.combatProfile.Loot) + for index := range loot { + loot[index].Evidence, loot[index].Inference = "", "" + } if spawn.monsterData != 30354 || spawn.level != 4 || spawn.position != [3]float32{186.06424, 13.7, 182.79846} || spawn.combatProfile == nil || spawn.combatProfile.Health != 20 || spawn.combatProfile.Experience != 100 || spawn.combatProfile.Weapon != [2]uint32{121063, 121064} || - !reflect.DeepEqual(spawn.combatProfile.Loot, []gamedata.NPCLoot{{Template: 85596, Quality: [2]uint32{4, 4}, Chance: 50}, {Template: 123742, Quality: [2]uint32{4, 4}, Chance: 25}}) { + !reflect.DeepEqual(loot, []gamedata.NPCLoot{{Template: 85596, Quality: [2]uint32{4, 4}, Chance: 50}, {Template: 123742, Quality: [2]uint32{4, 4}, Chance: 25}, {Template: 136626, Quality: [2]uint32{4, 4}, Chance: 5}, {Template: 136628, Quality: [2]uint32{4, 4}, Chance: 5}}) { t.Fatal("authored starter boss has no isolated, level-appropriate equipment profile", spawn.combatProfile) } return @@ -37,7 +41,10 @@ func newStarterBossKillWorld(t *testing.T, attack string) (*server, *combatTestC target := world.characters[1000000] target.monsterData, target.level, target.playfield = 30354, 4, 952 target.npcDefinitionID = "952/district/5/fixed/0" - target.combatProfile = gamedata.NPCCombatProfiles[30354][4] + // Isolate equipment transfer/failure scenarios from additional sale-only drops. + profile := *gamedata.NPCCombatProfiles[30354][4] + profile.Loot = slices.Clone(profile.Loot[:2]) + target.combatProfile = &profile world.characters[1].playfield = 952 if err := world.saveUser(world.characters[1]); err != nil { t.Fatal(err) @@ -51,7 +58,7 @@ func newStarterBossKillWorld(t *testing.T, attack string) (*server, *combatTestC return world, conn } -func TestStarterBossProductionLootAcrossKillingActions(t *testing.T) { +func TestStarterBossEquipmentAcrossKillingActions(t *testing.T) { for _, attack := range []string{"unarmed", "axe", "pistol", "fling", "fast", "nano"} { t.Run(attack, func(t *testing.T) { world, _ := newStarterBossKillWorld(t, attack) @@ -190,7 +197,7 @@ func TestStarterBossCodeRecheckedOnColdLoadAndReplacement(t *testing.T) { } for _, current := range []*server{cold, respawned} { - if len(current.characters[1000000].corpse.items) != 2 || current.characters[player.id].experience != 100 || current.nextItem != 2 || + if len(current.characters[1000000].corpse.items) != 4 || current.characters[player.id].experience != 100 || current.nextItem != 4 || (current.characters[1000000].combatProfile != nil) == changed || (current.characters[1000001].combatProfile != nil) == changed || current.characters[1000001].health != health { t.Fatal("code change leaked a boss profile or erased already committed rewards") } diff --git a/tools/client/test_item_sources.mjs b/tools/client/test_item_sources.mjs @@ -13,6 +13,19 @@ try { if (/admin\/map-(players|entities)/.test(request.url())) liveFeeds.push(request.url()); }); + // The catalog exposes configured odds and the distinction between observations and inference. + await page.goto(url + 'admin/items/catalog?source=loot&catalog=136627'); + const ruby = page.locator('tr').filter({has: page.locator("button[value='136627']")}); + assert.match(await ruby.textContent(), /Loot: 1.*5%.*Inferred/); + await ruby.locator("a[href='admin/items/catalog/136627']").click(); + assert.match(await page.locator('main').textContent(), /AORebirth.*Ruby on Writhetongue/); + assert.equal(await page.locator('[data-world-map]').count(), 0); + const nestedScrollers = await page.locator('main *').evaluateAll(elements => elements.filter(element => { + const style = getComputedStyle(element); + return /(auto|scroll)/.test(style.overflowY) && element.scrollHeight > element.clientHeight; + }).length); + assert.equal(nestedScrollers, 0, 'item detail must use ordinary page scrolling'); + for (const path of ['admin/items/catalog/95577', 'admin/shops/99491']) { await page.goto(url + path); if (path === 'admin/items/catalog/95577') {