diff options
-rw-r--r-- | Archipelago/client.gd | 8 | ||||
-rw-r--r-- | Archipelago/load.gd | 41 | ||||
-rw-r--r-- | util/generate_gamedata.rb | 65 |
3 files changed, 48 insertions, 66 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 9f15506..068f300 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -588,16 +588,16 @@ func processItem(item, index, from, flags): | |||
588 | if _item_id_to_name.has(item): | 588 | if _item_id_to_name.has(item): |
589 | item_name = _item_id_to_name[item] | 589 | item_name = _item_id_to_name[item] |
590 | 590 | ||
591 | if gamedata.door_ids_by_item_id.has(item_name): | 591 | if gamedata.door_ids_by_item_id.has(int(item)): |
592 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") | 592 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") |
593 | for door_id in gamedata.door_ids_by_item_id[item_name]: | 593 | for door_id in gamedata.door_ids_by_item_id[int(item)]: |
594 | doorsNode.get_node(door_id).openDoor() | 594 | doorsNode.get_node(door_id).openDoor() |
595 | 595 | ||
596 | if gamedata.painting_ids_by_item_id.has(item_name): | 596 | if gamedata.painting_ids_by_item_id.has(int(item)): |
597 | var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings") | 597 | var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings") |
598 | var fake_parent_node = get_tree().get_root().get_node_or_null("Spatial/AP_Paintings") | 598 | var fake_parent_node = get_tree().get_root().get_node_or_null("Spatial/AP_Paintings") |
599 | 599 | ||
600 | for painting_id in gamedata.painting_ids_by_item_id[item_name]: | 600 | for painting_id in gamedata.painting_ids_by_item_id[int(item)]: |
601 | var painting_node = real_parent_node.get_node_or_null(painting_id) | 601 | var painting_node = real_parent_node.get_node_or_null(painting_id) |
602 | if painting_node != null: | 602 | if painting_node != null: |
603 | painting_node.movePainting() | 603 | painting_node.movePainting() |
diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 876910b..d2977dd 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd | |||
@@ -114,28 +114,25 @@ func _load(): | |||
114 | var panels_parent = self.get_node("Panels") | 114 | var panels_parent = self.get_node("Panels") |
115 | var location_script = ResourceLoader.load("user://maps/Archipelago/location.gd") | 115 | var location_script = ResourceLoader.load("user://maps/Archipelago/location.gd") |
116 | for location_id in gamedata.panel_ids_by_location_id.keys(): | 116 | for location_id in gamedata.panel_ids_by_location_id.keys(): |
117 | if apclient._location_name_to_id.has(location_id): | 117 | var location = location_script.new() |
118 | var location = location_script.new() | 118 | location.ap_id = location_id |
119 | location.ap_id = int(apclient._location_name_to_id[location_id]) | 119 | location.name = "AP_location_%d" % location.ap_id |
120 | location.name = "AP_location_%d" % location.ap_id | 120 | location.classification = gamedata.classification_by_location_id[location_id] |
121 | location.classification = gamedata.classification_by_location_id[location_id] | 121 | self.add_child(location) |
122 | self.add_child(location) | 122 | |
123 | 123 | var panels = gamedata.panel_ids_by_location_id[location_id] | |
124 | var panels = gamedata.panel_ids_by_location_id[location_id] | 124 | location.total = panels.size() |
125 | location.total = panels.size() | 125 | |
126 | 126 | for panel in panels: | |
127 | for panel in panels: | 127 | var that_panel |
128 | var that_panel | 128 | if panel.begins_with("EndPanel"): |
129 | if panel.begins_with("EndPanel"): | 129 | that_panel = self.get_node("Decorations").get_node(panel) |
130 | that_panel = self.get_node("Decorations").get_node(panel) | 130 | else: |
131 | else: | 131 | that_panel = panels_parent.get_node(panel) |
132 | that_panel = panels_parent.get_node(panel) | 132 | |
133 | 133 | that_panel.get_node("Viewport/GUI/Panel/TextEdit").connect( | |
134 | that_panel.get_node("Viewport/GUI/Panel/TextEdit").connect( | 134 | "answer_correct", location, "handle_correct" |
135 | "answer_correct", location, "handle_correct" | 135 | ) |
136 | ) | ||
137 | else: | ||
138 | global._print("Could not find location ID for %s" % location_id) | ||
139 | 136 | ||
140 | # HOT CRUSTS should be at eye-level, have a yellow block behind it, and | 137 | # HOT CRUSTS should be at eye-level, have a yellow block behind it, and |
141 | # not vanish when solved. | 138 | # not vanish when solved. |
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index 72f0932..e130572 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -2,7 +2,8 @@ require 'set' | |||
2 | require 'yaml' | 2 | require 'yaml' |
3 | 3 | ||
4 | configpath = ARGV[0] | 4 | configpath = ARGV[0] |
5 | outputpath = ARGV[1] | 5 | idspath = ARGV[1] |
6 | outputpath = ARGV[2] | ||
6 | 7 | ||
7 | CLASSIFICATION_NORMAL = 1 | 8 | CLASSIFICATION_NORMAL = 1 |
8 | CLASSIFICATION_REDUCED = 2 | 9 | CLASSIFICATION_REDUCED = 2 |
@@ -20,10 +21,14 @@ mentioned_doors = Set[] | |||
20 | mentioned_paintings = Set[] | 21 | mentioned_paintings = Set[] |
21 | painting_output = {} | 22 | painting_output = {} |
22 | 23 | ||
24 | ids_config = YAML.load_file(idspath) | ||
25 | |||
23 | config = YAML.load_file(configpath) | 26 | config = YAML.load_file(configpath) |
24 | config.each do |room_name, room_data| | 27 | config.each do |room_name, room_data| |
25 | if room_data.include? "panels" | 28 | if room_data.include? "panels" |
26 | room_data["panels"].each do |panel_name, panel| | 29 | room_data["panels"].each do |panel_name, panel| |
30 | location_id = ids_config["panels"][room_name][panel_name] | ||
31 | |||
27 | full_name = "#{room_name} - #{panel_name}" | 32 | full_name = "#{room_name} - #{panel_name}" |
28 | panel_to_id[full_name] = panel["id"] | 33 | panel_to_id[full_name] = panel["id"] |
29 | 34 | ||
@@ -59,16 +64,16 @@ config.each do |room_name, room_data| | |||
59 | end | 64 | end |
60 | panel_output << ret | 65 | panel_output << ret |
61 | 66 | ||
62 | panel_ids_by_location_id[full_name] = [panel["id"]] | 67 | panel_ids_by_location_id[location_id] = [panel["id"]] |
63 | 68 | ||
64 | classification_by_location_id[full_name] ||= 0 | 69 | classification_by_location_id[location_id] ||= 0 |
65 | classification_by_location_id[full_name] += CLASSIFICATION_INSANITY | 70 | classification_by_location_id[location_id] += CLASSIFICATION_INSANITY |
66 | 71 | ||
67 | if panel.include? "check" and panel["check"] | 72 | if panel.include? "check" and panel["check"] |
68 | classification_by_location_id[full_name] += CLASSIFICATION_NORMAL | 73 | classification_by_location_id[location_id] += CLASSIFICATION_NORMAL |
69 | 74 | ||
70 | unless panel.include? "exclude_reduce" and panel["exclude_reduce"] | 75 | unless panel.include? "exclude_reduce" and panel["exclude_reduce"] |
71 | classification_by_location_id[full_name] += CLASSIFICATION_REDUCED | 76 | classification_by_location_id[location_id] += CLASSIFICATION_REDUCED |
72 | end | 77 | end |
73 | end | 78 | end |
74 | end | 79 | end |
@@ -90,27 +95,9 @@ config.each do |room_name, room_data| | |||
90 | not (door.include? "event" and door["event"]) and | 95 | not (door.include? "event" and door["event"]) and |
91 | door.include? "panels" then | 96 | door.include? "panels" then |
92 | 97 | ||
93 | chosen_name = full_name | 98 | location_id = ids_config["doors"][room_name][door_name]["location"] |
94 | if door.include? "location_name" | ||
95 | chosen_name = door["location_name"] | ||
96 | else | ||
97 | panels_per_room = {} | ||
98 | door["panels"].each do |panel_identifier| | ||
99 | if panel_identifier.kind_of? String | ||
100 | panels_per_room[room_name] ||= [] | ||
101 | panels_per_room[room_name] << panel_identifier | ||
102 | else | ||
103 | panels_per_room[panel_identifier["room"]] ||= [] | ||
104 | panels_per_room[panel_identifier["room"]] << panel_identifier["panel"] | ||
105 | end | ||
106 | end | ||
107 | 99 | ||
108 | chosen_name = panels_per_room.map do |room_name, panels| | 100 | panel_ids_by_location_id[location_id] = door["panels"].map do |panel_identifier| |
109 | room_name + " - " + panels.join(", ") | ||
110 | end.join(" and ") | ||
111 | end | ||
112 | |||
113 | panel_ids_by_location_id[chosen_name] = door["panels"].map do |panel_identifier| | ||
114 | other_name = "" | 101 | other_name = "" |
115 | if panel_identifier.kind_of? String | 102 | if panel_identifier.kind_of? String |
116 | other_name = "#{room_name} - #{panel_identifier}" | 103 | other_name = "#{room_name} - #{panel_identifier}" |
@@ -120,21 +107,18 @@ config.each do |room_name, room_data| | |||
120 | panel_to_id[other_name] | 107 | panel_to_id[other_name] |
121 | end | 108 | end |
122 | 109 | ||
123 | classification_by_location_id[chosen_name] ||= 0 | 110 | classification_by_location_id[location_id] ||= 0 |
124 | classification_by_location_id[chosen_name] += CLASSIFICATION_NORMAL | 111 | classification_by_location_id[location_id] += CLASSIFICATION_NORMAL |
125 | 112 | ||
126 | if door.include? "include_reduce" and door["include_reduce"] | 113 | if door.include? "include_reduce" and door["include_reduce"] |
127 | classification_by_location_id[chosen_name] += CLASSIFICATION_REDUCED | 114 | classification_by_location_id[location_id] += CLASSIFICATION_REDUCED |
128 | end | 115 | end |
129 | end | 116 | end |
130 | 117 | ||
131 | if not (door.include? "skip_item" and door["skip_item"]) and | 118 | if not (door.include? "skip_item" and door["skip_item"]) and |
132 | not (door.include? "event" and door["event"]) then | 119 | not (door.include? "event" and door["event"]) then |
133 | 120 | ||
134 | chosen_name = full_name | 121 | item_id = ids_config["doors"][room_name][door_name]["item"] |
135 | if door.include? "item_name" | ||
136 | chosen_name = door["item_name"] | ||
137 | end | ||
138 | 122 | ||
139 | if door.include? "id" | 123 | if door.include? "id" |
140 | internal_door_ids = [] | 124 | internal_door_ids = [] |
@@ -149,7 +133,7 @@ config.each do |room_name, room_data| | |||
149 | door_groups[door["group"]].merge(internal_door_ids) | 133 | door_groups[door["group"]].merge(internal_door_ids) |
150 | end | 134 | end |
151 | 135 | ||
152 | door_ids_by_item_id[chosen_name] = internal_door_ids | 136 | door_ids_by_item_id[item_id] = internal_door_ids |
153 | mentioned_doors.merge(internal_door_ids) | 137 | mentioned_doors.merge(internal_door_ids) |
154 | end | 138 | end |
155 | 139 | ||
@@ -161,7 +145,7 @@ config.each do |room_name, room_data| | |||
161 | internal_painting_ids = door["painting_id"] | 145 | internal_painting_ids = door["painting_id"] |
162 | end | 146 | end |
163 | 147 | ||
164 | painting_ids_by_item_id[chosen_name] = internal_painting_ids | 148 | painting_ids_by_item_id[item_id] = internal_painting_ids |
165 | mentioned_paintings.merge(internal_painting_ids) | 149 | mentioned_paintings.merge(internal_painting_ids) |
166 | end | 150 | end |
167 | end | 151 | end |
@@ -170,7 +154,8 @@ config.each do |room_name, room_data| | |||
170 | end | 154 | end |
171 | 155 | ||
172 | door_groups.each do |group_name, door_ids| | 156 | door_groups.each do |group_name, door_ids| |
173 | door_ids_by_item_id[group_name] = door_ids.to_a | 157 | item_id = ids_config["door_groups"][group_name] |
158 | door_ids_by_item_id[item_id] = door_ids.to_a | ||
174 | end | 159 | end |
175 | 160 | ||
176 | File.open(outputpath, "w") do |f| | 161 | File.open(outputpath, "w") do |f| |
@@ -182,19 +167,19 @@ File.open(outputpath, "w") do |f| | |||
182 | end.join(",")) | 167 | end.join(",")) |
183 | f.write "]\nvar door_ids_by_item_id = {" | 168 | f.write "]\nvar door_ids_by_item_id = {" |
184 | f.write(door_ids_by_item_id.map do |item_id, door_ids| | 169 | f.write(door_ids_by_item_id.map do |item_id, door_ids| |
185 | "\"#{item_id}\":[" + door_ids.map do |door_id| | 170 | "#{item_id}:[" + door_ids.map do |door_id| |
186 | "\"#{door_id}\"" | 171 | "\"#{door_id}\"" |
187 | end.join(",") + "]" | 172 | end.join(",") + "]" |
188 | end.join(",")) | 173 | end.join(",")) |
189 | f.write "}\nvar painting_ids_by_item_id = {" | 174 | f.write "}\nvar painting_ids_by_item_id = {" |
190 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| | 175 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| |
191 | "\"#{item_id}\":[" + painting_ids.map do |painting_id| | 176 | "#{item_id}:[" + painting_ids.map do |painting_id| |
192 | "\"#{painting_id}\"" | 177 | "\"#{painting_id}\"" |
193 | end.join(",") + "]" | 178 | end.join(",") + "]" |
194 | end.join(",")) | 179 | end.join(",")) |
195 | f.write "}\nvar panel_ids_by_location_id = {" | 180 | f.write "}\nvar panel_ids_by_location_id = {" |
196 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | 181 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| |
197 | "\"#{location_id}\":[" + panel_ids.map do |panel_id| | 182 | "#{location_id}:[" + panel_ids.map do |panel_id| |
198 | "\"#{panel_id}\"" | 183 | "\"#{panel_id}\"" |
199 | end.join(",") + "]" | 184 | end.join(",") + "]" |
200 | end.join(",")) | 185 | end.join(",")) |
@@ -212,7 +197,7 @@ File.open(outputpath, "w") do |f| | |||
212 | end.join(",")) | 197 | end.join(",")) |
213 | f.write "}\nvar classification_by_location_id = {" | 198 | f.write "}\nvar classification_by_location_id = {" |
214 | f.write(classification_by_location_id.map do |location_id, classification| | 199 | f.write(classification_by_location_id.map do |location_id, classification| |
215 | "\"#{location_id}\":#{classification}" | 200 | "#{location_id}:#{classification}" |
216 | end.join(",")) | 201 | end.join(",")) |
217 | f.write "}" | 202 | f.write "}" |
218 | end | 203 | end |