From 5ca50cd8d34d9f42b2f8ad76c5bf64203a643cb4 Mon Sep 17 00:00:00 2001 From: Bryce Wilson Date: Sun, 29 Mar 2026 14:10:16 -0700 Subject: [PATCH] Pokemon Emerald: Fix Latios KeyError (#6056) --- worlds/pokemon_emerald/__init__.py | 8 ++++++++ worlds/pokemon_emerald/pokemon.py | 4 ++-- worlds/pokemon_emerald/rules.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/worlds/pokemon_emerald/__init__.py b/worlds/pokemon_emerald/__init__.py index 10abed539f..fb683df90d 100644 --- a/worlds/pokemon_emerald/__init__.py +++ b/worlds/pokemon_emerald/__init__.py @@ -263,6 +263,14 @@ class PokemonEmeraldWorld(World): if self.options.hms == RandomizeHms.option_shuffle: self.options.local_items.value.update(self.item_name_groups["HM"]) + # Manually enable Latios as a dexsanity location if we're doing legendary hunt (which confines Latios to + # the roamer encounter), the player allows Latios as a valid legendary hunt target, and they didn't also + # blacklist Latios to remove its dexsanity location + if self.options.goal == Goal.option_legendary_hunt and self.options.dexsanity \ + and "Latios" in self.options.allowed_legendary_hunt_encounters.value \ + and emerald_data.constants["SPECIES_LATIOS"] not in self.blacklisted_wilds: + self.allowed_dexsanity_species.add(emerald_data.constants["SPECIES_LATIOS"]) + def create_regions(self) -> None: from .regions import create_regions all_regions = create_regions(self) diff --git a/worlds/pokemon_emerald/pokemon.py b/worlds/pokemon_emerald/pokemon.py index 73af6c4658..76285d11da 100644 --- a/worlds/pokemon_emerald/pokemon.py +++ b/worlds/pokemon_emerald/pokemon.py @@ -376,10 +376,10 @@ def randomize_wild_encounters(world: "PokemonEmeraldWorld") -> None: # Actually create the new list of slots and encounter table new_slots: List[int] = [] - if encounter_type in enabled_encounters: - world.allowed_dexsanity_species.update(table.slots) for species_id in table.slots: new_slots.append(species_old_to_new_map[species_id]) + if encounter_type in enabled_encounters: + world.allowed_dexsanity_species.update(new_slots) new_encounters[encounter_type] = EncounterTableData(new_slots, table.address) diff --git a/worlds/pokemon_emerald/rules.py b/worlds/pokemon_emerald/rules.py index eeadb8bea2..30ebf72e4d 100644 --- a/worlds/pokemon_emerald/rules.py +++ b/worlds/pokemon_emerald/rules.py @@ -1559,7 +1559,7 @@ def set_rules(world: "PokemonEmeraldWorld") -> None: # Legendary hunt prevents Latios from being a wild spawn so the roamer # can be tracked, and also guarantees that the roamer is a Latios. if world.options.goal == Goal.option_legendary_hunt and \ - data.constants["SPECIES_LATIOS"] not in world.blacklisted_wilds: + data.constants["SPECIES_LATIOS"] in world.allowed_dexsanity_species: set_rule( get_location(f"Pokedex - Latios"), lambda state: state.has("EVENT_ENCOUNTER_LATIOS", world.player)