about summary refs log tree commit diff stats
path: root/data/maps/the_quiet/rooms/Main Area.txtpb
blob: 72c0a1e81889dc9c59f758c1a361b7a08cae979c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: "Main Area"
panels {
  name: "SOLID"
  path: "Panels/Main/panel_1"
  clue: "solid"
  answer: "gas"
  symbols: CROSS
  proxies { answer: "liquid" path: "Panels/Q/panel_1" }
}
panels {
  name: "RODENT"
  path: "Panels/Main/panel_2"
  clue: "rodent"
  answer: "rat"
  symbols: EXAMPLE
  proxies { answer: "squirrel" path: "Panels/Q/panel_2" }
}
panels {
  name: "COIN"
  path: "Panels/Main/panel_3"
  clue: "coin"
  answer: "dime"
  symbols: EXAMPLE
  proxies { answer: "quarter" path: "Panels/Q/panel_3" }
}
panels {
  name: "RULE"
  path: "Panels/Main/panel_4"
  clue: "rule"
  answer: "king"
  symbols: JOB
  proxies { answer: "queen" path: "Panels/Q/panel_4" }
}
panels {
  name: "PORCUPINE"
  path: "Panels/Main/panel_5"
  clue: "porcupine"
  answer: "spine"
  symbols: BOXES
  proxies { answer: "quill" path: "Panels/Q/panel_5" }
}
panels {
  name: "DISAGREE"
  path: "Panels/Main/panel_6"
  clue: "disagree"
  answer: "argue"
  symbols: PYRAMID
  proxies { answer: "quarrel" path: "Panels/Q/panel_6" }
}
panels {
  name: "DEMAND"
  path: "Panels/Main/panel_7"
  clue: "demand"
  answer: "ask"
  symbols: PYRAMID
  proxies { answer: "request" path: "Panels/Q/panel_7" }
}
panels {
  name: "FLOWER"
  path: "Panels/Main/panel_8"
  clue: "flower"
  answer: "flowers"
  symbols: PLANET
  proxies { answer: "bouquet" path: "Panels/Q/panel_8" }
}
panels {
  name: "BEE"
  path: "Panels/Main/panel_9"
  clue: "bee"
  answer: "fly"
  symbols: EXAMPLE
  proxies { answer: "mosquito" path: "Panels/Q/panel_9" }
}
panels {
  name: "DUO"
  path: "Panels/Main/panel_10"
  clue: "duo"
  answer: "trio"
  symbols: BOXES
  proxies { answer: "quartet" path: "Panels/Q/panel_10" }
}
panels {
  name: "LINGO 2"
  path: "Panels/Main/panel_11"
  clue: "lingo 2"
  answer: "game"
  symbols: EXAMPLE
  proxies { answer: "sequel" path: "Panels/Q/panel_11" }
}
panels {
  name: "CRUSH"
  path: "Panels/Main/panel_12"
  clue: "crush"
  answer: "mash"
  symbols: SUN
  proxies { answer: "squash" path: "Panels/Q/panel_12" }
}
ports {
  name: "DAEDALUS"
  display_name: "Entrance"
  path: "Components/Warps/worldport"
  destination { x: 3 y: 0 z: 8 }
  rotation: 90
}
.Number.Integer.Long */
extends "res://scripts/nodes/player.gd"

const kEndingNameByVictoryValue = {
	0: "GRAY",
	1: "PURPLE",
	2: "MINT",
	3: "BLACK",
	4: "BLUE",
	5: "CYAN",
	6: "RED",
	7: "PLUM",
	8: "ORANGE",
	9: "GOLD",
	10: "YELLOW",
	11: "GREEN",
	12: "WHITE",
}


