about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Archipelago/client.gd22
-rw-r--r--Archipelago/load.gd76
-rw-r--r--Archipelago/mypainting.gd99
-rw-r--r--Archipelago/paintingdata.gd88
-rw-r--r--data/LL1.yaml2
5 files changed, 284 insertions, 3 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index c5f1488..79313b2 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -42,12 +42,15 @@ var _mentioned_doors = []
42var _painting_ids_by_item = {} 42var _painting_ids_by_item = {}
43var _mentioned_paintings = [] 43var _mentioned_paintings = []
44var _panel_ids_by_location = {} 44var _panel_ids_by_location = {}
45var _paintings = {}
46var _paintings_mapping = {}
45var _localdata_file = "" 47var _localdata_file = ""
46var _death_link = false 48var _death_link = false
47var _victory_condition = 0 # THE END, THE MASTER 49var _victory_condition = 0 # THE END, THE MASTER
48var _door_shuffle = false 50var _door_shuffle = false
49var _color_shuffle = false 51var _color_shuffle = false
50var _panel_shuffle = 0 # none, rearrange 52var _panel_shuffle = 0 # none, rearrange
53var _painting_shuffle = false
51var _slot_seed = 0 54var _slot_seed = 0
52 55
53var _map_loaded = false 56var _map_loaded = false
@@ -162,6 +165,8 @@ func _on_data():
162 _mentioned_paintings.append(painting) 165 _mentioned_paintings.append(painting)
163 if _slot_data.has("panel_ids_by_location_id"): 166 if _slot_data.has("panel_ids_by_location_id"):
164 _panel_ids_by_location = _slot_data["panel_ids_by_location_id"] 167 _panel_ids_by_location = _slot_data["panel_ids_by_location_id"]
168 if _slot_data.has("paintings"):
169 _paintings = _slot_data["paintings"]
165 170
166 _death_link = _slot_data.has("death_link") and _slot_data["death_link"] 171 _death_link = _slot_data.has("death_link") and _slot_data["death_link"]
167 if _death_link: 172 if _death_link:
@@ -173,10 +178,14 @@ func _on_data():
173 _color_shuffle = _slot_data["shuffle_colors"] 178 _color_shuffle = _slot_data["shuffle_colors"]
174 if _slot_data.has("shuffle_doors"): 179 if _slot_data.has("shuffle_doors"):
175 _door_shuffle = (_slot_data["shuffle_doors"] > 0) 180 _door_shuffle = (_slot_data["shuffle_doors"] > 0)
181 if _slot_data.has("shuffle_paintings"):
182 _painting_shuffle = (_slot_data["shuffle_paintings"] > 0)
176 if _slot_data.has("shuffle_panels"): 183 if _slot_data.has("shuffle_panels"):
177 _panel_shuffle = _slot_data["shuffle_panels"] 184 _panel_shuffle = _slot_data["shuffle_panels"]
178 if _slot_data.has("seed"): 185 if _slot_data.has("seed"):
179 _slot_seed = _slot_data["seed"] 186 _slot_seed = _slot_data["seed"]
187 if _slot_data.has("painting_entrance_to_exit"):
188 _paintings_mapping = _slot_data["painting_entrance_to_exit"]
180 189
181 _localdata_file = "user://archipelago/%s_%d" % [_seed, _slot] 190 _localdata_file = "user://archipelago/%s_%d" % [_seed, _slot]
182 var ap_file = File.new() 191 var ap_file = File.new()
@@ -411,9 +420,18 @@ func processItem(item, index, from):
411 doorsNode.get_node(door_id).openDoor() 420 doorsNode.get_node(door_id).openDoor()
412 421
413 if _painting_ids_by_item.has(stringified): 422 if _painting_ids_by_item.has(stringified):
414 var paintingsNode = get_tree().get_root().get_node("Spatial/Decorations/Paintings") 423 var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings")
424 var fake_parent_node = get_tree().get_root().get_node("Spatial/AP_Paintings")
425
415 for painting_id in _painting_ids_by_item[stringified]: 426 for painting_id in _painting_ids_by_item[stringified]:
416 paintingsNode.get_node(painting_id).movePainting() 427 var painting_node = real_parent_node.get_node_or_null(painting_id)
428 if painting_node != null:
429 painting_node.movePainting()
430
431 if _painting_shuffle:
432 painting_node = fake_parent_node.get_node_or_null(painting_id)
433 if painting_node != null:
434 painting_node.get_node("Script").movePainting()
417 435
418 # Handle progressively opening up the tower. 436 # Handle progressively opening up the tower.
419 if _item_name_to_id["Progressive Orange Tower"] == item and _tower_floors < orange_tower.size(): 437 if _item_name_to_id["Progressive Orange Tower"] == item and _tower_floors < orange_tower.size():
diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 47f51a6..3c6b31c 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd
@@ -90,6 +90,52 @@ func _load():
90 target_panel_node.text = source["hint"] 90 target_panel_node.text = source["hint"]
91 target_panel_node.answer = source["answer"] 91 target_panel_node.answer = source["answer"]
92 92
93 # Randomize the paintings, if necessary.
94 if apclient._painting_shuffle:
95 var pd_script = ResourceLoader.load("user://maps/Archipelago/paintingdata.gd")
96 var pd = pd_script.new()
97 pd.set_name("AP_Paintings")
98 self.add_child(pd)
99
100 var all_paintings = pd.kALL_PAINTINGS
101
102 var classes = {}
103 for painting in apclient._paintings_mapping.values():
104 if not classes.has(painting):
105 var i = rng.randi_range(0, all_paintings.size() - 1)
106 var chosen = all_paintings[i]
107 classes[painting] = chosen
108 all_paintings.remove(i)
109
110 var randomized = []
111 for painting in apclient._paintings_mapping.values():
112 var painting_class = classes[painting]
113 instantiate_painting(painting, painting_class)
114 randomized.append(painting)
115
116 for source_painting in apclient._paintings_mapping.keys():
117 var target_painting = apclient._paintings_mapping[source_painting]
118 var painting_class = classes[target_painting]
119 var new_source = instantiate_painting(source_painting, painting_class)
120 new_source.target = pd.get_node(target_painting).get_node("Script")
121 randomized.append(source_painting)
122
123 var remaining_size = classes.size() / 2
124 if remaining_size >= all_paintings.size():
125 remaining_size = all_paintings.size()
126 var remaining = []
127 for i in range(0, remaining_size):
128 var j = rng.randi_range(0, all_paintings.size() - 1)
129 remaining.append(all_paintings[j])
130 all_paintings.remove(j)
131
132 for painting in apclient._paintings.keys():
133 if randomized.has(painting):
134 continue
135
136 var chosen_painting = remaining[rng.randi_range(0, remaining.size() - 1)]
137 instantiate_painting(painting, chosen_painting)
138
93 # Attach a script to every panel so that we can do things like conditionally 139 # Attach a script to every panel so that we can do things like conditionally
94 # disable them. 140 # disable them.
95 var panel_script = ResourceLoader.load("user://maps/Archipelago/panel.gd") 141 var panel_script = ResourceLoader.load("user://maps/Archipelago/panel.gd")
@@ -130,3 +176,33 @@ func _load():
130 176
131func sort_by_link(a, b): 177func sort_by_link(a, b):
132 return a["link"] < b["link"] 178 return a["link"] < b["link"]
179
180
181func instantiate_painting(name, scene):
182 var apclient = global.get_node("Archipelago")
183
184 var scene_path = "res://nodes/paintings/%s.tscn" % scene
185 var painting_scene = load(scene_path)
186 var new_painting = painting_scene.instance()
187 new_painting.set_name(name)
188
189 var old_painting = self.get_node("Decorations/Paintings").get_node(name)
190 new_painting.translation = old_painting.translation
191 new_painting.rotation = old_painting.rotation
192
193 var mypainting_script = ResourceLoader.load("user://maps/Archipelago/mypainting.gd")
194 var mps_inst = mypainting_script.new()
195 mps_inst.set_name("Script")
196
197 var pconfig = apclient._paintings[name]
198 mps_inst.orientation = pconfig["orientation"]
199 if pconfig["move"]:
200 mps_inst.move = true
201 mps_inst.move_to_x = old_painting.move_to_x
202 mps_inst.move_to_z = old_painting.move_to_z
203 mps_inst.key = old_painting.key
204
205 self.get_node("AP_Paintings").add_child(new_painting)
206 new_painting.add_child(mps_inst)
207 old_painting.queue_free()
208 return mps_inst
diff --git a/Archipelago/mypainting.gd b/Archipelago/mypainting.gd new file mode 100644 index 0000000..5e9c703 --- /dev/null +++ b/Archipelago/mypainting.gd
@@ -0,0 +1,99 @@
1extends Spatial
2
3var orientation = "" # north, south, east, west
4var move = false
5var move_to_x
6var move_to_z
7var target = null
8var key
9
10
11func _ready():
12 var _connected = get_tree().get_root().get_node("Spatial/player").connect(
13 "looked_at", self, "_looked_at"
14 )
15 if move:
16 key.get_node("Viewport/GUI/Panel/TextEdit").connect(
17 "answer_correct", self, "_answer_correct"
18 )
19
20
21func _answer_correct():
22 var apclient = global.get_node("Archipelago")
23 if not apclient._door_shuffle or apclient.paintingIsVanilla(self.get_parent().name):
24 movePainting()
25
26
27func movePainting():
28 self.get_parent().translation.x = move_to_x
29 self.get_parent().translation.z = move_to_z
30
31
32func _looked_at(body, painting):
33 if (
34 target != null
35 and body.is_in_group("player")
36 and (painting.get_name() == self.get_parent().get_name())
37 ):
38 var target_dir = _dir_to_int(target.orientation)
39 var source_dir = _dir_to_int(orientation)
40 var rotate = target_dir - source_dir
41 if rotate < 0:
42 rotate += 4
43 rotate *= 90
44
45 var target_painting = target.get_parent()
46
47 # this is ACW
48 if rotate == 0:
49 body.translation.x = (
50 target_painting.translation.x + (body.translation.x - painting.translation.x)
51 )
52 body.translation.y = (
53 target_painting.translation.y + (body.translation.y - painting.translation.y)
54 )
55 body.translation.z = (
56 target_painting.translation.z + (body.translation.z - painting.translation.z)
57 )
58 elif rotate == 180:
59 body.translation.x = (
60 target_painting.translation.x - (body.translation.x - painting.translation.x)
61 )
62 body.translation.y = (
63 target_painting.translation.y + (body.translation.y - painting.translation.y)
64 )
65 body.translation.z = (
66 target_painting.translation.z - (body.translation.z - painting.translation.z)
67 )
68 body.rotate_y(PI)
69 body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI)
70 elif rotate == 90:
71 var diff_x = body.translation.x - painting.translation.x
72 var diff_y = body.translation.y - painting.translation.y
73 var diff_z = body.translation.z - painting.translation.z
74 body.translation.x = target_painting.translation.x + diff_z
75 body.translation.y = target_painting.translation.y + diff_y
76 body.translation.z = target_painting.translation.z - diff_x
77 body.rotate_y(PI / 2)
78 body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI / 2)
79 elif rotate == 270:
80 var diff_x = body.translation.x - painting.translation.x
81 var diff_y = body.translation.y - painting.translation.y
82 var diff_z = body.translation.z - painting.translation.z
83 body.translation.x = target_painting.translation.x - diff_z
84 body.translation.y = target_painting.translation.y + diff_y
85 body.translation.z = target_painting.translation.z + diff_x
86 body.rotate_y(3 * PI / 2)
87 body.velocity = body.velocity.rotated(Vector3(0, 1, 0), 3 * PI / 2)
88
89
90func _dir_to_int(dir):
91 if dir == "north":
92 return 0
93 elif dir == "west":
94 return 1
95 elif dir == "south":
96 return 2
97 elif dir == "east":
98 return 3
99 return 4
diff --git a/Archipelago/paintingdata.gd b/Archipelago/paintingdata.gd new file mode 100644 index 0000000..0cbeac2 --- /dev/null +++ b/Archipelago/paintingdata.gd
@@ -0,0 +1,88 @@
1extends Node
2
3const kALL_PAINTINGS = [
4 "arrows",
5 "beach",
6 "bg_bg1",
7 "bg_bg2",
8 "bg_bg3",
9 "bg_bg4",
10 "bg_bg5",
11 "bg_bg6",
12 "bg_bg7",
13 "bg_bg8",
14 "bg_bookshelf",
15 "bg_candle",
16 "bg_colin",
17 "bg_cooking",
18 "bg_egg",
19 "bg_fish",
20 "bg_fourth",
21 "bg_gene",
22 "bg_knight",
23 "bg_margret",
24 "bg_nose",
25 "bg_pearson",
26 "bg_scorpion",
27 "bg_stakeout",
28 "bg_waves",
29 "blueman",
30 "boxes",
31 "catlike",
32 "cherry",
33 "clock",
34 "colors",
35 "crep",
36 "crown",
37 "egg",
38 "eight",
39 "electrons",
40 "emmy",
41 "ether",
42 "eyes",
43 "eyesyellow",
44 "flower",
45 "fruitbowl",
46 "garden",
47 "gardenexploded",
48 "hatkirby",
49 "hatman",
50 "hi",
51 "hi_solved",
52 "icy",
53 "ig_note",
54 "ig_rose",
55 "kiwi",
56 "knot",
57 "map",
58 "maze",
59 "mittens",
60 "ninjonicx",
61 "ninjonicx_square",
62 "noka",
63 "ntwiles",
64 "owl",
65 "panda",
66 "pattern_gold",
67 "pattern_gray",
68 "pattern_icely",
69 "pattern_purple",
70 "pattern_solar",
71 "pencil",
72 "rainbow",
73 "redman",
74 "rever",
75 "rm_tower",
76 "rubrica",
77 "samswine",
78 "smile",
79 "smile_red",
80 "snowman",
81 "symmetry",
82 "symmetry_2",
83 "taiji",
84 "tree",
85 "undalevein",
86 "yinyang",
87 "zombie"
88]
diff --git a/data/LL1.yaml b/data/LL1.yaml index 8c9bea2..88eb3f6 100644 --- a/data/LL1.yaml +++ b/data/LL1.yaml
@@ -2294,7 +2294,7 @@
2294 tag: topyellow 2294 tag: topyellow
2295# Forbid these three for now because one is hidden 2295# Forbid these three for now because one is hidden
2296- id: Chemistry Room/Panel_open 2296- id: Chemistry Room/Panel_open
2297 color: black 2297 color: white
2298 tag: forbid 2298 tag: forbid
2299- id: Chemistry Room/Panel_close 2299- id: Chemistry Room/Panel_close
2300 color: black 2300 color: black