diff --git a/GAME_PLAN.md b/GAME_PLAN.md index 698c616..d314128 100644 --- a/GAME_PLAN.md +++ b/GAME_PLAN.md @@ -1598,8 +1598,10 @@ two ways: 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 +pickup range collects a box's parts, even with a full hold. Each gate's parts go +first to pilots running that gate's operation when the box is on its operation map, +otherwise to the nearest pilot; a box holding several gates' parts splits them this +way. 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 @@ -1665,6 +1667,47 @@ 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. +#### Galaxy gates: the Korrath Gate + +On 2026-10-22 the user asked for a second gate; final models and renders can +follow later. Each gate is now a data definition (`GalaxyGates.GATES`): faction, +arena map, Outpost 01 portal, part count and chances, parts operation, alien pool, +waves, boss, escorts and rewards. Saved progress is per gate. One gate run is open +on the server at a time, and only its portal appears near Outpost 01. Network schema 22 +adds the Korrath arena and aliens. + +The **Korrath** are siege engineers. The occupying aliens drag Korrath gate +segments through the deeper sectors; the gate leads into the *Korrath Bastion*, +where a Siegebreaker battlestation is being readied against Outpost 01. + +- **Parts:** 24. *Siege Manifest* (Chief Engineer Brell) guarantees a part for + each contributed M3 kill; 10 parts complete it for +5 parts, 25,000 CR and 3 RP. + Random drops come only from M3 and M4 (8–16%). +- **Waves:** eight, with Husks (fast) and Bulwarks (heavy). The final wave adds + the slow Siegebreaker, which launches two Husks every 25 s; boss waves keep two + escorts in reserve for this at every group size. + +| Type | Hull / shield | Damage / interval | Credit pool | +| --- | --- | --- | --- | +| Husk | 8,000 / 4,000 | 4,000 / 0.8 s | 3,000 | +| Bulwark | 36,000 / 18,000 | 14,000 / 0.85 s | 15,000 | +| Siegebreaker | 500,000 / 250,000 | 30,000 / 0.5 s, 270 m | 300,000 | + +- **Rewards:** 300,000 CR, 10 research points and 25,000 x4 shots per + participant, with a 20% chance of the shop-unavailable SG3N-B00 shield. +- Lives, countdown, sealed exit, scaling, escorts, preview tools and collapse + follow the Vashar rules. The arena is map 5 with a forge-orange backdrop. + +The user approved the Korrath concepts and requested Blender models matching +them on 2026-10-22. Husk, Bulwark and Siegebreaker now use authored gunmetal and +copper siege hulls with orange furnace cores. The runtime GLBs share 2K PBR maps +and generate distance LODs on import; their visible diagonals are 12.35 m, +28.8 m and 108 m respectively. Combat statistics, colliders and waves are +unchanged. Editable Blender files with packed 4K maps, the concepts, build script, +construction views and Godot captures live in `korrath-review/README.md` in the +art archive. Fine details and hidden surfaces interpret the concepts for game +geometry. All values remain provisional until playtested. + #### First campaign implementation scope Begin with the pilot prologue and the clearance operation that establishes diff --git a/README.md b/README.md index 41c6f68..aca60c1 100644 --- a/README.md +++ b/README.md @@ -262,7 +262,7 @@ equip it, **Quests** to accept hunting contracts, or **Cargo trade** to sell sav 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** shows your -gate parts, the Signal Anomaly operation and the Vashar Gate; see +parts and operations for the Vashar and Korrath gates; 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 diff --git a/assets/aliens/bulwark.glb b/assets/aliens/bulwark.glb new file mode 100644 index 0000000..7c769e8 Binary files /dev/null and b/assets/aliens/bulwark.glb differ diff --git a/assets/aliens/bulwark.glb.import b/assets/aliens/bulwark.glb.import new file mode 100644 index 0000000..9a899bd --- /dev/null +++ b/assets/aliens/bulwark.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://lf06emuac122" +path="res://.godot/imported/bulwark.glb-60b1edc6a4fba70df4a8dca444aa7a56.scn" + +[deps] + +source_file="res://assets/aliens/bulwark.glb" +dest_files=["res://.godot/imported/bulwark.glb-60b1edc6a4fba70df4a8dca444aa7a56.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/export-stats.json b/assets/aliens/export-stats.json index cda241e..e889579 100644 --- a/assets/aliens/export-stats.json +++ b/assets/aliens/export-stats.json @@ -178,5 +178,50 @@ "forward": "-Z", "up": "+Y", "atlas_size": 2048 + }, + "Husk": { + "triangles": 27972, + "materials": 6, + "bytes": 12785120, + "omitted_degenerate_triangles": 0, + "visual_diameter": 9.5, + "bounds_godot": [ + 5.479079, + 1.28553, + 7.653568 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 + }, + "Bulwark": { + "triangles": 34452, + "materials": 6, + "bytes": 13926740, + "omitted_degenerate_triangles": 0, + "visual_diameter": 12.0, + "bounds_godot": [ + 7.080173, + 2.547897, + 9.347694 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 + }, + "Siegebreaker": { + "triangles": 62324, + "materials": 6, + "bytes": 15721328, + "omitted_degenerate_triangles": 0, + "visual_diameter": 12.0, + "bounds_godot": [ + 7.258338, + 2.373378, + 9.256544 + ], + "forward": "-Z", + "up": "+Y", + "atlas_size": 2048 } } diff --git a/assets/aliens/husk.glb b/assets/aliens/husk.glb new file mode 100644 index 0000000..fa05cfb Binary files /dev/null and b/assets/aliens/husk.glb differ diff --git a/assets/aliens/husk.glb.import b/assets/aliens/husk.glb.import new file mode 100644 index 0000000..b7232d2 --- /dev/null +++ b/assets/aliens/husk.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://p33il7b0bbkc" +path="res://.godot/imported/husk.glb-9c18c5f737a88eefdda4f241e64d7cd6.scn" + +[deps] + +source_file="res://assets/aliens/husk.glb" +dest_files=["res://.godot/imported/husk.glb-9c18c5f737a88eefdda4f241e64d7cd6.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/siegebreaker.glb b/assets/aliens/siegebreaker.glb new file mode 100644 index 0000000..49e0359 Binary files /dev/null and b/assets/aliens/siegebreaker.glb differ diff --git a/assets/aliens/siegebreaker.glb.import b/assets/aliens/siegebreaker.glb.import new file mode 100644 index 0000000..b7f3a98 --- /dev/null +++ b/assets/aliens/siegebreaker.glb.import @@ -0,0 +1,45 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://bkbgnfnumcqws" +path="res://.godot/imported/siegebreaker.glb-91cc13092079e600a9ec4f59eb80066b.scn" + +[deps] + +source_file="res://assets/aliens/siegebreaker.glb" +dest_files=["res://.godot/imported/siegebreaker.glb-91cc13092079e600a9ec4f59eb80066b.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 800faf5..3acb452 100644 --- a/scripts/alien.gd +++ b/scripts/alien.gd @@ -19,6 +19,9 @@ const VISUAL_DIAMETERS := { "Shardling": 9.5, "Spireguard": 9.5, "Mothership": 16.0, + "Husk": 9.5, + "Bulwark": 12.0, + "Siegebreaker": 12.0, } # Stronger encounters should remain easy to track among cooperating pilots. const VISUAL_SCALE := { @@ -34,6 +37,9 @@ const VISUAL_SCALE := { "Shardling": 1.0, "Spireguard": 2.0, "Mothership": 4.0, + "Husk": 1.3, + "Bulwark": 2.4, + "Siegebreaker": 9.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")}, @@ -49,6 +55,10 @@ const TYPES := { "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}, + # Korrath Gate arena only; authored siege-engineer hulls use orange furnace cores. + "Husk": {"hull": 8000.0, "shield": 4000.0, "damage": 4000.0, "interval": 0.8, "range": 230.0, "speed": 34.0, "detection": 2400.0, "leash": 5000.0, "reward": 3000, "respawn": 0.0, "scale": Vector3(0.9, 0.7, 1.2), "color": Color("ff8a3d")}, + "Bulwark": {"hull": 36000.0, "shield": 18000.0, "damage": 14000.0, "interval": 0.85, "range": 260.0, "speed": 15.0, "detection": 2400.0, "leash": 5000.0, "reward": 15000, "respawn": 0.0, "scale": Vector3(1.4, 1.2, 1.3), "color": Color("d0562a")}, + "Siegebreaker": {"hull": 500000.0, "shield": 250000.0, "damage": 30000.0, "interval": 0.5, "range": 270.0, "speed": 3.0, "detection": 2400.0, "leash": 5000.0, "reward": 300000, "respawn": 0.0, "scale": Vector3(1.6, 0.8, 1.6), "color": Color("ffb35c"), "radius": 22.0}, } var alien_id: int = 0 @@ -83,6 +93,7 @@ static func model_scene(alien_kind: String) -> Node3D: var scene: PackedScene = load("res://assets/aliens/%s.glb" % alien_kind.to_lower()) var instance := scene.instantiate() as Node3D instance.scale *= float(VISUAL_SCALE[alien_kind]) + var korrath: bool = alien_kind in GalaxyGates.info("korrath")["pool"] # Apply to shared materials at load time so existing imported assets also # receive the visibility finish. Keep dark machinery and recesses distinct. for node: MeshInstance3D in instance.find_children("*", "MeshInstance3D", true, false): @@ -94,7 +105,16 @@ static func model_scene(alien_kind: String) -> Node3D: material.emission_operator = BaseMaterial3D.EMISSION_OP_MULTIPLY material.emission_texture = material.albedo_texture # 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) + material.emission_energy_multiplier = 2.0 if alien_kind in ["Scout", "Sentinel", "Heavy"] else (0.12 if alien_kind in GalaxyGates.arena_kinds() else 0.35) + if korrath: + # Scorched iron has a broad dull finish under the strong sector sun. + material.metallic_specular = 0.2 + material.clearcoat = 0.04 + elif korrath and material.resource_name.ends_with("sensor emission"): + # Unlit furnace apertures retain orange instead of picking up white sun specular. + material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED + material.emission = Color("ff6508") + material.emission_energy_multiplier = 0.4 return instance diff --git a/scripts/cargo_resources.gd b/scripts/cargo_resources.gd index 732c7a9..e3136a4 100644 --- a/scripts/cargo_resources.gd +++ b/scripts/cargo_resources.gd @@ -24,6 +24,9 @@ const LOOT := { "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)}, + "Husk": {"duranium": Vector2i(6, 10), "xenomit": Vector2i(2, 4), "promerium": Vector2i(2, 4)}, + "Bulwark": {"xenomit": Vector2i(6, 10), "promerium": Vector2i(10, 14), "seprom": Vector2i(4, 6)}, + "Siegebreaker": {"xenomit": Vector2i(30, 40), "promerium": Vector2i(40, 50), "seprom": Vector2i(25, 35)}, "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 abca81a..d3101b6 100644 --- a/scripts/equipment.gd +++ b/scripts/equipment.gd @@ -16,7 +16,7 @@ const MODELS := { "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}, "sg3n-a03": {"name": "SG3N-A03", "kind": "generator", "price": 128000, "damage": 0.0, "shield": 5000.0, "absorption": 0.6, "speed": 0.0}, - "sg3n-b00": {"name": "SG3N-B00", "kind": "generator", "price": 0, "unavailable": "Unavailable until assembly is added.", "damage": 0.0, "shield": 9000.0, "absorption": 0.7, "speed": 0.0}, + "sg3n-b00": {"name": "SG3N-B00", "kind": "generator", "price": 0, "unavailable": "Unavailable in the shop. Korrath Gate victories can award one.", "damage": 0.0, "shield": 9000.0, "absorption": 0.7, "speed": 0.0}, "sg3n-b01": {"name": "SG3N-B01", "kind": "generator", "price": 2500 * URIDIUM_TO_CREDITS, "damage": 0.0, "shield": 9500.0, "absorption": 0.7, "speed": 0.0}, "sg3n-b02": {"name": "SG3N-B02", "kind": "generator", "price": 10000 * URIDIUM_TO_CREDITS, "damage": 0.0, "shield": 10000.0, "absorption": 0.8, "speed": 0.0}, "g3n-1010": {"name": "G3N-1010", "kind": "generator", "price": 2000, "damage": 0.0, "shield": 0.0, "speed": 2.0}, @@ -101,7 +101,7 @@ 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"]): + if data.has("gates") and not GalaxyGates.valid_collection(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])): diff --git a/scripts/flight_navigation.gd b/scripts/flight_navigation.gd index ab7210c..b3d3a5c 100644 --- a/scripts/flight_navigation.gd +++ b/scripts/flight_navigation.gd @@ -308,7 +308,7 @@ func build_contacts() -> 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.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}) + result.append({"key": "gate%d" % map, "name": SectorMaps.gate_label(map).capitalize() if GalaxyGates.is_arena(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}) diff --git a/scripts/flight_session.gd b/scripts/flight_session.gd index 48d7fa3..6c3b712 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 = 21 +const NETWORK_SCHEMA: int = 22 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 @@ -578,7 +578,7 @@ 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: + if GalaxyGates.is_arena(ship.map_id): combat.gate.retreated(id) ship.set_meta("docked", true) if ship.map_id != 0: @@ -660,7 +660,7 @@ func peer_left(id: int) -> void: 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: + if active and multiplayer.is_server() and ships.has(id) and GalaxyGates.is_arena(ships[id].map_id): combat.gate.retreated(id, false) pilot_ids.erase(id) challenges.erase(id) @@ -1147,17 +1147,17 @@ func jump(id: int, life: int, destination: int) -> String: 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 GalaxyGates.is_arena(destination): + var blocker := combat.gate.entry_blocker(id, destination) if not blocker.is_empty(): return blocker - if ship.map_id == GalaxyGates.MAP: + if GalaxyGates.is_arena(ship.map_id): 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: + if GalaxyGates.is_arena(destination): combat.gate.entered(id) return "" @@ -1232,8 +1232,9 @@ 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() - 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")) + var arena := GalaxyGates.for_map(sector.map_id) + if not arena.is_empty(): + sector.notify("Entered the %s. The gate behind you returns to M1 between waves (%s)." % [GalaxyGates.info(arena)["arena"], 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 index c45a2ba..dfbd693 100644 --- a/scripts/galaxy_gates.gd +++ b/scripts/galaxy_gates.gd @@ -1,30 +1,12 @@ class_name GalaxyGates extends RefCounted -## Galaxy gate parts, the signal operation and the Vashar Gate run. +## Galaxy gate parts, signal operations and gate definitions. ## 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. +## summon allied factions. Pilots capture the parts, assemble a faction's gate +## themselves and strike its 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 @@ -35,24 +17,98 @@ const ABANDON_TIME := 120.0 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"] +# Display and lookup order. Each gate has its own arena map, entry portal near +# Outpost 01, parts, operation, alien pool, waves and rewards. +const ORDER := ["vashar", "korrath"] +const GATES := { + "vashar": { + "name": "Vashar Gate", "faction": "Vashar", "arena": "Vashar Rift", "map": 4, "glow": Color("c86bff"), + "portal": Vector3(320, 40, -300), "parts_required": 20, "lives": 3, + "summary": "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.", + # Chance that an alien carries one part in its loot box. Home-map aliens carry none. + "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. + "signal": { + "title": "Signal Anomaly", "contact": "sato", "map": 1, "required": 8, "parts": 4, "credits": 10000, "research": 2, + "objective": "Recover Vashar 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.", + }, + # Every participant: credits, research points and x4 rounds, plus a chance at an item. + "reward": {"credits": 150000, "research": 6, "x4": 15000, "item": "lf-4", "item_chance": 0.2}, + "boss": "Mothership", "boss_title": "VASHAR MOTHERSHIP", "escort": "Shardling", + "victory": "Vashar mothership destroyed. Their invasion is set back.", + # Arena alien pool, in stable ID order. Waves activate subsets; nothing respawns by itself. + "pool": {"Shardling": 8, "Spireguard": 4, "Mothership": 1}, + "waves": [ + {"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}, + ], + }, + "korrath": { + "name": "Korrath Gate", "faction": "Korrath", "arena": "Korrath Bastion", "map": 5, "glow": Color("ff8a3d"), + "portal": Vector3(-340, -30, -330), "parts_required": 24, "lives": 3, + "summary": "The Korrath are siege engineers: armored hulks that crack planetary defenses. The occupiers are dragging Korrath gate segments through the deep sectors. Assemble the gate, break into their staging bastion and destroy the Siegebreaker before it is turned on Outpost 01.", + "part_chance": {"Marauder": 0.08, "Warden": 0.12, "Ravager": 0.12, "Overlord": 0.16}, + "signal": { + "title": "Siege Manifest", "contact": "brell", "map": 2, "required": 10, "parts": 5, "credits": 25000, "research": 3, + "objective": "Recover Korrath gate parts from aliens in M3 / Debris Fields", + "briefing": "Brell here. I pulled a cargo manifest out of a Warden wreck in the Debris Fields. The aliens are hauling heavy gate segments through there, built for something called the Korrath. Siege engineers, by the look of the tooling. Knock out the haulers in M3 and bring me those segments before they finish another gate.", + "done": "That manifest pointed straight at a segment depot. I cracked it open and added the parts to your stock. Finish the gate and we hit their bastion before they hit us.", + }, + "reward": {"credits": 300000, "research": 10, "x4": 25000, "item": "sg3n-b00", "item_chance": 0.2}, + "boss": "Siegebreaker", "boss_title": "KORRATH SIEGEBREAKER", "escort": "Husk", + "victory": "The Korrath Siegebreaker is wrecked. Their siege is set back.", + "pool": {"Husk": 10, "Bulwark": 5, "Siegebreaker": 1}, + "waves": [ + {"Husk": 4}, + {"Husk": 6}, + {"Husk": 4, "Bulwark": 1}, + {"Husk": 6, "Bulwark": 2}, + {"Bulwark": 3}, + {"Husk": 8, "Bulwark": 2}, + {"Husk": 6, "Bulwark": 3}, + {"Siegebreaker": 1, "Husk": 4, "Bulwark": 2}, + ], + }, +} + +static func info(gate: String) -> Dictionary: + return GATES[gate] + + +## The gate whose arena is `map`, or an empty string for normal maps. +static func for_map(map: int) -> String: + for gate: String in ORDER: + if int(GATES[gate]["map"]) == map: + return gate + return "" -static func pool_kinds() -> Array[String]: + +static func is_arena(map: int) -> bool: + return not for_map(map).is_empty() + + +static func pool_kinds(gate: String) -> Array[String]: var kinds: Array[String] = [] - for kind: String in POOL: - for index in range(POOL[kind]): + for kind: String in GATES[gate]["pool"]: + for index in range(GATES[gate]["pool"][kind]): + kinds.append(kind) + return kinds + + +## Every alien kind fought inside any gate arena. +static func arena_kinds() -> Array[String]: + var kinds: Array[String] = [] + for gate: String in ORDER: + for kind: String in GATES[gate]["pool"]: kinds.append(kind) return kinds @@ -61,96 +117,124 @@ 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()) +## Saved progress for every gate. Pilots without saved progress start empty. +static func states(equipment: Dictionary) -> Dictionary: + return equipment.get("gates", {}) + + +static func state(equipment: Dictionary, gate: String) -> Dictionary: + return states(equipment).get(gate, empty()) -static func valid(value: Variant) -> bool: +static func valid(value: Variant, gate: String) -> 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) + return Skylab.integer(value.get("progress"), 0, int(GATES[gate]["signal"]["required"]) - 1 if value["signal"] == "active" else 0) + + +## Saved gate progress: a dictionary keyed by known gate IDs. +static func valid_collection(value: Variant) -> bool: + if not value is Dictionary: + return false + for gate: Variant in value: + if not gate is String or not GATES.has(gate) or not valid(value[gate], gate): + return false + return true static func normalize(value: Dictionary) -> void: - value["parts"] = int(value["parts"]) - value["progress"] = int(value["progress"]) + for gate: String in value: + value[gate]["parts"] = int(value[gate]["parts"]) + value[gate]["progress"] = int(value[gate]["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 +## Parts carried by one destroyed alien, per gate. `guaranteed` lists gates whose +## active operation guarantees a part for this kill. +static func roll_parts(kind: String, rng: RandomNumberGenerator, guaranteed: Array) -> Dictionary: + var parts := {} + for gate: String in ORDER: + var count := 1 if gate in guaranteed else 0 + if rng.randf() < float(GATES[gate]["part_chance"].get(kind, 0.0)): + count += 1 + if count > 0: + parts[gate] = count 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: +static func collect(gates: Dictionary, gate: String, amount: int, qualifying: int) -> Dictionary: + var operation: Dictionary = GATES[gate]["signal"] 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"]): + if progress < int(operation["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"] + next["parts"] = mini(MAX_PARTS, int(next["parts"]) + int(operation["parts"])) + result["credits"] = operation["credits"] + result["research"] = operation["research"] result["completed"] = true return result -static func accept_blocker(gates: Dictionary) -> String: +static func accept_blocker(gates: Dictionary, gate: String) -> String: match gates["signal"]: - "active": return "Signal Anomaly is already active." - "done": return "Assemble the %s before tracing another signal." % NAME + "active": return "%s is already active." % GATES[gate]["signal"]["title"] + "done": return "Assemble the %s before tracing another lead." % GATES[gate]["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"])] +static func assemble_blocker(gates: Dictionary, gate: String) -> String: + if int(gates["parts"]) < int(GATES[gate]["parts_required"]): + return "Need %d gate parts; %d collected." % [GATES[gate]["parts_required"], int(gates["parts"])] return "" ## Consumes one gate's parts. A finished signal operation becomes available again. -static func assemble(gates: Dictionary) -> Dictionary: +static func assemble(gates: Dictionary, gate: String) -> Dictionary: var next := gates.duplicate() - next["parts"] = int(next["parts"]) - PARTS_REQUIRED + next["parts"] = int(next["parts"]) - int(GATES[gate]["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: +## a boss wave leaves enough dormant escorts for the boss to launch. +static func wave_counts(gate: String, wave: int, pilots: int) -> Dictionary: var counts := {} + var definition: Dictionary = GATES[gate] 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)) + var boss_wave: bool = definition["waves"][wave].has(definition["boss"]) + for kind: String in definition["waves"][wave]: + var base := int(definition["waves"][wave][kind]) + var limit := int(definition["pool"][kind]) - (ESCORTS if boss_wave and kind == definition["escort"] else 0) + counts[kind] = base if kind == definition["boss"] 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 signal_objective(gates: Dictionary, gate: String) -> String: + var operation: Dictionary = GATES[gate]["signal"] + return "%s %d / %d" % [operation["objective"], int(gates["progress"]), int(operation["required"])] + + +static func item_name(gate: String) -> String: + return Equipment.MODELS[GATES[gate]["reward"]["item"]]["name"] -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 "") +static func reward_text(gate: String, item: bool) -> String: + var reward: Dictionary = GATES[gate]["reward"] + var text := "%s and +%s x4 shots" % [Story.reward_text(reward["credits"], reward["research"]), StationShop.credits_text(reward["x4"])] + return text + (" and an %s (in storage)" % item_name(gate) if item else "") diff --git a/scripts/gate_menu.gd b/scripts/gate_menu.gd index c75cdc4..0fbfdc4 100644 --- a/scripts/gate_menu.gd +++ b/scripts/gate_menu.gd @@ -1,20 +1,31 @@ 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. +## Galaxy Gates station page: per-gate parts, operation and the open run. Tabs +## select a gate. The server validates every action and owns the gate run. const SIZE := Vector2(1150, 690) var sector: Sector +var selected: String = GalaxyGates.ORDER[0] +var tabs: Dictionary[String, Button] = {} var summary: Label +var faction: Label +var title: Label +var lore: Label var parts_label: Label var parts_bar: ProgressBar +var facts: Label var run_label: Label var assemble_button: Button var preview_button: Button +var operation_title: Label +var portrait: TextureRect +var briefing: Label +var operation_rules: Label var signal_state: Label var signal_progress: ProgressBar var accept_button: Button var status: Label +var shown := "" func _ready() -> void: @@ -24,27 +35,39 @@ func _ready() -> void: 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 tab_row := HBoxContainer.new() + rows.add_child(tab_row) + # A button group keeps exactly one tab pressed; clicking the selected tab + # leaves it highlighted. + var tab_group := ButtonGroup.new() + for gate: String in GalaxyGates.ORDER: + var tab := StationUi.button(tab_row, GalaxyGates.info(gate)["name"], func(): select(gate)) + tab.toggle_mode = true + tab.button_group = tab_group + tab.size_flags_horizontal = Control.SIZE_EXPAND_FILL + StationUi.tab(tab) + tabs[gate] = tab 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) + var gate_card := StationUi.card(body) + gate_card.size_flags_horizontal = Control.SIZE_EXPAND_FILL + var gate_rows := StationUi.rows(gate_card, 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) + faction = StationUi.heading(gate_rows, "", 13) + faction.add_theme_font_override("font", StationUi.tracked(true, 3)) + title = StationUi.heading(gate_rows, "", 30) + lore = StationUi.text(gate_rows, "", 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) + facts = StationUi.text(gate_rows, "", 15, StationUi.MUTED) + run_label = StationUi.text(gate_rows, "", 16) 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")) @@ -54,27 +77,25 @@ func _ready() -> void: 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) + StationUi.heading(op_rows, "PARTS OPERATION", 13, StationUi.MUTED).add_theme_font_override("font", StationUi.tracked(true, 3)) + operation_title = StationUi.heading(op_rows, "", 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 = TextureRect.new() 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 = StationUi.text(speaker, "", 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) + operation_rules = StationUi.text(op_rows, "", 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) @@ -85,15 +106,45 @@ func _ready() -> void: hide() +func select(gate: String) -> void: + selected = gate + + +# Static texts change only when another gate is selected. +func show_gate() -> void: + shown = selected + var definition := GalaxyGates.info(selected) + var operation: Dictionary = definition["signal"] + var reward: Dictionary = definition["reward"] + for gate: String in tabs: + tabs[gate].set_pressed_no_signal(gate == selected) + faction.text = definition["faction"].to_upper() + " FACTION" + faction.add_theme_color_override("font_color", definition["glow"]) + run_label.add_theme_color_override("font_color", definition["glow"]) + title.text = definition["name"].to_upper() + lore.text = definition["summary"] + parts_bar.max_value = definition["parts_required"] + facts.text = "%d waves, ending with the %s / %d lives per pilot / any pilot may join\nVictory pays every participant %s, with a %d%% chance of an %s." % [ + definition["waves"].size(), definition["boss"], definition["lives"], GalaxyGates.reward_text(selected, false), + roundi(reward["item_chance"] * 100), GalaxyGates.item_name(selected)] + operation_title.text = str(operation["title"]).to_upper() + portrait.texture = StorySites.portrait(operation["contact"]) + briefing.text = "%s\n%s" % [Story.CONTACTS[operation["contact"]]["name"].to_upper(), operation["briefing"]] + operation_rules.text = "Each %s kill you contribute to carries a %s part. Recover %d parts to complete the operation: +%d gate parts and %s. Other aliens sometimes carry parts too." % [ + SectorMaps.code(operation["map"]), definition["faction"], operation["required"], operation["parts"], + Story.reward_text(operation["credits"], operation["research"])] + signal_progress.max_value = operation["required"] + + func gates() -> Dictionary: var inventory := StationUi.inventory(sector) - return GalaxyGates.empty() if inventory.is_empty() else GalaxyGates.state(inventory) + return GalaxyGates.empty() if inventory.is_empty() else GalaxyGates.state(inventory, selected) 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, "") + sector.session.combat.request_station(action, selected) func fit_window() -> void: @@ -119,43 +170,48 @@ func close() -> void: func _process(_delta: float) -> void: if not visible: return + if shown != selected: + show_gate() + var definition := GalaxyGates.info(selected) + var required: int = definition["parts_required"] 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) + StationUi.set_text(summary, "%d / %d %s PARTS" % [parts, required, definition["faction"].to_upper()]) + StationUi.set_text(parts_label, "GATE PARTS %d / %d" % [parts, required]) + parts_bar.value = mini(parts, required) var run_text := "" if run.get("active", false): + var open_name: String = GalaxyGates.info(run["gate"])["name"] if run["phase"] == "victory": - run_text = "The mothership is down. The rift closes shortly." + run_text = "The %s boss is down. The arena closes shortly." % open_name 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"] + run_text = "%s OPEN near Outpost 01, assembled by %s. Fly through it to join; the first wave starts when a pilot arrives." % [open_name.to_upper(), 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"]] + run_text = "%s OPEN near Outpost 01. %s, %d pilots inside. Your lives: %d." % [open_name.to_upper(), 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 + reason = "A %s run is already open." % GalaxyGates.info(run["gate"])["name"] if reason.is_empty(): - reason = GalaxyGates.assemble_blocker(data) + reason = GalaxyGates.assemble_blocker(data, selected) 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 + assemble_button.tooltip_text = reason if not reason.is_empty() else "Consumes %d parts and opens the gate for everyone near Outpost 01." % 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)) + StationUi.set_text(signal_state, GalaxyGates.signal_objective(data, selected)) "done": - StationUi.set_text(signal_state, "Cache decoded. Assemble the gate to trace the next signal.") + StationUi.set_text(signal_state, "Operation complete. Assemble the gate to start the next one.") _: 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) + var accept_reason := station if not station.is_empty() else GalaxyGates.accept_blocker(data, selected) 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_run.gd b/scripts/gate_run.gd index 1bc785c..0960834 100644 --- a/scripts/gate_run.gd +++ b/scripts/gate_run.gd @@ -1,14 +1,16 @@ 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. +## Server-owned galaxy gate run. One run at a time across every gate: a pilot +## assembles a gate at Outpost 01, its portal opens nearby, and any pilot can fly +## through while it is open. Waves activate the gate's dormant arena aliens and +## end with its boss. 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 +# The open gate's ID in GalaxyGates.GATES, or empty without a run. +var gate := "" var builder := "" # waiting: before the first wave; fighting; interval: between waves; victory. var phase := "waiting" @@ -16,7 +18,7 @@ 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. +# Pilots inside at the last tick; the countdown pauses while the arena is empty. var last_inside := 0 # Remaining lives and participation, keyed by persistent pilot identity. var lives: Dictionary[String, int] = {} @@ -50,17 +52,32 @@ func key(id: int) -> String: return combat.session.pilot_ids.get(id, "peer%d" % id) +func definition() -> Dictionary: + return GalaxyGates.info(gate) + + +func map() -> int: + return int(definition()["map"]) if not gate.is_empty() else -1 + + +func gate_name() -> String: + return definition()["name"] + + func arena_aliens() -> Array[Alien]: var result: Array[Alien] = [] - result.assign(sector().map_rosters[GalaxyGates.MAP].values()) + if not gate.is_empty(): + result.assign(sector().map_rosters[map()].values()) return result func inside() -> Array[int]: var result: Array[int] = [] + if gate.is_empty(): + return result 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): + if ship.map_id == map() and ship.alive and not ship.get_meta("docked", false): result.append(id) return result @@ -68,44 +85,47 @@ func inside() -> Array[int]: ## Clears every run without rewards; used when a session starts or ends. func reset() -> void: active = false + gate = "" builder = "" phase = "waiting" wave = -1 lives.clear() wave_aliens.clear() - SectorMaps.rift_open = false - for alien in arena_aliens(): - dormant(alien) + SectorMaps.open_rift = -1 + for gate_id: String in GalaxyGates.ORDER: + for alien: Alien in sector().map_rosters[int(GalaxyGates.info(gate_id)["map"])].values(): + 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 "" + return "A %s run is already open. Join it near Outpost 01." % gate_name() if active else "" -func start(label: String) -> void: +func start(gate_id: String, label: String) -> void: reset() active = true + gate = gate_id builder = label clock = GalaxyGates.FIRST_WAVE_DELAY empty_clock = 0.0 - SectorMaps.rift_open = true + SectorMaps.open_rift = map() publish() - broadcast("%s opened near Outpost 01 by %s. Fly through it to join the run." % [GalaxyGates.NAME, label]) + broadcast("%s opened near Outpost 01 by %s. Fly through it to join the run." % [gate_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 +func entry_blocker(id: int, destination: int) -> String: + if not active or phase == "victory" or destination != map(): + return "That galaxy gate is closed." + if lives.get(key(id), int(definition()["lives"])) <= 0: + return "No lives left in this %s run." % gate_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 "" + return "The arena 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. @@ -114,16 +134,16 @@ 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]) + combat.message(id, "You abandoned the wave. %d lives left in this %s run." % [lives[key(id)], gate_name()]) publish() func entered(id: int) -> void: if not lives.has(key(id)): - lives[key(id)] = GalaxyGates.LIVES + lives[key(id)] = int(definition()["lives"]) empty_clock = 0.0 publish() - var notice := "Entered the Vashar Rift. %d lives. The gate behind you returns to M1." % lives[key(id)] + var notice := "Entered the %s. %d lives. The gate behind you returns to M1 between waves." % [definition()["arena"], lives[key(id)]] if phase == "waiting": notice += " First wave in %d seconds." % ceili(clock) combat.message(id, notice) @@ -133,7 +153,7 @@ 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.") + combat.message(id, "Ship lost in the %s. %d lives left in this run." % [definition()["arena"], lives[key(id)]] if lives[key(id)] > 0 else "Ship lost. No lives left in this %s run." % gate_name()) publish() @@ -153,7 +173,7 @@ func tick(delta: float) -> void: 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.") + fail("No pilots can continue." if exhausted else "Nobody held the arena.") return empty_clock = 0.0 match phase: @@ -166,7 +186,7 @@ func tick(delta: float) -> void: for alien in wave_aliens: if alien.alive: return - if wave >= GalaxyGates.WAVES.size() - 1: + if wave >= definition()["waves"].size() - 1: victory() else: phase = "interval" @@ -180,7 +200,7 @@ func start_wave(index: int, pilots: int) -> void: phase = "fighting" escort_clock = 0.0 wave_aliens.clear() - var counts := GalaxyGates.wave_counts(wave, pilots) + var counts := GalaxyGates.wave_counts(gate, wave, pilots) var parts: PackedStringArray = [] for kind: String in counts: var spawned := 0 @@ -191,13 +211,13 @@ func start_wave(index: int, pilots: int) -> void: 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)]) + arena_message("Wave %d of %d: %s." % [wave + 1, definition()["waves"].size(), ", ".join(parts)]) publish() func wave_point(kind: String) -> Vector3: - var origin := SectorMaps.origin(GalaxyGates.MAP) - var boss := kind == "Mothership" + var origin := SectorMaps.origin(map()) + var boss: bool = kind == definition()["boss"] var point := origin + Vector3(0, 60, -450) # Keep spawn points clear of the arena's asteroid colliders. for attempt in range(48): @@ -211,7 +231,7 @@ func wave_point(kind: String) -> Vector3: func clear_of_rocks(point: Vector3, margin: float) -> bool: - var terrain: Node3D = sector().map_terrain.get(GalaxyGates.MAP) + var terrain: Node3D = sector().map_terrain.get(map()) if terrain == null: return true for rock: Node in terrain.get_children(): @@ -232,11 +252,11 @@ func spawn(alien: Alien, point: Vector3) -> void: wave_aliens.append(alien) -# The mothership launches Shardling escorts from its hangar while it survives. +# The boss launches 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: + if alien.kind == definition()["boss"] and alien.alive: boss = alien if boss == null: return @@ -246,18 +266,19 @@ func tick_escorts(delta: float) -> void: escort_clock = 0.0 var launched := 0 for alien in arena_aliens(): - if launched < GalaxyGates.ESCORTS and alien.kind == "Shardling" and not alien.alive: + if launched < GalaxyGates.ESCORTS and alien.kind == definition()["escort"] 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) + arena_message("The %s launches %d %ss." % [definition()["boss"], launched, definition()["escort"]]) func victory() -> void: phase = "victory" clock = GalaxyGates.VICTORY_TIME - SectorMaps.rift_open = false + SectorMaps.open_rift = -1 + var reward: Dictionary = definition()["reward"] var session: FlightSession = combat.session var winners: Array[int] = [] var items: Dictionary[int, bool] = {} @@ -265,9 +286,9 @@ func victory() -> void: 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 ""} + items[id] = rng.randf() < float(reward["item_chance"]) + rewards[key(id)] = {"credits": reward["credits"], "research": reward["research"], + "x4": reward["x4"], "item": 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: @@ -281,22 +302,23 @@ func victory() -> void: 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.message(id, "%s %s. The arena closes in %d seconds." % [definition()["victory"], GalaxyGates.reward_text(gate, 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]) + broadcast("%s collapsed. %s The gate parts are lost." % [gate_name(), reason]) close() func close() -> void: for id in inside(): - combat.message(id, "The rift is closing. Returning to M1.") + combat.message(id, "The arena 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) + if map() >= 0: + sector().loot.clear_map(map()) reset() publish() @@ -318,10 +340,11 @@ func state_for(id: int, pilots: int = -1) -> Dictionary: 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. + # stop while the arena 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, + return {"active": true, "gate": gate, "map": map(), "open": SectorMaps.open_rift == map(), "phase": phase, + "wave": wave + 1, "waves": definition()["waves"].size(), "lives": lives.get(key(id), int(definition()["lives"])), + "entered": lives.has(key(id)), "builder": builder, "pilots": pilots, "countdown": countdown, "paused": pilots == 0} diff --git a/scripts/hud.gd b/scripts/hud.gd index 2df5590..34610c1 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -636,11 +636,13 @@ func draw_context() -> void: var messages: Array[String] = [] 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: - 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") + var target_gate := GalaxyGates.for_map(destination) + var place: String = "THE " + GalaxyGates.info(target_gate)["arena"].to_upper() if not target_gate.is_empty() else SectorMaps.code(destination) + var in_arena := GalaxyGates.is_arena(sector.map_id) + if in_arena and sector.session.combat.gate_summary.get("phase", "") == "fighting": + messages.append("ARENA 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"]) + messages.append("%s / JUMP TO %s%s" % [GameSettings.binding_text("jump_gate"), place, "" if in_arena else " / GATE PROTECTED"]) var run := gate_status() if not run.is_empty(): messages.append(run) @@ -936,31 +938,37 @@ func occupied(rect: Rect2) -> bool: 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 carried: Dictionary = drop.get("parts", {}) + if carried.is_empty() or not sector.loot.is_presented(id): + continue + var parts := 0 + for gate_id: String in carried: + parts += int(carried[gate_id]) + if parts > 0: var caption := "%d GATE PART%s" % [parts, "" if parts == 1 else "S"] - marker(drop["position"], caption, GalaxyGates.GLOW, false, null, false) + marker(drop["position"], caption, GalaxyGates.info(carried.keys()[0])["glow"], false, null, false) -# One-line Vashar Gate run status: wave and lives inside the rift, an invitation at M1. +# One-line galaxy gate run status: wave and lives inside the arena, 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: + var title: String = GalaxyGates.info(run["gate"])["name"].to_upper() + if sector.map_id == int(run["map"]): if run["phase"] == "victory": - return "VASHAR GATE CLEARED / RETURN THROUGH THE GATE" + return "%s CLEARED / RETURN THROUGH THE GATE" % title 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"]] + return "%s / %s / %d LIVES" % [title, 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 "%s OPEN NEAR OUTPOST 01 / %d LIVES" % [title, run["lives"]] if run["lives"] > 0 else "%s OPEN / NO LIVES LEFT" % title 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. +## Seconds until the next gate wave, counted down locally from the last +## server update; -1 without a pending wave. Paused while the arena 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: @@ -970,25 +978,25 @@ func gate_countdown() -> float: 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. +## Large centered countdown inside a gate arena 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 + if seconds < 0.0 or sector.map_id != int(run.get("map", -1)): + return + var definition := GalaxyGates.info(run["gate"]) + var glow: Color = definition["glow"] 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" + title = "FINAL WAVE / " + definition["boss_title"] 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) + draw_rect(Rect2(box.position, Vector2(box.size.x, 3)), glow) + text_at(Vector2(center.x - title_width * 0.5, box.position.y + 36), title, 26, 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 diff --git a/scripts/pilot_store.gd b/scripts/pilot_store.gd index 0783f20..35cbb85 100644 --- a/scripts/pilot_store.gd +++ b/scripts/pilot_store.gd @@ -113,8 +113,13 @@ func open(directory: String) -> bool: if pilot.has("equipment"): return fail("Unexpected equipment in legacy save. Original file preserved.") pilot["equipment"] = Equipment.starter() - elif not Equipment.valid(pilot.get("equipment")): - return fail("Invalid pilot equipment. Original file preserved.") + else: + var equipment: Variant = pilot.get("equipment") + # The first Vashar gate stored one gate state directly in equipment. + if equipment is Dictionary and GalaxyGates.valid(equipment.get("gates"), "vashar"): + equipment["gates"] = {"vashar": equipment["gates"]} + if not Equipment.valid(equipment): + return fail("Invalid pilot equipment. Original file preserved.") pilot["equipment"]["revision"] = int(pilot["equipment"]["revision"]) if pilot["equipment"].has("research"): Research.normalize(pilot["equipment"]["research"]) @@ -278,7 +283,7 @@ func commit(balances: Dictionary, contracts: Dictionary = {}, cargo: Dictionary 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]): + if not next.has(id) or not GalaxyGates.valid_collection(gates[id]): return fail("Invalid server gate update.") next[id]["equipment"]["gates"] = gates[id].duplicate() return persist(next) diff --git a/scripts/resource_loot.gd b/scripts/resource_loot.gd index 21af053..11e81d7 100644 --- a/scripts/resource_loot.gd +++ b/scripts/resource_loot.gd @@ -22,15 +22,15 @@ func clear_map(map: int) -> void: 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: +# `parts` maps gate IDs to galaxy gate parts carried in the box; they need no cargo space. +func spawn_drop(alien: Alien, parts: Dictionary = {}) -> void: if sector.session.active and not multiplayer.is_server(): return if drops.size() >= MAX_DROPS: change(drops.keys()[0], {}) next_id += 1 var data := {"map": alien.map_id, "position": alien.position, "resources": CargoResources.roll(alien.kind), "ttl": LIFETIME} - if parts > 0: + if not parts.is_empty(): data["parts"] = parts change(next_id, data) @@ -62,8 +62,10 @@ func apply_drop(id: int, data: Dictionary) -> void: if data["resources"].has(resource): richest = resource var material := StandardMaterial3D.new() - 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) + # Boxes carrying gate parts glow in the first gate's faction color. + var parts: Dictionary = data.get("parts", {}) + material.albedo_color = GalaxyGates.info(parts.keys()[0])["glow"] if not parts.is_empty() else CargoResources.TYPES[richest]["color"] + meshes[id].scale = Vector3.ONE * (1.5 if not parts.is_empty() 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 25d14a1..3766c5c 100644 --- a/scripts/sector.gd +++ b/scripts/sector.gd @@ -395,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) - elif enemy.map_id != GalaxyGates.MAP: + elif not GalaxyGates.is_arena(enemy.map_id): enemy.respawn = maxf(0.0, enemy.respawn - delta) if enemy.respawn <= 0.0: relocate_alien(enemy) @@ -748,8 +748,10 @@ func activate_map(map: int) -> void: SectorBackdrop.activate(self, map) -# Shows the Outpost 01 Vashar Gate only while the server reports an open run. +# Shows an Outpost 01 galaxy gate only while the server reports its run open. 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 + for gate_id: String in GalaxyGates.ORDER: + var arena: int = GalaxyGates.info(gate_id)["map"] + var gate := get_node_or_null("Map1Gates/GateToM%d" % (arena + 1)) as Node3D + if gate != null: + gate.visible = SectorMaps.open_rift == arena diff --git a/scripts/sector_backdrop.gd b/scripts/sector_backdrop.gd index 3936040..5895f2d 100644 --- a/scripts/sector_backdrop.gd +++ b/scripts/sector_backdrop.gd @@ -9,6 +9,8 @@ const THEMES := [ {"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")}, + # Korrath Bastion: a scorched forge world behind the siege fleet. + {"planet": Vector3(1900, 1000, -3500), "radius": 1600.0, "ocean": Color("2a1208"), "land": Color("5a2a14"), "atmosphere": Color("ff7a2e"), "water": 0.0, "clouds": 0.02, "mining": 1.0, "cool": Color("3d1a10"), "warm": Color("c2541f"), "light": Color("ff9a52")}, ] @@ -125,7 +127,13 @@ 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: + elif map == 5: + # Siege staging: heavy alien relays and extraction collars around the forge world. + planet_collectors(root, planet_position, radius, 5) + alien_relay(root, Vector3(-1700, 150, -2200), 1.6) + alien_collar(root, Vector3(-1900, -200, 1600), 320.0, Vector3(-.3, .4, .2), "SiegeCollar") + alien_collar(root, Vector3(1700, 260, 1900), 220.0, Vector3(.5, -.2, .3), "ForgeCollar") + elif map == 4: # 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) diff --git a/scripts/sector_maps.gd b/scripts/sector_maps.gd index d4d75f8..a2ef2e6 100644 --- a/scripts/sector_maps.gd +++ b/scripts/sector_maps.gd @@ -11,11 +11,14 @@ 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. + # Galaxy gate arenas: outside the connected network, entered only through an + # open gate. Each pool matches its GalaxyGates definition; waves activate it. 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"}, + 5: {"name": "KG / Korrath Bastion", "color": Color("ff8a3d"), "instance": true, + "aliens": ["Husk", "Husk", "Husk", "Husk", "Husk", "Husk", "Husk", "Husk", "Husk", "Husk", "Bulwark", "Bulwark", "Bulwark", "Bulwark", "Bulwark", "Siegebreaker"], + "description": "Korrath Gate / siege bastion / waves end with the Siegebreaker"}, } const GATES := { 0: {1: Vector3(0, 120, -900)}, @@ -23,17 +26,20 @@ 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. +# Galaxy gate endpoints: each gate's portal near Outpost 01 (see GalaxyGates +# "portal") and every arena's return gate. const SPECIAL_GATES := { - 0: {4: Vector3(320, 40, -300)}, + 0: {4: Vector3(320, 40, -300), 5: Vector3(-340, -30, -330)}, 4: {0: Vector3(0, 0, 700)}, + 5: {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 +# Replicated from the server's gate run: the arena map whose Outpost 01 portal is +# open, or -1. Only one gate run is open at a time. +static var open_rift := -1 # 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 +static var link_cache_open := -1 # Maps in the connected network, excluding gate arenas. static func network_maps() -> Array[int]: @@ -46,13 +52,13 @@ static func network_maps() -> Array[int]: # 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: + if link_cache_open != open_rift: link_cache.clear() - link_cache_open = rift_open + link_cache_open = open_rift 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: + if map != 0 or destination == open_rift: result[destination] = SPECIAL_GATES[map][destination] link_cache[map] = result return link_cache[map] @@ -66,7 +72,8 @@ static func endpoints(map: int) -> Dictionary: static func gate_label(destination: int) -> String: - return GalaxyGates.NAME.to_upper() if destination == GalaxyGates.MAP else "GATE TO " + code(destination) + var gate := GalaxyGates.for_map(destination) + return GalaxyGates.info(gate)["name"].to_upper() if not gate.is_empty() else "GATE TO " + code(destination) # Short map label such as "M2", used where a gate names its destination. static func code(map: int) -> String: @@ -89,7 +96,7 @@ static func arrival(map: int, source: int, slot: int = 0) -> Vector3: 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: + if GalaxyGates.is_arena(ship.map_id): return false if ship.map_id == 0 and ship.position.distance_to(Sector.STATION_POSITION) <= Sector.PROTECTION_RADIUS: return true @@ -103,7 +110,7 @@ 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: + if GalaxyGates.is_arena(source): return 0 var pending: Array[int] = [source] var previous := {source: -1} @@ -123,7 +130,9 @@ 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] + # Galaxy gates and arena exits take their faction's color. + var gate := GalaxyGates.for_map(destination if map == 0 else map) + var glow: Color = GalaxyGates.info(gate)["glow"] if not gate.is_empty() else Color("48e6f5") root.position = gate_position(map, destination) parent.add_child(root) root.look_at(origin(map), Vector3.UP) @@ -139,20 +148,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: + if not gate.is_empty(): # 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) + var tinted := surface.duplicate() as BaseMaterial3D + tinted.albedo_color = glow + tinted.emission = glow + part.set_surface_override_material(index, tinted) 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)) + if not gate.is_empty(): + energy.set_shader_parameter("energy_color", glow) var portal := SectorVisuals.mesh(root,aperture,Vector3.ZERO,energy) portal.name = "Portal" portal.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF @@ -161,7 +170,7 @@ 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("c86bff") if vashar else Color("48e6f5") + light.light_color = glow light.light_energy = 5.0 light.omni_range = 29 light.omni_attenuation = 0.8 diff --git a/scripts/session_combat.gd b/scripts/session_combat.gd index f40d624..bd4df0a 100644 --- a/scripts/session_combat.gd +++ b/scripts/session_combat.gd @@ -160,7 +160,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() and alien.map_id != GalaxyGates.MAP: + if multiplayer.is_server() and not GalaxyGates.is_arena(alien.map_id): sector.relocate_alien(alien) alien.position = alien.home_position alien.patrol_time = 0.0 @@ -435,7 +435,7 @@ func tick(delta: float) -> void: alien.tick_combat(delta) if alien.alive: alien.fly(delta, choose_target(alien), Sector.STATION_POSITION) - elif alien.map_id != GalaxyGates.MAP: # The gate run owns arena spawns. + elif not GalaxyGates.is_arena(alien.map_id): # The gate run owns arena spawns. alien.respawn = maxf(0.0, alien.respawn - delta) if alien.respawn <= 0.0: sector.relocate_alien(alien) @@ -558,7 +558,7 @@ 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: + if GalaxyGates.is_arena(ship.map_id): gate.died(id) @@ -1115,32 +1115,45 @@ 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] = {} + # Parts collected per pilot, keyed by gate ID, and those recovered on each + # gate's operation map, which advance its operation. + var parts: Dictionary[int, Dictionary] = {} + var qualifying: Dictionary[int, Dictionary] = {} 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)): + # Gate parts need no cargo space. Each gate's 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 boxed: Dictionary = drop.get("parts", {}) + var left := {} + var taken_any := false + for gate_id: String in boxed: + var remaining := int(boxed[gate_id]) + var qualifies := int(drop.get("map", 0)) == int(GalaxyGates.info(gate_id)["signal"]["map"]) + for carrier: int in part_collectors(drop, gate_id): + var held := int(parts[carrier].get(gate_id, 0)) if parts.has(carrier) else 0 + var room: int = GalaxyGates.MAX_PARTS - int(GalaxyGates.state(session.store.pilots[session.pilot_ids[carrier]]["equipment"], gate_id)["parts"]) - held + var take: int = mini(remaining, room) + if take <= 0: + continue + if not parts.has(carrier): + parts[carrier] = {} + qualifying[carrier] = {} + parts[carrier][gate_id] = held + take + if qualifies: + qualifying[carrier][gate_id] = int(qualifying[carrier].get(gate_id, 0)) + take + remaining -= take + taken_any = true + if remaining == 0: + break if remaining > 0: - drop["parts"] = remaining - else: + left[gate_id] = remaining + if taken_any: + if left.is_empty(): drop.erase("parts") - changed[drop_id] = {} if drop["resources"].is_empty() and remaining == 0 else drop + else: + drop["parts"] = left + changed[drop_id] = {} if drop["resources"].is_empty() and left.is_empty() else drop var candidates: Array[int] = [] for id: int in records: var ship := session.ships[id] @@ -1156,7 +1169,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() and int(drop.get("parts", 0)) == 0 else drop + changed[drop_id] = {} if drop["resources"].is_empty() and not drop.has("parts") 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] @@ -1171,14 +1184,26 @@ func collect_loot() -> void: var gates := {} var balances := {} var research := {} + # results[pilot][gate] holds each gate's collection result. 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"] + var equipment: Dictionary = session.store.pilots[pilot_id]["equipment"] + var next_gates := GalaxyGates.states(equipment).duplicate(true) + var credits := int(records[id]["credits"]) + var earned := 0 + results[id] = {} + for gate_id: String in parts[id]: + var result := GalaxyGates.collect(GalaxyGates.state(equipment, gate_id), gate_id, parts[id][gate_id], int(qualifying[id].get(gate_id, 0))) + results[id][gate_id] = result + next_gates[gate_id] = result["gates"] + credits = mini(PilotStore.MAX_CREDITS, credits + int(result["credits"])) + earned += int(result["research"]) + gates[pilot_id] = next_gates + if credits != int(records[id]["credits"]): + balances[pilot_id] = credits + if earned > 0: + research[pilot_id] = earned # 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() @@ -1187,11 +1212,16 @@ func collect_loot() -> void: 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"]: + if balances.has(session.pilot_ids[id]): 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"])]) + for gate_id: String in results[id]: + var result: Dictionary = results[id][gate_id] + var definition := GalaxyGates.info(gate_id) + var count: int = parts[id][gate_id] + message(id, "Collected %d %s part%s. %d / %d toward the gate." % [count, definition["faction"] + " gate", "" if count == 1 else "s", int(result["gates"]["parts"]), definition["parts_required"]]) + if result["completed"]: + var operation: Dictionary = definition["signal"] + message(id, "%s: %s %s and +%d gate parts." % [Story.CONTACTS[operation["contact"]]["call"], operation["done"], Story.reward_text(result["credits"], result["research"]), int(operation["parts"])]) publish_inventory(id) for id: int in notices: message(id, "Collected " + CargoResources.describe(notices[id])) @@ -1206,13 +1236,16 @@ func collect_loot() -> void: 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]: +# Living pilots within pickup range who may take one gate's parts from a box, +# in priority order. Pilots running that gate's operation come first when the +# box lies on its operation map, so its guaranteed parts reach them even in a +# box shared with other gates' parts; otherwise nearer pilots win, with ties in +# peer-ID order. +func part_collectors(drop: Dictionary, gate_id: String) -> Array[int]: var result: Array[int] = [] - if int(drop.get("parts", 0)) <= 0 or not session.sector.dedicated_server: + if int(drop.get("parts", {}).get(gate_id, 0)) <= 0 or not session.sector.dedicated_server: return result + var operation_map := int(drop.get("map", 0)) == int(GalaxyGates.info(gate_id)["signal"]["map"]) var ranks: Dictionary[int, Vector2] = {} for id: int in records: var ship := session.ships[id] @@ -1221,7 +1254,7 @@ func part_collectors(drop: Dictionary) -> Array[int]: 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"])) + var running := operation_map and GalaxyGates.signal_active(GalaxyGates.state(session.store.pilots[session.pilot_ids[id]]["equipment"], gate_id)) ranks[id] = Vector2(0.0 if running else 1.0, distance) result.append(id) result.sort_custom(func(a: int, b: int) -> bool: @@ -1229,16 +1262,19 @@ func part_collectors(drop: Dictionary) -> Array[int]: 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: +# Parts carried by a destroyed alien, per gate. A gate's operation guarantees one +# on its map when any contributing pilot has that operation active. +func roll_gate_parts(alien: Alien) -> Dictionary: if not session.sector.dedicated_server: - return 0 - var guaranteed := false - if alien.map_id == int(GalaxyGates.SIGNAL["map"]): + return {} + var guaranteed := [] + for gate_id: String in GalaxyGates.ORDER: + if alien.map_id != int(GalaxyGates.info(gate_id)["signal"]["map"]): + continue for id: int in alien.contributors: - if GalaxyGates.signal_active(GalaxyGates.state(session.store.pilots[session.pilot_ids[id]]["equipment"])): - guaranteed = true + if GalaxyGates.signal_active(GalaxyGates.state(session.store.pilots[session.pilot_ids[id]]["equipment"], gate_id)): + guaranteed.append(gate_id) + break return GalaxyGates.roll_parts(alien.kind, part_rng, guaranteed) @@ -1247,7 +1283,7 @@ 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) + SectorMaps.open_rift = int(data.get("map", -1)) if data.get("open", false) else -1 if not session.sector.dedicated_server: session.sector.refresh_rift() diff --git a/scripts/station_actions.gd b/scripts/station_actions.gd index 4a01b26..cc2f190 100644 --- a/scripts/station_actions.gd +++ b/scripts/station_actions.gd @@ -50,9 +50,10 @@ static func result(pilot: Dictionary, action: String, subject: String, previous_ if action == "configure_extra": return "Extra settings saved." if action == "gate_signal": - return "Signal Anomaly accepted. " + GalaxyGates.SIGNAL["objective"] + "." + var operation: Dictionary = GalaxyGates.info(subject)["signal"] + return "%s accepted. %s." % [operation["title"], operation["objective"]] if action == "gate_assemble": - return "%s assembled. It is opening near Outpost 01." % GalaxyGates.NAME + return "%s assembled. It is opening near Outpost 01." % GalaxyGates.info(subject)["name"] if action == "research": return "%s researched to level %d.%s" % [Research.SKILLS[subject]["name"], Research.level(Research.state(equipment), subject), Story.progress_notice(previous_story, Story.state(equipment))] if action == "research_reset": @@ -293,24 +294,27 @@ static func story(pilot: Dictionary, action: String, subject: String, ship: Stri 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(): + # The subject names the gate; progress for other gates is unchanged. + if not GalaxyGates.GATES.has(subject) 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 state := GalaxyGates.state(equipment, subject) var blocker := "" match action: "gate_signal": - blocker = GalaxyGates.accept_blocker(state) + blocker = GalaxyGates.accept_blocker(state, subject) state = state.duplicate() state["signal"] = "active" state["progress"] = 0 "gate_assemble": - blocker = GalaxyGates.assemble_blocker(state) + blocker = GalaxyGates.assemble_blocker(state, subject) if blocker.is_empty(): - state = GalaxyGates.assemble(state) + state = GalaxyGates.assemble(state, subject) if not blocker.is_empty(): return blocker - equipment["gates"] = state + var gates := GalaxyGates.states(equipment).duplicate(true) + gates[subject] = state + equipment["gates"] = gates return "" diff --git a/scripts/station_desk.gd b/scripts/station_desk.gd index 9e13fe3..f1bf238 100644 --- a/scripts/station_desk.gd +++ b/scripts/station_desk.gd @@ -30,7 +30,7 @@ func station_request(id: int, sequence: int, action: String, subject: String, sh 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() + blocker = "Unknown galaxy gate." if not GalaxyGates.GATES.has(subject) else 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(): @@ -38,8 +38,8 @@ func station_request(id: int, sequence: int, action: String, subject: String, sh 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) + combat.gate.start(subject, "a preview pilot") + publish_inventory(id, "Preview: %s opened near Outpost 01." % GalaxyGates.info(subject)["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"] @@ -71,7 +71,7 @@ func station_request(id: int, sequence: int, action: String, subject: String, sh 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) + combat.gate.start(subject, "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 77e9f43..2d01b43 100644 --- a/tests/alien_assets_test.gd +++ b/tests/alien_assets_test.gd @@ -78,14 +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") - 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)) + "Every authored encounter type has an imported model and a mesh-free server diameter") + check_gate_models("vashar") + check_gate_models("korrath") + # Gate rosters are their own faction progressions, checked separately. + var roster: Array = Alien.TYPES.keys().filter(func(kind: String): return not kind in GalaxyGates.arena_kinds()) 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: @@ -151,7 +151,7 @@ func check_finish(kind: String, mesh: ArrayMesh) -> void: if material.resource_name.ends_with("coated armor"): painted = material.clearcoat_enabled # 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) + var minimum_lift := 2.0 if kind in ["Scout", "Sentinel", "Heavy"] else (0.1 if kind in GalaxyGates.arena_kinds() 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 @@ -164,21 +164,21 @@ func check_finish(kind: String, mesh: ArrayMesh) -> void: 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") # Vashar crystals are deliberately low-poly faceted hulls without forward optics. - var vashar := GalaxyGates.POOL.has(kind) + var vashar := kind in GalaxyGates.arena_kinds() 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: +func check_gate_models(gate_id: String) -> void: var previous := 0.0 - for kind: String in GalaxyGates.POOL: + for kind: String in GalaxyGates.info(gate_id)["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(diameter > previous, kind + " is larger than the previous faction 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]) diff --git a/tests/combat_effects_test.gd b/tests/combat_effects_test.gd index 5598938..f07ee08 100644 --- a/tests/combat_effects_test.gd +++ b/tests/combat_effects_test.gd @@ -4,9 +4,11 @@ extends "res://tests/encounter_test.gd" class LootHud extends FlightHud: var captions: Array[String] = [] + var tints: Array[Color] = [] - func marker(_location: Vector3, label: String, _color: Color, _selected: bool, _teammate: Pilot = null, _priority: bool = true) -> void: + func marker(_location: Vector3, label: String, color: Color, _selected: bool, _teammate: Pilot = null, _priority: bool = true) -> void: captions.append(label) + tints.append(color) func run() -> void: @@ -169,7 +171,7 @@ 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 during the explosion") var update: Dictionary = sector.loot.drops[id].duplicate(true) update["resources"] = {"prometium": 1} - update["parts"] = 2 + update["parts"] = {"korrath": 2, "vashar": 1} 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}) @@ -181,7 +183,13 @@ func destruction_checks() -> void: 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") + check(hud.captions == ["3 GATE PARTS"] and hud.tints == [GalaxyGates.info("korrath")["glow"]], "Mixed gate parts share one marker tinted to match the box") + update["parts"] = {"vashar": 1} + sector.loot.apply_drop(id, update) + hud.captions.clear() + hud.tints.clear() + hud.draw_gate_parts() + check(hud.captions == ["1 GATE PART"] and hud.tints == [GalaxyGates.info("vashar")["glow"]], "Remaining Vashar part has its own faction tint and singular caption") update.erase("parts") sector.loot.apply_drop(id, update) hud.captions.clear() diff --git a/tests/connected_maps_test.gd b/tests/connected_maps_test.gd index 6fb15c5..01afe09 100644 --- a/tests/connected_maps_test.gd +++ b/tests/connected_maps_test.gd @@ -59,7 +59,10 @@ 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 + 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 arena_slots := 0 + for gate_id: String in GalaxyGates.ORDER: + arena_slots += GalaxyGates.pool_kinds(gate_id).size() + check(server.world_aliens.size() == 20 + arena_slots and server.map_rosters.size() == 4 + GalaxyGates.ORDER.size(), "Four bounded maps contain five alien slots each, plus the dormant gate arena pools") var gates := 0 for map: int in SectorMaps.GATES: for destination: int in SectorMaps.GATES[map]: @@ -68,7 +71,7 @@ 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: + if GalaxyGates.is_arena(enemy.map_id): 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") diff --git a/tests/galaxy_gates_test.gd b/tests/galaxy_gates_test.gd index b814f65..8fea48e 100644 --- a/tests/galaxy_gates_test.gd +++ b/tests/galaxy_gates_test.gd @@ -3,60 +3,91 @@ extends "res://tests/hunting_contracts_test.gd" ## full Vashar Gate run with lives, waves, escorts, victory and collapse. +const VASHAR := "vashar" +const KORRATH := "korrath" +const VMAP := 4 +const KMAP := 5 + + func run_rules() -> void: var gates := GalaxyGates.empty() - check(GalaxyGates.valid(gates), "Empty gate progress is valid") + var vashar := GalaxyGates.info(VASHAR) + var operation: Dictionary = vashar["signal"] + check(GalaxyGates.valid(gates, VASHAR) and GalaxyGates.valid_collection({}), "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)) + {"parts": 0, "signal": "active", "progress": operation["required"]}, {"parts": 0, "signal": "done", "progress": 0, "extra": 1}]: + check(not GalaxyGates.valid(invalid, VASHAR), "Malformed gate state is rejected: %s" % JSON.stringify(invalid)) + check(not GalaxyGates.valid_collection({"unknown": gates}) and not GalaxyGates.valid_collection([gates]), "Unknown gates and non-dictionaries are rejected") + check(GalaxyGates.valid({"parts": 0, "signal": "active", "progress": 9}, KORRATH) and not GalaxyGates.valid({"parts": 0, "signal": "active", "progress": 9}, VASHAR), + "Operation progress is bounded by each gate's own requirement") 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} + equipment["gates"] = {VASHAR: {"parts": 7, "signal": "active", "progress": 3}, KORRATH: {"parts": 2, "signal": "available", "progress": 0}} + check(Equipment.valid(equipment), "Saved progress for several gates keeps equipment valid") + equipment["gates"] = {VASHAR: {"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(GalaxyGates.accept_blocker(gates, VASHAR).is_empty() and not GalaxyGates.assemble_blocker(gates, VASHAR).is_empty(), "A new pilot can trace the signal but cannot assemble") + var plain := GalaxyGates.collect(gates, VASHAR, 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") + var partial := GalaxyGates.collect(active, VASHAR, 1, 1) + check(GalaxyGates.collect(active, VASHAR, 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}) + var done := GalaxyGates.collect(partial["gates"], VASHAR, 3, 3) + check(done["completed"] and done["gates"] == {"parts": 4 + operation["parts"], "signal": "done", "progress": 0} + and done["credits"] == operation["credits"] and done["research"] == operation["research"], "The final part decodes the cache once") + check(not GalaxyGates.accept_blocker(done["gates"], VASHAR).is_empty(), "A decoded signal waits for the next gate") + check(GalaxyGates.collect({"parts": 998, "signal": "available", "progress": 0}, VASHAR, 5, 5)["gates"]["parts"] == GalaxyGates.MAX_PARTS, "Stock is capped") + var assembled := GalaxyGates.assemble({"parts": 23, "signal": "done", "progress": 0}, VASHAR) check(assembled == {"parts": 3, "signal": "available", "progress": 0}, "Assembly consumes one gate and reopens the signal") + check(GalaxyGates.assemble({"parts": 30, "signal": "available", "progress": 0}, KORRATH)["parts"] == 6, "Each gate consumes its own part count") 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}, + check(GalaxyGates.roll_parts("Scout", rng, []).is_empty() and GalaxyGates.roll_parts("Shardling", rng, []).is_empty() and GalaxyGates.roll_parts("Husk", rng, []).is_empty(), + "Home-map and arena aliens carry no parts") + check(int(GalaxyGates.roll_parts("Skirmisher", rng, [VASHAR]).get(VASHAR, 0)) >= 1, "The operation guarantees a part") + check(not GalaxyGates.roll_parts("Skirmisher", rng, []).has(KORRATH), "Korrath parts only come from the deeper maps") + check(GalaxyGates.wave_counts(VASHAR, 0, 1) == {"Shardling": 3} and GalaxyGates.wave_counts(VASHAR, 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") + check(GalaxyGates.wave_counts(VASHAR, 6, 10)["Mothership"] == 1, "The boss wave has one mothership at any group size") + for gate_id: String in GalaxyGates.ORDER: + var definition := GalaxyGates.info(gate_id) + check(str(GalaxyGates.pool_kinds(gate_id)) == str(SectorMaps.MAPS[definition["map"]]["aliens"]), "%s arena roster matches its pool" % definition["name"]) + check(GalaxyGates.for_map(definition["map"]) == gate_id and SectorMaps.SPECIAL_GATES[0][definition["map"]] == definition["portal"], "%s has its own arena and Outpost 01 portal" % definition["name"]) + check(Equipment.MODELS.has(definition["reward"]["item"]) and not Equipment.purchase_blocker(definition["reward"]["item"]).is_empty(), "%s rewards an item the shop does not sell" % definition["name"]) + for wave: Dictionary in definition["waves"]: + for kind: String in wave: + check(Alien.TYPES.has(kind) and CargoResources.LOOT.has(kind) and int(wave[kind]) <= int(definition["pool"][kind]), "%s wave aliens exist and fit the pool" % definition["name"]) + check(definition["waves"].back().has(definition["boss"]) and definition["pool"].has(definition["escort"]), "%s ends with its boss and escorts" % definition["name"]) + var final_wave: int = definition["waves"].size() - 1 + check(int(GalaxyGates.wave_counts(gate_id, final_wave, 10)[definition["escort"]]) <= int(definition["pool"][definition["escort"]]) - GalaxyGates.ESCORTS, + "%s boss wave leaves dormant escorts at any group size" % definition["name"]) + check(float(Alien.TYPES[definition["boss"]]["range"]) < 310.0, "%s boss stays out-ranged by pilot lasers" % definition["name"]) + check(SectorMaps.first_hop(VMAP, 1) == 0 and SectorMaps.first_hop(KMAP, 2) == 0, "Routing out of an 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 saved(server: Sector, client: Sector, gate_id: String = VASHAR) -> Dictionary: + return GalaxyGates.state(server.session.store.pilots[server.session.pilot_ids[client.multiplayer.get_unique_id()]]["equipment"], gate_id) 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) + # Follow real gate connections; arenas connect only to Outpost 01. + while server.session.ships[id].map_id != map: + var current := server.session.ships[id].map_id + var hop := 0 + if SectorMaps.GATES.get(current, {}).has(map) or (current == 0 and GalaxyGates.is_arena(map)): + hop = map + elif not GalaxyGates.is_arena(current) and not GalaxyGates.is_arena(map): + hop = SectorMaps.first_hop(current, map) + server.session.transfer(id, hop) await settle(0.08) -func request(server: Sector, client: Sector, action: String) -> void: +func request(server: Sector, client: Sector, action: String, gate_id: String = VASHAR) -> void: await move_to(server, client, 0) station(server, client) - client.session.combat.request_station(action, "") + client.session.combat.request_station(action, gate_id) await settle(0.12) @@ -82,24 +113,37 @@ func pick_up(server: Sector, client: Sector, drop_id: int) -> void: # 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: +func click_control(client: Sector, control: Control) -> void: + var point := control.get_global_rect().get_center() + for pressed: bool in [true, false]: + var event := InputEventMouseButton.new() + event.button_index = MOUSE_BUTTON_LEFT + event.button_mask = MOUSE_BUTTON_MASK_LEFT if pressed else 0 + event.pressed = pressed + event.position = point + client.get_viewport().push_input(event) + await settle(0.05) + + +# `parts` maps gate IDs to part counts. +func place_box(server: Sector, map: int, position: Vector3, parts: Dictionary, resources: Dictionary = {}) -> int: server.loot.next_id += 1 var data := {"map": map, "position": position, "resources": resources, "ttl": ResourceLoot.LIFETIME} - if parts > 0: + if not parts.is_empty(): data["parts"] = parts server.loot.change(server.loot.next_id, data) return server.loot.next_id -func enter(server: Sector, client: Sector) -> String: +func enter(server: Sector, client: Sector, arena: int = VMAP) -> 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) + ship.position = SectorMaps.gate_position(0, arena) server.session.jump_until.erase(id) - var reason := server.session.jump(id, server.session.combat.records[id]["life"], GalaxyGates.MAP) + var reason := server.session.jump(id, server.session.combat.records[id]["life"], arena) # Leave the protected arrival zone so the pilot can fight. - ship.position = SectorMaps.origin(GalaxyGates.MAP) + Vector3(0, 0, 200) + ship.position = SectorMaps.origin(arena) + Vector3(0, 0, 200) return reason @@ -137,12 +181,12 @@ func run() -> void: 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(): + for alien: Alien in server.map_rosters[VMAP].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") + check(saved(server, pilot)["signal"] == "active" and pilot.session.combat.inventory["gates"][VASHAR]["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) @@ -151,13 +195,13 @@ func run() -> void: 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"]) + check(drop >= 0 and int(server.loot.drops[drop].get("parts", {}).get(VASHAR, 0)) >= 1, "An M2 kill during the operation carries a gate part") + var carried := int(server.loot.drops[drop]["parts"][VASHAR]) 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(saved(server, pilot)["parts"] == carried and saved(server, pilot)["progress"] == mini(carried, GalaxyGates.info(VASHAR)["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") + check(partner_drop < 0 or int(server.loot.drops[partner_drop].get("parts", {}).get(VASHAR, 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"] @@ -172,26 +216,26 @@ func run() -> void: 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() + next[pilot_id]["equipment"]["gates"][VASHAR]["parts"] = GalaxyGates.MAX_PARTS - 1 + next[partner_key]["equipment"]["gates"] = {VASHAR: 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) + var full_box := place_box(server, 2, spot, {VASHAR: 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 + next[partner_key]["equipment"]["gates"][VASHAR]["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) + var first_box := place_box(server, 2, spot, {VASHAR: 1}) + full_box = place_box(server, 2, spot, {VASHAR: 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") + 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"][VASHAR]) == 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") + check(server.loot.drops.has(full_box) and int(server.loot.drops[full_box]["parts"][VASHAR]) == 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]: @@ -200,30 +244,48 @@ func run() -> void: else: next[key]["equipment"].erase("gates") check(store.persist(next), "Restore gate-part stocks") + # A mixed box: the pilot running the Korrath operation gets its M3 part even + # though a closer pilot runs the Vashar one, who takes the Vashar part. + next = store.pilots.duplicate(true) + var partner_gates: Dictionary = next[partner_key]["equipment"].get("gates", {}).duplicate(true) + next[partner_key]["equipment"]["gates"] = partner_gates.merged({KORRATH: {"parts": 0, "signal": "active", "progress": 0}}, true) + check(store.persist(next), "Start the partner's Korrath operation") + var vashar_before: int = saved(server, pilot)["parts"] + var mixed := place_box(server, 2, spot, {VASHAR: 1, KORRATH: 1}) + combat.collect_loot() + await settle(0.05) + check(not server.loot.drops.has(mixed) and saved(server, partner, KORRATH)["parts"] == 1 and saved(server, partner, KORRATH)["progress"] == 1 + and saved(server, pilot, KORRATH)["parts"] == 0 and saved(server, pilot)["parts"] == vashar_before + 1, "A mixed box sends each operation's part to the pilot running it on its map") + next = store.pilots.duplicate(true) + if partner_gates.is_empty(): + next[partner_key]["equipment"].erase("gates") + else: + next[partner_key]["equipment"]["gates"] = partner_gates + check(store.persist(next), "Restore the partner's operations") # 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"]): + for attempt in range(GalaxyGates.info(VASHAR)["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") + check(after["signal"] == "done" and after["parts"] >= GalaxyGates.info(VASHAR)["signal"]["required"] + GalaxyGates.info(VASHAR)["signal"]["parts"], "Completing the operation adds the cache parts") + check(store.pilots[pilot_id]["credits"] >= credits + GalaxyGates.info(VASHAR)["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 + next[pilot_id]["equipment"]["gates"][VASHAR]["parts"] = GalaxyGates.info(VASHAR)["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.active and SectorMaps.open_rift == VMAP 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") + check(pilot.hud.navigation.has_contact("gate%d" % VMAP), "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") @@ -231,7 +293,7 @@ func run() -> void: 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") + check(server.session.ships[id].map_id == VMAP and gate.lives[pilot_id] == GalaxyGates.info(VASHAR)["lives"], "Entering joins the run with full lives") gate.tick(1.0) await settle(0.1) var countdown: float = pilot.hud.gate_countdown() @@ -239,26 +301,26 @@ func run() -> void: 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.phase == "fighting" and gate.wave == 0 and alive == GalaxyGates.wave_counts(VASHAR, 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.map_id == VMAP 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) + holder.position = SectorMaps.gate_position(VMAP, 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) + check(server.session.jump(id, combat.records[id]["life"], 0).contains("sealed") and holder.map_id == VMAP, "The rift exit is sealed while a wave is alive") + holder.position = SectorMaps.origin(VMAP) + 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") + check(gate.lives[server.session.pilot_ids[partner_id]] == GalaxyGates.info(VASHAR)["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") + check(gate.lives[server.session.pilot_ids[partner_id]] == GalaxyGates.info(VASHAR)["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) @@ -273,15 +335,15 @@ func run() -> void: while true: var probe := RandomNumberGenerator.new() probe.seed = seed - if probe.randf() < GalaxyGates.REWARD["item_chance"] and probe.randf() >= GalaxyGates.REWARD["item_chance"]: + if probe.randf() < GalaxyGates.info(VASHAR)["reward"]["item_chance"] and probe.randf() >= GalaxyGates.info(VASHAR)["reward"]["item_chance"]: break seed += 1 var research := int(Research.state(store.pilots[pilot_id]["equipment"])["points"]) - for wave in range(GalaxyGates.WAVES.size()): + for wave in range(GalaxyGates.info(VASHAR)["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: + if wave == GalaxyGates.info(VASHAR)["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() @@ -290,11 +352,11 @@ func run() -> void: 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") + check(gate.phase == "victory" and SectorMaps.open_rift != VMAP, "Destroying the last wave wins and closes the entrance") + check(store.pilots[pilot_id]["credits"] >= pilot_credits + GalaxyGates.info(VASHAR)["reward"]["credits"] + and int(Research.state(store.pilots[pilot_id]["equipment"])["points"]) == research + GalaxyGates.info(VASHAR)["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(int(store.pilots[winner]["ammo"]["x4"]) == x4[winner] + GalaxyGates.info(VASHAR)["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") @@ -306,7 +368,7 @@ func run() -> void: 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(): + for alien: Alien in server.map_rosters[VMAP].values(): check(not alien.alive, "Closing the rift leaves arena aliens dormant") # Preview gates need an allowlisted pilot; an empty gate collapses. @@ -321,16 +383,81 @@ func run() -> void: 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") + # Gate tabs behave as one group: re-clicking the selected tab keeps it pressed. + var menu := pilot.gate_menu + var pressed_tabs := func() -> Array: return menu.tabs.keys().filter(func(gate: String): return menu.tabs[gate].button_pressed) + await click_control(pilot, menu.tabs[menu.selected]) + check(pressed_tabs.call() == [menu.selected], "Clicking the selected gate tab keeps it highlighted") + await click_control(pilot, menu.tabs[KORRATH]) + check(menu.selected == KORRATH and pressed_tabs.call() == [KORRATH] and menu.title.text == "KORRATH GATE", "Clicking another gate tab moves the highlight") + await click_control(pilot, menu.tabs[VASHAR]) # 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") + check(retreating.is_empty() and gate.phase == "fighting" and gate.lives[partner_pilot_id] == GalaxyGates.info(VASHAR)["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}) + check(server.session.ships[partner_id].get_meta("docked", false) and gate.lives[partner_pilot_id] == GalaxyGates.info(VASHAR)["lives"] - 1, "Quitting to the station mid-wave costs a life") + var leftover := place_box(server, VMAP, SectorMaps.origin(VMAP), {VASHAR: 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") + check(not gate.active and SectorMaps.open_rift != VMAP, "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)) != VMAP), "A closing run clears the arena's loot") + await run_korrath(server, pilot) finish() + + +# The second gate: its own operation map, portal, arena, boss and rewards. +func run_korrath(server: Sector, pilot: Sector) -> void: + var store := server.session.store + var combat := server.session.combat + var gate := combat.gate + var id := pilot.multiplayer.get_unique_id() + var pilot_id: String = server.session.pilot_ids[id] + var korrath := GalaxyGates.info(KORRATH) + await request(server, pilot, "gate_signal", KORRATH) + check(saved(server, pilot, KORRATH)["signal"] == "active" and saved(server, pilot)["signal"] == "available", "The Korrath operation is tracked separately from the Vashar one") + var drop: int = await kill_on_map(server, int(korrath["signal"]["map"]), [pilot]) + check(drop >= 0 and int(server.loot.drops[drop].get("parts", {}).get(KORRATH, 0)) >= 1, "An M3 kill during the Korrath operation carries a Korrath part") + await pick_up(server, pilot, drop) + check(saved(server, pilot, KORRATH)["parts"] >= 1 and saved(server, pilot, KORRATH)["progress"] >= 1, "Korrath parts are saved under their own gate") + await request(server, pilot, "gate_preview", KORRATH) + check(gate.active and gate.gate == KORRATH and SectorMaps.open_rift == KMAP, "A preview pilot opens the Korrath Gate") + check(SectorMaps.links(0).has(KMAP) and not SectorMaps.links(0).has(VMAP), "Only the open gate's portal is usable at Outpost 01") + await sync(server) + check(pilot.hud.navigation.has_contact("gate%d" % KMAP) and pilot.session.combat.gate_summary["gate"] == KORRATH, "Clients see the open Korrath Gate") + var blocked := server.session.jump(id, combat.records[id]["life"], VMAP) + check(not blocked.is_empty(), "A closed gate cannot be entered while another is open") + var entered: String = await enter(server, pilot, KMAP) + check(entered.is_empty() and server.session.ships[id].map_id == KMAP, "Pilots fly into the Korrath Bastion") + await settle(0.1) + check(pilot.hud.gate_status().begins_with("KORRATH GATE / WAVE 1 IN"), "The HUD names the Korrath Gate and its countdown") + var credits: int = store.pilots[pilot_id]["credits"] + var shields := func() -> int: return store.pilots[pilot_id]["equipment"]["items"].values().filter(func(item: Dictionary): return item["model"] == "sg3n-b00").size() + var shields_before: int = shields.call() + gate.tick(GalaxyGates.FIRST_WAVE_DELAY + 0.1) + check(gate.wave_aliens.size() == GalaxyGates.wave_counts(KORRATH, 0, 1)["Husk"] and gate.wave_aliens.all(func(alien: Alien): return alien.kind == "Husk" and alien.map_id == KMAP), + "The first Korrath wave sends Husks into the bastion") + var seed := 0 + while true: + var probe := RandomNumberGenerator.new() + probe.seed = seed + if probe.randf() < korrath["reward"]["item_chance"]: + break + seed += 1 + for wave in range(korrath["waves"].size()): + if wave > 0: + gate.tick(GalaxyGates.WAVE_DELAY + 0.1) + if wave == korrath["waves"].size() - 1: + check(gate.wave_aliens.any(func(alien: Alien): return alien.kind == "Siegebreaker" and alien.alive), "The final wave brings the Siegebreaker") + var before := gate.wave_aliens.filter(func(alien: Alien): return alien.alive).size() + gate.tick(GalaxyGates.ESCORT_INTERVAL + 0.1) + check(gate.wave_aliens.filter(func(alien: Alien): return alien.alive).size() > before, "The Siegebreaker launches Husk escorts") + gate.rng.seed = seed + clear_wave(server, pilot) + gate.tick(0.1) + check(gate.phase == "victory" and store.pilots[pilot_id]["credits"] >= credits + int(korrath["reward"]["credits"]), "Destroying the Siegebreaker pays the Korrath reward") + check(shields.call() == shields_before + 1, "A won roll places an SG3N-B00 shield in storage") + gate.tick(GalaxyGates.VICTORY_TIME + 0.1) + await settle(0.1) + check(not gate.active and server.session.ships[id].map_id == 0, "The Korrath Bastion closes and returns pilots home") diff --git a/tests/pilot_persistence_test.gd b/tests/pilot_persistence_test.gd index 361af5d..f88ee98 100644 --- a/tests/pilot_persistence_test.gd +++ b/tests/pilot_persistence_test.gd @@ -105,6 +105,7 @@ func run() -> void: check(FileAccess.get_file_as_string(path + ".bak") == before, "Backup retains previous complete ledger") store.close() var good := FileAccess.get_file_as_string(path) + check_gate_saves(directory, good) for invalid in ["{broken", '{"version":2,"pilots":{}}', '{"version":1,"pilots":{"pilot0":{"verifier":"%s","credits":-1}}}' % test_token(0).sha256_text(), '{"version":1,"pilots":{"pilot0":{"verifier":"%s","credits":1.5}}}' % test_token(0).sha256_text()]: write_text(path, invalid) store = PilotStore.new() @@ -130,6 +131,48 @@ func run() -> void: finish() +func check_gate_saves(directory: String, snapshot: String) -> void: + var path := directory.path_join("pilots.json") + var ledger: Dictionary = JSON.parse_string(snapshot) + var equipment: Dictionary = ledger["pilots"]["pilot0"]["equipment"] + var flat := {"parts": 23, "signal": "active", "progress": 7} + var current := {"vashar": flat, "korrath": {"parts": 19, "signal": "active", "progress": 9}} + for gates: Variant in [flat, current, {}, null]: + var expected := equipment.duplicate(true) + if gates == null: + equipment.erase("gates") + expected.erase("gates") + else: + equipment["gates"] = gates + expected["gates"] = {"vashar": flat} if gates == flat else gates + write_text(path, JSON.stringify(ledger)) + # Compare JSON values consistently: Godot parses numbers as floats. + expected = JSON.parse_string(JSON.stringify(expected)) + for attempt in 2: + var store := PilotStore.new() + var opened := store.open(directory) + check(opened, "Gate fixture opens on pass %d: %s" % [attempt, store.error]) + if opened: + var loaded: Dictionary = JSON.parse_string(JSON.stringify(store.pilots["pilot0"]["equipment"])) + check(loaded == expected, "Loader preserves gate and equipment progress") + check(store.commit({"pilot0": 81}), "Normal wallet commit saves gate progress") + var disk: Dictionary = JSON.parse_string(FileAccess.get_file_as_string(path)) + check(disk["pilots"]["pilot0"]["equipment"] == expected, "Ledger writes canonical gate progress") + store.close() + if not opened: break + var mixed := flat.duplicate() + mixed["korrath"] = current["korrath"] + for invalid: Variant in [mixed, {"parts": 4}, {"parts": 0, "signal": "active", "progress": 8}, + {"parts": true, "signal": "done", "progress": 0}, {"unknown": flat}, {"korrath": null}, null]: + equipment["gates"] = invalid + var original := JSON.stringify(ledger) + write_text(path, original) + var store := PilotStore.new() + check(not store.open(directory), "Corrupt gate fixture refuses startup") + store.close() + check(FileAccess.get_file_as_string(path) == original, "Rejected gate fixture preserves the snapshot") + + func write_text(path: String, value: String) -> void: var file := FileAccess.open(path, FileAccess.WRITE) file.store_string(value) diff --git a/tests/pilots_test.py b/tests/pilots_test.py index 4daac4d..59bbce2 100644 --- a/tests/pilots_test.py +++ b/tests/pilots_test.py @@ -88,6 +88,48 @@ 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_gate_save_edits(self): + flat = {"parts": 23, "signal": "active", "progress": 7} + current = {"vashar": flat, "korrath": {"parts": 19, "signal": "active", "progress": 9}} + for first_edit in ("rotate", "add"): + with self.subTest(first_edit=first_edit), tempfile.TemporaryDirectory() as directory: + root = Path(directory) + path, _, _, _ = self.journal_fixture(root) + data = json.loads(path.read_text()) + records = data["pilots"] + for pilot in ("current", "empty", "absent"): + records[pilot] = json.loads(json.dumps(records["test"])) + records["test"]["equipment"]["gates"] = flat + records["current"]["equipment"]["gates"] = current + records["empty"]["equipment"]["gates"] = {} + path.write_text(json.dumps(data)) + expected = {pilot: rec["equipment"].copy() for pilot, rec in records.items()} + expected["test"]["gates"] = {"vashar": flat} + for index, edit in enumerate((first_edit, "rotate")): + pilot, flags = ("test", ["--rotate"]) if edit == "rotate" else ("new", []) + result = subprocess.run([sys.executable, pilots.__file__, str(root), pilot, + str(root / f"credential-{index}.json"), *flags], capture_output=True) + self.assertEqual(result.returncode, 0, result.stderr.decode()) + saved = json.loads(path.read_text())["pilots"] + for pilot, equipment in expected.items(): + self.assertEqual(saved[pilot]["equipment"], equipment) + + def test_corrupt_gate_save_preserved(self): + flat = {"parts": 23, "signal": "active", "progress": 7} + for invalid in (None, flat | {"korrath": flat}, {"parts": 12}, flat | {"progress": 8}, + flat | {"parts": True}, {"unknown": flat}, {"korrath": None}): + with self.subTest(invalid=invalid), tempfile.TemporaryDirectory() as directory: + root = Path(directory) + path, _, _, _ = self.journal_fixture(root) + data = json.loads(path.read_text()) + data["pilots"]["test"]["equipment"]["gates"] = invalid + path.write_text(json.dumps(data)) + before = {p.name: p.read_bytes() for p in root.iterdir()} + result = subprocess.run([sys.executable, pilots.__file__, str(root), "new", + str(root / "new.json")], capture_output=True) + self.assertNotEqual(result.returncode, 0) + self.assertEqual({p.name: p.read_bytes() for p in root.iterdir()}, before) + 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. @@ -101,10 +143,12 @@ def test_rollback_float_gate_counters_rotate_and_normalize(self): 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()) + # The flat single-gate record also migrates to the Vashar key. 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) + self.assertEqual(gates, {"vashar": {"parts": 20, "signal": "active", "progress": 7}}) + self.assertIs(type(gates["vashar"]["parts"]), int) + self.assertIs(type(gates["vashar"]["progress"]), int) + self.assertTrue(pilots.valid_gates({"korrath": {"parts": 24.0, "signal": "active", "progress": 9.0}})) 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) @@ -344,9 +388,12 @@ def test_extra_fitting_and_cargo(self): 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} + equipment["gates"] = {"vashar": {"parts": 20, "signal": "active", "progress": 7}, + "korrath": {"parts": 3, "signal": "active", "progress": 9}} self.assertTrue(pilots.valid_equipment(equipment)) - equipment["gates"] = {"parts": 20, "signal": "done", "progress": 1} + equipment["gates"] = {"vashar": {"parts": 20, "signal": "done", "progress": 1}} + self.assertFalse(pilots.valid_equipment(equipment)) + equipment["gates"] = {"unknown": {"parts": 1, "signal": "available", "progress": 0}} self.assertFalse(pilots.valid_equipment(equipment)) del equipment["gates"] equipment["items"]["ammo-cpu"]["ammo_type"] = "x4" diff --git a/tests/rpc_compatibility_test.gd b/tests/rpc_compatibility_test.gd index 9a0afbf..d4dc9f6 100644 --- a/tests/rpc_compatibility_test.gd +++ b/tests/rpc_compatibility_test.gd @@ -66,7 +66,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 == 21, "Profile revisions change the protocol fingerprint") + check(preview != server.session.protocol_fingerprint() and FlightSession.NETWORK_SCHEMA == 22, "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 736f401..22d0260 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() == 173, "All four rendered maps and the gate arena retain identical server obstacles") + check(client_obstacles == static_obstacles(authority) and client_obstacles.size() == 197, "All four rendered maps and both gate arenas 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") @@ -94,8 +94,8 @@ func check_campaign_backdrops() -> void: flight.player.map_id = map for destination: int in SectorMaps.links(map): flight.player.position = SectorMaps.gate_position(map, destination) - # 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") + # Gate arenas deliberately have no safe zone; every other gate protects pilots. + check(SectorMaps.protected(flight.player) != GalaxyGates.is_arena(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 diff --git a/tests/server_export_test.gd b/tests/server_export_test.gd index 48fd15c..8b0d852 100644 --- a/tests/server_export_test.gd +++ b/tests/server_export_test.gd @@ -35,8 +35,11 @@ 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() == 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") + check(colliders.size() == 197, "All 144 asteroids across four maps and two gate arenas, and 53 station colliders, survive export") + var arena_slots := 0 + for gate_id: String in GalaxyGates.ORDER: + arena_slots += GalaxyGates.pool_kinds(gate_id).size() + check(sector.world_aliens.size() == 20 + arena_slots and sector.map_rosters.size() == 4 + GalaxyGates.ORDER.size(), "All four map populations and the gate arena pools survive server export") for model: String in ShipCatalog.MODELS: var pilot := Pilot.new() pilot.render_enabled = false diff --git a/tools/pilots.py b/tools/pilots.py index 1665722..fc00be4 100644 --- a/tools/pilots.py +++ b/tools/pilots.py @@ -130,18 +130,30 @@ def whole(value: object, low: int, high: int) -> bool: 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)) +# Mirrors GalaxyGates in scripts/galaxy_gates.gd: per-gate progress with at most +# 999 parts and operation progress below each gate's requirement. +GATE_OPERATION_REQUIRED = {"vashar": 8, "korrath": 10} + +def gate_collection(data: object) -> object: + # The single-gate ledger stored this record directly in equipment.gates. + if isinstance(data, dict) and data.keys() == {"parts", "signal", "progress"}: + return {"vashar": data} + return data -def normalize_gates(equipment: dict) -> None: - if "gates" in equipment: - for field in ("parts", "progress"): - equipment["gates"][field] = int(equipment["gates"][field]) + +def valid_gates(data: object) -> bool: + data = gate_collection(data) + if not isinstance(data, dict): + return False + for gate, state in data.items(): + if (gate not in GATE_OPERATION_REQUIRED or not isinstance(state, dict) + or state.keys() != {"parts", "signal", "progress"} + or not whole(state["parts"], 0, 999) + or state["signal"] not in ("available", "active", "done") + or not whole(state["progress"], 0, GATE_OPERATION_REQUIRED[gate] - 1 if state["signal"] == "active" else 0)): + return False + return True def valid_cargo(data: object, equipment: dict) -> bool: @@ -378,7 +390,12 @@ 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"]) + equipment = record["equipment"] + if "gates" in equipment: + equipment["gates"] = gate_collection(equipment["gates"]) + for state in equipment["gates"].values(): + for field in ("parts", "progress"): + state[field] = int(state[field]) 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 c15de47..b535004 100644 --- a/tools/render_alien_preview.gd +++ b/tools/render_alien_preview.gd @@ -1,6 +1,7 @@ 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. +## -- --korrath limits the set to the Korrath Gate aliens. func _initialize() -> void: @@ -11,9 +12,12 @@ 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 korrath_view := "--korrath" 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() + kinds = GalaxyGates.info("vashar")["pool"].keys() + elif korrath_view: + kinds = GalaxyGates.info("korrath")["pool"].keys() if DisplayServer.get_name() == "headless": push_error("Alien review rendering requires a graphics display.") quit(1) @@ -72,6 +76,8 @@ func render_preview() -> void: filename = "outer-" + filename elif vashar_view: filename = "vashar-" + filename + elif korrath_view: + filename = "korrath-" + 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)