Skip to content

Commit

Permalink
Pokemon Emerald: Automatically exclude locations based on goal (#2655)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zunawe authored Jan 16, 2024
1 parent d000b52 commit 3a58809
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions worlds/pokemon_emerald/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
from typing import Any, Set, List, Dict, Optional, Tuple, ClassVar

from BaseClasses import ItemClassification, MultiWorld, Tutorial
from BaseClasses import ItemClassification, MultiWorld, Tutorial, LocationProgressType
from Fill import FillError, fill_restrictive
from Options import Toggle
import settings
Expand All @@ -20,7 +20,7 @@
offset_item_value)
from .locations import (LOCATION_GROUPS, PokemonEmeraldLocation, create_location_label_to_id_map,
create_locations_with_tags)
from .options import (ItemPoolType, RandomizeWildPokemon, RandomizeBadges, RandomizeTrainerParties, RandomizeHms,
from .options import (Goal, ItemPoolType, RandomizeWildPokemon, RandomizeBadges, RandomizeTrainerParties, RandomizeHms,
RandomizeStarters, LevelUpMoves, RandomizeAbilities, RandomizeTypes, TmCompatibility,
HmCompatibility, RandomizeStaticEncounters, NormanRequirement, PokemonEmeraldOptions)
from .pokemon import get_random_species, get_random_move, get_random_damaging_move, get_random_type
Expand Down Expand Up @@ -146,6 +146,60 @@ def create_regions(self) -> None:

self.multiworld.regions.extend(regions.values())

# Exclude locations which are always locked behind the player's goal
def exclude_locations(location_names: List[str]):
for location_name in location_names:
try:
self.multiworld.get_location(location_name,
self.player).progress_type = LocationProgressType.EXCLUDED
except KeyError:
continue # Location not in multiworld

if self.options.goal == Goal.option_champion:
# Always required to beat champion before receiving this
exclude_locations([
"Littleroot Town - S.S. Ticket from Norman"
])

# S.S. Ticket requires beating champion, so ferry is not accessible until after goal
if not self.options.enable_ferry:
exclude_locations([
"SS Tidal - Hidden Item in Lower Deck Trash Can",
"SS Tidal - TM49 from Thief"
])

# Construction workers don't move until champion is defeated
if "Safari Zone Construction Workers" not in self.options.remove_roadblocks.value:
exclude_locations([
"Safari Zone NE - Hidden Item North",
"Safari Zone NE - Hidden Item East",
"Safari Zone NE - Item on Ledge",
"Safari Zone SE - Hidden Item in South Grass 1",
"Safari Zone SE - Hidden Item in South Grass 2",
"Safari Zone SE - Item in Grass"
])
elif self.options.goal == Goal.option_norman:
# If the player sets their options such that Surf or the Balance
# Badge is vanilla, a very large number of locations become
# "post-Norman". Similarly, access to the E4 may require you to
# defeat Norman as an event or to get his badge, making postgame
# locations inaccessible. Detecting these situations isn't trivial
# and excluding all locations requiring Surf would be a bad idea.
# So for now we just won't touch it and blame the user for
# constructing their options in this way. Players usually expect
# to only partially complete their world when playing this goal
# anyway.

# Locations which are directly unlocked by defeating Norman.
exclude_locations([
"Petalburg Gym - Balance Badge",
"Petalburg Gym - TM42 from Norman",
"Petalburg City - HM03 from Wally's Uncle",
"Dewford Town - TM36 from Sludge Bomb Man",
"Mauville City - Basement Key from Wattson",
"Mauville City - TM24 from Wattson"
])

def create_items(self) -> None:
item_locations: List[PokemonEmeraldLocation] = [
location
Expand Down

0 comments on commit 3a58809

Please sign in to comment.