commit e08b4325077be8f5826cd7856119f5b6d0e1a0c2 parent 734d49d1530dcdb6f8378bb0865815f68873ced0 Author: anon <anon@example.com> Date: Sat, 24 Oct 2026 04:33:30 +0000 Initialize fresh characters from native breed ability baselines Diffstat:
32 files changed, 282 insertions(+), 50 deletions(-)
diff --git a/TODO.md b/TODO.md @@ -339,9 +339,13 @@ Known-amount credit collection and native balance limits are verified in period server observations. Current charging sums exact tenths and rounds the accepted batch up once; native draft float arithmetic alone cannot prove the original server rule. -- [ ] Replace provisional new-character stats with verified breed/profession - defaults. Check: all four breeds begin with legal ability values and correct - raw skills/IP; the current all-10 abilities exceed some level-1 native caps. +- [x] Initialize abilities from the original four breed baselines. Check: fresh + players start within every native training cap, can purchase ability/skill + increases, and retain accepted purchases after reconnect. See + [character creation](docs/character-creation.md). +- [ ] Establish historical profession-specific starting raw skills and IP. + Current creation uses raw skills 5, including Run Speed, and 1500 IP. Original + client fallbacks alone do not establish original-server creation rules. The recovered XP update and level-up handler, controlled WASM checks and remaining reward-rule gaps are recorded in [character progression](docs/character-progression.md). @@ -861,6 +865,10 @@ and server restarts. Turn every reproduced bug into a focused regression test. observer movement, arrival usability and restart at transition boundaries. - [ ] Audit fresh-character initialization. Cover inventory, stats, resources, learned programs, starter actions/preferences and separation between players. + Breed ability baselines, legal starting skill caps, accepted/rejected training + and durable resource-item eligibility now have focused regressions. Two fresh + WASM players verified independent stats/IP, native ACCEPT/CANCEL and purchases + retained across a server restart. The broader creation audit remains open. - [ ] Audit disconnects, retries and failure handling across these features. Cover transport replacement, stale sessions, action replay, database failures and concurrent requests; success must follow the durable significant change. diff --git a/docs/character-creation.md b/docs/character-creation.md @@ -0,0 +1,63 @@ +# Starting abilities and skills + +Creation reads the six ability baselines directly from the original 14.9.1 +breed training data in `server/gamedata/ip_training.yaml`. Resource type +1000027, identities 1 through 4, contains the breed ID followed by six starting +values and six breed maxima. `tools/data/extract_ip_training.py` retains the +payloads and hashes in `local/ip-training-research/resources.json`. + +| Breed | Strength | Agility | Stamina | Intelligence | Sense | Psychic | +| --- | --- | --- | --- | --- | --- | --- | +| Solitus | 6 | 6 | 6 | 6 | 6 | 6 | +| Opifex | 3 | 15 | 6 | 6 | 10 | 3 | +| Nanomage | 3 | 3 | 3 | 15 | 6 | 10 | +| Atrox | 15 | 6 | 10 | 3 | 3 | 3 | + +The local Fandom mirror's `Abilities` page agrees for Solitus and Atrox but +differs on four entries: it lists Opifex Stamina/Psychic as 3/6 and Nanomage +Sense/Psychic as 4/15. Creation uses the original resource values above. That +page was touched in 2015 and includes later content; it does not establish +every original-server creation rule. The snapshot and comparison script are +in `local/character-creation-research/abilities.json` and `tmp_verify.py`. +The player-authored [Metaphysicist FAQ v0.31](https://www.neoseeker.com/anarchyonline/faqs/93322-anarchy-online-metaphysicist.html) +lists the original resource's Opifex and Nanomage starting values. Its level-220 +tables are expansion-era corroboration, rather than an exact 14.9.1 server +capture. + +The browser currently creates Solitus Soldiers. Selecting other breeds and +professions, including their appropriate appearance assets, remains open. +Profiles with explicitly supplied stats retain those values. + +All raw skills start at 5 and unspent IP at 1500. Those remain reconstruction +choices pending historical profession-specific creation evidence. In particular, +the client's Run Speed fallback of 100 exceeds level-1 training caps and is +unsuitable as a fresh player's raw skill. Run Speed uses the common raw seed +of 5. This permits native training while keeping every initial skill within +its training cap; it does not prove the historical Run Speed seed. + +Starting health comes from the existing breed/profession formula and effective +Body Development. At level 1, the four breed baselines give Soldier maximum +health/nano of 34/32, 38/31, 25/48 and 59/20 respectively. Creation starts at full +health and retains the current zero-nano policy. Historical starting resources, +equipment and action choices still need a complete creation audit. + +## Verification + +`server/character_initialization_test.go` checks all four breed baselines and +every raw ability/skill against its native level-1 cap. Browser-launch tests +exercise durable creation, accepted training, rejected increases beyond the +cap, and reconnect persistence. A fresh player's rejected nano-kit use retains +all charges and creates no cooldown; sufficient First Aid training makes the +same use succeed and persist its charge, resource gain and cooldown together. + +Combat arithmetic fixtures explicitly supply their all-10 abilities and raw +Run Speed 100. Their established numeric checks remain controlled inputs, +independent of character creation defaults. + +Hardware Chromium/WASM checks used two fresh players on the single shared +HTTPS preview. Both started with six abilities of 6, raw Run Speed 5 and +1500 IP. Native ACCEPT raised Strength 6 to 8 for 26 IP, then Run Speed 5 to 7 +for 22 IP. A subsequent cancelled draft left 1452 IP and both trained values +unchanged. A server restart and native reconnect retained those purchases; +the second player retained its original abilities, skills and IP. Native +snapshots and screenshots are in `local/character-creation-research/`. diff --git a/docs/combat-starting-stats.md b/docs/combat-starting-stats.md @@ -38,6 +38,12 @@ gives **7 Martial Arts, 7 Physical Initiative, and 7 Body Development**. Abilities of 10 are a local fixture choice; this does not establish the historical starting abilities of a newly created character. +New characters use the breed ability baselines from resource 1000027, rather +than the controlled all-10 fixture used in the calculations below. A fresh +Solitus has six abilities of 6, effective Body Development 6 and maximum health +34. See [character creation](character-creation.md) for the other breeds, +starting-skill assumptions and verification. + The percentage multiplication uses float constant `0x10170894`, value 0.009999999776482582, followed by exactly 0.25 at `0x10170e78`. Thus the exact expression is `trunc(weighted_sum * float32(.01) * .25)`, not integer division diff --git a/docs/ip-training.md b/docs/ip-training.md @@ -94,9 +94,11 @@ receives the authoritative result rather than controlling the charge. Increasing maximum health/nano preserves current resources; it grants no free heal. The historical training-time refill policy remains unverified. Training -does not reschedule a weapon cycle already in progress. New-character ability -and skill defaults are still provisional: the current all-10 ability default -already exceeds some level-1 breed caps. Training never lowers those values. +does not reschedule a weapon cycle already in progress. New-character abilities +use the original breed baselines; all raw skills start at 5, including Run +Speed. Fresh players are within native training caps. Historical profession +skill seeds and starting IP remain unverified; see +[character creation](character-creation.md). XP rewards, level advancement, IP grants and IP Reset remain open. ## Verification diff --git a/server/attack_rating_test.go b/server/attack_rating_test.go @@ -67,7 +67,7 @@ func TestAttackRatingFistEndpointsIncludeZeroSkill(t *testing.T) { }{ {0, 3, 5}, {400, 6, 10}, {800, 9, 15}, } { - attacker := &character{stats: defaultCharacterStats()} + attacker := &character{stats: testCharacterStats()} attacker.stats.Abilities.Strength, attacker.stats.Abilities.Agility, attacker.stats.Abilities.Psychic = 0, 0, 0 attacker.stats.Body.MartialArts, attacker.stats.Melee.OneHandEdged = scenario.skill, 2000 target := &character{} @@ -83,7 +83,7 @@ func TestAttackRatingFistEndpointsIncludeZeroSkill(t *testing.T) { func TestAttackRatingScaledMinimumPrecedesArmor(t *testing.T) { world, _ := newArmorDamageWorld(t) - attacker := &character{stats: defaultCharacterStats(), inventory: playerInventory{ + attacker := &character{stats: testCharacterStats(), inventory: playerInventory{ Items: []ownedItem{{ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 6, Count: 1}}, }} attacker.stats.Melee.OneHandEdged = 398 diff --git a/server/character_initialization_test.go b/server/character_initialization_test.go @@ -0,0 +1,127 @@ +package main + +import ( + "fmt" + "net/http/httptest" + "testing" +) + +func TestCharacterInitializationUsesNativeBreedAbilityBaselines(t *testing.T) { + for _, scenario := range []struct { + breed uint16 + abilities characterAbilitiesStats + health, nano uint32 + }{ + {1, characterAbilitiesStats{6, 6, 6, 6, 6, 6}, 34, 32}, + {2, characterAbilitiesStats{3, 15, 6, 6, 10, 3}, 38, 31}, + {3, characterAbilitiesStats{3, 3, 3, 15, 6, 10}, 25, 48}, + {4, characterAbilitiesStats{15, 6, 10, 3, 3, 3}, 59, 20}, + } { + t.Run(fmt.Sprint(scenario.breed), func(t *testing.T) { + data := userData{ID: 1, Name: "New player", Level: 1, Appearance: scenario.breed << 4} + + player := data.character() + + if player.stats.Abilities != scenario.abilities || player.maximumHealth() != scenario.health || player.maximumNano() != scenario.nano { + t.Fatalf("breed %d baseline/resources: abilities=%+v HP=%d nano=%d", scenario.breed, player.stats.Abilities, player.maximumHealth(), player.maximumNano()) + } + for _, stat := range player.stats.nativeStats() { + if stat[0] != 53 && stat[1] > player.trainingMaximum(stat[0]) { + t.Fatalf("fresh stat %d exceeds native level1 cap: %d > %d", stat[0], stat[1], player.trainingMaximum(stat[0])) + } + } + }) + } +} + +func TestBrowserCharacterStartsWithLegalSolitusAbilities(t *testing.T) { + useNPCData(t, testNPCData()) + world := newTestServer(t) + response := httptest.NewRecorder() + + world.browserLaunch(response, httptest.NewRequest("POST", "/browser-launch", nil)) + restored := newTestInventoryServer(t).characters[1] + + if restored.stats.Abilities != (characterAbilitiesStats{6, 6, 6, 6, 6, 6}) || restored.health != 34 || restored.stats.ImprovementPoints != 1500 { + t.Fatalf("fresh browser player used fixture stats: %+v", restored) + } +} + +func TestFreshCharacterCanTrainStrengthToFirstLevelCap(t *testing.T) { + useNPCData(t, testNPCData()) + world := newTestServer(t) + world.browserLaunch(httptest.NewRecorder(), httptest.NewRequest("POST", "/browser-launch", nil)) + player := world.characters[1] + world.clients[1] = &worldClient{id: 1, conn: &combatTestConn{}, ready: true, target: true} + proposed := player.stats + proposed.Abilities.Strength = 9 + + if err := world.handleSkillTraining(world.clients[1], skillTrainingRequest(proposed)[20:]); err != nil { + t.Fatal(err) + } + proposed.Abilities.Strength = 10 + if err := world.handleSkillTraining(world.clients[1], skillTrainingRequest(proposed)[20:]); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if player.stats.Abilities.Strength != 9 || restored.stats.Abilities.Strength != 9 || player.stats.ImprovementPoints != 1458 || restored.stats.ImprovementPoints != 1458 || + player.health != 34 || player.nano != 0 { + t.Fatalf("fresh ability training exceeded its cap, repeated a charge or changed resources: %+v", player.stats) + } +} + +func TestFreshCharacterCanTrainRunSpeed(t *testing.T) { + useNPCData(t, testNPCData()) + world := newTestServer(t) + world.browserLaunch(httptest.NewRecorder(), httptest.NewRequest("POST", "/browser-launch", nil)) + player := world.characters[1] + world.clients[1] = &worldClient{id: 1, conn: &combatTestConn{}, ready: true, target: true} + proposed := player.stats + proposed.Speed.RunSpeed = 6 + + if err := world.handleSkillTraining(world.clients[1], skillTrainingRequest(proposed)[20:]); err != nil { + t.Fatal(err) + } + proposed.Speed.RunSpeed = 100 + if err := world.handleSkillTraining(world.clients[1], skillTrainingRequest(proposed)[20:]); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if player.stats.Speed.RunSpeed != 6 || restored.stats.Speed.RunSpeed != 6 || player.stats.ImprovementPoints != 1490 || restored.stats.ImprovementPoints != 1490 { + t.Fatalf("fresh Run Speed training was blocked by a fallback or bypassed its cap: %+v", player.stats) + } +} + +func TestFreshCharacterNanoKitRequiresTrainingWithoutLosingCharges(t *testing.T) { + useNPCData(t, testNPCData()) + world := newTestServer(t) + world.browserLaunch(httptest.NewRecorder(), httptest.NewRequest("POST", "/browser-launch", nil)) + player := world.characters[1] + world.clients[1] = &worldClient{id: 1, conn: &combatTestConn{}, ready: true, target: true, selectedTarget: [2]uint32{50000, 1}} + if granted, err := world.grantItem_locked(player, 85366); !granted || err != nil { + t.Fatal(granted, err) + } + + if err := world.handleOwnedItemUse(world.clients[1], backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + if player.inventory.Items[0].Count != 25 || player.nano != 0 || !player.inventory.FirstAidLockedUntil.IsZero() { + t.Fatal("untrained use consumed the kit or supplied its effect") + } + proposed := player.stats + proposed.NanoAiding.FirstAid = 7 + if err := world.handleSkillTraining(world.clients[1], skillTrainingRequest(proposed)[20:]); err != nil { + t.Fatal(err) + } + if err := world.handleOwnedItemUse(world.clients[1], backpackUseRequest(1, 64, 2)[20:]); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if player.stats.ImprovementPoints != 1478 || restored.stats.NanoAiding.FirstAid != 7 || restored.inventory.Items[0].Count != 24 || + restored.nano < 10 || restored.nano > 12 || restored.inventory.FirstAidLockedUntil.IsZero() { + t.Fatal("trained fresh player lost its IP, charge, nano gain or cooldown") + } +} diff --git a/server/combat_stats_test.go b/server/combat_stats_test.go @@ -19,7 +19,7 @@ func TestCombatPlayerHealthMatchesBreedAndSoldierTitle(t *testing.T) { {1, 149, 4, 1372}, {1, 150, 5, 1531}, {1, 189, 5, 1921}, {1, 190, 6, 2121}, {1, 200, 6, 2231}, } { - data := userData{ID: 1, Level: scenario.level, Appearance: scenario.breed << 4} + data := userData{ID: 1, Level: scenario.level, Appearance: scenario.breed << 4, Stats: testCharacterStats()} player := data.character() packet := fullCharacterPacket(player) diff --git a/server/combat_test.go b/server/combat_test.go @@ -25,8 +25,8 @@ func newCombatWorld() (*server, *combatTestConn) { conn := &combatTestConn{} return &server{ characters: map[uint32]*character{ - 1: {id: 1, playfield: 950, health: 100}, - 1000000: {id: 1000000, playfield: 950, position: [3]float32{1, 0, 0}, appearance: 229, npc: true, health: 100}, + 1: {id: 1, playfield: 950, health: 100, stats: testCharacterStats()}, + 1000000: {id: 1000000, playfield: 950, position: [3]float32{1, 0, 0}, appearance: 229, npc: true, health: 100, stats: testCharacterStats()}, }, clients: map[uint32]*worldClient{ 1: {id: 1, conn: conn, target: true, ready: true, npcs: map[uint32]bool{1000000: true}}, @@ -428,7 +428,7 @@ func TestCombatReconnectRevivesDefeatedPlayer(t *testing.T) { world.mutex.Lock() defer world.mutex.Unlock() - if world.characters[1].health != 37 || world.characters[1].fighting != 0 { + if world.characters[1].health != 34 || world.characters[1].fighting != 0 { t.Fatal("reconnecting did not revive the defeated player") } } diff --git a/server/consumable_outcome_test.go b/server/consumable_outcome_test.go @@ -41,6 +41,7 @@ func newConsumableOutcomeWorld(t *testing.T, template uint32, other bool) (*serv useNPCData(t, testNPCData()) world := newTestServer(t) player := world.newCharacter() + player.stats = testCharacterStats() if template == 85366 { player.stats.NanoAiding.FirstAid = 6 } else { @@ -49,6 +50,7 @@ func newConsumableOutcomeWorld(t *testing.T, template uint32, other bool) (*serv target := player if other { target = world.newCharacter() + target.stats = testCharacterStats() } if template == 85366 { target.nano = 1 diff --git a/server/control_data_test.go b/server/control_data_test.go @@ -211,7 +211,7 @@ func TestControlEditorShowsAllSkillCategoriesAndDefaultFields(t *testing.T) { t.Fatalf("incomplete %s category: %v", category, stats[category]) } } - if stats["improvement_points"] != 1500 || stats["body"].(map[string]any)["martial_arts"] != 0 || stats["abilities"].(map[string]any)["strength"] != 10 || stats["ranged"].(map[string]any)["rifle"] != 5 || stats["speed"].(map[string]any)["run_speed"] != 100 { + if stats["improvement_points"] != 1500 || stats["body"].(map[string]any)["martial_arts"] != 0 || stats["abilities"].(map[string]any)["strength"] != 6 || stats["ranged"].(map[string]any)["rifle"] != 5 || stats["speed"].(map[string]any)["run_speed"] != 5 { t.Fatalf("incorrect defaults: %v", stats) } var data characterEditor @@ -241,7 +241,7 @@ func TestControlNestedSkillsAndImprovementPointsPersistAndReachClient(t *testing if response.Code != http.StatusSeeOther || restarted.characters[1].stats.ImprovementPoints != 12345 || restarted.characters[1].stats.Ranged.Rifle != 42 || restarted.characters[1].stats.Spying.Concealment != 87 { t.Fatalf("nested skills or IP lost: %d %s", response.Code, response.Body.String()) } - if values[53] != 12345 || values[113] != 42 || values[164] != 87 || values[102] != 5 || values[16] != 10 || values[156] != 100 { + if values[53] != 12345 || values[113] != 42 || values[164] != 87 || values[102] != 5 || values[16] != 6 || values[156] != 5 { t.Fatalf("native stats: %v", values) } } diff --git a/server/equipment_test.go b/server/equipment_test.go @@ -18,7 +18,7 @@ func newEquipmentWorld(t *testing.T) (*server, *combatTestConn) { player := world.characters[1] player.name, player.level, player.appearance = "Axe Owner", 1, 277 player.rotation[3] = 1 - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() if err := world.saveUser_locked(player); err != nil { t.Fatal(err) } diff --git a/server/flying_vehicle_test.go b/server/flying_vehicle_test.go @@ -16,6 +16,7 @@ func newFlyingVehicleWorld(t *testing.T) (*server, *combatTestConn) { t.Chdir(t.TempDir()) world, conn := newCombatWorld() player := world.newCharacter() + player.stats = testCharacterStats() player.playfield, player.position = 800, [3]float32{600, 67, 700} player.stats.Navigation.VehicleAir = 79 // Effective 81 with the fixture's abilities. if err := world.saveUser_locked(player); err != nil { diff --git a/server/grid_test.go b/server/grid_test.go @@ -10,6 +10,7 @@ func newGridWorld(t *testing.T) (*server, *combatTestConn) { t.Helper() world, conn := newCombatWorld() player := world.newCharacter() + player.stats = testCharacterStats() player.playfield = 800 player.position = [3]float32{637, 67.3, 728} player.stats.TradeRepair.ComputerLiteracy = 89 // Effective 91 with Intelligence 10. diff --git a/server/maps_test.go b/server/maps_test.go @@ -53,6 +53,7 @@ func TestMapPlayersPredictsMovementWithoutChangingSavedPosition(t *testing.T) { useNPCData(t, testNPCData()) world := newTestServer(t) player := world.newCharacter() + player.stats = testCharacterStats() player.running = true world.clients[player.id] = &worldClient{ready: true, forward: 1, movementStarted: time.Now().Add(-time.Minute)} response := httptest.NewRecorder() diff --git a/server/nano_casting_test.go b/server/nano_casting_test.go @@ -18,7 +18,7 @@ func newNanoCastingWorld(t *testing.T) (*server, *combatTestConn) { player.profession, player.nano = 8, 30 player.appearance, player.level = 0x315, 1 player.rotation[3] = 1 - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() player.stats.NanoAiding.PsychologicalModification, player.stats.NanoAiding.MatterCreation = 7, 6 player.health = player.maximumHealth() player.inventory.LearnedNanos = []uint32{29618} diff --git a/server/nano_kit_test.go b/server/nano_kit_test.go @@ -14,7 +14,7 @@ func newNanoKitWorld(t *testing.T) (*server, *combatTestConn) { world, conn := newCombatWorld() player := world.characters[1] player.name, player.level, player.appearance = "Nano Kit Owner", 1, 277 - player.rotation[3], player.stats = 1, defaultCharacterStats() + player.rotation[3], player.stats = 1, testCharacterStats() player.stats.NanoAiding.FirstAid = 6 player.health = player.maximumHealth() - 20 world.clients[1].selectedTarget = [2]uint32{50000, 1} @@ -144,7 +144,7 @@ func TestNanoKitRejectsInvalidUseAndFailedSave(t *testing.T) { func TestNanoKitRestoresFriendAtNativeRangeDuringCombat(t *testing.T) { world, _ := newNanoKitWorld(t) player, client := world.characters[1], world.clients[1] - target := &character{id: 2, name: "Patient", playfield: player.playfield, position: [3]float32{7, 0, 0}, rotation: [4]float32{0, 0, 0, 1}, level: 1, appearance: 277, stats: defaultCharacterStats(), health: 10, fighting: 1000000} + target := &character{id: 2, name: "Patient", playfield: player.playfield, position: [3]float32{7, 0, 0}, rotation: [4]float32{0, 0, 0, 1}, level: 1, appearance: 277, stats: testCharacterStats(), health: 10, fighting: 1000000} world.characters[2] = target if err := world.saveUser_locked(target); err != nil { t.Fatal(err) diff --git a/server/nano_learning_test.go b/server/nano_learning_test.go @@ -13,6 +13,7 @@ func newNanoLearningWorld(t *testing.T) (*server, *combatTestConn) { t.Chdir(t.TempDir()) world, conn := newCombatWorld() player := world.newCharacter() + player.stats = testCharacterStats() player.profession = 12 player.stats.NanoAiding.MatterCreation, player.stats.NanoAiding.TimeAndSpace = 6, 6 if err := world.saveUser_locked(player); err != nil { diff --git a/server/npc_combat_test.go b/server/npc_combat_test.go @@ -90,7 +90,7 @@ func TestNPCProfileCombatUsesCatalogTimingAndDamageForBothObservers(t *testing.T t.Fatalf("Leet Bite attack deadline: %v", npc.nextAttack.Sub(start)) } world.advanceCombat(start.Add(1750*time.Millisecond - time.Nanosecond)) - if player.health != 37 { + if player.health != 34 { t.Fatal("Leet Bite landed before its attack phase ended") } world.advanceCombat(start.Add(1750 * time.Millisecond)) @@ -111,7 +111,7 @@ func TestNPCProfileCombatUsesCatalogTimingAndDamageForBothObservers(t *testing.T } } } - if len(damage) != 2 || len(second.packets) != len(first.packets) || player.health != 37-damage[0]-damage[1] { + if len(damage) != 2 || len(second.packets) != len(first.packets) || player.health != 34-damage[0]-damage[1] { t.Fatalf("Leet Bite results: %v, health %d", damage, player.health) } } @@ -142,7 +142,7 @@ func TestNPCProfileDoesNotApplyToOtherLevelsOrSpecies(t *testing.T) { world.advanceCombat(start.Add(time.Second)) world.clients[player.id].send(characterPacket(world.characters[1000000])) - if player.health != 32 || world.characters[1000000].nextAttack != start.Add(3*time.Second) { + if player.health != 29 || world.characters[1000000].nextAttack != start.Add(3*time.Second) { t.Fatal("a Leet profile changed an unlisted creature's prototype behavior") } packet := conn.packets[len(conn.packets)-1] diff --git a/server/overequipping_test.go b/server/overequipping_test.go @@ -74,7 +74,7 @@ func TestOverequippingIncludesTrickleAndRecoversAfterRestart(t *testing.T) { func TestOverequippingAdjustedMinimumPrecedesArmor(t *testing.T) { world, _ := newArmorDamageWorld(t) - attacker := &character{stats: defaultCharacterStats(), inventory: playerInventory{ + attacker := &character{stats: testCharacterStats(), inventory: playerInventory{ Items: []ownedItem{{ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 6, Count: 1}}, }} attacker.stats.Melee.OneHandEdged, attacker.stats.Body.Brawling = 398, 1 diff --git a/server/profession_resources_test.go b/server/profession_resources_test.go @@ -26,7 +26,7 @@ func TestProfessionResourcesReachFullCharacter(t *testing.T) { } { t.Run(fmt.Sprintf("profession%d/level%d", scenario.profession, scenario.level), func(t *testing.T) { player := (userData{ID: 1, Appearance: 0x10, Level: scenario.level, - Profession: scenario.profession, Stats: defaultCharacterStats()}).character() + Profession: scenario.profession, Stats: testCharacterStats()}).character() packet := fullCharacterPacket(player) stats := make(map[uint32]uint32) @@ -54,6 +54,7 @@ func TestProfessionEditClampsResourcesAndPersistsCoefficients(t *testing.T) { t.Chdir(t.TempDir()) world, _ := newCombatWorld() player := world.newCharacter() + player.stats = testCharacterStats() player.level, player.profession = 190, scenario.from player.health, player.nano = player.maximumHealth(), player.maximumNano() destination := player.userData() diff --git a/server/ranged_test.go b/server/ranged_test.go @@ -18,7 +18,7 @@ func newRangedWorld(t *testing.T) (*server, *combatTestConn) { player := world.characters[1] player.name, player.level, player.appearance = "Pistol Owner", 1, 277 player.rotation[3] = 1 - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() world.characters[1000000].position = [3]float32{20, 0, 0} world.characters[1000000].health = 1000 if err := world.saveUser_locked(player); err != nil { diff --git a/server/regeneration_test.go b/server/regeneration_test.go @@ -212,7 +212,7 @@ func TestRegenerationFullCharacterPreservesNanoAndBreedMaximum(t *testing.T) { }{ {0, 18}, {1, 35}, {2, 34}, {3, 48}, {4, 24}, {5, 59}, {6, 18}, {7, 18}, } { - player := (&userData{ID: 1, Appearance: scenario.breed << 4, Level: 1}).character() + player := (&userData{ID: 1, Appearance: scenario.breed << 4, Level: 1, Stats: testCharacterStats()}).character() player.nano = 11 packet := fullCharacterPacket(player) diff --git a/server/stacks_test.go b/server/stacks_test.go @@ -30,7 +30,7 @@ func newStackWorld(t *testing.T) (*server, *combatTestConn) { world, conn := newCombatWorld() player := world.characters[1] player.name, player.level, player.appearance = "Stack Owner", 1, 277 - player.rotation[3], player.stats = 1, defaultCharacterStats() + player.rotation[3], player.stats = 1, testCharacterStats() if err := world.saveUser_locked(player); err != nil { t.Fatal(err) } diff --git a/server/state.go b/server/state.go @@ -193,8 +193,8 @@ func (server *server) newCharacter_locked() *character { id: server.nextCharacter, name: fmt.Sprintf("Local Explorer %d", server.nextCharacter), playfield: 950, position: [3]float32{52.625, 14.75, 56.875 + float32((server.nextCharacter-1)%4)*3}, rotation: [4]float32{0, 0, 0, 1}, appearance: 0x315, level: 1, profession: 1, - stats: defaultCharacterStats(), } + character.stats = defaultCharacterStats(character.appearance >> 4 & 7) character.health = character.maximumHealth() server.characters[character.id] = character return character diff --git a/server/stats.go b/server/stats.go @@ -1,5 +1,7 @@ package main +import "ao/server/gamedata" + type characterStats struct { ImprovementPoints uint32 `yaml:"improvement_points"` Abilities characterAbilitiesStats `yaml:"abilities"` @@ -119,15 +121,16 @@ type characterNavigationStats struct { MapNavigation uint16 `yaml:"map_navigation"` } -func defaultCharacterStats() characterStats { +func defaultCharacterStats(breed uint16) characterStats { + abilities := gamedata.IPTraining.Breeds[breed].Base return characterStats{ ImprovementPoints: 1500, - Abilities: characterAbilitiesStats{10, 10, 10, 10, 10, 10}, + Abilities: characterAbilitiesStats{uint16(abilities[0]), uint16(abilities[1]), uint16(abilities[2]), uint16(abilities[3]), uint16(abilities[4]), uint16(abilities[5])}, Body: characterBodyStats{5, 5, 5, 5, 5, 5, 5, 5}, Melee: characterMeleeStats{5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, MiscWeapons: characterMiscWeaponsStats{5, 5, 5}, Ranged: characterRangedStats{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, - Speed: characterSpeedStats{5, 5, 5, 5, 5, 5, 5, 5, 100}, + Speed: characterSpeedStats{5, 5, 5, 5, 5, 5, 5, 5, 5}, TradeRepair: characterTradeRepairStats{5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, NanoAiding: characterNanoAidingStats{5, 5, 5, 5, 5, 5, 5, 5}, Spying: characterSpyingStats{5, 5, 5, 5}, @@ -137,7 +140,12 @@ func defaultCharacterStats() characterStats { func (character *character) baseStats() characterStats { if character.stats == (characterStats{}) { - return defaultCharacterStats() + breed := character.appearance >> 4 & 7 + // Nonplayer breed codes retain the default player skill foundation. + if _, exists := gamedata.IPTraining.Breeds[breed]; !exists { + breed = 1 + } + return defaultCharacterStats(breed) } return character.stats } diff --git a/server/stats_test.go b/server/stats_test.go @@ -6,8 +6,16 @@ import ( "time" ) +func testCharacterStats() characterStats { + // Use explicit inputs for the documented combat arithmetic fixtures. + stats := defaultCharacterStats(1) + stats.Abilities = characterAbilitiesStats{10, 10, 10, 10, 10, 10} + stats.Speed.RunSpeed = 100 + return stats +} + func TestCharacterStatsDeriveHealthNanoAndAttackTiming(t *testing.T) { - stats := defaultCharacterStats() + stats := testCharacterStats() stats.Abilities.Stamina, stats.Abilities.Psychic = 60, 120 stats.Body.BodyDevelopment, stats.Body.NanoPool = 200, 100 stats.Body.MartialArts, stats.Speed.PhysicalInitiative = 100, 100 @@ -49,7 +57,7 @@ func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { restarted := newServer() if restarted.characters[1].baseStats().Abilities.Stamina != 60 || restarted.characters[1].baseStats().Body.BodyDevelopment != 200 || - restarted.characters[1].maximumHealth() != 658 || restarted.characters[1].health != 37 { + restarted.characters[1].maximumHealth() != 658 || restarted.characters[1].health != 34 { t.Fatalf("stats or current health lost across restart: %+v", restarted.characters[1]) } if restarted.characters[1].baseStats() != destination.Stats { @@ -60,12 +68,12 @@ func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { func TestCharacterStatsProfileEditClampsBothResources(t *testing.T) { t.Chdir(t.TempDir()) world, _, _ := newRegenerationWorld() - world.characters[1].stats = defaultCharacterStats() + world.characters[1].stats = testCharacterStats() world.characters[1].stats.Body.BodyDevelopment = 300 world.characters[1].stats.Body.NanoPool = 300 world.characters[1].health, world.characters[1].nano = 500, 500 destination := world.characters[1].userData() - destination.Stats = defaultCharacterStats() + destination.Stats = testCharacterStats() err := world.updateUser(destination) @@ -77,7 +85,7 @@ func TestCharacterStatsProfileEditClampsBothResources(t *testing.T) { func TestRegenerationUsesEditedAbilitiesAndBodyDevelopment(t *testing.T) { for _, sitting := range []bool{false, true} { world, _, start := newRegenerationWorld() - world.characters[1].stats = defaultCharacterStats() + world.characters[1].stats = testCharacterStats() world.characters[1].stats.Abilities.Stamina, world.characters[1].stats.Abilities.Psychic = 60, 120 world.characters[1].stats.Body.BodyDevelopment, world.characters[1].stats.Body.NanoPool = 200, 100 world.characters[1].sitting = sitting @@ -98,7 +106,7 @@ func TestRegenerationUsesEditedAbilitiesAndBodyDevelopment(t *testing.T) { func TestRegenerationHandlesMinimumIntervals(t *testing.T) { world, _, start := newRegenerationWorld() - world.characters[1].stats = defaultCharacterStats() + world.characters[1].stats = testCharacterStats() world.characters[1].stats.Abilities.Stamina, world.characters[1].stats.Abilities.Psychic = 1000, 1000 world.advanceRegeneration(start.Add(2 * time.Second)) @@ -109,7 +117,7 @@ func TestRegenerationHandlesMinimumIntervals(t *testing.T) { } func TestCharacterStatsAttackTimingPreservesNativeFloatRounding(t *testing.T) { - stats := defaultCharacterStats() + stats := testCharacterStats() stats.Speed.PhysicalInitiative = 385 player := (&userData{ID: 1, Level: 1, Appearance: 1 << 4, Stats: stats}).character() player.aggDef = -100 diff --git a/server/target_protocol_test.go b/server/target_protocol_test.go @@ -44,7 +44,7 @@ func TestTargetCharactersIncludeUnarmedWeapon(t *testing.T) { func TestTargetCharacterSnapshotPreservesPhysicalAbilities(t *testing.T) { player := &character{id: 1, name: "Player", appearance: 0x315, level: 1, health: 100} - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() player.stats.Abilities.Strength, player.stats.Abilities.Agility, player.stats.Abilities.Stamina = 11, 22, 33 player.stats.Abilities.Intelligence = 44 diff --git a/server/team_loot_test.go b/server/team_loot_test.go @@ -23,7 +23,7 @@ func TestTeamLootNanoAndFlingUseTheSameDurableTeamAward(t *testing.T) { formTestTeam(t, world, 1, 2) player, npc := world.characters[1], world.characters[1000000] player.profession, player.nano = 8, 30 - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() player.stats.NanoAiding.PsychologicalModification, player.stats.NanoAiding.MatterCreation = 7, 6 player.inventory.LearnedNanos = []uint32{29618} if attack == "Fling" { @@ -114,7 +114,7 @@ func TestTeamLootFailedNanoDeathRetainsReservationUntilRefundCommits(t *testing. formTestTeam(t, world, 1, 2) player, npc := world.characters[1], world.characters[1000000] player.profession, player.nano = 8, 30 - player.stats = defaultCharacterStats() + player.stats = testCharacterStats() player.stats.NanoAiding.PsychologicalModification, player.stats.NanoAiding.MatterCreation = 7, 6 player.inventory.LearnedNanos = []uint32{29618} npc.health = 1 diff --git a/server/teams_test.go b/server/teams_test.go @@ -15,6 +15,8 @@ func newTeamWorld(t *testing.T) (*server, []*combatTestConn) { var connections []*combatTestConn for id := uint32(1); id <= 8; id++ { player := world.newCharacter() + player.stats = testCharacterStats() + player.health = player.maximumHealth() player.name = "Member" if err := world.saveUser_locked(player); err != nil { t.Fatal(err) diff --git a/server/treatment_kit_test.go b/server/treatment_kit_test.go @@ -14,7 +14,7 @@ func newTreatmentKitWorld(t *testing.T) (*server, *combatTestConn) { world, conn := newCombatWorld() player := world.characters[1] player.name, player.level, player.appearance = "Treatment Kit Owner", 1, 277 - player.rotation[3], player.stats = 1, defaultCharacterStats() + player.rotation[3], player.stats = 1, testCharacterStats() player.stats.NanoAiding.Treatment, player.health, player.sitting = 6, 1, true world.clients[1].selectedTarget = [2]uint32{50000, 1} if err := world.saveUser_locked(player); err != nil { @@ -117,7 +117,7 @@ func TestTreatmentKitStandingHealerTreatsDistinctPatientsAndRestoresLocks(t *tes player.treatmentLockedUntil = time.Now().Add(600 * time.Second) connections := make(map[uint32]*combatTestConn) for _, id := range []uint32{2, 3} { - world.characters[id] = &character{id: id, name: "Patient", playfield: player.playfield, position: [3]float32{7, 0, 0}, rotation: [4]float32{0, 0, 0, 1}, level: 1, appearance: 277, stats: defaultCharacterStats(), health: 1, sitting: true} + world.characters[id] = &character{id: id, name: "Patient", playfield: player.playfield, position: [3]float32{7, 0, 0}, rotation: [4]float32{0, 0, 0, 1}, level: 1, appearance: 277, stats: testCharacterStats(), health: 1, sitting: true} connections[id] = &combatTestConn{} world.clients[id] = &worldClient{id: id, conn: connections[id], target: true, ready: true} if err := world.saveUser_locked(world.characters[id]); err != nil { diff --git a/server/vehicle_test.go b/server/vehicle_test.go @@ -14,6 +14,7 @@ func newVehicleWorld(t *testing.T) (*server, *combatTestConn) { t.Chdir(t.TempDir()) world, conn := newCombatWorld() player := world.newCharacter() + player.stats = testCharacterStats() player.playfield, player.position = 800, [3]float32{600, 67, 700} player.stats.Navigation.VehicleGround = 79 // Effective 81 with the fixture's abilities. if err := world.saveUser_locked(player); err != nil { diff --git a/server/world.sql b/server/world.sql @@ -20,12 +20,12 @@ CREATE TABLE IF NOT EXISTS characters ( level INTEGER NOT NULL DEFAULT 1, profession INTEGER NOT NULL DEFAULT 1, improvement_points INTEGER NOT NULL DEFAULT 1500, - abilities_strength INTEGER NOT NULL DEFAULT 10, - abilities_agility INTEGER NOT NULL DEFAULT 10, - abilities_stamina INTEGER NOT NULL DEFAULT 10, - abilities_intelligence INTEGER NOT NULL DEFAULT 10, - abilities_sense INTEGER NOT NULL DEFAULT 10, - abilities_psychic INTEGER NOT NULL DEFAULT 10, + abilities_strength INTEGER NOT NULL DEFAULT 6, + abilities_agility INTEGER NOT NULL DEFAULT 6, + abilities_stamina INTEGER NOT NULL DEFAULT 6, + abilities_intelligence INTEGER NOT NULL DEFAULT 6, + abilities_sense INTEGER NOT NULL DEFAULT 6, + abilities_psychic INTEGER NOT NULL DEFAULT 6, body_martial_arts INTEGER NOT NULL DEFAULT 5, body_brawling INTEGER NOT NULL DEFAULT 5, body_riposte INTEGER NOT NULL DEFAULT 5, @@ -68,7 +68,7 @@ CREATE TABLE IF NOT EXISTS characters ( speed_evade_close INTEGER NOT NULL DEFAULT 5, speed_duck_explosions INTEGER NOT NULL DEFAULT 5, speed_nano_resist INTEGER NOT NULL DEFAULT 5, - speed_run_speed INTEGER NOT NULL DEFAULT 100, + speed_run_speed INTEGER NOT NULL DEFAULT 5, trade_repair_mechanical_engineering INTEGER NOT NULL DEFAULT 5, trade_repair_electrical_engineering INTEGER NOT NULL DEFAULT 5, trade_repair_quantum_field_technology INTEGER NOT NULL DEFAULT 5,