From e448f5b318f05cae1b40a949e11ef2d7fb613645 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 15 Apr 2024 11:39:52 -0400 Subject: Implemented panels mode door shuffle --- Archipelago/load.gd | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Archipelago/load.gd') diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 566ee39..82f8e94 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -568,6 +568,8 @@ func _load(): var script_instance = panel_script.new() script_instance.name = "AP_Panel" script_instance.data = panel + if apclient._panel_door_shuffle and gamedata.mentioned_panels.has(panel["id"]): + script_instance.locked = true panel_node.add_child(script_instance) apclient.connect("evaluate_solvability", script_instance, "evaluate_solvability") -- cgit 1.4.1 From 400ad1ed74166d3f01adf6d97f07a16ec391f2a9 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 2 Sep 2024 11:49:12 -0400 Subject: Added text client --- Archipelago/client.gd | 44 +++++++++++++++++++++ Archipelago/load.gd | 6 +++ Archipelago/pause_menu.gd | 5 +++ Archipelago/settings_screen.gd | 1 + Archipelago/textclient.gd | 88 ++++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++ 6 files changed, 147 insertions(+) create mode 100644 Archipelago/textclient.gd (limited to 'Archipelago/load.gd') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index aa50069..f58b3d6 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -8,6 +8,7 @@ var SCRIPT_mypainting var SCRIPT_notifier var SCRIPT_panel var SCRIPT_pilgrimage_terminator +var SCRIPT_textclient var SCRIPT_uuid var ap_server = "" @@ -451,6 +452,8 @@ func _on_data(): i += 1 elif cmd == "PrintJSON": + parse_printjson(message) + if ( !message.has("receiving") or !message.has("item") @@ -684,6 +687,10 @@ func setValue(key, value, operation = "replace"): ) +func say(textdata): + sendMessage([{"cmd": "Say", "text": textdata}]) + + func completedGoal(): sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL @@ -855,6 +862,43 @@ func colorForItemType(flags): return "#14de9e" +func parse_printjson(message): + var parts = [] + for message_part in message["data"]: + if !message_part.has("type") and message_part.has("text"): + parts.append(message_part["text"]) + elif message_part["type"] == "player_id": + if int(message_part["text"]) == _slot: + parts.append("[color=#ee00ee]%s[/color]" % _player_name_by_slot[_slot]) + else: + var from = float(message_part["text"]) + parts.append("[color=#fafad2]%s[/color]" % _player_name_by_slot[from]) + elif message_part["type"] == "item_id": + var item_name = "Unknown" + var item_player_game = _game_by_player[message_part["player"]] + if _item_id_to_name[item_player_game].has(float(message_part["text"])): + item_name = _item_id_to_name[item_player_game][float(message_part["text"])] + + parts.append( + "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name] + ) + elif message_part["type"] == "location_id": + var location_name = "Unknown" + var location_player_game = _game_by_player[message_part["player"]] + if _location_id_to_name[location_player_game].has(float(message_part["text"])): + location_name = _location_id_to_name[location_player_game][float( + message_part["text"] + )] + + parts.append("[color=#00ff7f]%s[/color]" % location_name) + elif message_part.has("text"): + parts.append(message_part["text"]) + + var textclient_node = get_tree().get_root().get_node_or_null("Spatial/AP_TextClient") + if textclient_node != null: + textclient_node.parse_printjson("".join(parts)) + + func compareVersion(lhs, rhs): if lhs["major"] == rhs["major"]: if lhs["minor"] == rhs["minor"]: diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 931dfde..c35525b 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -663,6 +663,12 @@ func _load(): effects.set_name("AP_Effects") self.add_child(effects) + # Create the textclient node. + var textclient_script = apclient.SCRIPT_textclient + var textclient = textclient_script.new() + textclient.set_name("AP_TextClient") + self.add_child(textclient) + # Create the multiplayer node, if needed. if apclient.enable_multiplayer: var multiplayer_node = apclient.SCRIPT_multiplayer.new() diff --git a/Archipelago/pause_menu.gd b/Archipelago/pause_menu.gd index 40994d9..62ba6c3 100644 --- a/Archipelago/pause_menu.gd +++ b/Archipelago/pause_menu.gd @@ -6,3 +6,8 @@ func _main_menu(): apclient.disconnect_from_ap() ._main_menu() + + +func _pause_game(): + get_tree().get_root().get_node("Spatial/AP_TextClient").dismiss() + ._pause_game() diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 6c64b15..2ed8594 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd @@ -32,6 +32,7 @@ func _ready(): apclient_instance.SCRIPT_panel = load("user://maps/Archipelago/panel.gd") var pilg_term = load("user://maps/Archipelago/pilgrimage_terminator.gd") apclient_instance.SCRIPT_pilgrimage_terminator = pilg_term + apclient_instance.SCRIPT_textclient = load("user://maps/Archipelago/textclient.gd") apclient_instance.SCRIPT_uuid = load("user://maps/Archipelago/vendor/uuid.gd") var apdata = ResourceLoader.load("user://maps/Archipelago/gamedata.gd") diff --git a/Archipelago/textclient.gd b/Archipelago/textclient.gd new file mode 100644 index 0000000..7bddf38 --- /dev/null +++ b/Archipelago/textclient.gd @@ -0,0 +1,88 @@ +extends Node + +var panel +var label +var entry +var is_open = false + + +func _ready(): + pause_mode = PAUSE_MODE_PROCESS + + panel = Panel.new() + panel.set_name("Panel") + panel.margin_left = 100 + panel.margin_right = 1820 + panel.margin_top = 100 + panel.margin_bottom = 980 + panel.visible = false + add_child(panel) + + label = RichTextLabel.new() + label.set_name("Label") + label.margin_left = 80 + label.margin_right = 1640 + label.margin_top = 80 + label.margin_bottom = 720 + label.scroll_following = true + panel.add_child(label) + + var dynamic_font = DynamicFont.new() + dynamic_font.font_data = load("res://fonts/Lingo.ttf") + dynamic_font.size = 36 + label.push_font(dynamic_font) + + var entry_style = StyleBoxFlat.new() + entry_style.bg_color = Color(0.9, 0.9, 0.9, 1) + + entry = LineEdit.new() + entry.set_name("Entry") + entry.margin_left = 80 + entry.margin_right = 1640 + entry.margin_top = 760 + entry.margin_bottom = 840 + entry.add_font_override("font", dynamic_font) + entry.add_color_override("font_color", Color(0, 0, 0, 1)) + entry.add_color_override("cursor_color", Color(0, 0, 0, 1)) + entry.add_stylebox_override("focus", entry_style) + panel.add_child(entry) + entry.connect("text_entered", self, "text_entered") + + +func _input(event): + if event is InputEventKey and event.pressed: + if event.scancode == KEY_TAB: + if !get_tree().paused: + is_open = true + get_tree().paused = true + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + panel.visible = true + entry.grab_focus() + get_tree().set_input_as_handled() + else: + dismiss() + elif event.scancode == KEY_ESCAPE: + if is_open: + dismiss() + get_tree().set_input_as_handled() + + +func dismiss(): + if is_open: + get_tree().paused = false + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + panel.visible = false + is_open = false + + +func parse_printjson(text): + if !label.text.empty(): + label.append_bbcode("\n") + + label.append_bbcode(text) + + +func text_entered(text): + var apclient = global.get_node("Archipelago") + apclient.say(text.trim_suffix("\n")) + entry.text = "" diff --git a/README.md b/README.md index a242f95..a8491d6 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ pick and choose which ones you would like to use. the numbering can change. You can also specify whether access to the sunwarps should be locked behind receiving certain items. +There is also a built-in text client you can use to talk to other players and +issue commands. You can open and close it by pressing tab. + ## Frequently Asked Questions ### What are location checks in this game? -- cgit 1.4.1 From e92ae750012d37733ef803e882eb8191ad530e11 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 20 Sep 2024 21:29:42 -0400 Subject: Added proximity chat --- Archipelago/client.gd | 4 ++++ Archipelago/load.gd | 1 + Archipelago/multiplayer.gd | 55 ++++++++++++++++++++++++++++++++++++++++++++++ Archipelago/textclient.gd | 13 ++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-) (limited to 'Archipelago/load.gd') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 6621194..a636bec 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -912,6 +912,10 @@ func parse_printjson(message): textclient_node.parse_printjson("".join(parts)) +func get_player_name(): + return _player_name_by_slot[_slot] + + func compareVersion(lhs, rhs): if lhs["major"] == rhs["major"]: if lhs["minor"] == rhs["minor"]: diff --git a/Archipelago/load.gd b/Archipelago/load.gd index c35525b..09aaee2 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -672,6 +672,7 @@ func _load(): # Create the multiplayer node, if needed. if apclient.enable_multiplayer: var multiplayer_node = apclient.SCRIPT_multiplayer.new() + multiplayer_node.name = "Multiplayer" multiplayer_node.ghost_mode = true add_child(multiplayer_node) diff --git a/Archipelago/multiplayer.gd b/Archipelago/multiplayer.gd index 0bc2241..c2d9875 100644 --- a/Archipelago/multiplayer.gd +++ b/Archipelago/multiplayer.gd @@ -1,5 +1,8 @@ extends "res://scripts/multiplayer.gd" +var queued_messages = [] +var queued_messages_mutex = Mutex.new() + func _request_lobby_list(): var apclient = global.get_node("Archipelago") @@ -41,3 +44,55 @@ func _update_lobby_members(): if member_id != player_steam_id and member_id in active_lobby_members: var slot_name = Steam.getLobbyMemberData(active_lobby_id, member_id, "slot_name") active_lobby_members[member_id].steam_name = slot_name + + +func say(text): + queued_messages_mutex.lock() + queued_messages.append(text) + queued_messages_mutex.unlock() + + +func _physics_process(_delta): + if queued_messages_mutex.try_lock() == OK: + if queued_messages.empty(): + queued_messages_mutex.unlock() + else: + var messages = queued_messages.duplicate() + queued_messages = [] + queued_messages_mutex.unlock() + + var player = get_tree().get_root().get_node("Spatial/player") + var space_state = get_tree().get_root().get_world().direct_space_state + var nearby_members = [] + for member_id in active_lobby_members.keys(): + var other_member = active_lobby_members[member_id] + var ray = space_state.intersect_ray( + player.global_translation, other_member.global_translation, [player], 0b0101 + ) + if !("collider" in ray) or ray["collider"] == other_member: + # Visible! + nearby_members.append(member_id) + + var apclient = global.get_node("Archipelago") + var player_name = apclient.get_player_name() + for member_id in nearby_members: + for msg in messages: + _send_p2p_packet( + {"solves": [{"say": msg, "from": player_name}]}, + member_id, + Steam.P2P_SEND_RELIABLE, + true + ) + + +# I'm completely hijacking this callback, since we're in ghost mode and it won't be called normally. +func _receive_solve(data): + if "say" in data: + get_tree().get_root().get_node("Spatial/AP_TextClient").parse_printjson( + "[LOCAL] [color=#fafad2]%s[/color]: %s" % [data["from"], data["say"]] + ) + messages.showMessage("[color=#fafad2]%s[/color]: %s" % [data["from"], data["say"]]) + + +func _send_hi(_discard): + pass diff --git a/Archipelago/textclient.gd b/Archipelago/textclient.gd index 7bddf38..f100776 100644 --- a/Archipelago/textclient.gd +++ b/Archipelago/textclient.gd @@ -84,5 +84,16 @@ func parse_printjson(text): func text_entered(text): var apclient = global.get_node("Archipelago") - apclient.say(text.trim_suffix("\n")) + var cmd = text.trim_suffix("\n") + if cmd.begins_with("/say "): + if apclient.enable_multiplayer: + var msg = cmd.trim_prefix("/say ") + parse_printjson( + "[LOCAL] [color=#ee00ee]%s[/color]: %s" % [apclient.get_player_name(), msg] + ) + get_tree().get_root().get_node("Spatial/Multiplayer").say(msg) + else: + parse_printjson("Multiplayer must be enabled to use /say") + else: + apclient.say(cmd) entry.text = "" -- cgit 1.4.1 From 84f4fc2db8b7ada36faa5341cb7bee17750f1a07 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 8 Dec 2024 16:14:53 -0500 Subject: Add workaround for 0.5.1 number hunt logic bug --- Archipelago/client.gd | 16 ++++++++- Archipelago/extradata.gd | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ Archipelago/load.gd | 14 ++++++++ 3 files changed, 113 insertions(+), 1 deletion(-) (limited to 'Archipelago/load.gd') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 8f9d3e0..99be37a 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -779,8 +779,14 @@ func processItem(item, index, from, flags): doorsNode.get_node(door_id).openDoor() if gamedata.panel_ids_by_item_id.has(int(item)): + var panel_ids = gamedata.panel_ids_by_item_id[int(item)] + if wasGeneratedOnVersion(0, 5, 1): + var extradata = get_node("Extradata") + if extradata.panels_mode_051_panel_fixes.has(int(item)): + panel_ids = extradata.panels_mode_051_panel_fixes[int(item)] + var panelsNode = get_tree().get_root().get_node("Spatial/Panels") - for panel_id in gamedata.panel_ids_by_item_id[int(item)]: + for panel_id in panel_ids: panelsNode.get_node(panel_id).get_node("AP_Panel").locked = false emit_signal("evaluate_solvability") @@ -990,3 +996,11 @@ func compareVersion(lhs, rhs): func wasGeneratedBeforeVersion(major, minor, build): return compareVersion(_gen_version, {"major": major, "minor": minor, "build": build}) + + +func wasGeneratedOnVersion(major, minor, build): + return ( + _gen_version["major"] == major + and _gen_version["minor"] == minor + and _gen_version["build"] == build + ) diff --git a/Archipelago/extradata.gd b/Archipelago/extradata.gd index 89c41d2..2e26eb2 100644 --- a/Archipelago/extradata.gd +++ b/Archipelago/extradata.gd @@ -93,3 +93,87 @@ var proxies = { "Open Areas/Panel_rise_horizon": ["Open Areas/Panel_son_horizon"], "Open Areas/Panel_son_sunrise": ["Open Areas/Panel_rise_sunrise"] } + +var panels_mode_051_panel_fixes = { + 444647: + [ + "Backside Room/Panel_three_three", + "Backside Room/Panel_three_three_2", + "Backside Room/Panel_three_three_3", + "Backside Room/Panel_four_four_3", + "Backside Room/Panel_four_four_2", + "Backside Room/Panel_four_four_4" + ], + 444648: + [ + "Backside Room/Panel_four_four", + "Backside Room/Panel_five_five_5", + "Backside Room/Panel_five_five_4" + ], + 444649: + [ + "Backside Room/Panel_five_five", + "Backside Room/Panel_five_five_3", + "Backside Room/Panel_five_five_2", + "Backside Room/Panel_six_six_4" + ], + 444650: + [ + "Backside Room/Panel_six_six", + "Backside Room/Panel_six_six_3", + "Backside Room/Panel_six_six_2", + "Backside Room/Panel_six_six_5", + "Backside Room/Panel_six_six_6", + "Backside Room/Panel_seven_seven_5", + "Backside Room/Panel_seven_seven_6" + ], + 444651: + [ + "Backside Room/Panel_seven_seven", + "Backside Room/Panel_seven_seven_2", + "Backside Room/Panel_seven_seven_7", + "Backside Room/Panel_seven_seven_3", + "Backside Room/Panel_seven_seven_4", + "Backside Room/Panel_eight_eight_8", + "Backside Room/Panel_eight_eight_5", + "Backside Room/Panel_eight_eight_3", + "Backside Room/Panel_eight_eight_7" + ], + 444652: + [ + "Backside Room/Panel_eight_eight", + "Backside Room/Panel_eight_eight_2", + "Backside Room/Panel_eight_eight_4", + "Backside Room/Panel_eight_eight_6", + "Backside Room/Panel_nine_nine_3", + "Backside Room/Panel_nine_nine_8", + "Backside Room/Panel_nine_nine_4", + "Backside Room/Panel_nine_nine_5", + "Backside Room/Panel_nine_nine_2" + ], + 444653: + [ + "Backside Room/Panel_nine_nine", + "Backside Room/Panel_nine_nine_6", + "Backside Room/Panel_nine_nine_8", + "Backside Room/Panel_nine_nine_9", + "Backside Room/Panel_nine_nine_7" + ] +} + +var panels_mode_051_door_fixes = { + "Door_four_hider": ["Door_four_hider_3", "Door_four_hider_4", "Door_four_hider_2"], + "Door_five_hider": ["Door_five_hider_4", "Door_five_hider_5"], + "Door_six_hider": ["Door_six_hider_4"], + "Door_seven_hider": ["Door_seven_hider_6", "Door_seven_hider_5"], + "Door_eight_hider": + ["Door_eight_hider_7", "Door_eight_hider_8", "Door_eight_hider_3", "Door_eight_hider_5"], + "Door_nine_hider": + [ + "Door_nine_hider_3", + "Door_nine_hider_8", + "Door_nine_hider_4", + "Door_nine_hider_5", + "Door_nine_hider_2" + ] +} diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 4811b47..e593548 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -551,6 +551,20 @@ func _load(): proxynode.exact_proxy = true proxynode.request_ready() oldparent.add_child(proxynode) + + # If the world was generated on 0.5.1, apply the hotfix for the number hunt doors. + if apclient.wasGeneratedOnVersion(0, 5, 1): + var number_hunt_parent = get_node("Doors/Count Up Room Area Doors") + var extradata_051_fix = apclient.get_node("Extradata").panels_mode_051_door_fixes + for template_door_path in extradata_051_fix: + var template_door = number_hunt_parent.get_node(template_door_path) + var impacted_doors = extradata_051_fix[template_door_path] + for impacted_door_path in impacted_doors: + var impacted_door = number_hunt_parent.get_node(impacted_door_path) + var copied_door = impacted_door.duplicate() + copied_door.panels = template_door.panels + number_hunt_parent.add_child(copied_door) + impacted_door.queue_free() # Attach a script to every panel so that we can do things like conditionally # disable them. -- cgit 1.4.1 From 7d158c97ca10e815c8344dca801d0eba307dff57 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 8 Dec 2024 16:46:42 -0500 Subject: The workaround should only be on PMDS --- Archipelago/load.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Archipelago/load.gd') diff --git a/Archipelago/load.gd b/Archipelago/load.gd index e593548..651fc39 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -553,7 +553,7 @@ func _load(): oldparent.add_child(proxynode) # If the world was generated on 0.5.1, apply the hotfix for the number hunt doors. - if apclient.wasGeneratedOnVersion(0, 5, 1): + if apclient._panel_door_shuffle && apclient.wasGeneratedOnVersion(0, 5, 1): var number_hunt_parent = get_node("Doors/Count Up Room Area Doors") var extradata_051_fix = apclient.get_node("Extradata").panels_mode_051_door_fixes for template_door_path in extradata_051_fix: -- cgit 1.4.1