commit 1dd0204602cd72e36ba485b31c06f3a29f030deb
parent 5ff3f06bf33acb9bcb13601012d0bdee9266c38e
Author: anon <anon@example.com>
Date: Wed, 28 Oct 2026 22:54:07 +0000
Add bounded early NPC progression profiles
Diffstat:
14 files changed, 502 insertions(+), 34 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -640,16 +640,28 @@ for exact records, protocol, tests and remaining reconstruction assumptions.
provisional values at each level. Two native clients verified both fights,
rewards, item pickup and cold reconstruction; automation covers both levels.
See [NPC combat balance](docs/combat-npc-balance.md).
-- [ ] [P0] Expand admitted early mission combat profiles beyond levels 1 and 2.
- New contracts now select levels before charging and reject an unsupported
- level-3 encounter without a fee. Add reviewed resources, attacks, defenses,
- XP and useful loot for the next progression levels, keeping balance explicitly
- provisional where historical measurements are missing. Prefer shared growth
- rules supported by evidence over a separate bespoke profile for every level.
- Include raw attack/evade skills and all-off/all-def foundations; the current
- five-point NPC skill default does not establish level growth.
- Verify ordinary earned equipment, healing costs, mission completion and the next
- level without admin grants. Preserve authored outdoor level ranges.
+- [x] [P0] Expand admitted early mission combat through levels 3..5. Shared
+ level-anchor interpolation resolves HP, XP, raw skills, modifiers and nearby
+ loot QLs without extrapolating. Original Leet Bite fields use actor QL;
+ HP/XP/skill growth and loot balance remain explicitly provisional. Template
+ weights and existing armor/all-off/all-def consumers use the same foundations.
+ Authored outdoor levels and unresolved identity boundaries remain intact.
+ An ordinary earned Enforcer defeated five full-health level-3 enemies, reached
+ level 3, trained skills, wore its QL3 reward, and defeated full-health level-4
+ and level-5 enemies. Three native Find Item returns retained QL3/4/5 rewards,
+ used nine lab charges and preserved all other owned items across page and cold
+ restart. The seven owner-health audits reconcile damage and observed recovery.
+ All 16,418 Go results, 64 focused race results and vet pass. See
+ [NPC balance and evidence limits](docs/combat-npc-balance.md).
+- [ ] [P0] Extend reviewed progression beyond enemy level 5 and to additional
+ early enemy families. Admit resources, attacks, defenses, XP and useful loot
+ through shared data rules, retaining evidence and explicit provisional balance
+ where historical measurements are missing. Do not infer universal health/XP
+ curves from the starter placeholders or silently extrapolate an anchored range.
+ Verify normal training, earned equipment, recovery costs, mission completion
+ and further player levels without admin grants. Preserve authored outdoor
+ ranges; enemies outside the admitted range still reject mission generation
+ before fees. Original NPC growth and damage-rating scaling remain unresolved.
- [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
diff --git a/docs/combat-npc-balance.md b/docs/combat-npc-balance.md
@@ -2,9 +2,154 @@
The local wiki database provides useful weapon and behavior leads, but it does
not supply a complete set of historical creature health, ratings and armor.
-The server has explicit level-1 and level-2 Leet profiles below. Other creatures retain
+The server admits Leet levels 1..5 through the bounded profiles below. Unprofiled creatures retain
prototype 100 HP, 5 damage and one-second attack/recharge phases.
+## Bounded early progression
+
+`npc_combat.yaml` contains level anchors, not an unlimited species formula.
+The loader resolves intervening levels using signed integer linear interpolation
+of health, XP, raw skills, modifiers and loot QL endpoints. It never extrapolates.
+Weapons, initiative, AggDef, lifecycle settings, cash ranges and loot identities
+and chances must agree across a gap; mismatched anchors fail loading rather than
+silently choosing an unrelated encounter. Every resolved level passes the same
+catalog, weapon QL, loot and population-scope validation as an explicit anchor.
+
+| Leet level | HP / solo XP | Raw MA / Duck / Dodge / Evade Close / Nano Resist | Monster Parts QL |
+| --- | --- | --- | --- |
+| 1 | 100 / 100 | 5 | 1 |
+| 2 | 100 / 100 | 5 | 1..3 |
+| 3 | 125 / 125 | 10 | 2..4 |
+| 4 | 150 / 150 | 15 | 3..5 |
+| 5 | 175 / 175 | 20 | 4..6 |
+
+All numbers in this table are **provisional gameplay balance**. Levels 1 and 2
+retain their independently tested baseline. From level 2, each next level adds
+25 HP/XP and five raw skill points. Levels 3 and 5 are explicit anchors; level 4
+is resolved by the shared interpolation. This bounded choice unlocks the next
+ordinary missions without claiming that the original server used these slopes.
+Cash remains 1..5 and the Monster Parts chance remains 50%, also provisional.
+Mission reward equipment uses its independently selected mission QL; no new
+unverified equipment loot table is inferred for Leets.
+
+Raw profile skills supply the NPC foundation when no explicit actor stats are
+stored. Original native weapon-rating mode 2 reads these raw skills without
+player ability trickle or direct skill buffs. The existing conditional
+AddAllOff276/AddAllDef277 path then adds profile modifiers, equipment and nanos.
+Profile armor foundations use the existing AC consumers. This Leet range has
+zero authored armor/all-off/all-def modifiers; those values are not inferred
+from level. The [hit probability curve](weapon-hit-chance.md) and NPC damage
+rating scaling remain separate evidence gaps. Native actor QL still selects the
+original Leet Bite weapon's damage, critical bonus and timing fields.
+
+The original outdoor population levels, positions and identity evidence are
+unchanged. Species eligibility still applies before profile lookup; unresolved
+NPCs using a Leet stand-in do not gain these profiles. Level 6 and above remain
+unsupported for generated Leet encounters, with admission checked before fees.
+The Clan Training salamander boss retains its independent template-scoped QL4
+profile and does not inherit Leet growth.
+
+### Additional source check
+
+The bounded source review in `local/early-npc-growth/` includes CellAO at commit
+`ca77f375a7dabe3be769da94e6c2a3d093344c2c`. Its
+[mobtemplate.sql](https://github.com/CellAO/CellAO-NightPredator/blob/ca77f375a7dabe3be769da94e6c2a3d093344c2c/CellAO/Libraries/Source/CellAO.Database/SqlTables/mobtemplate.sql)
+stores fixed Health values for named templates: Eleet 38 at range 1..2,
+Leetas 92 at 4..5, Soleet 146 at 7..8, and Beach Leet 12 at level 1.
+These are later emulator seed records, not 14.9.1 server measurements. Their
+different names and ranges do not establish a shared ordinary-Leet HP curve.
+`NonPlayerCharacterHandler.CreateMob` assigns template Health, while its generic
+`StatLife` also implements player-style breed/profession coefficients. Neither
+path establishes historical NPC skill, HP, XP or armor growth. Those coefficients
+and seed health values are not used as the new progression formula.
+
+The local wiki search below, the original weapon endpoints and the existing
+native rating/getter evidence likewise do not establish those missing curves.
+Historical measurements should replace the provisional anchors when available.
+
+The NPC-mapping handoff also retains AORebirth's later capture-backed combat
+inventory at revision `758a712201472a2481af4b4e7c88cea20427c6a1`. Its metadata
+preserves names, levels and MonsterData, while the included packet table covers
+weapon setup, attacks and attack results rather than maximum-health snapshots.
+It includes 2026 Arete sessions and explicit `Codex Test` actors; its capture
+certification does not establish an ordinary 14.9.1 Leet resource/skill curve.
+The bounded review and selected metadata are in
+`local/early-npc-growth/capture-inventory-summary.txt` and
+`later-leet-capture-projections.json`. Raw source-session review remains a lead.
+
+### Earned progression verification
+
+The retained ordinary Atrox Enforcer entered a difficulty-11 contract at level 2,
+with 2,150 / 2,600 XP, 104 credits and its previously earned QL2 bat. Five unmodified
+level-3 Leets each awarded 125 XP. The fourth kill advanced it to level 3, carrying
+50 XP and granting 4,000 IP; the fifth left 175 XP. Native skill training spent
+208 earned IP. The run used eight QL1 laboratory charges to recover between
+fights; some top-ups restored only a few HP, so this is observed consumption,
+not a minimum healing cost. The two offer requests cost four credits total.
+
+The actual book pickup and hand-in consumed only that contract's key/book,
+awarded 20 credits and created bat87 at QL3. Native requirements rejected an
+initial equip attempt: Sneak Attack/Fast Attack needed 11 and Brawling 12.
+Training those requirements cost 266 more earned IP. Removing bat72 to inventory
+then equipping bat87 retained both identities; a page reconnect reconstructed
+the worn QL3 upgrade and stored QL2 bat. No character stats, gear, HP, XP, cash,
+positions, drop rolls or encounter outcomes were granted through admin edits.
+
+All five settled native owner HP results match received damage plus observed
+four-point Atrox recovery: 34, 52, 16, 36 and 47. Actual damage totals were 57,
+43, 75, 55 and 39, with recovery in the second and fifth cases. The last fight
+started at 82 HP after a deliberate recovery threshold. The enemies received
+125, 125, 128, 128 and 128, including three combat recovery ticks. Each actual
+death packet arrived by its first sampled native zero-HP state. This run does not
+reproduce or resolve the earlier independent NPC recovery-phase gap.
+
+Periodically checkpointed SQLite HP is not a live combat measurement. The
+native samples, complete result stream and settled queues are the health
+evidence; snapshots taken mid-fight can lag. Artifacts are retained under
+`local/early-npc-growth/native/`, including `first-five-fight-audit.json`.
+
+The next difficulty-10 offer selected level 4. Native construction showed 150 HP,
+QL4, 4..11 base damage, critical bonus 5 and the original 175 cs phases. The same
+ordinary character defeated one full-health encounter with bat87, earned 150 XP
+and collected one corpse credit. That roll had no item. Fetching the book past
+the other nonaggressive Leets completed this Find Item contract and awarded
+20 credits plus bat90 at QL4. It did not require clearing every encounter.
+
+Before the difficulty-11 level-5 contract, another 145 earned IP raised raw Body
+Development to 20 and raw 1HB to 20. Maximum HP became 138. The final laboratory
+charge and ordinary seated recovery restored full HP; no replacement supplies
+were granted. The full-health level-5 enemy had 175 HP and awarded 175 XP.
+Bat87 remained the QL3 weapon throughout this harder fight. Settled live health
+was 25, with level-3 XP now 500. Its corpse transferred one credit and again
+contained no item. Automated ranged-loot tests separately cover selected QL
+boundaries, cold pickup and sale; these empty native rolls are not item-pickup
+evidence. The harder trial establishes this prepared Enforcer path, not balanced
+progression for every profession, build or enemy family.
+
+The last return consumed book92/key91 and awarded bat93 at QL5 plus 20 credits.
+After ordinary recovery, page closure and a real cold server restart, native and
+SQLite checks retained level 3, cumulative XP 4,550 (500 within level), 8,309 IP,
+138 HP, 26 nano, 156 credits and all 17 owned items. Bat87 remained worn; bats72,
+90 and 93 remained stored. Only the nine deliberately consumed laboratory charges
+were removed from the original owned set. Live and cold native containers both
+have one row per item, including during the QL2-to-QL3 weapon upgrade. No pending
+hit results survived cold loading; the documented holder state was 1 (idle).
+
+Original weapon interpolation also produced the QL5 minimum of 5: native base
+damage/critical bonus was 4..10/+4 at QL3, 4..11/+5 at QL4 and 5..12/+5 at QL5.
+The two higher encounters received 153 and 178 damage including one combat
+recovery tick each. Their settled owner HP was 22 and 25; the latter also matched
+the live control-panel value. All 950 newly earned XP came from kills. The
+advertised conditional mission-completion XP and the earlier NPC recovery-phase
+gap remain open; these checks do not claim those separate issues are resolved.
+
+The clean maintained Go suite passed 1,670 roots / 16,418 results, with no skips.
+The focused race run passed 9 / 64, and final vet passed. The first broad run's
+old two-level admission and boss-isolation expectations were updated to cover
+the level-5/6 boundary and independent Leet/boss profiles before that clean run.
+`local/early-npc-growth/native/native-verified.json` retains the completed native
+audit. Every owned test browser closed; one preview retains all default ports.
+
## Local wiki search
Read-only source: `~/tmp/fandom-scraper/anarchyonline.db`, 879 pages,
@@ -69,7 +214,7 @@ outside their QL range, zero health, and AggDef outside -100..100.
| Maximum health | 100 at each level | Provisional prototype value retained independently; no health scaling formula inferred |
| Solo XP reward | 100 at each level | Provisional; the atomic [XP path](kill-experience.md) does not establish original reward size or eligibility |
| Weapon | LeetBite1 endpoints 120910 / 120911, QL 1 or 2 | Shipped endpoints and native actor-level construction verified; binding and choice of variant provisional |
-| Normal damage endpoints | Level 1: 4-8; level 2: 4-9 | Level 2 uses the shared recovered item interpolation; uniform always-hit roll and omitted actor rating remain local |
+| Normal damage endpoints | Level 1: 4-8; level 2: 4-9 | Shared recovered item interpolation; ordinary accuracy uses template weights and the provisional probability curve, while NPC damage rating scaling remains unresolved |
| Critical damage before AC | Level 1: 12; level 2: 13 | Interpolated maximum plus bonus4; [critical chance and AC policy](critical-hits.md) are provisional |
| Initiative | 0 | Provisional actor value |
| AggDef | 75 | Provisional actor value |
@@ -87,7 +232,7 @@ remain gaps in canonical balance; the profile does not make those values
historically verified.
The level-2 profile is a separate explicit record, with the same selected
-initiative, AggDef, lifecycle and provisional fixed-QL1 loot policy. Its weapon
+initiative, AggDef and lifecycle, with a provisional QL1..3 loot range. Its weapon
uses the original 1..400 endpoints at actor QL2. The server reuses
`interpolateItemValue` for weapon damage, range and delays, retaining categorical
fields from the nearer endpoint and leaving the shared catalog records unchanged.
diff --git a/server/armor_overequipping.go b/server/armor_overequipping.go
@@ -3,6 +3,10 @@ package main
import "ao/server/gamedata"
func (character *character) equipmentBonus(stat uint32) int32 {
+ // NPC foundations share the existing armor and all-off/all-def consumers.
+ if character.npc && character.combatProfile != nil {
+ return character.combatProfile.Modifiers[stat] + character.inventory.equipmentBonus(stat)
+ }
// FUN_100734e0's initialized table selects the bonuses affected by armor OE.
switch stat {
case 1, 90, 91, 92, 93, 94, 95, 96, 97, 118, 119, 120, 149, 168,
diff --git a/server/gamedata/load.go b/server/gamedata/load.go
@@ -235,10 +235,23 @@ func init() {
}
}
- // Combat profiles bind exact creature levels to catalog weapon endpoints.
+ // Expand bounded level anchors before validating every resolved combat profile.
loadYAML("npc_combat.yaml", &NPCCombatProfiles)
+ if err := interpolateNPCProfiles(NPCCombatProfiles); err != nil {
+ panic(err)
+ }
for monster, levels := range NPCCombatProfiles {
for level, profile := range levels {
+ for stat, value := range profile.Skills {
+ if _, known := IPTraining.Weights[stat]; !known || value < 0 || value > 65535 {
+ panic(fmt.Errorf("NPC combat profile %d/%d has invalid raw skill %d", monster, level, stat))
+ }
+ }
+ for stat, value := range profile.Modifiers {
+ if stat != 276 && stat != 277 && (stat < 90 || stat > 97 || value < 0) {
+ panic(fmt.Errorf("NPC combat profile %d/%d has unsupported modifier %d", monster, level, stat))
+ }
+ }
// Template-specific encounters must match an admitted original population.
if profile.TemplateCode != "" {
matched := false
diff --git a/server/gamedata/npc_combat.go b/server/gamedata/npc_combat.go
@@ -0,0 +1,65 @@
+package gamedata
+
+import (
+ "fmt"
+ "maps"
+ "slices"
+)
+
+// Expand only the bounded ranges between authored level anchors, never extrapolate.
+func interpolateNPCProfiles(profiles map[uint32]map[uint16]*NPCCombatProfile) error {
+ for monster, levels := range profiles {
+ anchors := slices.Sorted(maps.Keys(levels))
+ for index := 1; index < len(anchors); index++ {
+ low, high := anchors[index-1], anchors[index]
+ if high-low == 1 {
+ continue
+ }
+ first, second := levels[low], levels[high]
+ if first.TemplateCode != second.TemplateCode || 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) {
+ 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)
+ }
+ }
+
+ // Each resolved level owns its maps and loot; catalog anchors remain unchanged.
+ for level := low + 1; level < high; level++ {
+ interpolate := func(first, second int64) int64 {
+ return first + (second-first)*int64(level-low)/int64(high-low)
+ }
+ profile := *first
+ 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)
+ for _, pair := range []struct{ first, second, result map[uint32]int32 }{
+ {first.Skills, second.Skills, profile.Skills}, {first.Modifiers, second.Modifiers, profile.Modifiers},
+ } {
+ if len(pair.first) != len(pair.second) {
+ return fmt.Errorf("NPC combat anchors %d/%d..%d change stat membership", monster, low, high)
+ }
+ for stat, value := range pair.first {
+ upper, exists := pair.second[stat]
+ if !exists {
+ return fmt.Errorf("NPC combat anchors %d/%d..%d omit stat %d", monster, low, high, stat)
+ }
+ pair.result[stat] = int32(interpolate(int64(value), int64(upper)))
+ }
+ }
+ profile.Loot = slices.Clone(first.Loot)
+ for index := range profile.Loot {
+ for endpoint := range profile.Loot[index].Quality {
+ profile.Loot[index].Quality[endpoint] = uint32(interpolate(int64(first.Loot[index].Quality[endpoint]), int64(second.Loot[index].Quality[endpoint])))
+ }
+ }
+ levels[level] = &profile
+ }
+ }
+ }
+ return nil
+}
diff --git a/server/gamedata/npc_combat.yaml b/server/gamedata/npc_combat.yaml
@@ -1,10 +1,13 @@
-# Exact MonsterData and level; unlisted creatures retain prototype combat.
+# MonsterData and level anchors; intermediate levels interpolate within each species.
+# Values outside the anchored range retain prototype combat. See docs/combat-npc-balance.md.
17655:
- 1:
+ 1: &leet
# Provisional health; no historical level-1 Leet HP measurement recovered.
health: 100
# Provisional solo XP; no historical level-1 Leet reward measurement recovered.
experience: 100
+ # Provisional raw Martial Arts, evades and Nano Resist; no player trickle.
+ skills: {100: 5, 153: 5, 154: 5, 155: 5, 168: 5}
# Health recovery uses the checked native NPC branch; see docs/npc-regeneration.md.
# Shipped QL 1 LeetBite1_001. Choosing this variant for this spawn is provisional.
# Base damage 4..8 and attack/recharge 175 cs are verified item data.
@@ -27,6 +30,7 @@
# Retained prototype health and the same provisional solo reward, not a scaling formula.
health: 100
experience: 100
+ skills: {100: 5, 153: 5, 154: 5, 155: 5, 168: 5}
# Original LeetBite1 endpoints; the native constructor uses creature level as QL.
weapon: [120910, 120911]
# Actor initiative, AggDef and lifecycle values remain provisional as at level 1.
@@ -41,6 +45,27 @@
quality: [1, 3]
chance: 50
+ # Bounded provisional growth: +25 HP/XP and +5 raw skills per level from 2.
+ # This is a gameplay choice, not a recovered historical formula. Level 4 is interpolated.
+ 3:
+ <<: *leet
+ health: 125
+ experience: 125
+ skills: {100: 10, 153: 10, 154: 10, 155: 10, 168: 10}
+ loot:
+ - template: 42640
+ quality: [2, 4]
+ chance: 50
+ 5:
+ <<: *leet
+ health: 175
+ experience: 175
+ skills: {100: 20, 153: 20, 154: 20, 155: 20, 168: 20}
+ loot:
+ - template: 42640
+ quality: [4, 6]
+ chance: 50
+
30354:
4:
# The original Clan Training fixed boss; ordinary salamanders do not inherit it.
diff --git a/server/gamedata/npc_combat_test.go b/server/gamedata/npc_combat_test.go
@@ -0,0 +1,92 @@
+package gamedata
+
+import (
+ "maps"
+ "testing"
+)
+
+func TestNPCLevelAnchorsResolveBoundedIndependentProfiles(t *testing.T) {
+ first := &NPCCombatProfile{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},
+ 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}}
+
+ err := interpolateNPCProfiles(profiles)
+ profile := profiles[17655][4]
+
+ if err != nil || len(profiles[17655]) != 3 || profile == nil || profile.Health != 150 || profile.Experience != 150 ||
+ 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
+ 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} {
+ t.Fatal("resolved profile shares mutable data with an anchor")
+ }
+}
+
+func TestNPCLevelAnchorsRejectAmbiguousIntermediateIdentity(t *testing.T) {
+ for _, change := range []string{"template", "weapon", "initiative", "aggdef", "respawn", "corpse", "cash", "loot count", "loot template", "loot chance", "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}}}
+ second := *first
+ switch change {
+ case "template":
+ second.TemplateCode = "other"
+ case "weapon":
+ second.Weapon = [2]uint32{120910, 120911}
+ case "initiative":
+ second.Initiative = 1
+ case "aggdef":
+ second.AggDef = 1
+ case "respawn":
+ second.RespawnSeconds = 1
+ case "corpse":
+ second.CorpseSeconds = 1
+ case "cash":
+ second.Credits = [2]uint32{1, 5}
+ case "loot count":
+ second.Loot = nil
+ case "loot template":
+ 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 "skill count":
+ second.Skills = nil
+ case "skill identity":
+ second.Skills = map[uint32]int32{155: 5}
+ case "modifier identity":
+ second.Modifiers = map[uint32]int32{277: 5}
+ }
+ profiles := map[uint32]map[uint16]*NPCCombatProfile{17655: {3: first, 5: &second}}
+
+ err := interpolateNPCProfiles(profiles)
+
+ if err == nil || profiles[17655][4] != nil {
+ t.Fatal("ambiguous anchor acquired an intermediate combat profile", err)
+ }
+ })
+ }
+}
+
+func TestProductionNPCGrowthRetainsBaselineAndStopsAtReviewedBoundary(t *testing.T) {
+ expected := []struct{ health, skill, qualityLow, qualityHigh int32 }{
+ {100, 5, 1, 1}, {100, 5, 1, 3}, {125, 10, 2, 4}, {150, 15, 3, 5}, {175, 20, 4, 6},
+ }
+
+ profiles := NPCCombatProfiles[17655]
+
+ for index, want := range expected {
+ profile := profiles[uint16(index+1)]
+ if profile == nil || profile.Health != uint32(want.health) || profile.Experience != uint32(want.health) ||
+ !maps.Equal(profile.Skills, map[uint32]int32{100: want.skill, 153: want.skill, 154: want.skill, 155: want.skill, 168: want.skill}) ||
+ profile.Loot[0].Quality != [2]uint32{uint32(want.qualityLow), uint32(want.qualityHigh)} || profile.Weapon != [2]uint32{120910, 120911} {
+ t.Fatal("production profile changed the declared bounded growth", index+1, profile)
+ }
+ }
+ if len(profiles) != 5 || profiles[0] != nil || profiles[6] != nil || len(NPCCombatProfiles[30354]) != 1 || NPCCombatProfiles[30354][4].TemplateCode != "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
@@ -62,16 +62,18 @@ type NPCData struct {
}
type NPCCombatProfile struct {
- TemplateCode string `yaml:"template_code"`
- Health uint32 `yaml:"health"`
- Experience uint32 `yaml:"experience"`
- Weapon [2]uint32 `yaml:"weapon,flow"`
- Initiative int32 `yaml:"initiative"`
- AggDef int32 `yaml:"agg_def"`
- RespawnSeconds uint32 `yaml:"respawn_seconds"`
- CorpseSeconds uint32 `yaml:"corpse_seconds"`
- Credits [2]uint32 `yaml:"credits,flow"`
- Loot []NPCLoot `yaml:"loot"`
+ TemplateCode string `yaml:"template_code"`
+ Health uint32 `yaml:"health"`
+ Experience uint32 `yaml:"experience"`
+ Skills map[uint32]int32 `yaml:"skills"`
+ Modifiers map[uint32]int32 `yaml:"modifiers"`
+ Weapon [2]uint32 `yaml:"weapon,flow"`
+ Initiative int32 `yaml:"initiative"`
+ AggDef int32 `yaml:"agg_def"`
+ RespawnSeconds uint32 `yaml:"respawn_seconds"`
+ CorpseSeconds uint32 `yaml:"corpse_seconds"`
+ Credits [2]uint32 `yaml:"credits,flow"`
+ Loot []NPCLoot `yaml:"loot"`
}
type NPCLoot struct {
diff --git a/server/mission_encounters_test.go b/server/mission_encounters_test.go
@@ -77,7 +77,7 @@ func TestMissionEncounterInvalidSelectionCannotConsumeOfferOrKey(t *testing.T) {
case "unknown definition":
definition.Encounters[0].Definition = "missing"
case "unsupported level":
- definition.Encounters[0].Level = 3
+ definition.Encounters[0].Level = 6
case "empty positions":
definition.Encounters[0].Positions = nil
case "outside":
diff --git a/server/mission_levels_test.go b/server/mission_levels_test.go
@@ -130,7 +130,7 @@ func TestMissionUnsupportedEncounterLevelDoesNotChargeOrAllocate(t *testing.T) {
world, output := newMissionOfferWorld(t)
t.Cleanup(func() { world.db.Close() })
player := world.characters[1]
- player.level = 2
+ player.level = 4
definition := gamedata.MissionTemplates[3221228472]
definition.RewardItems = []uint32{122691}
definition.Encounters = []gamedata.MissionEncounter{{Definition: "950/district/2/group/0/authored_point", Positions: [][3]float32{{15, 0, 43}}}}
@@ -146,14 +146,14 @@ func TestMissionUnsupportedEncounterLevelDoesNotChargeOrAllocate(t *testing.T) {
if world.clients[1].missionOffer != nil || len(output.packets) != 1 || player.inventory.Credits != 5 ||
cold.characters[1].inventory.Credits != 5 || world.nextItem != 1 || len(player.missions) != 0 {
- t.Fatal("unimplemented level-three encounters produced a paid or partial contract")
+ t.Fatal("unimplemented encounter level produced a paid or partial contract")
}
request[17] = 6
if err := world.handleMissionOffers(world.clients[1], request); err != nil {
t.Fatal(err)
}
- if world.clients[1].missionOffer == nil || world.clients[1].missionOffer.definition.Encounters[0].Level != 2 || player.inventory.Credits != 3 {
- t.Fatal("a supported retry did not charge once and advertise level two")
+ if world.clients[1].missionOffer == nil || world.clients[1].missionOffer.definition.Encounters[0].Level != 4 || player.inventory.Credits != 1 {
+ t.Fatal("a supported retry did not charge once and advertise level four")
}
}
diff --git a/server/npc_growth_test.go b/server/npc_growth_test.go
@@ -0,0 +1,97 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "fmt"
+ "testing"
+)
+
+func TestMissionEarlyGrowthLevelsSurviveColdAcceptance(t *testing.T) {
+ for _, expected := range []struct {
+ level uint16
+ health uint32
+ rating int32
+ credits uint32
+ }{{3, 125, 10, 2}, {4, 150, 15, 1}, {5, 175, 20, 0}} {
+ t.Run(fmt.Sprint(expected.level), func(t *testing.T) {
+ world, _ := newMissionOfferWorld(t)
+ t.Cleanup(func() { world.db.Close() })
+ player, client := world.characters[1], world.clients[1]
+ player.level, world.nextNPC = expected.level, 2000000
+ definition := gamedata.MissionTemplates[3221228472]
+ definition.RewardItems = []uint32{122691}
+ definition.Encounters = []gamedata.MissionEncounter{{Definition: "950/district/2/group/0/authored_point", Positions: [][3]float32{{15, 0, 43}}}}
+ gamedata.MissionTemplates[3221228472] = definition
+
+ if err := world.handleMissionOffers(client, missionOffersRequest()); err != nil {
+ t.Fatal(err)
+ }
+ if client.missionOffer == nil {
+ t.Fatal("reviewed early encounter was rejected")
+ }
+ if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil {
+ t.Fatal(err)
+ }
+ cold := reloadMissionEntranceWorld(t)
+
+ npc := cold.characters[2000000]
+ if npc == nil || npc.level != expected.level || npc.health != expected.health || npc.combatProfile != gamedata.NPCCombatProfiles[17655][expected.level] ||
+ npc.attackRating() != expected.rating || npc.weaponRating(npc.attackWeapon(), 13) != expected.rating ||
+ cold.characters[1].inventory.Credits != expected.credits || cold.characters[1].missions[0].offer.definition.RewardQuality != uint32(expected.level) {
+ t.Fatal("cold encounter lost its level, resources, raw ratings, reward quality or fee", npc)
+ }
+ })
+ }
+}
+
+func TestEarlyGrowthKillRewardsRetainSelectedQualityAcrossRestart(t *testing.T) {
+ for _, expected := range []struct {
+ level uint16
+ experience uint32
+ quality uint32
+ }{{3, 125, 2}, {4, 150, 3}, {5, 175, 4}} {
+ for _, attack := range []string{"unarmed", "pistol", "nano"} {
+ t.Run(fmt.Sprintf("%d/%s", expected.level, attack), func(t *testing.T) {
+ world, _ := newKillExperienceWorld(t, attack)
+ target := world.characters[1000000]
+ target.level, target.combatProfile = expected.level, gamedata.NPCCombatProfiles[17655][expected.level]
+ world.combatRoll = func(uint32) uint32 { return 0 }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+
+ attackForExperience(t, world, attack)
+ cold := newTestInventoryServer(t)
+
+ for _, current := range []*server{world, cold} {
+ corpse := current.characters[1000000].corpse
+ if corpse == nil || len(corpse.items) != 1 || corpse.items[0].Template != 42640 || corpse.items[0].Quality != expected.quality ||
+ corpse.credits != 1 || current.characters[1].experience != expected.experience || current.characters[1000000].health != 0 {
+ t.Fatal("early growth death lost its selected quality, cash or XP", corpse)
+ }
+ }
+ })
+ }
+ }
+}
+
+func TestNPCProfileFoundationsUseExistingRatingAndArmorConsumers(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{4, 4}
+ useNPCData(t, data)
+ world := newTestServer(t)
+ npc := world.characters[1000000]
+ profile := *npc.combatProfile
+ profile.Modifiers = map[uint32]int32{276: 5, 277: 7, 91: 20}
+ npc.combatProfile = &profile
+
+ attack := npc.attackRating()
+ defense := npc.weaponRating(npc.attackWeapon(), 13)
+ armor := npc.equipmentBonus(91)
+
+ if npc.maximumHealth() != 150 || attack != 20 || defense != 22 || armor != 20 || npc.baseStats().Speed.NanoResist != 15 ||
+ npc.baseStats().Speed.DodgeRanged != 15 || npc.baseStats().Speed.DuckExplosions != 15 || len(gamedata.NPCCombatProfiles[17655][4].Modifiers) != 0 {
+ t.Fatal("NPC foundations gained player trickle, bypassed consumers or changed shared data", attack, defense, armor, npc.baseStats().Speed)
+ }
+}
diff --git a/server/npc_population_levels_test.go b/server/npc_population_levels_test.go
@@ -68,6 +68,7 @@ func TestNPCPopulationRangesIncludeExtendedLevelsWithoutChangingPlacement(t *tes
}{
{[2]uint16{1, 2}, []uint16{1, 2, 1, 2}},
{[2]uint16{2, 4}, []uint16{2, 3, 4, 2}},
+ {[2]uint16{5, 6}, []uint16{5, 6, 5, 6}},
{[2]uint16{300, 301}, []uint16{300, 301, 300, 301}},
{[2]uint16{65534, 65535}, []uint16{65534, 65535, 65534, 65535}},
{[2]uint16{1, 65535}, []uint16{1, 2, 3, 4}},
@@ -91,7 +92,7 @@ func TestNPCPopulationRangesIncludeExtendedLevelsWithoutChangingPlacement(t *tes
if spawn.id != 1000000+uint32(index) || spawn.position != data.Playfields[0].Districts[0].Groups[0].Positions[index] || spawn.npcDefinitionID != "test/npc" {
t.Fatal("level allocation changed placement or definition", spawn)
}
- if (spawn.combatProfile != nil) != (spawn.level <= 2) {
+ if (spawn.combatProfile != nil) != (spawn.level <= 5) {
t.Fatal("unlisted level inherited a supported profile", spawn.level)
}
}
diff --git a/server/starter_boss_test.go b/server/starter_boss_test.go
@@ -383,7 +383,8 @@ func TestStarterBossProfileRequiresItsCodeSpeciesLevelAndEvidence(t *testing.T)
{"boss", "BSML", "inferred_species", 30354, 4, true},
{"ordinary salamander", "SM01", "inferred_species", 30354, 4, false},
{"unresolved salamander", "BSML", "placeholder_creature", 30354, 4, false},
- {"other species", "BSML", "inferred_species", 17655, 4, false},
+ {"other profiled species", "BSML", "inferred_species", 17655, 4, true},
+ {"unprofiled species", "BSML", "inferred_species", 17708, 4, false},
{"other level", "BSML", "inferred_species", 30354, 3, false},
{"existing Leet", "TEST", "inferred_species", 17655, 1, true},
} {
@@ -399,6 +400,9 @@ 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 != "" {
+ t.Fatal("a Leet acquired template-specific boss combat")
+ }
})
}
}
diff --git a/server/stats.go b/server/stats.go
@@ -145,7 +145,15 @@ func (character *character) baseStats() characterStats {
if _, exists := gamedata.IPTraining.Breeds[breed]; !exists {
breed = 1
}
- return defaultCharacterStats(breed)
+ stats := defaultCharacterStats(breed)
+ if character.npc && character.combatProfile != nil {
+ for _, field := range stats.trainingStats() {
+ if value, exists := character.combatProfile.Skills[field.stat]; exists {
+ *field.value = uint16(value)
+ }
+ }
+ }
+ return stats
}
return character.stats
}