aorecomp

Anarchy Online classic in the browser

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


commit 49067b3650099f5af0ee98290751228ac71602fe
parent d9ff8a1a58e0df1b35da4a2eb54505dd9782a6b5
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 22:47:18 +0000

Support Yalmaha flight and preserve mode across zoning

Diffstat:
MTODO.md | 13+++++++++----
Mdocs/combat-client-effect-handlers.md | 2+-
Mdocs/vehicles.md | 109++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mserver/appearance_test.go | 12+++++++-----
Mserver/equipment.go | 7++++++-
Aserver/flying_vehicle_test.go | 273+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/main_test.go | 2+-
Mserver/stats.go | 3++-
Mserver/target_protocol_test.go | 2+-
Mserver/vehicle.go | 15++++++++++++++-
Mserver/world.go | 15+++++++++++----
Mserver/zoning.go | 16++++++++++++++--
Mtools/data/extract_vehicle.py | 11++++++++++-
13 files changed, 454 insertions(+), 26 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -348,7 +348,7 @@ checks are recorded in [treatment kits](docs/treatment-kit.md). textured surfaces render for the driver and observer after equip and reconnect. - [x] Re-equip the Kodaik after removing it without reconnecting. Check: using the returned inventory item emits a native wear request and restores the car. -- [ ] Use one flying vehicle. Check: altitude and movement modes replicate to an +- [x] Use one flying vehicle. Check: altitude and movement modes replicate to an observer and zoning does not leave the character stuck in the wrong mode. - [x] Resolve one currently unmapped door. Check: source evidence identifies its eligibility and destination, and a real client can make the round trip. @@ -366,11 +366,16 @@ and the provisional exit envelope are in QL 15 Kodaik Turbo IX supports HUD1 equip/removal, skill and outdoor checks, native model/scale/fighting effects, and sourced movement changes. Two WASM -clients verified restart and removal without duplicated bonuses. Its body -currently renders white despite the shipped metal/glass textures; the remaining -renderer diagnosis and indoor playshift uncertainty are recorded in +clients verified restart, shipped materials and repeated removal/reuse without +duplicated bonuses. Source evidence and indoor playshift uncertainty are in [ground vehicles](docs/vehicles.md). +QL 30 Yalmaha XL - 29478 supports native flight effects, Vehicle Air checks, +three-dimensional movement prediction and textured appearance. Two WASM clients +verified altitude replication, an Entertainment/Omni Forest round trip, restart +and removal back to running mode. The reconstructed boundary altitude policy +and unresolved indoor lifecycle are explicit in [flight](docs/vehicles.md#yalmaha-flight). + ## Pets - [ ] Summon one pet. Check: one owned entity appears to its owner and an diff --git a/docs/combat-client-effect-handlers.md b/docs/combat-client-effect-handlers.md @@ -218,7 +218,7 @@ render/text/appearance call; an evocative name alone was not enough. | 53130 unnamed | `100c2810` | Partial: invokes `10061bc0`, clearing a controller identity via `1005f270`. | | 53132 GenerateName | `100bdf60` | Decoded presentation: applies supplied name strings through `10070f40`. | | 53134 unnamed | `100c2840` | Decoded presentation: text to local actor or within an argument-specified 3D radius. | -| 53138 unnamed | `100c1cc0` | Partial presentation: actor animation/state notifications 27 and 35. | +| 53138 flight | `100c1cc0` | Movement events 27/35 enter flight mode 7 and restore the saved ground mode; see [vehicles](vehicles.md#yalmaha-flight). | | 53139 unnamed | `100c2980` | Decoded: set a bit in a stat. | | 53140 unnamed | `100c29e0` | Decoded: clear a bit in a stat. | | 53162 unnamed | `100c2aa0` | Decoded no-op through `1010ba00`. | diff --git a/docs/vehicles.md b/docs/vehicles.md @@ -1,10 +1,10 @@ -# Kodaik ground vehicle in 14.9.1 +# Vehicles in 14.9.1 -The supported vehicle is the exact QL 15 Kodaik Turbo IX, template 117294, +The supported ground vehicle is the exact QL 15 Kodaik Turbo IX, template 117294, native item type 51022. Its owned identity remains stable when moving between ordinary inventory and HUD1 (slot 1, equipment page 101). Acquisition can use the existing test fixture grant; no vehicle provisioning interface is added. -Other qualities and vehicles are not inferred from this endpoint. +The flying endpoint is documented below; other qualities are not interpolated. ## Authored requirements and effects @@ -163,7 +163,8 @@ would instead copy the mesh's default mappings, but would lose our explicit human skin selection. The combined list preserves both supported forms; it is a reconstruction using shipped mappings, not an original server capture. -Seven rows use encoded count 8072, `(7+1)*1009`. The 14.9.1 readers in +The combined list includes five human, two Kodaik and two Yalmaha rows, using +encoded count 10090, `(9+1)*1009`. The 14.9.1 readers in `kkr.dll` (`1015b580`, `1015b540`) consume that count and fixed 32-byte material names followed by three DWORDs. The shared-protocol converter honors the count when padding names. Human NPCs retain their five-entry list. @@ -229,3 +230,103 @@ passes over snapshot item kinds and armor, belt, implant, weapon and backpack restoration passed in 95.493 seconds. Regression tests retain live flags for the actual weapon and Chest paths while rejecting live flags for template equipment. + +## Yalmaha flight + +The exact QL 30 Yalmaha XL - 29478, template 117322, uses item type 51022, +HUD1 and a ten-second equip/removal delay. Its Wear action requires outdoor +stat 438 equal to 1, effective Vehicle Air 139 greater than 80, InBattle 410 +zero and Form 359 zero. The persisted `vehicle_air` skill defaults to 5, +from native `kkr.dll` `10072768` / `10072a05`. Its ability weights are +`[0,20,0,20,60,0]`, so the fixture's trained 78/79 gives effective 80/81. +Eligibility is checked at both ends of the delay; removal needs no skill. + +The item authors these OnWear functions in order: + +| Function | Arguments | Effect | +| --- | --- | --- | +| Modify 53045 | 156, 150 | Add 150 Run Speed. | +| RestrictAction 53068 | 2, 0 | Clear the fighting feature. | +| ChangeStat 53110 | 360, 20 | Set Scale 20 and retain the original. | +| 53138 | none | Enter flight; leave it on removal. | +| ChangeShape 53060 | 99470, 0 | Use the sleek vehicle model. | + +Function 53138's handler `100c1cc0` sends movement event 27 on wear and 35 +on removal. The native transition table at `10045220` enters mode 7 and +restores the separately saved ground mode, respectively. SwitchToFly +`10046770` disables falling, raises relative Y by 0.5 and selects orientation +mode 4. LeaveFly `100468f0` enables falling, raises Y by 0.1 and restores +orientation from stat 197. Removal lets native collision settle the character; +the server does not teleport it directly to the ground. + +The initial SimpleChar movement snapshot carries current mode 7 and remembers +walking 2 or running 3 in the separate DWORD. The reader `10047160` and setter +`100496d5` keep these fields distinct. Mode refresh `10046f80` restores flight +without raising Y; the subsequent ordinary worn-item initialization applies +its one 0.5 m lift. Owner FullCharacter and observer TemplateAction still +apply the authored effects once, with raw base RunSpeed 100. + +Mode 7's maximum-speed branch `10047e60` passes base 12 to `10047af0`, adds +`0.005 * adjustedRunSpeed`, caps at 15 before encumbrance and floors at 0.1 +afterward. Forward and reverse use the same configured maximum, 13.25 m/s +for the healthy, unencumbered fixture. Flight's forward vector includes +quaternion Y component `2*y*z - 2*x*w`; reverse negates all three components. +The bounded server estimate uses this speed and full direction. Acceleration, +collision and encumbrance remain outside that estimate. + +The shipped controls use plain RMB mouse movement to pitch the character in +first-person or locked third-person. Free third-person and Ctrl+RMB can move +only the camera. Native `ccr.dll` `100041f0` / `10004350` routes character +mouselook to `kkr.dll` `10020520`, `1004bd30`, then `10049f10`, which applies +vertical mouse delta to the flight quaternion. Space remains Jump and +PageUp/PageDown scroll chat. No client adapter changes are needed for flight. + +Model 99470 uses mesh 42370, `sleek_vehicle_cat.cir`, with exact texture rows +`{Material #7,38586,38585,0}` and `{Material #8,38584,38585,0}`. Both primary +and secondary identities are included in the player's initial material list. +The renderer displays the shipped silver/glass surfaces. + +Outdoor wall crossings retain absolute flight altitude, raised if needed to +clear destination terrain by 0.5 m. This is a provisional reconstruction: +original server altitude policy and ceilings are not established. Authored +door arrival transforms still control their own height. The item's separate +Playshift action checks outdoor type and Form, as for the Kodaik; indoor +suppression, automatic removal and full-inventory fallback remain unresolved. + +`python3 tools/data/extract_vehicle.py` retains the selected flight item and +Vehicle Air weights alongside the ground vehicle report. Item payload SHA-256: +`78130e994ef9717d005c230375582107b15089c122db0182900153395ed3733e`. +Exact item, model, material, transition, speed and control evidence is in +`local/flying-vehicle-research/native-flight.json`, `server-flight-review.json` +and `flight-specifics.json`, with original DLL bytes and source addresses. + +`TestFlyingVehicle*` checks the ten-second equip deadline, strict 80/81 skill +boundary, separate ground/air skills, outdoor/combat requirements and delayed +revalidation. It covers removal without skill, persisted identity and effects, +fighting restriction, observer publication, mode 7 with saved mode 2/3, +forward/reverse pitched prediction, terrain clearance and flight altitude at +boundary arrivals. A captured native airborne CharDCMove verifies that altitude +and pitch reach an observer and persist through restart. The prediction and +arrival regressions failed before their respective fixes. + +Two real WASM clients verified native equip at 81, denial at 80, configured +speed 13.25, textured model 99470, Scale 20 and Features 4. Gradual plain-RMB +pitch and forward movement raised the driver from approximately 17 m to 65 m; +the observer's altitude agreed within the native 1/16 m resolution. Removal +restored ordinary effects and native falling. A second isolated run started +worn near the Entertainment boundary at 70 m, crossed into Omni Forest, +restarted the server and returned to Entertainment. Both clients retained mode +7, saved running mode 3 and one speed bonus. Removing HUD1 after that round trip +restored mode 3 and settled onto the city roof; ordinary movement still worked. +Health and owned item identity/count stayed unchanged. + +The manual runs passed 30 evidence checks in +`local/flying-vehicle-smoke/verification.json`, with screenshots, native packets +and read-only guest-memory probes beside it. Only expected connection refusals +during the intentional restart were recorded. No native functions were called +from probes and no guest memory was modified. Both clients and the temporary +server were closed before the full test runs. + +The full maintained server suite passed in 91.813 seconds. +Five race-enabled passes over flying/ground vehicle lifecycle, movement, +reconnect snapshots and materials passed in 109.844 seconds. diff --git a/server/appearance_test.go b/server/appearance_test.go @@ -6,19 +6,21 @@ import ( "testing" ) -func TestPlayerAppearanceIncludesKodaikMaterials(t *testing.T) { +func TestPlayerAppearanceIncludesVehicleMaterials(t *testing.T) { player := &character{id: 1, name: "Driver", appearance: 0x515, level: 1} packet := targetPacket(characterPacket(player)) start := bytes.Index(packet, []byte("arms\x00")) - if start < 4 || binary.BigEndian.Uint32(packet[start-4:start]) != 8072 { - t.Fatal("player texture list does not contain seven materials") + if start < 4 || binary.BigEndian.Uint32(packet[start-4:start]) != 10090 { + t.Fatal("player texture list does not contain nine materials") } for _, material := range []struct { name string texture uint32 - }{{"Material #2b", 30043}, {"Material #2a", 30044}} { + second uint32 + }{{"Material #2b", 30043, 0}, {"Material #2a", 30044, 0}, + {"Material #7", 38586, 38585}, {"Material #8", 38584, 38585}} { name := make([]byte, 32) copy(name, material.name) start := bytes.Index(packet, name) @@ -26,7 +28,7 @@ func TestPlayerAppearanceIncludesKodaikMaterials(t *testing.T) { t.Fatalf("missing vehicle material %s", material.name) } values := packet[start+32:] - if binary.BigEndian.Uint32(values) != material.texture || binary.BigEndian.Uint32(values[4:]) != 0 || binary.BigEndian.Uint32(values[8:]) != 0 { + if binary.BigEndian.Uint32(values) != material.texture || binary.BigEndian.Uint32(values[4:]) != material.second || binary.BigEndian.Uint32(values[8:]) != 0 { t.Fatalf("incorrect vehicle texture for %s: %x", material.name, values[:12]) } } diff --git a/server/equipment.go b/server/equipment.go @@ -21,7 +21,7 @@ func (item ownedItem) isKineticAxe() bool { } func (item ownedItem) fitsEquipmentSlot(slot uint32) bool { - if item.isKodaik() { + if item.isKodaik() || item.isYalmaha() { return slot == 1 } if item.isKineticAxe() { @@ -53,6 +53,11 @@ func (character *character) canEquip(item ownedItem) bool { return gamedata.Playfields[character.playfield].Outdoor && !character.driving() && stats.effectiveSkill(stats.VehicleGround, [6]uint32{0, 20, 0, 20, 60, 0}) > 80 } + if item.isYalmaha() { + stats := character.baseStats() + return gamedata.Playfields[character.playfield].Outdoor && !character.driving() && + stats.effectiveSkill(stats.VehicleAir, [6]uint32{0, 20, 0, 20, 60, 0}) > 80 + } if item.fitsEquipmentSlot(7) || item.fitsEquipmentSlot(9) { stats := character.baseStats() return stats.effectiveSkill(stats.ComputerLiteracy, [6]uint32{0, 0, 0, 100, 0, 0}) > 5 diff --git a/server/flying_vehicle_test.go b/server/flying_vehicle_test.go @@ -0,0 +1,273 @@ +package main + +import ( + "bytes" + "encoding/binary" + "encoding/hex" + "encoding/json" + "math" + "net/http/httptest" + "testing" + "time" +) + +func newFlyingVehicleWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() + t.Chdir(t.TempDir()) + world, conn := newCombatWorld() + player := world.newCharacter() + player.playfield, player.position = 800, [3]float32{600, 67, 700} + player.stats.VehicleAir = 79 // Effective 81 with the fixture's abilities. + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if granted, err := world.grantItem_locked(player, 117322); err != nil || !granted { + t.Fatal(granted, err) + } + return world, conn +} + +func TestFlyingVehicleEquipRemovalAndRestart(t *testing.T) { + world, conn := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + observer := &combatTestConn{} + world.characters[2] = &character{id: 2, playfield: 800, health: 100} + world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true} + started := time.Now() + + if err := world.handleInventory(client, inventoryMovePacket(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + if client.equipment == nil || client.equipment.readyAt.Before(started.Add(10*time.Second)) || + client.equipment.readyAt.After(time.Now().Add(10*time.Second)) { + t.Fatal("Yalmaha did not schedule its authored ten-second HUD1 equip") + } + world.advanceEquipment(client.equipment.readyAt.Add(-time.Nanosecond)) + if len(conn.packets) != 0 || player.inventory.Items[0].Slot != 64 { + t.Fatal("Yalmaha appeared before the equip delay expired") + } + world.advanceEquipment(client.equipment.readyAt) + restored := newTestInventoryServer(t).characters[1] + if !restored.flying() || restored.stats.VehicleAir != 79 || restored.inventory.equipmentBonus(156) != 150 || + restored.inventory.Items[0] != (ownedItem{1, 51022, 117322, 30, 1, 1}) || len(equippedItemPackets(restored)) != 1 { + t.Fatal("worn Yalmaha, flight effects or trained skill did not survive restart") + } + world.characters[1000000].playfield, world.characters[1000000].position = 800, player.position + if err := world.handleCombat(client, attackPacket(1, 1000000)[20:]); err != nil || player.fighting != 0 { + t.Fatal("a Yalmaha pilot started fighting") + } + player.stats.VehicleAir = 0 + if err := world.handleInventory(client, itemMovePacket(1, 1, 111)[20:]); err != nil { + t.Fatal(err) + } + if client.equipment == nil { + t.Fatal("removal incorrectly required Vehicle Air") + } + world.advanceEquipment(client.equipment.readyAt) + restored = newTestInventoryServer(t).characters[1] + + if restored.flying() || restored.driving() || restored.inventory.equipmentBonus(156) != 0 || + restored.inventory.Items[0] != (ownedItem{1, 51022, 117322, 30, 64, 1}) || len(equippedItemPackets(restored)) != 0 { + t.Fatal("removing the Yalmaha lost its identity or retained its effects") + } + if len(observer.packets) != 2 || binary.BigEndian.Uint32(observer.packets[0][45:49]) != 6 || + binary.BigEndian.Uint32(observer.packets[1][45:49]) != 7 || len(conn.packets) != 5 { + t.Fatal("owner and observer did not receive one native wear and removal effect") + } +} + +func TestFlyingVehicleRejectsIneligibleEquipment(t *testing.T) { + for _, scenario := range []string{"skill 80", "ground skill only", "indoor", "Grid", "outgoing combat", "incoming combat", "wrong quality", "wrong slot"} { + t.Run(scenario, func(t *testing.T) { + world, conn := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + request := inventoryMovePacket(1, 64, 1)[20:] + switch scenario { + case "skill 80": + player.stats.VehicleAir = 78 + case "ground skill only": + player.stats.VehicleAir, player.stats.VehicleGround = 5, 79 + case "indoor": + player.playfield = 1183 + case "Grid": + player.playfield = 152 + case "outgoing combat": + player.fighting = 1000000 + world.fighting[1] = player + case "incoming combat": + world.characters[1000000].fighting = 1 + world.fighting[1000000] = world.characters[1000000] + case "wrong quality": + player.inventory.Items[0].Quality = 29 + case "wrong slot": + binary.BigEndian.PutUint32(request[32:36], 2) + } + + if err := world.handleInventory(client, request); err != nil { + t.Fatal(err) + } + + if client.equipment != nil || player.inventory.Items[0].Slot != 64 || len(conn.packets) > 1 { + t.Fatal("ineligible Yalmaha changed equipment or published effects") + } + }) + } +} + +func TestFlyingVehicleRechecksRequirementsAfterDelay(t *testing.T) { + for _, scenario := range []string{"skill", "playfield", "combat"} { + t.Run(scenario, func(t *testing.T) { + world, conn := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + if err := world.handleInventory(client, inventoryMovePacket(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + finish := client.equipment.readyAt + switch scenario { + case "skill": + player.stats.VehicleAir = 78 + case "playfield": + player.playfield = 1183 + case "combat": + world.characters[1000000].fighting = 1 + world.fighting[1000000] = world.characters[1000000] + } + + world.advanceEquipment(finish) + + if player.inventory.Items[0].Slot != 64 || player.flying() || len(conn.packets) != 1 { + t.Fatal("Yalmaha used stale eligibility from the start of its equip delay") + } + }) + } +} + +func TestFlyingVehiclePredictsPitchedForwardAndReverse(t *testing.T) { + for _, scenario := range []struct { + name string + running bool + forward float32 + y, z float32 + }{ + {"forward", true, 1, 254.3833, 887.3833}, + {"reverse", true, -1, -120.3833, 512.6167}, + {"walking selected", false, 1, 254.3833, 887.3833}, + } { + t.Run(scenario.name, func(t *testing.T) { + world, _ := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + player.inventory.Items[0].Slot = 1 + player.running = scenario.running + player.rotation = [4]float32{-0.38268343, 0, 0, 0.9238795} + client.forward, client.movementStarted = scenario.forward, time.Now().Add(-30*time.Second) + response := httptest.NewRecorder() + + world.mapPlayers(response, httptest.NewRequest("GET", "/map/players", nil)) + var result struct{ Players []mapPlayer } + if err := json.Unmarshal(response.Body.Bytes(), &result); err != nil { + t.Fatal(err) + } + + if len(result.Players) != 1 || math.Abs(float64(result.Players[0].Position[1]-scenario.y)) > 0.0001 || math.Abs(float64(result.Players[0].Position[2]-scenario.z)) > 0.0001 { + t.Fatalf("pitched flight prediction: %+v", result.Players) + } + }) + } +} + +func TestFlyingVehicleSnapshotPreservesGroundMode(t *testing.T) { + for _, running := range []bool{false, true} { + t.Run(map[bool]string{false: "walking", true: "running"}[running], func(t *testing.T) { + player := &character{id: 1, name: "Pilot", appearance: 0x515, level: 1, running: running, + inventory: playerInventory{Items: []ownedItem{{1, 51022, 117322, 30, 1, 1}}}} + + packet := targetPacket(characterPacket(player)) + start := bytes.Index(packet, []byte("Pilot\x00")) + len("Pilot") + 40 + vehicle := packet[start : start+28] + + previous := uint32(2) + if running { + previous = 3 + } + if vehicle[12] != 7 || binary.BigEndian.Uint32(vehicle[22:26]) != previous { + t.Fatalf("flight snapshot mode/previous mode: %x", vehicle) + } + }) + } +} + +func TestFlyingVehicleBoundaryArrivalPreservesAltitude(t *testing.T) { + for _, scenario := range []struct { + name string + flying bool + altitude float32 + want float32 + }{ + {"airborne", true, 67, 67}, + {"terrain clearance", true, 10, 20.5}, + {"grounded", false, 67, 20.5}, + } { + t.Run(scenario.name, func(t *testing.T) { + world, _ := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + player.position = [3]float32{600, scenario.altitude, 700} + if scenario.flying { + player.inventory.Items[0].Slot = 1 + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + } + world.zoneLinks = map[string]map[uint32]zoneLinks{"target": {800: {Walls: []zoneWall{{ + Start: [3]float32{590, 0, 700}, End: [3]float32{610, 0, 700}, Destination: 716, + ArrivalStart: [3]float32{100, 0, 100}, ArrivalEnd: [3]float32{120, 0, 100}, + }}}}} + world.terrain = map[uint32]*terrain{716: {width: 1, height: 1, spacing: 200, scale: 1, heights: []byte{20, 20, 20, 20}}} + request := npcMovementPacket(player, 2)[20:] + request = append(request[:16:16], encodeMovement1491(request[16:])...) + + if err := world.handleMovement(client, request); err != nil { + t.Fatal(err) + } + if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if restored.playfield != 716 || restored.position != [3]float32{110, scenario.want, 108} || restored.flying() != scenario.flying || + player.rotation != [4]float32{0, 0, 0, 1} || len(restored.inventory.Items) != 1 { + t.Fatalf("flight boundary arrival: %+v", restored.userData()) + } + }) + } +} + +func TestFlyingVehicleCapturedAltitudeReachesObserverAndRestart(t *testing.T) { + world, _ := newFlyingVehicleWorld(t) + player, client := world.characters[1], world.clients[1] + observer := &combatTestConn{} + world.characters[2] = &character{id: 2, playfield: 800, health: 100} + world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true} + compact, err := hex.DecodeString("021c20041714efd6c60000000030f30000") + if err != nil { + t.Fatal(err) + } + request := npcMovementPacket(player, 2)[20:36] + request = append(request, compact...) + + if err := world.handleMovement(client, request); err != nil { + t.Fatal(err) + } + if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if restored.position != [3]float32{900, 65.4375, 669.875} || math.Abs(float64(restored.rotation[0])+0.644166) > 0.0001 || + math.Abs(float64(restored.rotation[3])-0.764886) > 0.0001 || len(observer.packets) != 1 { + t.Fatalf("captured airborne position/pitch was lost: %+v", restored.userData()) + } + relay := observer.packets[0] + if binary.BigEndian.Uint32(relay[16:20]) != 0x54111123 || binary.BigEndian.Uint16(relay[32:34]) != 1047 { + t.Fatalf("observer did not receive the captured sixteenth-metre altitude: %x", relay) + } +} diff --git a/server/main_test.go b/server/main_test.go @@ -363,7 +363,7 @@ func TestWorldCookieThenPing(t *testing.T) { if hex.EncodeToString(updates[1][37:41]) != "000002d8" || hex.EncodeToString(updates[1][154:158]) != "00009eea" { t.Fatalf("player head mesh: %x", updates[1]) } - if hex.EncodeToString(updates[1][159:163]) != "00001f88" || hex.EncodeToString(updates[1][197:215]) != "68616e647300000022450000000000000000" { + if hex.EncodeToString(updates[1][159:163]) != "0000276a" || hex.EncodeToString(updates[1][197:215]) != "68616e647300000022450000000000000000" { t.Fatalf("original named hand texture: %x", updates[1][159:215]) } var leet []byte diff --git a/server/stats.go b/server/stats.go @@ -19,10 +19,11 @@ type characterStats struct { ComputerLiteracy uint16 `yaml:"computer_literacy"` FirstAid uint16 `yaml:"first_aid"` VehicleGround uint16 `yaml:"vehicle_ground"` + VehicleAir uint16 `yaml:"vehicle_air"` } func defaultCharacterStats() characterStats { - return characterStats{10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5} + return characterStats{10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5} } func (character *character) baseStats() characterStats { 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]) != "000003f1000082110000003600000001" { + if hex.EncodeToString(full[57:73]) != "000003f1000086020000003600000001" { t.Fatalf("target seventh list and first stat: %x", full[57:73]) } } diff --git a/server/vehicle.go b/server/vehicle.go @@ -4,9 +4,22 @@ func (item ownedItem) isKodaik() bool { return item.Type == 51022 && item.Template == 117294 && item.Quality == 15 } +func (item ownedItem) isYalmaha() bool { + return item.Type == 51022 && item.Template == 117322 && item.Quality == 30 +} + func (character *character) driving() bool { for _, item := range character.inventory.Items { - if item.Slot == 1 && item.isKodaik() { + if item.Slot == 1 && (item.isKodaik() || item.isYalmaha()) { + return true + } + } + return false +} + +func (character *character) flying() bool { + for _, item := range character.inventory.Items { + if item.Slot == 1 && item.isYalmaha() { return true } } diff --git a/server/world.go b/server/world.go @@ -109,7 +109,11 @@ func characterPacket(character *character) []byte { if character.running { vehicle[12] = 3 } - binary.BigEndian.PutUint32(vehicle[22:26], 2) + // Flight retains the ground speed mode used when its effect is removed. + binary.BigEndian.PutUint32(vehicle[22:26], uint32(vehicle[12])) + if character.flying() { + vehicle[12] = 7 + } body = binary.BigEndian.AppendUint32(body, uint32(len(vehicle))) body = append(body, vehicle...) if human { @@ -130,7 +134,7 @@ func characterPacket(character *character) []byte { if character.npc { body = binary.BigEndian.AppendUint32(body, 6054) } else { - body = binary.BigEndian.AppendUint32(body, 8072) + body = binary.BigEndian.AppendUint32(body, 10090) } textures := [5]uint32{8714, 8710, 8773, 8713, 8709} if character.appearance>>4&7 == 1 && character.appearance>>7&3 == 3 { @@ -148,10 +152,12 @@ func characterPacket(character *character) []byte { for _, material := range []struct { name string texture uint32 - }{{"Material #2b", 30043}, {"Material #2a", 30044}} { + second uint32 + }{{"Material #2b", 30043, 0}, {"Material #2a", 30044, 0}, + {"Material #7", 38586, 38585}, {"Material #8", 38584, 38585}} { body = append(body, material.name...) body = append(body, 0) - for _, value := range []uint32{material.texture, 0, 0} { + for _, value := range []uint32{material.texture, material.second, 0} { body = binary.BigEndian.AppendUint32(body, value) } } @@ -183,6 +189,7 @@ func fullCharacterPacket(character *character) []byte { stats := [][2]uint32{{54, uint32(character.level)}, {4, uint32(character.appearance >> 4 & 7)}, {60, 1}, {33, uint32(character.appearance >> 9 & 3)}, {59, uint32(character.appearance >> 7 & 3)}, {156, 100}, {16, uint32(base.Strength)}, {17, uint32(base.Agility)}, {18, uint32(base.Stamina)}, {19, uint32(base.Intelligence)}, {20, uint32(base.Sense)}, {21, uint32(base.Psychic)}, {27, character.health}, {1, character.maximumHealth()}, {123, uint32(base.FirstAid)}, {124, uint32(base.Treatment)}, {37, character.titleLevel()}} stats = append(stats, [2]uint32{51, uint32(character.aggDef)}, [2]uint32{161, uint32(base.ComputerLiteracy)}, [2]uint32{61, character.inventory.Credits}) stats = append(stats, [2]uint32{166, uint32(base.VehicleGround)}) + stats = append(stats, [2]uint32{139, uint32(base.VehicleAir)}) if time.Now().Before(character.implantChangesUntil) { stats = append(stats, [2]uint32{224, 16}) } diff --git a/server/zoning.go b/server/zoning.go @@ -177,8 +177,13 @@ func (server *server) zoneDestination_locked(character *character, client *world } destination.Position[0] -= 8 * dz / length destination.Position[2] += 8 * dx / length + // Keep airborne wall crossings at their altitude, clear of destination terrain. + if character.flying() { + destination.Position[1] = character.position[1] + } if ground := server.terrain[destination.Playfield]; ground != nil { - if height, inside := ground.elevation(destination.Position[0], destination.Position[2]); inside { + if height, inside := ground.elevation(destination.Position[0], destination.Position[2]); inside && + (!character.flying() || destination.Position[1] < height+0.5) { // Native human movement settles half a metre above the ground surface. destination.Position[1] = height + 0.5 } @@ -229,7 +234,7 @@ func predictedPosition_locked(character *character, client *worldClient, now tim // Reuse the same bounded movement estimate for portal checks and the web map. seconds := math.Min(now.Sub(client.movementStarted).Seconds(), 20) speed := float32(1.5) - if character.running { + if character.running || character.flying() { // Native movement reads RunSpeed without ability trickle-down. runSpeed := float32(100 + character.inventory.equipmentBonus(156)) if float32(character.health) < float32(character.maximumHealth())*float32(0.15) { @@ -239,11 +244,18 @@ func predictedPosition_locked(character *character, client *worldClient, now tim if client.forward < 0 { speed = 3 + runSpeed*float32(0.0035) } + if character.flying() { + // Mode 7 uses the same base and RunSpeed helper in both directions. + speed = 12 + runSpeed*float32(0.005) + } speed = max(float32(0.1), min(15, speed)) } x, y, z, w := character.rotation[0], character.rotation[1], character.rotation[2], character.rotation[3] position := character.position position[0] += float32(seconds) * speed * client.forward * (2*x*z + 2*y*w) + if character.flying() { + position[1] += float32(seconds) * speed * client.forward * (2*y*z - 2*x*w) + } position[2] += float32(seconds) * speed * client.forward * (1 - 2*x*x - 2*y*y) return position } diff --git a/tools/data/extract_vehicle.py b/tools/data/extract_vehicle.py @@ -19,11 +19,18 @@ def main(): assert dict(item['stats'])[298] == 2 and dict(item['stats'])[211] == 1000 assert item['name'] == 'Kodaik Turbo IX' weights = {} - for skill in (156, 166): + for skill in (139, 156, 166): raw = database.read(1000204, skill) weights[skill] = dict(weights=struct.unpack('<6i', raw), payload_hex=raw.hex(), payload_sha256=hashlib.sha256(raw).hexdigest()) + # The selected Yalmaha also authors the native flight transition effect. + flight_payload = database.read(1000020, 117322) + flying_item = extract_items.parse_item(flight_payload, 1000020, 117322) + assert flying_item['header_words'][0] == 51022 and flying_item['quality'] == 30 + assert dict(flying_item['stats'])[298] == 2 and dict(flying_item['stats'])[211] == 1000 + assert flying_item['name'] == 'Yalmaha XL - 29478' + # The native RDBTilemap reader classifies CHGA as ground, GNDA/UOHA as dungeon. outdoors = {} for kind, identity in sorted(database.records): @@ -39,6 +46,8 @@ def main(): output.parent.mkdir(parents=True, exist_ok=True) output.write_text(json.dumps(dict(index_sha256=hashlib.sha256(database.index).hexdigest(), item=item, payload_sha256=hashlib.sha256(payload).hexdigest(), + flying_item=flying_item, + flying_payload_sha256=hashlib.sha256(flight_payload).hexdigest(), skill_weights=weights, outdoor_playfields=outdoors), indent=2) + '\n') print(output)