From 067d8e707bfa7a445da37190c24f7654dd738121 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 6 Sep 2025 16:09:10 -0400 Subject: [Client] Location scouting for letters --- client/Archipelago/manager.gd | 56 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'client/Archipelago/manager.gd') 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 = "" var _last_new_item = -1 var _batch_locations = false var _held_locations = [] +var _held_location_scouts = [] +var _location_scouts = {} var _item_locks = {} var _held_letters = {} var _letters_setup = false @@ -75,6 +77,7 @@ func _ready(): client.connect("item_received", _process_item) client.connect("message_received", _process_message) + client.connect("location_scout_received", _process_location_scout) client.connect("could_not_connect", _client_could_not_connect) client.connect("connect_status", _client_connect_status) client.connect("client_connected", _client_connected) @@ -161,9 +164,11 @@ func _process_item(item, index, from, flags, amount): if rnode != null: rnode.handleTriggered() - var letter_key = gamedata.letter_key_by_ap_id.get(item, null) - if letter_key != null: - _process_key_item(letter_key, amount) + var letter_id = gamedata.letter_id_by_ap_id.get(item, null) + if letter_id != null: + var letter = gamedata.objects.get_letters()[letter_id] + if not letter.has_level2() or not letter.get_level2(): + _process_key_item(letter.get_key(), amount) # Show a message about the item if it's new. if index != null and index > _last_new_item: @@ -280,6 +285,29 @@ func parse_printjson_for_textclient(message): textclient_node.parse_printjson("".join(parts)) +func _process_location_scout(item_id, location_id, player, flags): + _location_scouts[location_id] = {"item": item_id, "player": player, "flags": flags} + + var gamedata = global.get_node("Gamedata") + var map_id = gamedata.map_id_by_name.get(global.map) + + var item_name = "Unknown" + var item_player_game = client._game_by_player[float(player)] + if client._item_id_to_name[item_player_game].has(item_id): + item_name = client._item_id_to_name[item_player_game][item_id] + + var letter_id = gamedata.letter_id_by_ap_id.get(location_id, null) + if letter_id != null: + var letter = gamedata.objects.get_letters()[letter_id] + var room = gamedata.objects.get_rooms()[letter.get_room_id()] + if room.get_map_id() == map_id: + var collectable = get_tree().get_root().get_node("scene").get_node_or_null( + letter.get_path() + ) + if collectable != null: + collectable.setScoutedText(item_name) + + func _client_could_not_connect(): emit_signal("could_not_connect") @@ -345,10 +373,28 @@ func send_location(loc_id): client.sendLocation(loc_id) +func scout_location(loc_id): + if _location_scouts.has(loc_id): + return _location_scouts.get(loc_id) + + if _batch_locations: + _held_location_scouts.append(loc_id) + else: + client.scoutLocation(loc_id) + + return null + + func stop_batching_locations(): _batch_locations = false - client.sendLocations(_held_locations) - _held_locations.clear() + + if not _held_locations.is_empty(): + client.sendLocations(_held_locations) + _held_locations.clear() + + if not _held_location_scouts.is_empty(): + client.scoutLocations(_held_location_scouts) + _held_location_scouts.clear() func colorForItemType(flags): -- cgit 1.4.1