diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-22 18:45:03 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-22 18:45:03 -0400 |
| commit | 793564a44706b302921fae599f5cbe2fb8590e67 (patch) | |
| tree | 48fd08034eda561dd5de50a735a8fe77462bd68f | |
| parent | 7c0c676fedef3bbeb5dd04ded5a94fe8933822cf (diff) | |
| download | lingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.tar.gz lingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.tar.bz2 lingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.zip | |
Added traps
| -rw-r--r-- | Archipelago/client.gd | 8 | ||||
| -rw-r--r-- | Archipelago/effects.gd | 89 | ||||
| -rw-r--r-- | Archipelago/load.gd | 6 |
3 files changed, 102 insertions, 1 deletions
| diff --git a/Archipelago/client.gd b/Archipelago/client.gd index dba8227..97e2ca4 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
| @@ -523,7 +523,7 @@ func processItem(item, index, from): | |||
| 523 | _has_colors.append(lcol) | 523 | _has_colors.append(lcol) |
| 524 | emit_signal("evaluate_solvability") | 524 | emit_signal("evaluate_solvability") |
| 525 | 525 | ||
| 526 | # Show a message about the item if it's new. | 526 | # Show a message about the item if it's new. Also apply effects here. |
| 527 | if index != null and index > _last_new_item: | 527 | if index != null and index > _last_new_item: |
| 528 | _last_new_item = index | 528 | _last_new_item = index |
| 529 | saveLocaldata() | 529 | saveLocaldata() |
| @@ -545,6 +545,12 @@ func processItem(item, index, from): | |||
| 545 | else: | 545 | else: |
| 546 | messages_node.showMessage("Received %s from %s" % [item_name, player_name]) | 546 | messages_node.showMessage("Received %s from %s" % [item_name, player_name]) |
| 547 | 547 | ||
| 548 | var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") | ||
| 549 | if item_name == "Slowness Trap": | ||
| 550 | effects_node.trigger_slowness_trap() | ||
| 551 | if item_name == "Iceland Trap": | ||
| 552 | effects_node.trigger_iceland_trap() | ||
| 553 | |||
| 548 | 554 | ||
| 549 | func doorIsVanilla(door): | 555 | func doorIsVanilla(door): |
| 550 | return !_mentioned_doors.has(door) | 556 | return !_mentioned_doors.has(door) |
| diff --git a/Archipelago/effects.gd b/Archipelago/effects.gd new file mode 100644 index 0000000..7d7e0fe --- /dev/null +++ b/Archipelago/effects.gd | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | extends Node | ||
| 2 | |||
| 3 | var effect_running = false | ||
| 4 | var slowness_remaining = 0 | ||
| 5 | var iceland_remaining = 0 | ||
| 6 | |||
| 7 | var orig_env | ||
| 8 | var orig_walk | ||
| 9 | var orig_run | ||
| 10 | |||
| 11 | |||
| 12 | func _ready(): | ||
| 13 | orig_env = get_tree().get_root().get_node("Spatial/player/pivot/camera").environment | ||
| 14 | orig_walk = get_tree().get_root().get_node("Spatial/player").walk_speed | ||
| 15 | orig_run = get_tree().get_root().get_node("Spatial/player").run_speed | ||
| 16 | |||
| 17 | var label = Label.new() | ||
| 18 | label.set_name("label") | ||
| 19 | label.margin_right = 1920.0 - 20.0 | ||
| 20 | label.margin_top = 20.0 | ||
| 21 | label.align = Label.ALIGN_RIGHT | ||
| 22 | label.valign = Label.VALIGN_TOP | ||
| 23 | |||
| 24 | var dynamic_font = DynamicFont.new() | ||
| 25 | dynamic_font.font_data = load("res://fonts/Lingo.ttf") | ||
| 26 | dynamic_font.size = 36 | ||
| 27 | dynamic_font.outline_color = Color(0, 0, 0, 1) | ||
| 28 | dynamic_font.outline_size = 2 | ||
| 29 | label.add_font_override("font", dynamic_font) | ||
| 30 | |||
| 31 | add_child(label) | ||
| 32 | |||
| 33 | |||
| 34 | func trigger_slowness_trap(): | ||
| 35 | if slowness_remaining == 0: | ||
| 36 | var player = get_tree().get_root().get_node("Spatial/player") | ||
| 37 | player.walk_speed = orig_walk / 2.0 | ||
| 38 | player.run_speed = orig_run / 2.0 | ||
| 39 | |||
| 40 | slowness_remaining += 30 | ||
| 41 | |||
| 42 | if not effect_running: | ||
| 43 | _process_effects() | ||
| 44 | |||
| 45 | |||
| 46 | func trigger_iceland_trap(): | ||
| 47 | if iceland_remaining == 0: | ||
| 48 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
| 49 | load("res://environments/level_iceland.tres") | ||
| 50 | ) | ||
| 51 | |||
| 52 | iceland_remaining += 30 | ||
| 53 | |||
| 54 | if not effect_running: | ||
| 55 | _process_effects() | ||
| 56 | |||
| 57 | |||
| 58 | func _process_effects(): | ||
| 59 | effect_running = true | ||
| 60 | |||
| 61 | while slowness_remaining > 0 or iceland_remaining > 0: | ||
| 62 | var text = "" | ||
| 63 | if slowness_remaining > 0: | ||
| 64 | text += "Slowness: %d seconds" % slowness_remaining | ||
| 65 | if iceland_remaining > 0: | ||
| 66 | if not text.empty(): | ||
| 67 | text += "\n" | ||
| 68 | text += "Iceland: %d seconds" % iceland_remaining | ||
| 69 | self.get_node("label").text = text | ||
| 70 | |||
| 71 | yield(get_tree().create_timer(1.0), "timeout") | ||
| 72 | |||
| 73 | if slowness_remaining > 0: | ||
| 74 | slowness_remaining -= 1 | ||
| 75 | |||
| 76 | if slowness_remaining == 0: | ||
| 77 | var player = get_tree().get_root().get_node("Spatial/player") | ||
| 78 | player.walk_speed = orig_walk | ||
| 79 | player.run_speed = orig_run | ||
| 80 | |||
| 81 | if iceland_remaining > 0: | ||
| 82 | iceland_remaining -= 1 | ||
| 83 | |||
| 84 | if iceland_remaining == 0: | ||
| 85 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
| 86 | orig_env | ||
| 87 | ) | ||
| 88 | |||
| 89 | effect_running = false | ||
| diff --git a/Archipelago/load.gd b/Archipelago/load.gd index f526411..80f7d06 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd | |||
| @@ -200,6 +200,12 @@ func _load(): | |||
| 200 | messages.set_name("AP_Messages") | 200 | messages.set_name("AP_Messages") |
| 201 | self.add_child(messages) | 201 | self.add_child(messages) |
| 202 | 202 | ||
| 203 | # Create the effects node. | ||
| 204 | var effects_script = ResourceLoader.load("user://maps/Archipelago/effects.gd") | ||
| 205 | var effects = effects_script.new() | ||
| 206 | effects.set_name("AP_Effects") | ||
| 207 | self.add_child(effects) | ||
| 208 | |||
| 203 | # Hook up the scene to be able to handle connection failures. | 209 | # Hook up the scene to be able to handle connection failures. |
| 204 | apclient.connect("could_not_connect", self, "archipelago_disconnected") | 210 | apclient.connect("could_not_connect", self, "archipelago_disconnected") |
| 205 | 211 | ||
