From a3cc416a21297747b412dabe75fc4532cd5c8d68 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 3 Aug 2023 21:57:04 -0400 Subject: Puzzle skips --- Archipelago/client.gd | 12 +++++++++ Archipelago/effects.gd | 59 +++++++++++++++++++++++++++++++++++++++++- Archipelago/panel.gd | 3 ++- Archipelago/panelInput.gd | 21 +++++++++++++++ Archipelago/player.gd | 24 +++++++++++++++++ Archipelago/settings_screen.gd | 1 + 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 Archipelago/player.gd diff --git a/Archipelago/client.gd b/Archipelago/client.gd index e3b2c89..f0a4d2e 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -92,6 +92,7 @@ var _last_new_item = -1 var _progressive_progress = {} var _has_colors = ["white"] var _received_indexes = [] +var _puzzle_skips = 0 signal could_not_connect signal connect_status @@ -539,6 +540,7 @@ func mapFinishedLoading(): _received_indexes.clear() _progressive_progress.clear() _has_colors = ["white"] + _puzzle_skips = 0 emit_signal("evaluate_solvability") for item in _held_items: @@ -632,6 +634,8 @@ func processItem(item, index, from, flags): effects_node.trigger_iceland_trap() if item_name == "Atbash Trap": effects_node.trigger_atbash_trap() + if item_name == "Puzzle Skip": + _puzzle_skips += 1 func doorIsVanilla(door): @@ -646,6 +650,14 @@ func evaluateSolvability(): emit_signal("evaluate_solvability") +func getAvailablePuzzleSkips(): + return _puzzle_skips + + +func usePuzzleSkip(): + _puzzle_skips -= 1 + + func colorForItemType(flags): var int_flags = int(flags) if int_flags & 1: # progression diff --git a/Archipelago/effects.gd b/Archipelago/effects.gd index 80eaa9c..3d6e036 100644 --- a/Archipelago/effects.gd +++ b/Archipelago/effects.gd @@ -6,6 +6,10 @@ var slowness_remaining = 0 var iceland_remaining = 0 var atbash_activated = false var queued_iceland = 0 +var skip_available = false +var puzzle_focused = false +var solve_mode = false +var puzzle_to_skip = "" var orig_env var orig_walk @@ -90,13 +94,66 @@ func deactivate_atbash_trap(): apclient.evaluateSolvability() +func show_puzzle_skip_message(node_path): + var panel_input = get_tree().get_root().get_node(node_path) + if not panel_input.visible: + return + + var ap_panel = panel_input.get_parent().get_parent().get_parent().get_parent().get_node( + "AP_Panel" + ) + if not ap_panel.solvable: + return + + puzzle_focused = true + puzzle_to_skip = node_path + _evaluate_puzzle_skip() + + +func hide_puzzle_skip_message(): + puzzle_focused = false + _evaluate_puzzle_skip() + + +func enter_solve_mode(): + solve_mode = true + _evaluate_puzzle_skip() + + +func exit_solve_mode(): + solve_mode = false + _evaluate_puzzle_skip() + + +func skip_puzzle(): + if not solve_mode and puzzle_focused: + var apclient = global.get_node("Archipelago") + if apclient.getAvailablePuzzleSkips() > 0: + apclient.usePuzzleSkip() + get_tree().get_root().get_node(puzzle_to_skip).complete() + + +func _evaluate_puzzle_skip(): + if puzzle_focused and not solve_mode: + skip_available = true + + if not effect_running: + _process_effects() + else: + skip_available = false + + func _process_effects(): effect_running = true - while slowness_remaining > 0 or iceland_remaining > 0 or atbash_activated: + while slowness_remaining > 0 or iceland_remaining > 0 or atbash_activated or skip_available: var text = "" if atbash_activated: text += "Atbash Trap lasts until you solve a puzzle" + if skip_available: + var apclient = global.get_node("Archipelago") + if apclient.getAvailablePuzzleSkips() > 0: + text += "Press P to skip puzzle (%d available)" % apclient.getAvailablePuzzleSkips() if slowness_remaining > 0: if not text.empty(): text += "\n" diff --git a/Archipelago/panel.gd b/Archipelago/panel.gd index da11ddd..da5b572 100644 --- a/Archipelago/panel.gd +++ b/Archipelago/panel.gd @@ -4,6 +4,7 @@ var data = {} var orig_text = "" var atbash_text = "" var orig_color = Color(0, 0, 0, 0) +var solvable = true const kAtbashPre = "abcdefghijklmnopqrstuvwxyz1234567890+-" const kAtbashPost = "zyxwvutsrqponmlkjihgfedcba0987654321-+" @@ -35,7 +36,7 @@ func evaluate_solvability(): var apclient = global.get_node("Archipelago") var effects = get_tree().get_root().get_node("Spatial/AP_Effects") - var solvable = true + solvable = true var missing = [] if apclient._color_shuffle: diff --git a/Archipelago/panelInput.gd b/Archipelago/panelInput.gd index 48d6324..346dccb 100644 --- a/Archipelago/panelInput.gd +++ b/Archipelago/panelInput.gd @@ -3,3 +3,24 @@ extends "res://scripts/panelInput.gd" func uncomplete(): global._print("Filtered out panel uncompletion") + + +func grab_focus(): + .grab_focus() + + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.show_puzzle_skip_message(get_path()) + + +func release_focus(): + .release_focus() + + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.hide_puzzle_skip_message() + + +func complete(): + .complete() + + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.hide_puzzle_skip_message() diff --git a/Archipelago/player.gd b/Archipelago/player.gd new file mode 100644 index 0000000..87d9d0c --- /dev/null +++ b/Archipelago/player.gd @@ -0,0 +1,24 @@ +extends "res://scripts/player.gd" + + +func _solving(): + ._solving() + + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.enter_solve_mode() + + +func _solvingEnd(): + ._solvingEnd() + + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.exit_solve_mode() + + +func _unhandled_input(event): + ._unhandled_input(event) + + if event is InputEventKey: + if event.pressed and event.scancode == KEY_P: + var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") + effects_node.skip_puzzle() diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 130506b..3f56962 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd @@ -31,6 +31,7 @@ func _ready(): installScriptExtension("user://maps/Archipelago/panelEnd.gd") installScriptExtension("user://maps/Archipelago/panelInput.gd") installScriptExtension("user://maps/Archipelago/pause_menu.gd") + installScriptExtension("user://maps/Archipelago/player.gd") installScriptExtension("user://maps/Archipelago/worldTransporter.gd") var apclient = global.get_node("Archipelago") -- cgit 1.4.1