diff options
-rw-r--r-- | client/Archipelago/client.gd | 15 | ||||
-rw-r--r-- | client/Archipelago/collectable.gd | 4 | ||||
-rw-r--r-- | client/Archipelago/gamedata.gd | 5 | ||||
-rw-r--r-- | client/Archipelago/manager.gd | 56 | ||||
-rw-r--r-- | client/Archipelago/player.gd | 17 |
5 files changed, 89 insertions, 8 deletions
diff --git a/client/Archipelago/client.gd b/client/Archipelago/client.gd index 428560e..2e080fd 100644 --- a/client/Archipelago/client.gd +++ b/client/Archipelago/client.gd | |||
@@ -41,6 +41,7 @@ signal connect_status | |||
41 | signal client_connected(slot_data) | 41 | signal client_connected(slot_data) |
42 | signal item_received(item_id, index, player, flags, amount) | 42 | signal item_received(item_id, index, player, flags, amount) |
43 | signal message_received(message) | 43 | signal message_received(message) |
44 | signal location_scout_received(item_id, location_id, player, flags) | ||
44 | 45 | ||
45 | 46 | ||
46 | func _init(): | 47 | func _init(): |
@@ -257,6 +258,16 @@ func _process(_delta): | |||
257 | elif cmd == "PrintJSON": | 258 | elif cmd == "PrintJSON": |
258 | emit_signal("message_received", message) | 259 | emit_signal("message_received", message) |
259 | 260 | ||
261 | elif cmd == "LocationInfo": | ||
262 | for loc in message["locations"]: | ||
263 | emit_signal( | ||
264 | "location_scout_received", | ||
265 | int(loc["item"]), | ||
266 | int(loc["location"]), | ||
267 | int(loc["player"]), | ||
268 | int(loc["flags"]) | ||
269 | ) | ||
270 | |||
260 | elif state == WebSocketPeer.STATE_CLOSED: | 271 | elif state == WebSocketPeer.STATE_CLOSED: |
261 | if _has_connected: | 272 | if _has_connected: |
262 | _closed() | 273 | _closed() |
@@ -392,6 +403,10 @@ func completedGoal(): | |||
392 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL | 403 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL |
393 | 404 | ||
394 | 405 | ||
406 | func scoutLocations(loc_ids): | ||
407 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) | ||
408 | |||
409 | |||
395 | func hasItem(item_id): | 410 | func hasItem(item_id): |
396 | return _received_items.has(item_id) | 411 | return _received_items.has(item_id) |
397 | 412 | ||
diff --git a/client/Archipelago/collectable.gd b/client/Archipelago/collectable.gd index 7bbdd8b..4a17a2a 100644 --- a/client/Archipelago/collectable.gd +++ b/client/Archipelago/collectable.gd | |||
@@ -10,3 +10,7 @@ func pickedUp(): | |||
10 | ap.keyboard.update_unlocks() | 10 | ap.keyboard.update_unlocks() |
11 | 11 | ||
12 | super.pickedUp() | 12 | super.pickedUp() |
13 | |||
14 | |||
15 | func setScoutedText(text): | ||
16 | get_node("MeshInstance3D").mesh.text = text.replace(" ", "\n") | ||
diff --git a/client/Archipelago/gamedata.gd b/client/Archipelago/gamedata.gd index 11f4981..f7a5d90 100644 --- a/client/Archipelago/gamedata.gd +++ b/client/Archipelago/gamedata.gd | |||
@@ -8,7 +8,7 @@ var painting_id_by_map_node_path = {} | |||
8 | var door_id_by_ap_id = {} | 8 | var door_id_by_ap_id = {} |
9 | var map_id_by_name = {} | 9 | var map_id_by_name = {} |
10 | var progressive_id_by_ap_id = {} | 10 | var progressive_id_by_ap_id = {} |
11 | var letter_key_by_ap_id = {} | 11 | var letter_id_by_ap_id = {} |
12 | 12 | ||
13 | 13 | ||
14 | func _init(proto_script): | 14 | func _init(proto_script): |
@@ -56,8 +56,7 @@ func load(data_bytes): | |||
56 | progressive_id_by_ap_id[progressive.get_ap_id()] = progressive.get_id() | 56 | progressive_id_by_ap_id[progressive.get_ap_id()] = progressive.get_id() |
57 | 57 | ||
58 | for letter in objects.get_letters(): | 58 | for letter in objects.get_letters(): |
59 | if not letter.has_level2() or not letter.get_level2(): | 59 | letter_id_by_ap_id[letter.get_ap_id()] = letter.get_id() |
60 | letter_key_by_ap_id[letter.get_ap_id()] = letter.get_key() | ||
61 | 60 | ||
62 | 61 | ||
63 | func get_door_for_map_node_path(map_name, node_path): | 62 | func get_door_for_map_node_path(map_name, node_path): |
diff --git a/client/Archipelago/manager.gd b/client/Archipelago/manager.gd index 07d28a4..bcb21e7 100644 --- a/client/Archipelago/manager.gd +++ b/client/Archipelago/manager.gd | |||
@@ -20,6 +20,8 @@ var _localdata_file = "" | |||
20 | var _last_new_item = -1 | 20 | var _last_new_item = -1 |
21 | var _batch_locations = false | 21 | var _batch_locations = false |
22 | var _held_locations = [] | 22 | var _held_locations = [] |
23 | var _held_location_scouts = [] | ||
24 | var _location_scouts = {} | ||
23 | var _item_locks = {} | 25 | var _item_locks = {} |
24 | var _held_letters = {} | 26 | var _held_letters = {} |
25 | var _letters_setup = false | 27 | var _letters_setup = false |
@@ -75,6 +77,7 @@ func _ready(): | |||
75 | 77 | ||
76 | client.connect("item_received", _process_item) | 78 | client.connect("item_received", _process_item) |
77 | client.connect("message_received", _process_message) | 79 | client.connect("message_received", _process_message) |
80 | client.connect("location_scout_received", _process_location_scout) | ||
78 | client.connect("could_not_connect", _client_could_not_connect) | 81 | client.connect("could_not_connect", _client_could_not_connect) |
79 | client.connect("connect_status", _client_connect_status) | 82 | client.connect("connect_status", _client_connect_status) |
80 | client.connect("client_connected", _client_connected) | 83 | client.connect("client_connected", _client_connected) |
@@ -161,9 +164,11 @@ func _process_item(item, index, from, flags, amount): | |||
161 | if rnode != null: | 164 | if rnode != null: |
162 | rnode.handleTriggered() | 165 | rnode.handleTriggered() |
163 | 166 | ||
164 | var letter_key = gamedata.letter_key_by_ap_id.get(item, null) | 167 | var letter_id = gamedata.letter_id_by_ap_id.get(item, null) |
165 | if letter_key != null: | 168 | if letter_id != null: |
166 | _process_key_item(letter_key, amount) | 169 | var letter = gamedata.objects.get_letters()[letter_id] |
170 | if not letter.has_level2() or not letter.get_level2(): | ||
171 | _process_key_item(letter.get_key(), amount) | ||
167 | 172 | ||
168 | # Show a message about the item if it's new. | 173 | # Show a message about the item if it's new. |
169 | if index != null and index > _last_new_item: | 174 | if index != null and index > _last_new_item: |
@@ -280,6 +285,29 @@ func parse_printjson_for_textclient(message): | |||
280 | textclient_node.parse_printjson("".join(parts)) | 285 | textclient_node.parse_printjson("".join(parts)) |
281 | 286 | ||
282 | 287 | ||
288 | func _process_location_scout(item_id, location_id, player, flags): | ||
289 | _location_scouts[location_id] = {"item": item_id, "player": player, "flags": flags} | ||
290 | |||
291 | var gamedata = global.get_node("Gamedata") | ||
292 | var map_id = gamedata.map_id_by_name.get(global.map) | ||
293 | |||
294 | var item_name = "Unknown" | ||
295 | var item_player_game = client._game_by_player[float(player)] | ||
296 | if client._item_id_to_name[item_player_game].has(item_id): | ||
297 | item_name = client._item_id_to_name[item_player_game][item_id] | ||
298 | |||
299 | var letter_id = gamedata.letter_id_by_ap_id.get(location_id, null) | ||
300 | if letter_id != null: | ||
301 | var letter = gamedata.objects.get_letters()[letter_id] | ||
302 | var room = gamedata.objects.get_rooms()[letter.get_room_id()] | ||
303 | if room.get_map_id() == map_id: | ||
304 | var collectable = get_tree().get_root().get_node("scene").get_node_or_null( | ||
305 | letter.get_path() | ||
306 | ) | ||
307 | if collectable != null: | ||
308 | collectable.setScoutedText(item_name) | ||
309 | |||
310 | |||
283 | func _client_could_not_connect(): | 311 | func _client_could_not_connect(): |
284 | emit_signal("could_not_connect") | 312 | emit_signal("could_not_connect") |
285 | 313 | ||
@@ -345,10 +373,28 @@ func send_location(loc_id): | |||
345 | client.sendLocation(loc_id) | 373 | client.sendLocation(loc_id) |
346 | 374 | ||
347 | 375 | ||
376 | func scout_location(loc_id): | ||
377 | if _location_scouts.has(loc_id): | ||
378 | return _location_scouts.get(loc_id) | ||
379 | |||
380 | if _batch_locations: | ||
381 | _held_location_scouts.append(loc_id) | ||
382 | else: | ||
383 | client.scoutLocation(loc_id) | ||
384 | |||
385 | return null | ||
386 | |||
387 | |||
348 | func stop_batching_locations(): | 388 | func stop_batching_locations(): |
349 | _batch_locations = false | 389 | _batch_locations = false |
350 | client.sendLocations(_held_locations) | 390 | |
351 | _held_locations.clear() | 391 | if not _held_locations.is_empty(): |
392 | client.sendLocations(_held_locations) | ||
393 | _held_locations.clear() | ||
394 | |||
395 | if not _held_location_scouts.is_empty(): | ||
396 | client.scoutLocations(_held_location_scouts) | ||
397 | _held_location_scouts.clear() | ||
352 | 398 | ||
353 | 399 | ||
354 | func colorForItemType(flags): | 400 | func colorForItemType(flags): |
diff --git a/client/Archipelago/player.gd b/client/Archipelago/player.gd index 4569af5..dd6aa2b 100644 --- a/client/Archipelago/player.gd +++ b/client/Archipelago/player.gd | |||
@@ -81,6 +81,23 @@ func _ready(): | |||
81 | 81 | ||
82 | get_parent().add_child.call_deferred(locationListener) | 82 | get_parent().add_child.call_deferred(locationListener) |
83 | 83 | ||
84 | if ( | ||
85 | ap.get_letter_behavior(letter.get_key(), letter.has_level2() and letter.get_level2()) | ||
86 | != ap.kLETTER_BEHAVIOR_VANILLA | ||
87 | ): | ||
88 | var scout = ap.scout_location(letter.get_ap_id()) | ||
89 | if scout != null: | ||
90 | var item_name = "Unknown" | ||
91 | var item_player_game = ap.client._game_by_player[float(scout["player"])] | ||
92 | if ap.client._item_id_to_name[item_player_game].has(scout["item"]): | ||
93 | item_name = ap.client._item_id_to_name[item_player_game][scout["item"]] | ||
94 | |||
95 | var collectable = get_tree().get_root().get_node("scene").get_node_or_null( | ||
96 | letter.get_path() | ||
97 | ) | ||
98 | if collectable != null: | ||
99 | collectable.setScoutedText.call_deferred(item_name) | ||
100 | |||
84 | # Set up mastery locations. | 101 | # Set up mastery locations. |
85 | for mastery in gamedata.objects.get_masteries(): | 102 | for mastery in gamedata.objects.get_masteries(): |
86 | var room = gamedata.objects.get_rooms()[mastery.get_room_id()] | 103 | var room = gamedata.objects.get_rooms()[mastery.get_room_id()] |