commit d4408069694eb3c5092caaaf2be2de48f45589b1
parent b04d21581f796b80487c14c565395f90c916ae1c
Author: anon <anon@example.com>
Date: Thu, 22 Oct 2026 23:40:06 +0000
Use shipped profession health and nano coefficients
Diffstat:
6 files changed, 232 insertions(+), 4 deletions(-)
diff --git a/docs/combat-starting-stats.md b/docs/combat-starting-stats.md
@@ -95,6 +95,76 @@ same health formula applies on both ends. Levels above 200 remain a local
extension. This calculation does not establish historical starting abilities,
creature health, regeneration, death recovery, or progression.
+## Profession resource coefficients
+
+The server loads the original twelve professions' health/nano coefficients
+from [profession_resources.yaml](../server/gamedata/profession_resources.yaml).
+`python3 tools/data/extract_profession_resources.py` regenerates this file from
+resource type 1000200 and retains exact payloads and hashes in
+`local/reports/profession-resources-14.9.1.json`.
+
+`10075910` selects the row with real Profession 60 and stored TitleLevel 37,
+through `100e6050`. VisualProfession 368 does not select it. Each resource row
+contains four signed DWORDs: starting level, nano coefficient, health
+coefficient and a fourth field unused by this resource calculation. The
+coefficient multiplies the full current level, without accumulation across
+earlier titles:
+
+```
+maximum health = breed600 + level * (breed601 + title.health) + effectiveBD * breed602
+maximum nano = breed603 + level * (breed604 + title.nano) + effectiveNP * breed605
+```
+
+Doctor 10 and Meta-Physicist 12 have these identical coefficients:
+
+| Title starting level | Health per level | Nano per level |
+| --- | --- | --- |
+| 1 | 0 | 0 |
+| 15 | 0 | 1 |
+| 50 | 0 | 2 |
+| 100 | 0 | 3 |
+| 150 | 0 | 4 |
+| 190 | 0 | 6 |
+
+For Solitus with effective Body Development and Nano Pool fixed at 7, level
+15 Doctor/MP maxima are 121 health and 106 nano; level 190 gives 1171/1931.
+Soldier gives 136/91 and 2121/791 respectively. These are coefficient examples,
+without automatic leveling or historical ability progression. The native
+selector accepts title levels 1 through 6; the server's existing above-200
+extension does not establish Shadowlevel rules.
+
+`local/profession-resource-research/native-source-audit.json` retains the
+original DLL reader, selector and arithmetic, exact profession/breed resources
+and original bytes. Resource 1000201 is absent from the selected index.
+NPC health, breed coefficients and ability-trickle arithmetic are unchanged.
+Profile edits clamp current resources to the newly selected maxima; increases
+in the maxima do not refill current resources. Tests check all twelve
+professions, every Doctor title boundary, packet values and profile reloads.
+
+Two WASM clients checked level 190 Doctor and Soldier maxima, then used the
+existing profile editor to change Doctor to Soldier, Soldier to Doctor and
+Doctor to MP. Native current nano clamped from 1931 to 791 and current health
+from 2121 to 1171 as the applicable maxima fell. MP level 14/15 showed maxima
+115/87 and 121/106; returning to 15 retained current values 115/87. The Skills
+window displayed the six abilities at 10 and effective resource skills at 7.
+Both clients reloaded after a full server restart and recovered their selected
+professions, titles and maxima. Remote HP was also verified; this does not
+claim observer profession or nano-stat publication through SCFU.
+
+The run passed 101 checks in
+`local/profession-resource-smoke/verification.json`, with UI screenshots,
+server profiles and read-only native probes. The fixture fills nano on cold
+start to isolate maxima/clamps; restart does not prove current-resource
+persistence or a canonical starting-nano rule. No client changes were needed.
+Both clients and the temporary server were closed before the full test runs.
+
+The focused resource tests passed in 9.642 seconds, and the full
+`go test ./server/...` run passed (server 92.478 seconds). A separate temporary
+extraction reproduced both coefficients and source report byte-for-byte.
+Five repeated race runs covering profession resources, profile-edit clamps
+and breed nano maxima passed in 94.395 seconds.
+Logs and reproduction hashes are in `local/profession-resource-research/`.
+
## Agg/Def slider request
`n3EngineClientAnarchy_t::N3Msg_SetAggDef`, original `0x1002b5b0`, creates
diff --git a/server/combat.go b/server/combat.go
@@ -118,19 +118,19 @@ func (character *character) maximumHealth() uint32 {
}
return 100
}
- // kkr.dll FUN_10075910; breed resources 1000203, Soldier titles 1000200/1.
+ // kkr.dll FUN_10075910; breed 1000203 and profession/title 1000200 coefficients.
stats := [8][3]uint32{{2, 2, 2}, {10, 6, 3}, {15, 5, 3}, {10, 5, 2}, {25, 6, 4}, {15, 8, 6}, {2, 2, 2}, {2, 2, 2}}[character.appearance>>4&7]
base := character.baseStats()
bodyDevelopment := base.effectiveSkill(base.BodyDevelopment, [6]uint32{0, 0, 100, 0, 0, 0})
- return stats[0] + uint32(character.level)*(stats[1]+character.titleLevel()-1) + bodyDevelopment*stats[2]
+ return stats[0] + uint32(character.level)*(stats[1]+gamedata.ProfessionTitles[max(1, character.profession)].Health[character.titleLevel()-1]) + bodyDevelopment*stats[2]
}
func (character *character) maximumNano() uint32 {
- // kkr.dll FUN_10075910; Soldier title rows contribute no extra nano.
+ // kkr.dll FUN_10075910 uses real profession and stored title, as for health.
stats := [8][3]uint32{{2, 2, 2}, {10, 4, 3}, {10, 3, 3}, {15, 5, 4}, {8, 2, 2}, {50, 2, 1}, {2, 2, 2}, {2, 2, 2}}[character.appearance>>4&7]
base := character.baseStats()
nanoPool := base.effectiveSkill(base.NanoPool, [6]uint32{0, 0, 10, 10, 10, 70})
- return stats[0] + uint32(character.level)*stats[1] + nanoPool*stats[2]
+ return stats[0] + uint32(character.level)*(stats[1]+gamedata.ProfessionTitles[max(1, character.profession)].Nano[character.titleLevel()-1]) + nanoPool*stats[2]
}
func (attacker *character) normalDamage(target *character, roll func(uint32) uint32) uint32 {
diff --git a/server/gamedata/load.go b/server/gamedata/load.go
@@ -28,6 +28,10 @@ var (
MapCoordinates MapCoordinateData
TerrainEvidence TerrainExtractionEvidence
Playfields map[uint32]Playfield
+ ProfessionTitles map[uint16]struct {
+ Health [6]uint32 `yaml:"health"`
+ Nano [6]uint32 `yaml:"nano"`
+ }
)
func init() {
@@ -47,6 +51,7 @@ func init() {
loadYAML("map_coordinates.yaml", &MapCoordinates)
loadYAML("terrain_evidence.yaml", &TerrainEvidence)
loadYAML("playfields.yaml", &Playfields)
+ loadYAML("profession_resources.yaml", &ProfessionTitles)
zones, err := fs.Glob(files, "zones/*.yaml")
if err != nil {
diff --git a/server/gamedata/profession_resources.yaml b/server/gamedata/profession_resources.yaml
@@ -0,0 +1,37 @@
+# Generated from 14.9.1 resource type 1000200.
+1:
+ health: [0, 1, 2, 3, 4, 5]
+ nano: [0, 0, 0, 0, 0, 0]
+2:
+ health: [0, 1, 1, 2, 3, 6]
+ nano: [0, 0, 0, 0, 0, 0]
+3:
+ health: [0, 0, 0, 0, 0, 0]
+ nano: [0, 1, 2, 3, 4, 5]
+4:
+ health: [0, 1, 1, 2, 3, 4]
+ nano: [0, 0, 0, 0, 0, 0]
+5:
+ health: [0, 1, 1, 2, 2, 3]
+ nano: [1, 1, 2, 2, 3, 3]
+6:
+ health: [0, 1, 2, 2, 3, 3]
+ nano: [0, 1, 1, 2, 2, 3]
+7:
+ health: [0, 0, 1, 1, 2, 3]
+ nano: [0, 1, 1, 1, 2, 3]
+8:
+ health: [0, 1, 1, 1, 2, 3]
+ nano: [0, 1, 1, 1, 2, 3]
+9:
+ health: [1, 2, 3, 4, 5, 6]
+ nano: [0, 0, 0, 0, 0, 0]
+10:
+ health: [0, 0, 0, 0, 0, 0]
+ nano: [0, 1, 2, 3, 4, 6]
+11:
+ health: [0, 0, 0, 0, 0, 0]
+ nano: [0, 1, 2, 3, 4, 6]
+12:
+ health: [0, 0, 0, 0, 0, 0]
+ nano: [0, 1, 2, 3, 4, 6]
diff --git a/server/profession_resources_test.go b/server/profession_resources_test.go
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+ "testing"
+)
+
+func TestProfessionResourcesReachFullCharacter(t *testing.T) {
+ for _, scenario := range []struct {
+ profession, level uint16
+ health, nano uint32
+ }{
+ {1, 1, 37, 35}, {1, 15, 136, 91}, {1, 50, 431, 231},
+ {1, 100, 931, 431}, {1, 150, 1531, 631}, {1, 190, 2121, 791},
+ {2, 50, 381, 231}, {2, 190, 2311, 791}, {3, 190, 1171, 1741},
+ {4, 50, 381, 231}, {4, 190, 1931, 791},
+ {5, 1, 37, 36}, {5, 190, 1741, 1361}, {6, 190, 1741, 1361},
+ {7, 190, 1741, 1361}, {8, 190, 1741, 1361},
+ {9, 1, 38, 35}, {9, 190, 2311, 791},
+ {10, 1, 37, 35}, {10, 14, 115, 87}, {10, 15, 121, 106},
+ {10, 49, 325, 276}, {10, 50, 331, 331}, {10, 99, 625, 625},
+ {10, 100, 631, 731}, {10, 149, 925, 1074}, {10, 150, 931, 1231},
+ {10, 189, 1165, 1543}, {10, 190, 1171, 1931},
+ {11, 190, 1171, 1931}, {12, 15, 121, 106}, {12, 190, 1171, 1931},
+ } {
+ 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()
+
+ packet := fullCharacterPacket(player)
+ stats := make(map[uint32]uint32)
+ count := binary.BigEndian.Uint32(packet[64:68])/1009 - 1
+ for offset := 68; offset < 68+int(count)*8; offset += 8 {
+ stats[binary.BigEndian.Uint32(packet[offset:])] = binary.BigEndian.Uint32(packet[offset+4:])
+ }
+
+ if stats[1] != scenario.health || stats[27] != scenario.health || stats[221] != scenario.nano ||
+ stats[60] != uint32(scenario.profession) {
+ t.Fatalf("profession resources: health=%d/%d nano=%d profession=%d", stats[27], stats[1], stats[221], stats[60])
+ }
+ })
+ }
+}
+
+func TestProfessionEditClampsResourcesAndPersistsCoefficients(t *testing.T) {
+ for _, scenario := range []struct {
+ from, to uint16
+ health, nano uint32
+ }{
+ {1, 10, 1171, 791}, {10, 1, 1171, 791},
+ } {
+ t.Run(fmt.Sprintf("%dto%d", scenario.from, scenario.to), func(t *testing.T) {
+ t.Chdir(t.TempDir())
+ world, _ := newCombatWorld()
+ player := world.newCharacter()
+ player.level, player.profession = 190, scenario.from
+ player.health, player.nano = player.maximumHealth(), player.maximumNano()
+ destination := player.userData()
+ destination.Profession = scenario.to
+
+ err := world.updateUser(destination)
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || world.characters[1].health != scenario.health || world.characters[1].nano != scenario.nano {
+ t.Fatalf("profession edit resources: health=%d nano=%d error=%v", world.characters[1].health, world.characters[1].nano, err)
+ }
+ if restored.profession != scenario.to || restored.maximumHealth() != world.characters[1].maximumHealth() ||
+ restored.maximumNano() != world.characters[1].maximumNano() {
+ t.Fatal("profession resource coefficients changed across restart")
+ }
+ })
+ }
+}
diff --git a/tools/data/extract_profession_resources.py b/tools/data/extract_profession_resources.py
@@ -0,0 +1,42 @@
+import hashlib
+import json
+import pathlib
+import struct
+
+import ao_database
+
+
+def main():
+ client = pathlib.Path('anarchy-vanilla-14.9.1')
+ assert (client / 'version.id').read_text().strip() == '14.9.1'
+ database = ao_database.Database(client)
+
+ # Extract only the original twelve professions supported by player profiles.
+ lines = ['# Generated from 14.9.1 resource type 1000200.']
+ records = []
+ for profession in range(1, 13):
+ raw = database.read(1000200, profession)
+ rows = list(struct.iter_unpack('<4i', raw))
+ assert [row[0] for row in rows] == [1, 15, 50, 100, 150, 190]
+ health = [row[2] for row in rows]
+ nano = [row[1] for row in rows]
+ assert all(value >= 0 for value in health + nano)
+ lines.extend([f'{profession}:', f' health: {json.dumps(health)}',
+ f' nano: {json.dumps(nano)}'])
+ records.append(dict(profession=profession, rows=rows, payload_hex=raw.hex(),
+ payload_sha256=hashlib.sha256(raw).hexdigest()))
+ database.close()
+
+ # Keep the consumed coefficients small and retain exact source bytes separately.
+ output = pathlib.Path('server/gamedata/profession_resources.yaml')
+ output.write_text('\n'.join(lines) + '\n')
+ report = pathlib.Path('local/reports/profession-resources-14.9.1.json')
+ report.parent.mkdir(parents=True, exist_ok=True)
+ report.write_text(json.dumps(dict(index_sha256=hashlib.sha256(database.index).hexdigest(),
+ records=records), indent=2) + '\n')
+ print(output)
+ print(report)
+
+
+if __name__ == '__main__':
+ main()