From 8a4298e504c4b689942c93bb455e47c59d67dee8 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Mon, 23 Jan 2023 18:42:13 -0800 Subject: [PATCH] ALttP: Fix hint tile hints being potentially useless with item links. (#1400) * ALttP: Fix hint tile hints being potentially useless with item links. * use the set returned from world.get_player_groups(player) * Move the group resolving to BaseClasses. Fix silver arrow hints as well. --- BaseClasses.py | 14 ++++++++++++-- worlds/alttp/Rom.py | 8 ++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 818bdc1f..bf89a0e6 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -393,7 +393,12 @@ class MultiWorld(): def get_items(self) -> List[Item]: return [loc.item for loc in self.get_filled_locations()] + self.itempool - def find_item_locations(self, item, player: int) -> List[Location]: + def find_item_locations(self, item, player: int, resolve_group_locations: bool = False) -> List[Location]: + if resolve_group_locations: + player_groups = self.get_player_groups(player) + return [location for location in self.get_locations() if + location.item and location.item.name == item and location.player not in player_groups and + (location.item.player == player or location.item.player in player_groups)] return [location for location in self.get_locations() if location.item and location.item.name == item and location.item.player == player] @@ -401,7 +406,12 @@ class MultiWorld(): return next(location for location in self.get_locations() if location.item and location.item.name == item and location.item.player == player) - def find_items_in_locations(self, items: Set[str], player: int) -> List[Location]: + def find_items_in_locations(self, items: Set[str], player: int, resolve_group_locations: bool = False) -> List[Location]: + if resolve_group_locations: + player_groups = self.get_player_groups(player) + return [location for location in self.get_locations() if + location.item and location.item.name in items and location.player not in player_groups and + (location.item.player == player or location.item.player in player_groups)] return [location for location in self.get_locations() if location.item and location.item.name in items and location.item.player == player] diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index 268cb9eb..a374658e 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -2304,7 +2304,7 @@ def write_strings(rom, world, player): 'dungeonscrossed'] else 8 hint_count = min(hint_count, len(items_to_hint), len(hint_locations)) if hint_count: - locations = world.find_items_in_locations(items_to_hint, player) + locations = world.find_items_in_locations(items_to_hint, player, True) local_random.shuffle(locations) for x in range(min(hint_count, len(locations))): this_location = locations.pop() @@ -2321,7 +2321,7 @@ def write_strings(rom, world, player): # We still need the older hints of course. Those are done here. - silverarrows = world.find_item_locations('Silver Bow', player) + silverarrows = world.find_item_locations('Silver Bow', player, True) local_random.shuffle(silverarrows) silverarrow_hint = ( ' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!' @@ -2329,13 +2329,13 @@ def write_strings(rom, world, player): tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint if world.worlds[player].has_progressive_bows and (world.difficulty_requirements[player].progressive_bow_limit >= 2 or ( world.swordless[player] or world.logic[player] == 'noglitches')): - prog_bow_locs = world.find_item_locations('Progressive Bow', player) + prog_bow_locs = world.find_item_locations('Progressive Bow', player, True) world.slot_seeds[player].shuffle(prog_bow_locs) found_bow = False found_bow_alt = False while prog_bow_locs and not (found_bow and found_bow_alt): bow_loc = prog_bow_locs.pop() - if bow_loc.item.code == 0x65: + if bow_loc.item.code == 0x65 or (found_bow and not prog_bow_locs): found_bow_alt = True target = 'ganon_phase_3_no_silvers' else: