diff options
Diffstat (limited to 'apworld/client/player.gd')
| -rw-r--r-- | apworld/client/player.gd | 191 |
1 files changed, 13 insertions, 178 deletions
| diff --git a/apworld/client/player.gd b/apworld/client/player.gd index 5417a48..5fac9fd 100644 --- a/apworld/client/player.gd +++ b/apworld/client/player.gd | |||
| @@ -19,6 +19,13 @@ func _ready(): | |||
| 19 | 19 | ||
| 20 | ap.start_batching_locations() | 20 | ap.start_batching_locations() |
| 21 | 21 | ||
| 22 | # Run map-specific initialization. | ||
| 23 | var map_script = ap.get_map_script(global.map) | ||
| 24 | if map_script != null: | ||
| 25 | map_script.on_map_load(get_tree().get_root()) | ||
| 26 | |||
| 27 | ap.update_job_well_done_sign() | ||
| 28 | |||
| 22 | # Set up door locations. | 29 | # Set up door locations. |
| 23 | var map_id = gamedata.map_id_by_name.get(global.map) | 30 | var map_id = gamedata.map_id_by_name.get(global.map) |
| 24 | for door in gamedata.objects.get_doors(): | 31 | for door in gamedata.objects.get_doors(): |
| @@ -29,8 +36,12 @@ func _ready(): | |||
| 29 | continue | 36 | continue |
| 30 | 37 | ||
| 31 | if ( | 38 | if ( |
| 32 | door.get_type() == gamedata.SCRIPT_proto.DoorType.ITEM_ONLY | 39 | not (door.has_legacy_location() and door.get_legacy_location()) |
| 33 | or door.get_type() == gamedata.SCRIPT_proto.DoorType.GALLERY_PAINTING | 40 | and ( |
| 41 | door.get_type() == gamedata.SCRIPT_proto.DoorType.ITEM_ONLY | ||
| 42 | or door.get_type() == gamedata.SCRIPT_proto.DoorType.GALLERY_PAINTING | ||
| 43 | or door.get_type() == gamedata.SCRIPT_proto.DoorType.CONTROL_CENTER_COLOR | ||
| 44 | ) | ||
| 34 | ): | 45 | ): |
| 35 | continue | 46 | continue |
| 36 | 47 | ||
| @@ -153,165 +164,6 @@ func _ready(): | |||
| 153 | 164 | ||
| 154 | get_parent().add_child.call_deferred(locationListener) | 165 | get_parent().add_child.call_deferred(locationListener) |
| 155 | 166 | ||
| 156 | # Block off roof access in Daedalus. | ||
| 157 | if global.map == "daedalus" and not ap.daedalus_roof_access: | ||
| 158 | _set_up_invis_wall(75.5, 11, -24.5, 1, 10, 49) | ||
| 159 | _set_up_invis_wall(51.5, 11, -17, 16, 10, 1) | ||
| 160 | _set_up_invis_wall(46, 10, -9.5, 1, 10, 10) | ||
| 161 | _set_up_invis_wall(67.5, 11, 17, 16, 10, 1) | ||
| 162 | _set_up_invis_wall(50.5, 11, 14, 10, 10, 1) | ||
| 163 | _set_up_invis_wall(39, 10, 18.5, 1, 10, 22) | ||
| 164 | _set_up_invis_wall(20, 15, 18.5, 1, 10, 16) | ||
| 165 | _set_up_invis_wall(11.5, 15, 3, 32, 10, 1) | ||
| 166 | _set_up_invis_wall(11.5, 16, -20, 14, 20, 1) | ||
| 167 | _set_up_invis_wall(14, 16, -26.5, 1, 20, 4) | ||
| 168 | _set_up_invis_wall(28.5, 20.5, -26.5, 1, 15, 25) | ||
| 169 | _set_up_invis_wall(40.5, 20.5, -11, 30, 15, 1) | ||
| 170 | _set_up_invis_wall(50.5, 15, 5.5, 7, 10, 1) | ||
| 171 | _set_up_invis_wall(83.5, 33.5, 5.5, 1, 7, 11) | ||
| 172 | _set_up_invis_wall(83.5, 33.5, -5.5, 1, 7, 11) | ||
| 173 | |||
| 174 | var warp_exit_prefab = preload("res://objects/nodes/exit.tscn") | ||
| 175 | var warp_exit = warp_exit_prefab.instantiate() | ||
| 176 | warp_exit.name = "roof_access_blocker_warp_exit" | ||
| 177 | warp_exit.position = Vector3(58, 10, 0) | ||
| 178 | warp_exit.rotation_degrees.y = 90 | ||
| 179 | get_parent().add_child.call_deferred(warp_exit) | ||
| 180 | |||
| 181 | var warp_enter_prefab = preload("res://objects/nodes/teleportAuto.tscn") | ||
| 182 | var warp_enter = warp_enter_prefab.instantiate() | ||
| 183 | warp_enter.target = warp_exit | ||
| 184 | warp_enter.position = Vector3(76.5, 30, 1) | ||
| 185 | warp_enter.scale = Vector3(4, 1.5, 1) | ||
| 186 | warp_enter.rotation_degrees.y = 90 | ||
| 187 | get_parent().add_child.call_deferred(warp_enter) | ||
| 188 | |||
| 189 | if global.map == "the_entry": | ||
| 190 | # Remove door behind X1. | ||
| 191 | var door_node = get_tree().get_root().get_node("/root/scene/Components/Doors/exit_1") | ||
| 192 | door_node.handleTriggered() | ||
| 193 | |||
| 194 | # Display win condition. | ||
| 195 | var sign_prefab = preload("res://objects/nodes/sign.tscn") | ||
| 196 | var sign1 = sign_prefab.instantiate() | ||
| 197 | sign1.position = Vector3(-7, 5, -15.01) | ||
| 198 | sign1.text = "victory" | ||
| 199 | get_parent().add_child.call_deferred(sign1) | ||
| 200 | |||
| 201 | var sign2 = sign_prefab.instantiate() | ||
| 202 | sign2.position = Vector3(-7, 4, -15.01) | ||
| 203 | sign2.text = "%s ending" % ap.kEndingNameByVictoryValue.get(ap.victory_condition, "?") | ||
| 204 | |||
| 205 | var sign2_color = ap.kEndingNameByVictoryValue.get(ap.victory_condition, "coral").to_lower() | ||
| 206 | if sign2_color == "white": | ||
| 207 | sign2_color = "silver" | ||
| 208 | |||
| 209 | sign2.material = load("res://assets/materials/%s.material" % sign2_color) | ||
| 210 | get_parent().add_child.call_deferred(sign2) | ||
| 211 | |||
| 212 | # Add the strict purple ending validation. | ||
| 213 | if global.map == "the_sun_temple" and ap.strict_purple_ending: | ||
| 214 | var panel_prefab = preload("res://objects/nodes/panel.tscn") | ||
| 215 | var tpl_prefab = preload("res://objects/nodes/listeners/teleportListener.tscn") | ||
| 216 | var reverse_prefab = preload("res://objects/nodes/listeners/reversingListener.tscn") | ||
| 217 | |||
| 218 | var previous_panel = null | ||
| 219 | var next_y = -100 | ||
| 220 | var words = ["quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"] | ||
| 221 | for word in words: | ||
| 222 | var panel = panel_prefab.instantiate() | ||
| 223 | panel.position = Vector3(0, next_y, 0) | ||
| 224 | next_y -= 10 | ||
| 225 | panel.clue = word | ||
| 226 | panel.symbol = "" | ||
| 227 | panel.answer = word | ||
| 228 | panel.name = "EndCheck_%s" % word | ||
| 229 | |||
| 230 | var tpl = tpl_prefab.instantiate() | ||
| 231 | tpl.teleport_point = Vector3(0, 1, 0) | ||
| 232 | tpl.teleport_rotate = Vector3(-45, 180, 0) | ||
| 233 | tpl.target_path = panel | ||
| 234 | tpl.name = "Teleport" | ||
| 235 | |||
| 236 | if previous_panel == null: | ||
| 237 | tpl.senders.append(NodePath("/root/scene/Panels/End/panel_24")) | ||
| 238 | else: | ||
| 239 | tpl.senders.append(NodePath("../../%s" % previous_panel.name)) | ||
| 240 | |||
| 241 | var reversing = reverse_prefab.instantiate() | ||
| 242 | reversing.senders.append(NodePath("..")) | ||
| 243 | reversing.name = "Reversing" | ||
| 244 | tpl.senders.append(NodePath("../Reversing")) | ||
| 245 | |||
| 246 | panel.add_child.call_deferred(tpl) | ||
| 247 | panel.add_child.call_deferred(reversing) | ||
| 248 | get_parent().get_node("Panels").add_child.call_deferred(panel) | ||
| 249 | |||
| 250 | previous_panel = panel | ||
| 251 | |||
| 252 | # Duplicate the doors that usually wait on EQUINOX. We can't set the senders | ||
| 253 | # here for some reason so we actually set them in the door ready function. | ||
| 254 | var endplat = get_node("/root/scene/Components/Doors/EndPlatform") | ||
| 255 | var endplat2 = endplat.duplicate() | ||
| 256 | endplat2.name = "spe_EndPlatform" | ||
| 257 | endplat.get_parent().add_child.call_deferred(endplat2) | ||
| 258 | endplat.queue_free() | ||
| 259 | |||
| 260 | var entry2 = get_node("/root/scene/Components/Doors/entry_2") | ||
| 261 | var entry22 = entry2.duplicate() | ||
| 262 | entry22.name = "spe_entry_2" | ||
| 263 | entry2.get_parent().add_child.call_deferred(entry22) | ||
| 264 | entry2.queue_free() | ||
| 265 | |||
| 266 | # Add the strict cyan ending validation. | ||
| 267 | if global.map == "the_parthenon" and ap.strict_cyan_ending: | ||
| 268 | var panel_prefab = preload("res://objects/nodes/panel.tscn") | ||
| 269 | var tpl_prefab = preload("res://objects/nodes/listeners/teleportListener.tscn") | ||
| 270 | var reverse_prefab = preload("res://objects/nodes/listeners/reversingListener.tscn") | ||
| 271 | |||
| 272 | var previous_panel = null | ||
| 273 | var next_y = -100 | ||
| 274 | var words = ["quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"] | ||
| 275 | for word in words: | ||
| 276 | var panel = panel_prefab.instantiate() | ||
| 277 | panel.position = Vector3(0, next_y, 0) | ||
| 278 | next_y -= 10 | ||
| 279 | panel.clue = word | ||
| 280 | panel.symbol = "." | ||
| 281 | panel.answer = "%s%s" % [word, word] | ||
| 282 | panel.name = "EndCheck_%s" % word | ||
| 283 | |||
| 284 | var tpl = tpl_prefab.instantiate() | ||
| 285 | tpl.teleport_point = Vector3(0, 1, -11) | ||
| 286 | tpl.teleport_rotate = Vector3(-45, 0, 0) | ||
| 287 | tpl.target_path = panel | ||
| 288 | tpl.name = "Teleport" | ||
| 289 | |||
| 290 | if previous_panel == null: | ||
| 291 | tpl.senderGroup.append(NodePath("/root/scene/Panels/Rulers")) | ||
| 292 | else: | ||
| 293 | tpl.senders.append(NodePath("../../%s" % previous_panel.name)) | ||
| 294 | |||
| 295 | var reversing = reverse_prefab.instantiate() | ||
| 296 | reversing.senders.append(NodePath("..")) | ||
| 297 | reversing.name = "Reversing" | ||
| 298 | tpl.senders.append(NodePath("../Reversing")) | ||
| 299 | |||
| 300 | panel.add_child.call_deferred(tpl) | ||
| 301 | panel.add_child.call_deferred(reversing) | ||
| 302 | get_parent().get_node("Panels").add_child.call_deferred(panel) | ||
| 303 | |||
| 304 | previous_panel = panel | ||
| 305 | |||
| 306 | # Duplicate the door that usually waits on the rulers. We can't set the | ||
| 307 | # senders here for some reason so we actually set them in the door ready | ||
| 308 | # function. | ||
| 309 | var entry1 = get_node("/root/scene/Components/Doors/entry_1") | ||
| 310 | var entry12 = entry1.duplicate() | ||
| 311 | entry12.name = "spe_entry_1" | ||
| 312 | entry1.get_parent().add_child.call_deferred(entry12) | ||
| 313 | entry1.queue_free() | ||
| 314 | |||
| 315 | var minimap = ap.SCRIPT_minimap.new() | 167 | var minimap = ap.SCRIPT_minimap.new() |
| 316 | minimap.name = "Minimap" | 168 | minimap.name = "Minimap" |
| 317 | minimap.visible = ap.show_minimap | 169 | minimap.visible = ap.show_minimap |
| @@ -325,22 +177,5 @@ func _ready(): | |||
| 325 | ap.stop_batching_locations() | 177 | ap.stop_batching_locations() |
| 326 | 178 | ||
| 327 | 179 | ||
| 328 | func _set_up_invis_wall(x, y, z, sx, sy, sz): | ||
| 329 | var prefab = preload("res://objects/nodes/block.tscn") | ||
| 330 | var newwall = prefab.instantiate() | ||
| 331 | newwall.position.x = x | ||
| 332 | newwall.position.y = y | ||
| 333 | newwall.position.z = z | ||
| 334 | newwall.scale.x = sz | ||
| 335 | newwall.scale.y = sy | ||
| 336 | newwall.scale.z = sx | ||
| 337 | newwall.set_surface_override_material(0, preload("res://assets/materials/blackMatte.material")) | ||
| 338 | newwall.visibility_range_end = 3 | ||
| 339 | newwall.visibility_range_end_margin = 1 | ||
| 340 | newwall.visibility_range_fade_mode = RenderingServer.VISIBILITY_RANGE_FADE_SELF | ||
| 341 | newwall.skeleton = ".." | ||
| 342 | get_parent().add_child.call_deferred(newwall) | ||
| 343 | |||
| 344 | |||
| 345 | func _process(_dt): | 180 | func _process(_dt): |
| 346 | compass.update_rotation(global_rotation.y) | 181 | compass.update_rotation(global_rotation.y) |
