aorecomp

Anarchy Online classic in the browser

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


commit 19ebde862defbf582b48f5fcb34c8b9812d93e58
parent 12b9c7a2318902c505ae86fece1e69f6a445862a
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 04:06:07 +0000

Persist and replicate melee weapon skills

Diffstat:
MDEVELOPERS.md | 2+-
Mdocs/combat-regeneration.md | 17+++++++++++++++--
Mdocs/inventory.md | 20++++++++++++++++++++
Mserver/stats.go | 6+++++-
Mserver/stats_test.go | 42++++++++++++++++++++++++++++++++++++++++++
Mserver/target_protocol_test.go | 2+-
Mserver/users.go | 3++-
Mserver/world.go | 2++
8 files changed, 88 insertions(+), 6 deletions(-)

diff --git a/DEVELOPERS.md b/DEVELOPERS.md @@ -155,7 +155,7 @@ continues until you leave melee range. Player fists use the shipped QL 1 1.97 seconds recharge at centered aggression, or one second each at full aggression. The Stats window's DEF/AGG slider changes this setting. Player health uses breed/level/Body Development and Soldier title data (37 HP for the -default level 1 Solitus). Six abilities and four combat skills are editable in +default level 1 Solitus). Six abilities and eight trained skills are editable in the character page's stats section and persist in player.yaml. Health, nano, initiative timing and regeneration derive from those base values. Absolute resource corrections reconcile client prediction outside active weapon queues; diff --git a/docs/combat-regeneration.md b/docs/combat-regeneration.md @@ -9,7 +9,7 @@ server's scheduler is not established by those rules. ## Character data The existing character editor at `/users/<id>` includes a persistent `stats` -section. All six abilities and four currently used combat skills are editable: +section. All six abilities and eight trained skills are editable: ```yaml stats: @@ -20,6 +20,10 @@ stats: sense: 10 psychic: 120 martial_arts: 100 + one_hand_edged: 5 + melee_initiative: 5 + brawling: 5 + fast_attack: 5 physical_initiative: 600 body_development: 200 nano_pool: 100 @@ -32,7 +36,11 @@ Agility, Stamina, Intelligence, Sense, Psychic: | Skill | Weights | | --- | --- | | Martial Arts 100 | 20,50,0,0,0,30 | +| 1h Edged 103 | 30,40,30,0,0,0 | +| Melee Initiative 118 | 0,10,0,10,60,20 | | Physical Initiative 120 | 0,10,0,10,60,20 | +| Brawling 142 | 60,0,40,0,0,0 | +| Fast Attack 147 | 0,60,0,0,40,0 | | Body Development 152 | 0,0,100,0,0,0 | | Nano Pool 132 | 0,0,10,10,10,70 | @@ -50,7 +58,12 @@ float store before AggDef subtraction. At effective initiative 387 and AggDef -100, recharge truncates to 170 centiseconds; the algebraically simplified division would give 171. This boundary is covered by a regression test. -Older profiles with no stats retain abilities 10 and these four base skills 5. +Older profiles with no stats retain abilities 10 and these eight base skills 5. +Profiles saved before the four melee skills were added receive base values 5 +for the missing fields. Explicitly saved zero skill values remain zero. The +native Skills window displays 7 for each new skill at the default abilities, +including ability trickle. These fields prepare the weapon equipment milestone; +server attacks still use fists and Physical Initiative. Saving writes the explicit stats to `data/players/<id>/player.yaml`. Values survive profile edits, teleporting and restart; location saving still writes only `position.yaml`. Lowering resource maximums clamps current health/nano. diff --git a/docs/inventory.md b/docs/inventory.md @@ -98,6 +98,26 @@ existing FIFO output queue. Manual WASM evidence is retained locally under `local/inventory-smoke/`: QL 1 details, native rearrangement, held menu, confirmation, deletion and packet logs. + +## Melee equipment investigation + +The next fixture uses QL 1 Kinetic Axe, template 209283, from +`server/gamedata/items/items_165.yaml`. Its Wield action requires 1h Edged 103, +Fast Attack 147 and Brawling 142 each greater than 4. The shipped skill-weight +resources are recorded in [editable stats](combat-regeneration.md). The item has +5..20 base damage, attack/recharge delays 125 centiseconds and equip delay 150 +centiseconds. These are catalog values, before combat modifiers. + +The shipped help file `cd_image/text/help/How to Wear and equip things.txt` +documents left-click pickup and placement into Wear. Capturing that path in +the WASM client produced `ContainerAddItem` with source page 104, source slot +64, target character identity and destination 6 (right hand). Taking it back +into inventory produced source page 101, slot 6, and destination 111 (next free +inventory slot). A temporary server probe echoing the move changed the native +inventory/Wear icons but did not draw the weapon on the actor. Production still +rejects these equipment moves; appearance, weapon binding, requirements and +equip timing must be implemented together before checking off that milestone. +Local captures and the temporary probe are in `local/equipment-smoke/`. The isolated fixture grants one pistol before native world initialization. Deletion was checked after reload, and a second simultaneous WASM visitor showed only its own pistol while the first visitor's inventory stayed empty. The diff --git a/server/stats.go b/server/stats.go @@ -8,13 +8,17 @@ type characterStats struct { Sense uint16 `yaml:"sense"` Psychic uint16 `yaml:"psychic"` MartialArts uint16 `yaml:"martial_arts"` + OneHandEdged uint16 `yaml:"one_hand_edged"` + MeleeInitiative uint16 `yaml:"melee_initiative"` + Brawling uint16 `yaml:"brawling"` + FastAttack uint16 `yaml:"fast_attack"` PhysicalInitiative uint16 `yaml:"physical_initiative"` BodyDevelopment uint16 `yaml:"body_development"` NanoPool uint16 `yaml:"nano_pool"` } func defaultCharacterStats() characterStats { - return characterStats{10, 10, 10, 10, 10, 10, 5, 5, 5, 5} + return characterStats{10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5} } func (character *character) baseStats() characterStats { diff --git a/server/stats_test.go b/server/stats_test.go @@ -2,6 +2,8 @@ package main import ( "encoding/binary" + "os" + "strings" "testing" "time" ) @@ -11,6 +13,7 @@ func TestCharacterStatsDeriveHealthNanoAndAttackTiming(t *testing.T) { stats.Stamina, stats.Psychic = 60, 120 stats.BodyDevelopment, stats.NanoPool = 200, 100 stats.MartialArts, stats.PhysicalInitiative = 100, 100 + stats.OneHandEdged, stats.MeleeInitiative, stats.Brawling, stats.FastAttack = 4, 20, 6, 7 data := userData{ID: 1, Level: 1, Appearance: 1 << 4, Stats: stats} player := data.character() @@ -28,6 +31,9 @@ func TestCharacterStatsDeriveHealthNanoAndAttackTiming(t *testing.T) { if values[18] != 60 || values[21] != 120 || values[100] != 100 || values[120] != 100 || values[152] != 200 || values[132] != 100 { t.Fatalf("base stats sent as effective skills: %v", values) } + if values[103] != 4 || values[118] != 20 || values[142] != 6 || values[147] != 7 { + t.Fatalf("melee base skills: %v", values) + } } func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { @@ -36,6 +42,8 @@ func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { destination := player.userData() destination.Stats.Stamina = 60 destination.Stats.BodyDevelopment = 200 + destination.Stats.OneHandEdged, destination.Stats.MeleeInitiative = 0, 120 + destination.Stats.Brawling, destination.Stats.FastAttack = 25, 15 if err := world.updateUser(destination); err != nil { t.Fatal(err) @@ -45,6 +53,40 @@ func TestCharacterStatsPersistThroughProfileEditAndRestart(t *testing.T) { if restarted.characters[1].baseStats().Stamina != 60 || restarted.characters[1].baseStats().BodyDevelopment != 200 || restarted.characters[1].health != 658 { t.Fatalf("stats lost across restart: %+v", restarted.characters[1]) } + if restarted.characters[1].baseStats() != destination.Stats { + t.Fatalf("trained skills lost across restart: %+v", restarted.characters[1].baseStats()) + } +} + +func TestCharacterStatsLoadMissingMeleeSkills(t *testing.T) { + world := newTestServer(t) + player := world.newCharacter() + player.stats.Strength, player.stats.MartialArts = 30, 0 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + contents, err := os.ReadFile("data/players/1/player.yaml") + if err != nil { + t.Fatal(err) + } + profile := string(contents) + for _, field := range []string{"one_hand_edged", "melee_initiative", "brawling", "fast_attack"} { + profile = strings.ReplaceAll(profile, " "+field+": 5\n", "") + } + if strings.Contains(profile, "one_hand_edged") { + t.Fatal("fixture still contains the new skills") + } + if err := os.WriteFile("data/players/1/player.yaml", []byte(profile), 0600); err != nil { + t.Fatal(err) + } + + restarted := newServer() + stats := restarted.characters[1].baseStats() + + if stats.Strength != 30 || stats.MartialArts != 0 || stats.OneHandEdged != 5 || + stats.MeleeInitiative != 5 || stats.Brawling != 5 || stats.FastAttack != 5 { + t.Fatalf("older profile skills: %+v", stats) + } } func TestCharacterStatsProfileEditClampsBothResources(t *testing.T) { diff --git a/server/target_protocol_test.go b/server/target_protocol_test.go @@ -82,7 +82,7 @@ initialized: if hex.EncodeToString(npc[60:89]) != "000001cb0b456469746564204e50430000000000000000000000000007" { t.Fatalf("target NPC appearance, name and new stats: %x", npc[60:89]) } - if hex.EncodeToString(full[57:73]) != "000003f10000667a0000003600000001" { + if hex.EncodeToString(full[57:73]) != "000003f10000763e0000003600000001" { t.Fatalf("target seventh list and first stat: %x", full[57:73]) } } diff --git a/server/users.go b/server/users.go @@ -136,7 +136,8 @@ func (server *server) loadUsers() error { if err != nil { return err } - var profile playerProfile + // Missing trained skills in older profiles retain their starting values. + profile := playerProfile{Stats: defaultCharacterStats()} if err := decodeUsers(bytes.NewReader(contents), &profile); err != nil { return fmt.Errorf("%s: %w", path, err) } diff --git a/server/world.go b/server/world.go @@ -160,6 +160,8 @@ func fullCharacterPacket(character *character) []byte { stats = append(stats, [2]uint32{214, character.nano}, [2]uint32{221, character.maximumNano()}) stats = append(stats, [2]uint32{100, uint32(base.MartialArts)}, [2]uint32{120, uint32(base.PhysicalInitiative)}, [2]uint32{152, uint32(base.BodyDevelopment)}, [2]uint32{132, uint32(base.NanoPool)}) + stats = append(stats, [2]uint32{103, uint32(base.OneHandEdged)}, [2]uint32{118, uint32(base.MeleeInitiative)}, + [2]uint32{142, uint32(base.Brawling)}, [2]uint32{147, uint32(base.FastAttack)}) body = binary.BigEndian.AppendUint32(body, uint32(len(stats)+1)*1009) for _, stat := range stats { body = binary.BigEndian.AppendUint32(body, stat[0])