From f696286fdab96ccfc2bb4bddd8cc0ceda87309db Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 23 Jan 2024 15:16:37 -0500 Subject: Effects text is more prompt now Slowness and Iceland aren't forced to tick at the same time anymore. Puzzle skip popups show up instantly and disappear instantly. Puzzle skip popups do not show up for puzzles hidden behind walls (although you can still press p to skip). --- Archipelago/effects.gd | 112 ++++++++++++++++++++++++++++++------------------- Archipelago/load.gd | 9 ++++ 2 files changed, 79 insertions(+), 42 deletions(-) diff --git a/Archipelago/effects.gd b/Archipelago/effects.gd index ae134bc..e830fbc 100644 --- a/Archipelago/effects.gd +++ b/Archipelago/effects.gd @@ -9,11 +9,14 @@ var queued_iceland = 0 var skip_available = false var puzzle_focused = false var solve_mode = false +var not_behind_wall = false var puzzle_to_skip = "" +var text_dirty = true var orig_env var orig_walk var orig_run +var wallcast func _ready(): @@ -21,6 +24,8 @@ func _ready(): orig_walk = get_tree().get_root().get_node("Spatial/player").walk_speed orig_run = get_tree().get_root().get_node("Spatial/player").run_speed + wallcast = get_tree().get_root().get_node("Spatial/player/pivot/camera/wallcast") + var label = Label.new() label.set_name("label") label.margin_right = 1920.0 - 20.0 @@ -37,6 +42,18 @@ func _ready(): add_child(label) + var slowness_timer = Timer.new() + slowness_timer.name = "SlownessTimer" + slowness_timer.wait_time = 1.0 + add_child(slowness_timer) + slowness_timer.connect("timeout", self, "_tick_slowness") + + var iceland_timer = Timer.new() + iceland_timer.name = "IcelandTimer" + iceland_timer.wait_time = 1.0 + add_child(iceland_timer) + iceland_timer.connect("timeout", self, "_tick_iceland") + func activate(): activated = true @@ -53,10 +70,10 @@ func trigger_slowness_trap(): player.walk_speed = orig_walk / 2.0 player.run_speed = orig_run / 2.0 - slowness_remaining += 30 + $SlownessTimer.start() - if not effect_running: - _process_effects() + slowness_remaining += 30 + text_dirty = true func trigger_iceland_trap(): @@ -69,10 +86,10 @@ func trigger_iceland_trap(): load("res://environments/level_iceland.tres") ) - iceland_remaining += 60 + $IcelandTimer.start() - if not effect_running: - _process_effects() + iceland_remaining += 60 + text_dirty = true func trigger_atbash_trap(): @@ -82,8 +99,7 @@ func trigger_atbash_trap(): var apclient = global.get_node("Archipelago") apclient.evaluateSolvability() - if not effect_running: - _process_effects() + text_dirty = true func deactivate_atbash_trap(): @@ -93,6 +109,8 @@ func deactivate_atbash_trap(): var apclient = global.get_node("Archipelago") apclient.evaluateSolvability() + text_dirty = true + func show_puzzle_skip_message(node_path): var panel_input = get_tree().get_root().get_node(node_path) @@ -106,12 +124,15 @@ func show_puzzle_skip_message(node_path): return puzzle_focused = true + wallcast.enabled = true + not_behind_wall = false puzzle_to_skip = node_path _evaluate_puzzle_skip() func hide_puzzle_skip_message(): puzzle_focused = false + wallcast.enabled = false _evaluate_puzzle_skip() @@ -136,26 +157,49 @@ func skip_puzzle(): func _evaluate_puzzle_skip(): if puzzle_focused and not solve_mode: skip_available = true - - if not effect_running: - _process_effects() else: skip_available = false + text_dirty = true + +func _tick_slowness(): + slowness_remaining -= 1 + text_dirty = true + + if slowness_remaining == 0: + var player = get_tree().get_root().get_node("Spatial/player") + player.walk_speed = orig_walk + player.run_speed = orig_run + + $SlownessTimer.stop() + + +func _tick_iceland(): + iceland_remaining -= 1 + text_dirty = true + + if iceland_remaining == 0: + get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( + orig_env + ) -func _process_effects(): - effect_running = true + $IcelandTimer.stop() + + +func _process(_delta): + if puzzle_focused: + if wallcast.is_colliding(): + var should_nbw = (get_tree().get_root().get_node("Spatial/player")._get_panel_from_ray(wallcast) != null) + if should_nbw != not_behind_wall: + not_behind_wall = true + text_dirty = true + + if text_dirty: + text_dirty = false - 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: - if not text.empty(): - text += "\n" - text += "Press P to skip puzzle (%d available)" % apclient.getAvailablePuzzleSkips() if slowness_remaining > 0: if not text.empty(): text += "\n" @@ -164,26 +208,10 @@ func _process_effects(): if not text.empty(): text += "\n" text += "Iceland: %d seconds" % iceland_remaining + if skip_available and not_behind_wall: + var apclient = global.get_node("Archipelago") + if apclient.getAvailablePuzzleSkips() > 0: + if not text.empty(): + text += "\n" + text += "Press P to skip puzzle (%d available)" % apclient.getAvailablePuzzleSkips() self.get_node("label").text = text - - yield(get_tree().create_timer(1.0), "timeout") - - if !get_tree().paused: - if slowness_remaining > 0: - slowness_remaining -= 1 - - if slowness_remaining == 0: - var player = get_tree().get_root().get_node("Spatial/player") - player.walk_speed = orig_walk - player.run_speed = orig_run - - if iceland_remaining > 0: - iceland_remaining -= 1 - - if iceland_remaining == 0: - get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( - orig_env - ) - - self.get_node("label").text = "" - effect_running = false diff --git a/Archipelago/load.gd b/Archipelago/load.gd index afe304b..7f86c91 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -25,6 +25,15 @@ func _load(): var apclient = global.get_node("Archipelago") var panels_parent = self.get_node("Panels") + # Add a wall-blocked raycast to the player. + var wallcast = RayCast.new() + wallcast.name = "wallcast" + wallcast.cast_to = Vector3(0, 0, -15) + wallcast.set_collision_mask_bit(1, true) + wallcast.set_collision_mask_bit(3, true) + wallcast.collide_with_areas = true + $player/pivot/camera.add_child(wallcast) + # Override the YOU panel with the AP slot name. if self.get_node_or_null("Panels/Color Arrow Room/Panel_you") != null: self.get_node("Panels/Color Arrow Room/Panel_you").answer = apclient.ap_user -- cgit 1.4.1