diff options
Diffstat (limited to 'client/Archipelago/manager.gd')
-rw-r--r-- | client/Archipelago/manager.gd | 56 |
1 files changed, 51 insertions, 5 deletions
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): |