diff options
-rw-r--r-- | Archipelago/client.gd | 49 | ||||
-rw-r--r-- | Archipelago/load.gd | 55 | ||||
-rw-r--r-- | util/generate_gamedata.rb | 215 |
3 files changed, 224 insertions, 95 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index a816c42..a4ffb1b 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -73,12 +73,6 @@ var _players = [] | |||
73 | var _player_name_by_slot = {} | 73 | var _player_name_by_slot = {} |
74 | var _checked_locations = [] | 74 | var _checked_locations = [] |
75 | var _slot_data = {} | 75 | var _slot_data = {} |
76 | var _door_ids_by_item = {} | ||
77 | var _mentioned_doors = [] | ||
78 | var _painting_ids_by_item = {} | ||
79 | var _mentioned_paintings = [] | ||
80 | var _panel_ids_by_location = {} | ||
81 | var _paintings = {} | ||
82 | var _paintings_mapping = {} | 76 | var _paintings_mapping = {} |
83 | var _localdata_file = "" | 77 | var _localdata_file = "" |
84 | var _death_link = false | 78 | var _death_link = false |
@@ -230,25 +224,6 @@ func _on_data(): | |||
230 | for player in _players: | 224 | for player in _players: |
231 | _player_name_by_slot[player["slot"]] = player["alias"] | 225 | _player_name_by_slot[player["slot"]] = player["alias"] |
232 | 226 | ||
233 | if _slot_data.has("door_ids_by_item_id"): | ||
234 | _door_ids_by_item = _slot_data["door_ids_by_item_id"] | ||
235 | |||
236 | _mentioned_doors = [] | ||
237 | for item in _door_ids_by_item.values(): | ||
238 | for door in item: | ||
239 | _mentioned_doors.append(door) | ||
240 | if _slot_data.has("painting_ids_by_item_id"): | ||
241 | _painting_ids_by_item = _slot_data["painting_ids_by_item_id"] | ||
242 | |||
243 | _mentioned_paintings = [] | ||
244 | for item in _painting_ids_by_item.values(): | ||
245 | for painting in item: | ||
246 | _mentioned_paintings.append(painting) | ||
247 | if _slot_data.has("panel_ids_by_location_id"): | ||
248 | _panel_ids_by_location = _slot_data["panel_ids_by_location_id"] | ||
249 | if _slot_data.has("paintings"): | ||
250 | _paintings = _slot_data["paintings"] | ||
251 | |||
252 | _death_link = _slot_data.has("death_link") and _slot_data["death_link"] | 227 | _death_link = _slot_data.has("death_link") and _slot_data["death_link"] |
253 | if _death_link: | 228 | if _death_link: |
254 | sendConnectUpdate(["DeathLink"]) | 229 | sendConnectUpdate(["DeathLink"]) |
@@ -260,7 +235,7 @@ func _on_data(): | |||
260 | if _slot_data.has("shuffle_doors"): | 235 | if _slot_data.has("shuffle_doors"): |
261 | _door_shuffle = (_slot_data["shuffle_doors"] > 0) | 236 | _door_shuffle = (_slot_data["shuffle_doors"] > 0) |
262 | if _slot_data.has("shuffle_paintings"): | 237 | if _slot_data.has("shuffle_paintings"): |
263 | _painting_shuffle = (_slot_data["shuffle_paintings"] > 0) | 238 | _painting_shuffle = _slot_data["shuffle_paintings"] |
264 | if _slot_data.has("shuffle_panels"): | 239 | if _slot_data.has("shuffle_panels"): |
265 | _panel_shuffle = _slot_data["shuffle_panels"] | 240 | _panel_shuffle = _slot_data["shuffle_panels"] |
266 | if _slot_data.has("seed"): | 241 | if _slot_data.has("seed"): |
@@ -585,17 +560,21 @@ func processItem(item, index, from, flags): | |||
585 | 560 | ||
586 | global._print(item) | 561 | global._print(item) |
587 | 562 | ||
588 | var stringified = String(item) | 563 | var gamedata = $Gamedata |
589 | if _door_ids_by_item.has(stringified): | 564 | var item_name = "Unknown" |
565 | if _item_id_to_name.has(item): | ||
566 | item_name = _item_id_to_name[item] | ||
567 | |||
568 | if gamedata.door_ids_by_item_id.has(item_name): | ||
590 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") | 569 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") |
591 | for door_id in _door_ids_by_item[stringified]: | 570 | for door_id in gamedata.door_ids_by_item_id[item_name]: |
592 | doorsNode.get_node(door_id).openDoor() | 571 | doorsNode.get_node(door_id).openDoor() |
593 | 572 | ||
594 | if _painting_ids_by_item.has(stringified): | 573 | if gamedata.painting_ids_by_item_id.has(item_name): |
595 | var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings") | 574 | var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings") |
596 | var fake_parent_node = get_tree().get_root().get_node_or_null("Spatial/AP_Paintings") | 575 | var fake_parent_node = get_tree().get_root().get_node_or_null("Spatial/AP_Paintings") |
597 | 576 | ||
598 | for painting_id in _painting_ids_by_item[stringified]: | 577 | for painting_id in gamedata.painting_ids_by_item_id[item_name]: |
599 | var painting_node = real_parent_node.get_node_or_null(painting_id) | 578 | var painting_node = real_parent_node.get_node_or_null(painting_id) |
600 | if painting_node != null: | 579 | if painting_node != null: |
601 | painting_node.movePainting() | 580 | painting_node.movePainting() |
@@ -606,10 +585,6 @@ func processItem(item, index, from, flags): | |||
606 | painting_node.get_node("Script").movePainting() | 585 | painting_node.get_node("Script").movePainting() |
607 | 586 | ||
608 | # Handle progressive items. | 587 | # Handle progressive items. |
609 | var item_name = "Unknown" | ||
610 | if _item_id_to_name.has(item): | ||
611 | item_name = _item_id_to_name[item] | ||
612 | |||
613 | if item_name in progressive_items.keys(): | 588 | if item_name in progressive_items.keys(): |
614 | if not item_name in _progressive_progress: | 589 | if not item_name in _progressive_progress: |
615 | _progressive_progress[item_name] = 0 | 590 | _progressive_progress[item_name] = 0 |
@@ -659,11 +634,11 @@ func processItem(item, index, from, flags): | |||
659 | 634 | ||
660 | 635 | ||
661 | func doorIsVanilla(door): | 636 | func doorIsVanilla(door): |
662 | return !_mentioned_doors.has(door) | 637 | return !$Gamedata.mentioned_doors.has(door) |
663 | 638 | ||
664 | 639 | ||
665 | func paintingIsVanilla(painting): | 640 | func paintingIsVanilla(painting): |
666 | return !_mentioned_paintings.has(painting) | 641 | return !$Gamedata.mentioned_paintings.has(painting) |
667 | 642 | ||
668 | 643 | ||
669 | func evaluateSolvability(): | 644 | func evaluateSolvability(): |
diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 0157395..95f0fb8 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd | |||
@@ -93,27 +93,31 @@ func _load(): | |||
93 | 93 | ||
94 | # This is the best time to create the location nodes, since the map is now | 94 | # This is the best time to create the location nodes, since the map is now |
95 | # loaded but the panels haven't been solved from the save file yet. | 95 | # loaded but the panels haven't been solved from the save file yet. |
96 | var gamedata = apclient.get_node("Gamedata") | ||
96 | var panels_parent = self.get_node("Panels") | 97 | var panels_parent = self.get_node("Panels") |
97 | var location_script = ResourceLoader.load("user://maps/Archipelago/location.gd") | 98 | var location_script = ResourceLoader.load("user://maps/Archipelago/location.gd") |
98 | for location_id in apclient._panel_ids_by_location.keys(): | 99 | for location_id in gamedata.panel_ids_by_location_id.keys(): |
99 | var location = location_script.new() | 100 | if apclient._location_name_to_id.has(location_id): |
100 | location.ap_id = int(location_id) | 101 | var location = location_script.new() |
101 | location.name = "AP_location_" + location.ap_id | 102 | location.ap_id = int(apclient._location_name_to_id[location_id]) |
102 | self.add_child(location) | 103 | location.name = "AP_location_%d" % location.ap_id |
103 | 104 | self.add_child(location) | |
104 | var panels = apclient._panel_ids_by_location[String(location.ap_id)] | 105 | |
105 | location.total = panels.size() | 106 | var panels = gamedata.panel_ids_by_location_id[location_id] |
106 | 107 | location.total = panels.size() | |
107 | for panel in panels: | 108 | |
108 | var that_panel | 109 | for panel in panels: |
109 | if panel.begins_with("EndPanel"): | 110 | var that_panel |
110 | that_panel = self.get_node("Decorations").get_node(panel) | 111 | if panel.begins_with("EndPanel"): |
111 | else: | 112 | that_panel = self.get_node("Decorations").get_node(panel) |
112 | that_panel = panels_parent.get_node(panel) | 113 | else: |
113 | 114 | that_panel = panels_parent.get_node(panel) | |
114 | that_panel.get_node("Viewport/GUI/Panel/TextEdit").connect( | 115 | |
115 | "answer_correct", location, "handle_correct" | 116 | that_panel.get_node("Viewport/GUI/Panel/TextEdit").connect( |
116 | ) | 117 | "answer_correct", location, "handle_correct" |
118 | ) | ||
119 | else: | ||
120 | global._print("Could not find location ID for %s" % location_id) | ||
117 | 121 | ||
118 | # HOT CRUSTS should be at eye-level, have a yellow block behind it, and | 122 | # HOT CRUSTS should be at eye-level, have a yellow block behind it, and |
119 | # not vanish when solved. | 123 | # not vanish when solved. |
@@ -133,8 +137,6 @@ func _load(): | |||
133 | var rng = RandomNumberGenerator.new() | 137 | var rng = RandomNumberGenerator.new() |
134 | rng.seed = apclient._slot_seed | 138 | rng.seed = apclient._slot_seed |
135 | 139 | ||
136 | var gamedata = apclient.get_node("Gamedata") | ||
137 | |||
138 | # Remove opaque wall in front of FOURTH. | 140 | # Remove opaque wall in front of FOURTH. |
139 | set_gridmap_tile(-71.5, 1.5, -64.5, "MeshInstance18") | 141 | set_gridmap_tile(-71.5, 1.5, -64.5, "MeshInstance18") |
140 | 142 | ||
@@ -309,7 +311,7 @@ func _load(): | |||
309 | remaining.append(all_paintings[j]) | 311 | remaining.append(all_paintings[j]) |
310 | all_paintings.remove(j) | 312 | all_paintings.remove(j) |
311 | 313 | ||
312 | for painting in apclient._paintings.keys(): | 314 | for painting in gamedata.paintings.keys(): |
313 | if randomized.has(painting): | 315 | if randomized.has(painting): |
314 | continue | 316 | continue |
315 | 317 | ||
@@ -364,7 +366,11 @@ func _load(): | |||
364 | # disable them. | 366 | # disable them. |
365 | var panel_script = ResourceLoader.load("user://maps/Archipelago/panel.gd") | 367 | var panel_script = ResourceLoader.load("user://maps/Archipelago/panel.gd") |
366 | for panel in gamedata.panels: | 368 | for panel in gamedata.panels: |
367 | var panel_node = panels_parent.get_node(panel["id"]) | 369 | var panel_node |
370 | if panel["id"].begins_with("EndPanel"): | ||
371 | panel_node = self.get_node("Decorations").get_node(panel["id"]) | ||
372 | else: | ||
373 | panel_node = panels_parent.get_node(panel["id"]) | ||
368 | var script_instance = panel_script.new() | 374 | var script_instance = panel_script.new() |
369 | script_instance.name = "AP_Panel" | 375 | script_instance.name = "AP_Panel" |
370 | script_instance.data = panel | 376 | script_instance.data = panel |
@@ -445,7 +451,8 @@ func instantiate_painting(name, scene): | |||
445 | var mps_inst = mypainting_script.new() | 451 | var mps_inst = mypainting_script.new() |
446 | mps_inst.set_name("Script") | 452 | mps_inst.set_name("Script") |
447 | 453 | ||
448 | var pconfig = apclient._paintings[name] | 454 | var gamedata = apclient.get_node("Gamedata") |
455 | var pconfig = gamedata.paintings[name] | ||
449 | mps_inst.orientation = pconfig["orientation"] | 456 | mps_inst.orientation = pconfig["orientation"] |
450 | if pconfig["move"]: | 457 | if pconfig["move"]: |
451 | mps_inst.move = true | 458 | mps_inst.move = true |
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index 3b57f76..bf8e3ae 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -1,46 +1,193 @@ | |||
1 | require 'set' | ||
1 | require 'yaml' | 2 | require 'yaml' |
2 | 3 | ||
3 | configpath = ARGV[0] | 4 | configpath = ARGV[0] |
4 | outputpath = ARGV[1] | 5 | outputpath = ARGV[1] |
5 | 6 | ||
7 | panel_to_id = {} | ||
8 | door_groups = {} | ||
9 | |||
10 | panel_output = [] | ||
11 | door_ids_by_item_id = {} | ||
12 | painting_ids_by_item_id = {} | ||
13 | panel_ids_by_location_id = {} | ||
14 | mentioned_doors = Set[] | ||
15 | mentioned_paintings = Set[] | ||
16 | painting_output = {} | ||
17 | |||
6 | config = YAML.load_file(configpath) | 18 | config = YAML.load_file(configpath) |
7 | output = config.map do |panel| | 19 | config.each do |room_name, room_data| |
8 | ret = panel | 20 | if room_data.include? "panels" |
9 | if ret["color"].kind_of? String | 21 | room_data["panels"].each do |panel_name, panel| |
10 | ret["color"] = [ret["color"]] | 22 | full_name = "#{room_name} - #{panel_name}" |
11 | end | 23 | panel_to_id[full_name] = panel["id"] |
12 | ret | 24 | |
13 | end.map do |panel| | 25 | ret = {} |
14 | ret = {} | 26 | ret["id"] = "\"#{panel["id"]}\"" |
15 | ret["id"] = "\"#{panel["id"]}\"" | 27 | if panel.include? "colors" |
16 | ret["color"] = "[\"" + panel["color"].join("\",\"") + "\"]" | 28 | if panel["colors"].kind_of? String |
17 | ret["tag"] = "\"#{panel["tag"]}\"" | 29 | ret["color"] = "[\"#{panel["colors"]}\"]" |
18 | if panel.include? "subtag" | 30 | else |
19 | ret["subtag"] = "\"#{panel["subtag"]}\"" | 31 | ret["color"] = "[\"" + panel["colors"].join("\",\"") + "\"]" |
20 | end | 32 | end |
21 | if panel.include? "link" | 33 | else |
22 | ret["link"] = "\"#{panel["link"]}\"" | 34 | ret["color"] = "[\"white\"]" |
35 | end | ||
36 | ret["tag"] = "\"#{panel["tag"]}\"" | ||
37 | if panel.include? "subtag" | ||
38 | ret["subtag"] = "\"#{panel["subtag"]}\"" | ||
39 | end | ||
40 | if panel.include? "link" | ||
41 | ret["link"] = "\"#{panel["link"]}\"" | ||
42 | end | ||
43 | if panel.include? "copy_to_sign" | ||
44 | copytos = [] | ||
45 | if panel["copy_to_sign"].kind_of? String | ||
46 | copytos = [panel["copy_to_sign"]] | ||
47 | else | ||
48 | copytos = panel["copy_to_sign"] | ||
49 | end | ||
50 | ret["copy_to_sign"] = "[\"" + copytos.join("\",\"") + "\"]" | ||
51 | end | ||
52 | if panel.include? "achievement" | ||
53 | ret["achievement"] = "\"#{panel["achievement"]}\"" | ||
54 | end | ||
55 | panel_output << ret | ||
56 | |||
57 | if panel.include? "check" and panel["check"] | ||
58 | panel_ids_by_location_id[full_name] = [panel["id"]] | ||
59 | end | ||
60 | end | ||
23 | end | 61 | end |
24 | if panel.include? "copy_to_sign" | 62 | |
25 | copytos = [] | 63 | if room_data.include? "paintings" |
26 | if panel["copy_to_sign"].kind_of? String | 64 | room_data["paintings"].each do |painting| |
27 | copytos = [panel["copy_to_sign"]] | 65 | painting_output[painting["id"]] = painting |
28 | else | ||
29 | copytos = panel["copy_to_sign"] | ||
30 | end | 66 | end |
31 | ret["copy_to_sign"] = "[\"" + copytos.join("\",\"") + "\"]" | ||
32 | end | 67 | end |
33 | if panel.include? "achievement" | 68 | end |
34 | ret["achievement"] = "\"#{panel["achievement"]}\"" | 69 | |
70 | config.each do |room_name, room_data| | ||
71 | if room_data.include? "doors" | ||
72 | room_data["doors"].each do |door_name, door| | ||
73 | full_name = "#{room_name} - #{door_name}" | ||
74 | |||
75 | if not (door.include? "skip_location" and door["skip_location"]) and | ||
76 | not (door.include? "event" and door["event"]) and | ||
77 | door.include? "panels" then | ||
78 | |||
79 | chosen_name = full_name | ||
80 | if door.include? "location_name" | ||
81 | chosen_name = door["location_name"] | ||
82 | else | ||
83 | panels_per_room = {} | ||
84 | door["panels"].each do |panel_identifier| | ||
85 | if panel_identifier.kind_of? String | ||
86 | panels_per_room[room_name] ||= [] | ||
87 | panels_per_room[room_name] << panel_identifier | ||
88 | else | ||
89 | panels_per_room[panel_identifier["room"]] ||= [] | ||
90 | panels_per_room[panel_identifier["room"]] << panel_identifier["panel"] | ||
91 | end | ||
92 | end | ||
93 | |||
94 | chosen_name = panels_per_room.map do |room_name, panels| | ||
95 | room_name + " - " + panels.join(", ") | ||
96 | end.join(" and ") | ||
97 | end | ||
98 | |||
99 | panel_ids_by_location_id[chosen_name] = door["panels"].map do |panel_identifier| | ||
100 | other_name = "" | ||
101 | if panel_identifier.kind_of? String | ||
102 | other_name = "#{room_name} - #{panel_identifier}" | ||
103 | else | ||
104 | other_name = "#{panel_identifier["room"]} - #{panel_identifier["panel"]}" | ||
105 | end | ||
106 | panel_to_id[other_name] | ||
107 | end | ||
108 | end | ||
109 | |||
110 | if not (door.include? "skip_item" and door["skip_item"]) and | ||
111 | not (door.include? "event" and door["event"]) then | ||
112 | |||
113 | chosen_name = full_name | ||
114 | if door.include? "item_name" | ||
115 | chosen_name = door["item_name"] | ||
116 | end | ||
117 | |||
118 | if door.include? "id" | ||
119 | internal_door_ids = [] | ||
120 | if door["id"].kind_of? String | ||
121 | internal_door_ids = [door["id"]] | ||
122 | else | ||
123 | internal_door_ids = door["id"] | ||
124 | end | ||
125 | |||
126 | if door.include? "group" | ||
127 | door_groups[door["group"]] ||= Set[] | ||
128 | door_groups[door["group"]].merge(internal_door_ids) | ||
129 | end | ||
130 | |||
131 | door_ids_by_item_id[chosen_name] = internal_door_ids | ||
132 | mentioned_doors.merge(internal_door_ids) | ||
133 | end | ||
134 | |||
135 | if door.include? "painting_id" | ||
136 | internal_painting_ids = [] | ||
137 | if door["painting_id"].kind_of? String | ||
138 | internal_painting_ids = [door["painting_id"]] | ||
139 | else | ||
140 | internal_painting_ids = door["painting_id"] | ||
141 | end | ||
142 | |||
143 | painting_ids_by_item_id[chosen_name] = internal_painting_ids | ||
144 | mentioned_paintings.merge(internal_painting_ids) | ||
145 | end | ||
146 | end | ||
147 | end | ||
35 | end | 148 | end |
36 | ret | 149 | end |
37 | end.map do |panel| | ||
38 | "{" + panel.to_a.map do |element| | ||
39 | "\"#{element[0]}\":#{element[1]}" | ||
40 | end.join(",") + "}" | ||
41 | end.join(",") | ||
42 | 150 | ||
43 | header = "extends Node\n\nvar panels = [" | 151 | door_groups.each do |group_name, door_ids| |
44 | footer = "]" | 152 | door_ids_by_item_id[group_name] = door_ids.to_a |
153 | end | ||
45 | 154 | ||
46 | File.write(outputpath, header + output + footer) \ No newline at end of file | 155 | File.open(outputpath, "w") do |f| |
156 | f.write "extends Node\n\nvar panels = [" | ||
157 | f.write(panel_output.map do |panel| | ||
158 | "{" + panel.to_a.map do |element| | ||
159 | "\"#{element[0]}\":#{element[1]}" | ||
160 | end.join(",") + "}" | ||
161 | end.join(",")) | ||
162 | f.write "]\nvar door_ids_by_item_id = {" | ||
163 | f.write(door_ids_by_item_id.map do |item_id, door_ids| | ||
164 | "\"#{item_id}\":[" + door_ids.map do |door_id| | ||
165 | "\"#{door_id}\"" | ||
166 | end.join(",") + "]" | ||
167 | end.join(",")) | ||
168 | f.write "}\nvar painting_ids_by_item_id = {" | ||
169 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| | ||
170 | "\"#{item_id}\":[" + painting_ids.map do |painting_id| | ||
171 | "\"#{painting_id}\"" | ||
172 | end.join(",") + "]" | ||
173 | end.join(",")) | ||
174 | f.write "}\nvar panel_ids_by_location_id = {" | ||
175 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | ||
176 | "\"#{location_id}\":[" + panel_ids.map do |panel_id| | ||
177 | "\"#{panel_id}\"" | ||
178 | end.join(",") + "]" | ||
179 | end.join(",")) | ||
180 | f.write "}\nvar mentioned_doors = [" | ||
181 | f.write(mentioned_doors.map do |door_id| | ||
182 | "\"#{door_id}\"" | ||
183 | end.join(",")) | ||
184 | f.write "]\nvar mentioned_paintings = [" | ||
185 | f.write(mentioned_paintings.map do |painting_id| | ||
186 | "\"#{painting_id}\"" | ||
187 | end.join(",")) | ||
188 | f.write "]\nvar paintings = {" | ||
189 | f.write(painting_output.map do |painting_id, painting| | ||
190 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | ||
191 | end.join(",")) | ||
192 | f.write "}" | ||
193 | end | ||