diff options
Diffstat (limited to 'Archipelago/effects.gd')
-rw-r--r-- | Archipelago/effects.gd | 173 |
1 files changed, 118 insertions, 55 deletions
diff --git a/Archipelago/effects.gd b/Archipelago/effects.gd index ae134bc..1e2e311 100644 --- a/Archipelago/effects.gd +++ b/Archipelago/effects.gd | |||
@@ -4,16 +4,19 @@ var activated = false | |||
4 | var effect_running = false | 4 | var effect_running = false |
5 | var slowness_remaining = 0 | 5 | var slowness_remaining = 0 |
6 | var iceland_remaining = 0 | 6 | var iceland_remaining = 0 |
7 | var atbash_activated = false | 7 | var atbash_remaining = 0 |
8 | var queued_iceland = 0 | 8 | var queued_iceland = 0 |
9 | var skip_available = false | 9 | var skip_available = false |
10 | var puzzle_focused = false | 10 | var puzzle_focused = false |
11 | var solve_mode = false | 11 | var solve_mode = false |
12 | var not_behind_wall = false | ||
12 | var puzzle_to_skip = "" | 13 | var puzzle_to_skip = "" |
14 | var text_dirty = true | ||
13 | 15 | ||
14 | var orig_env | 16 | var orig_env |
15 | var orig_walk | 17 | var orig_walk |
16 | var orig_run | 18 | var orig_run |
19 | var wallcast | ||
17 | 20 | ||
18 | 21 | ||
19 | func _ready(): | 22 | func _ready(): |
@@ -21,6 +24,8 @@ func _ready(): | |||
21 | orig_walk = get_tree().get_root().get_node("Spatial/player").walk_speed | 24 | orig_walk = get_tree().get_root().get_node("Spatial/player").walk_speed |
22 | orig_run = get_tree().get_root().get_node("Spatial/player").run_speed | 25 | orig_run = get_tree().get_root().get_node("Spatial/player").run_speed |
23 | 26 | ||
27 | wallcast = get_tree().get_root().get_node("Spatial/player/pivot/camera/wallcast") | ||
28 | |||
24 | var label = Label.new() | 29 | var label = Label.new() |
25 | label.set_name("label") | 30 | label.set_name("label") |
26 | label.margin_right = 1920.0 - 20.0 | 31 | label.margin_right = 1920.0 - 20.0 |
@@ -37,31 +42,46 @@ func _ready(): | |||
37 | 42 | ||
38 | add_child(label) | 43 | add_child(label) |
39 | 44 | ||
45 | var slowness_timer = Timer.new() | ||
46 | slowness_timer.name = "SlownessTimer" | ||
47 | slowness_timer.wait_time = 1.0 | ||
48 | add_child(slowness_timer) | ||
49 | slowness_timer.connect("timeout", self, "_tick_slowness") | ||
50 | |||
51 | var iceland_timer = Timer.new() | ||
52 | iceland_timer.name = "IcelandTimer" | ||
53 | iceland_timer.wait_time = 1.0 | ||
54 | add_child(iceland_timer) | ||
55 | iceland_timer.connect("timeout", self, "_tick_iceland") | ||
56 | |||
40 | 57 | ||
41 | func activate(): | 58 | func activate(): |
42 | activated = true | 59 | activated = true |
43 | 60 | ||
44 | for _i in range(0, queued_iceland): | 61 | if queued_iceland > 0: |
45 | trigger_iceland_trap() | 62 | trigger_iceland_trap(queued_iceland) |
46 | 63 | ||
47 | queued_iceland = 0 | 64 | queued_iceland = 0 |
48 | 65 | ||
49 | 66 | ||
50 | func trigger_slowness_trap(): | 67 | func trigger_slowness_trap(length = 30): |
51 | if slowness_remaining == 0: | 68 | if slowness_remaining == 0: |
52 | var player = get_tree().get_root().get_node("Spatial/player") | 69 | var player = get_tree().get_root().get_node("Spatial/player") |
53 | player.walk_speed = orig_walk / 2.0 | 70 | player.walk_speed = orig_walk / 2.0 |
54 | player.run_speed = orig_run / 2.0 | 71 | player.run_speed = orig_run / 2.0 |
55 | 72 | ||
56 | slowness_remaining += 30 | 73 | $SlownessTimer.start() |
57 | 74 | ||
58 | if not effect_running: | 75 | slowness_remaining += length |
59 | _process_effects() | 76 | text_dirty = true |
60 | 77 | ||
78 | var apclient = global.get_node("Archipelago") | ||
79 | apclient.saveLocaldata() | ||
61 | 80 | ||
62 | func trigger_iceland_trap(): | 81 | |
82 | func trigger_iceland_trap(length = 60): | ||
63 | if not activated: | 83 | if not activated: |
64 | queued_iceland += 1 | 84 | queued_iceland += length |
65 | return | 85 | return |
66 | 86 | ||
67 | if iceland_remaining == 0: | 87 | if iceland_remaining == 0: |
@@ -69,32 +89,47 @@ func trigger_iceland_trap(): | |||
69 | load("res://environments/level_iceland.tres") | 89 | load("res://environments/level_iceland.tres") |
70 | ) | 90 | ) |
71 | 91 | ||
72 | iceland_remaining += 60 | 92 | $IcelandTimer.start() |
93 | |||
94 | iceland_remaining += length | ||
95 | text_dirty = true | ||
73 | 96 | ||
74 | if not effect_running: | 97 | var apclient = global.get_node("Archipelago") |
75 | _process_effects() | 98 | apclient.saveLocaldata() |
76 | 99 | ||
77 | 100 | ||
78 | func trigger_atbash_trap(): | 101 | func trigger_atbash_trap(): |
79 | if not atbash_activated: | 102 | var newly_atbash = (atbash_remaining == 0) |
80 | atbash_activated = true | 103 | atbash_remaining += 1 |
81 | 104 | ||
105 | if newly_atbash: | ||
82 | var apclient = global.get_node("Archipelago") | 106 | var apclient = global.get_node("Archipelago") |
83 | apclient.evaluateSolvability() | 107 | apclient.evaluateSolvability() |
84 | 108 | ||
85 | if not effect_running: | 109 | text_dirty = true |
86 | _process_effects() | 110 | |
111 | var apclient = global.get_node("Archipelago") | ||
112 | apclient.saveLocaldata() | ||
87 | 113 | ||
88 | 114 | ||
89 | func deactivate_atbash_trap(): | 115 | func deactivate_atbash_trap(): |
90 | if atbash_activated: | 116 | if atbash_remaining > 0: |
91 | atbash_activated = false | 117 | atbash_remaining -= 1 |
92 | 118 | ||
93 | var apclient = global.get_node("Archipelago") | 119 | if atbash_remaining == 0: |
94 | apclient.evaluateSolvability() | 120 | var apclient = global.get_node("Archipelago") |
121 | apclient.evaluateSolvability() | ||
122 | |||
123 | text_dirty = true | ||
124 | |||
125 | var apclient = global.get_node("Archipelago") | ||
126 | apclient.saveLocaldata() | ||
95 | 127 | ||
96 | 128 | ||
97 | func show_puzzle_skip_message(node_path): | 129 | func show_puzzle_skip_message(node_path): |
130 | if puzzle_focused and node_path != puzzle_to_skip: | ||
131 | hide_puzzle_skip_message() | ||
132 | |||
98 | var panel_input = get_tree().get_root().get_node(node_path) | 133 | var panel_input = get_tree().get_root().get_node(node_path) |
99 | if not panel_input.visible: | 134 | if not panel_input.visible: |
100 | return | 135 | return |
@@ -106,12 +141,18 @@ func show_puzzle_skip_message(node_path): | |||
106 | return | 141 | return |
107 | 142 | ||
108 | puzzle_focused = true | 143 | puzzle_focused = true |
144 | wallcast.enabled = true | ||
145 | not_behind_wall = false | ||
146 | text_dirty = true | ||
109 | puzzle_to_skip = node_path | 147 | puzzle_to_skip = node_path |
110 | _evaluate_puzzle_skip() | 148 | _evaluate_puzzle_skip() |
111 | 149 | ||
112 | 150 | ||
113 | func hide_puzzle_skip_message(): | 151 | func hide_puzzle_skip_message(): |
114 | puzzle_focused = false | 152 | puzzle_focused = false |
153 | wallcast.enabled = false | ||
154 | not_behind_wall = false | ||
155 | text_dirty = true | ||
115 | _evaluate_puzzle_skip() | 156 | _evaluate_puzzle_skip() |
116 | 157 | ||
117 | 158 | ||
@@ -136,26 +177,64 @@ func skip_puzzle(): | |||
136 | func _evaluate_puzzle_skip(): | 177 | func _evaluate_puzzle_skip(): |
137 | if puzzle_focused and not solve_mode: | 178 | if puzzle_focused and not solve_mode: |
138 | skip_available = true | 179 | skip_available = true |
139 | |||
140 | if not effect_running: | ||
141 | _process_effects() | ||
142 | else: | 180 | else: |
143 | skip_available = false | 181 | skip_available = false |
182 | text_dirty = true | ||
183 | |||
184 | |||
185 | func _tick_slowness(): | ||
186 | slowness_remaining -= 1 | ||
187 | text_dirty = true | ||
188 | |||
189 | if slowness_remaining == 0: | ||
190 | var player = get_tree().get_root().get_node("Spatial/player") | ||
191 | player.walk_speed = orig_walk | ||
192 | player.run_speed = orig_run | ||
193 | |||
194 | $SlownessTimer.stop() | ||
195 | |||
196 | if slowness_remaining % 5 == 0: | ||
197 | var apclient = global.get_node("Archipelago") | ||
198 | apclient.saveLocaldata() | ||
199 | |||
200 | |||
201 | func _tick_iceland(): | ||
202 | iceland_remaining -= 1 | ||
203 | text_dirty = true | ||
204 | |||
205 | if iceland_remaining == 0: | ||
206 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
207 | orig_env | ||
208 | ) | ||
209 | |||
210 | $IcelandTimer.stop() | ||
211 | |||
212 | if iceland_remaining % 5 == 0: | ||
213 | var apclient = global.get_node("Archipelago") | ||
214 | apclient.saveLocaldata() | ||
215 | |||
144 | 216 | ||
217 | func _process(_delta): | ||
218 | if puzzle_focused: | ||
219 | var should_nbw = false | ||
220 | if wallcast.is_colliding(): | ||
221 | var player = get_tree().get_root().get_node("Spatial/player") | ||
222 | var puzzlecast = player.get_node("pivot/camera/RayCast_sight") | ||
223 | var distance = puzzlecast.get_collision_point().distance_to(wallcast.get_collision_point()) | ||
224 | should_nbw = (distance < 0.05) | ||
225 | |||
226 | if should_nbw != not_behind_wall: | ||
227 | not_behind_wall = should_nbw | ||
228 | text_dirty = true | ||
145 | 229 | ||
146 | func _process_effects(): | 230 | if text_dirty: |
147 | effect_running = true | 231 | text_dirty = false |
148 | 232 | ||
149 | while slowness_remaining > 0 or iceland_remaining > 0 or atbash_activated or skip_available: | ||
150 | var text = "" | 233 | var text = "" |
151 | if atbash_activated: | 234 | if atbash_remaining == 1: |
152 | text += "Atbash Trap lasts until you solve a puzzle" | 235 | text += "Atbash Trap lasts until you solve a puzzle" |
153 | if skip_available: | 236 | if atbash_remaining > 1: |
154 | var apclient = global.get_node("Archipelago") | 237 | text += ("Atbash Trap lasts until you solve %d puzzles" % atbash_remaining) |
155 | if apclient.getAvailablePuzzleSkips() > 0: | ||
156 | if not text.empty(): | ||
157 | text += "\n" | ||
158 | text += "Press P to skip puzzle (%d available)" % apclient.getAvailablePuzzleSkips() | ||
159 | if slowness_remaining > 0: | 238 | if slowness_remaining > 0: |
160 | if not text.empty(): | 239 | if not text.empty(): |
161 | text += "\n" | 240 | text += "\n" |
@@ -164,26 +243,10 @@ func _process_effects(): | |||
164 | if not text.empty(): | 243 | if not text.empty(): |
165 | text += "\n" | 244 | text += "\n" |
166 | text += "Iceland: %d seconds" % iceland_remaining | 245 | text += "Iceland: %d seconds" % iceland_remaining |
246 | if skip_available and not_behind_wall: | ||
247 | var apclient = global.get_node("Archipelago") | ||
248 | if apclient.getAvailablePuzzleSkips() > 0: | ||
249 | if not text.empty(): | ||
250 | text += "\n" | ||
251 | text += "Press P to skip puzzle (%d available)" % apclient.getAvailablePuzzleSkips() | ||
167 | self.get_node("label").text = text | 252 | self.get_node("label").text = text |
168 | |||
169 | yield(get_tree().create_timer(1.0), "timeout") | ||
170 | |||
171 | if !get_tree().paused: | ||
172 | if slowness_remaining > 0: | ||
173 | slowness_remaining -= 1 | ||
174 | |||
175 | if slowness_remaining == 0: | ||
176 | var player = get_tree().get_root().get_node("Spatial/player") | ||
177 | player.walk_speed = orig_walk | ||
178 | player.run_speed = orig_run | ||
179 | |||
180 | if iceland_remaining > 0: | ||
181 | iceland_remaining -= 1 | ||
182 | |||
183 | if iceland_remaining == 0: | ||
184 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
185 | orig_env | ||
186 | ) | ||
187 | |||
188 | self.get_node("label").text = "" | ||
189 | effect_running = false | ||