From 17a51b95bd07c5291192ab6036550cb238c1ef4f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 28 Nov 2023 13:19:53 -0500 Subject: Add ghost multiplayer --- Archipelago/client.gd | 6 +++++- Archipelago/load.gd | 6 ++++++ Archipelago/multiplayer.gd | 20 ++++++++++++++++++++ Archipelago/settings_buttons.gd | 1 + Archipelago/settings_screen.gd | 6 +++--- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 Archipelago/multiplayer.gd (limited to 'Archipelago') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 96e6d41..cdae2d8 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -3,6 +3,7 @@ extends Node var SCRIPT_doorControl var SCRIPT_effects var SCRIPT_location +var SCRIPT_multiplayer var SCRIPT_mypainting var SCRIPT_notifier var SCRIPT_panel @@ -12,6 +13,7 @@ var ap_server = "" var ap_user = "" var ap_pass = "" var confusify_world = false +var enable_multiplayer = false const my_version = "0.15.1" const ap_version = {"major": 0, "minor": 4, "build": 0, "class": "Version"} @@ -137,6 +139,8 @@ func _init(): _datapackages = data[3] if data.size() > 4: confusify_world = data[4] + if data.size() > 5: + enable_multiplayer = data[5] processDatapackages() @@ -431,7 +435,7 @@ func saveSettings(): var file = File.new() file.open("user://settings/archipelago", File.WRITE) - var data = [ap_server, ap_user, ap_pass, _datapackages, confusify_world] + var data = [ap_server, ap_user, ap_pass, _datapackages, confusify_world, enable_multiplayer] file.store_var(data, true) file.close() diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 550ae1f..f536352 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -471,6 +471,12 @@ func _load(): effects.set_name("AP_Effects") self.add_child(effects) + # Create the multiplayer node, if needed. + if apclient.enable_multiplayer: + var multiplayer_node = apclient.SCRIPT_multiplayer.new() + multiplayer_node.ghost_mode = true + add_child(multiplayer_node) + # Hook up the scene to be able to handle connection failures. apclient.connect("could_not_connect", self, "archipelago_disconnected") diff --git a/Archipelago/multiplayer.gd b/Archipelago/multiplayer.gd new file mode 100644 index 0000000..07b63b8 --- /dev/null +++ b/Archipelago/multiplayer.gd @@ -0,0 +1,20 @@ +extends "res://scripts/multiplayer.gd" + + +func _request_lobby_list(): + var apclient = global.get_node("Archipelago") + Steam.addRequestLobbyListStringFilter( + "archipelago", apclient._seed, Steam.LOBBY_COMPARISON_EQUAL + ) + + ._request_lobby_list() + + +func _on_lobby_created(result: int, lobby_id: int) -> void: + if result != Steam.RESULT_OK: + return + + var apclient = global.get_node("Archipelago") + var _ignore = Steam.setLobbyData(lobby_id, "archipelago", apclient._seed) + + ._on_lobby_created(result, lobby_id) diff --git a/Archipelago/settings_buttons.gd b/Archipelago/settings_buttons.gd index a6bba2a..e9cff9d 100644 --- a/Archipelago/settings_buttons.gd +++ b/Archipelago/settings_buttons.gd @@ -13,6 +13,7 @@ func _connect_pressed(): apclient.ap_user = self.get_parent().get_node("player_box").text apclient.ap_pass = self.get_parent().get_node("password_box").text apclient.confusify_world = self.get_parent().get_node("confusing_box").pressed + apclient.enable_multiplayer = self.get_parent().get_node("multiplayer_box").pressed apclient.saveSettings() apclient.connectToServer() diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index a3305e5..8a81c4d 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd @@ -20,6 +20,7 @@ func _ready(): apclient_instance.SCRIPT_doorControl = load("user://maps/Archipelago/doorControl.gd") apclient_instance.SCRIPT_effects = load("user://maps/Archipelago/effects.gd") apclient_instance.SCRIPT_location = load("user://maps/Archipelago/location.gd") + apclient_instance.SCRIPT_multiplayer = load("user://maps/Archipelago/multiplayer.gd") apclient_instance.SCRIPT_mypainting = load("user://maps/Archipelago/mypainting.gd") apclient_instance.SCRIPT_notifier = load("user://maps/Archipelago/notifier.gd") apclient_instance.SCRIPT_panel = load("user://maps/Archipelago/panel.gd") @@ -52,6 +53,7 @@ func _ready(): self.get_node("Panel/player_box").text = apclient.ap_user self.get_node("Panel/password_box").text = apclient.ap_pass self.get_node("Panel/confusing_box").pressed = apclient.confusify_world + self.get_node("Panel/multiplayer_box").pressed = apclient.enable_multiplayer # Show client version. self.get_node("Panel/title").text = "ARCHIPELAGO (%s)" % apclient.my_version @@ -79,9 +81,7 @@ func installScriptExtension(childScript: Resource): var parentScript = childScript.get_base_script() var parentScriptPath = parentScript.resource_path - global._print( - "ModLoader: Installing script extension over %s" % parentScriptPath - ) + global._print("ModLoader: Installing script extension over %s" % parentScriptPath) childScript.take_over_path(parentScriptPath) -- cgit 1.4.1