func _ready():
	var khl_script = load("res://scripts/nodes/keyHolderListener.gd")

	var ap = global.get_node("Archipelago")
	var gamedata = global.get_node("Gamedata")

	ap.start_batching_locations()

	# Set up door locations.
	var map_id = gamedata.map_id_by_name.get(global.map)
	for door in gamedata.objects.get_doors():
		if door.get_map_id() != map_id:
			continue

		if not door.has_ap_id():
			continue

		if door.get_type() == gamedata.SCRIPT_proto.DoorType.ITEM_ONLY:
			continue

		var locationListener = ap.SCRIPT_locationListener.new()
		locationListener.location_id = door.get_ap_id()
		locationListener.name = "locationListener_%d" % door.get_ap_id()

		for panel_ref in door.get_panels():
			var panel_data = gamedata.objects.get_panels()[panel_ref.get_panel()]
			var panel_path = panel_data.get_path()

			if panel_ref.has_answer():
				for proxy in panel_data.get_proxies():
					if proxy.get_answer() == panel_ref.get_answer():
						panel_path = proxy.get_path()
						break

			locationListener.senders.append(NodePath("/root/scene/" + panel_path))

		for keyholder_ref in door.get_keyholders():
			var keyholder_data = gamedata.objects.get_keyholders()[keyholder_ref.get_keyholder()]

			var khl = khl_script.new()
			khl.name = (
				"location_%d_keyholder_%d" % [door.get_ap_id(), keyholder_ref.get_keyholder()]
			)
			khl.answer = keyholder_ref.get_key()
			khl.senders.append(NodePath("/root/scene/" + keyholder_data.get_path()))
			get_parent().add_child.call_deferred(khl)

			locationListener.senders.append(NodePath("../" + khl.name))

		get_parent().add_child.call_deferred(locationListener)

	# Set up letter locations.
	for letter in gamedata.objects.get_letters():
		var room = gamedata.objects.get_rooms()[letter.get_room_id()]
		if room.get_map_id() != map_id:
			continue

		var locationListener = ap.SCRIPT_locationListener.new()
		locationListener.location_id = letter.get_ap_id()
		locationListener.name = "locationListener_%d" % letter.get_ap_id()
		locationListener.senders.append(NodePath("/root/scene/" + letter.get_path()))

		get_parent().add_child.call_deferred(locationListener)

		if (
			ap.get_letter_behavior(letter.get_key(), letter.has_level2() and letter.get_level2())
			!= ap.kLETTER_BEHAVIOR_VANILLA
		):
			var scout = ap.scout_location(letter.get_ap_id())
			if scout != null:
				var item_name = "Unknown"
				var item_player_game = ap.client._game_by_player[float(scout["player"])]
				if ap.client._item_id_to_name[item_player_game].has(scout["item"]):
					item_name = ap.client._item_id_to_name[item_player_game][scout["item"]]

					var collectable = get_tree().get_root().get_node("scene").get_node_or_null(
						letter.get_path()
					)
					if collectable != null:
						collectable.setScoutedText.call_deferred(item_name)

	# Set up mastery locations.
	for mastery in gamedata.objects.get_masteries():
		var room = gamedata.objects.get_rooms()[mastery.get_room_id()]
		if room.get_map_id() != map_id:
			continue

		var locationListener = ap.SCRIPT_locationListener.new()
		locationListener.location_id = mastery.get_ap_id()
		locationListener.name = "locationListener_%d" % mastery.get_ap_id()
		locationListener.senders.append(NodePath("/root/scene/" + mastery.get_path()))

		get_parent().add_child.call_deferred(locationListener)

	# Set up ending locations.
	for ending in gamedata.objects.get_endings():
		var room = gamedata.objects.get_rooms()[ending.get_room_id()]
		if room.get_map_id() != map_id:
			continue

		var locationListener = ap.SCRIPT_locationListener.new()
		locationListener.location_id = ending.get_ap_id()
		locationListener.name = "locationListener_%d" % ending.get_ap_id()
		locationListener.senders.append(NodePath("/root/scene/" + ending.get_path()))

		get_parent().add_child.call_deferred(locationListener)

		if kEndingNameByVictoryValue.get(ap.victory_condition, null) == ending.get_name():
			var victoryListener = ap.SCRIPT_victoryListener.new()
			victoryListener.name = "victoryListener"
			victoryListener.senders.append(NodePath("/root/scene/" + ending.get_path()))

			get_parent().add_child.call_deferred(victoryListener)

	# Set up keyholder locations, in keyholder sanity.
	if ap.keyholder_sanity:
		for keyholder in gamedata.objects.get_keyholders():
			if not keyholder.has_key():
				continue

			var room = gamedata.objects.get_rooms()[keyholder.get_room_id()]
			if room.get_map_id() != map_id:
				continue

			var locationListener = ap.SCRIPT_locationListener.new()
			locationListener.location_id = keyholder.get_ap_id()
			locationListener.name = "locationListener_%d" % keyholder.get_ap_id()

			var khl = khl_script.new()
			khl.name = "location_%d_keyholder" % keyholder.get_ap_id()
			khl.answer = keyholder.get_key()
			khl.senders.append(NodePath("/root/scene/" + keyholder.get_path()))
			get_parent().add_child.call_deferred(khl)

			locationListener.senders.append(NodePath("../" + khl.name))

			get_parent().add_child.call_deferred(locationListener)

	# Block off roof access in Daedalus.
	if global.map == "daedalus" and not ap.daedalus_roof_access:
		_set_up_invis_wall(75.5, 11, -24.5, 1, 10, 49)
		_set_up_invis_wall(51.5, 11, -17, 16, 10, 1)
		_set_up_invis_wall(46, 10, -9.5, 1, 10, 10)
		_set_up_invis_wall(67.5, 11, 17, 16, 10, 1)
		_set_up_invis_wall(50.5, 11, 14, 10, 10, 1)
		_set_up_invis_wall(39, 10, 18.5, 1, 10, 22)
		_set_up_invis_wall(20, 15, 18.5, 1, 10, 16)
		_set_up_invis_wall(11.5, 15, 3, 32, 10, 1)
		_set_up_invis_wall(11.5, 16, -20, 14, 20, 1)
		_set_up_invis_wall(14, 16, -26.5, 1, 20, 4)
		_set_up_invis_wall(28.5, 20.5, -26.5, 1, 15, 25)
		_set_up_invis_wall(40.5, 20.5, -11, 30, 15, 1)
		_set_up_invis_wall(50.5, 15, 5.5, 7, 10, 1)
		_set_up_invis_wall(83.5, 33.5, 5.5, 1, 7, 11)
		_set_up_invis_wall(83.5, 33.5, -5.5, 1, 7, 11)

		var warp_exit_prefab = preload("res://objects/nodes/exit.tscn")
		var warp_exit = warp_exit_prefab.instantiate()
		warp_exit.name = "roof_access_blocker_warp_exit"
		warp_exit.position = Vector3(58, 10, 0)
		warp_exit.rotation_degrees.y = 90
		get_parent().add_child.call_deferred(warp_exit)

		var warp_enter_prefab = preload("res://objects/nodes/teleportAuto.tscn")
		var warp_enter = warp_enter_prefab.instantiate()
		warp_enter.target = warp_exit
		warp_enter.position = Vector3(76.5, 30, 1)
		warp_enter.scale = Vector3(4, 1.5, 1)
		warp_enter.rotation_degrees.y = 90
		get_parent().add_child.call_deferred(warp_enter)

	super._ready()

	await get_tree().process_frame
	await get_tree().process_frame

	ap.stop_batching_locations()


func _set_up_invis_wall(x, y, z, sx, sy, sz):
	var prefab = preload("res://objects/nodes/block.tscn")
	var newwall = prefab.instantiate()
	newwall.position.x = x
	newwall.position.y = y
	newwall.position.z = z
	newwall.scale.x = sz
	newwall.scale.y = sy
	newwall.scale.z = sx
	newwall.set_surface_override_material(0, preload("res://assets/materials/blackMatte.material"))
	newwall.visibility_range_end = 3
	newwall.visibility_range_end_margin = 1
	newwall.visibility_range_fade_mode = RenderingServer.VISIBILITY_RANGE_FADE_SELF
	newwall.skeleton = ".."
	get_parent().add_child.call_deferred(newwall)