diff options
Diffstat (limited to 'client/Archipelago')
-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 | 73 | ||||
-rw-r--r-- | client/Archipelago/player.gd | 17 |
5 files changed, 106 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..72abf34 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 |
@@ -36,6 +38,7 @@ const kLETTER_BEHAVIOR_UNLOCKED = 2 | |||
36 | 38 | ||
37 | var daedalus_roof_access = false | 39 | var daedalus_roof_access = false |
38 | var keyholder_sanity = false | 40 | var keyholder_sanity = false |
41 | var shuffle_control_center_colors = false | ||
39 | var shuffle_doors = false | 42 | var shuffle_doors = false |
40 | var shuffle_letters = kSHUFFLE_LETTERS_VANILLA | 43 | var shuffle_letters = kSHUFFLE_LETTERS_VANILLA |
41 | var victory_condition = -1 | 44 | var victory_condition = -1 |
@@ -75,6 +78,7 @@ func _ready(): | |||
75 | 78 | ||
76 | client.connect("item_received", _process_item) | 79 | client.connect("item_received", _process_item) |
77 | client.connect("message_received", _process_message) | 80 | client.connect("message_received", _process_message) |
81 | client.connect("location_scout_received", _process_location_scout) | ||
78 | client.connect("could_not_connect", _client_could_not_connect) | 82 | client.connect("could_not_connect", _client_could_not_connect) |
79 | client.connect("connect_status", _client_connect_status) | 83 | client.connect("connect_status", _client_connect_status) |
80 | client.connect("client_connected", _client_connected) | 84 | client.connect("client_connected", _client_connected) |
@@ -161,9 +165,11 @@ func _process_item(item, index, from, flags, amount): | |||
161 | if rnode != null: | 165 | if rnode != null: |
162 | rnode.handleTriggered() | 166 | rnode.handleTriggered() |
163 | 167 | ||
164 | var letter_key = gamedata.letter_key_by_ap_id.get(item, null) | 168 | var letter_id = gamedata.letter_id_by_ap_id.get(item, null) |
165 | if letter_key != null: | 169 | if letter_id != null: |
166 | _process_key_item(letter_key, amount) | 170 | var letter = gamedata.objects.get_letters()[letter_id] |
171 | if not letter.has_level2() or not letter.get_level2(): | ||
172 | _process_key_item(letter.get_key(), amount) | ||
167 | 173 | ||
168 | # Show a message about the item if it's new. | 174 | # Show a message about the item if it's new. |
169 | if index != null and index > _last_new_item: | 175 | if index != null and index > _last_new_item: |
@@ -280,6 +286,29 @@ func parse_printjson_for_textclient(message): | |||
280 | textclient_node.parse_printjson("".join(parts)) | 286 | textclient_node.parse_printjson("".join(parts)) |
281 | 287 | ||
282 | 288 | ||
289 | func _process_location_scout(item_id, location_id, player, flags): | ||
290 | _location_scouts[location_id] = {"item": item_id, "player": player, "flags": flags} | ||
291 | |||
292 | var gamedata = global.get_node("Gamedata") | ||
293 | var map_id = gamedata.map_id_by_name.get(global.map) | ||
294 | |||
295 | var item_name = "Unknown" | ||
296 | var item_player_game = client._game_by_player[float(player)] | ||
297 | if client._item_id_to_name[item_player_game].has(item_id): | ||
298 | item_name = client._item_id_to_name[item_player_game][item_id] | ||
299 | |||
300 | var letter_id = gamedata.letter_id_by_ap_id.get(location_id, null) | ||
301 | if letter_id != null: | ||
302 | var letter = gamedata.objects.get_letters()[letter_id] | ||
303 | var room = gamedata.objects.get_rooms()[letter.get_room_id()] | ||
304 | if room.get_map_id() == map_id: | ||
305 | var collectable = get_tree().get_root().get_node("scene").get_node_or_null( | ||
306 | letter.get_path() | ||
307 | ) | ||
308 | if collectable != null: | ||
309 | collectable.setScoutedText(item_name) | ||
310 | |||
311 | |||
283 | func _client_could_not_connect(): | 312 | func _client_could_not_connect(): |
284 | emit_signal("could_not_connect") | 313 | emit_signal("could_not_connect") |
285 | 314 | ||
@@ -311,6 +340,7 @@ func _client_connected(slot_data): | |||
311 | # Read slot data. | 340 | # Read slot data. |
312 | daedalus_roof_access = bool(slot_data.get("daedalus_roof_access", false)) | 341 | daedalus_roof_access = bool(slot_data.get("daedalus_roof_access", false)) |
313 | keyholder_sanity = bool(slot_data.get("keyholder_sanity", false)) | 342 | keyholder_sanity = bool(slot_data.get("keyholder_sanity", false)) |
343 | shuffle_control_center_colors = bool(slot_data.get("shuffle_control_center_colors", false)) | ||
314 | shuffle_doors = bool(slot_data.get("shuffle_doors", false)) | 344 | shuffle_doors = bool(slot_data.get("shuffle_doors", false)) |
315 | shuffle_letters = int(slot_data.get("shuffle_letters", 0)) | 345 | shuffle_letters = int(slot_data.get("shuffle_letters", 0)) |
316 | victory_condition = int(slot_data.get("victory_condition", 0)) | 346 | victory_condition = int(slot_data.get("victory_condition", 0)) |
@@ -331,6 +361,21 @@ func _client_connected(slot_data): | |||
331 | var door = gamedata.objects.get_doors()[progressive.get_doors()[i]] | 361 | var door = gamedata.objects.get_doors()[progressive.get_doors()[i]] |
332 | _item_locks[door.get_id()] = [progressive.get_ap_id(), i + 1] | 362 | _item_locks[door.get_id()] = [progressive.get_ap_id(), i + 1] |
333 | 363 | ||
364 | for door_group in gamedata.objects.get_door_groups(): | ||
365 | if door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.CONNECTOR: | ||
366 | for door in door_group.get_doors(): | ||
367 | _item_locks[door] = [door_group.get_ap_id(), 1] | ||
368 | |||
369 | if shuffle_control_center_colors: | ||
370 | for door in gamedata.objects.get_doors(): | ||
371 | if door.get_type() == gamedata.SCRIPT_proto.DoorType.CONTROL_CENTER_COLOR: | ||
372 | _item_locks[door.get_id()] = [door.get_ap_id(), 1] | ||
373 | |||
374 | for door_group in gamedata.objects.get_door_groups(): | ||
375 | if door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.COLOR_CONNECTOR: | ||
376 | for door in door_group.get_doors(): | ||
377 | _item_locks[door] = [door_group.get_ap_id(), 1] | ||
378 | |||
334 | emit_signal("ap_connected") | 379 | emit_signal("ap_connected") |
335 | 380 | ||
336 | 381 | ||
@@ -345,10 +390,28 @@ func send_location(loc_id): | |||
345 | client.sendLocation(loc_id) | 390 | client.sendLocation(loc_id) |
346 | 391 | ||
347 | 392 | ||
393 | func scout_location(loc_id): | ||
394 | if _location_scouts.has(loc_id): | ||
395 | return _location_scouts.get(loc_id) | ||
396 | |||
397 | if _batch_locations: | ||
398 | _held_location_scouts.append(loc_id) | ||
399 | else: | ||
400 | client.scoutLocation(loc_id) | ||
401 | |||
402 | return null | ||
403 | |||
404 | |||
348 | func stop_batching_locations(): | 405 | func stop_batching_locations(): |
349 | _batch_locations = false | 406 | _batch_locations = false |
350 | client.sendLocations(_held_locations) | 407 | |
351 | _held_locations.clear() | 408 | if not _held_locations.is_empty(): |
409 | client.sendLocations(_held_locations) | ||
410 | _held_locations.clear() | ||
411 | |||
412 | if not _held_location_scouts.is_empty(): | ||
413 | client.scoutLocations(_held_location_scouts) | ||
414 | _held_location_scouts.clear() | ||
352 | 415 | ||
353 | 416 | ||
354 | func colorForItemType(flags): | 417 | 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()] |