diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 70893b4..2269a2f 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -153,7 +153,7 @@ jobs: DORBIT_TEST_WORKERS: 2 runs-on: windows-latest cache-mode: read - timeout-minutes: 20 + timeout-minutes: 30 outputs: attempt: ${{ steps.build.outputs.attempt }} steps: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 672e57a..c4051cf 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -95,7 +95,7 @@ jobs: env: DORBIT_TEST_WORKERS: 2 runs-on: windows-latest - timeout-minutes: 20 + timeout-minutes: 30 steps: - name: Documentation-only validation if: needs.changes.outputs.build != 'true' diff --git a/GAME_PLAN.md b/GAME_PLAN.md index 792cc7d..8ae73c6 100644 --- a/GAME_PLAN.md +++ b/GAME_PLAN.md @@ -360,8 +360,9 @@ speed. See README.md for configuration and use. Normal clients connect to the persistent server into a docked pilot console before entering the map. The graphite-and-amber console presents saved credits, active-ship preparation, Hangar, Shop, Quests, Cargo Trade, Settings and Connection. The user -approved persistent Skylab industry on 2026-10-08 as a Milestone 3 extension; -Galaxy Gates remains a coming-soon page. +approved persistent Skylab industry on 2026-10-08 as a Milestone 3 extension. +The Galaxy Gates page manages gate parts and the Vashar Gate; see +[Galaxy gates](#galaxy-gates-the-vashar-gate). Docked pilots can buy ships/equipment, activate owned hulls, fit items, trade saved cargo and accept or abandon hunts through the same server-validated persistence @@ -533,7 +534,7 @@ The user requested the models in four supplied screenshots, with their damage, s | MP-1 | 40,000 CR | +70 damage per shot | | LF-2 | 500,000 CR (5,000 U) | +140 damage per shot | | LF-3 | 1,000,000 CR (10,000 U) | +175 damage per shot; +15% for this laser against aliens (201.25 total) | -| LF-4 | Unavailable: future loot/assembly | +200 damage per shot | +| LF-4 | Not sold: 20% Vashar Gate victory reward | +200 damage per shot | | SG3N-A01 | 8,000 CR | +1,000 shield / 40% absorption | | SG3N-A02 | 16,000 CR | +2,000 shield / 50% absorption | | FS-01 | 256,000 CR | +3,200 shield / 70% absorption; +6.25% shield regeneration | @@ -1289,7 +1290,7 @@ increments the flight life and map-visit epoch, so delayed commands, world state and effects cannot revive an earlier visit, including returning to the same map. Map transfers were introduced in network schema 16; current schema 19 requires matching client/server builds. Save schema 8 is unchanged because flight locations are temporary. Ordinary travel gates are separate from -the future Galaxy Gates alien-wave challenges. +the Galaxy Gates alien-wave challenges. ### Reclamation campaign background art @@ -1460,7 +1461,7 @@ The user approved periodic alien counterattack events with increasingly strong waves and a concluding boss fight. The first assault is a story milestone after the initial defense wing is ready; recurring assaults follow, with stronger variants introduced by later chapters. These are shared station-defense encounters, -separate from travel gates and future Galaxy Gates challenges. +separate from travel gates and Galaxy Gates challenges. An assault starts with a visible early-warning countdown so pilots can resupply and return. Marked attack directions lead into opening Scout waves, Sentinel @@ -1491,6 +1492,101 @@ Event operating rules agreed as the starting direction: everyone is offline. Timing, minimum participation and behavior if pilots leave during an assault still require explicit rules. +#### Galaxy gates: the Vashar Gate + +On 2026-10-21 the user approved galaxy gates as wave-challenge instances, separate +from travel gates and station-defense assaults. Gates are named after alien +factions rather than Greek letters, and use alien models that never appear on the +normal maps. The first implementation adds one gate so it can be playtested +before more are designed. + +Story: the occupying aliens are ferrying gate parts through the reclaimed sectors +to build gates that summon allied factions. The first is the **Vashar**. Pilots +capture the parts, assemble the gate themselves and strike the Vashar staging +fleet before it can come through. Destroying its mothership sets the Vashar +invasion back, which keeps repeated runs consistent with the story. The same +premise supports a future event where the aliens manage to set up a gate on a +normal map and pilots must push the incoming invasion back. + +**Parts.** A gate needs 20 parts, saved per pilot (at most 999). Pilots get them in +two ways: + +- *Signal Anomaly* (Dr. Sato, accepted on the Galaxy Gates page): research + picks up the courier traffic in M2. While it is active, every M2 kill the pilot + contributes to guarantees a part in that alien's loot box. Recovering 8 parts + decodes the courier cache for +4 parts, 10,000 CR and 2 research points. One + operation is available per gate; assembling the gate makes the next available. +- Random drops: aliens beyond Outpost 01 sometimes carry a part (8–12% in M2, + 12–16% in M3, 16–20% in M4). Home-map and arena aliens carry none. + +Parts sit in the normal loot box and take no cargo space. A living pilot within +pickup range collects a box's parts, even with a full hold: pilots running +the operation come first, otherwise the nearest pilot. A pilot takes only what fits +under the 999-part limit; the rest passes to the next pilot in range or stays in the +box. Only parts recovered on +the operation's map advance it; boxes remain shared, as with resources. Gate runs +are announced by the builder's public pilot label, not the login identity. + +**Opening a run.** At Outpost 01 a pilot with 20 parts presses *Assemble and open +gate*. The parts are consumed and the Vashar Gate opens near the station. Any pilot +can fly through it while it is open. One run exists on the server at a time. + +**The run.** The arena (*Vashar Rift*) is a separate map outside the connected +network, with a protected return gate to M1. Seven waves follow: + +| Wave | Base enemies | +| --- | --- | +| 1 | 3 Shardlings | +| 2 | 5 Shardlings | +| 3 | 4 Shardlings, 1 Spireguard | +| 4 | 5 Shardlings, 2 Spireguards | +| 5 | 6 Shardlings, 2 Spireguards | +| 6 | 5 Shardlings, 3 Spireguards | +| 7 | Vashar mothership, 4 Shardlings, 2 Spireguards | + +The first wave starts 12 s after a pilot arrives, and later waves 8 s after the +previous one is cleared. A large centered countdown shows the time to the next +wave inside the rift and pauses while nobody is inside. The rift has no protected +zone: wave aliens always pursue the pilots, including at the return gate, which is +sealed while a wave is alive. Quitting to the station or disconnecting mid-wave costs a life (once; a pilot already destroyed pays only for the death), so +pilots cannot slip out to repair and return. Each additional pilot inside (up to four) adds half the +base count, capped by the arena pool of 8 Shardlings and 4 Spireguards; the size +locks when the wave starts. The mothership is fixed-strength and launches two +Shardlings from its hangar every 25 s while it survives; its wave always leaves +two Shardlings in reserve for this. Its 270 m weapons stay out-ranged by pilot +lasers, like every other alien. + +| Type | Hull / shield | Damage / interval | Credit pool | +| --- | --- | --- | --- | +| Shardling | 4,000 / 2,000 | 2,200 / 0.85 s | 1,500 | +| Spireguard | 16,000 / 8,000 | 7,500 / 0.8 s | 7,000 | +| Mothership | 200,000 / 100,000 | 18,000 / 0.55 s, 270 m | 120,000 | + +Kills share credit pools and leave resource boxes as usual. Each pilot has three +lives per run. Dying in the rift costs one, and the normal rescue returns the +pilot to Outpost 01; pilots with lives left can fly back in while the gate is open. +Destroying the final wave pays every participant still connected 150,000 CR, +6 research points and 15,000 x4 shots; each also has a 20% chance of an LF-4 +laser, delivered to storage. Victory closes the entrance and returns anyone still inside to M1 +after 90 s. Closing a run clears any loot left in the arena. A run collapses, without refunding parts, when no pilot has been inside +for 120 s or every participant has used all their lives. + +**Preview tools.** Allowlisted preview pilots see *Preview: open gate without +parts* on the Galaxy Gates page. It opens a run immediately for testing; ordinary +pilots and production servers cannot use it. + +**Implementation notes.** Gate progress is an optional equipment field, so save +schema 8 is unchanged. Older builds reject saves that contain it, so rollback +needs a backup taken before the first gate parts are collected. The run itself is +session state: a server restart ends an open run and its parts are lost. Network +schema 21 adds the run summary. The user supplied concepts for the three Vashar +aliens; Blender models built from them (faceted obsidian crystal hulls, purple +armor, violet seams and hot-pink weapon and hangar glow) ship as 2K-textured GLBs. +Sources, renders and the build script are in `vashar-review/README.md` in the art +archive. All counts, chances, stats, lives, +timings and rewards above are provisional until playtested. Further gates, +other equipment rewards, personal gate instances and the on-map invasion event are future work. + #### First campaign implementation scope Begin with the pilot prologue and the clearance operation that establishes diff --git a/README.md b/README.md index 5dca0ea..30d6120 100644 --- a/README.md +++ b/README.md @@ -245,8 +245,9 @@ map. Visit **Shop** to buy ships and equipment, **Hangar** to activate a hull an equip it, **Quests** to accept hunting contracts, or **Cargo trade** to sell saved resources. **Skylab** manages persistent collectors, refining, upgrades, robots and shipments to ship cargo; see [Skylab rules and balance](docs/skylab.md). -**Settings** and **Connection** are also available. **Galaxy Gates** opens a -coming-soon page. Choose the amber **START** button on Overview +**Settings** and **Connection** are also available. **Galaxy Gates** shows your +gate parts, the Signal Anomaly operation and the Vashar Gate; see +[Galaxy gates](GAME_PLAN.md#galaxy-gates-the-vashar-gate). Choose the amber **START** button on Overview to spawn at Outpost 01 with your selected ship and fitting. Esc or Back returns to the overview; these actions do not launch. Docked ships are hidden from other pilots and cannot move, fight or collect loot. Each reconnect returns to this menu diff --git a/assets/aliens/export-stats.json b/assets/aliens/export-stats.json index ef07051..cda241e 100644 --- a/assets/aliens/export-stats.json +++ b/assets/aliens/export-stats.json @@ -133,5 +133,50 @@ "forward": "-Z", "up": "+Y", "atlas_size": 2048 + }, + "Shardling": { + "triangles": 15364, + "materials": 6, + "bytes": 9778832, + "omitted_degenerate_triangles": 0, + "visual_diameter": 9.5, + "bounds_godot": [ + 5.46453, + 4.732422, + 6.163854 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 + }, + "Spireguard": { + "triangles": 28316, + "materials": 7, + "bytes": 10306748, + "omitted_degenerate_triangles": 0, + "visual_diameter": 9.5, + "bounds_godot": [ + 5.205069, + 4.104681, + 6.80506 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 + }, + "Mothership": { + "triangles": 39930, + "materials": 7, + "bytes": 11414636, + "omitted_degenerate_triangles": 0, + "visual_diameter": 16.0, + "bounds_godot": [ + 10.962345, + 3.956571, + 10.962322 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 } } diff --git a/assets/aliens/mothership.glb b/assets/aliens/mothership.glb new file mode 100644 index 0000000..85d6633 Binary files /dev/null and b/assets/aliens/mothership.glb differ diff --git a/assets/aliens/mothership.glb.import b/assets/aliens/mothership.glb.import new file mode 100644 index 0000000..a29185c --- /dev/null +++ b/assets/aliens/mothership.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://d2u2d20rnb8wx" +path="res://.godot/imported/mothership.glb-e4438dab3e4ae2fb7933e5322e8466f2.scn" + +[deps] + +source_file="res://assets/aliens/mothership.glb" +dest_files=["res://.godot/imported/mothership.glb-e4438dab3e4ae2fb7933e5322e8466f2.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/root_script=null +mesh_library/use_node_names_as_mesh_names=false +array_mesh/deduplicate_surfaces=true +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_name_suffixes=true +nodes/use_node_type_suffixes=true +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=false +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="res://tools/import_alien_materials.gd" +materials/extract=0 +materials/extract_format=0 +materials/extract_path="" +_subresources={} +gltf/naming_version=2 +gltf/embedded_image_handling=2 +gltf/texture_map_mode=1 diff --git a/assets/aliens/shardling.glb b/assets/aliens/shardling.glb new file mode 100644 index 0000000..59acb1c Binary files /dev/null and b/assets/aliens/shardling.glb differ diff --git a/assets/aliens/shardling.glb.import b/assets/aliens/shardling.glb.import new file mode 100644 index 0000000..70cb731 --- /dev/null +++ b/assets/aliens/shardling.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://x5fsauclax5w" +path="res://.godot/imported/shardling.glb-2599e8d26ebeb69d39ea6a0c75677e36.scn" + +[deps] + +source_file="res://assets/aliens/shardling.glb" +dest_files=["res://.godot/imported/shardling.glb-2599e8d26ebeb69d39ea6a0c75677e36.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/root_script=null +mesh_library/use_node_names_as_mesh_names=false +array_mesh/deduplicate_surfaces=true +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_name_suffixes=true +nodes/use_node_type_suffixes=true +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=false +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="res://tools/import_alien_materials.gd" +materials/extract=0 +materials/extract_format=0 +materials/extract_path="" +_subresources={} +gltf/naming_version=2 +gltf/embedded_image_handling=2 +gltf/texture_map_mode=1 diff --git a/assets/aliens/spireguard.glb b/assets/aliens/spireguard.glb new file mode 100644 index 0000000..225245b Binary files /dev/null and b/assets/aliens/spireguard.glb differ diff --git a/assets/aliens/spireguard.glb.import b/assets/aliens/spireguard.glb.import new file mode 100644 index 0000000..d246945 --- /dev/null +++ b/assets/aliens/spireguard.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://dbuqt0ci4l4u" +path="res://.godot/imported/spireguard.glb-7d8ea61ad3f7a855f8cb8b5ecbd04341.scn" + +[deps] + +source_file="res://assets/aliens/spireguard.glb" +dest_files=["res://.godot/imported/spireguard.glb-7d8ea61ad3f7a855f8cb8b5ecbd04341.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/root_script=null +mesh_library/use_node_names_as_mesh_names=false +array_mesh/deduplicate_surfaces=true +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_name_suffixes=true +nodes/use_node_type_suffixes=true +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=false +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="res://tools/import_alien_materials.gd" +materials/extract=0 +materials/extract_format=0 +materials/extract_path="" +_subresources={} +gltf/naming_version=2 +gltf/embedded_image_handling=2 +gltf/texture_map_mode=1 diff --git a/scripts/alien.gd b/scripts/alien.gd index 2356d03..800faf5 100644 --- a/scripts/alien.gd +++ b/scripts/alien.gd @@ -16,6 +16,9 @@ const VISUAL_DIAMETERS := { "Warden": 13.199097, "Ravager": 14.993888, "Overlord": 17.013710, + "Shardling": 9.5, + "Spireguard": 9.5, + "Mothership": 16.0, } # Stronger encounters should remain easy to track among cooperating pilots. const VISUAL_SCALE := { @@ -28,6 +31,9 @@ const VISUAL_SCALE := { "Warden": 2.4, "Ravager": 3.2, "Overlord": 3.5, + "Shardling": 1.0, + "Spireguard": 2.0, + "Mothership": 4.0, } const TYPES := { "Scout": {"hull": 1000.0, "shield": 500.0, "damage": 1500.0, "interval": 0.85, "range": 205.0, "speed": 29.0, "detection": 230.0, "leash": 210.0, "reward": 300, "respawn": 10.0, "scale": Vector3(0.7, 0.7, 0.85), "color": Color("ffc875")}, @@ -39,6 +45,10 @@ const TYPES := { "Warden": {"hull": 24000.0, "shield": 12000.0, "damage": 18000.0, "interval": 0.8, "range": 255.0, "speed": 17.0, "detection": 285.0, "leash": 260.0, "reward": 22000, "respawn": 20.0, "scale": Vector3(1.6, 1.4, 1.1), "color": Color("ee7954")}, "Ravager": {"hull": 36000.0, "shield": 18000.0, "damage": 24000.0, "interval": 0.8, "range": 260.0, "speed": 22.0, "detection": 295.0, "leash": 265.0, "reward": 32000, "respawn": 22.0, "scale": Vector3(1.4, 1.2, 1.7), "color": Color("b788fa")}, "Overlord": {"hull": 60000.0, "shield": 30000.0, "damage": 32000.0, "interval": 0.75, "range": 270.0, "speed": 14.0, "detection": 310.0, "leash": 275.0, "reward": 50000, "respawn": 26.0, "scale": Vector3(2.0, 1.8, 1.5), "color": Color("ed70c1")}, + # Vashar Gate arena only. The run director spawns them; detection covers the arena and they never leash. + "Shardling": {"hull": 4000.0, "shield": 2000.0, "damage": 2200.0, "interval": 0.85, "range": 220.0, "speed": 30.0, "detection": 2400.0, "leash": 5000.0, "reward": 1500, "respawn": 0.0, "scale": Vector3.ONE, "color": Color("c86bff")}, + "Spireguard": {"hull": 16000.0, "shield": 8000.0, "damage": 7500.0, "interval": 0.8, "range": 250.0, "speed": 17.0, "detection": 2400.0, "leash": 5000.0, "reward": 7000, "respawn": 0.0, "scale": Vector3.ONE, "color": Color("ff5fa8")}, + "Mothership": {"hull": 200000.0, "shield": 100000.0, "damage": 18000.0, "interval": 0.55, "range": 270.0, "speed": 5.0, "detection": 2400.0, "leash": 5000.0, "reward": 120000, "respawn": 0.0, "scale": Vector3.ONE, "color": Color("9b5cff"), "radius": 16.0}, } var alien_id: int = 0 @@ -83,7 +93,8 @@ static func model_scene(alien_kind: String) -> Node3D: material.emission = Color.WHITE material.emission_operator = BaseMaterial3D.EMISSION_OP_MULTIPLY material.emission_texture = material.albedo_texture - material.emission_energy_multiplier = 2.0 if alien_kind in ["Scout", "Sentinel", "Heavy"] else 0.35 + # Vashar armor stays dark so its violet seams carry the contrast. + material.emission_energy_multiplier = 2.0 if alien_kind in ["Scout", "Sentinel", "Heavy"] else (0.12 if GalaxyGates.POOL.has(alien_kind) else 0.35) return instance @@ -96,6 +107,10 @@ func _ready() -> void: laser_interval = stats["interval"] laser_range = stats["range"] super._ready() + if stats.has("radius"): + for child in get_children(): + if child is CollisionShape3D: + (child.shape as SphereShape3D).radius = stats["radius"] if render_enabled: remove_child(model) model.queue_free() diff --git a/scripts/cargo_resources.gd b/scripts/cargo_resources.gd index ddc3f53..732c7a9 100644 --- a/scripts/cargo_resources.gd +++ b/scripts/cargo_resources.gd @@ -21,6 +21,9 @@ const LOOT := { "Overlord": {"duranium": Vector2i(24, 32), "xenomit": Vector2i(10, 14), "promerium": Vector2i(18, 24), "seprom": Vector2i(8, 12)}, "Scout": {"prometium": Vector2i(6, 10), "endurium": Vector2i(2, 4), "terbium": Vector2i(1, 2)}, "Sentinel": {"prometium": Vector2i(10, 16), "endurium": Vector2i(6, 10), "terbium": Vector2i(4, 6), "prometid": Vector2i(2, 4), "duranium": Vector2i(1, 2)}, + "Shardling": {"prometid": Vector2i(4, 8), "duranium": Vector2i(2, 4), "xenomit": Vector2i(1, 2)}, + "Spireguard": {"duranium": Vector2i(8, 12), "xenomit": Vector2i(3, 5), "promerium": Vector2i(4, 6)}, + "Mothership": {"xenomit": Vector2i(20, 30), "promerium": Vector2i(30, 40), "seprom": Vector2i(15, 20)}, "Heavy": {"prometium": Vector2i(18, 24), "endurium": Vector2i(12, 18), "terbium": Vector2i(8, 12), "prometid": Vector2i(6, 10), "duranium": Vector2i(4, 6), "xenomit": Vector2i(1, 3), "promerium": Vector2i(2, 4), "seprom": Vector2i(1, 2)}, } diff --git a/scripts/equipment.gd b/scripts/equipment.gd index ade03bc..abca81a 100644 --- a/scripts/equipment.gd +++ b/scripts/equipment.gd @@ -11,7 +11,7 @@ const MODELS := { "mp-1": {"name": "MP-1", "kind": "laser", "price": 40000, "damage": 70.0, "shield": 0.0, "speed": 0.0}, "lf-2": {"name": "LF-2", "kind": "laser", "price": 5000 * URIDIUM_TO_CREDITS, "damage": 140.0, "shield": 0.0, "speed": 0.0}, "lf-3": {"name": "LF-3", "kind": "laser", "price": 10000 * URIDIUM_TO_CREDITS, "damage": 175.0, "npc_bonus": 0.15, "shield": 0.0, "speed": 0.0}, - "lf-4": {"name": "LF-4", "kind": "laser", "price": 0, "unavailable": "Unavailable until loot or assembly is added.", "damage": 200.0, "shield": 0.0, "speed": 0.0}, + "lf-4": {"name": "LF-4", "kind": "laser", "price": 0, "unavailable": "Unavailable in the shop. Vashar Gate victories can award one.", "damage": 200.0, "shield": 0.0, "speed": 0.0}, "shield": {"name": "SG3N-A01", "kind": "generator", "price": 8000, "damage": 0.0, "shield": 1000.0, "absorption": 0.4, "speed": 0.0}, "sg3n-a02": {"name": "SG3N-A02", "kind": "generator", "price": 16000, "damage": 0.0, "shield": 2000.0, "absorption": 0.5, "speed": 0.0}, "fs-01": {"name": "FS-01", "kind": "generator", "price": 256000, "damage": 0.0, "shield": 3200.0, "absorption": 0.7, "regen_bonus": 0.0625, "speed": 0.0}, @@ -101,6 +101,8 @@ static func valid(data: Variant) -> bool: return false if data.has("story") and not Story.valid(data["story"]): return false + if data.has("gates") and not GalaxyGates.valid(data["gates"]): + return false for id: Variant in data["ships"]: if not id is String or not PilotStore.valid_id(id) or not data["ships"][id] is String or not ShipCatalog.MODELS.has(ShipCatalog.canonical(data["ships"][id])): return false diff --git a/scripts/flight_navigation.gd b/scripts/flight_navigation.gd index 63e508f..ab7210c 100644 --- a/scripts/flight_navigation.gd +++ b/scripts/flight_navigation.gd @@ -115,7 +115,7 @@ class NetworkPlot extends Control: draw_polyline(points, color, 1.5, true) for port: Vector2 in [points[0], points[-1]]: draw_circle(port, 3.5, color) - for map: int in SectorMaps.MAPS: + for map: int in SectorMaps.network_maps(): var rect := map_rect(map) var color: Color = SectorMaps.MAPS[map]["color"] var border := FlightHud.AMBER if selected == map else color if map == current else Color("405767") @@ -148,7 +148,7 @@ class NetworkPlot extends Control: func _gui_input(event: InputEvent) -> void: if event is InputEventMouseMotion: hovered_map = -1 - for map: int in SectorMaps.MAPS: + for map: int in SectorMaps.network_maps(): if map_rect(map).has_point(event.position): hovered_map = map mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND if hovered_map >= 0 and hovered_map != navigation.sector.map_id else Control.CURSOR_ARROW @@ -160,7 +160,7 @@ class NetworkPlot extends Control: tooltip_text += "\nSet waypoint to " + SectorMaps.MAPS[hop]["name"] queue_redraw() elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: - for map: int in SectorMaps.MAPS: + for map: int in SectorMaps.network_maps(): if map_rect(map).has_point(event.position): select_map(map) accept_event() @@ -168,7 +168,7 @@ class NetworkPlot extends Control: if event.keycode in [KEY_LEFT,KEY_RIGHT,KEY_UP,KEY_DOWN]: if keyboard_map < 0: keyboard_map = navigation.sector.map_id - keyboard_map = posmod(keyboard_map + (-1 if event.keycode in [KEY_LEFT,KEY_UP] else 1),SectorMaps.MAPS.size()) + keyboard_map = posmod(keyboard_map + (-1 if event.keycode in [KEY_LEFT,KEY_UP] else 1),SectorMaps.network_maps().size()) hovered_map = -1 queue_redraw() accept_event() @@ -270,7 +270,7 @@ func contacts_current() -> bool: # Allocation-free check of the cached membership; refreshes moving positions. if contact_cache_map != sector.map_id: return false - var index: int = SectorMaps.GATES[sector.map_id].size() + (1 if sector.map_id == 0 else 0) + var index: int = SectorMaps.links(sector.map_id).size() + (1 if sector.map_id == 0 else 0) var site := Story.site(sector.story_state(), sector.map_id) if not site.is_empty(): if index >= contact_cache.size() or contact_cache[index]["key"] != "story_" + site["id"]: @@ -307,8 +307,8 @@ func build_contacts() -> Array[Dictionary]: var result: Array[Dictionary] = [] if sector.map_id == 0: result.append({"key": "station", "name": "Outpost 01", "position": Sector.STATION_POSITION, "color": FlightHud.GREEN, "ship": null}) - for map: int in SectorMaps.GATES[sector.map_id]: - result.append({"key": "gate%d" % map, "name": "Gate to " + SectorMaps.code(map), "position": SectorMaps.gate_position(sector.map_id, map), "color": SectorMaps.MAPS[map]["color"], "ship": null}) + for map: int in SectorMaps.links(sector.map_id): + result.append({"key": "gate%d" % map, "name": SectorMaps.gate_label(map).capitalize() if map == GalaxyGates.MAP else "Gate to " + SectorMaps.code(map), "position": SectorMaps.gate_position(sector.map_id, map), "color": SectorMaps.MAPS[map]["color"], "ship": null}) var site := Story.site(sector.story_state(), sector.map_id) if not site.is_empty(): result.append({"key": "story_" + site["id"], "name": "Objective: " + site["site"], "position": Story.site_position(site), "color": StorySites.GOLD, "ship": null}) @@ -584,7 +584,7 @@ func draw_radar() -> void: var title_state := Vector2i(sector.map_id, range_index) if title_state != radar_title_state: radar_title_state = title_state - radar_title = "M%d / RADAR / %s m" % [sector.map_id + 1, FlightHud.number(RANGES[range_index])] + radar_title = "%s / RADAR / %s m" % [SectorMaps.code(sector.map_id), FlightHud.number(RANGES[range_index])] card(radar_rect(), radar_title) var center := origin + Vector2(84, 108) draw_circle(center, 62, Color("111a20")) diff --git a/scripts/flight_session.gd b/scripts/flight_session.gd index 36b1b63..48d7fa3 100644 --- a/scripts/flight_session.gd +++ b/scripts/flight_session.gd @@ -7,7 +7,7 @@ const MAX_PLAYERS: int = 10 const COMMAND_TIMEOUT: float = 0.5 const CONNECT_TIMEOUT: float = 10.0 # Bump when packet contents or shared physics change without an RPC signature change. -const NETWORK_SCHEMA: int = 20 +const NETWORK_SCHEMA: int = 21 const BUILD_MISMATCH := "Client and server builds are incompatible. Use the matching client and server from the same release or PR preview." var sector: Sector @@ -311,7 +311,11 @@ func rpc_signature(node: Node) -> Array: func protocol_fingerprint(schema: int = NETWORK_SCHEMA) -> String: - return JSON.stringify([schema, rpc_signature(self), rpc_signature(combat)]).sha256_text() + # Story progress travels as an index into the shared sequence. + var step_ids: Array[String] = [] + for step in Story.STEPS: + step_ids.append(step["id"]) + return JSON.stringify([schema, rpc_signature(self), rpc_signature(combat), step_ids]).sha256_text() func begin_authentication(id: int) -> void: @@ -483,6 +487,7 @@ func ready_for_flight(docked: bool = false) -> void: stop_for_save_failure() return combat.publish_inventory(id) + combat.gate_state.rpc_id(id, combat.gate.state_for(id)) combat.loot_state.rpc_id(id, loot_for_map(0), ships[id].map_visit) status = "Server on UDP %d. Players: %d/%d" % [host_port, ships.size(), MAX_PLAYERS] if sector.dedicated_server: @@ -573,6 +578,8 @@ func dock_request() -> void: if not ships.has(id) or ships[id].get_meta("docked", false): return var ship := ships[id] + if ship.map_id == GalaxyGates.MAP: + combat.gate.retreated(id) ship.set_meta("docked", true) if ship.map_id != 0: ship.map_visit += 1 @@ -651,6 +658,10 @@ func flight_launched(id: int) -> void: func peer_left(id: int) -> void: if active and sector.dedicated_server and not combat.flush_boosts([id]): stop_for_save_failure() + # Disconnecting mid-wave is a retreat, like quitting to the station. Run + # lives are keyed by pilot identity, so settle them before it is erased. + if active and multiplayer.is_server() and ships.has(id) and ships[id].map_id == GalaxyGates.MAP: + combat.gate.retreated(id, false) pilot_ids.erase(id) challenges.erase(id) if active and multiplayer.is_server(): @@ -1033,7 +1044,7 @@ func request_jump() -> void: return var destination := -1 var nearest := SectorMaps.JUMP_RADIUS - for map: int in SectorMaps.GATES[sector.map_id]: + for map: int in SectorMaps.links(sector.map_id): var distance := sector.player.position.distance_to(SectorMaps.gate_position(sector.map_id, map)) if distance <= nearest: nearest = distance @@ -1130,13 +1141,30 @@ func jump(id: int, life: int, destination: int) -> String: var ship := ships[id] if life != combat.records[id]["life"] or not ship.alive or ship.get_meta("docked", false): return "Jump unavailable for this flight." - if not SectorMaps.GATES[ship.map_id].has(destination): + if not SectorMaps.links(ship.map_id).has(destination): return "No gate connects these maps." if ship.position.distance_to(SectorMaps.gate_position(ship.map_id, destination)) > SectorMaps.JUMP_RADIUS: return "Fly within 50 m of the gate to jump." if Time.get_ticks_msec() < jump_until.get(id, 0): return "Gate stabilizing. Wait two seconds between jumps." + if destination == GalaxyGates.MAP: + var blocker := combat.gate.entry_blocker(id) + if not blocker.is_empty(): + return blocker + if ship.map_id == GalaxyGates.MAP: + var sealed := combat.gate.exit_blocker() + if not sealed.is_empty(): + return sealed jump_until[id] = Time.get_ticks_msec() + int(SectorMaps.JUMP_COOLDOWN * 1000) + transfer(id, destination) + if destination == GalaxyGates.MAP: + combat.gate.entered(id) + return "" + + +## Moves a living pilot to another map's arrival point, invalidating the previous visit. +func transfer(id: int, destination: int) -> void: + var ship := ships[id] var source := ship.map_id ship.map_id = destination ship.map_visit += 1 @@ -1152,7 +1180,6 @@ func jump(id: int, life: int, destination: int) -> String: for enemy: Alien in sector.world_aliens.values(): enemy.contributors.erase(id) announce_map_change(id) - return "" func announce_map_change(id: int) -> void: @@ -1205,5 +1232,8 @@ func finish_local_jump() -> void: for effect in get_tree().get_nodes_in_group("transient_feedback"): if sector.is_ancestor_of(effect): effect.queue_free() - sector.notify("Arrived at %s. Gates are protected; press %s nearby to return." % [SectorMaps.MAPS[sector.map_id]["name"], GameSettings.binding_text("jump_gate")]) + if sector.map_id == GalaxyGates.MAP: + sector.notify("Entered the Vashar Rift. The protected gate behind you returns to M1 (%s)." % GameSettings.binding_text("jump_gate")) + else: + sector.notify("Arrived at %s. Gates are protected; press %s nearby to return." % [SectorMaps.MAPS[sector.map_id]["name"], GameSettings.binding_text("jump_gate")]) reveal_jump() diff --git a/scripts/galaxy_gates.gd b/scripts/galaxy_gates.gd new file mode 100644 index 0000000..c45a2ba --- /dev/null +++ b/scripts/galaxy_gates.gd @@ -0,0 +1,156 @@ +class_name GalaxyGates +extends RefCounted +## Galaxy gate parts, the signal operation and the Vashar Gate run. +## The occupying aliens ferry gate parts through the reclaimed maps so they can +## summon their Vashar allies. Pilots capture the parts, assemble the gate +## themselves and strike the Vashar staging fleet before it comes through. +## Part counts, chances, waves, lives and rewards are provisional playtesting values. + +const NAME := "Vashar Gate" +# Faction violet for gate UI, loot and labels. +const GLOW := Color("c86bff") +const FACTION := "Vashar" +const MAP := 4 +const PARTS_REQUIRED := 20 +const MAX_PARTS := 999 +# Chance that an alien carries one part in its loot box. Home-map aliens carry none. +const PART_CHANCE := {"Skirmisher": 0.08, "Raider": 0.12, "Marauder": 0.12, "Warden": 0.16, "Ravager": 0.16, "Overlord": 0.2} +# Each qualifying kill on the signal map guarantees a part while the operation is active. +const SIGNAL := { + "title": "Signal Anomaly", "contact": "sato", "map": 1, "required": 8, "parts": 4, "credits": 10000, "research": 2, + "objective": "Recover gate parts from aliens in M2 / Outer Patrol", + "briefing": "Pilot, Sato here. I have isolated an anomaly in the alien traffic through Outer Patrol. Their couriers are hauling segments of a jump gate, and the signature is not theirs. It belongs to the Vashar, an allied faction they are trying to summon. Destroy the couriers in M2 and recover the parts before anyone can assemble that gate.", + "done": "That is enough to decode the courier manifest. I have located their cache and added its parts to your stock. Keep collecting: once the gate is complete, we can turn it on the Vashar ourselves.", +} +const LIVES := 3 +# Every participant: credits, research points and x4 rounds, plus a chance at an LF-4 laser. +const REWARD := {"credits": 150000, "research": 6, "x4": 15000, "item": "lf-4", "item_chance": 0.2} +# Pilots counted when locking a wave's size. Each additional pilot adds half the base count. +const SCALED_PILOTS := 4 +const WAVE_DELAY := 8.0 +const FIRST_WAVE_DELAY := 12.0 +# A run with nobody inside the gate for this long collapses. +const ABANDON_TIME := 120.0 +# Pilots left inside after a victory are returned home after this long. +const VICTORY_TIME := 90.0 +const ESCORT_INTERVAL := 25.0 +const ESCORTS := 2 +# Arena alien pool, in stable ID order. Waves activate subsets; nothing respawns by itself. +const POOL := {"Shardling": 8, "Spireguard": 4, "Mothership": 1} +const WAVES: Array[Dictionary] = [ + {"Shardling": 3}, + {"Shardling": 5}, + {"Shardling": 4, "Spireguard": 1}, + {"Shardling": 5, "Spireguard": 2}, + {"Shardling": 6, "Spireguard": 2}, + {"Shardling": 5, "Spireguard": 3}, + {"Mothership": 1, "Shardling": 4, "Spireguard": 2}, +] +const SIGNAL_STATES := ["available", "active", "done"] + + +static func pool_kinds() -> Array[String]: + var kinds: Array[String] = [] + for kind: String in POOL: + for index in range(POOL[kind]): + kinds.append(kind) + return kinds + + +static func empty() -> Dictionary: + return {"parts": 0, "signal": "available", "progress": 0} + + +# Pilots without saved gate progress start empty; no save migration is needed. +static func state(equipment: Dictionary) -> Dictionary: + return equipment.get("gates", empty()) + + +static func valid(value: Variant) -> bool: + if not value is Dictionary or value.size() != 3 or not Skylab.integer(value.get("parts"), 0, MAX_PARTS): + return false + if not value.get("signal") is String or not value["signal"] in SIGNAL_STATES: + return false + return Skylab.integer(value.get("progress"), 0, int(SIGNAL["required"]) - 1 if value["signal"] == "active" else 0) + + +static func normalize(value: Dictionary) -> void: + value["parts"] = int(value["parts"]) + value["progress"] = int(value["progress"]) + + +static func signal_active(gates: Dictionary) -> bool: + return gates.get("signal", "") == "active" + + +## Parts carried by one destroyed alien. `guaranteed` adds the signal operation's part. +static func roll_parts(kind: String, rng: RandomNumberGenerator, guaranteed: bool) -> int: + var parts := 1 if guaranteed else 0 + if rng.randf() < float(PART_CHANCE.get(kind, 0.0)): + parts += 1 + return parts + + +## Adds collected parts. `qualifying` of them came from the operation's map and +## count toward an active signal operation. Returns the next state with any reward. +static func collect(gates: Dictionary, amount: int, qualifying: int) -> Dictionary: + var next := gates.duplicate() + var result := {"gates": next, "credits": 0, "research": 0, "completed": false} + next["parts"] = mini(MAX_PARTS, int(next["parts"]) + amount) + if not signal_active(next) or qualifying <= 0: + return result + var progress := int(next["progress"]) + qualifying + if progress < int(SIGNAL["required"]): + next["progress"] = progress + return result + next["signal"] = "done" + next["progress"] = 0 + next["parts"] = mini(MAX_PARTS, int(next["parts"]) + int(SIGNAL["parts"])) + result["credits"] = SIGNAL["credits"] + result["research"] = SIGNAL["research"] + result["completed"] = true + return result + + +static func accept_blocker(gates: Dictionary) -> String: + match gates["signal"]: + "active": return "Signal Anomaly is already active." + "done": return "Assemble the %s before tracing another signal." % NAME + return "" + + +static func assemble_blocker(gates: Dictionary) -> String: + if int(gates["parts"]) < PARTS_REQUIRED: + return "Need %d gate parts; %d collected." % [PARTS_REQUIRED, int(gates["parts"])] + return "" + + +## Consumes one gate's parts. A finished signal operation becomes available again. +static func assemble(gates: Dictionary) -> Dictionary: + var next := gates.duplicate() + next["parts"] = int(next["parts"]) - PARTS_REQUIRED + if next["signal"] == "done": + next["signal"] = "available" + return next + + +## Alien counts for one wave, locked when it starts. The boss never scales, and +## a boss wave leaves enough dormant Shardlings for the mothership's escorts. +static func wave_counts(wave: int, pilots: int) -> Dictionary: + var counts := {} + var extra := clampi(pilots, 1, SCALED_PILOTS) - 1 + var boss_wave: bool = WAVES[wave].has("Mothership") + for kind: String in WAVES[wave]: + var base := int(WAVES[wave][kind]) + var limit := int(POOL[kind]) - (ESCORTS if boss_wave and kind == "Shardling" else 0) + counts[kind] = base if kind == "Mothership" else mini(limit, base + int(base * extra / 2.0)) + return counts + + +static func signal_objective(gates: Dictionary) -> String: + return "%s %d / %d" % [SIGNAL["objective"], int(gates["progress"]), int(SIGNAL["required"])] + + +static func reward_text(item: bool) -> String: + var text := "%s and +%s x4 shots" % [Story.reward_text(REWARD["credits"], REWARD["research"]), StationShop.credits_text(REWARD["x4"])] + return text + (" and an %s laser (in storage)" % Equipment.MODELS[REWARD["item"]]["name"] if item else "") diff --git a/scripts/galaxy_gates.gd.uid b/scripts/galaxy_gates.gd.uid new file mode 100644 index 0000000..5ddd1f6 --- /dev/null +++ b/scripts/galaxy_gates.gd.uid @@ -0,0 +1 @@ +uid://b44lktioaqe08 diff --git a/scripts/gate_menu.gd b/scripts/gate_menu.gd new file mode 100644 index 0000000..c75cdc4 --- /dev/null +++ b/scripts/gate_menu.gd @@ -0,0 +1,161 @@ +class_name GateMenu +extends PanelContainer +## Galaxy Gates station page: gate parts, the Signal Anomaly operation and the +## open run. The server validates every action and owns the gate run. + +const SIZE := Vector2(1150, 690) +var sector: Sector +var summary: Label +var parts_label: Label +var parts_bar: ProgressBar +var run_label: Label +var assemble_button: Button +var preview_button: Button +var signal_state: Label +var signal_progress: ProgressBar +var accept_button: Button +var status: Label + + +func _ready() -> void: + StationUi.frame(self, SIZE) + var rows := StationUi.rows(self, 16) + rows.add_theme_constant_override("separation", 10) + var header := StationUi.header_row(StationUi.header(rows, "GALAXY GATES", "OPERATIONS")) + summary = StationUi.heading(header, "", 17, StationUi.MUTED) + summary.size_flags_vertical = Control.SIZE_SHRINK_END + var body := HBoxContainer.new() + body.add_theme_constant_override("separation", 14) + body.size_flags_vertical = Control.SIZE_EXPAND_FILL + rows.add_child(body) + + var gate := StationUi.card(body) + gate.size_flags_horizontal = Control.SIZE_EXPAND_FILL + var gate_rows := StationUi.rows(gate, 16) + gate_rows.add_theme_constant_override("separation", 10) + StationUi.heading(gate_rows, "VASHAR FACTION", 13, GalaxyGates.GLOW).add_theme_font_override("font", StationUi.tracked(true, 3)) + StationUi.heading(gate_rows, GalaxyGates.NAME.to_upper(), 30) + var lore := StationUi.text(gate_rows, "The occupying aliens are smuggling gate parts through our sectors to summon their Vashar allies. Capture enough parts and assemble the gate ourselves: it opens near Outpost 01 and leads straight into the Vashar staging fleet. Destroy the mothership to set back their invasion.", 16) + lore.size_flags_vertical = Control.SIZE_EXPAND_FILL + parts_label = StationUi.heading(gate_rows, "", 18) + parts_bar = ProgressBar.new() + parts_bar.custom_minimum_size.y = 10 + parts_bar.show_percentage = false + parts_bar.max_value = GalaxyGates.PARTS_REQUIRED + gate_rows.add_child(parts_bar) + StationUi.text(gate_rows, "%d waves, ending with the Vashar mothership / %d lives per pilot / any pilot may join\nVictory pays every participant %s, with a %d%% chance of an LF-4 laser." % [GalaxyGates.WAVES.size(), GalaxyGates.LIVES, GalaxyGates.reward_text(false), roundi(GalaxyGates.REWARD["item_chance"] * 100)], 15, StationUi.MUTED) + run_label = StationUi.text(gate_rows, "", 16, GalaxyGates.GLOW) + assemble_button = StationUi.button(gate_rows, "ASSEMBLE AND OPEN GATE", func(): act("gate_assemble")) + StationUi.primary(assemble_button) + preview_button = StationUi.button(gate_rows, "Preview: open gate without parts", func(): act("gate_preview")) + preview_button.hide() + + var operation := StationUi.card(body) + operation.custom_minimum_size.x = 420 + var op_rows := StationUi.rows(operation, 16) + op_rows.add_theme_constant_override("separation", 10) + StationUi.heading(op_rows, "RESEARCH OPERATION", 13, StationUi.MUTED).add_theme_font_override("font", StationUi.tracked(true, 3)) + StationUi.heading(op_rows, str(GalaxyGates.SIGNAL["title"]).to_upper(), 26) + var speaker := HBoxContainer.new() + speaker.add_theme_constant_override("separation", 14) + op_rows.add_child(speaker) + var portrait := TextureRect.new() + portrait.texture = StorySites.portrait(GalaxyGates.SIGNAL["contact"]) + portrait.custom_minimum_size = Vector2(96, 96) + portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE + portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED + portrait.size_flags_vertical = Control.SIZE_SHRINK_BEGIN + speaker.add_child(portrait) + var briefing := StationUi.text(speaker, "%s\n%s" % [Story.CONTACTS[GalaxyGates.SIGNAL["contact"]]["name"].to_upper(), GalaxyGates.SIGNAL["briefing"]], 15) + briefing.size_flags_horizontal = Control.SIZE_EXPAND_FILL + briefing.size_flags_vertical = Control.SIZE_EXPAND_FILL + StationUi.text(op_rows, "Each M2 kill you contribute to carries a gate part. Recover %d parts to decode the courier cache: +%d gate parts and %s. Other aliens beyond Outpost 01 sometimes carry parts too." % [GalaxyGates.SIGNAL["required"], GalaxyGates.SIGNAL["parts"], Story.reward_text(GalaxyGates.SIGNAL["credits"], GalaxyGates.SIGNAL["research"])], 15, StationUi.MUTED) + signal_state = StationUi.heading(op_rows, "", 17) + signal_progress = ProgressBar.new() + signal_progress.custom_minimum_size.y = 8 + signal_progress.show_percentage = false + signal_progress.max_value = GalaxyGates.SIGNAL["required"] + op_rows.add_child(signal_progress) + accept_button = StationUi.button(op_rows, "ACCEPT OPERATION", func(): act("gate_signal")) + StationUi.primary(accept_button) + status = StationUi.text(rows, "", 16, StationUi.AMBER) + status.custom_minimum_size.y = 26 + get_viewport().size_changed.connect(fit_window) + fit_window() + hide() + + +func gates() -> Dictionary: + var inventory := StationUi.inventory(sector) + return GalaxyGates.empty() if inventory.is_empty() else GalaxyGates.state(inventory) + + +func act(action: String) -> void: + var button := {"gate_assemble": assemble_button, "gate_preview": preview_button, "gate_signal": accept_button}[action] as Button + if not button.disabled and button.visible: + sector.session.combat.request_station(action, "") + + +func fit_window() -> void: + if is_instance_valid(sector.main_menu) and sector.main_menu.visible: + sector.main_menu.fit_panel(self, SIZE) + else: + StationUi.centered(self, SIZE) + + +func open() -> void: + if sector.main_menu.route_page("gates"): + return + sector.set_paused(true) + fit_window() + show() + + +func close() -> void: + hide() + sector.set_paused(false) + + +func _process(_delta: float) -> void: + if not visible: + return + var data := gates() + var parts := int(data["parts"]) + var run: Dictionary = sector.session.combat.gate_summary + StationUi.set_text(summary, "%d / %d GATE PARTS" % [parts, GalaxyGates.PARTS_REQUIRED]) + StationUi.set_text(parts_label, "GATE PARTS %d / %d" % [parts, GalaxyGates.PARTS_REQUIRED]) + parts_bar.value = mini(parts, GalaxyGates.PARTS_REQUIRED) + var run_text := "" + if run.get("active", false): + if run["phase"] == "victory": + run_text = "The mothership is down. The rift closes shortly." + elif run["phase"] == "waiting": + run_text = "GATE OPEN near Outpost 01, assembled by %s. Fly through it to join; the first wave starts when a pilot arrives." % run["builder"] + else: + var progress := "Wave %d of %d in progress" % [run["wave"], run["waves"]] if run["phase"] == "fighting" else "Wave %d of %d cleared, next wave incoming" % [run["wave"], run["waves"]] + run_text = "GATE OPEN near Outpost 01. %s, %d pilots inside. Your lives: %d." % [progress, run["pilots"], run["lives"]] + StationUi.set_text(run_label, run_text) + var station := StationUi.blocker(sector) + var reason := station + if reason.is_empty() and run.get("active", false): + reason = "A %s run is already open." % GalaxyGates.NAME + if reason.is_empty(): + reason = GalaxyGates.assemble_blocker(data) + assemble_button.disabled = not reason.is_empty() + assemble_button.tooltip_text = reason if not reason.is_empty() else "Consumes %d parts and opens the gate for everyone near Outpost 01." % GalaxyGates.PARTS_REQUIRED + preview_button.visible = not StationUi.offline_preview(sector) and sector.session.combat.preview_tools_available + preview_button.disabled = not station.is_empty() or run.get("active", false) + preview_button.tooltip_text = "Opens the gate on an authorized preview server without consuming parts." + match data["signal"]: + "active": + StationUi.set_text(signal_state, GalaxyGates.signal_objective(data)) + "done": + StationUi.set_text(signal_state, "Cache decoded. Assemble the gate to trace the next signal.") + _: + StationUi.set_text(signal_state, "Available") + signal_progress.value = int(data["progress"]) + signal_progress.visible = data["signal"] == "active" + var accept_reason := station if not station.is_empty() else GalaxyGates.accept_blocker(data) + accept_button.disabled = not accept_reason.is_empty() + accept_button.tooltip_text = accept_reason + StationUi.set_text(status, station if not station.is_empty() else sector.session.combat.station_message) diff --git a/scripts/gate_menu.gd.uid b/scripts/gate_menu.gd.uid new file mode 100644 index 0000000..e040b2a --- /dev/null +++ b/scripts/gate_menu.gd.uid @@ -0,0 +1 @@ +uid://bd4vnn7djsd52 diff --git a/scripts/gate_run.gd b/scripts/gate_run.gd new file mode 100644 index 0000000..1bc785c --- /dev/null +++ b/scripts/gate_run.gd @@ -0,0 +1,334 @@ +class_name GateRun +extends RefCounted +## Server-owned Vashar Gate run. One run at a time: a pilot assembles the gate at +## Outpost 01, the gate opens nearby, and any pilot can fly through while it is +## open. Waves activate dormant arena aliens and end with the mothership. +## Run state is session state; a server restart ends an open run. + +# The owning SessionCombat. Typed as Node because the RPC compatibility test +# recompiles SessionCombat's source without its class_name. +var combat: Node +var active := false +var builder := "" +# waiting: before the first wave; fighting; interval: between waves; victory. +var phase := "waiting" +var wave := -1 +var clock := 0.0 +var empty_clock := 0.0 +var escort_clock := 0.0 +# Pilots inside at the last tick; the countdown pauses while the rift is empty. +var last_inside := 0 +# Remaining lives and participation, keyed by persistent pilot identity. +var lives: Dictionary[String, int] = {} +var wave_aliens: Array[Alien] = [] +var rng := RandomNumberGenerator.new() + + +func _init(owner: Node) -> void: + combat = owner + rng.randomize() + + +static func dormant(alien: Alien) -> void: + alien.alive = false + alien.velocity = Vector3.ZERO + alien.hide() + alien.set_collision_layer_value(2, false) + alien.contributors.clear() + alien.engaged = false + alien.returning = false + alien.last_attacker = null + alien.respawn = 0.0 + alien.life += 1 + + +func sector() -> Sector: + return combat.session.sector + + +func key(id: int) -> String: + return combat.session.pilot_ids.get(id, "peer%d" % id) + + +func arena_aliens() -> Array[Alien]: + var result: Array[Alien] = [] + result.assign(sector().map_rosters[GalaxyGates.MAP].values()) + return result + + +func inside() -> Array[int]: + var result: Array[int] = [] + for id: int in combat.session.ships: + var ship: Pilot = combat.session.ships[id] + if ship.map_id == GalaxyGates.MAP and ship.alive and not ship.get_meta("docked", false): + result.append(id) + return result + + +## Clears every run without rewards; used when a session starts or ends. +func reset() -> void: + active = false + builder = "" + phase = "waiting" + wave = -1 + lives.clear() + wave_aliens.clear() + SectorMaps.rift_open = false + for alien in arena_aliens(): + dormant(alien) + if not sector().dedicated_server: + sector().refresh_rift() + + +func open_blocker() -> String: + return "A %s run is already open. Join it near Outpost 01." % GalaxyGates.NAME if active else "" + + +func start(label: String) -> void: + reset() + active = true + builder = label + clock = GalaxyGates.FIRST_WAVE_DELAY + empty_clock = 0.0 + SectorMaps.rift_open = true + publish() + broadcast("%s opened near Outpost 01 by %s. Fly through it to join the run." % [GalaxyGates.NAME, label]) + + +func entry_blocker(id: int) -> String: + if not active or phase == "victory": + return "The %s is closed." % GalaxyGates.NAME + if lives.get(key(id), GalaxyGates.LIVES) <= 0: + return "No lives left in this %s run." % GalaxyGates.NAME + return "" + + +## Pilots cannot slip out mid-wave to repair; the exit opens between waves. +func exit_blocker() -> String: + return "The rift exit is sealed until this wave is cleared." if active and phase == "fighting" else "" + + +## Quitting to the station during a wave counts as a lost life. +## A destroyed ship already paid with its death; only a living ship retreats. +func retreated(id: int, notify: bool = true) -> void: + if active and phase == "fighting" and lives.has(key(id)) and combat.session.ships[id].alive: + lives[key(id)] = maxi(0, lives[key(id)] - 1) + if notify: + combat.message(id, "You abandoned the wave. %d lives left in this %s run." % [lives[key(id)], GalaxyGates.NAME]) + publish() + + +func entered(id: int) -> void: + if not lives.has(key(id)): + lives[key(id)] = GalaxyGates.LIVES + empty_clock = 0.0 + publish() + var notice := "Entered the Vashar Rift. %d lives. The gate behind you returns to M1." % lives[key(id)] + if phase == "waiting": + notice += " First wave in %d seconds." % ceili(clock) + combat.message(id, notice) + + +func died(id: int) -> void: + if not active or not lives.has(key(id)): + return + lives[key(id)] = maxi(0, lives[key(id)] - 1) + combat.message(id, "Ship lost in the Vashar Rift. %d lives left in this run." % lives[key(id)] if lives[key(id)] > 0 else "Ship lost. No lives left in this Vashar Gate run.") + publish() + + +func tick(delta: float) -> void: + if not active: + return + var pilots := inside() + if pilots.size() != last_inside: + last_inside = pilots.size() + publish() + if phase == "victory": + clock -= delta + if clock <= 0.0: + close() + return + if pilots.is_empty(): + empty_clock += delta + var exhausted: bool = not lives.is_empty() and lives.values().max() <= 0 + if exhausted or empty_clock >= GalaxyGates.ABANDON_TIME: + fail("No pilots can continue." if exhausted else "Nobody held the rift.") + return + empty_clock = 0.0 + match phase: + "waiting", "interval": + clock -= delta + if clock <= 0.0: + start_wave(wave + 1, pilots.size()) + "fighting": + tick_escorts(delta) + for alien in wave_aliens: + if alien.alive: + return + if wave >= GalaxyGates.WAVES.size() - 1: + victory() + else: + phase = "interval" + clock = GalaxyGates.WAVE_DELAY + arena_message("Wave %d cleared. Next wave in %d seconds." % [wave + 1, int(GalaxyGates.WAVE_DELAY)]) + publish() + + +func start_wave(index: int, pilots: int) -> void: + wave = index + phase = "fighting" + escort_clock = 0.0 + wave_aliens.clear() + var counts := GalaxyGates.wave_counts(wave, pilots) + var parts: PackedStringArray = [] + for kind: String in counts: + var spawned := 0 + for alien in arena_aliens(): + if spawned >= counts[kind]: + break + if alien.kind == kind and not alien.alive: + spawn(alien, wave_point(kind)) + spawned += 1 + parts.append("%d %s" % [spawned, kind + ("s" if spawned != 1 else "")]) + arena_message("Wave %d of %d: %s." % [wave + 1, GalaxyGates.WAVES.size(), ", ".join(parts)]) + publish() + + +func wave_point(kind: String) -> Vector3: + var origin := SectorMaps.origin(GalaxyGates.MAP) + var boss := kind == "Mothership" + var point := origin + Vector3(0, 60, -450) + # Keep spawn points clear of the arena's asteroid colliders. + for attempt in range(48): + if not boss or attempt > 0: + var spread := 1.0 if not boss else 0.25 + point = (origin + Vector3(0, 60, -450) if boss else origin + Vector3(0, 0, -250)) + Vector3( + rng.randf_range(-320, 320), rng.randf_range(-120, 120), rng.randf_range(-170, 170)) * spread + if clear_of_rocks(point, 40.0 if boss else 15.0): + return point + return point + + +func clear_of_rocks(point: Vector3, margin: float) -> bool: + var terrain: Node3D = sector().map_terrain.get(GalaxyGates.MAP) + if terrain == null: + return true + for rock: Node in terrain.get_children(): + var body := rock as StaticBody3D + var shape := (body.get_child(0) as CollisionShape3D).shape as SphereShape3D + if point.distance_to(body.global_position) < shape.radius + margin: + return false + return true + + +func spawn(alien: Alien, point: Vector3) -> void: + alien.home_position = point + alien.position = point + alien.rotation = Vector3.ZERO + alien.patrol_time = 0.0 + alien.returning = false + alien.reset_encounter() + wave_aliens.append(alien) + + +# The mothership launches Shardling escorts from its hangar while it survives. +func tick_escorts(delta: float) -> void: + var boss: Alien = null + for alien in wave_aliens: + if alien.kind == "Mothership" and alien.alive: + boss = alien + if boss == null: + return + escort_clock += delta + if escort_clock < GalaxyGates.ESCORT_INTERVAL: + return + escort_clock = 0.0 + var launched := 0 + for alien in arena_aliens(): + if launched < GalaxyGates.ESCORTS and alien.kind == "Shardling" and not alien.alive: + wave_aliens.erase(alien) + spawn(alien, boss.position + Vector3(rng.randf_range(-40, 40), -20, rng.randf_range(-40, 40))) + launched += 1 + if launched > 0: + arena_message("The mothership launches %d Shardlings." % launched) + + +func victory() -> void: + phase = "victory" + clock = GalaxyGates.VICTORY_TIME + SectorMaps.rift_open = false + var session: FlightSession = combat.session + var winners: Array[int] = [] + var items: Dictionary[int, bool] = {} + var rewards := {} + for id: int in combat.records: + if lives.has(key(id)): + winners.append(id) + items[id] = rng.randf() < float(GalaxyGates.REWARD["item_chance"]) + rewards[key(id)] = {"credits": GalaxyGates.REWARD["credits"], "research": GalaxyGates.REWARD["research"], + "x4": GalaxyGates.REWARD["x4"], "item": GalaxyGates.REWARD["item"] if items[id] else ""} + # Rewards are persistent; runs only start on a dedicated server. One save + # covers every winner before anyone sees a reward. + if not session.sector.dedicated_server: + publish() + return + if not rewards.is_empty() and not session.store.reward_gate(rewards): + session.stop_for_save_failure() + return + for id: int in winners: + var ship := session.ships[id] + var pilot: Dictionary = session.store.pilots[key(id)] + combat.records[id]["credits"] = pilot["credits"] + ship.ammo = pilot["ammo"].duplicate() + combat.message(id, "Vashar mothership destroyed. Their invasion is set back. %s. The rift closes in %d seconds." % [GalaxyGates.reward_text(items[id]), int(GalaxyGates.VICTORY_TIME)]) + combat.publish_inventory(id) + publish() + + +func fail(reason: String) -> void: + broadcast("%s collapsed. %s The gate parts are lost." % [GalaxyGates.NAME, reason]) + close() + + +func close() -> void: + for id in inside(): + combat.message(id, "The rift is closing. Returning to M1.") + combat.session.transfer(id, 0) + # Arena loot belongs to this run; the next one starts with an empty rift. + sector().loot.clear_map(GalaxyGates.MAP) + reset() + publish() + + +func arena_message(text: String) -> void: + for id in inside(): + combat.message(id, text) + + +func broadcast(text: String) -> void: + for id: int in combat.records: + combat.message(id, text) + + +## Run summary for one pilot's HUD and station page. +func state_for(id: int, pilots: int = -1) -> Dictionary: + if not active: + return {"active": false} + if pilots < 0: + pilots = inside().size() + # Seconds until the next wave; clients count down locally from receipt and + # stop while the rift is empty, matching the paused server clock. + var countdown := clock if phase in ["waiting", "interval"] else -1.0 + return {"active": true, "open": SectorMaps.rift_open, "phase": phase, "wave": wave + 1, "waves": GalaxyGates.WAVES.size(), + "lives": lives.get(key(id), GalaxyGates.LIVES), "entered": lives.has(key(id)), "builder": builder, "pilots": pilots, + "countdown": countdown, "paused": pilots == 0} + + +func publish() -> void: + var pilots := inside().size() + for id: int in combat.records: + if id == 1: + combat.gate_state(state_for(id, pilots)) + else: + combat.gate_state.rpc_id(id, state_for(id, pilots)) diff --git a/scripts/gate_run.gd.uid b/scripts/gate_run.gd.uid new file mode 100644 index 0000000..abb8707 --- /dev/null +++ b/scripts/gate_run.gd.uid @@ -0,0 +1 @@ +uid://dcyfe3q6t3urq diff --git a/scripts/hud.gd b/scripts/hud.gd index b07550c..b3b432b 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -589,9 +589,16 @@ func draw_context() -> void: marker_labels.append(layout.transform_rect("context", comm_rect)) point.y = comm_rect.end.y + 8 var messages: Array[String] = [] - for destination: int in SectorMaps.GATES[sector.map_id]: + for destination: int in SectorMaps.links(sector.map_id): if sector.player.position.distance_to(SectorMaps.gate_position(sector.map_id, destination)) <= SectorMaps.JUMP_RADIUS: - messages.append("%s / JUMP TO %s / GATE PROTECTED" % [GameSettings.binding_text("jump_gate"), SectorMaps.code(destination)]) + var place := "THE VASHAR RIFT" if destination == GalaxyGates.MAP else SectorMaps.code(destination) + if sector.map_id == GalaxyGates.MAP and sector.session.combat.gate_summary.get("phase", "") == "fighting": + messages.append("RIFT EXIT SEALED / CLEAR THE WAVE TO LEAVE") + else: + messages.append("%s / JUMP TO %s%s" % [GameSettings.binding_text("jump_gate"), place, "" if sector.map_id == GalaxyGates.MAP else " / GATE PROTECTED"]) + var run := gate_status() + if not run.is_empty(): + messages.append(run) if CargoResources.units(sector.cargo) >= sector.cargo_capacity: messages.append("CARGO FULL / SELL AT OUTPOST 01 [B]") if sector.toast_time > 0: @@ -707,6 +714,7 @@ func _draw() -> void: draw_objectives() layout.end_draw(self) draw_context() + draw_gate_countdown() draw_tutorial() draw_performance() if layout.begin_draw(self, "ship"): @@ -729,19 +737,16 @@ func _draw() -> void: draw_line(center + Vector2(3, 0), center + Vector2(8, 0), Color(INK, 0.5)) draw_circle(center, 2.0, AMBER) layout.end_draw(self) + draw_gate_parts() if sector.map_id == 0: marker(Sector.STATION_POSITION, "OUTPOST 01", GREEN, false) var site := Story.site(sector.story_state(), sector.map_id) if not site.is_empty(): marker(Story.site_position(site), "OBJECTIVE / " + str(site["site"]).to_upper(), GOLD, false) - for destination: int in SectorMaps.GATES[sector.map_id]: - marker(SectorMaps.gate_position(sector.map_id, destination), "GATE TO " + SectorMaps.code(destination), SectorMaps.MAPS[destination]["color"], false, null, false) + for destination: int in SectorMaps.links(sector.map_id): + marker(SectorMaps.gate_position(sector.map_id, destination), SectorMaps.gate_label(destination), SectorMaps.MAPS[destination]["color"], false, null, false) if is_instance_valid(sector.target): alien_marker(sector.target as Alien) - for id: int in sector.loot.drops: - if sector.loot.is_presented(id): - var drop: Dictionary = sector.loot.drops[id] - marker(drop["position"], "LOOT %d UNITS / FLY CLOSE" % CargoResources.units(drop["resources"]), AMBER, false, null, false) for alien_id: int in sector.aliens: var enemy := sector.aliens[alien_id] if enemy != sector.target and enemy.alive and enemy.visible: @@ -881,3 +886,66 @@ func occupied(rect: Rect2) -> bool: if label.intersects(rect): return true return false + + +func draw_gate_parts() -> void: + for id: int in sector.loot.drops: + var drop: Dictionary = sector.loot.drops[id] + var parts := int(drop.get("parts", 0)) + if parts > 0 and sector.loot.is_presented(id): + var caption := "%d GATE PART%s" % [parts, "" if parts == 1 else "S"] + marker(drop["position"], caption, GalaxyGates.GLOW, false, null, false) + + +# One-line Vashar Gate run status: wave and lives inside the rift, an invitation at M1. +func gate_status() -> String: + var run: Dictionary = sector.session.combat.gate_summary if is_instance_valid(sector.session) else {} + if not run.get("active", false): + return "" + if sector.map_id == GalaxyGates.MAP: + if run["phase"] == "victory": + return "VASHAR GATE CLEARED / RETURN THROUGH THE GATE" + var wave := "WAVE %d OF %d" % [run["wave"], run["waves"]] + if gate_countdown() >= 0.0: + wave = "WAVE %d IN %d s" % [int(run["wave"]) + 1, ceili(gate_countdown())] + return "VASHAR GATE / %s / %d LIVES" % [wave, run["lives"]] + if sector.map_id == 0 and run.get("open", false): + return "VASHAR GATE OPEN NEAR OUTPOST 01 / %d LIVES" % run["lives"] if run["lives"] > 0 else "VASHAR GATE OPEN / NO LIVES LEFT" + return "" + + +## Seconds until the next Vashar wave, counted down locally from the last +## server update; -1 without a pending wave. Paused while the rift is empty. +func gate_countdown() -> float: + var run: Dictionary = sector.session.combat.gate_summary if is_instance_valid(sector.session) else {} + if not run.get("active", false) or float(run.get("countdown", -1.0)) < 0.0: + return -1.0 + if run.get("paused", false): + return float(run["countdown"]) + return maxf(0.0, float(run["countdown"]) - (Time.get_ticks_msec() - int(run.get("received", 0))) / 1000.0) + + +## Large centered countdown inside the rift before each wave. +func draw_gate_countdown() -> void: + if sector.map_id != GalaxyGates.MAP: + return + var seconds := gate_countdown() + if seconds < 0.0: + return + var run: Dictionary = sector.session.combat.gate_summary + var title := "WAVE %d OF %d" % [int(run["wave"]) + 1, int(run["waves"])] + if int(run["wave"]) + 1 == int(run["waves"]): + title = "FINAL WAVE / VASHAR MOTHERSHIP" + var number := str(ceili(seconds)) + var center := Vector2(size.x * 0.5, size.y * 0.3) + var title_width := font.get_string_size(title, HORIZONTAL_ALIGNMENT_LEFT, -1, 26).x + var number_width := font.get_string_size(number, HORIZONTAL_ALIGNMENT_LEFT, -1, 84).x + var box := Rect2(center - Vector2(maxf(title_width, 220) * 0.5 + 28, 70), Vector2(maxf(title_width, 220) + 56, 150)) + draw_rect(box, Color(0.02, 0.03, 0.04, 0.72)) + draw_rect(Rect2(box.position, Vector2(box.size.x, 3)), GalaxyGates.GLOW) + text_at(Vector2(center.x - title_width * 0.5, box.position.y + 36), title, 26, GalaxyGates.GLOW) + text_at(Vector2(center.x - number_width * 0.5, box.position.y + 118), number, 84, INK) + var caption := "WAITING FOR PILOTS" if run.get("paused", false) else "ALIENS INCOMING" + var caption_width := font.get_string_size(caption, HORIZONTAL_ALIGNMENT_LEFT, -1, 14).x + text_at(Vector2(center.x - caption_width * 0.5, box.end.y - 8), caption, 14, Color(INK, 0.7)) + marker_labels.append(box) diff --git a/scripts/main_menu.gd b/scripts/main_menu.gd index 554b017..d0f0325 100644 --- a/scripts/main_menu.gd +++ b/scripts/main_menu.gd @@ -20,9 +20,6 @@ var home: Control var ship_art: ShipHangarPreview var ship_title: Label var notice: Label -var placeholder: PanelContainer -var placeholder_title: Label -var placeholder_icon: TextureRect var selected_page := "overview" var last_model := "" var canvas: Control @@ -45,7 +42,6 @@ var opening_page := false var page_scrim: TextureRect var hints: HBoxContainer var hint_action: Label -var placeholder_heading: Label var brand_slash: Label var page_name: Label var header_accent: ColorRect @@ -130,23 +126,6 @@ func _ready() -> void: compact.content_margin_left = 16 button.add_theme_stylebox_override(state, compact) build_home() - placeholder = PanelContainer.new() - placeholder.theme = StationUi.page_theme() - placeholder.add_theme_stylebox_override("panel", StyleBoxEmpty.new()) - add_child(placeholder) - var future := StationUi.rows(placeholder, 16) - placeholder_heading = StationUi.header(future, "GALAXY GATES", "OPERATIONS") - var upper := Control.new() - upper.size_flags_vertical = Control.SIZE_EXPAND_FILL - future.add_child(upper) - placeholder_icon = StationUi.art(future, "ship", Vector2(96, 96)) - placeholder_icon.modulate = Color("60717e") - placeholder_title = StationUi.heading(future, "COMING SOON", 24, MUTED) - placeholder_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER - var lower := Control.new() - lower.size_flags_vertical = Control.SIZE_EXPAND_FILL - future.add_child(lower) - placeholder.hide() hide() @@ -270,16 +249,6 @@ func build_navigation() -> void: var page: String = entry[0] var button := rail_button(entry[1], page, func(): select_page(page)) button.toggle_mode = true - if page == "gates": - button.add_theme_color_override("font_color", Color("60717e")) - button.add_theme_color_override("font_hover_color", Color("60717e")) - button.add_theme_color_override("icon_normal_color", Color("60717e")) - button.add_theme_color_override("icon_hover_color", Color("60717e")) - button.add_theme_stylebox_override("hover", button.get_theme_stylebox("normal")) - button.tooltip_text = "Coming soon" - var soon := label(button, "COMING SOON", 11, Color("60717e"), true) - soon.add_theme_font_override("font", StationUi.tracked(true, 3)) - soon.position = Vector2(82, 48) navigation[page] = button @@ -446,7 +415,7 @@ func hide_pages() -> void: sector.research_menu.hide() sector.hud.contract_panel.hide() sector.settings_menu.dismiss() - placeholder.hide() + sector.gate_menu.hide() sector.skylab_menu.hide() home.hide() @@ -507,10 +476,7 @@ func select_page(page: String) -> void: "quests": sector.hud.toggle_contracts() "settings": sector.settings_menu.open() "connection": sector.session.open_menu() - "gates": - placeholder_heading.text = "GALAXY GATES" - placeholder_icon.texture = load("res://assets/ui/menu/%s.svg" % page) - placeholder.show() + "gates": sector.gate_menu.open() opening_page = false if not home.visible: navigation[page].grab_focus() @@ -630,6 +596,8 @@ func _process(_delta: float) -> void: selected_page = "refining" elif sector.research_menu.visible: selected_page = "research" + elif sector.gate_menu.visible: + selected_page = "gates" elif sector.hud.contract_panel.visible: selected_page = "quests" elif sector.settings_menu.panel.visible: @@ -674,6 +642,6 @@ func _process(_delta: float) -> void: StationUi.set_text(stat_values["damage"], str(int(stats["damage"]))) StationUi.set_text(stat_values["speed"], "%d m/s" % stats["speed"]) StationUi.set_text(stat_values["cargo"], "%d / %d" % [CargoResources.units(sector.cargo), sector.cargo_capacity]) - for panel: Control in [placeholder, sector.shop, sector.equipment_menu, sector.resource_workshop, sector.research_menu, sector.hud.contract_panel]: + for panel: Control in [sector.gate_menu, sector.shop, sector.equipment_menu, sector.resource_workshop, sector.research_menu, sector.hud.contract_panel]: if panel.visible: fit_panel(panel, Vector2(1150, 690)) diff --git a/scripts/pilot_store.gd b/scripts/pilot_store.gd index 2a87fe9..9960c43 100644 --- a/scripts/pilot_store.gd +++ b/scripts/pilot_store.gd @@ -120,6 +120,8 @@ func open(directory: String) -> bool: Research.normalize(pilot["equipment"]["research"]) if pilot["equipment"].has("story"): Story.normalize(pilot["equipment"]["story"]) + if pilot["equipment"].has("gates"): + GalaxyGates.normalize(pilot["equipment"]["gates"]) if data["version"] < 3: if pilot.has("cargo"): return fail("Unexpected cargo in legacy save. Original file preserved.") @@ -240,8 +242,8 @@ func verifies(id: String, nonce: PackedByteArray, proof: PackedByteArray) -> boo # Commit all shares of a kill together, before combat publishes the new balances. # Research holds points earned by each pilot in this transaction; stories hold -# each pilot's next chapter position. -func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary = {}, ammo: Dictionary = {}, boosts: Dictionary = {}, research: Dictionary = {}, stories: Dictionary = {}) -> bool: +# each pilot's next chapter position; gates hold each pilot's galaxy gate parts. +func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary = {}, ammo: Dictionary = {}, boosts: Dictionary = {}, research: Dictionary = {}, stories: Dictionary = {}, gates: Dictionary = {}) -> bool: if failed or not locked: return false var next := pilots.duplicate(true) @@ -275,6 +277,34 @@ func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary if not next.has(id) or not Story.valid(stories[id]): return fail("Invalid server story update.") next[id]["equipment"]["story"] = stories[id].duplicate() + for id: String in gates: + if not next.has(id) or not GalaxyGates.valid(gates[id]): + return fail("Invalid server gate update.") + next[id]["equipment"]["gates"] = gates[id].duplicate() + return persist(next) + + +# Victory rewards for one gate run, saved together for every winner. Each reward +# holds credits, research points, x4 shots and an optional storage item model. +func reward_gate(rewards: Dictionary) -> bool: + if failed or not locked: + return false + var next := pilots.duplicate(true) + for id: String in rewards: + var reward: Dictionary = rewards[id] + if not next.has(id): + return fail("Invalid server gate reward.") + var pilot: Dictionary = next[id] + pilot["credits"] = mini(MAX_CREDITS, int(pilot["credits"]) + int(reward["credits"])) + Research.add_points(pilot["equipment"], int(reward["research"])) + pilot["ammo"]["x4"] = mini(Ammunition.MAX_SHOTS, int(pilot["ammo"]["x4"]) + int(reward["x4"])) + if not str(reward["item"]).is_empty(): + var item_id := "gate-" + Crypto.new().generate_random_bytes(8).hex_encode() + if pilot["equipment"]["items"].has(item_id): + return fail("Gate reward item ID conflict.") + pilot["equipment"]["items"][item_id] = {"model": reward["item"], "ship": "", "slot": ""} + if not Equipment.valid(pilot["equipment"]) or not Ammunition.valid(pilot["ammo"]): + return fail("Invalid server gate reward.") return persist(next) diff --git a/scripts/resource_loot.gd b/scripts/resource_loot.gd index 4915cbc..21af053 100644 --- a/scripts/resource_loot.gd +++ b/scripts/resource_loot.gd @@ -16,13 +16,23 @@ func clear() -> void: apply_drop(id, {}) collect_clock = 0.0 -func spawn_drop(alien: Alien) -> void: +# Removes every box on one map, telling its clients. +func clear_map(map: int) -> void: + for id: int in drops.keys(): + if int(drops[id].get("map", 0)) == map: + change(id, {}) + +# `parts` are galaxy gate parts carried in the box; they need no cargo space. +func spawn_drop(alien: Alien, parts: int = 0) -> void: if sector.session.active and not multiplayer.is_server(): return if drops.size() >= MAX_DROPS: change(drops.keys()[0], {}) next_id += 1 - change(next_id, {"map": alien.map_id, "position": alien.position, "resources": CargoResources.roll(alien.kind), "ttl": LIFETIME}) + var data := {"map": alien.map_id, "position": alien.position, "resources": CargoResources.roll(alien.kind), "ttl": LIFETIME} + if parts > 0: + data["parts"] = parts + change(next_id, data) func change(id: int, data: Dictionary) -> void: var map: int = data.get("map", drops.get(id, {}).get("map", 0)) @@ -52,7 +62,8 @@ func apply_drop(id: int, data: Dictionary) -> void: if data["resources"].has(resource): richest = resource var material := StandardMaterial3D.new() - material.albedo_color = CargoResources.TYPES[richest]["color"] + material.albedo_color = GalaxyGates.GLOW if int(data.get("parts", 0)) > 0 else CargoResources.TYPES[richest]["color"] + meshes[id].scale = Vector3.ONE * (1.5 if int(data.get("parts", 0)) > 0 else 1.0) material.emission_enabled = true material.emission = material.albedo_color material.emission_energy_multiplier = 1.8 diff --git a/scripts/sector.gd b/scripts/sector.gd index ce2c064..25d14a1 100644 --- a/scripts/sector.gd +++ b/scripts/sector.gd @@ -49,6 +49,7 @@ var shop: StationShop var equipment_menu: ShipEquipment var resource_workshop: ResourceWorkshop var research_menu: ResearchMenu +var gate_menu: GateMenu var story_sites: StorySites var dedicated_server: bool = false var client_only: bool = true @@ -108,7 +109,9 @@ func _ready() -> void: world_aliens[id] = enemy map_rosters[map][id] = enemy add_child(enemy) - if dedicated_server or not client_only: + if SectorMaps.MAPS[map].get("instance", false): + GateRun.dormant(enemy) + elif dedicated_server or not client_only: relocate_alien(enemy) enemy.destroyed.connect(on_destroyed) enemy.fired.connect(on_laser.bind(enemy)) @@ -152,6 +155,9 @@ func _ready() -> void: research_menu = ResearchMenu.new() research_menu.sector = self shop_layer.add_child(research_menu) + gate_menu = GateMenu.new() + gate_menu.sector = self + shop_layer.add_child(gate_menu) skylab_menu = SkylabMenu.new() skylab_menu.sector = self shop_layer.add_child(skylab_menu) @@ -269,6 +275,9 @@ func _unhandled_input(event: InputEvent) -> void: if research_menu.visible: research_menu.close() return + if gate_menu.visible: + gate_menu.close() + return session.menu.hide() set_paused(not paused) return @@ -386,7 +395,7 @@ func _physics_process(delta: float) -> void: enemy.tick_combat(delta) if enemy.alive: enemy.fly(delta, player if player.alive and player.map_id == enemy.map_id and not SectorMaps.protected(player) and player.position.distance_to(enemy.position) < float(enemy.tuning()["detection"]) else null, STATION_POSITION) - else: + elif enemy.map_id != GalaxyGates.MAP: enemy.respawn = maxf(0.0, enemy.respawn - delta) if enemy.respawn <= 0.0: relocate_alien(enemy) @@ -419,7 +428,7 @@ func alien_home_clear(point: Vector3, enemy: Alien) -> bool: return false if enemy.map_id == 0 and point.distance_to(STATION_POSITION) < float(enemy.tuning()["detection"]) + PROTECTION_RADIUS + 15.0: return false - for destination: int in SectorMaps.GATES[enemy.map_id]: + for destination: int in SectorMaps.endpoints(enemy.map_id): if point.distance_to(SectorMaps.gate_position(enemy.map_id, destination)) < float(enemy.tuning()["detection"]) + SectorMaps.PROTECTION_RADIUS + 35.0: return false for other: Alien in world_aliens.values(): @@ -695,8 +704,9 @@ func build_map_visuals(map: int) -> void: gates.name = "Map%dGates" % (map + 1) add_child(gates) map_scenery[map].append(gates) - for destination: int in SectorMaps.GATES[map]: + for destination: int in SectorMaps.endpoints(map): SectorMaps.gate_model(gates, map, destination) + refresh_rift() # Newly created materials must respect the current device setting too. for node: Node3D in map_scenery[map]: SectorVisuals.configure_texture_filtering(node, settings.anisotropic_filtering > 0) @@ -732,7 +742,14 @@ func activate_map(map: int) -> void: if int(loot.drops[id].get("map", 0)) == map: loot.apply_drop(id, loot.drops[id]) if is_instance_valid(hud): - hud.navigation.waypoint_key = "station" if map == 0 else "gate%d" % SectorMaps.GATES[map].keys()[0] + hud.navigation.waypoint_key = "station" if map == 0 else "gate%d" % SectorMaps.links(map).keys()[0] hud.navigation.reset_view() hud.navigation.close_overview(false) SectorBackdrop.activate(self, map) + + +# Shows the Outpost 01 Vashar Gate only while the server reports an open run. +func refresh_rift() -> void: + var gate := get_node_or_null("Map1Gates/GateToM%d" % (GalaxyGates.MAP + 1)) as Node3D + if gate != null: + gate.visible = SectorMaps.rift_open diff --git a/scripts/sector_backdrop.gd b/scripts/sector_backdrop.gd index 833d37c..3936040 100644 --- a/scripts/sector_backdrop.gd +++ b/scripts/sector_backdrop.gd @@ -7,6 +7,8 @@ const THEMES := [ {"planet": Vector3(2000, 1020, -3550), "radius": 1350.0, "ocean": Color("554632"), "land": Color("b48a56"), "atmosphere": Color("b68d52"), "water": 0.0, "clouds": 0.08, "mining": 1.0, "cool": Color("80653a"), "warm": Color("c48a3c"), "light": Color("e0b46a")}, {"planet": Vector3(-2150, 1200, -3750), "radius": 1150.0, "ocean": Color("382c29"), "land": Color("916957"), "atmosphere": Color("b36045"), "water": 0.0, "clouds": 0.04, "mining": 0.8, "cool": Color("68362e"), "warm": Color("bc5940"), "light": Color("d98660")}, {"planet": Vector3(2050, 1100, -3500), "radius": 1350.0, "ocean": Color("1d263c"), "land": Color("555265"), "atmosphere": Color("557ca7"), "water": 0.2, "clouds": 0.18, "mining": 1.0, "cool": Color("454980"), "warm": Color("9161b2"), "light": Color("558fac")}, + # Vashar Rift: the faction's staging space beyond the gate. + {"planet": Vector3(-1700, 900, -3600), "radius": 1500.0, "ocean": Color("1a0f24"), "land": Color("3b2346"), "atmosphere": Color("b04cff"), "water": 0.0, "clouds": 0.0, "mining": 1.0, "cool": Color("3a1752"), "warm": Color("b0367f"), "light": Color("c86bff")}, ] @@ -123,6 +125,12 @@ static func build(parent: Node3D, map: int) -> Node3D: carrier(root, wreck, Vector3(0.15, -1.3, 0.22)) human_relay(root, Vector3(-1450, -280, -1500), 1.5) human_ring(root, Vector3(-1800, 500, 1800), 330.0, Vector3(0.3, -0.7, 0.4), false) + elif map == GalaxyGates.MAP: + # No human structures: alien relays and collectors staging the next invasion wave. + planet_collectors(root, planet_position, radius, 4) + alien_relay(root, Vector3(1600, 200, -2300), 1.4) + alien_relay(root, Vector3(-1500, -260, 1900), 0.9) + alien_collar(root, Vector3(1900, -120, 1500), 260.0, Vector3(0.4, 0.2, -0.3), "StagingCollar") else: human_ring(root, planet_position, radius*1.3, Vector3(0.18, 0.32, -0.4), true) planet_collectors(root, planet_position, radius, 3) diff --git a/scripts/sector_maps.gd b/scripts/sector_maps.gd index 5a84b74..d4d75f8 100644 --- a/scripts/sector_maps.gd +++ b/scripts/sector_maps.gd @@ -11,6 +11,11 @@ const MAPS := { 1: {"name": "M2 / Outer Patrol", "color": Color("67dfb5"), "aliens": ["Skirmisher", "Skirmisher", "Skirmisher", "Raider", "Raider"], "description": "Tier 1 / Skirmishers and Raiders / no station"}, 2: {"name": "M3 / Debris Fields", "color": Color("efb35f"), "aliens": ["Marauder", "Marauder", "Marauder", "Warden", "Warden"], "description": "Tier 2 / Marauders and Wardens / no station"}, 3: {"name": "M4 / Frontier", "color": Color("d48eef"), "aliens": ["Ravager", "Ravager", "Ravager", "Overlord", "Overlord"], "description": "Tier 3 / Ravagers and Overlords / no station"}, + # Vashar Gate arena: outside the connected network, entered only through an open gate. + # Its pool matches GalaxyGates.POOL; waves activate these aliens. + 4: {"name": "VG / Vashar Rift", "color": Color("c86bff"), "instance": true, + "aliens": ["Shardling", "Shardling", "Shardling", "Shardling", "Shardling", "Shardling", "Shardling", "Shardling", "Spireguard", "Spireguard", "Spireguard", "Spireguard", "Mothership"], + "description": "Vashar Gate / staging fleet / waves end with the mothership"}, } const GATES := { 0: {1: Vector3(0, 120, -900)}, @@ -18,6 +23,50 @@ const GATES := { 2: {1: Vector3(750, -120, 300), 3: Vector3(-720, 220, -400)}, 3: {1: Vector3(-760, 80, 300), 2: Vector3(730, -160, -400)}, } +# Galaxy gate endpoints: the Vashar Gate near Outpost 01 and the arena's return gate. +const SPECIAL_GATES := { + 0: {4: Vector3(320, 40, -300)}, + 4: {0: Vector3(0, 0, 700)}, +} +# Replicated from the server's gate run; the Outpost 01 entry exists only while open. +static var rift_open := false +# Read-only link tables per map, rebuilt when the open portal changes. Hot paths +# (protection, contacts, HUD) look links up every tick without allocating. +static var link_cache := {} +static var link_cache_open := false + +# Maps in the connected network, excluding gate arenas. +static func network_maps() -> Array[int]: + var result: Array[int] = [] + for map: int in MAPS: + if not MAPS[map].get("instance", false): + result.append(map) + return result + + +# Every usable gate on a map, keyed by destination. Callers must not modify it. +static func links(map: int) -> Dictionary: + if link_cache_open != rift_open: + link_cache.clear() + link_cache_open = rift_open + if not link_cache.has(map): + var result: Dictionary = GATES.get(map, {}).duplicate() + for destination: int in SPECIAL_GATES.get(map, {}): + if map != 0 or rift_open: + result[destination] = SPECIAL_GATES[map][destination] + link_cache[map] = result + return link_cache[map] + + +# Every gate endpoint on a map, open or closed; used to keep alien homes clear. +static func endpoints(map: int) -> Dictionary: + var result: Dictionary = GATES.get(map, {}).duplicate() + result.merge(SPECIAL_GATES.get(map, {})) + return result + + +static func gate_label(destination: int) -> String: + return GalaxyGates.NAME.to_upper() if destination == GalaxyGates.MAP else "GATE TO " + code(destination) # Short map label such as "M2", used where a gate names its destination. static func code(map: int) -> String: @@ -26,20 +75,26 @@ static func code(map: int) -> String: static func origin(map: int) -> Vector3: return Vector3(map * 15000.0, 0, 0) +static func gate_point(map: int, destination: int) -> Vector3: + return GATES[map][destination] if GATES.get(map, {}).has(destination) else SPECIAL_GATES[map][destination] + static func gate_position(map: int, destination: int) -> Vector3: - return origin(map) + GATES[map][destination] + return origin(map) + gate_point(map, destination) static func arrival(map: int, source: int, slot: int = 0) -> Vector3: - var gate: Vector3 = GATES[map][source] + var gate: Vector3 = gate_point(map, source) var inward := -gate.normalized() var side := inward.cross(Vector3.UP).normalized() return origin(map) + gate + inward * 30.0 + side * ((slot % 5) - 2) * 6.0 + Vector3.UP * (slot / 5) * 6.0 static func protected(ship: SpaceShip) -> bool: + # The gate arena has no safe zone: aliens may pursue pilots to the exit. + if ship.map_id == GalaxyGates.MAP: + return false if ship.map_id == 0 and ship.position.distance_to(Sector.STATION_POSITION) <= Sector.PROTECTION_RADIUS: return true if ship.get_parent() is Sector: - for destination: int in GATES[ship.map_id]: + for destination: int in links(ship.map_id): if ship.position.distance_to(gate_position(ship.map_id, destination)) <= PROTECTION_RADIUS: return true return false @@ -47,11 +102,14 @@ static func protected(ship: SpaceShip) -> bool: static func first_hop(source: int, destination: int) -> int: if source == destination: return -1 + # Gate arenas lead only back to Outpost 01. + if source == GalaxyGates.MAP: + return 0 var pending: Array[int] = [source] var previous := {source: -1} while not pending.is_empty(): var map: int = pending.pop_front() - for neighbor: int in GATES[map]: + for neighbor: int in GATES.get(map, {}): if previous.has(neighbor): continue previous[neighbor] = map @@ -65,6 +123,7 @@ static func first_hop(source: int, destination: int) -> int: static func gate_model(parent: Node3D, map: int, destination: int) -> void: var root := Node3D.new() root.name = "GateToM%d" % (destination+1) + var vashar := GalaxyGates.MAP in [map, destination] root.position = gate_position(map, destination) parent.add_child(root) root.look_at(origin(map), Vector3.UP) @@ -80,12 +139,20 @@ static func gate_model(parent: Node3D, map: int, destination: int) -> void: surface.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED surface.albedo_color = Color(0.02,0.72,1.0) surface.emission_energy_multiplier = 0.4 + if vashar: + # The imported material is shared by every gate; tint a copy. + var violet := surface.duplicate() as BaseMaterial3D + violet.albedo_color = Color(0.78,0.42,1.0) + violet.emission = Color(0.78,0.42,1.0) + part.set_surface_override_material(index, violet) SectorVisuals.configure_texture_filtering(model) var aperture := QuadMesh.new() aperture.size = Vector2.ONE*25.2 var energy := ShaderMaterial.new() energy.shader = preload("res://shaders/gate_portal.gdshader") energy.set_shader_parameter("turbulence",preload("res://assets/sector/nebula-panorama.png")) + if vashar: + energy.set_shader_parameter("energy_color", Color(0.8,0.3,1.0)) var portal := SectorVisuals.mesh(root,aperture,Vector3.ZERO,energy) portal.name = "Portal" portal.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF @@ -94,14 +161,14 @@ static func gate_model(parent: Node3D, map: int, destination: int) -> void: for side in [-1,1]: var light := OmniLight3D.new() light.position = Vector3(0,0,side*5.0) - light.light_color = Color("48e6f5") + light.light_color = Color("c86bff") if vashar else Color("48e6f5") light.light_energy = 5.0 light.omni_range = 29 light.omni_attenuation = 0.8 light.light_cull_mask = 2 root.add_child(light) var label := Label3D.new() - label.text = "GATE TO " + code(destination) + label.text = gate_label(destination) label.position = Vector3(0, 27, 0) label.font_size = 40 label.pixel_size = 0.08 diff --git a/scripts/session_combat.gd b/scripts/session_combat.gd index 84264c0..64024f6 100644 --- a/scripts/session_combat.gd +++ b/scripts/session_combat.gd @@ -19,6 +19,12 @@ var ammo_sequence: int = -1 var boost_save_clock: float = 0.0 var boost_sequence: int = -1 var lab_snapshot: Dictionary = {} + +# Server-side Vashar Gate run; clients keep the latest published summary. +var gate := GateRun.new(self) +var gate_summary: Dictionary = {"active": false} +var part_rng := RandomNumberGenerator.new() + var rocket_request_sequence: int = 0 var rocket_sequences: Dictionary[int, int] = {} var rocket_maps: Dictionary[String, int] = {} @@ -147,7 +153,7 @@ func begin() -> void: sector.player.simulation_authority = multiplayer.is_server() for alien: Alien in sector.world_aliens.values(): alien.simulation_authority = multiplayer.is_server() - if multiplayer.is_server(): + if multiplayer.is_server() and alien.map_id != GalaxyGates.MAP: sector.relocate_alien(alien) alien.position = alien.home_position alien.patrol_time = 0.0 @@ -163,6 +169,9 @@ func begin() -> void: alien.collision_layer = 2 if multiplayer.is_server() else 0 if not alien.damaged.is_connected(record_damage): alien.damaged.connect(record_damage) + gate.reset() + gate_summary = {"active": false} + part_rng.randomize() sector.notify("Alien contacts scattered across the sector. Press M to choose a destination.") @@ -417,12 +426,14 @@ func tick(delta: float) -> void: alien.tick_combat(delta) if alien.alive: alien.fly(delta, choose_target(alien), Sector.STATION_POSITION) - else: + elif alien.map_id != GalaxyGates.MAP: # The gate run owns arena spawns. alien.respawn = maxf(0.0, alien.respawn - delta) if alien.respawn <= 0.0: sector.relocate_alien(alien) alien.returning = false alien.reset_encounter() + gate.tick(delta) + if sector.dedicated_server and session.store.failed: return if records.has(1): update_local(records[1]) if session.benchmark_timing: @@ -503,7 +514,7 @@ func destroyed(ship: SpaceShip) -> void: saved_stories[id] = stories[id]["story"] if not balances.is_empty() and not session.save_balances(balances, contracts, research, saved_stories): return - session.sector.loot.spawn_drop(alien) + session.sector.loot.spawn_drop(alien, roll_gate_parts(alien)) for id: int in balances: var reward: int = balances[id] - records[id]["credits"] - payouts[id]["reward"] - int(stories.get(id, {}).get("credits", 0)) records[id]["credits"] = balances[id] @@ -538,6 +549,8 @@ func destroyed(ship: SpaceShip) -> void: session.sector.autopilot.cancel() ship.release_mouse() message(id, "Ship lost. Recovery cost: %d credits. Rescue in three seconds." % fee) + if ship.map_id == GalaxyGates.MAP: + gate.died(id) func request_repair() -> bool: @@ -898,6 +911,8 @@ func finish() -> void: session.sector.player.rockets.unload() session.sector.active_contracts = {} session.sector.loot.clear() + gate.reset() + gate_summary = {"active": false} cargo_holds.clear() session.sector.cargo = {} inventory.clear() @@ -1027,8 +1042,32 @@ func collect_loot() -> void: var changed: Dictionary[int, Dictionary] = {} var notices: Dictionary[int, Dictionary] = {} var saved: Dictionary = {} + var parts: Dictionary[int, int] = {} + # Parts recovered on the operation's map, which advance Signal Anomaly. + var qualifying: Dictionary[int, int] = {} for drop_id: int in session.sector.loot.drops: var drop: Dictionary = session.sector.loot.drops[drop_id].duplicate(true) + # Gate parts need no cargo space. Collectors take what their stock can + # hold, counting parts already assigned in this pass; any remainder stays + # in the box rather than being clamped away. + var remaining := int(drop.get("parts", 0)) + for carrier: int in part_collectors(drop): + var room: int = GalaxyGates.MAX_PARTS - int(GalaxyGates.state(session.store.pilots[session.pilot_ids[carrier]]["equipment"])["parts"]) - parts.get(carrier, 0) + var take: int = mini(remaining, room) + if take <= 0: + continue + parts[carrier] = parts.get(carrier, 0) + take + if int(drop.get("map", 0)) == int(GalaxyGates.SIGNAL["map"]): + qualifying[carrier] = qualifying.get(carrier, 0) + take + remaining -= take + if remaining == 0: + break + if remaining < int(drop.get("parts", 0)): + if remaining > 0: + drop["parts"] = remaining + else: + drop.erase("parts") + changed[drop_id] = {} if drop["resources"].is_empty() and remaining == 0 else drop var candidates: Array[int] = [] for id: int in records: var ship := session.ships[id] @@ -1044,7 +1083,7 @@ func collect_loot() -> void: var taken := CargoResources.collect(next[id][equipment["active_ship"]], drop["resources"], CargoResources.capacity(equipment)) if taken.is_empty(): continue - changed[drop_id] = {} if drop["resources"].is_empty() else drop + changed[drop_id] = {} if drop["resources"].is_empty() and int(drop.get("parts", 0)) == 0 else drop var extra := CargoResources.collect_bonus(next[id][equipment["active_ship"]], taken, Research.bonus(equipment, "loot"), CargoResources.capacity(equipment)) for resource: String in extra: taken[resource] += extra[resource] @@ -1054,15 +1093,33 @@ func collect_loot() -> void: notices[id][resource] = int(notices[id].get(resource, 0)) + taken[resource] if session.sector.dedicated_server: saved[session.pilot_ids[id]] = next[id] - if notices.is_empty(): + if notices.is_empty() and parts.is_empty(): return - # All nearby pickups commit once, before removing a single unit from space. - if session.sector.dedicated_server and not session.store.commit({}, {}, saved): + var gates := {} + var balances := {} + var research := {} + var results: Dictionary[int, Dictionary] = {} + for id: int in parts: + var pilot_id: String = session.pilot_ids[id] + results[id] = GalaxyGates.collect(GalaxyGates.state(session.store.pilots[pilot_id]["equipment"]), parts[id], qualifying.get(id, 0)) + gates[pilot_id] = results[id]["gates"] + if results[id]["completed"]: + balances[pilot_id] = mini(PilotStore.MAX_CREDITS, int(records[id]["credits"]) + int(results[id]["credits"])) + research[pilot_id] = results[id]["research"] + # All nearby pickups commit once, before removing a single unit or part from space. + if session.sector.dedicated_server and not session.store.commit(balances, {}, saved, {}, {}, research, {}, gates): session.stop_for_save_failure() return cargo_holds = next for drop_id: int in changed: session.sector.loot.change(drop_id, changed[drop_id]) + for id: int in results: + var gate_state: Dictionary = results[id]["gates"] + message(id, "Collected %d Vashar gate part%s. %d / %d toward the gate." % [parts[id], "" if parts[id] == 1 else "s", int(gate_state["parts"]), GalaxyGates.PARTS_REQUIRED]) + if results[id]["completed"]: + records[id]["credits"] = balances[session.pilot_ids[id]] + message(id, "SATO: %s %s." % [GalaxyGates.SIGNAL["done"], Story.reward_text(results[id]["credits"], results[id]["research"]) + " and +%d gate parts" % int(GalaxyGates.SIGNAL["parts"])]) + publish_inventory(id) for id: int in notices: message(id, "Collected " + CargoResources.describe(notices[id])) if session.sector.dedicated_server and not advance_story(id, "collect", CargoResources.units(notices[id])): @@ -1075,6 +1132,52 @@ func collect_loot() -> void: else: cargo_result.rpc_id(id, next[id]["starter"]) + +# Living pilots within pickup range who may take a box's gate parts, in +# priority order. Pilots running Signal Anomaly come first, so its guaranteed +# parts reach them; otherwise nearer pilots win, with ties in peer-ID order. +func part_collectors(drop: Dictionary) -> Array[int]: + var result: Array[int] = [] + if int(drop.get("parts", 0)) <= 0 or not session.sector.dedicated_server: + return result + var ranks: Dictionary[int, Vector2] = {} + for id: int in records: + var ship := session.ships[id] + if ship.map_id != int(drop.get("map", 0)) or ship.get_meta("docked", false) or not ship.alive: + continue + var distance := ship.position.distance_to(drop["position"]) + if distance > ResourceLoot.PICKUP_RADIUS: + continue + var running := GalaxyGates.signal_active(GalaxyGates.state(session.store.pilots[session.pilot_ids[id]]["equipment"])) + ranks[id] = Vector2(0.0 if running else 1.0, distance) + result.append(id) + result.sort_custom(func(a: int, b: int) -> bool: + return a < b if ranks[a].is_equal_approx(ranks[b]) else ranks[a] < ranks[b]) + return result + + +# Parts carried by a destroyed alien. Signal Anomaly guarantees one on its map +# when any contributing pilot has the operation active. +func roll_gate_parts(alien: Alien) -> int: + if not session.sector.dedicated_server: + return 0 + var guaranteed := false + if alien.map_id == int(GalaxyGates.SIGNAL["map"]): + for id: int in alien.contributors: + if GalaxyGates.signal_active(GalaxyGates.state(session.store.pilots[session.pilot_ids[id]]["equipment"])): + guaranteed = true + return GalaxyGates.roll_parts(alien.kind, part_rng, guaranteed) + + +@rpc("authority", "call_remote", "reliable") +func gate_state(data: Dictionary) -> void: + gate_summary = data + gate_summary["received"] = Time.get_ticks_msec() + if not multiplayer.is_server(): + SectorMaps.rift_open = data.get("open", false) + if not session.sector.dedicated_server: + session.sector.refresh_rift() + @rpc("authority", "call_remote", "reliable") func cargo_result(hold: Dictionary, capacity: int = 400) -> void: if session.active: diff --git a/scripts/station_actions.gd b/scripts/station_actions.gd index 0259b7f..a101155 100644 --- a/scripts/station_actions.gd +++ b/scripts/station_actions.gd @@ -25,6 +25,7 @@ static func apply(pilot: Dictionary, previous: Dictionary, sequence: int, action "research_reset": return research_reset(pilot, subject, ship, slot) "story_deliver", "story_skip": return story(pilot, action, subject, ship, slot) "configure_extra": return configure_extra(pilot, subject, ship, slot) + "gate_signal", "gate_assemble": return gate(pilot, action, subject, ship, slot) return "Unknown station action." @@ -43,6 +44,10 @@ static func result(pilot: Dictionary, action: String, subject: String, previous_ return "Preview: added %d research points." % (int(Research.state(equipment)["points"]) - previous_points) if action == "configure_extra": return "Extra settings saved." + if action == "gate_signal": + return "Signal Anomaly accepted. " + GalaxyGates.SIGNAL["objective"] + "." + if action == "gate_assemble": + return "%s assembled. It is opening near Outpost 01." % GalaxyGates.NAME if action == "research": return "%s researched to level %d." % [Research.SKILLS[subject]["name"], Research.level(Research.state(equipment), subject)] if action == "research_reset": @@ -281,6 +286,28 @@ static func story(pilot: Dictionary, action: String, subject: String, ship: Stri equipment["story"] = reward["story"] return "" +static func gate(pilot: Dictionary, action: String, subject: String, ship: String, slot: String) -> String: + if not subject.is_empty() or not ship.is_empty() or not slot.is_empty(): + return "Invalid gate request." + var equipment: Dictionary = pilot["equipment"] + var state := GalaxyGates.state(equipment) + var blocker := "" + match action: + "gate_signal": + blocker = GalaxyGates.accept_blocker(state) + state = state.duplicate() + state["signal"] = "active" + state["progress"] = 0 + "gate_assemble": + blocker = GalaxyGates.assemble_blocker(state) + if blocker.is_empty(): + state = GalaxyGates.assemble(state) + if not blocker.is_empty(): + return blocker + equipment["gates"] = state + return "" + + static func configure_extra(pilot: Dictionary, subject: String, ship: String, slot: String) -> String: var item: Dictionary = pilot["equipment"]["items"].get(subject, {}) var configurable: bool = not item.is_empty() and Equipment.MODELS[item["model"]].get("family", "") in ["ammo", "generators", "repair-auto"] diff --git a/scripts/station_desk.gd b/scripts/station_desk.gd index a41ed91..49d81d7 100644 --- a/scripts/station_desk.gd +++ b/scripts/station_desk.gd @@ -29,9 +29,18 @@ func station_request(id: int, sequence: int, action: String, subject: String, sh blocker = "" if records[id]["life"] != life: blocker = "Ship changed. Review your fitting after rescue." + if blocker.is_empty() and action in ["gate_assemble", "gate_preview"]: + blocker = combat.gate.open_blocker() + if blocker.is_empty() and action == "gate_preview" and not session.can_grant_test_credits(id): + blocker = "Preview gates are unavailable for this pilot on this server." if not blocker.is_empty(): publish_inventory(id, blocker) return + # Preview gates open without parts or a saved transaction. + if action == "gate_preview": + combat.gate.start("a preview pilot") + publish_inventory(id, "Preview: %s opened near Outpost 01." % GalaxyGates.NAME) + return var previous_revision: int = session.store.pilots[pilot_id]["equipment"]["revision"] var previous_ship: String = session.store.pilots[pilot_id]["equipment"]["active_ship"] var result := session.store.transact(pilot_id, sequence, action, subject, ship, slot, @@ -60,6 +69,8 @@ func station_request(id: int, sequence: int, action: String, subject: String, sh session.commands.erase(id) session.ships[id].velocity = Vector3.ZERO publish_inventory(id, result) + if action == "gate_assemble" and pilot["equipment"]["revision"] > previous_revision: + combat.gate.start("Pilot %d" % id) if action in ["buy", "buy_ship", "buy_ammo", "sell", "refine", "boost", "replace_boost", "research", "research_reset"] and pilot["equipment"]["revision"] > previous_revision: combat.message(id, result, "purchase") diff --git a/tests/alien_assets_test.gd b/tests/alien_assets_test.gd index dd760e7..77e9f43 100644 --- a/tests/alien_assets_test.gd +++ b/tests/alien_assets_test.gd @@ -59,8 +59,8 @@ func run() -> void: and alien.model.scale.is_equal_approx(Vector3.ONE * float(Alien.VISUAL_SCALE[kind])), kind + " retains its baked orientation with presentation scaling") var collision := alien.get_child(0) as CollisionShape3D - check(collision.shape is SphereShape3D and is_equal_approx(collision.shape.radius, 2.2), - kind + " keeps the 2.2 m collision sphere") + check(collision.shape is SphereShape3D and is_equal_approx(collision.shape.radius, float(Alien.TYPES[kind].get("radius", 2.2))), + kind + " keeps its configured collision sphere") check(alien.hull == Alien.TYPES[kind]["hull"] and alien.shield == Alien.TYPES[kind]["shield"] and alien.laser_damage == Alien.TYPES[kind]["damage"], kind + " keeps combat tuning") check_finish(kind, mesh) @@ -78,11 +78,14 @@ func run() -> void: check(alien.alive and alien.visible and alien.collision_layer == 2, kind + " respawn restores visibility and collision") alien.free() + # Vashar Gate aliens use procedural playtest models until authored art is approved. check(sizes.size() == Alien.TYPES.size() and sizes[0] < sizes[1] and sizes[1] < sizes[2], "Scout, Sentinel and Heavy retain increasing visual size") check(Alien.VISUAL_DIAMETERS.size() == Alien.TYPES.size(), "Every encounter type has an imported model and a mesh-free server diameter") - var roster: Array = Alien.TYPES.keys() + check_vashar() + # The Vashar Gate roster is its own faction progression, checked separately. + var roster: Array = Alien.TYPES.keys().filter(func(kind: String): return not GalaxyGates.POOL.has(kind)) roster.sort_custom(func(a: String, b: String): return Alien.TYPES[a]["hull"] < Alien.TYPES[b]["hull"]) var previous_diameter := 0.0 for kind: String in roster: @@ -147,7 +150,8 @@ func check_finish(kind: String, mesh: ArrayMesh) -> void: kind + " shares metallic and roughness maps") if material.resource_name.ends_with("coated armor"): painted = material.clearcoat_enabled - var minimum_lift := 2.0 if kind in ["Scout", "Sentinel", "Heavy"] else 0.3 + # Vashar armor keeps a low lift so near-black crystal contrasts with its violet seams. + var minimum_lift := 2.0 if kind in ["Scout", "Sentinel", "Heavy"] else (0.1 if GalaxyGates.POOL.has(kind) else 0.3) check(material.emission_enabled and material.emission == Color.WHITE and material.emission_operator == BaseMaterial3D.EMISSION_OP_MULTIPLY and material.emission_energy_multiplier >= minimum_lift @@ -159,6 +163,23 @@ func check_finish(kind: String, mesh: ArrayMesh) -> void: forward_optics = forward_optics or vertex.z < bounds.position.z + .04 rear_exhaust = rear_exhaust or vertex.z > bounds.end.z - bounds.size.length() * .08 check(textures.size() == 3 and painted and luminous, kind + " retains three shared maps, coated armor and emission") - check(forward_optics and rear_exhaust, kind + " cannons face -Z and exhausts face +Z") - check(lod_count > 0 and triangles > 30000, kind + " retains detailed geometry and generated distance LODs") + # Vashar crystals are deliberately low-poly faceted hulls without forward optics. + var vashar := GalaxyGates.POOL.has(kind) + check(vashar or (forward_optics and rear_exhaust), kind + " cannons face -Z and exhausts face +Z") + check(lod_count > 0 and triangles > (1500 if vashar else 30000), kind + " retains detailed geometry and generated distance LODs") print("ALIEN_GEOMETRY %s triangles=%d lod_levels=%d" % [kind, triangles, lod_count]) + + +func check_vashar() -> void: + var previous := 0.0 + for kind: String in GalaxyGates.POOL: + var alien := Alien.new() + alien.kind = kind + root.add_child(alien) + var instance := alien.model.find_children("*", "MeshInstance3D", true, false)[0] as MeshInstance3D + var diameter := instance.mesh.get_aabb().size.length() * float(Alien.VISUAL_SCALE[kind]) + check(diameter > previous, kind + " is larger than the previous Vashar tier") + check(is_equal_approx(SectorVisuals.destruction_size(alien), float(Alien.VISUAL_DIAMETERS[kind]) * float(Alien.VISUAL_SCALE[kind])), kind + " destruction size matches its exported model") + previous = diameter + print("ALIEN_SIZE %s diameter=%.2f m" % [kind, diameter]) + alien.free() diff --git a/tests/benchmark_store.gd b/tests/benchmark_store.gd index a55d073..44635b6 100644 --- a/tests/benchmark_store.gd +++ b/tests/benchmark_store.gd @@ -68,10 +68,10 @@ func replace_file(destination: String, text: String) -> bool: return result -func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary = {}, ammo: Dictionary = {}, boosts: Dictionary = {}, research: Dictionary = {}, stories: Dictionary = {}) -> bool: +func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary = {}, ammo: Dictionary = {}, boosts: Dictionary = {}, research: Dictionary = {}, stories: Dictionary = {}, gates: Dictionary = {}) -> bool: var previous := reason reason = "extras" if not ammo.is_empty() else ("loot" if balances.is_empty() and not cargo.is_empty() else "economy") - var result := super.commit(balances, contracts, cargo, ammo, boosts, research, stories) + var result := super.commit(balances, contracts, cargo, ammo, boosts, research, stories, gates) if measuring and reason == "extras" and result: extras_pilots += ammo.size() reason = previous diff --git a/tests/combat_effects_test.gd b/tests/combat_effects_test.gd index 3cd5acd..3dda722 100644 --- a/tests/combat_effects_test.gd +++ b/tests/combat_effects_test.gd @@ -2,6 +2,13 @@ extends "res://tests/encounter_test.gd" ## Presentation lifecycle, contact direction, caps and unchanged combat state. +class LootHud extends FlightHud: + var captions: Array[String] = [] + + func marker(_location: Vector3, label: String, _color: Color, _selected: bool, _teammate: Pilot = null, _priority: bool = true) -> void: + captions.append(label) + + func run() -> void: var world := Node3D.new() root.add_child(world) @@ -162,12 +169,25 @@ func destruction_checks() -> void: check(sector.loot.drops.has(id) and not sector.loot.is_presented(id), "Actual death creates loot state but hides the box and caption during the explosion") var update: Dictionary = sector.loot.drops[id].duplicate(true) update["resources"] = {"prometium": 1} + update["parts"] = 2 sector.loot.apply_drop(id, update) check(not sector.loot.is_presented(id), "Updating a drop during destruction does not expose its box early") sector.loot.apply_drop(999, {"position": sector.alien.position + Vector3(30, 0, 0), "resources": {"prometium": 1}, "ttl": 180.0}) check(sector.loot.is_presented(999), "An explosion does not suppress unrelated nearby loot") + var hud := LootHud.new() + hud.sector = sector + hud.draw_gate_parts() + check(hud.captions.is_empty(), "Neither ordinary loot nor an unrevealed gate part gets a marker") await create_timer(SectorVisuals.EXPLOSION_DURATION + 0.1).timeout check(sector.loot.is_presented(id) and not SectorVisuals.explosion_active(sector, sector.alien.position), "Loot becomes visible only after the last explosion mesh is gone") + hud.draw_gate_parts() + check(hud.captions == ["2 GATE PARTS"], "Only the revealed gate parts get a caption") + update.erase("parts") + sector.loot.apply_drop(id, update) + hud.captions.clear() + hud.draw_gate_parts() + check(sector.loot.is_presented(id) and hud.captions.is_empty(), "Taking the parts leaves the remaining ore visible and unlabeled") + hud.free() sector.loot.apply_drop(id, {}) await process_frame check(not sector.loot.meshes.has(id), "Removing a drop cannot resurrect its visual") diff --git a/tests/connected_maps_playthrough.gd b/tests/connected_maps_playthrough.gd index 27b824f..694b21d 100644 --- a/tests/connected_maps_playthrough.gd +++ b/tests/connected_maps_playthrough.gd @@ -25,10 +25,10 @@ func run() -> void: await capture("connected-map-network-%d" % pixels.x) check(Rect2(Vector2.ZERO, Vector2(pixels)).encloses(navigation.overview.get_global_rect()), "Connections view fits the %d window" % pixels.x) var chart := navigation.network_plot - for map: int in SectorMaps.MAPS: + for map: int in SectorMaps.network_maps(): check(Rect2(Vector2.ZERO, chart.size).encloses(chart.map_rect(map)), "Image card remains inside the map canvas") check(chart.PICTURES[map].get_width() >= 720, "Every card uses a detailed sector capture") - for other: int in SectorMaps.MAPS: + for other: int in SectorMaps.network_maps(): if map < other: check(not chart.map_rect(map).intersects(chart.map_rect(other)), "Sector images do not overlap") var route := chart.route_edges(3) diff --git a/tests/connected_maps_test.gd b/tests/connected_maps_test.gd index d8b965e..6fb15c5 100644 --- a/tests/connected_maps_test.gd +++ b/tests/connected_maps_test.gd @@ -59,7 +59,7 @@ func run() -> void: var second := make_sector("SecondMapPilot") var late := make_sector("LateMapPilot") var clients: Array[Sector] = [first, second, late] - check(server.world_aliens.size() == 20 and server.map_rosters.size() == 4, "Four bounded maps contain five alien slots each") + check(server.world_aliens.size() == 20 + GalaxyGates.pool_kinds().size() and server.map_rosters.size() == 5, "Four bounded maps contain five alien slots each, plus the dormant gate arena pool") var gates := 0 for map: int in SectorMaps.GATES: for destination: int in SectorMaps.GATES[map]: @@ -68,6 +68,9 @@ func run() -> void: check(SectorMaps.GATES[map][destination].length() + SectorMaps.PROTECTION_RADIUS < Sector.MAP_RADIUS, "Gate protection remains inside safe space") check(gates == 8 and not SectorMaps.GATES[0].has(2) and not SectorMaps.GATES[0].has(3), "Approved topology contains exactly eight gates") for enemy: Alien in server.world_aliens.values(): + if enemy.map_id == GalaxyGates.MAP: + check(not enemy.alive, "Gate arena aliens stay dormant without a run") + continue check(server.alien_home_clear(enemy.home_position, enemy), "Alien homes avoid gates, station and colliders") check(not CargoResources.roll(enemy.kind).is_empty(), "Every alien type has resource loot") for property: String in ["hull", "shield", "damage", "reward"]: diff --git a/tests/galaxy_gates_test.gd b/tests/galaxy_gates_test.gd new file mode 100644 index 0000000..b814f65 --- /dev/null +++ b/tests/galaxy_gates_test.gd @@ -0,0 +1,336 @@ +extends "res://tests/hunting_contracts_test.gd" +## Gate part rules, the Signal Anomaly operation, assembly, preview gates and a +## full Vashar Gate run with lives, waves, escorts, victory and collapse. + + +func run_rules() -> void: + var gates := GalaxyGates.empty() + check(GalaxyGates.valid(gates), "Empty gate progress is valid") + for invalid: Variant in [null, {"parts": 0}, {"parts": -1, "signal": "available", "progress": 0}, {"parts": 1000, "signal": "available", "progress": 0}, + {"parts": 0, "signal": "unknown", "progress": 0}, {"parts": 0, "signal": "available", "progress": 1}, + {"parts": 0, "signal": "active", "progress": GalaxyGates.SIGNAL["required"]}, {"parts": 0, "signal": "done", "progress": 0, "extra": 1}]: + check(not GalaxyGates.valid(invalid), "Malformed gate state is rejected: %s" % JSON.stringify(invalid)) + var equipment := Equipment.starter() + equipment["gates"] = {"parts": 7, "signal": "active", "progress": 3} + check(Equipment.valid(equipment), "Saved gate progress keeps equipment valid") + equipment["gates"] = {"parts": 7, "signal": "active", "progress": 99} + check(not Equipment.valid(equipment), "Equipment with impossible gate progress is rejected") + check(GalaxyGates.accept_blocker(gates).is_empty() and not GalaxyGates.assemble_blocker(gates).is_empty(), "A new pilot can trace the signal but cannot assemble") + var plain := GalaxyGates.collect(gates, 2, 2) + check(plain["gates"]["parts"] == 2 and plain["gates"]["progress"] == 0 and not plain["completed"], "Parts outside the operation only add to stock") + var active := {"parts": 0, "signal": "active", "progress": 6} + var partial := GalaxyGates.collect(active, 1, 1) + check(GalaxyGates.collect(active, 3, 0)["gates"] == {"parts": 3, "signal": "active", "progress": 6}, "Parts from other maps add stock without operation progress") + check(partial["gates"] == {"parts": 1, "signal": "active", "progress": 7} and partial["credits"] == 0, "Operation parts advance progress") + var done := GalaxyGates.collect(partial["gates"], 3, 3) + check(done["completed"] and done["gates"] == {"parts": 4 + GalaxyGates.SIGNAL["parts"], "signal": "done", "progress": 0} + and done["credits"] == GalaxyGates.SIGNAL["credits"] and done["research"] == GalaxyGates.SIGNAL["research"], "The final part decodes the cache once") + check(not GalaxyGates.accept_blocker(done["gates"]).is_empty(), "A decoded signal waits for the next gate") + check(GalaxyGates.collect({"parts": 998, "signal": "available", "progress": 0}, 5, 5)["gates"]["parts"] == GalaxyGates.MAX_PARTS, "Stock is capped") + var assembled := GalaxyGates.assemble({"parts": 23, "signal": "done", "progress": 0}) + check(assembled == {"parts": 3, "signal": "available", "progress": 0}, "Assembly consumes one gate and reopens the signal") + var rng := RandomNumberGenerator.new() + for attempt in range(50): + check(GalaxyGates.roll_parts("Scout", rng, false) == 0 and GalaxyGates.roll_parts("Shardling", rng, false) == 0, "Home-map and arena aliens carry no parts") + check(GalaxyGates.roll_parts("Skirmisher", rng, true) >= 1, "The operation guarantees a part") + check(GalaxyGates.wave_counts(0, 1) == {"Shardling": 3} and GalaxyGates.wave_counts(1, 3) == {"Shardling": 8}, + "Waves scale with pilots and stay within the arena pool") + check(GalaxyGates.wave_counts(6, 10)["Mothership"] == 1 and GalaxyGates.wave_counts(6, 10)["Shardling"] <= GalaxyGates.POOL["Shardling"] - GalaxyGates.ESCORTS, + "The boss wave has one mothership and leaves dormant escorts at any group size") + check(Alien.TYPES["Mothership"]["range"] < 310.0, "The mothership stays out-ranged by pilot lasers") + check(str(GalaxyGates.pool_kinds()) == str(SectorMaps.MAPS[GalaxyGates.MAP]["aliens"]), "The arena roster matches the gate pool") + check(SectorMaps.first_hop(GalaxyGates.MAP, 1) == 0, "Routing out of the arena leads through its exit to M1") + + +func saved(server: Sector, client: Sector) -> Dictionary: + return GalaxyGates.state(server.session.store.pilots[server.session.pilot_ids[client.multiplayer.get_unique_id()]]["equipment"]) + + +func move_to(server: Sector, client: Sector, map: int) -> void: + var id := client.multiplayer.get_unique_id() + if server.session.ships[id].map_id != map: + server.session.transfer(id, map) + await settle(0.08) + + +func request(server: Sector, client: Sector, action: String) -> void: + await move_to(server, client, 0) + station(server, client) + client.session.combat.request_station(action, "") + await settle(0.12) + + +# Kill one alien on `map` with the listed pilots contributing; returns its loot box ID. +func kill_on_map(server: Sector, map: int, clients: Array[Sector]) -> int: + var alien: Alien = server.map_rosters[map].values()[0] + alien.reset_encounter() + for client in clients: + await move_to(server, client, map) + var ship := server.session.ships[client.multiplayer.get_unique_id()] + ship.position = alien.home_position + Vector3(0, 0, 80) + alien.take_damage(1, ship) + var before := server.loot.next_id + alien.take_damage(alien.max_hull + alien.max_shield + 1.0, server.session.ships[clients.back().multiplayer.get_unique_id()]) + return server.loot.next_id if server.loot.next_id != before else -1 + + +func pick_up(server: Sector, client: Sector, drop_id: int) -> void: + var ship := server.session.ships[client.multiplayer.get_unique_id()] + ship.position = server.loot.drops[drop_id]["position"] + server.session.combat.collect_loot() + await settle(0.05) + + +# Places a server-owned box directly, for pickup cases a kill cannot pin down. +func place_box(server: Sector, map: int, position: Vector3, parts: int, resources: Dictionary = {}) -> int: + server.loot.next_id += 1 + var data := {"map": map, "position": position, "resources": resources, "ttl": ResourceLoot.LIFETIME} + if parts > 0: + data["parts"] = parts + server.loot.change(server.loot.next_id, data) + return server.loot.next_id + + +func enter(server: Sector, client: Sector) -> String: + var id := client.multiplayer.get_unique_id() + await move_to(server, client, 0) + var ship := server.session.ships[id] + ship.position = SectorMaps.gate_position(0, GalaxyGates.MAP) + server.session.jump_until.erase(id) + var reason := server.session.jump(id, server.session.combat.records[id]["life"], GalaxyGates.MAP) + # Leave the protected arrival zone so the pilot can fight. + ship.position = SectorMaps.origin(GalaxyGates.MAP) + Vector3(0, 0, 200) + return reason + + +func clear_wave(server: Sector, client: Sector) -> void: + var ship := server.session.ships[client.multiplayer.get_unique_id()] + for alien: Alien in server.session.combat.gate.wave_aliens.duplicate(): + if alien.alive: + ship.position = alien.position + Vector3(0, 0, 60) + alien.take_damage(alien.max_hull + alien.max_shield + 1.0, ship) + + +# Pilots on different maps never see each other, so wait for snapshots rather +# than the shared-map convergence used by other suites. +func sync(server: Sector) -> void: + for attempt in range(4): + server.session.send_snapshot() + await settle(0.05) + + +func run() -> void: + run_rules() + var server := make_sector("GateServer", true, CONTRACT_PORT) + var pilot := make_sector("GatePilot") + var partner := make_sector("GatePartner") + await connect_pilot(pilot, 0) + await connect_pilot(partner, 1) + if server.session.ships.size() != 2: + check(false, "Gate pilots authenticate") + finish() + return + var store := server.session.store + var combat := server.session.combat + var gate := combat.gate + var id := pilot.multiplayer.get_unique_id() + var partner_id := partner.multiplayer.get_unique_id() + var pilot_id: String = server.session.pilot_ids[id] + check(saved(server, pilot) == GalaxyGates.empty(), "Existing pilots start without gate parts") + for alien: Alien in server.map_rosters[GalaxyGates.MAP].values(): + check(not alien.alive, "Arena aliens are dormant before any run") + + # Signal Anomaly: guaranteed M2 parts, pickup without cargo space and the cache reward. + await request(server, pilot, "gate_signal") + check(saved(server, pilot)["signal"] == "active" and pilot.session.combat.inventory["gates"]["signal"] == "active", "Accepting the operation is saved and published") + await request(server, pilot, "gate_signal") + check(pilot.session.combat.station_message.contains("already active"), "An active operation cannot be accepted twice") + var next := store.pilots.duplicate(true) + next[pilot_id]["cargo"]["starter"] = {"prometium": CargoResources.capacity(next[pilot_id]["equipment"])} + check(store.persist(next), "Fill the pilot's cargo hold") + combat.cargo_holds[id] = next[pilot_id]["cargo"].duplicate(true) + var credits: int = combat.records[id]["credits"] + var drop: int = await kill_on_map(server, 1, [pilot]) + check(drop >= 0 and int(server.loot.drops[drop].get("parts", 0)) >= 1, "An M2 kill during the operation carries a gate part") + var carried := int(server.loot.drops[drop]["parts"]) + await pick_up(server, pilot, drop) + check(saved(server, pilot)["parts"] == carried and saved(server, pilot)["progress"] == mini(carried, GalaxyGates.SIGNAL["required"] - 1), "Gate parts are collected and saved with a full cargo hold") + check(server.loot.drops.has(drop) and not server.loot.drops[drop].has("parts"), "Resources stay in the box when the hold is full") + var partner_drop: int = await kill_on_map(server, 1, [partner]) + check(partner_drop < 0 or int(server.loot.drops[partner_drop].get("parts", 0)) <= 1, "Pilots without the operation get only random parts") + # A closer pilot without the operation cannot take the operation pilot's parts. + var shared: int = await kill_on_map(server, 1, [pilot]) + var before_shared: int = saved(server, pilot)["parts"] + server.session.ships[partner_id].position = server.loot.drops[shared]["position"] + server.session.ships[id].position = server.loot.drops[shared]["position"] + Vector3(6, 0, 0) + combat.collect_loot() + await settle(0.05) + check(saved(server, pilot)["parts"] > before_shared, "Gate parts go to the in-range pilot running the operation first") + # A full stock never destroys parts: the remainder passes on or stays boxed. + var partner_key: String = server.session.pilot_ids[partner_id] + var before_full := store.pilots.duplicate(true) + await move_to(server, pilot, 2) + await move_to(server, partner, 2) + next = store.pilots.duplicate(true) + next[pilot_id]["equipment"]["gates"]["parts"] = GalaxyGates.MAX_PARTS - 1 + next[partner_key]["equipment"]["gates"] = GalaxyGates.empty() + check(store.persist(next), "Seed a nearly full gate-part stock") + var spot: Vector3 = server.session.ships[id].position + server.session.ships[partner_id].position = spot + Vector3(4, 0, 0) + var full_box := place_box(server, 2, spot, 3) + combat.collect_loot() + await settle(0.05) + check(saved(server, pilot)["parts"] == GalaxyGates.MAX_PARTS and saved(server, partner)["parts"] == 2 and not server.loot.drops.has(full_box), "Parts beyond a full stock go to the next pilot in range") + next = store.pilots.duplicate(true) + next[partner_key]["equipment"]["gates"]["parts"] = GalaxyGates.MAX_PARTS - 1 + check(store.persist(next), "Leave room for one more part") + var first_box := place_box(server, 2, spot, 1) + full_box = place_box(server, 2, spot, 1) + combat.collect_loot() + await settle(0.05) + check(saved(server, partner)["parts"] == GalaxyGates.MAX_PARTS and not server.loot.drops.has(first_box) and server.loot.drops.has(full_box) and int(server.loot.drops[full_box]["parts"]) == 1, "Pickup counts parts assigned earlier in the same pass") + combat.collect_loot() + await settle(0.05) + check(server.loot.drops.has(full_box) and int(server.loot.drops[full_box]["parts"]) == 1, "Parts nobody can hold stay in the box") + server.loot.change(full_box, {}) + next = store.pilots.duplicate(true) + for key: String in [pilot_id, partner_key]: + if before_full[key]["equipment"].has("gates"): + next[key]["equipment"]["gates"] = before_full[key]["equipment"]["gates"] + else: + next[key]["equipment"].erase("gates") + check(store.persist(next), "Restore gate-part stocks") + # M3 has no gate to Outpost 01; return through M2 like a pilot would. + await move_to(server, pilot, 1) + await move_to(server, partner, 1) + for attempt in range(GalaxyGates.SIGNAL["required"]): + if saved(server, pilot)["signal"] != "active": + break + var box: int = await kill_on_map(server, 1, [pilot]) + await pick_up(server, pilot, box) + var after := saved(server, pilot) + check(after["signal"] == "done" and after["parts"] >= GalaxyGates.SIGNAL["required"] + GalaxyGates.SIGNAL["parts"], "Completing the operation adds the cache parts") + check(store.pilots[pilot_id]["credits"] >= credits + GalaxyGates.SIGNAL["credits"], "The operation pays its credit reward") + await request(server, pilot, "gate_assemble") + check(saved(server, pilot)["parts"] == after["parts"] and not gate.active, "Assembly needs a full set of parts") + + # Assembly consumes parts and opens one shared run. + next = store.pilots.duplicate(true) + next[pilot_id]["equipment"]["gates"]["parts"] = GalaxyGates.PARTS_REQUIRED + 2 + check(store.persist(next), "Seed a full set of gate parts") + await request(server, pilot, "gate_assemble") + check(gate.active and SectorMaps.rift_open and saved(server, pilot) == {"parts": 2, "signal": "available", "progress": 0}, "Assembly consumes parts, reopens the signal and opens the gate") + check(gate.builder == "Pilot %d" % id, "Runs are announced by the public pilot label, not the login ID") + await sync(server) + check(pilot.session.combat.gate_summary.get("active", false) and partner.session.combat.gate_summary.get("open", false), "Every pilot learns the gate is open") + check(pilot.hud.navigation.has_contact("gate%d" % GalaxyGates.MAP), "The open gate is a navigation contact at Outpost 01") + await request(server, partner, "gate_assemble") + check(partner.session.combat.station_message.contains("already open"), "Only one run is open at a time") + + # Entry, lives and the first wave. + var first: String = await enter(server, pilot) + var second: String = await enter(server, partner) + check(first.is_empty() and second.is_empty(), "Pilots fly through the open gate") + check(server.session.ships[id].map_id == GalaxyGates.MAP and gate.lives[pilot_id] == GalaxyGates.LIVES, "Entering joins the run with full lives") + gate.tick(1.0) + await settle(0.1) + var countdown: float = pilot.hud.gate_countdown() + check(countdown > 0.0 and countdown <= GalaxyGates.FIRST_WAVE_DELAY, "Entering shows the countdown to the first wave") + check(pilot.hud.gate_status().contains("WAVE 1 IN"), "The status line names the next wave and its countdown") + gate.tick(GalaxyGates.FIRST_WAVE_DELAY) + var alive := gate.wave_aliens.filter(func(alien: Alien): return alien.alive).size() + check(gate.phase == "fighting" and gate.wave == 0 and alive == GalaxyGates.wave_counts(0, 2)["Shardling"], "The first wave scales to the pilots inside") + check(gate.wave_aliens.all(func(alien: Alien): return gate.clear_of_rocks(alien.position, 14.9)), "Wave aliens spawn clear of arena asteroids") + await sync(server) + check(pilot.map_id == GalaxyGates.MAP and pilot.session.combat.gate_summary["wave"] == 1, "The pilot's client shows the arena and wave") + check(pilot.hud.gate_status().begins_with("VASHAR GATE / WAVE 1 OF") and pilot.hud.gate_countdown() < 0.0, "The HUD reports the active wave once the countdown ends") + # No safe zone in the rift: aliens pursue a pilot waiting at the exit, which stays sealed. + var holder := server.session.ships[id] + holder.position = SectorMaps.gate_position(GalaxyGates.MAP, 0) + server.session.ships[partner_id].position = holder.position + Vector3(8, 0, 0) + check(not SectorMaps.protected(holder), "The rift exit has no protected zone") + var hunter: Alien = gate.wave_aliens.filter(func(alien: Alien): return alien.alive)[0] + check(combat.choose_target(hunter) in [holder, server.session.ships[partner_id]], "Wave aliens pursue pilots waiting at the rift exit") + server.session.jump_until.erase(id) + check(server.session.jump(id, combat.records[id]["life"], 0).contains("sealed") and holder.map_id == GalaxyGates.MAP, "The rift exit is sealed while a wave is alive") + holder.position = SectorMaps.origin(GalaxyGates.MAP) + Vector3(0, 0, 200) + var ship := server.session.ships[partner_id] + ship.take_damage(ship.max_hull + ship.max_shield + 1.0, null) + check(gate.lives[server.session.pilot_ids[partner_id]] == GalaxyGates.LIVES - 1, "Dying in the arena costs one life") + gate.retreated(partner_id) + check(gate.lives[server.session.pilot_ids[partner_id]] == GalaxyGates.LIVES - 1, "Quitting during rescue does not cost a second life") + combat.tick(3.1) + check(ship.alive and ship.map_id == 0, "Rescue returns the pilot to Outpost 01") + var rejoined: String = await enter(server, partner) + check(rejoined.is_empty(), "A pilot with lives left can rejoin while the gate is open") + + # Clear every wave; the mothership launches escorts. + var pilot_credits: int = store.pilots[pilot_id]["credits"] + var partner_pilot: String = server.session.pilot_ids[partner_id] + var x4 := {pilot_id: int(store.pilots[pilot_id]["ammo"]["x4"]), partner_pilot: int(store.pilots[partner_pilot]["ammo"]["x4"])} + # Fix the LF-4 roll: this seed awards the pilot and not the partner. + var seed := 0 + while true: + var probe := RandomNumberGenerator.new() + probe.seed = seed + if probe.randf() < GalaxyGates.REWARD["item_chance"] and probe.randf() >= GalaxyGates.REWARD["item_chance"]: + break + seed += 1 + var research := int(Research.state(store.pilots[pilot_id]["equipment"])["points"]) + for wave in range(GalaxyGates.WAVES.size()): + if wave > 0: + gate.tick(GalaxyGates.WAVE_DELAY + 0.1) + check(gate.phase == "fighting" and gate.wave == wave, "Wave %d starts" % (wave + 1)) + if wave == GalaxyGates.WAVES.size() - 1: + var boss := gate.wave_aliens.filter(func(alien: Alien): return alien.kind == "Mothership") + check(boss.size() == 1 and boss[0].alive, "The final wave brings the mothership") + var before := gate.wave_aliens.filter(func(alien: Alien): return alien.alive).size() + gate.tick(GalaxyGates.ESCORT_INTERVAL + 0.1) + gate.rng.seed = seed + check(gate.wave_aliens.filter(func(alien: Alien): return alien.alive).size() > before, "The mothership launches escorts") + clear_wave(server, pilot) + gate.tick(0.1) + check(gate.phase == "victory" and not SectorMaps.rift_open, "Destroying the last wave wins and closes the entrance") + check(store.pilots[pilot_id]["credits"] >= pilot_credits + GalaxyGates.REWARD["credits"] + and int(Research.state(store.pilots[pilot_id]["equipment"])["points"]) == research + GalaxyGates.REWARD["research"], "Victory pays participants credits and research") + for winner: String in x4: + check(int(store.pilots[winner]["ammo"]["x4"]) == x4[winner] + GalaxyGates.REWARD["x4"], "Victory adds 15,000 x4 shots to each participant") + check(server.session.ships[id].ammo["x4"] == store.pilots[pilot_id]["ammo"]["x4"], "The live ship can fire the rewarded x4 shots") + var lasers := func(pilot: String) -> Array: return store.pilots[pilot]["equipment"]["items"].values().filter(func(item: Dictionary): return item["model"] == "lf-4") + check(lasers.call(pilot_id).size() == 1 and lasers.call(pilot_id)[0]["ship"] == "" and lasers.call(partner_pilot).is_empty(), "A won LF-4 roll places one LF-4 in storage") + check(Equipment.fitting_blocker(store.pilots[pilot_id]["equipment"], store.pilots[pilot_id]["equipment"]["items"].find_key(lasers.call(pilot_id)[0]), "starter", "laser2").is_empty(), "The rewarded LF-4 can be fitted") + await settle(0.1) + check(pilot.session.combat.inventory["items"].values().any(func(item: Dictionary): return item["model"] == "lf-4"), "The pilot's client receives the LF-4") + var closed: String = await enter(server, pilot) + check(not closed.is_empty(), "A won gate cannot be re-entered") + gate.tick(GalaxyGates.VICTORY_TIME + 0.1) + await settle(0.1) + check(not gate.active and server.session.ships[id].map_id == 0 and server.session.ships[partner_id].map_id == 0, "The rift closes and returns remaining pilots home") + for alien: Alien in server.map_rosters[GalaxyGates.MAP].values(): + check(not alien.alive, "Closing the rift leaves arena aliens dormant") + + # Preview gates need an allowlisted pilot; an empty gate collapses. + await request(server, partner, "gate_preview") + check(not gate.active and partner.session.combat.station_message.contains("unavailable"), "Preview gates are refused for ordinary pilots") + server.session.preview_tools_enabled = true + server.session.preview_pilots = PackedStringArray([pilot_id]) + await sync(server) + await request(server, pilot, "gate_preview") + check(gate.active and saved(server, pilot)["parts"] == 2, "A preview pilot opens a gate without parts") + await process_frame + pilot.main_menu.select_page("gates") + await process_frame + check(pilot.gate_menu.visible and pilot.gate_menu.preview_button.visible and pilot.gate_menu.run_label.text.contains("GATE OPEN"), "The Galaxy Gates page shows the open gate and preview tool") + # Quitting to the station mid-wave costs a life instead of a free repair. + var retreating: String = await enter(server, partner) + gate.tick(GalaxyGates.FIRST_WAVE_DELAY + 0.1) + var partner_pilot_id: String = server.session.pilot_ids[partner_id] + check(retreating.is_empty() and gate.phase == "fighting" and gate.lives[partner_pilot_id] == GalaxyGates.LIVES, "A pilot joins the preview wave") + partner.session.quit_to_menu() + await settle(0.15) + check(server.session.ships[partner_id].get_meta("docked", false) and gate.lives[partner_pilot_id] == GalaxyGates.LIVES - 1, "Quitting to the station mid-wave costs a life") + var leftover := place_box(server, GalaxyGates.MAP, SectorMaps.origin(GalaxyGates.MAP), 1, {"prometium": 1}) + gate.tick(GalaxyGates.ABANDON_TIME + 0.1) + check(not gate.active and not SectorMaps.rift_open, "A gate nobody holds collapses") + check(not server.loot.drops.has(leftover) and server.loot.drops.values().all(func(box: Dictionary): return int(box.get("map", 0)) != GalaxyGates.MAP), "A closing run clears the arena's loot") + finish() diff --git a/tests/galaxy_gates_test.gd.uid b/tests/galaxy_gates_test.gd.uid new file mode 100644 index 0000000..0bcaaba --- /dev/null +++ b/tests/galaxy_gates_test.gd.uid @@ -0,0 +1 @@ +uid://co4c733hluy1e diff --git a/tests/main_menu_test.gd b/tests/main_menu_test.gd index 6636115..f8850c0 100644 --- a/tests/main_menu_test.gd +++ b/tests/main_menu_test.gd @@ -120,7 +120,7 @@ func run() -> void: check(bounds.encloses(button.get_global_rect()), "Left navigation fits at %s" % dimensions) for page: String in ["shop", "hangar", "quests", "cargo", "skylab", "gates"]: await click(client, menu.navigation[page]) - var panel: Control = {"shop": client.shop, "hangar": client.equipment_menu, "quests": client.hud.contract_panel, "cargo": client.shop, "skylab": client.skylab_menu, "gates": menu.placeholder}[page] + var panel: Control = {"shop": client.shop, "hangar": client.equipment_menu, "quests": client.hud.contract_panel, "cargo": client.shop, "skylab": client.skylab_menu, "gates": client.gate_menu}[page] check(panel.visible and bounds.encloses(panel.get_global_rect()), "Page %s fits beneath navigation at %s" % [page, dimensions]) check(menu.content_rect().encloses(panel.get_global_rect()), "Page %s leaves the header and left navigation accessible" % page) check(not menu.start_button.is_visible_in_tree() and not menu.specifications.is_visible_in_tree(), "Overview footer is hidden on %s" % page) diff --git a/tests/menu_assets_test.gd b/tests/menu_assets_test.gd index fcfd383..f462f29 100644 --- a/tests/menu_assets_test.gd +++ b/tests/menu_assets_test.gd @@ -46,7 +46,7 @@ func run() -> void: "settings": panel = sector.settings_menu.panel "connection": panel = sector.session.menu "skylab": panel = sector.skylab_menu - _: panel = menu.placeholder + _: panel = sector.gate_menu if not panel.is_visible_in_tree() or menu.start_button.is_visible_in_tree(): push_error("Exported offline %s did not open independently of Overview." % page) quit(1) diff --git a/tests/offline_main_menu_test.gd b/tests/offline_main_menu_test.gd index dbb479e..33b08a4 100644 --- a/tests/offline_main_menu_test.gd +++ b/tests/offline_main_menu_test.gd @@ -29,7 +29,7 @@ func run() -> void: for page: String in ["hangar", "shop", "cargo", "refining", "research", "quests", "skylab", "gates"]: check(not menu.navigation[page].disabled, "Offline %s can be browsed" % page) await click(client, menu.navigation[page]) - var panel: Control = client.equipment_menu if page == "hangar" else (client.shop if page in ["shop", "cargo"] else (client.hud.contract_panel if page == "quests" else (client.skylab_menu if page == "skylab" else menu.placeholder))) + var panel: Control = client.equipment_menu if page == "hangar" else (client.shop if page in ["shop", "cargo"] else (client.hud.contract_panel if page == "quests" else (client.skylab_menu if page == "skylab" else client.gate_menu))) if page == "refining": panel = client.resource_workshop if page == "research": panel = client.research_menu check(panel.is_visible_in_tree() and not menu.start_button.is_visible_in_tree() and not menu.specifications.is_visible_in_tree(), "Offline %s stays open without Overview footer" % page) diff --git a/tests/pilots_test.py b/tests/pilots_test.py index 4a13880..ff9334d 100644 --- a/tests/pilots_test.py +++ b/tests/pilots_test.py @@ -88,6 +88,26 @@ def test_journal_rotation_checkpoint_and_new_pilot_preserve_debits(self): self.assertEqual(backup["pilots"]["test"]["boosts"], boosts) self.assertTrue(pilots.valid_skylab(saved["pilots"]["new"]["skylab"], saved["pilots"]["new"]["equipment"])) + def test_rollback_float_gate_counters_rotate_and_normalize(self): + # A rollback build that preserves unknown fields may write whole gate + # counters as floats. The server accepts them, so provisioning must too. + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + path, _, _, _ = self.journal_fixture(root) + data = json.loads(path.read_text()) + data["pilots"]["test"]["equipment"]["gates"] = {"parts": 20, "signal": "active", "progress": 7} + path.write_text(json.dumps(data).replace('"parts": 20', '"parts": 20.0').replace('"progress": 7}', '"progress": 7.0}')) + self.assertIn('"progress": 7.0', path.read_text()) + result = subprocess.run([sys.executable, pilots.__file__, str(root), "test", + str(root / "credential.json"), "--rotate"], capture_output=True) + self.assertEqual(result.returncode, 0, result.stderr.decode()) + gates = json.loads(path.read_text())["pilots"]["test"]["equipment"]["gates"] + self.assertEqual(gates, {"parts": 20, "signal": "active", "progress": 7}) + self.assertIs(type(gates["parts"]), int) + self.assertIs(type(gates["progress"]), int) + for bad in (7.5, float("inf"), float("nan"), True, "7", 8.0): + self.assertFalse(pilots.valid_gates({"parts": 20, "signal": "active", "progress": bad}), bad) + def test_checkpointed_journal_does_not_reverse_purchase(self): with tempfile.TemporaryDirectory() as directory: root = Path(directory) @@ -321,6 +341,12 @@ def test_extra_fitting_and_cargo(self): equipment["story"] = {"step": 11, "progress": 0} self.assertFalse(pilots.valid_equipment(equipment)) del equipment["story"] + # Galaxy gate parts are optional; signal progress exists only while active. + equipment["gates"] = {"parts": 20, "signal": "active", "progress": 7} + self.assertTrue(pilots.valid_equipment(equipment)) + equipment["gates"] = {"parts": 20, "signal": "done", "progress": 1} + self.assertFalse(pilots.valid_equipment(equipment)) + del equipment["gates"] equipment["items"]["ammo-cpu"]["ammo_type"] = "x4" self.assertFalse(pilots.valid_equipment(equipment)) equipment["items"]["ammo-cpu"]["ammo_type"] = "x2" diff --git a/tests/rpc_compatibility_test.gd b/tests/rpc_compatibility_test.gd index 04170f4..14e7122 100644 --- a/tests/rpc_compatibility_test.gd +++ b/tests/rpc_compatibility_test.gd @@ -62,7 +62,7 @@ func run() -> void: # Schema 17 previews share this RPC table but pack world entries and profiles # without revisions, so only the schema separates their fingerprints. var preview := server.session.protocol_fingerprint(17) - check(preview != server.session.protocol_fingerprint() and FlightSession.NETWORK_SCHEMA == 20, "Profile revisions change the protocol fingerprint") + check(preview != server.session.protocol_fingerprint() and FlightSession.NETWORK_SCHEMA == 21, "Profile revisions change the protocol fingerprint") var preview_server := func(id: int): server.multiplayer.send_auth(id, JSON.stringify({"nonce": "00".repeat(32), "protocol": preview}).to_utf8_buffer()) server.multiplayer.peer_authenticating.connect(preview_server) client.session.join("127.0.0.1", test_port(24683)) diff --git a/tests/sector_visuals_test.gd b/tests/sector_visuals_test.gd index 89748c7..736f401 100644 --- a/tests/sector_visuals_test.gd +++ b/tests/sector_visuals_test.gd @@ -75,7 +75,7 @@ func check_campaign_backdrops() -> void: root.add_child(authority) authority.set_physics_process(false) var client_obstacles := static_obstacles(flight) - check(client_obstacles == static_obstacles(authority) and client_obstacles.size() == 149, "All four rendered maps retain identical server obstacles") + check(client_obstacles == static_obstacles(authority) and client_obstacles.size() == 173, "All four rendered maps and the gate arena retain identical server obstacles") check(render_nodes(authority) == 0, "Four-map server creates no campaign planets, machines or sky") check(flight.map_scenery.keys() == [0], "Startup builds only the current map's scenery") check(authority.map_scenery.is_empty(), "Dedicated startup has no visual map cache") @@ -87,11 +87,15 @@ func check_campaign_backdrops() -> void: flight.autopilot.collect_obstacles() check(flight.autopilot.obstacles.size() == (77 if map == 0 else 24), "Autopilot sees every map's obstacles before its scenery exists") var enemy: Alien = authority.map_rosters[map].values()[0] - check(authority.alien_home_clear(enemy.home_position, enemy), "Alien relocation uses complete startup collision and gate data") + if SectorMaps.MAPS[map].get("instance", false): + check(not enemy.alive and not enemy.visible, "Gate arena aliens stay dormant until a run spawns them") + else: + check(authority.alien_home_clear(enemy.home_position, enemy), "Alien relocation uses complete startup collision and gate data") flight.player.map_id = map - for destination: int in SectorMaps.GATES[map]: + for destination: int in SectorMaps.links(map): flight.player.position = SectorMaps.gate_position(map, destination) - check(SectorMaps.protected(flight.player), "Unvisited gate protection is available at startup") + # The gate arena deliberately has no safe zone; every other gate protects pilots. + check(SectorMaps.protected(flight.player) != (map == GalaxyGates.MAP), "Unvisited gate protection is available at startup") check(SectorMaps.arrival(map, destination).distance_to(flight.player.position) <= SectorMaps.JUMP_RADIUS, "Unvisited reciprocal spawn stays inside the gate trigger range") flight.player.map_id = 0 flight.player.position = Sector.SPAWN_POSITION @@ -108,7 +112,7 @@ func check_campaign_backdrops() -> void: var body := flight.map_terrain[map].get_child(index) as StaticBody3D var model := rocks.get_child(index) as Node3D check(model.global_position.is_equal_approx(body.global_position) and is_equal_approx(model.scale.x, body.get_child(0).shape.radius), "Lazy asteroid visuals align with their existing collider") - for destination: int in SectorMaps.GATES[map]: + for destination: int in SectorMaps.links(map): var gate := flight.get_node("Map%dGates/GateToM%d" % [map+1,destination+1]) as Node3D check(gate.global_position.is_equal_approx(SectorMaps.gate_position(map,destination)), "Detailed gate retains its authoritative travel position") check(gate.find_children("*","CollisionObject3D",true,false).is_empty(), "Transit armor and portal add no collision bodies") diff --git a/tests/server_export_test.gd b/tests/server_export_test.gd index 2404755..48fd15c 100644 --- a/tests/server_export_test.gd +++ b/tests/server_export_test.gd @@ -35,8 +35,8 @@ func run() -> void: var shape := collider.shape colliders.append([str(collider.global_transform), shape.get_class(), shape.radius if shape is SphereShape3D else str(shape.size)]) - check(colliders.size() == 149, "All 96 asteroids across four maps and 53 station colliders survive export") - check(sector.world_aliens.size() == 20 and sector.map_rosters.size() == 4, "All four map populations survive server export") + check(colliders.size() == 173, "All 120 asteroids across four maps and the gate arena, and 53 station colliders, survive export") + check(sector.world_aliens.size() == 20 + GalaxyGates.pool_kinds().size() and sector.map_rosters.size() == 5, "All four map populations and the gate arena pool survive server export") for model: String in ShipCatalog.MODELS: var pilot := Pilot.new() pilot.render_enabled = false diff --git a/tests/shop_test.gd b/tests/shop_test.gd index 716b8c1..cc29d40 100644 --- a/tests/shop_test.gd +++ b/tests/shop_test.gd @@ -158,7 +158,7 @@ func check_flight_pages(client: Sector, prefix: String) -> void: "settings": panel = client.settings_menu.panel "connection": panel = client.session.menu "skylab": panel = client.skylab_menu - _: panel = menu.placeholder + _: panel = client.gate_menu check(panel.is_visible_in_tree() and menu.selected_page == page and menu.resume_button.is_visible_in_tree(), "%s flight %s remains reachable at %s" % [prefix, page, dimensions]) check(menu.content_rect().grow(1).encloses(panel.get_global_rect()), "%s flight %s fits beside the navigation at %s" % [prefix, page, dimensions]) check(not client.preflight and client.paused and not client.settings_menu.pause_panel.visible and not menu.start_button.is_visible_in_tree(), "%s flight %s does not dock, launch or overlay the pause menu" % [prefix, page]) @@ -176,7 +176,7 @@ func check_flight_pages(client: Sector, prefix: String) -> void: if page in ["hangar", "cargo"]: await capture(client, "%s-flight-%s-%d" % [prefix, page, dimensions.x]) await click(client, menu.resume_button) - check(not menu.visible and not client.paused and not client.session.menu.visible and not menu.placeholder.visible, "%s Resume closes the shell and its pages" % prefix) + check(not menu.visible and not client.paused and not client.session.menu.visible and not client.gate_menu.visible, "%s Resume closes the shell and its pages" % prefix) await press(client, KEY_I) await press(client, KEY_ESCAPE) check(not menu.visible and not client.equipment_menu.visible and not client.paused, "%s Esc closes the flight Hangar and resumes" % prefix) diff --git a/tests/skylab_ui_test.gd b/tests/skylab_ui_test.gd index 7b16961..b43328a 100644 --- a/tests/skylab_ui_test.gd +++ b/tests/skylab_ui_test.gd @@ -31,7 +31,7 @@ func run() -> void: root.size = dimensions await click(client, client.main_menu.navigation["skylab"]) await settle(.3) - check(menu.visible and not client.main_menu.placeholder.visible, "Skylab replaces the Coming soon placeholder") + check(menu.visible and not client.gate_menu.visible, "Skylab replaces the Galaxy Gates page") check(menu.buttons.size() == 12 and menu.ore_labels.size() == 8 and menu.ore_labels.has("xenomit"), "All modules and eight separate resource capacities are displayed") check(client.main_menu.content_rect().grow(1).encloses(menu.get_global_rect()), "Industry screen fits %s" % dimensions) check(menu.get_global_rect().position.distance_to(client.main_menu.content_rect().position) < 1 and menu.get_global_rect().size.distance_to(client.main_menu.content_rect().size) < 1, "Skylab fills the entire navigation content area at %s" % dimensions) diff --git a/tools/check-suites.json b/tools/check-suites.json index 29b7575..a4180b0 100644 --- a/tools/check-suites.json +++ b/tools/check-suites.json @@ -35,6 +35,7 @@ {"name": "economy_test", "checks": [["economy_test.gd"]]}, {"name": "research_test", "checks": [["research_test.gd"]]}, {"name": "story_test", "checks": [["story_test.gd"]]}, + {"name": "galaxy_gates_test", "checks": [["galaxy_gates_test.gd"]]}, {"name": "equipment_test", "checks": [["equipment_test.gd"]]}, {"name": "equipment_stats_test", "checks": [["equipment_stats_test.gd"]]}, {"name": "station_actions_test", "checks": [["station_actions_test.gd"]]}, @@ -86,6 +87,7 @@ {"name": "economy_test", "checks": [["economy_test.gd"]]}, {"name": "research_test", "checks": [["research_test.gd"]]}, {"name": "story_test", "checks": [["story_test.gd"]]}, + {"name": "galaxy_gates_test", "checks": [["galaxy_gates_test.gd"]]}, {"name": "equipment_test", "checks": [["equipment_test.gd"]]}, {"name": "equipment_stats_test", "checks": [["equipment_stats_test.gd"]]}, {"name": "station_actions_test", "checks": [["station_actions_test.gd"]]}, diff --git a/tools/pilots.py b/tools/pilots.py index ff8a8ed..7bfb4fd 100644 --- a/tools/pilots.py +++ b/tools/pilots.py @@ -55,7 +55,8 @@ def valid_equipment(data: object) -> bool: or not isinstance(data.get("items"), dict) or not isinstance(data.get("active_ship"), str) or data["active_ship"] not in data["ships"] or ("research" in data and not valid_research(data["research"])) - or ("story" in data and not valid_story(data["story"]))): + or ("story" in data and not valid_story(data["story"])) + or ("gates" in data and not valid_gates(data["gates"]))): return False for ship, model in data["ships"].items(): if (not isinstance(ship, str) or not re.fullmatch(r"[a-z0-9_-]{1,32}", ship) @@ -122,6 +123,27 @@ def valid_story(data: object) -> bool: and type(data["progress"]) is int and 0 <= data["progress"] <= 1000) +def whole(value: object, low: int, high: int) -> bool: + # Mirrors Skylab.integer: an older build that preserves unknown fields can + # write a whole counter such as 7 as 7.0; the server accepts and normalizes it. + return ((type(value) is int or (type(value) is float and value.is_integer())) + and low <= value <= high) + + +# Mirrors GalaxyGates in scripts/galaxy_gates.gd: at most 999 parts, signal progress below 8. +def valid_gates(data: object) -> bool: + return (isinstance(data, dict) and data.keys() == {"parts", "signal", "progress"} + and whole(data["parts"], 0, 999) + and data["signal"] in ("available", "active", "done") + and whole(data["progress"], 0, 7 if data["signal"] == "active" else 0)) + + +def normalize_gates(equipment: dict) -> None: + if "gates" in equipment: + for field in ("parts", "progress"): + equipment["gates"][field] = int(equipment["gates"][field]) + + def valid_cargo(data: object, equipment: dict) -> bool: prices = {"prometium", "endurium", "terbium", "prometid", "duranium", "xenomit", "promerium", "seprom"} if not isinstance(data, dict) or data.keys() != equipment["ships"].keys(): @@ -356,6 +378,7 @@ def main() -> None: record["equipment"] = starter_equipment() elif not valid_equipment(record.get("equipment")): parser.error("Invalid equipment; preserve it and recover from backup") + normalize_gates(record["equipment"]) if data["version"] < 3: if "cargo" in record: parser.error("Unexpected cargo in legacy ledger; preserve it and recover") diff --git a/tools/render_alien_preview.gd b/tools/render_alien_preview.gd index 2dfc65e..c15de47 100644 --- a/tools/render_alien_preview.gd +++ b/tools/render_alien_preview.gd @@ -1,5 +1,6 @@ extends SceneTree ## Capture contract/rear previews, or use -- --sector for 25 m / 90 m visibility. +## -- --outer limits the set to the M2–M4 aliens and -- --vashar to the Vashar Gate aliens. func _initialize() -> void: @@ -9,7 +10,10 @@ func _initialize() -> void: func render_preview() -> void: var sector_view := "--sector" in OS.get_cmdline_user_args() var outer_view := "--outer" in OS.get_cmdline_user_args() + var vashar_view := "--vashar" in OS.get_cmdline_user_args() var kinds: Array = ["Skirmisher", "Raider", "Marauder", "Warden", "Ravager", "Overlord"] if outer_view else Alien.TYPES.keys() + if vashar_view: + kinds = GalaxyGates.POOL.keys() if DisplayServer.get_name() == "headless": push_error("Alien review rendering requires a graphics display.") quit(1) @@ -66,6 +70,8 @@ func render_preview() -> void: var filename := "alien-visibility-sector.png" if sector_view else "alien-models-godot.png" if outer_view: filename = "outer-" + filename + elif vashar_view: + filename = "vashar-" + filename var error := root.get_texture().get_image().save_png(directory.path_join(filename)) print("ALIEN_PREVIEWS ", root.size, " renderer=", RenderingServer.get_video_adapter_name(), " result=", error) quit(error)