diff --git a/BaseClasses.py b/BaseClasses.py index cd8749e11dce..c98909380732 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -51,10 +51,6 @@ def __getattr__(self, name: str) -> Any: class MultiWorld(): debug_types = False player_name: Dict[int, str] - difficulty_requirements: dict - required_medallions: dict - dark_room_logic: Dict[int, str] - restrict_dungeon_item_on_boss: Dict[int, bool] plando_texts: List[Dict[str, str]] plando_items: List[List[Dict[str, Any]]] plando_connections: List @@ -164,49 +160,10 @@ def __init__(self, players: int): for player in range(1, players + 1): def set_player_attr(attr, val): self.__dict__.setdefault(attr, {})[player] = val - - set_player_attr('shuffle', "vanilla") - set_player_attr('logic', "noglitches") - set_player_attr('mode', 'open') - set_player_attr('difficulty', 'normal') - set_player_attr('item_functionality', 'normal') - set_player_attr('timer', False) - set_player_attr('goal', 'ganon') - set_player_attr('required_medallions', ['Ether', 'Quake']) - set_player_attr('swamp_patch_required', False) - set_player_attr('powder_patch_required', False) - set_player_attr('ganon_at_pyramid', True) - set_player_attr('ganonstower_vanilla', True) - set_player_attr('can_access_trock_eyebridge', None) - set_player_attr('can_access_trock_front', None) - set_player_attr('can_access_trock_big_chest', None) - set_player_attr('can_access_trock_middle', None) - set_player_attr('fix_fake_world', True) - set_player_attr('difficulty_requirements', None) - set_player_attr('boss_shuffle', 'none') - set_player_attr('enemy_health', 'default') - set_player_attr('enemy_damage', 'default') - set_player_attr('beemizer_total_chance', 0) - set_player_attr('beemizer_trap_chance', 0) - set_player_attr('escape_assist', []) - set_player_attr('treasure_hunt_icon', 'Triforce Piece') - set_player_attr('treasure_hunt_count', 0) - set_player_attr('clock_mode', False) - set_player_attr('countdown_start_time', 10) - set_player_attr('red_clock_time', -2) - set_player_attr('blue_clock_time', 2) - set_player_attr('green_clock_time', 4) - set_player_attr('can_take_damage', True) - set_player_attr('triforce_pieces_available', 30) - set_player_attr('triforce_pieces_required', 20) - set_player_attr('shop_shuffle', 'off') - set_player_attr('shuffle_prizes', "g") - set_player_attr('sprite_pool', []) - set_player_attr('dark_room_logic', "lamp") set_player_attr('plando_items', []) set_player_attr('plando_texts', {}) set_player_attr('plando_connections', []) - set_player_attr('game', "A Link to the Past") + set_player_attr('game', "Archipelago") set_player_attr('completion_condition', lambda state: True) self.worlds = {} self.per_slot_randoms = Utils.DeprecateDict("Using per_slot_randoms is now deprecated. Please use the " diff --git a/Main.py b/Main.py index f1d2f63692d6..50ad94de0198 100644 --- a/Main.py +++ b/Main.py @@ -36,37 +36,13 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No logger = logging.getLogger() multiworld.set_seed(seed, args.race, str(args.outputname) if args.outputname else None) multiworld.plando_options = args.plando_options - - multiworld.shuffle = args.shuffle.copy() - multiworld.logic = args.logic.copy() - multiworld.mode = args.mode.copy() - multiworld.difficulty = args.difficulty.copy() - multiworld.item_functionality = args.item_functionality.copy() - multiworld.timer = args.timer.copy() - multiworld.goal = args.goal.copy() - multiworld.boss_shuffle = args.shufflebosses.copy() - multiworld.enemy_health = args.enemy_health.copy() - multiworld.enemy_damage = args.enemy_damage.copy() - multiworld.beemizer_total_chance = args.beemizer_total_chance.copy() - multiworld.beemizer_trap_chance = args.beemizer_trap_chance.copy() - multiworld.countdown_start_time = args.countdown_start_time.copy() - multiworld.red_clock_time = args.red_clock_time.copy() - multiworld.blue_clock_time = args.blue_clock_time.copy() - multiworld.green_clock_time = args.green_clock_time.copy() - multiworld.dungeon_counters = args.dungeon_counters.copy() - multiworld.triforce_pieces_available = args.triforce_pieces_available.copy() - multiworld.triforce_pieces_required = args.triforce_pieces_required.copy() - multiworld.shop_shuffle = args.shop_shuffle.copy() - multiworld.shuffle_prizes = args.shuffle_prizes.copy() - multiworld.sprite_pool = args.sprite_pool.copy() - multiworld.dark_room_logic = args.dark_room_logic.copy() multiworld.plando_items = args.plando_items.copy() multiworld.plando_texts = args.plando_texts.copy() multiworld.plando_connections = args.plando_connections.copy() - multiworld.required_medallions = args.required_medallions.copy() multiworld.game = args.game.copy() multiworld.player_name = args.name.copy() multiworld.sprite = args.sprite.copy() + multiworld.sprite_pool = args.sprite_pool.copy() multiworld.glitch_triforce = args.glitch_triforce # This is enabled/disabled globally, no per player option. multiworld.set_options(args) diff --git a/worlds/alttp/EntranceRandomizer.py b/worlds/alttp/EntranceRandomizer.py index 37486a9cde07..e62088c1e05c 100644 --- a/worlds/alttp/EntranceRandomizer.py +++ b/worlds/alttp/EntranceRandomizer.py @@ -23,170 +23,7 @@ def defval(value): multiargs, _ = parser.parse_known_args(argv) parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter) - parser.add_argument('--logic', default=defval('no_glitches'), const='no_glitches', nargs='?', choices=['no_glitches', 'minor_glitches', 'overworld_glitches', 'hybrid_major_glitches', 'no_logic'], - help='''\ - Select Enforcement of Item Requirements. (default: %(default)s) - No Glitches: - Minor Glitches: May require Fake Flippers, Bunny Revival - and Dark Room Navigation. - Overworld Glitches: May require overworld glitches. - Hybrid Major Glitches: May require both overworld and underworld clipping. - No Logic: Distribute items without regard for - item requirements. - ''') - parser.add_argument('--glitch_triforce', help='Allow glitching to Triforce from Ganon\'s room', action='store_true') - parser.add_argument('--mode', default=defval('open'), const='open', nargs='?', choices=['standard', 'open', 'inverted'], - help='''\ - Select game mode. (default: %(default)s) - Open: World starts with Zelda rescued. - Standard: Fixes Hyrule Castle Secret Entrance and Front Door - but may lead to weird rain state issues if you exit - through the Hyrule Castle side exits before rescuing - Zelda in a full shuffle. - Inverted: Starting locations are Dark Sanctuary in West Dark - World or at Link's House, which is shuffled freely. - Requires the moon pearl to be Link in the Light World - instead of a bunny. - ''') - parser.add_argument('--goal', default=defval('ganon'), const='ganon', nargs='?', - choices=['ganon', 'pedestal', 'bosses', 'triforce_hunt', 'local_triforce_hunt', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'crystals', 'ganon_pedestal'], - help='''\ - Select completion goal. (default: %(default)s) - Ganon: Collect all crystals, beat Agahnim 2 then - defeat Ganon. - Crystals: Collect all crystals then defeat Ganon. - Pedestal: Places the Triforce at the Master Sword Pedestal. - Ganon Pedestal: Pull the Master Sword Pedestal, then defeat Ganon. - All Dungeons: Collect all crystals, pendants, beat both - Agahnim fights and then defeat Ganon. - Triforce Hunt: Places 30 Triforce Pieces in the world, collect - 20 of them to beat the game. - Local Triforce Hunt: Places 30 Triforce Pieces in your world, collect - 20 of them to beat the game. - Ganon Triforce Hunt: Places 30 Triforce Pieces in the world, collect - 20 of them, then defeat Ganon. - Local Ganon Triforce Hunt: Places 30 Triforce Pieces in your world, - collect 20 of them, then defeat Ganon. - ''') - parser.add_argument('--triforce_pieces_available', default=defval(30), - type=lambda value: min(max(int(value), 1), 90), - help='''Set Triforce Pieces available in item pool.''') - parser.add_argument('--triforce_pieces_required', default=defval(20), - type=lambda value: min(max(int(value), 1), 90), - help='''Set Triforce Pieces required to win a Triforce Hunt''') - parser.add_argument('--difficulty', default=defval('normal'), const='normal', nargs='?', - choices=['easy', 'normal', 'hard', 'expert'], - help='''\ - Select game difficulty. Affects available itempool. (default: %(default)s) - Easy: An easier setting with some equipment duplicated and increased health. - Normal: Normal difficulty. - Hard: A harder setting with less equipment and reduced health. - Expert: A harder yet setting with minimum equipment and health. - ''') - parser.add_argument('--item_functionality', default=defval('normal'), const='normal', nargs='?', - choices=['easy', 'normal', 'hard', 'expert'], - help='''\ - Select limits on item functionality to increase difficulty. (default: %(default)s) - Easy: Easy functionality. (Medallions usable without sword) - Normal: Normal functionality. - Hard: Reduced functionality. - Expert: Greatly reduced functionality. - ''') - parser.add_argument('--timer', default=defval('none'), const='normal', nargs='?', choices=['none', 'display', 'timed', 'timed_ohko', 'ohko', 'timed_countdown'], - help='''\ - Select game timer setting. Affects available itempool. (default: %(default)s) - None: No timer. - Display: Displays a timer but does not affect - the itempool. - Timed: Starts with clock at zero. Green Clocks - subtract 4 minutes (Total: 20), Blue Clocks - subtract 2 minutes (Total: 10), Red Clocks add - 2 minutes (Total: 10). Winner is player with - lowest time at the end. - Timed OHKO: Starts clock at 10 minutes. Green Clocks add - 5 minutes (Total: 25). As long as clock is at 0, - Link will die in one hit. - OHKO: Like Timed OHKO, but no clock items are present - and the clock is permenantly at zero. - Timed Countdown: Starts with clock at 40 minutes. Same clocks as - Timed mode. If time runs out, you lose (but can - still keep playing). - ''') - parser.add_argument('--countdown_start_time', default=defval(10), type=int, - help='''Set amount of time, in minutes, to start with in Timed Countdown and Timed OHKO modes''') - parser.add_argument('--red_clock_time', default=defval(-2), type=int, - help='''Set amount of time, in minutes, to add from picking up red clocks; negative removes time instead''') - parser.add_argument('--blue_clock_time', default=defval(2), type=int, - help='''Set amount of time, in minutes, to add from picking up blue clocks; negative removes time instead''') - parser.add_argument('--green_clock_time', default=defval(4), type=int, - help='''Set amount of time, in minutes, to add from picking up green clocks; negative removes time instead''') - parser.add_argument('--dungeon_counters', default=defval('default'), const='default', nargs='?', choices=['default', 'on', 'pickup', 'off'], - help='''\ - Select dungeon counter display settings. (default: %(default)s) - (Note, since timer takes up the same space on the hud as dungeon - counters, timer settings override dungeon counter settings.) - Default: Dungeon counters only show when the compass is - picked up, or otherwise sent, only when compass - shuffle is turned on. - On: Dungeon counters are always displayed. - Pickup: Dungeon counters are shown when the compass is - picked up, even when compass shuffle is turned - off. - Off: Dungeon counters are never shown. - ''') - parser.add_argument('--algorithm', default=defval('balanced'), const='balanced', nargs='?', - choices=['freshness', 'flood', 'vt25', 'vt26', 'balanced'], - help='''\ - Select item filling algorithm. (default: %(default)s - balanced: vt26 derivitive that aims to strike a balance between - the overworld heavy vt25 and the dungeon heavy vt26 - algorithm. - vt26: Shuffle items and place them in a random location - that it is not impossible to be in. This includes - dungeon keys and items. - vt25: Shuffle items and place them in a random location - that it is not impossible to be in. - Flood: Push out items starting from Link\'s House and - slightly biased to placing progression items with - less restrictions. - ''') - parser.add_argument('--shuffle', default=defval('vanilla'), const='vanilla', nargs='?', choices=['vanilla', 'simple', 'restricted', 'full', 'crossed', 'insanity', 'restricted_legacy', 'full_legacy', 'madness_legacy', 'insanity_legacy', 'dungeons_full', 'dungeons_simple', 'dungeons_crossed'], - help='''\ - Select Entrance Shuffling Algorithm. (default: %(default)s) - Full: Mix cave and dungeon entrances freely while limiting - multi-entrance caves to one world. - Simple: Shuffle Dungeon Entrances/Exits between each other - and keep all 4-entrance dungeons confined to one - location. All caves outside of death mountain are - shuffled in pairs and matched by original type. - Restricted: Use Dungeons shuffling from Simple but freely - connect remaining entrances. - Crossed: Mix cave and dungeon entrances freely while allowing - caves to cross between worlds. - Insanity: Decouple entrances and exits from each other and - shuffle them freely. Caves that used to be single - entrance will still exit to the same location from - which they are entered. - Vanilla: All entrances are in the same locations they were - in the base game. - Legacy shuffles preserve behavior from older versions of the - entrance randomizer including significant technical limitations. - The dungeon variants only mix up dungeons and keep the rest of - the overworld vanilla. - ''') - parser.add_argument('--open_pyramid', default=defval('auto'), help='''\ - Pre-opens the pyramid hole, this removes the Agahnim 2 requirement for it. - Depending on goal, you might still need to beat Agahnim 2 in order to beat ganon. - fast ganon goals are crystals, ganon_triforce_hunt, local_ganon_triforce_hunt, pedestalganon - auto - Only opens pyramid hole if the goal specifies a fast ganon, and entrance shuffle - is vanilla, dungeons_simple or dungeons_full. - goal - Opens pyramid hole if the goal specifies a fast ganon. - yes - Always opens the pyramid hole. - no - Never opens the pyramid hole. - ''', choices=['auto', 'goal', 'yes', 'no']) - - parser.add_argument('--loglevel', default=defval('info'), const='info', nargs='?', choices=['error', 'info', 'warning', 'debug'], help='Select level of logging for output.') parser.add_argument('--seed', help='Define seed number to generate.', type=int) parser.add_argument('--count', help='''\ Use to batch generate multiple seeds with same settings. @@ -195,16 +32,6 @@ def defval(value): --seed given will produce the same 10 (different) roms each time). ''', type=int) - - parser.add_argument('--custom', default=defval(False), help='Not supported.') - parser.add_argument('--customitemarray', default=defval(False), help='Not supported.') - # included for backwards compatibility - parser.add_argument('--shuffleganon', help=argparse.SUPPRESS, action='store_true', default=defval(True)) - parser.add_argument('--no-shuffleganon', help='''\ - If set, the Pyramid Hole and Ganon's Tower are not - included entrance shuffle pool. - ''', action='store_false', dest='shuffleganon') - parser.add_argument('--sprite', help='''\ Path to a sprite sheet to use for Link. Needs to be in binary format and have a length of 0x7000 (28672) bytes, @@ -212,35 +39,12 @@ def defval(value): Alternatively, can be a ALttP Rom patched with a Link sprite that will be extracted. ''') - - parser.add_argument('--shufflebosses', default=defval('none'), choices=['none', 'basic', 'normal', 'chaos', - "singularity"]) - - parser.add_argument('--enemy_health', default=defval('default'), - choices=['default', 'easy', 'normal', 'hard', 'expert']) - parser.add_argument('--enemy_damage', default=defval('default'), choices=['default', 'shuffled', 'chaos']) - parser.add_argument('--beemizer_total_chance', default=defval(0), type=lambda value: min(max(int(value), 0), 100)) - parser.add_argument('--beemizer_trap_chance', default=defval(0), type=lambda value: min(max(int(value), 0), 100)) - parser.add_argument('--shop_shuffle', default='', help='''\ - combine letters for options: - g: generate default inventories for light and dark world shops, and unique shops - f: generate default inventories for each shop individually - i: shuffle the default inventories of the shops around - p: randomize the prices of the items in shop inventories - u: shuffle capacity upgrades into the item pool - w: consider witch's hut like any other shop and shuffle/randomize it too - ''') - parser.add_argument('--shuffle_prizes', default=defval('g'), choices=['', 'g', 'b', 'gb']) parser.add_argument('--sprite_pool', help='''\ Specifies a colon separated list of sprites used for random/randomonevent. If not specified, the full sprite pool is used.''') - parser.add_argument('--dark_room_logic', default=('Lamp'), choices=["lamp", "torches", "none"], help='''\ - For unlit dark rooms, require the Lamp to be considered in logic by default. - Torches means additionally easily accessible Torches that can be lit with Fire Rod are considered doable. - None means full traversal through dark rooms without tools is considered doable.''') parser.add_argument('--multi', default=defval(1), type=lambda value: max(int(value), 1)) parser.add_argument('--names', default=defval('')) parser.add_argument('--outputpath') - parser.add_argument('--game', default="A Link to the Past") + parser.add_argument('--game', default="Archipelago") parser.add_argument('--race', default=defval(False), action='store_true') parser.add_argument('--outputname') if multiargs.multi: @@ -249,43 +53,21 @@ def defval(value): ret = parser.parse_args(argv) - # shuffle medallions - - ret.required_medallions = ("random", "random") # cannot be set through CLI currently ret.plando_items = [] ret.plando_texts = {} ret.plando_connections = [] - if ret.timer == "none": - ret.timer = False - if ret.dungeon_counters == 'on': - ret.dungeon_counters = True - elif ret.dungeon_counters == 'off': - ret.dungeon_counters = False - if multiargs.multi: defaults = copy.deepcopy(ret) for player in range(1, multiargs.multi + 1): playerargs = parse_arguments(shlex.split(getattr(ret, f"p{player}")), True) - for name in ['logic', 'mode', 'goal', 'difficulty', 'item_functionality', - 'shuffle', 'open_pyramid', 'timer', - 'countdown_start_time', 'red_clock_time', 'blue_clock_time', 'green_clock_time', - 'beemizer_total_chance', 'beemizer_trap_chance', - 'shufflebosses', 'enemy_health', 'enemy_damage', - 'sprite', - "triforce_pieces_available", - "triforce_pieces_required", "shop_shuffle", - "required_medallions", - "plando_items", "plando_texts", "plando_connections", - 'dungeon_counters', - 'shuffle_prizes', 'sprite_pool', 'dark_room_logic', - 'game']: + for name in ["plando_items", "plando_texts", "plando_connections", "game", "sprite", "sprite_pool"]: value = getattr(defaults, name) if getattr(playerargs, name) is None else getattr(playerargs, name) if player == 1: setattr(ret, name, {1: value}) else: getattr(ret, name)[player] = value - return ret \ No newline at end of file + return ret diff --git a/worlds/alttp/EntranceShuffle.py b/worlds/alttp/EntranceShuffle.py index 062f0588f623..87e28646a262 100644 --- a/worlds/alttp/EntranceShuffle.py +++ b/worlds/alttp/EntranceShuffle.py @@ -554,19 +554,20 @@ def connect_reachable_exit(entrance, caves, doors): # check for swamp palace fix if world.get_entrance('Dam', player).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', player).connected_region.name != 'Swamp Palace (Entrance)': - world.swamp_patch_required[player] = True + world.worlds[player].swamp_patch_required = True # check for potion shop location if world.get_entrance('Potion Shop', player).connected_region.name != 'Potion Shop': - world.powder_patch_required[player] = True + world.worlds[player].powder_patch_required = True # check for ganon location if world.get_entrance('Pyramid Hole', player).connected_region.name != 'Pyramid': - world.ganon_at_pyramid[player] = False + world.worlds[player].ganon_at_pyramid = False # check for Ganon's Tower location if world.get_entrance('Ganons Tower', player).connected_region.name != 'Ganons Tower (Entrance)': - world.ganonstower_vanilla[player] = False + world.worlds[player].ganonstower_vanilla = False + def link_inverted_entrances(world, player): # Link's house shuffled freely, Houlihan set in mandatory_connections @@ -1261,19 +1262,19 @@ def connect_reachable_exit(entrance, caves, doors): # patch swamp drain if world.get_entrance('Dam', player).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', player).connected_region.name != 'Swamp Palace (Entrance)': - world.swamp_patch_required[player] = True + world.worlds[player].swamp_patch_required = True # check for potion shop location if world.get_entrance('Potion Shop', player).connected_region.name != 'Potion Shop': - world.powder_patch_required[player] = True + world.worlds[player].powder_patch_required = True # check for ganon location if world.get_entrance('Inverted Pyramid Hole', player).connected_region.name != 'Pyramid': - world.ganon_at_pyramid[player] = False + world.worlds[player].ganon_at_pyramid = False # check for Ganon's Tower location if world.get_entrance('Inverted Ganons Tower', player).connected_region.name != 'Ganons Tower (Entrance)': - world.ganonstower_vanilla[player] = False + world.worlds[player].ganonstower_vanilla = False def connect_simple(world, exitname, regionname, player): diff --git a/worlds/alttp/ItemPool.py b/worlds/alttp/ItemPool.py index c26c32a7a309..af35d00f8878 100644 --- a/worlds/alttp/ItemPool.py +++ b/worlds/alttp/ItemPool.py @@ -238,7 +238,7 @@ def generate_itempool(world): raise NotImplementedError(f"Timer {multiworld.timer[player]} for player {player}") if multiworld.timer[player] in ['ohko', 'timed_ohko']: - multiworld.can_take_damage[player] = False + world.can_take_damage = False if multiworld.goal[player] in ['pedestal', 'triforce_hunt', 'local_triforce_hunt']: multiworld.push_item(multiworld.get_location('Ganon', player), item_factory('Nothing', world), False) else: @@ -277,12 +277,12 @@ def generate_itempool(world): # set up item pool additional_triforce_pieces = 0 if multiworld.custom: - (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, - treasure_hunt_icon) = make_custom_item_pool(multiworld, player) + pool, placed_items, precollected_items, clock_mode, treasure_hunt_count = ( + make_custom_item_pool(multiworld, player)) multiworld.rupoor_cost = min(multiworld.customitemarray[67], 9999) else: - pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, \ - treasure_hunt_icon, additional_triforce_pieces = get_pool_core(multiworld, player) + pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, additional_triforce_pieces = ( + get_pool_core(multiworld, player)) for item in precollected_items: multiworld.push_precollected(item_factory(item, world)) @@ -317,11 +317,11 @@ def generate_itempool(world): 'Bomb Upgrade (50)', 'Cane of Somaria', 'Cane of Byrna'] and multiworld.enemy_health[player] not in ['default', 'easy']): if multiworld.bombless_start[player] and "Bomb Upgrade" not in placed_items["Link's Uncle"]: if 'Bow' in placed_items["Link's Uncle"]: - multiworld.escape_assist[player].append('arrows') + multiworld.worlds[player].escape_assist.append('arrows') elif 'Cane' in placed_items["Link's Uncle"]: - multiworld.escape_assist[player].append('magic') + multiworld.worlds[player].escape_assist.append('magic') else: - multiworld.escape_assist[player].append('bombs') + multiworld.worlds[player].escape_assist.append('bombs') for (location, item) in placed_items.items(): multiworld.get_location(location, player).place_locked_item(item_factory(item, world)) @@ -334,13 +334,10 @@ def generate_itempool(world): item.code = 0x65 # Progressive Bow (Alt) break - if clock_mode is not None: - multiworld.clock_mode[player] = clock_mode + if clock_mode: + world.clock_mode = clock_mode - if treasure_hunt_count is not None: - multiworld.treasure_hunt_count[player] = treasure_hunt_count % 999 - if treasure_hunt_icon is not None: - multiworld.treasure_hunt_icon[player] = treasure_hunt_icon + multiworld.worlds[player].treasure_hunt_count = treasure_hunt_count % 999 dungeon_items = [item for item in get_dungeon_item_pool_player(world) if item.name not in multiworld.worlds[player].dungeon_local_item_names] @@ -369,7 +366,7 @@ def generate_itempool(world): elif "Small" in key_data[3] and multiworld.small_key_shuffle[player] == small_key_shuffle.option_universal: # key drop shuffle and universal keys are on. Add universal keys in place of key drop keys. multiworld.itempool.append(item_factory(GetBeemizerItem(multiworld, player, 'Small Key (Universal)'), world)) - dungeon_item_replacements = sum(difficulties[multiworld.difficulty[player]].extras, []) * 2 + dungeon_item_replacements = sum(difficulties[world.options.item_pool.current_key].extras, []) * 2 multiworld.random.shuffle(dungeon_item_replacements) for x in range(len(dungeon_items)-1, -1, -1): @@ -464,8 +461,6 @@ def cut_item(items, item_to_cut, minimum_items): while len(items) > pool_count: items_were_cut = False for reduce_item in items_reduction_table: - if len(items) <= pool_count: - break if len(reduce_item) == 2: items_were_cut = items_were_cut or cut_item(items, *reduce_item) elif len(reduce_item) == 4: @@ -477,7 +472,10 @@ def cut_item(items, item_to_cut, minimum_items): items.remove(bottle) removed_filler.append(bottle) items_were_cut = True - assert items_were_cut, f"Failed to limit item pool size for player {player}" + if items_were_cut: + break + else: + raise Exception(f"Failed to limit item pool size for player {player}") if len(items) < pool_count: items += removed_filler[len(items) - pool_count:] @@ -498,8 +496,8 @@ def cut_item(items, item_to_cut, minimum_items): for i in range(4): next(adv_heart_pieces).classification = ItemClassification.progression - multiworld.required_medallions[player] = (multiworld.misery_mire_medallion[player].current_key.title(), - multiworld.turtle_rock_medallion[player].current_key.title()) + world.required_medallions = (multiworld.misery_mire_medallion[player].current_key.title(), + multiworld.turtle_rock_medallion[player].current_key.title()) place_bosses(world) @@ -591,9 +589,8 @@ def get_pool_core(world, player: int): pool = [] placed_items = {} precollected_items = [] - clock_mode = None - treasure_hunt_count = None - treasure_hunt_icon = None + clock_mode: str = "" + treasure_hunt_count: int = 1 diff = difficulties[difficulty] pool.extend(diff.alwaysitems) @@ -684,19 +681,18 @@ def place_item(loc, item): if world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_extra: triforce_pieces = world.triforce_pieces_available[player].value + world.triforce_pieces_extra[player].value elif world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_percentage: - percentage = float(max(100, world.triforce_pieces_percentage[player].value)) / 100 - triforce_pieces = int(round(world.triforce_pieces_required[player].value * percentage, 0)) + percentage = float(world.triforce_pieces_percentage[player].value) / 100 + triforce_pieces = round(world.triforce_pieces_required[player].value * percentage, 0) else: # available triforce_pieces = world.triforce_pieces_available[player].value - triforce_pieces = max(triforce_pieces, world.triforce_pieces_required[player].value) + triforce_pieces = min(90, max(triforce_pieces, world.triforce_pieces_required[player].value)) pieces_in_core = min(extraitems, triforce_pieces) additional_pieces_to_place = triforce_pieces - pieces_in_core pool.extend(["Triforce Piece"] * pieces_in_core) extraitems -= pieces_in_core treasure_hunt_count = world.triforce_pieces_required[player].value - treasure_hunt_icon = 'Triforce Piece' for extra in diff.extras: if extraitems >= len(extra): @@ -737,7 +733,7 @@ def place_item(loc, item): place_item(key_location, "Small Key (Universal)") pool = pool[:-3] - return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, + return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, additional_pieces_to_place) @@ -752,9 +748,8 @@ def make_custom_item_pool(world, player): pool = [] placed_items = {} precollected_items = [] - clock_mode = None - treasure_hunt_count = None - treasure_hunt_icon = None + clock_mode: str = "" + treasure_hunt_count: int = 1 def place_item(loc, item): assert loc not in placed_items, "cannot place item twice" @@ -850,7 +845,6 @@ def place_item(loc, item): pool.extend(["Triforce Piece"] * world.triforce_pieces_available[player]) itemtotal += world.triforce_pieces_available[player] treasure_hunt_count = world.triforce_pieces_required[player] - treasure_hunt_icon = 'Triforce Piece' if timer in ['display', 'timed', 'timed_countdown']: clock_mode = 'countdown' if timer == 'timed_countdown' else 'stopwatch' @@ -895,4 +889,4 @@ def place_item(loc, item): pool.extend(['Nothing'] * (total_items_to_place - itemtotal)) logging.warning(f"Pool was filled up with {total_items_to_place - itemtotal} Nothing's for player {player}") - return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon) + return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count) diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index 80f7ab7fbec9..11e2f0a37123 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -945,22 +945,22 @@ def credits_digit(num): rom.write_bytes(0x118C64, [first_bot, mid_bot, last_bot]) # patch medallion requirements - if world.required_medallions[player][0] == 'Bombos': + if local_world.required_medallions[0] == 'Bombos': rom.write_byte(0x180022, 0x00) # requirement rom.write_byte(0x4FF2, 0x31) # sprite rom.write_byte(0x50D1, 0x80) rom.write_byte(0x51B0, 0x00) - elif world.required_medallions[player][0] == 'Quake': + elif local_world.required_medallions[0] == 'Quake': rom.write_byte(0x180022, 0x02) # requirement rom.write_byte(0x4FF2, 0x31) # sprite rom.write_byte(0x50D1, 0x88) rom.write_byte(0x51B0, 0x00) - if world.required_medallions[player][1] == 'Bombos': + if local_world.required_medallions[1] == 'Bombos': rom.write_byte(0x180023, 0x00) # requirement rom.write_byte(0x5020, 0x31) # sprite rom.write_byte(0x50FF, 0x90) rom.write_byte(0x51DE, 0x00) - elif world.required_medallions[player][1] == 'Ether': + elif local_world.required_medallions[1] == 'Ether': rom.write_byte(0x180023, 0x01) # requirement rom.write_byte(0x5020, 0x31) # sprite rom.write_byte(0x50FF, 0x98) @@ -1069,7 +1069,7 @@ def credits_digit(num): # Byrna residual magic cost rom.write_bytes(0x45C42, [0x04, 0x02, 0x01]) - difficulty = world.difficulty_requirements[player] + difficulty = local_world.difficulty_requirements # Set overflow items for progressive equipment rom.write_bytes(0x180090, @@ -1240,17 +1240,17 @@ def chunk(l, n): rom.write_byte(0x180044, 0x01) # hammer activates tablets # set up clocks for timed modes - if world.clock_mode[player] in ['ohko', 'countdown-ohko']: + if local_world.clock_mode in ['ohko', 'countdown-ohko']: rom.write_bytes(0x180190, [0x01, 0x02, 0x01]) # ohko timer with resetable timer functionality - elif world.clock_mode[player] == 'stopwatch': + elif local_world.clock_mode == 'stopwatch': rom.write_bytes(0x180190, [0x02, 0x01, 0x00]) # set stopwatch mode - elif world.clock_mode[player] == 'countdown': + elif local_world.clock_mode == 'countdown': rom.write_bytes(0x180190, [0x01, 0x01, 0x00]) # set countdown, with no reset available else: rom.write_bytes(0x180190, [0x00, 0x00, 0x00]) # turn off clock mode # Set up requested clock settings - if world.clock_mode[player] in ['countdown-ohko', 'stopwatch', 'countdown']: + if local_world.clock_mode in ['countdown-ohko', 'stopwatch', 'countdown']: rom.write_int32(0x180200, world.red_clock_time[player] * 60 * 60) # red clock adjustment time (in frames, sint32) rom.write_int32(0x180204, @@ -1263,14 +1263,14 @@ def chunk(l, n): rom.write_int32(0x180208, 0) # green clock adjustment time (in frames, sint32) # Set up requested start time for countdown modes - if world.clock_mode[player] in ['countdown-ohko', 'countdown']: + if local_world.clock_mode in ['countdown-ohko', 'countdown']: rom.write_int32(0x18020C, world.countdown_start_time[player] * 60 * 60) # starting time (in frames, sint32) else: rom.write_int32(0x18020C, 0) # starting time (in frames, sint32) # set up goals for treasure hunt - rom.write_int16(0x180163, world.treasure_hunt_count[player]) - rom.write_bytes(0x180165, [0x0E, 0x28] if world.treasure_hunt_icon[player] == 'Triforce Piece' else [0x0D, 0x28]) + rom.write_int16(0x180163, local_world.treasure_hunt_count) + rom.write_bytes(0x180165, [0x0E, 0x28]) # Triforce Piece Sprite rom.write_byte(0x180194, 1) # Must turn in triforced pieces (instant win not enabled) rom.write_bytes(0x180213, [0x00, 0x01]) # Not a Tournament Seed @@ -1283,14 +1283,14 @@ def chunk(l, n): rom.write_byte(0x180211, gametype) # Game type # assorted fixes - rom.write_byte(0x1800A2, 0x01 if world.fix_fake_world[ - player] else 0x00) # Toggle whether to be in real/fake dark world when dying in a DW dungeon before killing aga1 + # Toggle whether to be in real/fake dark world when dying in a DW dungeon before killing aga1 + rom.write_byte(0x1800A2, 0x01 if local_world.fix_fake_world else 0x00) # Lock or unlock aga tower door during escape sequence. rom.write_byte(0x180169, 0x00) if world.mode[player] == 'inverted': rom.write_byte(0x180169, 0x02) # lock aga/ganon tower door with crystals in inverted rom.write_byte(0x180171, - 0x01 if world.ganon_at_pyramid[player] else 0x00) # Enable respawning on pyramid after ganon death + 0x01 if local_world.ganon_at_pyramid else 0x00) # Enable respawning on pyramid after ganon death rom.write_byte(0x180173, 0x01) # Bob is enabled rom.write_byte(0x180168, 0x08) # Spike Cave Damage rom.write_bytes(0x18016B, [0x04, 0x02, 0x01]) # Set spike cave and MM spike room Cape usage @@ -1306,7 +1306,7 @@ def chunk(l, n): rom.write_byte(0x180086, 0x00 if world.aga_randomness else 0x01) # set blue ball and ganon warp randomness rom.write_byte(0x1800A0, 0x01) # return to light world on s+q without mirror rom.write_byte(0x1800A1, 0x01) # enable overworld screen transition draining for water level inside swamp - rom.write_byte(0x180174, 0x01 if world.fix_fake_world[player] else 0x00) + rom.write_byte(0x180174, 0x01 if local_world.fix_fake_world else 0x00) rom.write_byte(0x18017E, 0x01) # Fairy fountains only trade in bottles # Starting equipment @@ -1448,7 +1448,7 @@ def chunk(l, n): for address in keys[item.name]: equip[address] = min(equip[address] + 1, 99) elif item.name in bottles: - if equip[0x34F] < world.difficulty_requirements[player].progressive_bottle_limit: + if equip[0x34F] < local_world.difficulty_requirements.progressive_bottle_limit: equip[0x35C + equip[0x34F]] = bottles[item.name] equip[0x34F] += 1 elif item.name in rupees: @@ -1507,9 +1507,9 @@ def chunk(l, n): rom.write_bytes(0x180080, [50, 50, 70, 70]) # values to fill for Capacity Upgrades (Bomb5, Bomb10, Arrow5, Arrow10) - rom.write_byte(0x18004D, ((0x01 if 'arrows' in world.escape_assist[player] else 0x00) | - (0x02 if 'bombs' in world.escape_assist[player] else 0x00) | - (0x04 if 'magic' in world.escape_assist[player] else 0x00))) # Escape assist + rom.write_byte(0x18004D, ((0x01 if 'arrows' in local_world.escape_assist else 0x00) | + (0x02 if 'bombs' in local_world.escape_assist else 0x00) | + (0x04 if 'magic' in local_world.escape_assist else 0x00))) # Escape assist if world.goal[player] in ['pedestal', 'triforce_hunt', 'local_triforce_hunt']: rom.write_byte(0x18003E, 0x01) # make ganon invincible @@ -1546,7 +1546,7 @@ def chunk(l, n): rom.write_byte(0x18003B, 0x01 if world.map_shuffle[player] else 0x00) # maps showing crystals on overworld # compasses showing dungeon count - if world.clock_mode[player] or not world.dungeon_counters[player]: + if local_world.clock_mode or not world.dungeon_counters[player]: rom.write_byte(0x18003C, 0x00) # Currently must be off if timer is on, because they use same HUD location elif world.dungeon_counters[player] is True: rom.write_byte(0x18003C, 0x02) # always on @@ -1653,13 +1653,13 @@ def get_reveal_bytes(itemName): rom.write_bytes(0x18018B, [0x20, 0, 0]) # Mantle respawn refills (magic, bombs, arrows) # patch swamp: Need to enable permanent drain of water as dam or swamp were moved - rom.write_byte(0x18003D, 0x01 if world.swamp_patch_required[player] else 0x00) + rom.write_byte(0x18003D, 0x01 if local_world.swamp_patch_required else 0x00) # powder patch: remove the need to leave the screen after powder, since it causes problems for potion shop at race game # temporarally we are just nopping out this check we will conver this to a rom fix soon. rom.write_bytes(0x02F539, - [0xEA, 0xEA, 0xEA, 0xEA, 0xEA] if world.powder_patch_required[player] else [0xAD, 0xBF, 0x0A, 0xF0, - 0x4F]) + [0xEA, 0xEA, 0xEA, 0xEA, 0xEA] if local_world.powder_patch_required else [ + 0xAD, 0xBF, 0x0A, 0xF0, 0x4F]) # allow smith into multi-entrance caves in appropriate shuffles if world.entrance_shuffle[player] in ['restricted', 'full', 'crossed', 'insanity'] or ( @@ -2421,7 +2421,7 @@ def hint_text(dest, ped_hint=False): ' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!' tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint 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 ( + if world.worlds[player].has_progressive_bows and (w.difficulty_requirements.progressive_bow_limit >= 2 or ( world.swordless[player] or world.glitches_required[player] == 'no_glitches')): prog_bow_locs = world.find_item_locations('Progressive Bow', player, True) world.per_slot_randoms[player].shuffle(prog_bow_locs) @@ -2482,16 +2482,16 @@ def hint_text(dest, ped_hint=False): tt['sign_ganon'] = 'Go find the Triforce pieces with your friends... Ganon is invincible!' else: tt['sign_ganon'] = 'Go find the Triforce pieces... Ganon is invincible!' - if world.treasure_hunt_count[player] > 1: + if w.treasure_hunt_count > 1: tt['murahdahla'] = "Hello @. I\nam Murahdahla, brother of\nSahasrahla and Aginah. Behold the power of\n" \ "invisibility.\n\n\n\n… … …\n\nWait! you can see me? I knew I should have\n" \ "hidden in a hollow tree. If you bring\n%d Triforce pieces out of %d, I can reassemble it." % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) else: tt['murahdahla'] = "Hello @. I\nam Murahdahla, brother of\nSahasrahla and Aginah. Behold the power of\n" \ "invisibility.\n\n\n\n… … …\n\nWait! you can see me? I knew I should have\n" \ "hidden in a hollow tree. If you bring\n%d Triforce piece out of %d, I can reassemble it." % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) elif world.goal[player] in ['pedestal']: tt['ganon_fall_in_alt'] = 'Why are you even here?\n You can\'t even hurt me! Your goal is at the pedestal.' tt['ganon_phase_3_alt'] = 'Seriously? Go Away, I will not Die.' @@ -2500,20 +2500,20 @@ def hint_text(dest, ped_hint=False): tt['ganon_fall_in'] = Ganon1_texts[local_random.randint(0, len(Ganon1_texts) - 1)] tt['ganon_fall_in_alt'] = 'You cannot defeat me until you finish your goal!' tt['ganon_phase_3_alt'] = 'Got wax in\nyour ears?\nI can not die!' - if world.treasure_hunt_count[player] > 1: + if w.treasure_hunt_count > 1: if world.goal[player] == 'ganon_triforce_hunt' and world.players > 1: tt['sign_ganon'] = 'You need to find %d Triforce pieces out of %d with your friends to defeat Ganon.' % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) elif world.goal[player] in ['ganon_triforce_hunt', 'local_ganon_triforce_hunt']: tt['sign_ganon'] = 'You need to find %d Triforce pieces out of %d to defeat Ganon.' % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) else: if world.goal[player] == 'ganon_triforce_hunt' and world.players > 1: tt['sign_ganon'] = 'You need to find %d Triforce piece out of %d with your friends to defeat Ganon.' % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) elif world.goal[player] in ['ganon_triforce_hunt', 'local_ganon_triforce_hunt']: tt['sign_ganon'] = 'You need to find %d Triforce piece out of %d to defeat Ganon.' % \ - (world.treasure_hunt_count[player], world.triforce_pieces_available[player]) + (w.treasure_hunt_count, world.triforce_pieces_available[player]) tt['kakariko_tavern_fisherman'] = TavernMan_texts[local_random.randint(0, len(TavernMan_texts) - 1)] diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 6646aae1b93e..9a13c2c5d02f 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -97,7 +97,7 @@ def set_rules(world): # if swamp and dam have not been moved we require mirror for swamp palace # however there is mirrorless swamp in hybrid MG, so we don't necessarily want this. HMG handles this requirement itself. - if not world.swamp_patch_required[player] and world.glitches_required[player] not in ['hybrid_major_glitches', 'no_logic']: + if not world.worlds[player].swamp_patch_required and world.glitches_required[player] not in ['hybrid_major_glitches', 'no_logic']: add_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Magic Mirror', player)) # GT Entrance may be required for Turtle Rock for OWG and < 7 required @@ -186,247 +186,249 @@ def dungeon_boss_rules(world, player): set_defeat_dungeon_boss_rule(world.get_location(location, player)) -def global_rules(world, player): +def global_rules(multiworld: MultiWorld, player: int): + world = multiworld.worlds[player] # ganon can only carry triforce - add_item_rule(world.get_location('Ganon', player), lambda item: item.name == 'Triforce' and item.player == player) + add_item_rule(multiworld.get_location('Ganon', player), lambda item: item.name == 'Triforce' and item.player == player) # dungeon prizes can only be crystals/pendants crystals_and_pendants: Set[str] = \ {item for item, item_data in item_table.items() if item_data.type == "Crystal"} prize_locations: Iterator[str] = \ (locations for locations, location_data in location_table.items() if location_data[2] == True) for prize_location in prize_locations: - add_item_rule(world.get_location(prize_location, player), + add_item_rule(multiworld.get_location(prize_location, player), lambda item: item.name in crystals_and_pendants and item.player == player) # determines which S&Q locations are available - hide from paths since it isn't an in-game location - for exit in world.get_region('Menu', player).exits: + for exit in multiworld.get_region('Menu', player).exits: exit.hide_path = True try: - old_man_sq = world.get_entrance('Old Man S&Q', player) + old_man_sq = multiworld.get_entrance('Old Man S&Q', player) except KeyError: pass # it doesn't exist, should be dungeon-only unittests else: - old_man = world.get_location("Old Man", player) + old_man = multiworld.get_location("Old Man", player) set_rule(old_man_sq, lambda state: old_man.can_reach(state)) - set_rule(world.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player)) - set_rule(world.get_location('Dark Blacksmith Ruins', player), lambda state: state.has('Return Smith', player)) - set_rule(world.get_location('Purple Chest', player), + set_rule(multiworld.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player)) + set_rule(multiworld.get_location('Dark Blacksmith Ruins', player), lambda state: state.has('Return Smith', player)) + set_rule(multiworld.get_location('Purple Chest', player), lambda state: state.has('Pick Up Purple Chest', player)) # Can S&Q with chest - set_rule(world.get_location('Ether Tablet', player), lambda state: can_retrieve_tablet(state, player)) - set_rule(world.get_location('Master Sword Pedestal', player), lambda state: state.has('Red Pendant', player) and state.has('Blue Pendant', player) and state.has('Green Pendant', player)) - - set_rule(world.get_location('Missing Smith', player), lambda state: state.has('Get Frog', player) and state.can_reach('Blacksmiths Hut', 'Region', player)) # Can't S&Q with smith - set_rule(world.get_location('Blacksmith', player), lambda state: state.has('Return Smith', player)) - set_rule(world.get_location('Magic Bat', player), lambda state: state.has('Magic Powder', player)) - set_rule(world.get_location('Sick Kid', player), lambda state: state.has_group("Bottles", player)) - set_rule(world.get_location('Library', player), lambda state: state.has('Pegasus Boots', player)) - - if world.enemy_shuffle[player]: - set_rule(world.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player) and - can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Ether Tablet', player), lambda state: can_retrieve_tablet(state, player)) + set_rule(multiworld.get_location('Master Sword Pedestal', player), lambda state: state.has('Red Pendant', player) and state.has('Blue Pendant', player) and state.has('Green Pendant', player)) + + set_rule(multiworld.get_location('Missing Smith', player), lambda state: state.has('Get Frog', player) and state.can_reach('Blacksmiths Hut', 'Region', player)) # Can't S&Q with smith + set_rule(multiworld.get_location('Blacksmith', player), lambda state: state.has('Return Smith', player)) + set_rule(multiworld.get_location('Magic Bat', player), lambda state: state.has('Magic Powder', player)) + set_rule(multiworld.get_location('Sick Kid', player), lambda state: state.has_group("Bottles", player)) + set_rule(multiworld.get_location('Library', player), lambda state: state.has('Pegasus Boots', player)) + + if multiworld.enemy_shuffle[player]: + set_rule(multiworld.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player) and + can_kill_most_things(state, player, 4)) else: - set_rule(world.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player) - and ((state.multiworld.enemy_health[player] in ("easy", "default") and can_use_bombs(state, player, 4)) + set_rule(multiworld.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player) + and ((state.multiworld.enemy_health[player] in ("easy", "default") and can_use_bombs(state, player, 4)) or can_shoot_arrows(state, player) or state.has("Cane of Somaria", player) or has_beam_sword(state, player))) - set_rule(world.get_location('Sahasrahla', player), lambda state: state.has('Green Pendant', player)) - - set_rule(world.get_location('Aginah\'s Cave', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Blind\'s Hideout - Top', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Chicken House', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Kakariko Well - Top', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Graveyard Cave', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Sahasrahla\'s Hut - Left', player), lambda state: can_bomb_or_bonk(state, player)) - set_rule(world.get_location('Sahasrahla\'s Hut - Middle', player), lambda state: can_bomb_or_bonk(state, player)) - set_rule(world.get_location('Sahasrahla\'s Hut - Right', player), lambda state: can_bomb_or_bonk(state, player)) - set_rule(world.get_location('Paradox Cave Lower - Left', player), lambda state: can_use_bombs(state, player) - or has_beam_sword(state, player) or can_shoot_arrows(state, player) - or state.has_any(["Fire Rod", "Cane of Somaria"], player)) - set_rule(world.get_location('Paradox Cave Lower - Right', player), lambda state: can_use_bombs(state, player) - or has_beam_sword(state, player) or can_shoot_arrows(state, player) - or state.has_any(["Fire Rod", "Cane of Somaria"], player)) - set_rule(world.get_location('Paradox Cave Lower - Far Right', player), lambda state: can_use_bombs(state, player) - or has_beam_sword(state, player) or can_shoot_arrows(state, player) - or state.has_any(["Fire Rod", "Cane of Somaria"], player)) - set_rule(world.get_location('Paradox Cave Lower - Middle', player), lambda state: can_use_bombs(state, player) - or has_beam_sword(state, player) or can_shoot_arrows(state, player) - or state.has_any(["Fire Rod", "Cane of Somaria"], player)) - set_rule(world.get_location('Paradox Cave Lower - Far Left', player), lambda state: can_use_bombs(state, player) - or has_beam_sword(state, player) or can_shoot_arrows(state, player) - or state.has_any(["Fire Rod", "Cane of Somaria"], player)) - set_rule(world.get_location('Paradox Cave Upper - Left', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Paradox Cave Upper - Right', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Mini Moldorm Cave - Far Left', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Mini Moldorm Cave - Left', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Mini Moldorm Cave - Far Right', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Mini Moldorm Cave - Right', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Mini Moldorm Cave - Generous Guy', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Hype Cave - Bottom', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Hype Cave - Middle Left', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Hype Cave - Middle Right', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Hype Cave - Top', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Light World Death Mountain Shop', player), lambda state: can_use_bombs(state, player)) - - set_rule(world.get_entrance('Two Brothers House Exit (West)', player), lambda state: can_bomb_or_bonk(state, player)) - set_rule(world.get_entrance('Two Brothers House Exit (East)', player), lambda state: can_bomb_or_bonk(state, player)) - - set_rule(world.get_location('Spike Cave', player), lambda state: + set_rule(multiworld.get_location('Sahasrahla', player), lambda state: state.has('Green Pendant', player)) + + set_rule(multiworld.get_location('Aginah\'s Cave', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Blind\'s Hideout - Top', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Chicken House', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Kakariko Well - Top', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Graveyard Cave', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Sahasrahla\'s Hut - Left', player), lambda state: can_bomb_or_bonk(state, player)) + set_rule(multiworld.get_location('Sahasrahla\'s Hut - Middle', player), lambda state: can_bomb_or_bonk(state, player)) + set_rule(multiworld.get_location('Sahasrahla\'s Hut - Right', player), lambda state: can_bomb_or_bonk(state, player)) + set_rule(multiworld.get_location('Paradox Cave Lower - Left', player), lambda state: can_use_bombs(state, player) + or has_beam_sword(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Fire Rod", "Cane of Somaria"], player)) + set_rule(multiworld.get_location('Paradox Cave Lower - Right', player), lambda state: can_use_bombs(state, player) + or has_beam_sword(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Fire Rod", "Cane of Somaria"], player)) + set_rule(multiworld.get_location('Paradox Cave Lower - Far Right', player), lambda state: can_use_bombs(state, player) + or has_beam_sword(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Fire Rod", "Cane of Somaria"], player)) + set_rule(multiworld.get_location('Paradox Cave Lower - Middle', player), lambda state: can_use_bombs(state, player) + or has_beam_sword(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Fire Rod", "Cane of Somaria"], player)) + set_rule(multiworld.get_location('Paradox Cave Lower - Far Left', player), lambda state: can_use_bombs(state, player) + or has_beam_sword(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Fire Rod", "Cane of Somaria"], player)) + set_rule(multiworld.get_location('Paradox Cave Upper - Left', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Paradox Cave Upper - Right', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Mini Moldorm Cave - Far Left', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Mini Moldorm Cave - Left', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Mini Moldorm Cave - Far Right', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Mini Moldorm Cave - Right', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Mini Moldorm Cave - Generous Guy', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Hype Cave - Bottom', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Hype Cave - Middle Left', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Hype Cave - Middle Right', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Hype Cave - Top', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Light World Death Mountain Shop', player), lambda state: can_use_bombs(state, player)) + + set_rule(multiworld.get_entrance('Two Brothers House Exit (West)', player), lambda state: can_bomb_or_bonk(state, player)) + set_rule(multiworld.get_entrance('Two Brothers House Exit (East)', player), lambda state: can_bomb_or_bonk(state, player)) + + set_rule(multiworld.get_location('Spike Cave', player), lambda state: state.has('Hammer', player) and can_lift_rocks(state, player) and ((state.has('Cape', player) and can_extend_magic(state, player, 16, True)) or (state.has('Cane of Byrna', player) and (can_extend_magic(state, player, 12, True) or - (state.multiworld.can_take_damage[player] and (state.has('Pegasus Boots', player) or has_hearts(state, player, 4)))))) + (world.can_take_damage and (state.has('Pegasus Boots', player) or has_hearts(state, player, 4)))))) ) - set_rule(world.get_entrance('Hookshot Cave Bomb Wall (North)', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Hookshot Cave Bomb Wall (South)', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Hookshot Cave Bomb Wall (North)', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Hookshot Cave Bomb Wall (South)', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Hookshot Cave - Top Right', player), lambda state: state.has('Hookshot', player)) - set_rule(world.get_location('Hookshot Cave - Top Left', player), lambda state: state.has('Hookshot', player)) - set_rule(world.get_location('Hookshot Cave - Bottom Right', player), + set_rule(multiworld.get_location('Hookshot Cave - Top Right', player), lambda state: state.has('Hookshot', player)) + set_rule(multiworld.get_location('Hookshot Cave - Top Left', player), lambda state: state.has('Hookshot', player)) + set_rule(multiworld.get_location('Hookshot Cave - Bottom Right', player), lambda state: state.has('Hookshot', player) or state.has('Pegasus Boots', player)) - set_rule(world.get_location('Hookshot Cave - Bottom Left', player), lambda state: state.has('Hookshot', player)) + set_rule(multiworld.get_location('Hookshot Cave - Bottom Left', player), lambda state: state.has('Hookshot', player)) - set_rule(world.get_entrance('Sewers Door', player), + set_rule(multiworld.get_entrance('Sewers Door', player), lambda state: state._lttp_has_key('Small Key (Hyrule Castle)', player, 4) or ( - world.small_key_shuffle[player] == small_key_shuffle.option_universal and world.mode[ + multiworld.small_key_shuffle[player] == small_key_shuffle.option_universal and multiworld.mode[ player] == 'standard')) # standard universal small keys cannot access the shop - set_rule(world.get_entrance('Sewers Back Door', player), + set_rule(multiworld.get_entrance('Sewers Back Door', player), lambda state: state._lttp_has_key('Small Key (Hyrule Castle)', player, 4)) - set_rule(world.get_entrance('Sewers Secret Room', player), lambda state: can_bomb_or_bonk(state, player)) + set_rule(multiworld.get_entrance('Sewers Secret Room', player), lambda state: can_bomb_or_bonk(state, player)) - set_rule(world.get_entrance('Agahnim 1', player), + set_rule(multiworld.get_entrance('Agahnim 1', player), lambda state: has_sword(state, player) and state._lttp_has_key('Small Key (Agahnims Tower)', player, 4)) - set_rule(world.get_location('Castle Tower - Room 03', player), lambda state: can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Castle Tower - Dark Maze', player), + set_rule(multiworld.get_location('Castle Tower - Room 03', player), lambda state: can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Castle Tower - Dark Maze', player), lambda state: can_kill_most_things(state, player, 4) and state._lttp_has_key('Small Key (Agahnims Tower)', player)) - set_rule(world.get_location('Castle Tower - Dark Archer Key Drop', player), + set_rule(multiworld.get_location('Castle Tower - Dark Archer Key Drop', player), lambda state: can_kill_most_things(state, player, 4) and state._lttp_has_key('Small Key (Agahnims Tower)', player, 2)) - set_rule(world.get_location('Castle Tower - Circle of Pots Key Drop', player), + set_rule(multiworld.get_location('Castle Tower - Circle of Pots Key Drop', player), lambda state: can_kill_most_things(state, player, 4) and state._lttp_has_key('Small Key (Agahnims Tower)', player, 3)) - set_always_allow(world.get_location('Eastern Palace - Big Key Chest', player), + set_always_allow(multiworld.get_location('Eastern Palace - Big Key Chest', player), lambda state, item: item.name == 'Big Key (Eastern Palace)' and item.player == player) - set_rule(world.get_location('Eastern Palace - Big Key Chest', player), + set_rule(multiworld.get_location('Eastern Palace - Big Key Chest', player), lambda state: can_kill_most_things(state, player, 5) and (state._lttp_has_key('Small Key (Eastern Palace)', player, 2) or ((location_item_name(state, 'Eastern Palace - Big Key Chest', player) == ('Big Key (Eastern Palace)', player) and state.has('Small Key (Eastern Palace)', player))))) - set_rule(world.get_location('Eastern Palace - Dark Eyegore Key Drop', player), + set_rule(multiworld.get_location('Eastern Palace - Dark Eyegore Key Drop', player), lambda state: state.has('Big Key (Eastern Palace)', player) and can_kill_most_things(state, player, 1)) - set_rule(world.get_location('Eastern Palace - Big Chest', player), + set_rule(multiworld.get_location('Eastern Palace - Big Chest', player), lambda state: state.has('Big Key (Eastern Palace)', player)) # not bothering to check for can_kill_most_things in the rooms leading to boss, as if you can kill a boss you should # be able to get through these rooms - ep_boss = world.get_location('Eastern Palace - Boss', player) + ep_boss = multiworld.get_location('Eastern Palace - Boss', player) add_rule(ep_boss, lambda state: state.has('Big Key (Eastern Palace)', player) and state._lttp_has_key('Small Key (Eastern Palace)', player, 2) and ep_boss.parent_region.dungeon.boss.can_defeat(state)) - ep_prize = world.get_location('Eastern Palace - Prize', player) + ep_prize = multiworld.get_location('Eastern Palace - Prize', player) add_rule(ep_prize, lambda state: state.has('Big Key (Eastern Palace)', player) and state._lttp_has_key('Small Key (Eastern Palace)', player, 2) and ep_prize.parent_region.dungeon.boss.can_defeat(state)) - if not world.enemy_shuffle[player]: + if not multiworld.enemy_shuffle[player]: add_rule(ep_boss, lambda state: can_shoot_arrows(state, player)) add_rule(ep_prize, lambda state: can_shoot_arrows(state, player)) # You can always kill the Stalfos' with the pots on easy/normal - if world.enemy_health[player] in ("hard", "expert") or world.enemy_shuffle[player]: + if multiworld.enemy_health[player] in ("hard", "expert") or multiworld.enemy_shuffle[player]: stalfos_rule = lambda state: can_kill_most_things(state, player, 4) for location in ['Eastern Palace - Compass Chest', 'Eastern Palace - Big Chest', 'Eastern Palace - Dark Square Pot Key', 'Eastern Palace - Dark Eyegore Key Drop', 'Eastern Palace - Big Key Chest', 'Eastern Palace - Boss', 'Eastern Palace - Prize']: - add_rule(world.get_location(location, player), stalfos_rule) + add_rule(multiworld.get_location(location, player), stalfos_rule) - set_rule(world.get_location('Desert Palace - Big Chest', player), lambda state: state.has('Big Key (Desert Palace)', player)) - set_rule(world.get_location('Desert Palace - Torch', player), lambda state: state.has('Pegasus Boots', player)) + set_rule(multiworld.get_location('Desert Palace - Big Chest', player), lambda state: state.has('Big Key (Desert Palace)', player)) + set_rule(multiworld.get_location('Desert Palace - Torch', player), lambda state: state.has('Pegasus Boots', player)) - set_rule(world.get_entrance('Desert Palace East Wing', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4)) - set_rule(world.get_location('Desert Palace - Big Key Chest', player), lambda state: can_kill_most_things(state, player, 3)) - set_rule(world.get_location('Desert Palace - Beamos Hall Pot Key', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 2) and can_kill_most_things(state, player, 4)) - set_rule(world.get_location('Desert Palace - Desert Tiles 2 Pot Key', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 3) and can_kill_most_things(state, player, 4)) - add_rule(world.get_location('Desert Palace - Prize', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4) and state.has('Big Key (Desert Palace)', player) and has_fire_source(state, player) and state.multiworld.get_location('Desert Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) - add_rule(world.get_location('Desert Palace - Boss', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4) and state.has('Big Key (Desert Palace)', player) and has_fire_source(state, player) and state.multiworld.get_location('Desert Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) + set_rule(multiworld.get_entrance('Desert Palace East Wing', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4)) + set_rule(multiworld.get_location('Desert Palace - Big Key Chest', player), lambda state: can_kill_most_things(state, player, 3)) + set_rule(multiworld.get_location('Desert Palace - Beamos Hall Pot Key', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 2) and can_kill_most_things(state, player, 4)) + set_rule(multiworld.get_location('Desert Palace - Desert Tiles 2 Pot Key', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 3) and can_kill_most_things(state, player, 4)) + add_rule(multiworld.get_location('Desert Palace - Prize', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4) and state.has('Big Key (Desert Palace)', player) and has_fire_source(state, player) and state.multiworld.get_location('Desert Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) + add_rule(multiworld.get_location('Desert Palace - Boss', player), lambda state: state._lttp_has_key('Small Key (Desert Palace)', player, 4) and state.has('Big Key (Desert Palace)', player) and has_fire_source(state, player) and state.multiworld.get_location('Desert Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) # logic patch to prevent placing a crystal in Desert that's required to reach the required keys - if not (world.small_key_shuffle[player] and world.big_key_shuffle[player]): - add_rule(world.get_location('Desert Palace - Prize', player), lambda state: state.multiworld.get_region('Desert Palace Main (Outer)', player).can_reach(state)) + if not (multiworld.small_key_shuffle[player] and multiworld.big_key_shuffle[player]): + add_rule(multiworld.get_location('Desert Palace - Prize', player), lambda state: state.multiworld.get_region('Desert Palace Main (Outer)', player).can_reach(state)) - set_rule(world.get_entrance('Tower of Hera Small Key Door', player), lambda state: state._lttp_has_key('Small Key (Tower of Hera)', player) or location_item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player)) - set_rule(world.get_entrance('Tower of Hera Big Key Door', player), lambda state: state.has('Big Key (Tower of Hera)', player)) - if world.enemy_shuffle[player]: - add_rule(world.get_entrance('Tower of Hera Big Key Door', player), lambda state: can_kill_most_things(state, player, 3)) + set_rule(multiworld.get_entrance('Tower of Hera Small Key Door', player), lambda state: state._lttp_has_key('Small Key (Tower of Hera)', player) or location_item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player)) + set_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + if multiworld.enemy_shuffle[player]: + add_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: can_kill_most_things(state, player, 3)) else: - add_rule(world.get_entrance('Tower of Hera Big Key Door', player), + add_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: (has_melee_weapon(state, player) or (state.has('Silver Bow', player) and can_shoot_arrows(state, player)) or state.has("Cane of Byrna", player) or state.has("Cane of Somaria", player))) - set_rule(world.get_location('Tower of Hera - Big Chest', player), lambda state: state.has('Big Key (Tower of Hera)', player)) - set_rule(world.get_location('Tower of Hera - Big Key Chest', player), lambda state: has_fire_source(state, player)) - if world.accessibility[player] != 'locations': - set_always_allow(world.get_location('Tower of Hera - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Tower of Hera)' and item.player == player) - - set_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player)) - set_rule(world.get_entrance('Swamp Palace Small Key Door', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player)) - set_rule(world.get_location('Swamp Palace - Map Chest', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_location('Swamp Palace - Trench 1 Pot Key', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 2)) - set_rule(world.get_entrance('Swamp Palace (Center)', player), lambda state: state.has('Hammer', player) and state._lttp_has_key('Small Key (Swamp Palace)', player, 3)) - set_rule(world.get_location('Swamp Palace - Hookshot Pot Key', player), lambda state: state.has('Hookshot', player)) - if world.pot_shuffle[player]: + set_rule(multiworld.get_location('Tower of Hera - Big Chest', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(multiworld.get_location('Tower of Hera - Big Key Chest', player), lambda state: has_fire_source(state, player)) + if multiworld.accessibility[player] != 'locations': + set_always_allow(multiworld.get_location('Tower of Hera - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Tower of Hera)' and item.player == player) + + set_rule(multiworld.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player)) + set_rule(multiworld.get_entrance('Swamp Palace Small Key Door', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player)) + set_rule(multiworld.get_location('Swamp Palace - Map Chest', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Swamp Palace - Trench 1 Pot Key', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 2)) + set_rule(multiworld.get_entrance('Swamp Palace (Center)', player), lambda state: state.has('Hammer', player) and state._lttp_has_key('Small Key (Swamp Palace)', player, 3)) + set_rule(multiworld.get_location('Swamp Palace - Hookshot Pot Key', player), lambda state: state.has('Hookshot', player)) + if multiworld.pot_shuffle[player]: # it could move the key to the top right platform which can only be reached with bombs - add_rule(world.get_location('Swamp Palace - Hookshot Pot Key', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Swamp Palace (West)', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6) + add_rule(multiworld.get_location('Swamp Palace - Hookshot Pot Key', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Swamp Palace (West)', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6) if state.has('Hookshot', player) else state._lttp_has_key('Small Key (Swamp Palace)', player, 4)) - set_rule(world.get_location('Swamp Palace - Big Chest', player), lambda state: state.has('Big Key (Swamp Palace)', player)) - if world.accessibility[player] != 'locations': - allow_self_locking_items(world.get_location('Swamp Palace - Big Chest', player), 'Big Key (Swamp Palace)') - set_rule(world.get_entrance('Swamp Palace (North)', player), lambda state: state.has('Hookshot', player) and state._lttp_has_key('Small Key (Swamp Palace)', player, 5)) - if not world.small_key_shuffle[player] and world.glitches_required[player] not in ['hybrid_major_glitches', 'no_logic']: - forbid_item(world.get_location('Swamp Palace - Entrance', player), 'Big Key (Swamp Palace)', player) - set_rule(world.get_location('Swamp Palace - Prize', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6)) - set_rule(world.get_location('Swamp Palace - Boss', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6)) - if world.pot_shuffle[player]: + set_rule(multiworld.get_location('Swamp Palace - Big Chest', player), lambda state: state.has('Big Key (Swamp Palace)', player)) + if multiworld.accessibility[player] != 'locations': + allow_self_locking_items(multiworld.get_location('Swamp Palace - Big Chest', player), 'Big Key (Swamp Palace)') + set_rule(multiworld.get_entrance('Swamp Palace (North)', player), lambda state: state.has('Hookshot', player) and state._lttp_has_key('Small Key (Swamp Palace)', player, 5)) + if not multiworld.small_key_shuffle[player] and multiworld.glitches_required[player] not in ['hybrid_major_glitches', 'no_logic']: + forbid_item(multiworld.get_location('Swamp Palace - Entrance', player), 'Big Key (Swamp Palace)', player) + set_rule(multiworld.get_location('Swamp Palace - Prize', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6)) + set_rule(multiworld.get_location('Swamp Palace - Boss', player), lambda state: state._lttp_has_key('Small Key (Swamp Palace)', player, 6)) + if multiworld.pot_shuffle[player]: # key can (and probably will) be moved behind bombable wall - set_rule(world.get_location('Swamp Palace - Waterway Pot Key', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Swamp Palace - Waterway Pot Key', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player)) + set_rule(multiworld.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player)) - if world.worlds[player].dungeons["Thieves Town"].boss.enemizer_name == "Blind": - set_rule(world.get_entrance('Blind Fight', player), lambda state: state._lttp_has_key('Small Key (Thieves Town)', player, 3) and can_use_bombs(state, player)) + if multiworld.worlds[player].dungeons["Thieves Town"].boss.enemizer_name == "Blind": + set_rule(multiworld.get_entrance('Blind Fight', player), lambda state: state._lttp_has_key('Small Key (Thieves Town)', player, 3) and can_use_bombs(state, player)) - set_rule(world.get_location('Thieves\' Town - Big Chest', player), + set_rule(multiworld.get_location('Thieves\' Town - Big Chest', player), lambda state: ((state._lttp_has_key('Small Key (Thieves Town)', player, 3)) or (location_item_name(state, 'Thieves\' Town - Big Chest', player) == ("Small Key (Thieves Town)", player)) and state._lttp_has_key('Small Key (Thieves Town)', player, 2)) and state.has('Hammer', player)) - if world.accessibility[player] != 'locations': - set_always_allow(world.get_location('Thieves\' Town - Big Chest', player), lambda state, item: item.name == 'Small Key (Thieves Town)' and item.player == player) - set_rule(world.get_location('Thieves\' Town - Attic', player), lambda state: state._lttp_has_key('Small Key (Thieves Town)', player, 3)) - set_rule(world.get_location('Thieves\' Town - Spike Switch Pot Key', player), + if multiworld.accessibility[player] != 'locations' and not multiworld.key_drop_shuffle[player]: + set_always_allow(multiworld.get_location('Thieves\' Town - Big Chest', player), lambda state, item: item.name == 'Small Key (Thieves Town)' and item.player == player) + + set_rule(multiworld.get_location('Thieves\' Town - Attic', player), lambda state: state._lttp_has_key('Small Key (Thieves Town)', player, 3)) + set_rule(multiworld.get_location('Thieves\' Town - Spike Switch Pot Key', player), lambda state: state._lttp_has_key('Small Key (Thieves Town)', player)) # We need so many keys in the SW doors because they are all reachable as the last door (except for the door to mothula) - set_rule(world.get_entrance('Skull Woods First Section South Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - set_rule(world.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - set_rule(world.get_entrance('Skull Woods First Section West Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - set_rule(world.get_location('Skull Woods - Big Chest', player), lambda state: state.has('Big Key (Skull Woods)', player) and can_use_bombs(state, player)) - if world.accessibility[player] != 'locations': - allow_self_locking_items(world.get_location('Skull Woods - Big Chest', player), 'Big Key (Skull Woods)') - set_rule(world.get_entrance('Skull Woods Torch Room', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 4) and state.has('Fire Rod', player) and has_sword(state, player)) # sword required for curtain - add_rule(world.get_location('Skull Woods - Prize', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - add_rule(world.get_location('Skull Woods - Boss', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) - - set_rule(world.get_location('Ice Palace - Jelly Key Drop', player), lambda state: can_melt_things(state, player)) - set_rule(world.get_location('Ice Palace - Compass Chest', player), lambda state: can_melt_things(state, player) and state._lttp_has_key('Small Key (Ice Palace)', player)) - set_rule(world.get_entrance('Ice Palace (Second Section)', player), lambda state: can_melt_things(state, player) and state._lttp_has_key('Small Key (Ice Palace)', player) and can_use_bombs(state, player)) - - set_rule(world.get_entrance('Ice Palace (Main)', player), lambda state: state._lttp_has_key('Small Key (Ice Palace)', player, 2)) - set_rule(world.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player)) - set_rule(world.get_entrance('Ice Palace (Kholdstare)', player), lambda state: can_lift_rocks(state, player) and state.has('Hammer', player) and state.has('Big Key (Ice Palace)', player) and (state._lttp_has_key('Small Key (Ice Palace)', player, 6) or (state.has('Cane of Somaria', player) and state._lttp_has_key('Small Key (Ice Palace)', player, 5)))) + set_rule(multiworld.get_entrance('Skull Woods First Section South Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + set_rule(multiworld.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + set_rule(multiworld.get_entrance('Skull Woods First Section West Door', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + set_rule(multiworld.get_entrance('Skull Woods First Section (Left) Door to Exit', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + set_rule(multiworld.get_location('Skull Woods - Big Chest', player), lambda state: state.has('Big Key (Skull Woods)', player) and can_use_bombs(state, player)) + if multiworld.accessibility[player] != 'locations': + allow_self_locking_items(multiworld.get_location('Skull Woods - Big Chest', player), 'Big Key (Skull Woods)') + set_rule(multiworld.get_entrance('Skull Woods Torch Room', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 4) and state.has('Fire Rod', player) and has_sword(state, player)) # sword required for curtain + add_rule(multiworld.get_location('Skull Woods - Prize', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + add_rule(multiworld.get_location('Skull Woods - Boss', player), lambda state: state._lttp_has_key('Small Key (Skull Woods)', player, 5)) + + set_rule(multiworld.get_location('Ice Palace - Jelly Key Drop', player), lambda state: can_melt_things(state, player)) + set_rule(multiworld.get_location('Ice Palace - Compass Chest', player), lambda state: can_melt_things(state, player) and state._lttp_has_key('Small Key (Ice Palace)', player)) + set_rule(multiworld.get_entrance('Ice Palace (Second Section)', player), lambda state: can_melt_things(state, player) and state._lttp_has_key('Small Key (Ice Palace)', player) and can_use_bombs(state, player)) + + set_rule(multiworld.get_entrance('Ice Palace (Main)', player), lambda state: state._lttp_has_key('Small Key (Ice Palace)', player, 2)) + set_rule(multiworld.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player)) + set_rule(multiworld.get_entrance('Ice Palace (Kholdstare)', player), lambda state: can_lift_rocks(state, player) and state.has('Hammer', player) and state.has('Big Key (Ice Palace)', player) and (state._lttp_has_key('Small Key (Ice Palace)', player, 6) or (state.has('Cane of Somaria', player) and state._lttp_has_key('Small Key (Ice Palace)', player, 5)))) # This is a complicated rule, so let's break it down. # Hookshot always suffices to get to the right side. # Also, once you get over there, you have to cross the spikes, so that's the last line. @@ -436,102 +438,102 @@ def global_rules(world, player): # Hence if big key is available then it's 6 keys, otherwise 4 keys. # If key_drop is off, then we have 3 drop keys available, and can never satisfy the 6 key requirement because one key is on right side, # so this reduces perfectly to original logic. - set_rule(world.get_entrance('Ice Palace (East)', player), lambda state: (state.has('Hookshot', player) or - (state._lttp_has_key('Small Key (Ice Palace)', player, 4) + set_rule(multiworld.get_entrance('Ice Palace (East)', player), lambda state: (state.has('Hookshot', player) or + (state._lttp_has_key('Small Key (Ice Palace)', player, 4) if item_name_in_location_names(state, 'Big Key (Ice Palace)', player, [('Ice Palace - Spike Room', player), ('Ice Palace - Hammer Block Key Drop', player), ('Ice Palace - Big Key Chest', player), ('Ice Palace - Map Chest', player)]) - else state._lttp_has_key('Small Key (Ice Palace)', player, 6))) and - (state.multiworld.can_take_damage[player] or state.has('Hookshot', player) or state.has('Cape', player) or state.has('Cane of Byrna', player))) - set_rule(world.get_entrance('Ice Palace (East Top)', player), lambda state: can_lift_rocks(state, player) and state.has('Hammer', player)) + else state._lttp_has_key('Small Key (Ice Palace)', player, 6))) and ( + world.can_take_damage or state.has('Hookshot', player) or state.has('Cape', player) or state.has('Cane of Byrna', player))) + set_rule(multiworld.get_entrance('Ice Palace (East Top)', player), lambda state: can_lift_rocks(state, player) and state.has('Hammer', player)) - set_rule(world.get_entrance('Misery Mire Entrance Gap', player), lambda state: (state.has('Pegasus Boots', player) or state.has('Hookshot', player)) and (has_sword(state, player) or state.has('Fire Rod', player) or state.has('Ice Rod', player) or state.has('Hammer', player) or state.has('Cane of Somaria', player) or can_shoot_arrows(state, player))) # need to defeat wizzrobes, bombs don't work ... - set_rule(world.get_location('Misery Mire - Fishbone Pot Key', player), lambda state: state.has('Big Key (Misery Mire)', player) or state._lttp_has_key('Small Key (Misery Mire)', player, 4)) + set_rule(multiworld.get_entrance('Misery Mire Entrance Gap', player), lambda state: (state.has('Pegasus Boots', player) or state.has('Hookshot', player)) and (has_sword(state, player) or state.has('Fire Rod', player) or state.has('Ice Rod', player) or state.has('Hammer', player) or state.has('Cane of Somaria', player) or can_shoot_arrows(state, player))) # need to defeat wizzrobes, bombs don't work ... + set_rule(multiworld.get_location('Misery Mire - Fishbone Pot Key', player), lambda state: state.has('Big Key (Misery Mire)', player) or state._lttp_has_key('Small Key (Misery Mire)', player, 4)) - set_rule(world.get_location('Misery Mire - Big Chest', player), lambda state: state.has('Big Key (Misery Mire)', player)) - set_rule(world.get_location('Misery Mire - Spike Chest', player), lambda state: (state.multiworld.can_take_damage[player] and has_hearts(state, player, 4)) or state.has('Cane of Byrna', player) or state.has('Cape', player)) - set_rule(world.get_entrance('Misery Mire Big Key Door', player), lambda state: state.has('Big Key (Misery Mire)', player)) + set_rule(multiworld.get_location('Misery Mire - Big Chest', player), lambda state: state.has('Big Key (Misery Mire)', player)) + set_rule(multiworld.get_location('Misery Mire - Spike Chest', player), lambda state: (world.can_take_damage and has_hearts(state, player, 4)) or state.has('Cane of Byrna', player) or state.has('Cape', player)) + set_rule(multiworld.get_entrance('Misery Mire Big Key Door', player), lambda state: state.has('Big Key (Misery Mire)', player)) # How to access crystal switch: # If have big key: then you will need 2 small keys to be able to hit switch and return to main area, as you can burn key in dark room # If not big key: cannot burn key in dark room, hence need only 1 key. all doors immediately available lead to a crystal switch. # The listed chests are those which can be reached if you can reach a crystal switch. - set_rule(world.get_location('Misery Mire - Map Chest', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 2)) - set_rule(world.get_location('Misery Mire - Main Lobby', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 2)) + set_rule(multiworld.get_location('Misery Mire - Map Chest', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 2)) + set_rule(multiworld.get_location('Misery Mire - Main Lobby', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 2)) # we can place a small key in the West wing iff it also contains/blocks the Big Key, as we cannot reach and softlock with the basement key door yet - set_rule(world.get_location('Misery Mire - Conveyor Crystal Key Drop', player), + set_rule(multiworld.get_location('Misery Mire - Conveyor Crystal Key Drop', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 4) if location_item_name(state, 'Misery Mire - Compass Chest', player) == ('Big Key (Misery Mire)', player) or location_item_name(state, 'Misery Mire - Big Key Chest', player) == ('Big Key (Misery Mire)', player) or location_item_name(state, 'Misery Mire - Conveyor Crystal Key Drop', player) == ('Big Key (Misery Mire)', player) else state._lttp_has_key('Small Key (Misery Mire)', player, 5)) - set_rule(world.get_entrance('Misery Mire (West)', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 5) + set_rule(multiworld.get_entrance('Misery Mire (West)', player), lambda state: state._lttp_has_key('Small Key (Misery Mire)', player, 5) if ((location_item_name(state, 'Misery Mire - Compass Chest', player) in [('Big Key (Misery Mire)', player)]) or (location_item_name(state, 'Misery Mire - Big Key Chest', player) in [('Big Key (Misery Mire)', player)])) else state._lttp_has_key('Small Key (Misery Mire)', player, 6)) - set_rule(world.get_location('Misery Mire - Compass Chest', player), lambda state: has_fire_source(state, player)) - set_rule(world.get_location('Misery Mire - Big Key Chest', player), lambda state: has_fire_source(state, player)) - set_rule(world.get_entrance('Misery Mire (Vitreous)', player), lambda state: state.has('Cane of Somaria', player) and can_use_bombs(state, player)) - - set_rule(world.get_entrance('Turtle Rock Entrance Gap', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_location('Turtle Rock - Pokey 1 Key Drop', player), lambda state: can_kill_most_things(state, player, 5)) - set_rule(world.get_location('Turtle Rock - Pokey 2 Key Drop', player), lambda state: can_kill_most_things(state, player, 5)) - set_rule(world.get_location('Turtle Rock - Compass Chest', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_location('Turtle Rock - Roller Room - Left', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) - set_rule(world.get_location('Turtle Rock - Roller Room - Right', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) - set_rule(world.get_location('Turtle Rock - Big Chest', player), lambda state: state.has('Big Key (Turtle Rock)', player) and (state.has('Cane of Somaria', player) or state.has('Hookshot', player))) - set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)', player), lambda state: state.has('Cane of Somaria', player) or state.has('Hookshot', player)) - set_rule(world.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player) and can_kill_most_things(state, player, 10)) - set_rule(world.get_location('Turtle Rock - Chain Chomps', player), lambda state: can_use_bombs(state, player) or can_shoot_arrows(state, player) - or has_beam_sword(state, player) or state.has_any(["Blue Boomerang", "Red Boomerang", "Hookshot", "Cane of Somaria", "Fire Rod", "Ice Rod"], player)) - set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) - set_rule(world.get_entrance('Turtle Rock (Trinexx)', player), lambda state: state._lttp_has_key('Small Key (Turtle Rock)', player, 6) and state.has('Big Key (Turtle Rock)', player) and state.has('Cane of Somaria', player)) - set_rule(world.get_entrance('Turtle Rock Second Section Bomb Wall', player), lambda state: can_kill_most_things(state, player, 10)) - - if not world.worlds[player].fix_trock_doors: - add_rule(world.get_entrance('Turtle Rock Second Section Bomb Wall', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Turtle Rock Second Section from Bomb Wall', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Turtle Rock Eye Bridge from Bomb Wall', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Turtle Rock Eye Bridge Bomb Wall', player), lambda state: can_use_bombs(state, player)) - - if world.enemy_shuffle[player]: - set_rule(world.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: can_bomb_or_bonk(state, player) and can_kill_most_things(state, player, 3)) + set_rule(multiworld.get_location('Misery Mire - Compass Chest', player), lambda state: has_fire_source(state, player)) + set_rule(multiworld.get_location('Misery Mire - Big Key Chest', player), lambda state: has_fire_source(state, player)) + set_rule(multiworld.get_entrance('Misery Mire (Vitreous)', player), lambda state: state.has('Cane of Somaria', player) and can_use_bombs(state, player)) + + set_rule(multiworld.get_entrance('Turtle Rock Entrance Gap', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_entrance('Turtle Rock Entrance Gap Reverse', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_location('Turtle Rock - Pokey 1 Key Drop', player), lambda state: can_kill_most_things(state, player, 5)) + set_rule(multiworld.get_location('Turtle Rock - Pokey 2 Key Drop', player), lambda state: can_kill_most_things(state, player, 5)) + set_rule(multiworld.get_location('Turtle Rock - Compass Chest', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_location('Turtle Rock - Roller Room - Left', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(multiworld.get_location('Turtle Rock - Roller Room - Right', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(multiworld.get_location('Turtle Rock - Big Chest', player), lambda state: state.has('Big Key (Turtle Rock)', player) and (state.has('Cane of Somaria', player) or state.has('Hookshot', player))) + set_rule(multiworld.get_entrance('Turtle Rock (Big Chest) (North)', player), lambda state: state.has('Cane of Somaria', player) or state.has('Hookshot', player)) + set_rule(multiworld.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player) and can_kill_most_things(state, player, 10)) + set_rule(multiworld.get_location('Turtle Rock - Chain Chomps', player), lambda state: can_use_bombs(state, player) or can_shoot_arrows(state, player) + or has_beam_sword(state, player) or state.has_any(["Blue Boomerang", "Red Boomerang", "Hookshot", "Cane of Somaria", "Fire Rod", "Ice Rod"], player)) + set_rule(multiworld.get_entrance('Turtle Rock (Dark Room) (North)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_entrance('Turtle Rock (Dark Room) (South)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_location('Turtle Rock - Eye Bridge - Bottom Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(multiworld.get_location('Turtle Rock - Eye Bridge - Bottom Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(multiworld.get_location('Turtle Rock - Eye Bridge - Top Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(multiworld.get_location('Turtle Rock - Eye Bridge - Top Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(multiworld.get_entrance('Turtle Rock (Trinexx)', player), lambda state: state._lttp_has_key('Small Key (Turtle Rock)', player, 6) and state.has('Big Key (Turtle Rock)', player) and state.has('Cane of Somaria', player)) + set_rule(multiworld.get_entrance('Turtle Rock Second Section Bomb Wall', player), lambda state: can_kill_most_things(state, player, 10)) + + if not multiworld.worlds[player].fix_trock_doors: + add_rule(multiworld.get_entrance('Turtle Rock Second Section Bomb Wall', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Turtle Rock Second Section from Bomb Wall', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Turtle Rock Eye Bridge from Bomb Wall', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_entrance('Turtle Rock Eye Bridge Bomb Wall', player), lambda state: can_use_bombs(state, player)) + + if multiworld.enemy_shuffle[player]: + set_rule(multiworld.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: can_bomb_or_bonk(state, player) and can_kill_most_things(state, player, 3)) else: - set_rule(world.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: can_bomb_or_bonk(state, player) and can_shoot_arrows(state, player)) - set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop', player), lambda state: state.has('Hammer', player)) - set_rule(world.get_entrance('Palace of Darkness Bridge Room', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 1)) # If we can reach any other small key door, we already have back door access to this area - set_rule(world.get_entrance('Palace of Darkness Big Key Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) and state.has('Big Key (Palace of Darkness)', player) and can_shoot_arrows(state, player) and state.has('Hammer', player)) - set_rule(world.get_entrance('Palace of Darkness (North)', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 4)) - set_rule(world.get_location('Palace of Darkness - Big Chest', player), lambda state: can_use_bombs(state, player) and state.has('Big Key (Palace of Darkness)', player)) - set_rule(world.get_location('Palace of Darkness - The Arena - Ledge', player), lambda state: can_use_bombs(state, player)) - if world.pot_shuffle[player]: + set_rule(multiworld.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: can_bomb_or_bonk(state, player) and can_shoot_arrows(state, player)) + set_rule(multiworld.get_entrance('Palace of Darkness Hammer Peg Drop', player), lambda state: state.has('Hammer', player)) + set_rule(multiworld.get_entrance('Palace of Darkness Bridge Room', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 1)) # If we can reach any other small key door, we already have back door access to this area + set_rule(multiworld.get_entrance('Palace of Darkness Big Key Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) and state.has('Big Key (Palace of Darkness)', player) and can_shoot_arrows(state, player) and state.has('Hammer', player)) + set_rule(multiworld.get_entrance('Palace of Darkness (North)', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 4)) + set_rule(multiworld.get_location('Palace of Darkness - Big Chest', player), lambda state: can_use_bombs(state, player) and state.has('Big Key (Palace of Darkness)', player)) + set_rule(multiworld.get_location('Palace of Darkness - The Arena - Ledge', player), lambda state: can_use_bombs(state, player)) + if multiworld.pot_shuffle[player]: # chest switch may be up on ledge where bombs are required - set_rule(world.get_location('Palace of Darkness - Stalfos Basement', player), lambda state: can_use_bombs(state, player)) + set_rule(multiworld.get_location('Palace of Darkness - Stalfos Basement', player), lambda state: can_use_bombs(state, player)) - set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase', player), lambda state: can_use_bombs(state, player) and (state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) or ( + set_rule(multiworld.get_entrance('Palace of Darkness Big Key Chest Staircase', player), lambda state: can_use_bombs(state, player) and (state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) or ( location_item_name(state, 'Palace of Darkness - Big Key Chest', player) in [('Small Key (Palace of Darkness)', player)] and state._lttp_has_key('Small Key (Palace of Darkness)', player, 3)))) - if world.accessibility[player] != 'locations': - set_always_allow(world.get_location('Palace of Darkness - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state._lttp_has_key('Small Key (Palace of Darkness)', player, 5)) + if multiworld.accessibility[player] != 'locations': + set_always_allow(multiworld.get_location('Palace of Darkness - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state._lttp_has_key('Small Key (Palace of Darkness)', player, 5)) - set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) or ( + set_rule(multiworld.get_entrance('Palace of Darkness Spike Statue Room Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6) or ( location_item_name(state, 'Palace of Darkness - Harmless Hellway', player) in [('Small Key (Palace of Darkness)', player)] and state._lttp_has_key('Small Key (Palace of Darkness)', player, 4))) - if world.accessibility[player] != 'locations': - set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state._lttp_has_key('Small Key (Palace of Darkness)', player, 5)) + if multiworld.accessibility[player] != 'locations': + set_always_allow(multiworld.get_location('Palace of Darkness - Harmless Hellway', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state._lttp_has_key('Small Key (Palace of Darkness)', player, 5)) - set_rule(world.get_entrance('Palace of Darkness Maze Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6)) + set_rule(multiworld.get_entrance('Palace of Darkness Maze Door', player), lambda state: state._lttp_has_key('Small Key (Palace of Darkness)', player, 6)) # these key rules are conservative, you might be able to get away with more lenient rules randomizer_room_chests = ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', 'Ganons Tower - Randomizer Room - Bottom Left', 'Ganons Tower - Randomizer Room - Bottom Right'] compass_room_chests = ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', 'Ganons Tower - Compass Room - Bottom Left', 'Ganons Tower - Compass Room - Bottom Right', 'Ganons Tower - Conveyor Star Pits Pot Key'] back_chests = ['Ganons Tower - Bob\'s Chest', 'Ganons Tower - Big Chest', 'Ganons Tower - Big Key Room - Left', 'Ganons Tower - Big Key Room - Right', 'Ganons Tower - Big Key Chest'] - set_rule(world.get_location('Ganons Tower - Bob\'s Torch', player), lambda state: state.has('Pegasus Boots', player)) - set_rule(world.get_entrance('Ganons Tower (Tile Room)', player), lambda state: state.has('Cane of Somaria', player)) - set_rule(world.get_entrance('Ganons Tower (Hookshot Room)', player), lambda state: state.has('Hammer', player) and (state.has('Hookshot', player) or state.has('Pegasus Boots', player))) - set_rule(world.get_entrance('Ganons Tower (Map Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 8) or ( + set_rule(multiworld.get_location('Ganons Tower - Bob\'s Torch', player), lambda state: state.has('Pegasus Boots', player)) + set_rule(multiworld.get_entrance('Ganons Tower (Tile Room)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(multiworld.get_entrance('Ganons Tower (Hookshot Room)', player), lambda state: state.has('Hammer', player) and (state.has('Hookshot', player) or state.has('Pegasus Boots', player))) + set_rule(multiworld.get_entrance('Ganons Tower (Map Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 8) or ( location_item_name(state, 'Ganons Tower - Map Chest', player) in [('Big Key (Ganons Tower)', player)] and state._lttp_has_key('Small Key (Ganons Tower)', player, 6))) # this seemed to be causing generation failure, disable for now @@ -540,63 +542,63 @@ def global_rules(world, player): # It is possible to need more than 6 keys to get through this entrance if you spend keys elsewhere. We reflect this in the chest requirements. # However we need to leave these at the lower values to derive that with 7 keys it is always possible to reach Bob and Ice Armos. - set_rule(world.get_entrance('Ganons Tower (Double Switch Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 6)) + set_rule(multiworld.get_entrance('Ganons Tower (Double Switch Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 6)) # It is possible to need more than 7 keys .... - set_rule(world.get_entrance('Ganons Tower (Firesnake Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( + set_rule(multiworld.get_entrance('Ganons Tower (Firesnake Room)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests + back_chests, [player] * len(randomizer_room_chests + back_chests))) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5))) # The actual requirements for these rooms to avoid key-lock - set_rule(world.get_location('Ganons Tower - Firesnake Room', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or - ((item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) or item_name_in_location_names(state, 'Small Key (Ganons Tower)', player, [('Ganons Tower - Firesnake Room', player)])) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5))) + set_rule(multiworld.get_location('Ganons Tower - Firesnake Room', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or + ((item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) or item_name_in_location_names(state, 'Small Key (Ganons Tower)', player, [('Ganons Tower - Firesnake Room', player)])) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5))) for location in randomizer_room_chests: - set_rule(world.get_location(location, player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 8) or ( + set_rule(multiworld.get_location(location, player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 8) or ( item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) and state._lttp_has_key('Small Key (Ganons Tower)', player, 6))) # Once again it is possible to need more than 7 keys... - set_rule(world.get_entrance('Ganons Tower (Tile Room) Key Door', player), lambda state: state.has('Fire Rod', player) and (state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( + set_rule(multiworld.get_entrance('Ganons Tower (Tile Room) Key Door', player), lambda state: state.has('Fire Rod', player) and (state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(compass_room_chests, [player] * len(compass_room_chests))) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5)))) - set_rule(world.get_entrance('Ganons Tower (Bottom) (East)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( + set_rule(multiworld.get_entrance('Ganons Tower (Bottom) (East)', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(back_chests, [player] * len(back_chests))) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5))) # Actual requirements for location in compass_room_chests: - set_rule(world.get_location(location, player), lambda state: (can_use_bombs(state, player) or state.has("Cane of Somaria", player)) and state.has('Fire Rod', player) and (state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( + set_rule(multiworld.get_location(location, player), lambda state: (can_use_bombs(state, player) or state.has("Cane of Somaria", player)) and state.has('Fire Rod', player) and (state._lttp_has_key('Small Key (Ganons Tower)', player, 7) or ( item_name_in_location_names(state, 'Big Key (Ganons Tower)', player, zip(compass_room_chests, [player] * len(compass_room_chests))) and state._lttp_has_key('Small Key (Ganons Tower)', player, 5)))) - set_rule(world.get_location('Ganons Tower - Big Chest', player), lambda state: state.has('Big Key (Ganons Tower)', player)) + set_rule(multiworld.get_location('Ganons Tower - Big Chest', player), lambda state: state.has('Big Key (Ganons Tower)', player)) - set_rule(world.get_location('Ganons Tower - Big Key Room - Left', player), + set_rule(multiworld.get_location('Ganons Tower - Big Key Room - Left', player), lambda state: can_use_bombs(state, player) and state.multiworld.get_location('Ganons Tower - Big Key Room - Left', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Big Key Chest', player), + set_rule(multiworld.get_location('Ganons Tower - Big Key Chest', player), lambda state: can_use_bombs(state, player) and state.multiworld.get_location('Ganons Tower - Big Key Chest', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Big Key Room - Right', player), + set_rule(multiworld.get_location('Ganons Tower - Big Key Room - Right', player), lambda state: can_use_bombs(state, player) and state.multiworld.get_location('Ganons Tower - Big Key Room - Right', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) - if world.enemy_shuffle[player]: - set_rule(world.get_entrance('Ganons Tower Big Key Door', player), + if multiworld.enemy_shuffle[player]: + set_rule(multiworld.get_entrance('Ganons Tower Big Key Door', player), lambda state: state.has('Big Key (Ganons Tower)', player)) else: - set_rule(world.get_entrance('Ganons Tower Big Key Door', player), + set_rule(multiworld.get_entrance('Ganons Tower Big Key Door', player), lambda state: state.has('Big Key (Ganons Tower)', player) and can_shoot_arrows(state, player)) - set_rule(world.get_entrance('Ganons Tower Torch Rooms', player), + set_rule(multiworld.get_entrance('Ganons Tower Torch Rooms', player), lambda state: can_kill_most_things(state, player, 8) and has_fire_source(state, player) and state.multiworld.get_entrance('Ganons Tower Torch Rooms', player).parent_region.dungeon.bosses['middle'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Mini Helmasaur Key Drop', player), lambda state: can_kill_most_things(state, player, 1)) - set_rule(world.get_location('Ganons Tower - Pre-Moldorm Chest', player), + set_rule(multiworld.get_location('Ganons Tower - Mini Helmasaur Key Drop', player), lambda state: can_kill_most_things(state, player, 1)) + set_rule(multiworld.get_location('Ganons Tower - Pre-Moldorm Chest', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 7)) - set_rule(world.get_entrance('Ganons Tower Moldorm Door', player), + set_rule(multiworld.get_entrance('Ganons Tower Moldorm Door', player), lambda state: state._lttp_has_key('Small Key (Ganons Tower)', player, 8)) - set_rule(world.get_entrance('Ganons Tower Moldorm Gap', player), + set_rule(multiworld.get_entrance('Ganons Tower Moldorm Gap', player), lambda state: state.has('Hookshot', player) and state.multiworld.get_entrance('Ganons Tower Moldorm Gap', player).parent_region.dungeon.bosses['top'].can_defeat(state)) - set_defeat_dungeon_boss_rule(world.get_location('Agahnim 2', player)) - ganon = world.get_location('Ganon', player) + set_defeat_dungeon_boss_rule(multiworld.get_location('Agahnim 2', player)) + ganon = multiworld.get_location('Ganon', player) set_rule(ganon, lambda state: GanonDefeatRule(state, player)) - if world.goal[player] in ['ganon_triforce_hunt', 'local_ganon_triforce_hunt']: + if multiworld.goal[player] in ['ganon_triforce_hunt', 'local_ganon_triforce_hunt']: add_rule(ganon, lambda state: has_triforce_pieces(state, player)) - elif world.goal[player] == 'ganon_pedestal': - add_rule(world.get_location('Ganon', player), lambda state: state.can_reach('Master Sword Pedestal', 'Location', player)) + elif multiworld.goal[player] == 'ganon_pedestal': + add_rule(multiworld.get_location('Ganon', player), lambda state: state.can_reach('Master Sword Pedestal', 'Location', player)) else: add_rule(ganon, lambda state: has_crystals(state, state.multiworld.crystals_needed_for_ganon[player], player)) - set_rule(world.get_entrance('Ganon Drop', player), lambda state: has_beam_sword(state, player)) # need to damage ganon to get tiles to drop + set_rule(multiworld.get_entrance('Ganon Drop', player), lambda state: has_beam_sword(state, player)) # need to damage ganon to get tiles to drop - set_rule(world.get_location('Flute Activation Spot', player), lambda state: state.has('Flute', player)) + set_rule(multiworld.get_location('Flute Activation Spot', player), lambda state: state.has('Flute', player)) def default_rules(world, player): @@ -1106,14 +1108,10 @@ def set_trock_key_rules(world, player): all_state.stale[player] = True # Check if each of the four main regions of the dungoen can be reached. The previous code section prevents key-costing moves within the dungeon. - can_reach_back = all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)', player)) if world.can_access_trock_eyebridge[player] is None else world.can_access_trock_eyebridge[player] - world.can_access_trock_eyebridge[player] = can_reach_back - can_reach_front = all_state.can_reach(world.get_region('Turtle Rock (Entrance)', player)) if world.can_access_trock_front[player] is None else world.can_access_trock_front[player] - world.can_access_trock_front[player] = can_reach_front - can_reach_big_chest = all_state.can_reach(world.get_region('Turtle Rock (Big Chest)', player)) if world.can_access_trock_big_chest[player] is None else world.can_access_trock_big_chest[player] - world.can_access_trock_big_chest[player] = can_reach_big_chest - can_reach_middle = all_state.can_reach(world.get_region('Turtle Rock (Second Section)', player)) if world.can_access_trock_middle[player] is None else world.can_access_trock_middle[player] - world.can_access_trock_middle[player] = can_reach_middle + can_reach_back = all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)', player)) + can_reach_front = all_state.can_reach(world.get_region('Turtle Rock (Entrance)', player)) + can_reach_big_chest = all_state.can_reach(world.get_region('Turtle Rock (Big Chest)', player)) + can_reach_middle = all_state.can_reach(world.get_region('Turtle Rock (Second Section)', player)) # If you can't enter from the back, the door to the front of TR requires only 2 small keys if the big key is in one of these chests since 2 key doors are locked behind the big key door. # If you can only enter from the middle, this includes all locations that can only be reached by exiting the front. This can include Laser Bridge and Crystaroller if the front and back connect via Dark DM Ledge! diff --git a/worlds/alttp/StateHelpers.py b/worlds/alttp/StateHelpers.py index 4ed1b1caf205..80bf3c1ad77f 100644 --- a/worlds/alttp/StateHelpers.py +++ b/worlds/alttp/StateHelpers.py @@ -30,7 +30,7 @@ def can_shoot_arrows(state: CollectionState, player: int) -> bool: def has_triforce_pieces(state: CollectionState, player: int) -> bool: - count = state.multiworld.treasure_hunt_count[player] + count = state.multiworld.worlds[player].treasure_hunt_count return state.count('Triforce Piece', player) + state.count('Power Star', player) >= count @@ -48,8 +48,8 @@ def can_lift_heavy_rocks(state: CollectionState, player: int) -> bool: def bottle_count(state: CollectionState, player: int) -> int: - return min(state.multiworld.difficulty_requirements[player].progressive_bottle_limit, - state.count_group("Bottles", player)) + return min(state.multiworld.worlds[player].difficulty_requirements.progressive_bottle_limit, + state.count_group("Bottles", player)) def has_hearts(state: CollectionState, player: int, count: int) -> int: @@ -59,7 +59,7 @@ def has_hearts(state: CollectionState, player: int, count: int) -> int: def heart_count(state: CollectionState, player: int) -> int: # Warning: This only considers items that are marked as advancement items - diff = state.multiworld.difficulty_requirements[player] + diff = state.multiworld.worlds[player].difficulty_requirements return min(state.count('Boss Heart Container', player), diff.boss_heart_container_limit) \ + state.count('Sanctuary Heart Container', player) \ + min(state.count('Piece of Heart', player), diff.heart_piece_limit) // 4 \ @@ -171,10 +171,10 @@ def can_melt_things(state: CollectionState, player: int) -> bool: def has_misery_mire_medallion(state: CollectionState, player: int) -> bool: - return state.has(state.multiworld.required_medallions[player][0], player) + return state.has(state.multiworld.worlds[player].required_medallions[0], player) def has_turtle_rock_medallion(state: CollectionState, player: int) -> bool: - return state.has(state.multiworld.required_medallions[player][1], player) + return state.has(state.multiworld.worlds[player].required_medallions[1], player) def can_boots_clip_lw(state: CollectionState, player: int) -> bool: diff --git a/worlds/alttp/UnderworldGlitchRules.py b/worlds/alttp/UnderworldGlitchRules.py index 497d5de496c3..50397dea166c 100644 --- a/worlds/alttp/UnderworldGlitchRules.py +++ b/worlds/alttp/UnderworldGlitchRules.py @@ -15,7 +15,7 @@ def underworld_glitch_connections(world, player): specrock.exits.append(kikiskip) mire.exits.extend([mire_to_hera, mire_to_swamp]) - if world.fix_fake_world[player]: + if world.worlds[player].fix_fake_world: kikiskip.connect(world.get_entrance('Palace of Darkness Exit', player).connected_region) mire_to_hera.connect(world.get_entrance('Tower of Hera Exit', player).connected_region) mire_to_swamp.connect(world.get_entrance('Swamp Palace Exit', player).connected_region) @@ -38,8 +38,8 @@ def fake_pearl_state(state, player): # Sets the rules on where we can actually go using this clip. # Behavior differs based on what type of ER shuffle we're playing. def dungeon_reentry_rules(world, player, clip: Entrance, dungeon_region: str, dungeon_exit: str): - fix_dungeon_exits = world.fix_palaceofdarkness_exit[player] - fix_fake_worlds = world.fix_fake_world[player] + fix_dungeon_exits = world.worlds[player].fix_palaceofdarkness_exit + fix_fake_worlds = world.worlds[player].fix_fake_world dungeon_entrance = [r for r in world.get_region(dungeon_region, player).entrances if r.name != clip.name][0] if not fix_dungeon_exits: # vanilla, simple, restricted, dungeons_simple; should never have fake worlds fix @@ -52,7 +52,7 @@ def dungeon_reentry_rules(world, player, clip: Entrance, dungeon_region: str, du add_rule(clip, lambda state: state.has('Cape', player) or has_beam_sword(state, player) or state.has('Beat Agahnim 1', player)) # kill/bypass barrier # Then we set a restriction on exiting the dungeon, so you can't leave unless you got in normally. add_rule(world.get_entrance(dungeon_exit, player), lambda state: dungeon_entrance.can_reach(state)) - elif not fix_fake_worlds: # full, dungeons_full; fixed dungeon exits, but no fake worlds fix + elif not fix_fake_worlds: # full, dungeons_full; fixed dungeon exits, but no fake worlds fix # Entry requires the entrance's requirements plus a fake pearl, but you don't gain logical access to the surrounding region. add_rule(clip, lambda state: dungeon_entrance.access_rule(fake_pearl_state(state, player))) # exiting restriction @@ -62,9 +62,6 @@ def dungeon_reentry_rules(world, player, clip: Entrance, dungeon_region: str, du def underworld_glitches_rules(world, player): - fix_dungeon_exits = world.fix_palaceofdarkness_exit[player] - fix_fake_worlds = world.fix_fake_world[player] - # Ice Palace Entrance Clip # This is the easiest one since it's a simple internal clip. # Need to also add melting to freezor chest since it's otherwise assumed. @@ -92,7 +89,7 @@ def underworld_glitches_rules(world, player): # Build the rule for SP moat. # We need to be able to s+q to old man, then go to either Mire or Hera at either Hera or GT. # First we require a certain type of entrance shuffle, then build the rule from its pieces. - if not world.swamp_patch_required[player]: + if not world.worlds[player].swamp_patch_required: if world.entrance_shuffle[player] in ['vanilla', 'dungeons_simple', 'dungeons_full', 'dungeons_crossed']: rule_map = { 'Misery Mire (Entrance)': (lambda state: True), diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 9abc15b75bc9..f84c28be4bcc 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -251,6 +251,17 @@ def enemizer_path(self) -> str: dungeons: typing.Dict[str, Dungeon] waterfall_fairy_bottle_fill: str pyramid_fairy_bottle_fill: str + escape_assist: list + + can_take_damage: bool = True + swamp_patch_required: bool = False + powder_patch_required: bool = False + ganon_at_pyramid: bool = True + ganonstower_vanilla: bool = True + fix_fake_world: bool = True + + clock_mode: str = "" + treasure_hunt_count: int = 1 def __init__(self, *args, **kwargs): self.dungeon_local_item_names = set() @@ -265,6 +276,8 @@ def __init__(self, *args, **kwargs): self.fix_skullwoods_exit = None self.fix_palaceofdarkness_exit = None self.fix_trock_exit = None + self.required_medallions = ["Ether", "Quake"] + self.escape_assist = [] super(ALTTPWorld, self).__init__(*args, **kwargs) @classmethod @@ -298,7 +311,7 @@ def generate_early(self): "Bottle (Red Potion)", "Bottle (Green Potion)", "Bottle (Blue Potion)", "Bottle (Bee)", "Bottle (Good Bee)" ] - if multiworld.difficulty[player] not in ["hard", "expert"]: + if multiworld.item_pool[player] not in ["hard", "expert"]: bottle_options.append("Bottle (Fairy)") self.waterfall_fairy_bottle_fill = self.random.choice(bottle_options) self.pyramid_fairy_bottle_fill = self.random.choice(bottle_options) @@ -344,7 +357,7 @@ def generate_early(self): if option == "original_dungeon": self.dungeon_specific_item_names |= self.item_name_groups[option.item_name_group] - multiworld.difficulty_requirements[player] = difficulties[multiworld.item_pool[player].current_key] + self.difficulty_requirements = difficulties[multiworld.item_pool[player].current_key] # enforce pre-defined local items. if multiworld.goal[player] in ["local_triforce_hunt", "local_ganon_triforce_hunt"]: @@ -370,7 +383,7 @@ def create_regions(self): if (multiworld.glitches_required[player] not in ["no_glitches", "minor_glitches"] and multiworld.entrance_shuffle[player] in [ "vanilla", "dungeons_simple", "dungeons_full", "simple", "restricted", "full"]): - multiworld.fix_fake_world[player] = False + self.fix_fake_world = False # seeded entrance shuffle old_random = multiworld.random @@ -438,15 +451,16 @@ def collect_item(self, state: CollectionState, item: Item, remove=False): if 'Sword' in item_name: if state.has('Golden Sword', item.player): pass - elif state.has('Tempered Sword', item.player) and self.multiworld.difficulty_requirements[ - item.player].progressive_sword_limit >= 4: + elif (state.has('Tempered Sword', item.player) and + self.difficulty_requirements.progressive_sword_limit >= 4): return 'Golden Sword' - elif state.has('Master Sword', item.player) and self.multiworld.difficulty_requirements[ - item.player].progressive_sword_limit >= 3: + elif (state.has('Master Sword', item.player) and + self.difficulty_requirements.progressive_sword_limit >= 3): return 'Tempered Sword' - elif state.has('Fighter Sword', item.player) and self.multiworld.difficulty_requirements[item.player].progressive_sword_limit >= 2: + elif (state.has('Fighter Sword', item.player) and + self.difficulty_requirements.progressive_sword_limit >= 2): return 'Master Sword' - elif self.multiworld.difficulty_requirements[item.player].progressive_sword_limit >= 1: + elif self.difficulty_requirements.progressive_sword_limit >= 1: return 'Fighter Sword' elif 'Glove' in item_name: if state.has('Titans Mitts', item.player): @@ -458,20 +472,22 @@ def collect_item(self, state: CollectionState, item: Item, remove=False): elif 'Shield' in item_name: if state.has('Mirror Shield', item.player): return - elif state.has('Red Shield', item.player) and self.multiworld.difficulty_requirements[item.player].progressive_shield_limit >= 3: + elif (state.has('Red Shield', item.player) and + self.difficulty_requirements.progressive_shield_limit >= 3): return 'Mirror Shield' - elif state.has('Blue Shield', item.player) and self.multiworld.difficulty_requirements[item.player].progressive_shield_limit >= 2: + elif (state.has('Blue Shield', item.player) and + self.difficulty_requirements.progressive_shield_limit >= 2): return 'Red Shield' - elif self.multiworld.difficulty_requirements[item.player].progressive_shield_limit >= 1: + elif self.difficulty_requirements.progressive_shield_limit >= 1: return 'Blue Shield' elif 'Bow' in item_name: if state.has('Silver Bow', item.player): return - elif state.has('Bow', item.player) and (self.multiworld.difficulty_requirements[item.player].progressive_bow_limit >= 2 - or self.multiworld.glitches_required[item.player] == 'no_glitches' - or self.multiworld.swordless[item.player]): # modes where silver bow is always required for ganon + elif state.has('Bow', item.player) and (self.difficulty_requirements.progressive_bow_limit >= 2 + or self.glitches_required == 'no_glitches' + or self.swordless): # modes where silver bow is always required for ganon return 'Silver Bow' - elif self.multiworld.difficulty_requirements[item.player].progressive_bow_limit >= 1: + elif self.difficulty_requirements.progressive_bow_limit >= 1: return 'Bow' elif item.advancement: return item_name @@ -660,7 +676,7 @@ def stage_fill_hook(cls, multiworld, progitempool, usefulitempool, filleritempoo trash_counts = {} for player in multiworld.get_game_players("A Link to the Past"): world = multiworld.worlds[player] - if not multiworld.ganonstower_vanilla[player] or \ + if not world.ganonstower_vanilla or \ world.options.glitches_required.current_key in {'overworld_glitches', 'hybrid_major_glitches', "no_logic"}: pass elif 'triforce_hunt' in world.options.goal.current_key and ('local' in world.options.goal.current_key or multiworld.players == 1): @@ -701,10 +717,10 @@ def write_spoiler(self, spoiler_handle: typing.TextIO) -> None: player_name = self.multiworld.get_player_name(self.player) spoiler_handle.write("\n\nMedallions:\n") spoiler_handle.write(f"\nMisery Mire ({player_name}):" - f" {self.multiworld.required_medallions[self.player][0]}") + f" {self.required_medallions[0]}") spoiler_handle.write( f"\nTurtle Rock ({player_name}):" - f" {self.multiworld.required_medallions[self.player][1]}") + f" {self.required_medallions[1]}") spoiler_handle.write("\n\nFairy Fountain Bottle Fill:\n") spoiler_handle.write(f"\nPyramid Fairy ({player_name}):" f" {self.pyramid_fairy_bottle_fill}") @@ -815,8 +831,8 @@ def fill_slot_data(self): slot_data = {option_name: getattr(self.multiworld, option_name)[self.player].value for option_name in slot_options} slot_data.update({ - 'mm_medalion': self.multiworld.required_medallions[self.player][0], - 'tr_medalion': self.multiworld.required_medallions[self.player][1], + 'mm_medalion': self.required_medallions[0], + 'tr_medalion': self.required_medallions[1], } ) return slot_data diff --git a/worlds/alttp/test/__init__.py b/worlds/alttp/test/__init__.py index 49033a6ce36a..307e75381d7e 100644 --- a/worlds/alttp/test/__init__.py +++ b/worlds/alttp/test/__init__.py @@ -7,7 +7,9 @@ class LTTPTestBase(unittest.TestCase): def world_setup(self): + from worlds.alttp.Options import Medallion self.multiworld = MultiWorld(1) + self.multiworld.game[1] = "A Link to the Past" self.multiworld.state = CollectionState(self.multiworld) self.multiworld.set_seed(None) args = Namespace() @@ -15,3 +17,6 @@ def world_setup(self): setattr(args, name, {1: option.from_any(getattr(option, "default"))}) self.multiworld.set_options(args) self.world = self.multiworld.worlds[1] + # by default medallion access is randomized, for unittests we set it to vanilla + self.world.options.misery_mire_medallion.value = Medallion.option_ether + self.world.options.turtle_rock_medallion.value = Medallion.option_quake diff --git a/worlds/alttp/test/dungeons/TestDungeon.py b/worlds/alttp/test/dungeons/TestDungeon.py index 128f8b41b75e..a31ddd68b2e1 100644 --- a/worlds/alttp/test/dungeons/TestDungeon.py +++ b/worlds/alttp/test/dungeons/TestDungeon.py @@ -13,7 +13,7 @@ def setUp(self): self.world_setup() self.starting_regions = [] # Where to start exploring self.remove_exits = [] # Block dungeon exits - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True create_regions(self.multiworld, 1) @@ -23,7 +23,7 @@ def setUp(self): connect_simple(self.multiworld, exitname, regionname, 1) connect_simple(self.multiworld, 'Big Bomb Shop', 'Big Bomb Shop', 1) self.multiworld.get_region('Menu', 1).exits = [] - self.multiworld.swamp_patch_required[1] = True + self.multiworld.worlds[1].swamp_patch_required = True self.world.set_rules() self.world.create_items() self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) diff --git a/worlds/alttp/test/inverted/TestInverted.py b/worlds/alttp/test/inverted/TestInverted.py index 069639e81b9d..59a3d7f5f4fa 100644 --- a/worlds/alttp/test/inverted/TestInverted.py +++ b/worlds/alttp/test/inverted/TestInverted.py @@ -13,7 +13,7 @@ class TestInverted(TestBase, LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.multiworld.mode[1].value = 2 self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True @@ -22,7 +22,6 @@ def setUp(self): create_shops(self.multiworld, 1) link_inverted_entrances(self.multiworld, 1) self.world.create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world)) self.multiworld.get_location('Agahnim 1', 1).item = None diff --git a/worlds/alttp/test/inverted/TestInvertedBombRules.py b/worlds/alttp/test/inverted/TestInvertedBombRules.py index 83a25812c9b6..a33beca7a9f9 100644 --- a/worlds/alttp/test/inverted/TestInvertedBombRules.py +++ b/worlds/alttp/test/inverted/TestInvertedBombRules.py @@ -11,7 +11,7 @@ class TestInvertedBombRules(LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.multiworld.mode[1].value = 2 create_inverted_regions(self.multiworld, 1) self.multiworld.worlds[1].create_dungeons() diff --git a/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py b/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py index 912cca4390c3..029de39bc232 100644 --- a/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py +++ b/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py @@ -18,13 +18,12 @@ def setUp(self): self.multiworld.glitches_required[1] = GlitchesRequired.from_any("minor_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] create_inverted_regions(self.multiworld, 1) self.world.create_dungeons() create_shops(self.multiworld, 1) link_inverted_entrances(self.multiworld, 1) self.world.create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world)) self.multiworld.get_location('Agahnim 1', 1).item = None diff --git a/worlds/alttp/test/inverted_owg/TestInvertedOWG.py b/worlds/alttp/test/inverted_owg/TestInvertedOWG.py index fc38437e3ed7..86afae3e2a67 100644 --- a/worlds/alttp/test/inverted_owg/TestInvertedOWG.py +++ b/worlds/alttp/test/inverted_owg/TestInvertedOWG.py @@ -18,13 +18,12 @@ def setUp(self): self.multiworld.mode[1].value = 2 self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] create_inverted_regions(self.multiworld, 1) self.world.create_dungeons() create_shops(self.multiworld, 1) link_inverted_entrances(self.multiworld, 1) self.world.create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world)) self.multiworld.get_location('Agahnim 1', 1).item = None diff --git a/worlds/alttp/test/minor_glitches/TestMinor.py b/worlds/alttp/test/minor_glitches/TestMinor.py index a7b529382e5e..55fef61ebf99 100644 --- a/worlds/alttp/test/minor_glitches/TestMinor.py +++ b/worlds/alttp/test/minor_glitches/TestMinor.py @@ -14,11 +14,10 @@ def setUp(self): self.multiworld.glitches_required[1] = GlitchesRequired.from_any("minor_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.world.er_seed = 0 self.world.create_regions() self.world.create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory( ['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', diff --git a/worlds/alttp/test/owg/TestVanillaOWG.py b/worlds/alttp/test/owg/TestVanillaOWG.py index 3506154587e7..61b528f6fb91 100644 --- a/worlds/alttp/test/owg/TestVanillaOWG.py +++ b/worlds/alttp/test/owg/TestVanillaOWG.py @@ -11,14 +11,13 @@ class TestVanillaOWG(TestBase, LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.multiworld.glitches_required[1] = GlitchesRequired.from_any("overworld_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True self.multiworld.worlds[1].er_seed = 0 self.multiworld.worlds[1].create_regions() self.multiworld.worlds[1].create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world)) self.multiworld.get_location('Agahnim 1', 1).item = None diff --git a/worlds/alttp/test/vanilla/TestVanilla.py b/worlds/alttp/test/vanilla/TestVanilla.py index 5865ddf9873d..496b2ba0f9ac 100644 --- a/worlds/alttp/test/vanilla/TestVanilla.py +++ b/worlds/alttp/test/vanilla/TestVanilla.py @@ -11,13 +11,12 @@ class TestVanilla(TestBase, LTTPTestBase): def setUp(self): self.world_setup() self.multiworld.glitches_required[1] = GlitchesRequired.from_any("no_glitches") - self.multiworld.difficulty_requirements[1] = difficulties['normal'] + self.multiworld.worlds[1].difficulty_requirements = difficulties['normal'] self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True self.multiworld.worlds[1].er_seed = 0 self.multiworld.worlds[1].create_regions() self.multiworld.worlds[1].create_items() - self.multiworld.required_medallions[1] = ['Ether', 'Quake'] self.multiworld.itempool.extend(get_dungeon_item_pool(self.multiworld)) self.multiworld.itempool.extend(item_factory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], self.world)) self.multiworld.get_location('Agahnim 1', 1).item = None diff --git a/worlds/cv64/__init__.py b/worlds/cv64/__init__.py index 1f528feac22f..2bceefee0ed0 100644 --- a/worlds/cv64/__init__.py +++ b/worlds/cv64/__init__.py @@ -4,7 +4,7 @@ import base64 import logging -from BaseClasses import Item, Region, MultiWorld, Tutorial, ItemClassification +from BaseClasses import Item, Region, Tutorial, ItemClassification from .items import CV64Item, filler_item_names, get_item_info, get_item_names_to_ids, get_item_counts from .locations import CV64Location, get_location_info, verify_locations, get_location_names_to_ids, base_id from .entrances import verify_entrances, get_warp_entrances @@ -18,7 +18,7 @@ from .aesthetics import randomize_lighting, shuffle_sub_weapons, rom_empty_breakables_flags, rom_sub_weapon_flags, \ randomize_music, get_start_inventory_data, get_location_data, randomize_shop_prices, get_loading_zone_bytes, \ get_countdown_numbers -from .rom import LocalRom, patch_rom, get_base_rom_path, CV64DeltaPatch +from .rom import RomData, write_patch, get_base_rom_path, CV64ProcedurePatch, CV64_US_10_HASH from .client import Castlevania64Client @@ -27,7 +27,7 @@ class RomFile(settings.UserFilePath): """File name of the CV64 US 1.0 rom""" copy_to = "Castlevania (USA).z64" description = "CV64 (US 1.0) ROM File" - md5s = [CV64DeltaPatch.hash] + md5s = [CV64_US_10_HASH] rom_file: RomFile = RomFile(RomFile.copy_to) @@ -86,12 +86,6 @@ class CV64World(World): web = CV64Web() - @classmethod - def stage_assert_generate(cls, multiworld: MultiWorld) -> None: - rom_file = get_base_rom_path() - if not os.path.exists(rom_file): - raise FileNotFoundError(rom_file) - def generate_early(self) -> None: # Generate the player's unique authentication self.auth = bytearray(self.multiworld.random.getrandbits(8) for _ in range(16)) @@ -276,18 +270,13 @@ def generate_output(self, output_directory: str) -> None: offset_data.update(get_start_inventory_data(self.player, self.options, self.multiworld.precollected_items[self.player])) - cv64_rom = LocalRom(get_base_rom_path()) - - rompath = os.path.join(output_directory, f"{self.multiworld.get_out_file_name_base(self.player)}.z64") - - patch_rom(self, cv64_rom, offset_data, shop_name_list, shop_desc_list, shop_colors_list, active_locations) + patch = CV64ProcedurePatch() + write_patch(self, patch, offset_data, shop_name_list, shop_desc_list, shop_colors_list, active_locations) - cv64_rom.write_to_file(rompath) + rom_path = os.path.join(output_directory, f"{self.multiworld.get_out_file_name_base(self.player)}" + f"{patch.patch_file_ending}") - patch = CV64DeltaPatch(os.path.splitext(rompath)[0] + CV64DeltaPatch.patch_file_ending, player=self.player, - player_name=self.multiworld.player_name[self.player], patched_path=rompath) - patch.write() - os.unlink(rompath) + patch.write(rom_path) def get_filler_item_name(self) -> str: return self.random.choice(filler_item_names) diff --git a/worlds/cv64/aesthetics.py b/worlds/cv64/aesthetics.py index cbf2728c8298..66709174d837 100644 --- a/worlds/cv64/aesthetics.py +++ b/worlds/cv64/aesthetics.py @@ -14,111 +14,111 @@ from . import CV64World rom_sub_weapon_offsets = { - 0x10C6EB: (0x10, rname.forest_of_silence), # Forest - 0x10C6F3: (0x0F, rname.forest_of_silence), - 0x10C6FB: (0x0E, rname.forest_of_silence), - 0x10C703: (0x0D, rname.forest_of_silence), - - 0x10C81F: (0x0F, rname.castle_wall), # Castle Wall - 0x10C827: (0x10, rname.castle_wall), - 0x10C82F: (0x0E, rname.castle_wall), - 0x7F9A0F: (0x0D, rname.castle_wall), - - 0x83A5D9: (0x0E, rname.villa), # Villa - 0x83A5E5: (0x0D, rname.villa), - 0x83A5F1: (0x0F, rname.villa), - 0xBFC903: (0x10, rname.villa), - 0x10C987: (0x10, rname.villa), - 0x10C98F: (0x0D, rname.villa), - 0x10C997: (0x0F, rname.villa), - 0x10CF73: (0x10, rname.villa), - - 0x10CA57: (0x0D, rname.tunnel), # Tunnel - 0x10CA5F: (0x0E, rname.tunnel), - 0x10CA67: (0x10, rname.tunnel), - 0x10CA6F: (0x0D, rname.tunnel), - 0x10CA77: (0x0F, rname.tunnel), - 0x10CA7F: (0x0E, rname.tunnel), - - 0x10CBC7: (0x0E, rname.castle_center), # Castle Center - 0x10CC0F: (0x0D, rname.castle_center), - 0x10CC5B: (0x0F, rname.castle_center), - - 0x10CD3F: (0x0E, rname.tower_of_execution), # Character towers - 0x10CD65: (0x0D, rname.tower_of_execution), - 0x10CE2B: (0x0E, rname.tower_of_science), - 0x10CE83: (0x10, rname.duel_tower), - - 0x10CF8B: (0x0F, rname.room_of_clocks), # Room of Clocks - 0x10CF93: (0x0D, rname.room_of_clocks), - - 0x99BC5A: (0x0D, rname.clock_tower), # Clock Tower - 0x10CECB: (0x10, rname.clock_tower), - 0x10CED3: (0x0F, rname.clock_tower), - 0x10CEDB: (0x0E, rname.clock_tower), - 0x10CEE3: (0x0D, rname.clock_tower), + 0x10C6EB: (b"\x10", rname.forest_of_silence), # Forest + 0x10C6F3: (b"\x0F", rname.forest_of_silence), + 0x10C6FB: (b"\x0E", rname.forest_of_silence), + 0x10C703: (b"\x0D", rname.forest_of_silence), + + 0x10C81F: (b"\x0F", rname.castle_wall), # Castle Wall + 0x10C827: (b"\x10", rname.castle_wall), + 0x10C82F: (b"\x0E", rname.castle_wall), + 0x7F9A0F: (b"\x0D", rname.castle_wall), + + 0x83A5D9: (b"\x0E", rname.villa), # Villa + 0x83A5E5: (b"\x0D", rname.villa), + 0x83A5F1: (b"\x0F", rname.villa), + 0xBFC903: (b"\x10", rname.villa), + 0x10C987: (b"\x10", rname.villa), + 0x10C98F: (b"\x0D", rname.villa), + 0x10C997: (b"\x0F", rname.villa), + 0x10CF73: (b"\x10", rname.villa), + + 0x10CA57: (b"\x0D", rname.tunnel), # Tunnel + 0x10CA5F: (b"\x0E", rname.tunnel), + 0x10CA67: (b"\x10", rname.tunnel), + 0x10CA6F: (b"\x0D", rname.tunnel), + 0x10CA77: (b"\x0F", rname.tunnel), + 0x10CA7F: (b"\x0E", rname.tunnel), + + 0x10CBC7: (b"\x0E", rname.castle_center), # Castle Center + 0x10CC0F: (b"\x0D", rname.castle_center), + 0x10CC5B: (b"\x0F", rname.castle_center), + + 0x10CD3F: (b"\x0E", rname.tower_of_execution), # Character towers + 0x10CD65: (b"\x0D", rname.tower_of_execution), + 0x10CE2B: (b"\x0E", rname.tower_of_science), + 0x10CE83: (b"\x10", rname.duel_tower), + + 0x10CF8B: (b"\x0F", rname.room_of_clocks), # Room of Clocks + 0x10CF93: (b"\x0D", rname.room_of_clocks), + + 0x99BC5A: (b"\x0D", rname.clock_tower), # Clock Tower + 0x10CECB: (b"\x10", rname.clock_tower), + 0x10CED3: (b"\x0F", rname.clock_tower), + 0x10CEDB: (b"\x0E", rname.clock_tower), + 0x10CEE3: (b"\x0D", rname.clock_tower), } rom_sub_weapon_flags = { - 0x10C6EC: 0x0200FF04, # Forest of Silence - 0x10C6FC: 0x0400FF04, - 0x10C6F4: 0x0800FF04, - 0x10C704: 0x4000FF04, + 0x10C6EC: b"\x02\x00\xFF\x04", # Forest of Silence + 0x10C6FC: b"\x04\x00\xFF\x04", + 0x10C6F4: b"\x08\x00\xFF\x04", + 0x10C704: b"\x40\x00\xFF\x04", - 0x10C831: 0x08, # Castle Wall - 0x10C829: 0x10, - 0x10C821: 0x20, - 0xBFCA97: 0x04, + 0x10C831: b"\x08", # Castle Wall + 0x10C829: b"\x10", + 0x10C821: b"\x20", + 0xBFCA97: b"\x04", # Villa - 0xBFC926: 0xFF04, - 0xBFC93A: 0x80, - 0xBFC93F: 0x01, - 0xBFC943: 0x40, - 0xBFC947: 0x80, - 0x10C989: 0x10, - 0x10C991: 0x20, - 0x10C999: 0x40, - 0x10CF77: 0x80, - - 0x10CA58: 0x4000FF0E, # Tunnel - 0x10CA6B: 0x80, - 0x10CA60: 0x1000FF05, - 0x10CA70: 0x2000FF05, - 0x10CA78: 0x4000FF05, - 0x10CA80: 0x8000FF05, - - 0x10CBCA: 0x02, # Castle Center - 0x10CC10: 0x80, - 0x10CC5C: 0x40, - - 0x10CE86: 0x01, # Duel Tower - 0x10CD43: 0x02, # Tower of Execution - 0x10CE2E: 0x20, # Tower of Science - - 0x10CF8E: 0x04, # Room of Clocks - 0x10CF96: 0x08, - - 0x10CECE: 0x08, # Clock Tower - 0x10CED6: 0x10, - 0x10CEE6: 0x20, - 0x10CEDE: 0x80, + 0xBFC926: b"\xFF\x04", + 0xBFC93A: b"\x80", + 0xBFC93F: b"\x01", + 0xBFC943: b"\x40", + 0xBFC947: b"\x80", + 0x10C989: b"\x10", + 0x10C991: b"\x20", + 0x10C999: b"\x40", + 0x10CF77: b"\x80", + + 0x10CA58: b"\x40\x00\xFF\x0E", # Tunnel + 0x10CA6B: b"\x80", + 0x10CA60: b"\x10\x00\xFF\x05", + 0x10CA70: b"\x20\x00\xFF\x05", + 0x10CA78: b"\x40\x00\xFF\x05", + 0x10CA80: b"\x80\x00\xFF\x05", + + 0x10CBCA: b"\x02", # Castle Center + 0x10CC10: b"\x80", + 0x10CC5C: b"\x40", + + 0x10CE86: b"\x01", # Duel Tower + 0x10CD43: b"\x02", # Tower of Execution + 0x10CE2E: b"\x20", # Tower of Science + + 0x10CF8E: b"\x04", # Room of Clocks + 0x10CF96: b"\x08", + + 0x10CECE: b"\x08", # Clock Tower + 0x10CED6: b"\x10", + 0x10CEE6: b"\x20", + 0x10CEDE: b"\x80", } rom_empty_breakables_flags = { - 0x10C74D: 0x40FF05, # Forest of Silence - 0x10C765: 0x20FF0E, - 0x10C774: 0x0800FF0E, - 0x10C755: 0x80FF05, - 0x10C784: 0x0100FF0E, - 0x10C73C: 0x0200FF0E, - - 0x10C8D0: 0x0400FF0E, # Villa foyer - - 0x10CF9F: 0x08, # Room of Clocks flags - 0x10CFA7: 0x01, - 0xBFCB6F: 0x04, # Room of Clocks candle property IDs - 0xBFCB73: 0x05, + 0x10C74D: b"\x40\xFF\x05", # Forest of Silence + 0x10C765: b"\x20\xFF\x0E", + 0x10C774: b"\x08\x00\xFF\x0E", + 0x10C755: b"\x80\xFF\x05", + 0x10C784: b"\x01\x00\xFF\x0E", + 0x10C73C: b"\x02\x00\xFF\x0E", + + 0x10C8D0: b"\x04\x00\xFF\x0E", # Villa foyer + + 0x10CF9F: b"\x08", # Room of Clocks flags + 0x10CFA7: b"\x01", + 0xBFCB6F: b"\x04", # Room of Clocks candle property IDs + 0xBFCB73: b"\x05", } rom_axe_cross_lower_values = { @@ -269,19 +269,18 @@ } -def randomize_lighting(world: "CV64World") -> Dict[int, int]: +def randomize_lighting(world: "CV64World") -> Dict[int, bytes]: """Generates randomized data for the map lighting table.""" randomized_lighting = {} for entry in range(67): for sub_entry in range(19): if sub_entry not in [3, 7, 11, 15] and entry != 4: # The fourth entry in the lighting table affects the lighting on some item pickups; skip it - randomized_lighting[0x1091A0 + (entry * 28) + sub_entry] = \ - world.random.randint(0, 255) + randomized_lighting[0x1091A0 + (entry * 28) + sub_entry] = bytes([world.random.randint(0, 255)]) return randomized_lighting -def shuffle_sub_weapons(world: "CV64World") -> Dict[int, int]: +def shuffle_sub_weapons(world: "CV64World") -> Dict[int, bytes]: """Shuffles the sub-weapons amongst themselves.""" sub_weapon_dict = {offset: rom_sub_weapon_offsets[offset][0] for offset in rom_sub_weapon_offsets if rom_sub_weapon_offsets[offset][1] in world.active_stage_exits} @@ -295,7 +294,7 @@ def shuffle_sub_weapons(world: "CV64World") -> Dict[int, int]: return dict(zip(sub_weapon_dict, sub_bytes)) -def randomize_music(world: "CV64World") -> Dict[int, int]: +def randomize_music(world: "CV64World") -> Dict[int, bytes]: """Generates randomized or disabled data for all the music in the game.""" music_array = bytearray(0x7A) for number in music_sfx_ids: @@ -340,15 +339,10 @@ def randomize_music(world: "CV64World") -> Dict[int, int]: music_array[i] = fade_in_songs[i] del (music_array[0x00: 0x10]) - # Convert the music array into a data dict - music_offsets = {} - for i in range(len(music_array)): - music_offsets[0xBFCD30 + i] = music_array[i] + return {0xBFCD30: bytes(music_array)} - return music_offsets - -def randomize_shop_prices(world: "CV64World") -> Dict[int, int]: +def randomize_shop_prices(world: "CV64World") -> Dict[int, bytes]: """Randomize the shop prices based on the minimum and maximum values chosen. The minimum price will adjust if it's higher than the max.""" min_price = world.options.minimum_gold_price.value @@ -363,21 +357,15 @@ def randomize_shop_prices(world: "CV64World") -> Dict[int, int]: shop_price_list = [world.random.randint(min_price * 100, max_price * 100) for _ in range(7)] - # Convert the price list into a data dict. Which offset it starts from depends on how many bytes it takes up. + # Convert the price list into a data dict. price_dict = {} for i in range(len(shop_price_list)): - if shop_price_list[i] <= 0xFF: - price_dict[0x103D6E + (i*12)] = 0 - price_dict[0x103D6F + (i*12)] = shop_price_list[i] - elif shop_price_list[i] <= 0xFFFF: - price_dict[0x103D6E + (i*12)] = shop_price_list[i] - else: - price_dict[0x103D6D + (i*12)] = shop_price_list[i] + price_dict[0x103D6C + (i * 12)] = int.to_bytes(shop_price_list[i], 4, "big") return price_dict -def get_countdown_numbers(options: CV64Options, active_locations: Iterable[Location]) -> Dict[int, int]: +def get_countdown_numbers(options: CV64Options, active_locations: Iterable[Location]) -> Dict[int, bytes]: """Figures out which Countdown numbers to increase for each Location after verifying the Item on the Location should increase a number. @@ -400,16 +388,11 @@ def get_countdown_numbers(options: CV64Options, active_locations: Iterable[Locat if countdown_number is not None: countdown_list[countdown_number] += 1 - # Convert the Countdown list into a data dict - countdown_dict = {} - for i in range(len(countdown_list)): - countdown_dict[0xBFD818 + i] = countdown_list[i] - - return countdown_dict + return {0xBFD818: bytes(countdown_list)} def get_location_data(world: "CV64World", active_locations: Iterable[Location]) \ - -> Tuple[Dict[int, int], List[str], List[bytearray], List[List[Union[int, str, None]]]]: + -> Tuple[Dict[int, bytes], List[str], List[bytearray], List[List[Union[int, str, None]]]]: """Gets ALL the item data to go into the ROM. Item data consists of two bytes: the first dictates the appearance of the item, the second determines what the item actually is when picked up. All items from other worlds will be AP items that do nothing when picked up other than set their flag, and their appearance will depend on whether it's @@ -449,12 +432,11 @@ def get_location_data(world: "CV64World", active_locations: Iterable[Location]) # Figure out the item ID bytes to put in each Location here. Write the item itself if either it's the player's # very own, or it belongs to an Item Link that the player is a part of. - if loc.item.player == world.player or (loc.item.player in world.multiworld.groups and - world.player in world.multiworld.groups[loc.item.player]['players']): + if loc.item.player == world.player: if loc_type not in ["npc", "shop"] and get_item_info(loc.item.name, "pickup actor id") is not None: location_bytes[get_location_info(loc.name, "offset")] = get_item_info(loc.item.name, "pickup actor id") else: - location_bytes[get_location_info(loc.name, "offset")] = get_item_info(loc.item.name, "code") + location_bytes[get_location_info(loc.name, "offset")] = get_item_info(loc.item.name, "code") & 0xFF else: # Make the item the unused Wooden Stake - our multiworld item. location_bytes[get_location_info(loc.name, "offset")] = 0x11 @@ -534,11 +516,12 @@ def get_location_data(world: "CV64World", active_locations: Iterable[Location]) shop_colors_list.append(get_item_text_color(loc)) - return location_bytes, shop_name_list, shop_colors_list, shop_desc_list + return {offset: int.to_bytes(byte, 1, "big") for offset, byte in location_bytes.items()}, shop_name_list,\ + shop_colors_list, shop_desc_list def get_loading_zone_bytes(options: CV64Options, starting_stage: str, - active_stage_exits: Dict[str, Dict[str, Union[str, int, None]]]) -> Dict[int, int]: + active_stage_exits: Dict[str, Dict[str, Union[str, int, None]]]) -> Dict[int, bytes]: """Figure out all the bytes for loading zones and map transitions based on which stages are where in the exit data. The same data was used earlier in figuring out the logic. Map transitions consist of two major components: which map to send the player to, and which spot within the map to spawn the player at.""" @@ -551,8 +534,8 @@ def get_loading_zone_bytes(options: CV64Options, starting_stage: str, # Start loading zones # If the start zone is the start of the line, have it simply refresh the map. if active_stage_exits[stage]["prev"] == "Menu": - loading_zone_bytes[get_stage_info(stage, "startzone map offset")] = 0xFF - loading_zone_bytes[get_stage_info(stage, "startzone spawn offset")] = 0x00 + loading_zone_bytes[get_stage_info(stage, "startzone map offset")] = b"\xFF" + loading_zone_bytes[get_stage_info(stage, "startzone spawn offset")] = b"\x00" elif active_stage_exits[stage]["prev"]: loading_zone_bytes[get_stage_info(stage, "startzone map offset")] = \ get_stage_info(active_stage_exits[stage]["prev"], "end map id") @@ -563,7 +546,7 @@ def get_loading_zone_bytes(options: CV64Options, starting_stage: str, if active_stage_exits[stage]["prev"] == rname.castle_center: if options.character_stages == CharacterStages.option_carrie_only or \ active_stage_exits[rname.castle_center]["alt"] == stage: - loading_zone_bytes[get_stage_info(stage, "startzone spawn offset")] += 1 + loading_zone_bytes[get_stage_info(stage, "startzone spawn offset")] = b"\x03" # End loading zones if active_stage_exits[stage]["next"]: @@ -582,16 +565,16 @@ def get_loading_zone_bytes(options: CV64Options, starting_stage: str, return loading_zone_bytes -def get_start_inventory_data(player: int, options: CV64Options, precollected_items: List[Item]) -> Dict[int, int]: +def get_start_inventory_data(player: int, options: CV64Options, precollected_items: List[Item]) -> Dict[int, bytes]: """Calculate and return the starting inventory values. Not every Item goes into the menu inventory, so everything has to be handled appropriately.""" - start_inventory_data = {0xBFD867: 0, # Jewels - 0xBFD87B: 0, # PowerUps - 0xBFD883: 0, # Sub-weapon - 0xBFD88B: 0} # Ice Traps + start_inventory_data = {} inventory_items_array = [0 for _ in range(35)] total_money = 0 + total_jewels = 0 + total_powerups = 0 + total_ice_traps = 0 items_max = 10 @@ -615,42 +598,46 @@ def get_start_inventory_data(player: int, options: CV64Options, precollected_ite inventory_items_array[inventory_offset] = 2 # Starting sub-weapon elif sub_equip_id is not None: - start_inventory_data[0xBFD883] = sub_equip_id + start_inventory_data[0xBFD883] = bytes(sub_equip_id) # Starting PowerUps elif item.name == iname.powerup: - start_inventory_data[0xBFD87B] += 1 - if start_inventory_data[0xBFD87B] > 2: - start_inventory_data[0xBFD87B] = 2 + total_powerups += 1 + # Can't have more than 2 PowerUps. + if total_powerups > 2: + total_powerups = 2 # Starting Gold elif "GOLD" in item.name: total_money += int(item.name[0:4]) + # Money cannot be higher than 99999. if total_money > 99999: total_money = 99999 # Starting Jewels elif "jewel" in item.name: if "L" in item.name: - start_inventory_data[0xBFD867] += 10 + total_jewels += 10 else: - start_inventory_data[0xBFD867] += 5 - if start_inventory_data[0xBFD867] > 99: - start_inventory_data[0xBFD867] = 99 + total_jewels += 5 + # Jewels cannot be higher than 99. + if total_jewels > 99: + total_jewels = 99 # Starting Ice Traps else: - start_inventory_data[0xBFD88B] += 1 - if start_inventory_data[0xBFD88B] > 0xFF: - start_inventory_data[0xBFD88B] = 0xFF + total_ice_traps += 1 + # Ice Traps cannot be higher than 255. + if total_ice_traps > 0xFF: + total_ice_traps = 0xFF + + # Convert the jewels into data. + start_inventory_data[0xBFD867] = bytes([total_jewels]) + + # Convert the Ice Traps into data. + start_inventory_data[0xBFD88B] = bytes([total_ice_traps]) # Convert the inventory items into data. - for i in range(len(inventory_items_array)): - start_inventory_data[0xBFE518 + i] = inventory_items_array[i] - - # Convert the starting money into data. Which offset it starts from depends on how many bytes it takes up. - if total_money <= 0xFF: - start_inventory_data[0xBFE517] = total_money - elif total_money <= 0xFFFF: - start_inventory_data[0xBFE516] = total_money - else: - start_inventory_data[0xBFE515] = total_money + start_inventory_data[0xBFE518] = bytes(inventory_items_array) + + # Convert the starting money into data. + start_inventory_data[0xBFE514] = int.to_bytes(total_money, 4, "big") return start_inventory_data diff --git a/worlds/cv64/data/patches.py b/worlds/cv64/data/patches.py index 4c4670363831..938b615b3213 100644 --- a/worlds/cv64/data/patches.py +++ b/worlds/cv64/data/patches.py @@ -197,12 +197,15 @@ 0xA168FFFD, # SB T0, 0xFFFD (T3) ] -nitro_fall_killer = [ - # Custom code to force the instant fall death if at a high enough falling speed after getting killed by the Nitro - # explosion, since the game doesn't run the checks for the fall death after getting hit by said explosion and could - # result in a softlock when getting blown into an abyss. +launch_fall_killer = [ + # Custom code to force the instant fall death if at a high enough falling speed after getting killed by something + # that launches you (whether it be the Nitro explosion or a Big Toss hit). The game doesn't normally run the check + # that would trigger the fall death after you get killed by some other means, which could result in a softlock + # when a killing blow launches you into an abyss. 0x3C0C8035, # LUI T4, 0x8035 0x918807E2, # LBU T0, 0x07E2 (T4) + 0x24090008, # ADDIU T1, R0, 0x0008 + 0x11090002, # BEQ T0, T1, [forward 0x02] 0x2409000C, # ADDIU T1, R0, 0x000C 0x15090006, # BNE T0, T1, [forward 0x06] 0x3C098035, # LUI T1, 0x8035 @@ -2863,3 +2866,13 @@ 0xAD000814, # SW R0, 0x0814 (T0) 0x03200008 # JR T9 ] + +dog_bite_ice_trap_fix = [ + # Sets the freeze timer to 0 when a maze garden dog bites the player to ensure the ice chunk model will break if the + # player gets bitten while frozen via Ice Trap. + 0x3C088039, # LUI T0, 0x8039 + 0xA5009E76, # SH R0, 0x9E76 (T0) + 0x3C090F00, # LUI T1, 0x0F00 + 0x25291CB8, # ADDIU T1, T1, 0x1CB8 + 0x01200008 # JR T1 +] diff --git a/worlds/cv64/docs/obscure_checks.md b/worlds/cv64/docs/obscure_checks.md index 4aafc2db1c5f..6f0e0cdbb34e 100644 --- a/worlds/cv64/docs/obscure_checks.md +++ b/worlds/cv64/docs/obscure_checks.md @@ -27,7 +27,7 @@ in vanilla, contains 5 checks in rando. #### Bat archway rock After the broken bridge containing the invisible pathway to the Special1 in vanilla, this rock is off to the side in front of the gate frame with a swarm of bats that come at you, before the Werewolf's territory. Contains 4 checks. If you are new -to speedrunning the vanilla game and haven't yet learned the RNG manip strats, this is a guranteed spot to find a PowerUp at. +to speedrunning the vanilla game and haven't yet learned the RNG manip strats, this is a guaranteed spot to find a PowerUp at. diff --git a/worlds/cv64/options.py b/worlds/cv64/options.py index 495bb51c5ef8..da2b9f949662 100644 --- a/worlds/cv64/options.py +++ b/worlds/cv64/options.py @@ -74,7 +74,8 @@ class HardItemPool(Toggle): class Special1sPerWarp(Range): - """Sets how many Special1 jewels are needed per warp menu option unlock.""" + """Sets how many Special1 jewels are needed per warp menu option unlock. + This will decrease until the number x 7 is less than or equal to the Total Specail1s if it isn't already.""" range_start = 1 range_end = 10 default = 1 @@ -82,8 +83,7 @@ class Special1sPerWarp(Range): class TotalSpecial1s(Range): - """Sets how many Speical1 jewels are in the pool in total. - If this is set to be less than Special1s Per Warp x 7, it will decrease by 1 until it isn't.""" + """Sets how many Speical1 jewels are in the pool in total.""" range_start = 7 range_end = 70 default = 7 diff --git a/worlds/cv64/rom.py b/worlds/cv64/rom.py index ab8c7030aa4e..ab4371b0ac12 100644 --- a/worlds/cv64/rom.py +++ b/worlds/cv64/rom.py @@ -1,9 +1,9 @@ - +import json import Utils from BaseClasses import Location -from worlds.Files import APDeltaPatch -from typing import List, Dict, Union, Iterable, Collection, TYPE_CHECKING +from worlds.Files import APProcedurePatch, APTokenMixin, APTokenTypes, APPatchExtension +from typing import List, Dict, Union, Iterable, Collection, Optional, TYPE_CHECKING import hashlib import os @@ -22,37 +22,34 @@ if TYPE_CHECKING: from . import CV64World -CV64US10HASH = "1cc5cf3b4d29d8c3ade957648b529dc1" -ROM_PLAYER_LIMIT = 65535 +CV64_US_10_HASH = "1cc5cf3b4d29d8c3ade957648b529dc1" warp_map_offsets = [0xADF67, 0xADF77, 0xADF87, 0xADF97, 0xADFA7, 0xADFBB, 0xADFCB, 0xADFDF] -class LocalRom: +class RomData: orig_buffer: None buffer: bytearray - def __init__(self, file: str) -> None: - self.orig_buffer = None - - with open(file, "rb") as stream: - self.buffer = bytearray(stream.read()) + def __init__(self, file: bytes, name: Optional[str] = None) -> None: + self.file = bytearray(file) + self.name = name def read_bit(self, address: int, bit_number: int) -> bool: bitflag = (1 << bit_number) return (self.buffer[address] & bitflag) != 0 def read_byte(self, address: int) -> int: - return self.buffer[address] + return self.file[address] def read_bytes(self, start_address: int, length: int) -> bytearray: - return self.buffer[start_address:start_address + length] + return self.file[start_address:start_address + length] def write_byte(self, address: int, value: int) -> None: - self.buffer[address] = value + self.file[address] = value def write_bytes(self, start_address: int, values: Collection[int]) -> None: - self.buffer[start_address:start_address + len(values)] = values + self.file[start_address:start_address + len(values)] = values def write_int16(self, address: int, value: int) -> None: value = value & 0xFFFF @@ -78,862 +75,932 @@ def write_int32s(self, start_address: int, values: list) -> None: for i, value in enumerate(values): self.write_int32(start_address + (i * 4), value) - def write_to_file(self, filepath: str) -> None: - with open(filepath, "wb") as outfile: - outfile.write(self.buffer) + def get_bytes(self) -> bytes: + return bytes(self.file) -def patch_rom(world: "CV64World", rom: LocalRom, offset_data: Dict[int, int], shop_name_list: List[str], - shop_desc_list: List[List[Union[int, str, None]]], shop_colors_list: List[bytearray], - active_locations: Iterable[Location]) -> None: +class CV64PatchExtensions(APPatchExtension): + game = "Castlevania 64" - multiworld = world.multiworld - options = world.options - player = world.player - active_stage_exits = world.active_stage_exits - s1s_per_warp = world.s1s_per_warp + @staticmethod + def apply_patches(caller: APProcedurePatch, rom: bytes, options_file: str) -> bytes: + rom_data = RomData(rom) + options = json.loads(caller.get_file(options_file).decode("utf-8")) + + # NOP out the CRC BNEs + rom_data.write_int32(0x66C, 0x00000000) + rom_data.write_int32(0x678, 0x00000000) + + # Always offer Hard Mode on file creation + rom_data.write_int32(0xC8810, 0x240A0100) # ADDIU T2, R0, 0x0100 + + # Disable the Easy Mode cutoff point at Castle Center's elevator. + rom_data.write_int32(0xD9E18, 0x240D0000) # ADDIU T5, R0, 0x0000 + + # Disable the Forest, Castle Wall, and Villa intro cutscenes and make it possible to change the starting level + rom_data.write_byte(0xB73308, 0x00) + rom_data.write_byte(0xB7331A, 0x40) + rom_data.write_byte(0xB7332B, 0x4C) + rom_data.write_byte(0xB6302B, 0x00) + rom_data.write_byte(0x109F8F, 0x00) + + # Prevent Forest end cutscene flag from setting so it can be triggered infinitely. + rom_data.write_byte(0xEEA51, 0x01) + + # Hack to make the Forest, CW and Villa intro cutscenes play at the start of their levels no matter what map + # came before them. + rom_data.write_int32(0x97244, 0x803FDD60) + rom_data.write_int32s(0xBFDD60, patches.forest_cw_villa_intro_cs_player) + + # Make changing the map ID to 0xFF reset the map. Helpful to work around a bug wherein the camera gets stuck + # when entering a loading zone that doesn't change the map. + rom_data.write_int32s(0x197B0, [0x0C0FF7E6, # JAL 0x803FDF98 + 0x24840008]) # ADDIU A0, A0, 0x0008 + rom_data.write_int32s(0xBFDF98, patches.map_id_refresher) + + # Enable swapping characters when loading into a map by holding L. + rom_data.write_int32(0x97294, 0x803FDFC4) + rom_data.write_int32(0x19710, 0x080FF80E) # J 0x803FE038 + rom_data.write_int32s(0xBFDFC4, patches.character_changer) + + # Villa coffin time-of-day hack + rom_data.write_byte(0xD9D83, 0x74) + rom_data.write_int32(0xD9D84, 0x080FF14D) # J 0x803FC534 + rom_data.write_int32s(0xBFC534, patches.coffin_time_checker) + + # Fix both Castle Center elevator bridges for both characters unless enabling only one character's stages. + # At which point one bridge will be always broken and one always repaired instead. + if options["character_stages"] == CharacterStages.option_reinhardt_only: + rom_data.write_int32(0x6CEAA0, 0x240B0000) # ADDIU T3, R0, 0x0000 + elif options["character_stages"] == CharacterStages.option_carrie_only: + rom_data.write_int32(0x6CEAA0, 0x240B0001) # ADDIU T3, R0, 0x0001 + else: + rom_data.write_int32(0x6CEAA0, 0x240B0001) # ADDIU T3, R0, 0x0001 + rom_data.write_int32(0x6CEAA4, 0x240D0001) # ADDIU T5, R0, 0x0001 + + # Were-bull arena flag hack + rom_data.write_int32(0x6E38F0, 0x0C0FF157) # JAL 0x803FC55C + rom_data.write_int32s(0xBFC55C, patches.werebull_flag_unsetter) + rom_data.write_int32(0xA949C, 0x0C0FF380) # JAL 0x803FCE00 + rom_data.write_int32s(0xBFCE00, patches.werebull_flag_pickup_setter) + + # Enable being able to carry multiple Special jewels, Nitros, and Mandragoras simultaneously + rom_data.write_int32(0xBF1F4, 0x3C038039) # LUI V1, 0x8039 + # Special1 + rom_data.write_int32(0xBF210, 0x80659C4B) # LB A1, 0x9C4B (V1) + rom_data.write_int32(0xBF214, 0x24A50001) # ADDIU A1, A1, 0x0001 + rom_data.write_int32(0xBF21C, 0xA0659C4B) # SB A1, 0x9C4B (V1) + # Special2 + rom_data.write_int32(0xBF230, 0x80659C4C) # LB A1, 0x9C4C (V1) + rom_data.write_int32(0xBF234, 0x24A50001) # ADDIU A1, A1, 0x0001 + rom_data.write_int32(0xbf23C, 0xA0659C4C) # SB A1, 0x9C4C (V1) + # Magical Nitro + rom_data.write_int32(0xBF360, 0x10000004) # B 0x8013C184 + rom_data.write_int32(0xBF378, 0x25E50001) # ADDIU A1, T7, 0x0001 + rom_data.write_int32(0xBF37C, 0x10000003) # B 0x8013C19C + # Mandragora + rom_data.write_int32(0xBF3A8, 0x10000004) # B 0x8013C1CC + rom_data.write_int32(0xBF3C0, 0x25050001) # ADDIU A1, T0, 0x0001 + rom_data.write_int32(0xBF3C4, 0x10000003) # B 0x8013C1E4 + + # Give PowerUps their Legacy of Darkness behavior when attempting to pick up more than two + rom_data.write_int16(0xA9624, 0x1000) + rom_data.write_int32(0xA9730, 0x24090000) # ADDIU T1, R0, 0x0000 + rom_data.write_int32(0xBF2FC, 0x080FF16D) # J 0x803FC5B4 + rom_data.write_int32(0xBF300, 0x00000000) # NOP + rom_data.write_int32s(0xBFC5B4, patches.give_powerup_stopper) + + # Rename the Wooden Stake and Rose to "You are a FOOL!" + rom_data.write_bytes(0xEFE34, + bytearray([0xFF, 0xFF, 0xA2, 0x0B]) + cv64_string_to_bytearray("You are a FOOL!", + append_end=False)) + # Capitalize the "k" in "Archives key" to be consistent with...literally every other key name! + rom_data.write_byte(0xEFF21, 0x2D) + + # Skip the "There is a white jewel" text so checking one saves the game instantly. + rom_data.write_int32s(0xEFC72, [0x00020002 for _ in range(37)]) + rom_data.write_int32(0xA8FC0, 0x24020001) # ADDIU V0, R0, 0x0001 + # Skip the yes/no prompts when activating things. + rom_data.write_int32s(0xBFDACC, patches.map_text_redirector) + rom_data.write_int32(0xA9084, 0x24020001) # ADDIU V0, R0, 0x0001 + rom_data.write_int32(0xBEBE8, 0x0C0FF6B4) # JAL 0x803FDAD0 + # Skip Vincent and Heinrich's mandatory-for-a-check dialogue + rom_data.write_int32(0xBED9C, 0x0C0FF6DA) # JAL 0x803FDB68 + # Skip the long yes/no prompt in the CC planetarium to set the pieces. + rom_data.write_int32(0xB5C5DF, 0x24030001) # ADDIU V1, R0, 0x0001 + # Skip the yes/no prompt to activate the CC elevator. + rom_data.write_int32(0xB5E3FB, 0x24020001) # ADDIU V0, R0, 0x0001 + # Skip the yes/no prompts to set Nitro/Mandragora at both walls. + rom_data.write_int32(0xB5DF3E, 0x24030001) # ADDIU V1, R0, 0x0001 + + # Custom message if you try checking the downstairs CC crack before removing the seal. + rom_data.write_bytes(0xBFDBAC, cv64_string_to_bytearray("The Furious Nerd Curse\n" + "prevents you from setting\n" + "anything until the seal\n" + "is removed!", True)) + + rom_data.write_int32s(0xBFDD20, patches.special_descriptions_redirector) + + # Change the Stage Select menu options + rom_data.write_int32s(0xADF64, patches.warp_menu_rewrite) + rom_data.write_int32s(0x10E0C8, patches.warp_pointer_table) + + # Play the "teleportation" sound effect when teleporting + rom_data.write_int32s(0xAE088, [0x08004FAB, # J 0x80013EAC + 0x2404019E]) # ADDIU A0, R0, 0x019E + + # Lizard-man save proofing + rom_data.write_int32(0xA99AC, 0x080FF0B8) # J 0x803FC2E0 + rom_data.write_int32s(0xBFC2E0, patches.boss_save_stopper) + + # Disable or guarantee vampire Vincent's fight + if options["vincent_fight_condition"] == VincentFightCondition.option_never: + rom_data.write_int32(0xAACC0, 0x24010001) # ADDIU AT, R0, 0x0001 + rom_data.write_int32(0xAACE0, 0x24180000) # ADDIU T8, R0, 0x0000 + elif options["vincent_fight_condition"] == VincentFightCondition.option_always: + rom_data.write_int32(0xAACE0, 0x24180010) # ADDIU T8, R0, 0x0010 + else: + rom_data.write_int32(0xAACE0, 0x24180000) # ADDIU T8, R0, 0x0000 + + # Disable or guarantee Renon's fight + rom_data.write_int32(0xAACB4, 0x080FF1A4) # J 0x803FC690 + if options["renon_fight_condition"] == RenonFightCondition.option_never: + rom_data.write_byte(0xB804F0, 0x00) + rom_data.write_byte(0xB80632, 0x00) + rom_data.write_byte(0xB807E3, 0x00) + rom_data.write_byte(0xB80988, 0xB8) + rom_data.write_byte(0xB816BD, 0xB8) + rom_data.write_byte(0xB817CF, 0x00) + rom_data.write_int32s(0xBFC690, patches.renon_cutscene_checker_jr) + elif options["renon_fight_condition"] == RenonFightCondition.option_always: + rom_data.write_byte(0xB804F0, 0x0C) + rom_data.write_byte(0xB80632, 0x0C) + rom_data.write_byte(0xB807E3, 0x0C) + rom_data.write_byte(0xB80988, 0xC4) + rom_data.write_byte(0xB816BD, 0xC4) + rom_data.write_byte(0xB817CF, 0x0C) + rom_data.write_int32s(0xBFC690, patches.renon_cutscene_checker_jr) + else: + rom_data.write_int32s(0xBFC690, patches.renon_cutscene_checker) + + # NOP the Easy Mode check when buying a thing from Renon, so his fight can be triggered even on this mode. + rom_data.write_int32(0xBD8B4, 0x00000000) + + # Disable or guarantee the Bad Ending + if options["bad_ending_condition"] == BadEndingCondition.option_never: + rom_data.write_int32(0xAEE5C6, 0x3C0A0000) # LUI T2, 0x0000 + elif options["bad_ending_condition"] == BadEndingCondition.option_always: + rom_data.write_int32(0xAEE5C6, 0x3C0A0040) # LUI T2, 0x0040 + + # Play Castle Keep's song if teleporting in front of Dracula's door outside the escape sequence + rom_data.write_int32(0x6E937C, 0x080FF12E) # J 0x803FC4B8 + rom_data.write_int32s(0xBFC4B8, patches.ck_door_music_player) + + # Increase item capacity to 100 if "Increase Item Limit" is turned on + if options["increase_item_limit"]: + rom_data.write_byte(0xBF30B, 0x63) # Most items + rom_data.write_byte(0xBF3F7, 0x63) # Sun/Moon cards + rom_data.write_byte(0xBF353, 0x64) # Keys (increase regardless) + + # Change the item healing values if "Nerf Healing" is turned on + if options["nerf_healing_items"]: + rom_data.write_byte(0xB56371, 0x50) # Healing kit (100 -> 80) + rom_data.write_byte(0xB56374, 0x32) # Roast beef ( 80 -> 50) + rom_data.write_byte(0xB56377, 0x19) # Roast chicken ( 50 -> 25) + + # Disable loading zone healing if turned off + if not options["loading_zone_heals"]: + rom_data.write_byte(0xD99A5, 0x00) # Skip all loading zone checks + rom_data.write_byte(0xA9DFFB, + 0x40) # Disable free heal from King Skeleton by reading the unused magic meter value + + # Disable spinning on the Special1 and 2 pickup models so colorblind people can more easily identify them + rom_data.write_byte(0xEE4F5, 0x00) # Special1 + rom_data.write_byte(0xEE505, 0x00) # Special2 + # Make the Special2 the same size as a Red jewel(L) to further distinguish them + rom_data.write_int32(0xEE4FC, 0x3FA66666) + + # Prevent the vanilla Magical Nitro transport's "can explode" flag from setting + rom_data.write_int32(0xB5D7AA, 0x00000000) # NOP + + # Ensure the vampire Nitro check will always pass, so they'll never not spawn and crash the Villa cutscenes + rom_data.write_byte(0xA6253D, 0x03) + + # Enable the Game Over's "Continue" menu starting the cursor on whichever checkpoint is most recent + rom_data.write_int32(0xB4DDC, 0x0C060D58) # JAL 0x80183560 + rom_data.write_int32s(0x106750, patches.continue_cursor_start_checker) + rom_data.write_int32(0x1C444, 0x080FF08A) # J 0x803FC228 + rom_data.write_int32(0x1C2A0, 0x080FF08A) # J 0x803FC228 + rom_data.write_int32s(0xBFC228, patches.savepoint_cursor_updater) + rom_data.write_int32(0x1C2D0, 0x080FF094) # J 0x803FC250 + rom_data.write_int32s(0xBFC250, patches.stage_start_cursor_updater) + rom_data.write_byte(0xB585C8, 0xFF) + + # Make the Special1 and 2 play sounds when you reach milestones with them. + rom_data.write_int32s(0xBFDA50, patches.special_sound_notifs) + rom_data.write_int32(0xBF240, 0x080FF694) # J 0x803FDA50 + rom_data.write_int32(0xBF220, 0x080FF69E) # J 0x803FDA78 + + # Add data for White Jewel #22 (the new Duel Tower savepoint) at the end of the White Jewel ID data list + rom_data.write_int16s(0x104AC8, [0x0000, 0x0006, + 0x0013, 0x0015]) + + # Take the contract in Waterway off of its 00400000 bitflag. + rom_data.write_byte(0x87E3DA, 0x00) + + # Spawn coordinates list extension + rom_data.write_int32(0xD5BF4, 0x080FF103) # J 0x803FC40C + rom_data.write_int32s(0xBFC40C, patches.spawn_coordinates_extension) + rom_data.write_int32s(0x108A5E, patches.waterway_end_coordinates) + + # Fix a vanilla issue wherein saving in a character-exclusive stage as the other character would incorrectly + # display the name of that character's equivalent stage on the save file instead of the one they're actually in. + rom_data.write_byte(0xC9FE3, 0xD4) + rom_data.write_byte(0xCA055, 0x08) + rom_data.write_byte(0xCA066, 0x40) + rom_data.write_int32(0xCA068, 0x860C17D0) # LH T4, 0x17D0 (S0) + rom_data.write_byte(0xCA06D, 0x08) + rom_data.write_byte(0x104A31, 0x01) + rom_data.write_byte(0x104A39, 0x01) + rom_data.write_byte(0x104A89, 0x01) + rom_data.write_byte(0x104A91, 0x01) + rom_data.write_byte(0x104A99, 0x01) + rom_data.write_byte(0x104AA1, 0x01) + + # CC top elevator switch check + rom_data.write_int32(0x6CF0A0, 0x0C0FF0B0) # JAL 0x803FC2C0 + rom_data.write_int32s(0xBFC2C0, patches.elevator_flag_checker) + + # Disable time restrictions + if options["disable_time_restrictions"]: + # Fountain + rom_data.write_int32(0x6C2340, 0x00000000) # NOP + rom_data.write_int32(0x6C257C, 0x10000023) # B [forward 0x23] + # Rosa + rom_data.write_byte(0xEEAAB, 0x00) + rom_data.write_byte(0xEEAAD, 0x18) + # Moon doors + rom_data.write_int32(0xDC3E0, 0x00000000) # NOP + rom_data.write_int32(0xDC3E8, 0x00000000) # NOP + # Sun doors + rom_data.write_int32(0xDC410, 0x00000000) # NOP + rom_data.write_int32(0xDC418, 0x00000000) # NOP + + # Custom data-loading code + rom_data.write_int32(0x6B5028, 0x08060D70) # J 0x801835D0 + rom_data.write_int32s(0x1067B0, patches.custom_code_loader) + + # Custom remote item rewarding and DeathLink receiving code + rom_data.write_int32(0x19B98, 0x080FF000) # J 0x803FC000 + rom_data.write_int32s(0xBFC000, patches.remote_item_giver) + rom_data.write_int32s(0xBFE190, patches.subweapon_surface_checker) + + # Make received DeathLinks blow you to smithereens instead of kill you normally. + if options["death_link"] == DeathLink.option_explosive: + rom_data.write_int32(0x27A70, 0x10000008) # B [forward 0x08] + rom_data.write_int32s(0xBFC0D0, patches.deathlink_nitro_edition) + + # Set the DeathLink ROM flag if it's on at all. + if options["death_link"] != DeathLink.option_off: + rom_data.write_byte(0xBFBFDE, 0x01) + + # DeathLink counter decrementer code + rom_data.write_int32(0x1C340, 0x080FF8F0) # J 0x803FE3C0 + rom_data.write_int32s(0xBFE3C0, patches.deathlink_counter_decrementer) + rom_data.write_int32(0x25B6C, 0x080FFA5E) # J 0x803FE978 + rom_data.write_int32s(0xBFE978, patches.launch_fall_killer) + + # Death flag un-setter on "Beginning of stage" state overwrite code + rom_data.write_int32(0x1C2B0, 0x080FF047) # J 0x803FC11C + rom_data.write_int32s(0xBFC11C, patches.death_flag_unsetter) + + # Warp menu-opening code + rom_data.write_int32(0xB9BA8, 0x080FF099) # J 0x803FC264 + rom_data.write_int32s(0xBFC264, patches.warp_menu_opener) + + # NPC item textbox hack + rom_data.write_int32(0xBF1DC, 0x080FF904) # J 0x803FE410 + rom_data.write_int32(0xBF1E0, 0x27BDFFE0) # ADDIU SP, SP, -0x20 + rom_data.write_int32s(0xBFE410, patches.npc_item_hack) + + # Sub-weapon check function hook + rom_data.write_int32(0xBF32C, 0x00000000) # NOP + rom_data.write_int32(0xBF330, 0x080FF05E) # J 0x803FC178 + rom_data.write_int32s(0xBFC178, patches.give_subweapon_stopper) + + # Warp menu Special1 restriction + rom_data.write_int32(0xADD68, 0x0C04AB12) # JAL 0x8012AC48 + rom_data.write_int32s(0xADE28, patches.stage_select_overwrite) + rom_data.write_byte(0xADE47, options["s1s_per_warp"]) + + # Dracula's door text pointer hijack + rom_data.write_int32(0xD69F0, 0x080FF141) # J 0x803FC504 + rom_data.write_int32s(0xBFC504, patches.dracula_door_text_redirector) + + # Dracula's chamber condition + rom_data.write_int32(0xE2FDC, 0x0804AB25) # J 0x8012AC78 + rom_data.write_int32s(0xADE84, patches.special_goal_checker) + rom_data.write_bytes(0xBFCC48, + [0xA0, 0x00, 0xFF, 0xFF, 0xA0, 0x01, 0xFF, 0xFF, 0xA0, 0x02, 0xFF, 0xFF, 0xA0, 0x03, 0xFF, + 0xFF, 0xA0, 0x04, 0xFF, 0xFF, 0xA0, 0x05, 0xFF, 0xFF, 0xA0, 0x06, 0xFF, 0xFF, 0xA0, 0x07, + 0xFF, 0xFF, 0xA0, 0x08, 0xFF, 0xFF, 0xA0, 0x09]) + if options["draculas_condition"] == DraculasCondition.option_crystal: + rom_data.write_int32(0x6C8A54, 0x0C0FF0C1) # JAL 0x803FC304 + rom_data.write_int32s(0xBFC304, patches.crystal_special2_giver) + rom_data.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" + f"You'll need the power\n" + f"of the basement crystal\n" + f"to undo the seal.", True)) + special2_name = "Crystal " + special2_text = "The crystal is on!\n" \ + "Time to teach the old man\n" \ + "a lesson!" + elif options["draculas_condition"] == DraculasCondition.option_bosses: + rom_data.write_int32(0xBBD50, 0x080FF18C) # J 0x803FC630 + rom_data.write_int32s(0xBFC630, patches.boss_special2_giver) + rom_data.write_int32s(0xBFC55C, patches.werebull_flag_unsetter_special2_electric_boogaloo) + rom_data.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" + f"You'll need to defeat\n" + f"{options['required_s2s']} powerful monsters\n" + f"to undo the seal.", True)) + special2_name = "Trophy " + special2_text = f"Proof you killed a powerful\n" \ + f"Night Creature. Earn {options['required_s2s']}/{options['total_s2s']}\n" \ + f"to battle Dracula." + elif options["draculas_condition"] == DraculasCondition.option_specials: + special2_name = "Special2" + rom_data.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" + f"You'll need to find\n" + f"{options['required_s2s']} Special2 jewels\n" + f"to undo the seal.", True)) + special2_text = f"Need {options['required_s2s']}/{options['total_s2s']} to kill Dracula.\n" \ + f"Looking closely, you see...\n" \ + f"a piece of him within?" + else: + rom_data.write_byte(0xADE8F, 0x00) + special2_name = "Special2" + special2_text = "If you're reading this,\n" \ + "how did you get a Special2!?" + rom_data.write_byte(0xADE8F, options["required_s2s"]) + # Change the Special2 name depending on the setting. + rom_data.write_bytes(0xEFD4E, cv64_string_to_bytearray(special2_name)) + # Change the Special1 and 2 menu descriptions to tell you how many you need to unlock a warp and fight Dracula + # respectively. + special_text_bytes = cv64_string_to_bytearray(f"{options['s1s_per_warp']} per warp unlock.\n" + f"{options['total_special1s']} exist in total.\n" + f"Z + R + START to warp.") + cv64_string_to_bytearray( + special2_text) + rom_data.write_bytes(0xBFE53C, special_text_bytes) + + # On-the-fly overlay modifier + rom_data.write_int32s(0xBFC338, patches.double_component_checker) + rom_data.write_int32s(0xBFC3D4, patches.downstairs_seal_checker) + rom_data.write_int32s(0xBFE074, patches.mandragora_with_nitro_setter) + rom_data.write_int32s(0xBFC700, patches.overlay_modifiers) + + # On-the-fly actor data modifier hook + rom_data.write_int32(0xEAB04, 0x080FF21E) # J 0x803FC878 + rom_data.write_int32s(0xBFC870, patches.map_data_modifiers) + + # Fix to make flags apply to freestanding invisible items properly + rom_data.write_int32(0xA84F8, 0x90CC0039) # LBU T4, 0x0039 (A2) + + # Fix locked doors to check the key counters instead of their vanilla key locations' bitflags + # Pickup flag check modifications: + rom_data.write_int32(0x10B2D8, 0x00000002) # Left Tower Door + rom_data.write_int32(0x10B2F0, 0x00000003) # Storeroom Door + rom_data.write_int32(0x10B2FC, 0x00000001) # Archives Door + rom_data.write_int32(0x10B314, 0x00000004) # Maze Gate + rom_data.write_int32(0x10B350, 0x00000005) # Copper Door + rom_data.write_int32(0x10B3A4, 0x00000006) # Torture Chamber Door + rom_data.write_int32(0x10B3B0, 0x00000007) # ToE Gate + rom_data.write_int32(0x10B3BC, 0x00000008) # Science Door1 + rom_data.write_int32(0x10B3C8, 0x00000009) # Science Door2 + rom_data.write_int32(0x10B3D4, 0x0000000A) # Science Door3 + rom_data.write_int32(0x6F0094, 0x0000000B) # CT Door 1 + rom_data.write_int32(0x6F00A4, 0x0000000C) # CT Door 2 + rom_data.write_int32(0x6F00B4, 0x0000000D) # CT Door 3 + # Item counter decrement check modifications: + rom_data.write_int32(0xEDA84, 0x00000001) # Archives Door + rom_data.write_int32(0xEDA8C, 0x00000002) # Left Tower Door + rom_data.write_int32(0xEDA94, 0x00000003) # Storeroom Door + rom_data.write_int32(0xEDA9C, 0x00000004) # Maze Gate + rom_data.write_int32(0xEDAA4, 0x00000005) # Copper Door + rom_data.write_int32(0xEDAAC, 0x00000006) # Torture Chamber Door + rom_data.write_int32(0xEDAB4, 0x00000007) # ToE Gate + rom_data.write_int32(0xEDABC, 0x00000008) # Science Door1 + rom_data.write_int32(0xEDAC4, 0x00000009) # Science Door2 + rom_data.write_int32(0xEDACC, 0x0000000A) # Science Door3 + rom_data.write_int32(0xEDAD4, 0x0000000B) # CT Door 1 + rom_data.write_int32(0xEDADC, 0x0000000C) # CT Door 2 + rom_data.write_int32(0xEDAE4, 0x0000000D) # CT Door 3 + + # Fix ToE gate's "unlocked" flag in the locked door flags table + rom_data.write_int16(0x10B3B6, 0x0001) + + rom_data.write_int32(0x10AB2C, 0x8015FBD4) # Maze Gates' check code pointer adjustments + rom_data.write_int32(0x10AB40, 0x8015FBD4) + rom_data.write_int32s(0x10AB50, [0x0D0C0000, + 0x8015FBD4]) + rom_data.write_int32s(0x10AB64, [0x0D0C0000, + 0x8015FBD4]) + rom_data.write_int32s(0xE2E14, patches.normal_door_hook) + rom_data.write_int32s(0xBFC5D0, patches.normal_door_code) + rom_data.write_int32s(0x6EF298, patches.ct_door_hook) + rom_data.write_int32s(0xBFC608, patches.ct_door_code) + # Fix key counter not decrementing if 2 or above + rom_data.write_int32(0xAA0E0, 0x24020000) # ADDIU V0, R0, 0x0000 + + # Make the Easy-only candle drops in Room of Clocks appear on any difficulty + rom_data.write_byte(0x9B518F, 0x01) + + # Slightly move some once-invisible freestanding items to be more visible + if options["invisible_items"] == InvisibleItems.option_reveal_all: + rom_data.write_byte(0x7C7F95, 0xEF) # Forest dirge maiden statue + rom_data.write_byte(0x7C7FA8, 0xAB) # Forest werewolf statue + rom_data.write_byte(0x8099C4, 0x8C) # Villa courtyard tombstone + rom_data.write_byte(0x83A626, 0xC2) # Villa living room painting + # rom_data.write_byte(0x83A62F, 0x64) # Villa Mary's room table + rom_data.write_byte(0xBFCB97, 0xF5) # CC torture instrument rack + rom_data.write_byte(0x8C44D5, 0x22) # CC red carpet hallway knight + rom_data.write_byte(0x8DF57C, 0xF1) # CC cracked wall hallway flamethrower + rom_data.write_byte(0x90FCD6, 0xA5) # CC nitro hallway flamethrower + rom_data.write_byte(0x90FB9F, 0x9A) # CC invention room round machine + rom_data.write_byte(0x90FBAF, 0x03) # CC invention room giant famicart + rom_data.write_byte(0x90FE54, 0x97) # CC staircase knight (x) + rom_data.write_byte(0x90FE58, 0xFB) # CC staircase knight (z) + + # Change the bitflag on the item in upper coffin in Forest final switch gate tomb to one that's not used by + # something else. + rom_data.write_int32(0x10C77C, 0x00000002) + + # Make the torch directly behind Dracula's chamber that normally doesn't set a flag set bitflag 0x08 in + # 0x80389BFA. + rom_data.write_byte(0x10CE9F, 0x01) + + # Change the CC post-Behemoth boss depending on the option for Post-Behemoth Boss + if options["post_behemoth_boss"] == PostBehemothBoss.option_inverted: + rom_data.write_byte(0xEEDAD, 0x02) + rom_data.write_byte(0xEEDD9, 0x01) + elif options["post_behemoth_boss"] == PostBehemothBoss.option_always_rosa: + rom_data.write_byte(0xEEDAD, 0x00) + rom_data.write_byte(0xEEDD9, 0x03) + # Put both on the same flag so changing character won't trigger a rematch with the same boss. + rom_data.write_byte(0xEED8B, 0x40) + elif options["post_behemoth_boss"] == PostBehemothBoss.option_always_camilla: + rom_data.write_byte(0xEEDAD, 0x03) + rom_data.write_byte(0xEEDD9, 0x00) + rom_data.write_byte(0xEED8B, 0x40) + + # Change the RoC boss depending on the option for Room of Clocks Boss + if options["room_of_clocks_boss"] == RoomOfClocksBoss.option_inverted: + rom_data.write_byte(0x109FB3, 0x56) + rom_data.write_byte(0x109FBF, 0x44) + rom_data.write_byte(0xD9D44, 0x14) + rom_data.write_byte(0xD9D4C, 0x14) + elif options["room_of_clocks_boss"] == RoomOfClocksBoss.option_always_death: + rom_data.write_byte(0x109FBF, 0x44) + rom_data.write_byte(0xD9D45, 0x00) + # Put both on the same flag so changing character won't trigger a rematch with the same boss. + rom_data.write_byte(0x109FB7, 0x90) + rom_data.write_byte(0x109FC3, 0x90) + elif options["room_of_clocks_boss"] == RoomOfClocksBoss.option_always_actrise: + rom_data.write_byte(0x109FB3, 0x56) + rom_data.write_int32(0xD9D44, 0x00000000) + rom_data.write_byte(0xD9D4D, 0x00) + rom_data.write_byte(0x109FB7, 0x90) + rom_data.write_byte(0x109FC3, 0x90) + + # Un-nerf Actrise when playing as Reinhardt. + # This is likely a leftover TGS demo feature in which players could battle Actrise as Reinhardt. + rom_data.write_int32(0xB318B4, 0x240E0001) # ADDIU T6, R0, 0x0001 + + # Tunnel gondola skip + if options["skip_gondolas"]: + rom_data.write_int32(0x6C5F58, 0x080FF7D0) # J 0x803FDF40 + rom_data.write_int32s(0xBFDF40, patches.gondola_skipper) + # New gondola transfer point candle coordinates + rom_data.write_byte(0xBFC9A3, 0x04) + rom_data.write_bytes(0x86D824, [0x27, 0x01, 0x10, 0xF7, 0xA0]) + + # Waterway brick platforms skip + if options["skip_waterway_blocks"]: + rom_data.write_int32(0x6C7E2C, 0x00000000) # NOP + + # Ambience silencing fix + rom_data.write_int32(0xD9270, 0x080FF840) # J 0x803FE100 + rom_data.write_int32s(0xBFE100, patches.ambience_silencer) + # Fix for the door sliding sound playing infinitely if leaving the fan meeting room before the door closes + # entirely. Hooking this in the ambience silencer code does nothing for some reason. + rom_data.write_int32s(0xAE10C, [0x08004FAB, # J 0x80013EAC + 0x3404829B]) # ORI A0, R0, 0x829B + rom_data.write_int32s(0xD9E8C, [0x08004FAB, # J 0x80013EAC + 0x3404829B]) # ORI A0, R0, 0x829B + # Fan meeting room ambience fix + rom_data.write_int32(0x109964, 0x803FE13C) + + # Make the Villa coffin cutscene skippable + rom_data.write_int32(0xAA530, 0x080FF880) # J 0x803FE200 + rom_data.write_int32s(0xBFE200, patches.coffin_cutscene_skipper) + + # Increase shimmy speed + if options["increase_shimmy_speed"]: + rom_data.write_byte(0xA4241, 0x5A) + + # Disable landing fall damage + if options["fall_guard"]: + rom_data.write_byte(0x27B23, 0x00) + + # Enable the unused film reel effect on all cutscenes + if options["cinematic_experience"]: + rom_data.write_int32(0xAA33C, 0x240A0001) # ADDIU T2, R0, 0x0001 + rom_data.write_byte(0xAA34B, 0x0C) + rom_data.write_int32(0xAA4C4, 0x24090001) # ADDIU T1, R0, 0x0001 + + # Permanent PowerUp stuff + if options["permanent_powerups"]: + # Make receiving PowerUps increase the unused menu PowerUp counter instead of the one outside the save + # struct. + rom_data.write_int32(0xBF2EC, 0x806B619B) # LB T3, 0x619B (V1) + rom_data.write_int32(0xBFC5BC, 0xA06C619B) # SB T4, 0x619B (V1) + # Make Reinhardt's whip check the menu PowerUp counter + rom_data.write_int32(0x69FA08, 0x80CC619B) # LB T4, 0x619B (A2) + rom_data.write_int32(0x69FBFC, 0x80C3619B) # LB V1, 0x619B (A2) + rom_data.write_int32(0x69FFE0, 0x818C9C53) # LB T4, 0x9C53 (T4) + # Make Carrie's orb check the menu PowerUp counter + rom_data.write_int32(0x6AC86C, 0x8105619B) # LB A1, 0x619B (T0) + rom_data.write_int32(0x6AC950, 0x8105619B) # LB A1, 0x619B (T0) + rom_data.write_int32(0x6AC99C, 0x810E619B) # LB T6, 0x619B (T0) + rom_data.write_int32(0x5AFA0, 0x80639C53) # LB V1, 0x9C53 (V1) + rom_data.write_int32(0x5B0A0, 0x81089C53) # LB T0, 0x9C53 (T0) + rom_data.write_byte(0x391C7, 0x00) # Prevent PowerUps from dropping from regular enemies + rom_data.write_byte(0xEDEDF, 0x03) # Make any vanishing PowerUps that do show up L jewels instead + # Rename the PowerUp to "PermaUp" + rom_data.write_bytes(0xEFDEE, cv64_string_to_bytearray("PermaUp")) + # Replace the PowerUp in the Forest Special1 Bridge 3HB rock with an L jewel if 3HBs aren't randomized + if not options["multi_hit_breakables"]: + rom_data.write_byte(0x10C7A1, 0x03) + # Change the appearance of the Pot-Pourri to that of a larger PowerUp regardless of the above setting, so other + # game PermaUps are distinguishable. + rom_data.write_int32s(0xEE558, [0x06005F08, 0x3FB00000, 0xFFFFFF00]) + + # Write the associated code for the randomized (or disabled) music list. + if options["background_music"]: + rom_data.write_int32(0x14588, 0x08060D60) # J 0x80183580 + rom_data.write_int32(0x14590, 0x00000000) # NOP + rom_data.write_int32s(0x106770, patches.music_modifier) + rom_data.write_int32(0x15780, 0x0C0FF36E) # JAL 0x803FCDB8 + rom_data.write_int32s(0xBFCDB8, patches.music_comparer_modifier) + + # Enable storing item flags anywhere and changing the item model/visibility on any item instance. + rom_data.write_int32s(0xA857C, [0x080FF38F, # J 0x803FCE3C + 0x94D90038]) # LHU T9, 0x0038 (A2) + rom_data.write_int32s(0xBFCE3C, patches.item_customizer) + rom_data.write_int32s(0xA86A0, [0x0C0FF3AF, # JAL 0x803FCEBC + 0x95C40002]) # LHU A0, 0x0002 (T6) + rom_data.write_int32s(0xBFCEBC, patches.item_appearance_switcher) + rom_data.write_int32s(0xA8728, [0x0C0FF3B8, # JAL 0x803FCEE4 + 0x01396021]) # ADDU T4, T1, T9 + rom_data.write_int32s(0xBFCEE4, patches.item_model_visibility_switcher) + rom_data.write_int32s(0xA8A04, [0x0C0FF3C2, # JAL 0x803FCF08 + 0x018B6021]) # ADDU T4, T4, T3 + rom_data.write_int32s(0xBFCF08, patches.item_shine_visibility_switcher) + + # Make Axes and Crosses in AP Locations drop to their correct height, and make items with changed appearances + # spin their correct speed. + rom_data.write_int32s(0xE649C, [0x0C0FFA03, # JAL 0x803FE80C + 0x956C0002]) # LHU T4, 0x0002 (T3) + rom_data.write_int32s(0xA8B08, [0x080FFA0C, # J 0x803FE830 + 0x960A0038]) # LHU T2, 0x0038 (S0) + rom_data.write_int32s(0xE8584, [0x0C0FFA21, # JAL 0x803FE884 + 0x95D80000]) # LHU T8, 0x0000 (T6) + rom_data.write_int32s(0xE7AF0, [0x0C0FFA2A, # JAL 0x803FE8A8 + 0x958D0000]) # LHU T5, 0x0000 (T4) + rom_data.write_int32s(0xBFE7DC, patches.item_drop_spin_corrector) + + # Disable the 3HBs checking and setting flags when breaking them and enable their individual items checking and + # setting flags instead. + if options["multi_hit_breakables"]: + rom_data.write_int32(0xE87F8, 0x00000000) # NOP + rom_data.write_int16(0xE836C, 0x1000) + rom_data.write_int32(0xE8B40, 0x0C0FF3CD) # JAL 0x803FCF34 + rom_data.write_int32s(0xBFCF34, patches.three_hit_item_flags_setter) + # Villa foyer chandelier-specific functions (yeah, IDK why KCEK made different functions for this one) + rom_data.write_int32(0xE7D54, 0x00000000) # NOP + rom_data.write_int16(0xE7908, 0x1000) + rom_data.write_byte(0xE7A5C, 0x10) + rom_data.write_int32(0xE7F08, 0x0C0FF3DF) # JAL 0x803FCF7C + rom_data.write_int32s(0xBFCF7C, patches.chandelier_item_flags_setter) + + # New flag values to put in each 3HB vanilla flag's spot + rom_data.write_int32(0x10C7C8, 0x8000FF48) # FoS dirge maiden rock + rom_data.write_int32(0x10C7B0, 0x0200FF48) # FoS S1 bridge rock + rom_data.write_int32(0x10C86C, 0x0010FF48) # CW upper rampart save nub + rom_data.write_int32(0x10C878, 0x4000FF49) # CW Dracula switch slab + rom_data.write_int32(0x10CAD8, 0x0100FF49) # Tunnel twin arrows slab + rom_data.write_int32(0x10CAE4, 0x0004FF49) # Tunnel lonesome bucket pit rock + rom_data.write_int32(0x10CB54, 0x4000FF4A) # UW poison parkour ledge + rom_data.write_int32(0x10CB60, 0x0080FF4A) # UW skeleton crusher ledge + rom_data.write_int32(0x10CBF0, 0x0008FF4A) # CC Behemoth crate + rom_data.write_int32(0x10CC2C, 0x2000FF4B) # CC elevator pedestal + rom_data.write_int32(0x10CC70, 0x0200FF4B) # CC lizard locker slab + rom_data.write_int32(0x10CD88, 0x0010FF4B) # ToE pre-midsavepoint platforms ledge + rom_data.write_int32(0x10CE6C, 0x4000FF4C) # ToSci invisible bridge crate + rom_data.write_int32(0x10CF20, 0x0080FF4C) # CT inverted battery slab + rom_data.write_int32(0x10CF2C, 0x0008FF4C) # CT inverted door slab + rom_data.write_int32(0x10CF38, 0x8000FF4D) # CT final room door slab + rom_data.write_int32(0x10CF44, 0x1000FF4D) # CT Renon slab + rom_data.write_int32(0x10C908, 0x0008FF4D) # Villa foyer chandelier + rom_data.write_byte(0x10CF37, 0x04) # pointer for CT final room door slab item data + + # Once-per-frame gameplay checks + rom_data.write_int32(0x6C848, 0x080FF40D) # J 0x803FD034 + rom_data.write_int32(0xBFD058, 0x0801AEB5) # J 0x8006BAD4 + + # Everything related to dropping the previous sub-weapon + if options["drop_previous_sub_weapon"]: + rom_data.write_int32(0xBFD034, 0x080FF3FF) # J 0x803FCFFC + rom_data.write_int32(0xBFC190, 0x080FF3F2) # J 0x803FCFC8 + rom_data.write_int32s(0xBFCFC4, patches.prev_subweapon_spawn_checker) + rom_data.write_int32s(0xBFCFFC, patches.prev_subweapon_fall_checker) + rom_data.write_int32s(0xBFD060, patches.prev_subweapon_dropper) + + # Everything related to the Countdown counter + if options["countdown"]: + rom_data.write_int32(0xBFD03C, 0x080FF9DC) # J 0x803FE770 + rom_data.write_int32(0xD5D48, 0x080FF4EC) # J 0x803FD3B0 + rom_data.write_int32s(0xBFD3B0, patches.countdown_number_displayer) + rom_data.write_int32s(0xBFD6DC, patches.countdown_number_manager) + rom_data.write_int32s(0xBFE770, patches.countdown_demo_hider) + rom_data.write_int32(0xBFCE2C, 0x080FF5D2) # J 0x803FD748 + rom_data.write_int32s(0xBB168, [0x080FF5F4, # J 0x803FD7D0 + 0x8E020028]) # LW V0, 0x0028 (S0) + rom_data.write_int32s(0xBB1D0, [0x080FF5FB, # J 0x803FD7EC + 0x8E020028]) # LW V0, 0x0028 (S0) + rom_data.write_int32(0xBC4A0, 0x080FF5E6) # J 0x803FD798 + rom_data.write_int32(0xBC4C4, 0x080FF5E6) # J 0x803FD798 + rom_data.write_int32(0x19844, 0x080FF602) # J 0x803FD808 + # If the option is set to "all locations", count it down no matter what the item is. + if options["countdown"] == Countdown.option_all_locations: + rom_data.write_int32s(0xBFD71C, [0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101]) + else: + # If it's majors, then insert this last minute check I threw together for the weird edge case of a CV64 + # ice trap for another CV64 player taking the form of a major. + rom_data.write_int32s(0xBFD788, [0x080FF717, # J 0x803FDC5C + 0x2529FFFF]) # ADDIU T1, T1, 0xFFFF + rom_data.write_int32s(0xBFDC5C, patches.countdown_extra_safety_check) + rom_data.write_int32(0xA9ECC, + 0x00000000) # NOP the pointless overwrite of the item actor appearance custom value. + + # Ice Trap stuff + rom_data.write_int32(0x697C60, 0x080FF06B) # J 0x803FC18C + rom_data.write_int32(0x6A5160, 0x080FF06B) # J 0x803FC18C + rom_data.write_int32s(0xBFC1AC, patches.ice_trap_initializer) + rom_data.write_int32s(0xBFE700, patches.the_deep_freezer) + rom_data.write_int32s(0xB2F354, [0x3739E4C0, # ORI T9, T9, 0xE4C0 + 0x03200008, # JR T9 + 0x00000000]) # NOP + rom_data.write_int32s(0xBFE4C0, patches.freeze_verifier) + + # Fix for the ice chunk model staying when getting bitten by the maze garden dogs + rom_data.write_int32(0xA2DC48, 0x803FE9C0) + rom_data.write_int32s(0xBFE9C0, patches.dog_bite_ice_trap_fix) + + # Initial Countdown numbers + rom_data.write_int32(0xAD6A8, 0x080FF60A) # J 0x803FD828 + rom_data.write_int32s(0xBFD828, patches.new_game_extras) + + # Everything related to shopsanity + if options["shopsanity"]: + rom_data.write_byte(0xBFBFDF, 0x01) + rom_data.write_bytes(0x103868, cv64_string_to_bytearray("Not obtained. ")) + rom_data.write_int32s(0xBFD8D0, patches.shopsanity_stuff) + rom_data.write_int32(0xBD828, 0x0C0FF643) # JAL 0x803FD90C + rom_data.write_int32(0xBD5B8, 0x0C0FF651) # JAL 0x803FD944 + rom_data.write_int32(0xB0610, 0x0C0FF665) # JAL 0x803FD994 + rom_data.write_int32s(0xBD24C, [0x0C0FF677, # J 0x803FD9DC + 0x00000000]) # NOP + rom_data.write_int32(0xBD618, 0x0C0FF684) # JAL 0x803FDA10 + + # Panther Dash running + if options["panther_dash"]: + rom_data.write_int32(0x69C8C4, 0x0C0FF77E) # JAL 0x803FDDF8 + rom_data.write_int32(0x6AA228, 0x0C0FF77E) # JAL 0x803FDDF8 + rom_data.write_int32s(0x69C86C, [0x0C0FF78E, # JAL 0x803FDE38 + 0x3C01803E]) # LUI AT, 0x803E + rom_data.write_int32s(0x6AA1D0, [0x0C0FF78E, # JAL 0x803FDE38 + 0x3C01803E]) # LUI AT, 0x803E + rom_data.write_int32(0x69D37C, 0x0C0FF79E) # JAL 0x803FDE78 + rom_data.write_int32(0x6AACE0, 0x0C0FF79E) # JAL 0x803FDE78 + rom_data.write_int32s(0xBFDDF8, patches.panther_dash) + # Jump prevention + if options["panther_dash"] == PantherDash.option_jumpless: + rom_data.write_int32(0xBFDE2C, 0x080FF7BB) # J 0x803FDEEC + rom_data.write_int32(0xBFD044, 0x080FF7B1) # J 0x803FDEC4 + rom_data.write_int32s(0x69B630, [0x0C0FF7C6, # JAL 0x803FDF18 + 0x8CCD0000]) # LW T5, 0x0000 (A2) + rom_data.write_int32s(0x6A8EC0, [0x0C0FF7C6, # JAL 0x803FDF18 + 0x8CCC0000]) # LW T4, 0x0000 (A2) + # Fun fact: KCEK put separate code to handle coyote time jumping + rom_data.write_int32s(0x69910C, [0x0C0FF7C6, # JAL 0x803FDF18 + 0x8C4E0000]) # LW T6, 0x0000 (V0) + rom_data.write_int32s(0x6A6718, [0x0C0FF7C6, # JAL 0x803FDF18 + 0x8C4E0000]) # LW T6, 0x0000 (V0) + rom_data.write_int32s(0xBFDEC4, patches.panther_jump_preventer) + + # Everything related to Big Toss. + if options["big_toss"]: + rom_data.write_int32s(0x27E90, [0x0C0FFA38, # JAL 0x803FE8E0 + 0xAFB80074]) # SW T8, 0x0074 (SP) + rom_data.write_int32(0x26F54, 0x0C0FFA4D) # JAL 0x803FE934 + rom_data.write_int32s(0xBFE8E0, patches.big_tosser) + + # Write the specified window colors + rom_data.write_byte(0xAEC23, options["window_color_r"] << 4) + rom_data.write_byte(0xAEC33, options["window_color_g"] << 4) + rom_data.write_byte(0xAEC47, options["window_color_b"] << 4) + rom_data.write_byte(0xAEC43, options["window_color_a"] << 4) + + # Everything relating to loading the other game items text + rom_data.write_int32(0xA8D8C, 0x080FF88F) # J 0x803FE23C + rom_data.write_int32(0xBEA98, 0x0C0FF8B4) # JAL 0x803FE2D0 + rom_data.write_int32(0xBEAB0, 0x0C0FF8BD) # JAL 0x803FE2F8 + rom_data.write_int32(0xBEACC, 0x0C0FF8C5) # JAL 0x803FE314 + rom_data.write_int32s(0xBFE23C, patches.multiworld_item_name_loader) + rom_data.write_bytes(0x10F188, [0x00 for _ in range(264)]) + rom_data.write_bytes(0x10F298, [0x00 for _ in range(264)]) + + # When the game normally JALs to the item prepare textbox function after the player picks up an item, set the + # "no receiving" timer to ensure the item textbox doesn't freak out if you pick something up while there's a + # queue of unreceived items. + rom_data.write_int32(0xA8D94, 0x0C0FF9F0) # JAL 0x803FE7C0 + rom_data.write_int32s(0xBFE7C0, [0x3C088039, # LUI T0, 0x8039 + 0x24090020, # ADDIU T1, R0, 0x0020 + 0x0804EDCE, # J 0x8013B738 + 0xA1099BE0]) # SB T1, 0x9BE0 (T0) + + return rom_data.get_bytes() + + @staticmethod + def patch_ap_graphics(caller: APProcedurePatch, rom: bytes) -> bytes: + rom_data = RomData(rom) + + # Extract the item models file, decompress it, append the AP icons, compress it back, re-insert it. + items_file = lzkn64.decompress_buffer(rom_data.read_bytes(0x9C5310, 0x3D28)) + compressed_file = lzkn64.compress_buffer(items_file[0:0x69B6] + pkgutil.get_data(__name__, "data/ap_icons.bin")) + rom_data.write_bytes(0xBB2D88, compressed_file) + # Update the items' Nisitenma-Ichigo table entry to point to the new file's start and end addresses in the rom. + rom_data.write_int32s(0x95F04, [0x80BB2D88, 0x00BB2D88 + len(compressed_file)]) + # Update the items' decompressed file size tables with the new file's decompressed file size. + rom_data.write_int16(0x95706, 0x7BF0) + rom_data.write_int16(0x104CCE, 0x7BF0) + # Update the Wooden Stake and Roses' item appearance settings table to point to the Archipelago item graphics. + rom_data.write_int16(0xEE5BA, 0x7B38) + rom_data.write_int16(0xEE5CA, 0x7280) + # Change the items' sizes. The progression one will be larger than the non-progression one. + rom_data.write_int32(0xEE5BC, 0x3FF00000) + rom_data.write_int32(0xEE5CC, 0x3FA00000) + + return rom_data.get_bytes() + + +class CV64ProcedurePatch(APProcedurePatch, APTokenMixin): + hash = [CV64_US_10_HASH] + patch_file_ending: str = ".apcv64" + result_file_ending: str = ".z64" + + game = "Castlevania 64" + + procedure = [ + ("apply_patches", ["options.json"]), + ("apply_tokens", ["token_data.bin"]), + ("patch_ap_graphics", []) + ] + + @classmethod + def get_source_data(cls) -> bytes: + return get_base_rom_bytes() + + +def write_patch(world: "CV64World", patch: CV64ProcedurePatch, offset_data: Dict[int, bytes], shop_name_list: List[str], + shop_desc_list: List[List[Union[int, str, None]]], shop_colors_list: List[bytearray], + active_locations: Iterable[Location]) -> None: active_warp_list = world.active_warp_list - required_s2s = world.required_s2s - total_s2s = world.total_s2s - - # NOP out the CRC BNEs - rom.write_int32(0x66C, 0x00000000) - rom.write_int32(0x678, 0x00000000) - - # Always offer Hard Mode on file creation - rom.write_int32(0xC8810, 0x240A0100) # ADDIU T2, R0, 0x0100 - - # Disable Easy Mode cutoff point at Castle Center elevator - rom.write_int32(0xD9E18, 0x240D0000) # ADDIU T5, R0, 0x0000 - - # Disable the Forest, Castle Wall, and Villa intro cutscenes and make it possible to change the starting level - rom.write_byte(0xB73308, 0x00) - rom.write_byte(0xB7331A, 0x40) - rom.write_byte(0xB7332B, 0x4C) - rom.write_byte(0xB6302B, 0x00) - rom.write_byte(0x109F8F, 0x00) - - # Prevent Forest end cutscene flag from setting so it can be triggered infinitely - rom.write_byte(0xEEA51, 0x01) - - # Hack to make the Forest, CW and Villa intro cutscenes play at the start of their levels no matter what map came - # before them - rom.write_int32(0x97244, 0x803FDD60) - rom.write_int32s(0xBFDD60, patches.forest_cw_villa_intro_cs_player) - - # Make changing the map ID to 0xFF reset the map. Helpful to work around a bug wherein the camera gets stuck when - # entering a loading zone that doesn't change the map. - rom.write_int32s(0x197B0, [0x0C0FF7E6, # JAL 0x803FDF98 - 0x24840008]) # ADDIU A0, A0, 0x0008 - rom.write_int32s(0xBFDF98, patches.map_id_refresher) - - # Enable swapping characters when loading into a map by holding L. - rom.write_int32(0x97294, 0x803FDFC4) - rom.write_int32(0x19710, 0x080FF80E) # J 0x803FE038 - rom.write_int32s(0xBFDFC4, patches.character_changer) - - # Villa coffin time-of-day hack - rom.write_byte(0xD9D83, 0x74) - rom.write_int32(0xD9D84, 0x080FF14D) # J 0x803FC534 - rom.write_int32s(0xBFC534, patches.coffin_time_checker) - - # Fix both Castle Center elevator bridges for both characters unless enabling only one character's stages. At which - # point one bridge will be always broken and one always repaired instead. - if options.character_stages == CharacterStages.option_reinhardt_only: - rom.write_int32(0x6CEAA0, 0x240B0000) # ADDIU T3, R0, 0x0000 - elif options.character_stages == CharacterStages.option_carrie_only: - rom.write_int32(0x6CEAA0, 0x240B0001) # ADDIU T3, R0, 0x0001 - else: - rom.write_int32(0x6CEAA0, 0x240B0001) # ADDIU T3, R0, 0x0001 - rom.write_int32(0x6CEAA4, 0x240D0001) # ADDIU T5, R0, 0x0001 - - # Were-bull arena flag hack - rom.write_int32(0x6E38F0, 0x0C0FF157) # JAL 0x803FC55C - rom.write_int32s(0xBFC55C, patches.werebull_flag_unsetter) - rom.write_int32(0xA949C, 0x0C0FF380) # JAL 0x803FCE00 - rom.write_int32s(0xBFCE00, patches.werebull_flag_pickup_setter) - - # Enable being able to carry multiple Special jewels, Nitros, and Mandragoras simultaneously - rom.write_int32(0xBF1F4, 0x3C038039) # LUI V1, 0x8039 - # Special1 - rom.write_int32(0xBF210, 0x80659C4B) # LB A1, 0x9C4B (V1) - rom.write_int32(0xBF214, 0x24A50001) # ADDIU A1, A1, 0x0001 - rom.write_int32(0xBF21C, 0xA0659C4B) # SB A1, 0x9C4B (V1) - # Special2 - rom.write_int32(0xBF230, 0x80659C4C) # LB A1, 0x9C4C (V1) - rom.write_int32(0xBF234, 0x24A50001) # ADDIU A1, A1, 0x0001 - rom.write_int32(0xbf23C, 0xA0659C4C) # SB A1, 0x9C4C (V1) - # Magical Nitro - rom.write_int32(0xBF360, 0x10000004) # B 0x8013C184 - rom.write_int32(0xBF378, 0x25E50001) # ADDIU A1, T7, 0x0001 - rom.write_int32(0xBF37C, 0x10000003) # B 0x8013C19C - # Mandragora - rom.write_int32(0xBF3A8, 0x10000004) # B 0x8013C1CC - rom.write_int32(0xBF3C0, 0x25050001) # ADDIU A1, T0, 0x0001 - rom.write_int32(0xBF3C4, 0x10000003) # B 0x8013C1E4 - - # Give PowerUps their Legacy of Darkness behavior when attempting to pick up more than two - rom.write_int16(0xA9624, 0x1000) - rom.write_int32(0xA9730, 0x24090000) # ADDIU T1, R0, 0x0000 - rom.write_int32(0xBF2FC, 0x080FF16D) # J 0x803FC5B4 - rom.write_int32(0xBF300, 0x00000000) # NOP - rom.write_int32s(0xBFC5B4, patches.give_powerup_stopper) - - # Rename the Wooden Stake and Rose to "You are a FOOL!" - rom.write_bytes(0xEFE34, - bytearray([0xFF, 0xFF, 0xA2, 0x0B]) + cv64_string_to_bytearray("You are a FOOL!", append_end=False)) - # Capitalize the "k" in "Archives key" to be consistent with...literally every other key name! - rom.write_byte(0xEFF21, 0x2D) - - # Skip the "There is a white jewel" text so checking one saves the game instantly. - rom.write_int32s(0xEFC72, [0x00020002 for _ in range(37)]) - rom.write_int32(0xA8FC0, 0x24020001) # ADDIU V0, R0, 0x0001 - # Skip the yes/no prompts when activating things. - rom.write_int32s(0xBFDACC, patches.map_text_redirector) - rom.write_int32(0xA9084, 0x24020001) # ADDIU V0, R0, 0x0001 - rom.write_int32(0xBEBE8, 0x0C0FF6B4) # JAL 0x803FDAD0 - # Skip Vincent and Heinrich's mandatory-for-a-check dialogue - rom.write_int32(0xBED9C, 0x0C0FF6DA) # JAL 0x803FDB68 - # Skip the long yes/no prompt in the CC planetarium to set the pieces. - rom.write_int32(0xB5C5DF, 0x24030001) # ADDIU V1, R0, 0x0001 - # Skip the yes/no prompt to activate the CC elevator. - rom.write_int32(0xB5E3FB, 0x24020001) # ADDIU V0, R0, 0x0001 - # Skip the yes/no prompts to set Nitro/Mandragora at both walls. - rom.write_int32(0xB5DF3E, 0x24030001) # ADDIU V1, R0, 0x0001 - - # Custom message if you try checking the downstairs CC crack before removing the seal. - rom.write_bytes(0xBFDBAC, cv64_string_to_bytearray("The Furious Nerd Curse\n" - "prevents you from setting\n" - "anything until the seal\n" - "is removed!", True)) - - rom.write_int32s(0xBFDD20, patches.special_descriptions_redirector) - - # Change the Stage Select menu options - rom.write_int32s(0xADF64, patches.warp_menu_rewrite) - rom.write_int32s(0x10E0C8, patches.warp_pointer_table) + s1s_per_warp = world.s1s_per_warp + + # Write all the new item/loading zone/shop/lighting/music/etc. values. + for offset, data in offset_data.items(): + patch.write_token(APTokenTypes.WRITE, offset, data) + + # Write the new Stage Select menu destinations. for i in range(len(active_warp_list)): if i == 0: - rom.write_byte(warp_map_offsets[i], get_stage_info(active_warp_list[i], "start map id")) - rom.write_byte(warp_map_offsets[i] + 4, get_stage_info(active_warp_list[i], "start spawn id")) + patch.write_token(APTokenTypes.WRITE, + warp_map_offsets[i], get_stage_info(active_warp_list[i], "start map id")) + patch.write_token(APTokenTypes.WRITE, + warp_map_offsets[i] + 4, get_stage_info(active_warp_list[i], "start spawn id")) else: - rom.write_byte(warp_map_offsets[i], get_stage_info(active_warp_list[i], "mid map id")) - rom.write_byte(warp_map_offsets[i] + 4, get_stage_info(active_warp_list[i], "mid spawn id")) - - # Play the "teleportation" sound effect when teleporting - rom.write_int32s(0xAE088, [0x08004FAB, # J 0x80013EAC - 0x2404019E]) # ADDIU A0, R0, 0x019E - - # Change the Stage Select menu's text to reflect its new purpose - rom.write_bytes(0xEFAD0, cv64_string_to_bytearray(f"Where to...?\t{active_warp_list[0]}\t" - f"`{str(s1s_per_warp).zfill(2)} {active_warp_list[1]}\t" - f"`{str(s1s_per_warp * 2).zfill(2)} {active_warp_list[2]}\t" - f"`{str(s1s_per_warp * 3).zfill(2)} {active_warp_list[3]}\t" - f"`{str(s1s_per_warp * 4).zfill(2)} {active_warp_list[4]}\t" - f"`{str(s1s_per_warp * 5).zfill(2)} {active_warp_list[5]}\t" - f"`{str(s1s_per_warp * 6).zfill(2)} {active_warp_list[6]}\t" - f"`{str(s1s_per_warp * 7).zfill(2)} {active_warp_list[7]}")) - - # Lizard-man save proofing - rom.write_int32(0xA99AC, 0x080FF0B8) # J 0x803FC2E0 - rom.write_int32s(0xBFC2E0, patches.boss_save_stopper) - - # Disable or guarantee vampire Vincent's fight - if options.vincent_fight_condition == VincentFightCondition.option_never: - rom.write_int32(0xAACC0, 0x24010001) # ADDIU AT, R0, 0x0001 - rom.write_int32(0xAACE0, 0x24180000) # ADDIU T8, R0, 0x0000 - elif options.vincent_fight_condition == VincentFightCondition.option_always: - rom.write_int32(0xAACE0, 0x24180010) # ADDIU T8, R0, 0x0010 - else: - rom.write_int32(0xAACE0, 0x24180000) # ADDIU T8, R0, 0x0000 - - # Disable or guarantee Renon's fight - rom.write_int32(0xAACB4, 0x080FF1A4) # J 0x803FC690 - if options.renon_fight_condition == RenonFightCondition.option_never: - rom.write_byte(0xB804F0, 0x00) - rom.write_byte(0xB80632, 0x00) - rom.write_byte(0xB807E3, 0x00) - rom.write_byte(0xB80988, 0xB8) - rom.write_byte(0xB816BD, 0xB8) - rom.write_byte(0xB817CF, 0x00) - rom.write_int32s(0xBFC690, patches.renon_cutscene_checker_jr) - elif options.renon_fight_condition == RenonFightCondition.option_always: - rom.write_byte(0xB804F0, 0x0C) - rom.write_byte(0xB80632, 0x0C) - rom.write_byte(0xB807E3, 0x0C) - rom.write_byte(0xB80988, 0xC4) - rom.write_byte(0xB816BD, 0xC4) - rom.write_byte(0xB817CF, 0x0C) - rom.write_int32s(0xBFC690, patches.renon_cutscene_checker_jr) - else: - rom.write_int32s(0xBFC690, patches.renon_cutscene_checker) - - # NOP the Easy Mode check when buying a thing from Renon, so he can be triggered even on this mode. - rom.write_int32(0xBD8B4, 0x00000000) - - # Disable or guarantee the Bad Ending - if options.bad_ending_condition == BadEndingCondition.option_never: - rom.write_int32(0xAEE5C6, 0x3C0A0000) # LUI T2, 0x0000 - elif options.bad_ending_condition == BadEndingCondition.option_always: - rom.write_int32(0xAEE5C6, 0x3C0A0040) # LUI T2, 0x0040 - - # Play Castle Keep's song if teleporting in front of Dracula's door outside the escape sequence - rom.write_int32(0x6E937C, 0x080FF12E) # J 0x803FC4B8 - rom.write_int32s(0xBFC4B8, patches.ck_door_music_player) - - # Increase item capacity to 100 if "Increase Item Limit" is turned on - if options.increase_item_limit: - rom.write_byte(0xBF30B, 0x63) # Most items - rom.write_byte(0xBF3F7, 0x63) # Sun/Moon cards - rom.write_byte(0xBF353, 0x64) # Keys (increase regardless) - - # Change the item healing values if "Nerf Healing" is turned on - if options.nerf_healing_items: - rom.write_byte(0xB56371, 0x50) # Healing kit (100 -> 80) - rom.write_byte(0xB56374, 0x32) # Roast beef ( 80 -> 50) - rom.write_byte(0xB56377, 0x19) # Roast chicken ( 50 -> 25) - - # Disable loading zone healing if turned off - if not options.loading_zone_heals: - rom.write_byte(0xD99A5, 0x00) # Skip all loading zone checks - rom.write_byte(0xA9DFFB, 0x40) # Disable free heal from King Skeleton by reading the unused magic meter value - - # Disable spinning on the Special1 and 2 pickup models so colorblind people can more easily identify them - rom.write_byte(0xEE4F5, 0x00) # Special1 - rom.write_byte(0xEE505, 0x00) # Special2 - # Make the Special2 the same size as a Red jewel(L) to further distinguish them - rom.write_int32(0xEE4FC, 0x3FA66666) - - # Prevent the vanilla Magical Nitro transport's "can explode" flag from setting - rom.write_int32(0xB5D7AA, 0x00000000) # NOP - - # Ensure the vampire Nitro check will always pass, so they'll never not spawn and crash the Villa cutscenes - rom.write_byte(0xA6253D, 0x03) - - # Enable the Game Over's "Continue" menu starting the cursor on whichever checkpoint is most recent - rom.write_int32(0xB4DDC, 0x0C060D58) # JAL 0x80183560 - rom.write_int32s(0x106750, patches.continue_cursor_start_checker) - rom.write_int32(0x1C444, 0x080FF08A) # J 0x803FC228 - rom.write_int32(0x1C2A0, 0x080FF08A) # J 0x803FC228 - rom.write_int32s(0xBFC228, patches.savepoint_cursor_updater) - rom.write_int32(0x1C2D0, 0x080FF094) # J 0x803FC250 - rom.write_int32s(0xBFC250, patches.stage_start_cursor_updater) - rom.write_byte(0xB585C8, 0xFF) - - # Make the Special1 and 2 play sounds when you reach milestones with them. - rom.write_int32s(0xBFDA50, patches.special_sound_notifs) - rom.write_int32(0xBF240, 0x080FF694) # J 0x803FDA50 - rom.write_int32(0xBF220, 0x080FF69E) # J 0x803FDA78 - - # Add data for White Jewel #22 (the new Duel Tower savepoint) at the end of the White Jewel ID data list - rom.write_int16s(0x104AC8, [0x0000, 0x0006, - 0x0013, 0x0015]) - - # Take the contract in Waterway off of its 00400000 bitflag. - rom.write_byte(0x87E3DA, 0x00) - - # Spawn coordinates list extension - rom.write_int32(0xD5BF4, 0x080FF103) # J 0x803FC40C - rom.write_int32s(0xBFC40C, patches.spawn_coordinates_extension) - rom.write_int32s(0x108A5E, patches.waterway_end_coordinates) - - # Change the File Select stage numbers to match the new stage order. Also fix a vanilla issue wherein saving in a - # character-exclusive stage as the other character would incorrectly display the name of that character's equivalent - # stage on the save file instead of the one they're actually in. - rom.write_byte(0xC9FE3, 0xD4) - rom.write_byte(0xCA055, 0x08) - rom.write_byte(0xCA066, 0x40) - rom.write_int32(0xCA068, 0x860C17D0) # LH T4, 0x17D0 (S0) - rom.write_byte(0xCA06D, 0x08) - rom.write_byte(0x104A31, 0x01) - rom.write_byte(0x104A39, 0x01) - rom.write_byte(0x104A89, 0x01) - rom.write_byte(0x104A91, 0x01) - rom.write_byte(0x104A99, 0x01) - rom.write_byte(0x104AA1, 0x01) - - for stage in active_stage_exits: + patch.write_token(APTokenTypes.WRITE, + warp_map_offsets[i], get_stage_info(active_warp_list[i], "mid map id")) + patch.write_token(APTokenTypes.WRITE, + warp_map_offsets[i] + 4, get_stage_info(active_warp_list[i], "mid spawn id")) + + # Change the Stage Select menu's text to reflect its new purpose. + patch.write_token(APTokenTypes.WRITE, 0xEFAD0, bytes( + cv64_string_to_bytearray(f"Where to...?\t{active_warp_list[0]}\t" + f"`{str(s1s_per_warp).zfill(2)} {active_warp_list[1]}\t" + f"`{str(s1s_per_warp * 2).zfill(2)} {active_warp_list[2]}\t" + f"`{str(s1s_per_warp * 3).zfill(2)} {active_warp_list[3]}\t" + f"`{str(s1s_per_warp * 4).zfill(2)} {active_warp_list[4]}\t" + f"`{str(s1s_per_warp * 5).zfill(2)} {active_warp_list[5]}\t" + f"`{str(s1s_per_warp * 6).zfill(2)} {active_warp_list[6]}\t" + f"`{str(s1s_per_warp * 7).zfill(2)} {active_warp_list[7]}"))) + + # Write the new File Select stage numbers. + for stage in world.active_stage_exits: for offset in get_stage_info(stage, "save number offsets"): - rom.write_byte(offset, active_stage_exits[stage]["position"]) - - # CC top elevator switch check - rom.write_int32(0x6CF0A0, 0x0C0FF0B0) # JAL 0x803FC2C0 - rom.write_int32s(0xBFC2C0, patches.elevator_flag_checker) - - # Disable time restrictions - if options.disable_time_restrictions: - # Fountain - rom.write_int32(0x6C2340, 0x00000000) # NOP - rom.write_int32(0x6C257C, 0x10000023) # B [forward 0x23] - # Rosa - rom.write_byte(0xEEAAB, 0x00) - rom.write_byte(0xEEAAD, 0x18) - # Moon doors - rom.write_int32(0xDC3E0, 0x00000000) # NOP - rom.write_int32(0xDC3E8, 0x00000000) # NOP - # Sun doors - rom.write_int32(0xDC410, 0x00000000) # NOP - rom.write_int32(0xDC418, 0x00000000) # NOP - - # Custom data-loading code - rom.write_int32(0x6B5028, 0x08060D70) # J 0x801835D0 - rom.write_int32s(0x1067B0, patches.custom_code_loader) - - # Custom remote item rewarding and DeathLink receiving code - rom.write_int32(0x19B98, 0x080FF000) # J 0x803FC000 - rom.write_int32s(0xBFC000, patches.remote_item_giver) - rom.write_int32s(0xBFE190, patches.subweapon_surface_checker) - - # Make received DeathLinks blow you to smithereens instead of kill you normally. - if options.death_link == DeathLink.option_explosive: - rom.write_int32(0x27A70, 0x10000008) # B [forward 0x08] - rom.write_int32s(0xBFC0D0, patches.deathlink_nitro_edition) - - # Set the DeathLink ROM flag if it's on at all. - if options.death_link != DeathLink.option_off: - rom.write_byte(0xBFBFDE, 0x01) - - # DeathLink counter decrementer code - rom.write_int32(0x1C340, 0x080FF8F0) # J 0x803FE3C0 - rom.write_int32s(0xBFE3C0, patches.deathlink_counter_decrementer) - rom.write_int32(0x25B6C, 0x0080FF052) # J 0x803FC148 - rom.write_int32s(0xBFC148, patches.nitro_fall_killer) - - # Death flag un-setter on "Beginning of stage" state overwrite code - rom.write_int32(0x1C2B0, 0x080FF047) # J 0x803FC11C - rom.write_int32s(0xBFC11C, patches.death_flag_unsetter) - - # Warp menu-opening code - rom.write_int32(0xB9BA8, 0x080FF099) # J 0x803FC264 - rom.write_int32s(0xBFC264, patches.warp_menu_opener) - - # NPC item textbox hack - rom.write_int32(0xBF1DC, 0x080FF904) # J 0x803FE410 - rom.write_int32(0xBF1E0, 0x27BDFFE0) # ADDIU SP, SP, -0x20 - rom.write_int32s(0xBFE410, patches.npc_item_hack) - - # Sub-weapon check function hook - rom.write_int32(0xBF32C, 0x00000000) # NOP - rom.write_int32(0xBF330, 0x080FF05E) # J 0x803FC178 - rom.write_int32s(0xBFC178, patches.give_subweapon_stopper) - - # Warp menu Special1 restriction - rom.write_int32(0xADD68, 0x0C04AB12) # JAL 0x8012AC48 - rom.write_int32s(0xADE28, patches.stage_select_overwrite) - rom.write_byte(0xADE47, s1s_per_warp) - - # Dracula's door text pointer hijack - rom.write_int32(0xD69F0, 0x080FF141) # J 0x803FC504 - rom.write_int32s(0xBFC504, patches.dracula_door_text_redirector) - - # Dracula's chamber condition - rom.write_int32(0xE2FDC, 0x0804AB25) # J 0x8012AC78 - rom.write_int32s(0xADE84, patches.special_goal_checker) - rom.write_bytes(0xBFCC48, [0xA0, 0x00, 0xFF, 0xFF, 0xA0, 0x01, 0xFF, 0xFF, 0xA0, 0x02, 0xFF, 0xFF, 0xA0, 0x03, 0xFF, - 0xFF, 0xA0, 0x04, 0xFF, 0xFF, 0xA0, 0x05, 0xFF, 0xFF, 0xA0, 0x06, 0xFF, 0xFF, 0xA0, 0x07, - 0xFF, 0xFF, 0xA0, 0x08, 0xFF, 0xFF, 0xA0, 0x09]) - if options.draculas_condition == DraculasCondition.option_crystal: - rom.write_int32(0x6C8A54, 0x0C0FF0C1) # JAL 0x803FC304 - rom.write_int32s(0xBFC304, patches.crystal_special2_giver) - rom.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" - f"You'll need the power\n" - f"of the basement crystal\n" - f"to undo the seal.", True)) - special2_name = "Crystal " - special2_text = "The crystal is on!\n" \ - "Time to teach the old man\n" \ - "a lesson!" - elif options.draculas_condition == DraculasCondition.option_bosses: - rom.write_int32(0xBBD50, 0x080FF18C) # J 0x803FC630 - rom.write_int32s(0xBFC630, patches.boss_special2_giver) - rom.write_int32s(0xBFC55C, patches.werebull_flag_unsetter_special2_electric_boogaloo) - rom.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" - f"You'll need to defeat\n" - f"{required_s2s} powerful monsters\n" - f"to undo the seal.", True)) - special2_name = "Trophy " - special2_text = f"Proof you killed a powerful\n" \ - f"Night Creature. Earn {required_s2s}/{total_s2s}\n" \ - f"to battle Dracula." - elif options.draculas_condition == DraculasCondition.option_specials: - special2_name = "Special2" - rom.write_bytes(0xBFCC6E, cv64_string_to_bytearray(f"It won't budge!\n" - f"You'll need to find\n" - f"{required_s2s} Special2 jewels\n" - f"to undo the seal.", True)) - special2_text = f"Need {required_s2s}/{total_s2s} to kill Dracula.\n" \ - f"Looking closely, you see...\n" \ - f"a piece of him within?" - else: - rom.write_byte(0xADE8F, 0x00) - special2_name = "Special2" - special2_text = "If you're reading this,\n" \ - "how did you get a Special2!?" - rom.write_byte(0xADE8F, required_s2s) - # Change the Special2 name depending on the setting. - rom.write_bytes(0xEFD4E, cv64_string_to_bytearray(special2_name)) - # Change the Special1 and 2 menu descriptions to tell you how many you need to unlock a warp and fight Dracula - # respectively. - special_text_bytes = cv64_string_to_bytearray(f"{s1s_per_warp} per warp unlock.\n" - f"{options.total_special1s.value} exist in total.\n" - f"Z + R + START to warp.") + cv64_string_to_bytearray(special2_text) - rom.write_bytes(0xBFE53C, special_text_bytes) - - # On-the-fly TLB script modifier - rom.write_int32s(0xBFC338, patches.double_component_checker) - rom.write_int32s(0xBFC3D4, patches.downstairs_seal_checker) - rom.write_int32s(0xBFE074, patches.mandragora_with_nitro_setter) - rom.write_int32s(0xBFC700, patches.overlay_modifiers) - - # On-the-fly actor data modifier hook - rom.write_int32(0xEAB04, 0x080FF21E) # J 0x803FC878 - rom.write_int32s(0xBFC870, patches.map_data_modifiers) - - # Fix to make flags apply to freestanding invisible items properly - rom.write_int32(0xA84F8, 0x90CC0039) # LBU T4, 0x0039 (A2) - - # Fix locked doors to check the key counters instead of their vanilla key locations' bitflags - # Pickup flag check modifications: - rom.write_int32(0x10B2D8, 0x00000002) # Left Tower Door - rom.write_int32(0x10B2F0, 0x00000003) # Storeroom Door - rom.write_int32(0x10B2FC, 0x00000001) # Archives Door - rom.write_int32(0x10B314, 0x00000004) # Maze Gate - rom.write_int32(0x10B350, 0x00000005) # Copper Door - rom.write_int32(0x10B3A4, 0x00000006) # Torture Chamber Door - rom.write_int32(0x10B3B0, 0x00000007) # ToE Gate - rom.write_int32(0x10B3BC, 0x00000008) # Science Door1 - rom.write_int32(0x10B3C8, 0x00000009) # Science Door2 - rom.write_int32(0x10B3D4, 0x0000000A) # Science Door3 - rom.write_int32(0x6F0094, 0x0000000B) # CT Door 1 - rom.write_int32(0x6F00A4, 0x0000000C) # CT Door 2 - rom.write_int32(0x6F00B4, 0x0000000D) # CT Door 3 - # Item counter decrement check modifications: - rom.write_int32(0xEDA84, 0x00000001) # Archives Door - rom.write_int32(0xEDA8C, 0x00000002) # Left Tower Door - rom.write_int32(0xEDA94, 0x00000003) # Storeroom Door - rom.write_int32(0xEDA9C, 0x00000004) # Maze Gate - rom.write_int32(0xEDAA4, 0x00000005) # Copper Door - rom.write_int32(0xEDAAC, 0x00000006) # Torture Chamber Door - rom.write_int32(0xEDAB4, 0x00000007) # ToE Gate - rom.write_int32(0xEDABC, 0x00000008) # Science Door1 - rom.write_int32(0xEDAC4, 0x00000009) # Science Door2 - rom.write_int32(0xEDACC, 0x0000000A) # Science Door3 - rom.write_int32(0xEDAD4, 0x0000000B) # CT Door 1 - rom.write_int32(0xEDADC, 0x0000000C) # CT Door 2 - rom.write_int32(0xEDAE4, 0x0000000D) # CT Door 3 - - # Fix ToE gate's "unlocked" flag in the locked door flags table - rom.write_int16(0x10B3B6, 0x0001) - - rom.write_int32(0x10AB2C, 0x8015FBD4) # Maze Gates' check code pointer adjustments - rom.write_int32(0x10AB40, 0x8015FBD4) - rom.write_int32s(0x10AB50, [0x0D0C0000, - 0x8015FBD4]) - rom.write_int32s(0x10AB64, [0x0D0C0000, - 0x8015FBD4]) - rom.write_int32s(0xE2E14, patches.normal_door_hook) - rom.write_int32s(0xBFC5D0, patches.normal_door_code) - rom.write_int32s(0x6EF298, patches.ct_door_hook) - rom.write_int32s(0xBFC608, patches.ct_door_code) - # Fix key counter not decrementing if 2 or above - rom.write_int32(0xAA0E0, 0x24020000) # ADDIU V0, R0, 0x0000 - - # Make the Easy-only candle drops in Room of Clocks appear on any difficulty - rom.write_byte(0x9B518F, 0x01) - - # Slightly move some once-invisible freestanding items to be more visible - if options.invisible_items == InvisibleItems.option_reveal_all: - rom.write_byte(0x7C7F95, 0xEF) # Forest dirge maiden statue - rom.write_byte(0x7C7FA8, 0xAB) # Forest werewolf statue - rom.write_byte(0x8099C4, 0x8C) # Villa courtyard tombstone - rom.write_byte(0x83A626, 0xC2) # Villa living room painting - # rom.write_byte(0x83A62F, 0x64) # Villa Mary's room table - rom.write_byte(0xBFCB97, 0xF5) # CC torture instrument rack - rom.write_byte(0x8C44D5, 0x22) # CC red carpet hallway knight - rom.write_byte(0x8DF57C, 0xF1) # CC cracked wall hallway flamethrower - rom.write_byte(0x90FCD6, 0xA5) # CC nitro hallway flamethrower - rom.write_byte(0x90FB9F, 0x9A) # CC invention room round machine - rom.write_byte(0x90FBAF, 0x03) # CC invention room giant famicart - rom.write_byte(0x90FE54, 0x97) # CC staircase knight (x) - rom.write_byte(0x90FE58, 0xFB) # CC staircase knight (z) - - # Change bitflag on item in upper coffin in Forest final switch gate tomb to one that's not used by something else - rom.write_int32(0x10C77C, 0x00000002) - - # Make the torch directly behind Dracula's chamber that normally doesn't set a flag set bitflag 0x08 in 0x80389BFA - rom.write_byte(0x10CE9F, 0x01) - - # Change the CC post-Behemoth boss depending on the option for Post-Behemoth Boss - if options.post_behemoth_boss == PostBehemothBoss.option_inverted: - rom.write_byte(0xEEDAD, 0x02) - rom.write_byte(0xEEDD9, 0x01) - elif options.post_behemoth_boss == PostBehemothBoss.option_always_rosa: - rom.write_byte(0xEEDAD, 0x00) - rom.write_byte(0xEEDD9, 0x03) - # Put both on the same flag so changing character won't trigger a rematch with the same boss. - rom.write_byte(0xEED8B, 0x40) - elif options.post_behemoth_boss == PostBehemothBoss.option_always_camilla: - rom.write_byte(0xEEDAD, 0x03) - rom.write_byte(0xEEDD9, 0x00) - rom.write_byte(0xEED8B, 0x40) - - # Change the RoC boss depending on the option for Room of Clocks Boss - if options.room_of_clocks_boss == RoomOfClocksBoss.option_inverted: - rom.write_byte(0x109FB3, 0x56) - rom.write_byte(0x109FBF, 0x44) - rom.write_byte(0xD9D44, 0x14) - rom.write_byte(0xD9D4C, 0x14) - elif options.room_of_clocks_boss == RoomOfClocksBoss.option_always_death: - rom.write_byte(0x109FBF, 0x44) - rom.write_byte(0xD9D45, 0x00) - # Put both on the same flag so changing character won't trigger a rematch with the same boss. - rom.write_byte(0x109FB7, 0x90) - rom.write_byte(0x109FC3, 0x90) - elif options.room_of_clocks_boss == RoomOfClocksBoss.option_always_actrise: - rom.write_byte(0x109FB3, 0x56) - rom.write_int32(0xD9D44, 0x00000000) - rom.write_byte(0xD9D4D, 0x00) - rom.write_byte(0x109FB7, 0x90) - rom.write_byte(0x109FC3, 0x90) - - # Un-nerf Actrise when playing as Reinhardt. - # This is likely a leftover TGS demo feature in which players could battle Actrise as Reinhardt. - rom.write_int32(0xB318B4, 0x240E0001) # ADDIU T6, R0, 0x0001 - - # Tunnel gondola skip - if options.skip_gondolas: - rom.write_int32(0x6C5F58, 0x080FF7D0) # J 0x803FDF40 - rom.write_int32s(0xBFDF40, patches.gondola_skipper) - # New gondola transfer point candle coordinates - rom.write_byte(0xBFC9A3, 0x04) - rom.write_bytes(0x86D824, [0x27, 0x01, 0x10, 0xF7, 0xA0]) - - # Waterway brick platforms skip - if options.skip_waterway_blocks: - rom.write_int32(0x6C7E2C, 0x00000000) # NOP - - # Ambience silencing fix - rom.write_int32(0xD9270, 0x080FF840) # J 0x803FE100 - rom.write_int32s(0xBFE100, patches.ambience_silencer) - # Fix for the door sliding sound playing infinitely if leaving the fan meeting room before the door closes entirely. - # Hooking this in the ambience silencer code does nothing for some reason. - rom.write_int32s(0xAE10C, [0x08004FAB, # J 0x80013EAC - 0x3404829B]) # ORI A0, R0, 0x829B - rom.write_int32s(0xD9E8C, [0x08004FAB, # J 0x80013EAC - 0x3404829B]) # ORI A0, R0, 0x829B - # Fan meeting room ambience fix - rom.write_int32(0x109964, 0x803FE13C) - - # Make the Villa coffin cutscene skippable - rom.write_int32(0xAA530, 0x080FF880) # J 0x803FE200 - rom.write_int32s(0xBFE200, patches.coffin_cutscene_skipper) - - # Increase shimmy speed - if options.increase_shimmy_speed: - rom.write_byte(0xA4241, 0x5A) - - # Disable landing fall damage - if options.fall_guard: - rom.write_byte(0x27B23, 0x00) - - # Enable the unused film reel effect on all cutscenes - if options.cinematic_experience: - rom.write_int32(0xAA33C, 0x240A0001) # ADDIU T2, R0, 0x0001 - rom.write_byte(0xAA34B, 0x0C) - rom.write_int32(0xAA4C4, 0x24090001) # ADDIU T1, R0, 0x0001 - - # Permanent PowerUp stuff - if options.permanent_powerups: - # Make receiving PowerUps increase the unused menu PowerUp counter instead of the one outside the save struct - rom.write_int32(0xBF2EC, 0x806B619B) # LB T3, 0x619B (V1) - rom.write_int32(0xBFC5BC, 0xA06C619B) # SB T4, 0x619B (V1) - # Make Reinhardt's whip check the menu PowerUp counter - rom.write_int32(0x69FA08, 0x80CC619B) # LB T4, 0x619B (A2) - rom.write_int32(0x69FBFC, 0x80C3619B) # LB V1, 0x619B (A2) - rom.write_int32(0x69FFE0, 0x818C9C53) # LB T4, 0x9C53 (T4) - # Make Carrie's orb check the menu PowerUp counter - rom.write_int32(0x6AC86C, 0x8105619B) # LB A1, 0x619B (T0) - rom.write_int32(0x6AC950, 0x8105619B) # LB A1, 0x619B (T0) - rom.write_int32(0x6AC99C, 0x810E619B) # LB T6, 0x619B (T0) - rom.write_int32(0x5AFA0, 0x80639C53) # LB V1, 0x9C53 (V1) - rom.write_int32(0x5B0A0, 0x81089C53) # LB T0, 0x9C53 (T0) - rom.write_byte(0x391C7, 0x00) # Prevent PowerUps from dropping from regular enemies - rom.write_byte(0xEDEDF, 0x03) # Make any vanishing PowerUps that do show up L jewels instead - # Rename the PowerUp to "PermaUp" - rom.write_bytes(0xEFDEE, cv64_string_to_bytearray("PermaUp")) - # Replace the PowerUp in the Forest Special1 Bridge 3HB rock with an L jewel if 3HBs aren't randomized - if not options.multi_hit_breakables: - rom.write_byte(0x10C7A1, 0x03) - # Change the appearance of the Pot-Pourri to that of a larger PowerUp regardless of the above setting, so other - # game PermaUps are distinguishable. - rom.write_int32s(0xEE558, [0x06005F08, 0x3FB00000, 0xFFFFFF00]) - - # Write the randomized (or disabled) music ID list and its associated code - if options.background_music: - rom.write_int32(0x14588, 0x08060D60) # J 0x80183580 - rom.write_int32(0x14590, 0x00000000) # NOP - rom.write_int32s(0x106770, patches.music_modifier) - rom.write_int32(0x15780, 0x0C0FF36E) # JAL 0x803FCDB8 - rom.write_int32s(0xBFCDB8, patches.music_comparer_modifier) - - # Enable storing item flags anywhere and changing the item model/visibility on any item instance. - rom.write_int32s(0xA857C, [0x080FF38F, # J 0x803FCE3C - 0x94D90038]) # LHU T9, 0x0038 (A2) - rom.write_int32s(0xBFCE3C, patches.item_customizer) - rom.write_int32s(0xA86A0, [0x0C0FF3AF, # JAL 0x803FCEBC - 0x95C40002]) # LHU A0, 0x0002 (T6) - rom.write_int32s(0xBFCEBC, patches.item_appearance_switcher) - rom.write_int32s(0xA8728, [0x0C0FF3B8, # JAL 0x803FCEE4 - 0x01396021]) # ADDU T4, T1, T9 - rom.write_int32s(0xBFCEE4, patches.item_model_visibility_switcher) - rom.write_int32s(0xA8A04, [0x0C0FF3C2, # JAL 0x803FCF08 - 0x018B6021]) # ADDU T4, T4, T3 - rom.write_int32s(0xBFCF08, patches.item_shine_visibility_switcher) - - # Make Axes and Crosses in AP Locations drop to their correct height, and make items with changed appearances spin - # their correct speed. - rom.write_int32s(0xE649C, [0x0C0FFA03, # JAL 0x803FE80C - 0x956C0002]) # LHU T4, 0x0002 (T3) - rom.write_int32s(0xA8B08, [0x080FFA0C, # J 0x803FE830 - 0x960A0038]) # LHU T2, 0x0038 (S0) - rom.write_int32s(0xE8584, [0x0C0FFA21, # JAL 0x803FE884 - 0x95D80000]) # LHU T8, 0x0000 (T6) - rom.write_int32s(0xE7AF0, [0x0C0FFA2A, # JAL 0x803FE8A8 - 0x958D0000]) # LHU T5, 0x0000 (T4) - rom.write_int32s(0xBFE7DC, patches.item_drop_spin_corrector) - - # Disable the 3HBs checking and setting flags when breaking them and enable their individual items checking and - # setting flags instead. - if options.multi_hit_breakables: - rom.write_int32(0xE87F8, 0x00000000) # NOP - rom.write_int16(0xE836C, 0x1000) - rom.write_int32(0xE8B40, 0x0C0FF3CD) # JAL 0x803FCF34 - rom.write_int32s(0xBFCF34, patches.three_hit_item_flags_setter) - # Villa foyer chandelier-specific functions (yeah, IDK why KCEK made different functions for this one) - rom.write_int32(0xE7D54, 0x00000000) # NOP - rom.write_int16(0xE7908, 0x1000) - rom.write_byte(0xE7A5C, 0x10) - rom.write_int32(0xE7F08, 0x0C0FF3DF) # JAL 0x803FCF7C - rom.write_int32s(0xBFCF7C, patches.chandelier_item_flags_setter) - - # New flag values to put in each 3HB vanilla flag's spot - rom.write_int32(0x10C7C8, 0x8000FF48) # FoS dirge maiden rock - rom.write_int32(0x10C7B0, 0x0200FF48) # FoS S1 bridge rock - rom.write_int32(0x10C86C, 0x0010FF48) # CW upper rampart save nub - rom.write_int32(0x10C878, 0x4000FF49) # CW Dracula switch slab - rom.write_int32(0x10CAD8, 0x0100FF49) # Tunnel twin arrows slab - rom.write_int32(0x10CAE4, 0x0004FF49) # Tunnel lonesome bucket pit rock - rom.write_int32(0x10CB54, 0x4000FF4A) # UW poison parkour ledge - rom.write_int32(0x10CB60, 0x0080FF4A) # UW skeleton crusher ledge - rom.write_int32(0x10CBF0, 0x0008FF4A) # CC Behemoth crate - rom.write_int32(0x10CC2C, 0x2000FF4B) # CC elevator pedestal - rom.write_int32(0x10CC70, 0x0200FF4B) # CC lizard locker slab - rom.write_int32(0x10CD88, 0x0010FF4B) # ToE pre-midsavepoint platforms ledge - rom.write_int32(0x10CE6C, 0x4000FF4C) # ToSci invisible bridge crate - rom.write_int32(0x10CF20, 0x0080FF4C) # CT inverted battery slab - rom.write_int32(0x10CF2C, 0x0008FF4C) # CT inverted door slab - rom.write_int32(0x10CF38, 0x8000FF4D) # CT final room door slab - rom.write_int32(0x10CF44, 0x1000FF4D) # CT Renon slab - rom.write_int32(0x10C908, 0x0008FF4D) # Villa foyer chandelier - rom.write_byte(0x10CF37, 0x04) # pointer for CT final room door slab item data - - # Once-per-frame gameplay checks - rom.write_int32(0x6C848, 0x080FF40D) # J 0x803FD034 - rom.write_int32(0xBFD058, 0x0801AEB5) # J 0x8006BAD4 - - # Everything related to dropping the previous sub-weapon - if options.drop_previous_sub_weapon: - rom.write_int32(0xBFD034, 0x080FF3FF) # J 0x803FCFFC - rom.write_int32(0xBFC190, 0x080FF3F2) # J 0x803FCFC8 - rom.write_int32s(0xBFCFC4, patches.prev_subweapon_spawn_checker) - rom.write_int32s(0xBFCFFC, patches.prev_subweapon_fall_checker) - rom.write_int32s(0xBFD060, patches.prev_subweapon_dropper) - - # Everything related to the Countdown counter - if options.countdown: - rom.write_int32(0xBFD03C, 0x080FF9DC) # J 0x803FE770 - rom.write_int32(0xD5D48, 0x080FF4EC) # J 0x803FD3B0 - rom.write_int32s(0xBFD3B0, patches.countdown_number_displayer) - rom.write_int32s(0xBFD6DC, patches.countdown_number_manager) - rom.write_int32s(0xBFE770, patches.countdown_demo_hider) - rom.write_int32(0xBFCE2C, 0x080FF5D2) # J 0x803FD748 - rom.write_int32s(0xBB168, [0x080FF5F4, # J 0x803FD7D0 - 0x8E020028]) # LW V0, 0x0028 (S0) - rom.write_int32s(0xBB1D0, [0x080FF5FB, # J 0x803FD7EC - 0x8E020028]) # LW V0, 0x0028 (S0) - rom.write_int32(0xBC4A0, 0x080FF5E6) # J 0x803FD798 - rom.write_int32(0xBC4C4, 0x080FF5E6) # J 0x803FD798 - rom.write_int32(0x19844, 0x080FF602) # J 0x803FD808 - # If the option is set to "all locations", count it down no matter what the item is. - if options.countdown == Countdown.option_all_locations: - rom.write_int32s(0xBFD71C, [0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, - 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101]) - else: - # If it's majors, then insert this last minute check I threw together for the weird edge case of a CV64 ice - # trap for another CV64 player taking the form of a major. - rom.write_int32s(0xBFD788, [0x080FF717, # J 0x803FDC5C - 0x2529FFFF]) # ADDIU T1, T1, 0xFFFF - rom.write_int32s(0xBFDC5C, patches.countdown_extra_safety_check) - rom.write_int32(0xA9ECC, 0x00000000) # NOP the pointless overwrite of the item actor appearance custom value. - - # Ice Trap stuff - rom.write_int32(0x697C60, 0x080FF06B) # J 0x803FC18C - rom.write_int32(0x6A5160, 0x080FF06B) # J 0x803FC18C - rom.write_int32s(0xBFC1AC, patches.ice_trap_initializer) - rom.write_int32s(0xBFE700, patches.the_deep_freezer) - rom.write_int32s(0xB2F354, [0x3739E4C0, # ORI T9, T9, 0xE4C0 - 0x03200008, # JR T9 - 0x00000000]) # NOP - rom.write_int32s(0xBFE4C0, patches.freeze_verifier) - - # Initial Countdown numbers - rom.write_int32(0xAD6A8, 0x080FF60A) # J 0x803FD828 - rom.write_int32s(0xBFD828, patches.new_game_extras) - - # Everything related to shopsanity - if options.shopsanity: - rom.write_byte(0xBFBFDF, 0x01) - rom.write_bytes(0x103868, cv64_string_to_bytearray("Not obtained. ")) - rom.write_int32s(0xBFD8D0, patches.shopsanity_stuff) - rom.write_int32(0xBD828, 0x0C0FF643) # JAL 0x803FD90C - rom.write_int32(0xBD5B8, 0x0C0FF651) # JAL 0x803FD944 - rom.write_int32(0xB0610, 0x0C0FF665) # JAL 0x803FD994 - rom.write_int32s(0xBD24C, [0x0C0FF677, # J 0x803FD9DC - 0x00000000]) # NOP - rom.write_int32(0xBD618, 0x0C0FF684) # JAL 0x803FDA10 - - shopsanity_name_text = [] - shopsanity_desc_text = [] + patch.write_token(APTokenTypes.WRITE, offset, bytes([world.active_stage_exits[stage]["position"]])) + + # Write all the shop text. + if world.options.shopsanity: + patch.write_token(APTokenTypes.WRITE, 0x103868, bytes(cv64_string_to_bytearray("Not obtained. "))) + + shopsanity_name_text = bytearray(0) + shopsanity_desc_text = bytearray(0) for i in range(len(shop_name_list)): shopsanity_name_text += bytearray([0xA0, i]) + shop_colors_list[i] + \ cv64_string_to_bytearray(cv64_text_truncate(shop_name_list[i], 74)) - shopsanity_desc_text += [0xA0, i] + shopsanity_desc_text += bytearray([0xA0, i]) if shop_desc_list[i][1] is not None: shopsanity_desc_text += cv64_string_to_bytearray("For " + shop_desc_list[i][1] + ".\n", append_end=False) shopsanity_desc_text += cv64_string_to_bytearray(renon_item_dialogue[shop_desc_list[i][0]]) - rom.write_bytes(0x1AD00, shopsanity_name_text) - rom.write_bytes(0x1A800, shopsanity_desc_text) - - # Panther Dash running - if options.panther_dash: - rom.write_int32(0x69C8C4, 0x0C0FF77E) # JAL 0x803FDDF8 - rom.write_int32(0x6AA228, 0x0C0FF77E) # JAL 0x803FDDF8 - rom.write_int32s(0x69C86C, [0x0C0FF78E, # JAL 0x803FDE38 - 0x3C01803E]) # LUI AT, 0x803E - rom.write_int32s(0x6AA1D0, [0x0C0FF78E, # JAL 0x803FDE38 - 0x3C01803E]) # LUI AT, 0x803E - rom.write_int32(0x69D37C, 0x0C0FF79E) # JAL 0x803FDE78 - rom.write_int32(0x6AACE0, 0x0C0FF79E) # JAL 0x803FDE78 - rom.write_int32s(0xBFDDF8, patches.panther_dash) - # Jump prevention - if options.panther_dash == PantherDash.option_jumpless: - rom.write_int32(0xBFDE2C, 0x080FF7BB) # J 0x803FDEEC - rom.write_int32(0xBFD044, 0x080FF7B1) # J 0x803FDEC4 - rom.write_int32s(0x69B630, [0x0C0FF7C6, # JAL 0x803FDF18 - 0x8CCD0000]) # LW T5, 0x0000 (A2) - rom.write_int32s(0x6A8EC0, [0x0C0FF7C6, # JAL 0x803FDF18 - 0x8CCC0000]) # LW T4, 0x0000 (A2) - # Fun fact: KCEK put separate code to handle coyote time jumping - rom.write_int32s(0x69910C, [0x0C0FF7C6, # JAL 0x803FDF18 - 0x8C4E0000]) # LW T6, 0x0000 (V0) - rom.write_int32s(0x6A6718, [0x0C0FF7C6, # JAL 0x803FDF18 - 0x8C4E0000]) # LW T6, 0x0000 (V0) - rom.write_int32s(0xBFDEC4, patches.panther_jump_preventer) - - # Everything related to Big Toss. - if options.big_toss: - rom.write_int32s(0x27E90, [0x0C0FFA38, # JAL 0x803FE8E0 - 0xAFB80074]) # SW T8, 0x0074 (SP) - rom.write_int32(0x26F54, 0x0C0FFA4D) # JAL 0x803FE934 - rom.write_int32s(0xBFE8E0, patches.big_tosser) - - # Write all the new randomized bytes. - for offset, item_id in offset_data.items(): - if item_id <= 0xFF: - rom.write_byte(offset, item_id) - elif item_id <= 0xFFFF: - rom.write_int16(offset, item_id) - elif item_id <= 0xFFFFFF: - rom.write_int24(offset, item_id) - else: - rom.write_int32(offset, item_id) + patch.write_token(APTokenTypes.WRITE, 0x1AD00, bytes(shopsanity_name_text)) + patch.write_token(APTokenTypes.WRITE, 0x1A800, bytes(shopsanity_desc_text)) - # Write the secondary name the client will use to distinguish a vanilla ROM from an AP one. - rom.write_bytes(0xBFBFD0, "ARCHIPELAGO1".encode("utf-8")) - # Write the slot authentication - rom.write_bytes(0xBFBFE0, world.auth) - - # Write the specified window colors - rom.write_byte(0xAEC23, options.window_color_r.value << 4) - rom.write_byte(0xAEC33, options.window_color_g.value << 4) - rom.write_byte(0xAEC47, options.window_color_b.value << 4) - rom.write_byte(0xAEC43, options.window_color_a.value << 4) - - # Write the item/player names for other game items + # Write the item/player names for other game items. for loc in active_locations: - if loc.address is None or get_location_info(loc.name, "type") == "shop" or loc.item.player == player: + if loc.address is None or get_location_info(loc.name, "type") == "shop" or loc.item.player == world.player: continue if len(loc.item.name) > 67: item_name = loc.item.name[0x00:0x68] else: item_name = loc.item.name inject_address = 0xBB7164 + (256 * (loc.address & 0xFFF)) - wrapped_name, num_lines = cv64_text_wrap(item_name + "\nfor " + multiworld.get_player_name(loc.item.player), 96) - rom.write_bytes(inject_address, get_item_text_color(loc) + cv64_string_to_bytearray(wrapped_name)) - rom.write_byte(inject_address + 255, num_lines) - - # Everything relating to loading the other game items text - rom.write_int32(0xA8D8C, 0x080FF88F) # J 0x803FE23C - rom.write_int32(0xBEA98, 0x0C0FF8B4) # JAL 0x803FE2D0 - rom.write_int32(0xBEAB0, 0x0C0FF8BD) # JAL 0x803FE2F8 - rom.write_int32(0xBEACC, 0x0C0FF8C5) # JAL 0x803FE314 - rom.write_int32s(0xBFE23C, patches.multiworld_item_name_loader) - rom.write_bytes(0x10F188, [0x00 for _ in range(264)]) - rom.write_bytes(0x10F298, [0x00 for _ in range(264)]) - - # When the game normally JALs to the item prepare textbox function after the player picks up an item, set the - # "no receiving" timer to ensure the item textbox doesn't freak out if you pick something up while there's a queue - # of unreceived items. - rom.write_int32(0xA8D94, 0x0C0FF9F0) # JAL 0x803FE7C0 - rom.write_int32s(0xBFE7C0, [0x3C088039, # LUI T0, 0x8039 - 0x24090020, # ADDIU T1, R0, 0x0020 - 0x0804EDCE, # J 0x8013B738 - 0xA1099BE0]) # SB T1, 0x9BE0 (T0) - - -class CV64DeltaPatch(APDeltaPatch): - hash = CV64US10HASH - patch_file_ending: str = ".apcv64" - result_file_ending: str = ".z64" + wrapped_name, num_lines = cv64_text_wrap(item_name + "\nfor " + + world.multiworld.get_player_name(loc.item.player), 96) + patch.write_token(APTokenTypes.WRITE, inject_address, bytes(get_item_text_color(loc) + + cv64_string_to_bytearray(wrapped_name))) + patch.write_token(APTokenTypes.WRITE, inject_address + 255, bytes([num_lines])) - game = "Castlevania 64" - - @classmethod - def get_source_data(cls) -> bytes: - return get_base_rom_bytes() - - def patch(self, target: str): - super().patch(target) - rom = LocalRom(target) - - # Extract the item models file, decompress it, append the AP icons, compress it back, re-insert it. - items_file = lzkn64.decompress_buffer(rom.read_bytes(0x9C5310, 0x3D28)) - compressed_file = lzkn64.compress_buffer(items_file[0:0x69B6] + pkgutil.get_data(__name__, "data/ap_icons.bin")) - rom.write_bytes(0xBB2D88, compressed_file) - # Update the items' Nisitenma-Ichigo table entry to point to the new file's start and end addresses in the ROM. - rom.write_int32s(0x95F04, [0x80BB2D88, 0x00BB2D88 + len(compressed_file)]) - # Update the items' decompressed file size tables with the new file's decompressed file size. - rom.write_int16(0x95706, 0x7BF0) - rom.write_int16(0x104CCE, 0x7BF0) - # Update the Wooden Stake and Roses' item appearance settings table to point to the Archipelago item graphics. - rom.write_int16(0xEE5BA, 0x7B38) - rom.write_int16(0xEE5CA, 0x7280) - # Change the items' sizes. The progression one will be larger than the non-progression one. - rom.write_int32(0xEE5BC, 0x3FF00000) - rom.write_int32(0xEE5CC, 0x3FA00000) - rom.write_to_file(target) + # Write the secondary name the client will use to distinguish a vanilla ROM from an AP one. + patch.write_token(APTokenTypes.WRITE, 0xBFBFD0, "ARCHIPELAGO1".encode("utf-8")) + # Write the slot authentication + patch.write_token(APTokenTypes.WRITE, 0xBFBFE0, bytes(world.auth)) + + patch.write_file("token_data.bin", patch.get_token_binary()) + + # Write these slot options to a JSON. + options_dict = { + "character_stages": world.options.character_stages.value, + "vincent_fight_condition": world.options.vincent_fight_condition.value, + "renon_fight_condition": world.options.renon_fight_condition.value, + "bad_ending_condition": world.options.bad_ending_condition.value, + "increase_item_limit": world.options.increase_item_limit.value, + "nerf_healing_items": world.options.nerf_healing_items.value, + "loading_zone_heals": world.options.loading_zone_heals.value, + "disable_time_restrictions": world.options.disable_time_restrictions.value, + "death_link": world.options.death_link.value, + "draculas_condition": world.options.draculas_condition.value, + "invisible_items": world.options.invisible_items.value, + "post_behemoth_boss": world.options.post_behemoth_boss.value, + "room_of_clocks_boss": world.options.room_of_clocks_boss.value, + "skip_gondolas": world.options.skip_gondolas.value, + "skip_waterway_blocks": world.options.skip_waterway_blocks.value, + "s1s_per_warp": world.options.special1s_per_warp.value, + "required_s2s": world.required_s2s, + "total_s2s": world.total_s2s, + "total_special1s": world.options.total_special1s.value, + "increase_shimmy_speed": world.options.increase_shimmy_speed.value, + "fall_guard": world.options.fall_guard.value, + "cinematic_experience": world.options.cinematic_experience.value, + "permanent_powerups": world.options.permanent_powerups.value, + "background_music": world.options.background_music.value, + "multi_hit_breakables": world.options.multi_hit_breakables.value, + "drop_previous_sub_weapon": world.options.drop_previous_sub_weapon.value, + "countdown": world.options.countdown.value, + "shopsanity": world.options.shopsanity.value, + "panther_dash": world.options.panther_dash.value, + "big_toss": world.options.big_toss.value, + "window_color_r": world.options.window_color_r.value, + "window_color_g": world.options.window_color_g.value, + "window_color_b": world.options.window_color_b.value, + "window_color_a": world.options.window_color_a.value, + } + + patch.write_file("options.json", json.dumps(options_dict).encode('utf-8')) def get_base_rom_bytes(file_name: str = "") -> bytes: @@ -944,7 +1011,7 @@ def get_base_rom_bytes(file_name: str = "") -> bytes: basemd5 = hashlib.md5() basemd5.update(base_rom_bytes) - if CV64US10HASH != basemd5.hexdigest(): + if CV64_US_10_HASH != basemd5.hexdigest(): raise Exception("Supplied Base Rom does not match known MD5 for Castlevania 64 US 1.0." "Get the correct game and version, then dump it.") setattr(get_base_rom_bytes, "base_rom_bytes", base_rom_bytes) diff --git a/worlds/cv64/stages.py b/worlds/cv64/stages.py index a6fa6679214c..d7059b3580f2 100644 --- a/worlds/cv64/stages.py +++ b/worlds/cv64/stages.py @@ -47,9 +47,9 @@ # corresponding Locations and Entrances will all be created. stage_info = { "Forest of Silence": { - "start region": rname.forest_start, "start map id": 0x00, "start spawn id": 0x00, - "mid region": rname.forest_mid, "mid map id": 0x00, "mid spawn id": 0x04, - "end region": rname.forest_end, "end map id": 0x00, "end spawn id": 0x01, + "start region": rname.forest_start, "start map id": b"\x00", "start spawn id": b"\x00", + "mid region": rname.forest_mid, "mid map id": b"\x00", "mid spawn id": b"\x04", + "end region": rname.forest_end, "end map id": b"\x00", "end spawn id": b"\x01", "endzone map offset": 0xB6302F, "endzone spawn offset": 0xB6302B, "save number offsets": [0x1049C5, 0x1049CD, 0x1049D5], "regions": [rname.forest_start, @@ -58,9 +58,9 @@ }, "Castle Wall": { - "start region": rname.cw_start, "start map id": 0x02, "start spawn id": 0x00, - "mid region": rname.cw_start, "mid map id": 0x02, "mid spawn id": 0x07, - "end region": rname.cw_exit, "end map id": 0x02, "end spawn id": 0x10, + "start region": rname.cw_start, "start map id": b"\x02", "start spawn id": b"\x00", + "mid region": rname.cw_start, "mid map id": b"\x02", "mid spawn id": b"\x07", + "end region": rname.cw_exit, "end map id": b"\x02", "end spawn id": b"\x10", "endzone map offset": 0x109A5F, "endzone spawn offset": 0x109A61, "save number offsets": [0x1049DD, 0x1049E5, 0x1049ED], "regions": [rname.cw_start, @@ -69,9 +69,9 @@ }, "Villa": { - "start region": rname.villa_start, "start map id": 0x03, "start spawn id": 0x00, - "mid region": rname.villa_storeroom, "mid map id": 0x05, "mid spawn id": 0x04, - "end region": rname.villa_crypt, "end map id": 0x1A, "end spawn id": 0x03, + "start region": rname.villa_start, "start map id": b"\x03", "start spawn id": b"\x00", + "mid region": rname.villa_storeroom, "mid map id": b"\x05", "mid spawn id": b"\x04", + "end region": rname.villa_crypt, "end map id": b"\x1A", "end spawn id": b"\x03", "endzone map offset": 0xD9DA3, "endzone spawn offset": 0x109E81, "altzone map offset": 0xD9DAB, "altzone spawn offset": 0x109E81, "save number offsets": [0x1049F5, 0x1049FD, 0x104A05, 0x104A0D], @@ -85,9 +85,9 @@ }, "Tunnel": { - "start region": rname.tunnel_start, "start map id": 0x07, "start spawn id": 0x00, - "mid region": rname.tunnel_end, "mid map id": 0x07, "mid spawn id": 0x03, - "end region": rname.tunnel_end, "end map id": 0x07, "end spawn id": 0x11, + "start region": rname.tunnel_start, "start map id": b"\x07", "start spawn id": b"\x00", + "mid region": rname.tunnel_end, "mid map id": b"\x07", "mid spawn id": b"\x03", + "end region": rname.tunnel_end, "end map id": b"\x07", "end spawn id": b"\x11", "endzone map offset": 0x109B4F, "endzone spawn offset": 0x109B51, "character": "Reinhardt", "save number offsets": [0x104A15, 0x104A1D, 0x104A25, 0x104A2D], "regions": [rname.tunnel_start, @@ -95,9 +95,9 @@ }, "Underground Waterway": { - "start region": rname.uw_main, "start map id": 0x08, "start spawn id": 0x00, - "mid region": rname.uw_main, "mid map id": 0x08, "mid spawn id": 0x03, - "end region": rname.uw_end, "end map id": 0x08, "end spawn id": 0x01, + "start region": rname.uw_main, "start map id": b"\x08", "start spawn id": b"\x00", + "mid region": rname.uw_main, "mid map id": b"\x08", "mid spawn id": b"\x03", + "end region": rname.uw_end, "end map id": b"\x08", "end spawn id": b"\x01", "endzone map offset": 0x109B67, "endzone spawn offset": 0x109B69, "character": "Carrie", "save number offsets": [0x104A35, 0x104A3D], "regions": [rname.uw_main, @@ -105,9 +105,9 @@ }, "Castle Center": { - "start region": rname.cc_main, "start map id": 0x19, "start spawn id": 0x00, - "mid region": rname.cc_main, "mid map id": 0x0E, "mid spawn id": 0x03, - "end region": rname.cc_elev_top, "end map id": 0x0F, "end spawn id": 0x02, + "start region": rname.cc_main, "start map id": b"\x19", "start spawn id": b"\x00", + "mid region": rname.cc_main, "mid map id": b"\x0E", "mid spawn id": b"\x03", + "end region": rname.cc_elev_top, "end map id": b"\x0F", "end spawn id": b"\x02", "endzone map offset": 0x109CB7, "endzone spawn offset": 0x109CB9, "altzone map offset": 0x109CCF, "altzone spawn offset": 0x109CD1, "save number offsets": [0x104A45, 0x104A4D, 0x104A55, 0x104A5D, 0x104A65, 0x104A6D, 0x104A75], @@ -119,20 +119,20 @@ }, "Duel Tower": { - "start region": rname.dt_main, "start map id": 0x13, "start spawn id": 0x00, + "start region": rname.dt_main, "start map id": b"\x13", "start spawn id": b"\x00", "startzone map offset": 0x109DA7, "startzone spawn offset": 0x109DA9, - "mid region": rname.dt_main, "mid map id": 0x13, "mid spawn id": 0x15, - "end region": rname.dt_main, "end map id": 0x13, "end spawn id": 0x01, + "mid region": rname.dt_main, "mid map id": b"\x13", "mid spawn id": b"\x15", + "end region": rname.dt_main, "end map id": b"\x13", "end spawn id": b"\x01", "endzone map offset": 0x109D8F, "endzone spawn offset": 0x109D91, "character": "Reinhardt", "save number offsets": [0x104ACD], "regions": [rname.dt_main] }, "Tower of Execution": { - "start region": rname.toe_main, "start map id": 0x10, "start spawn id": 0x00, + "start region": rname.toe_main, "start map id": b"\x10", "start spawn id": b"\x00", "startzone map offset": 0x109D17, "startzone spawn offset": 0x109D19, - "mid region": rname.toe_main, "mid map id": 0x10, "mid spawn id": 0x02, - "end region": rname.toe_main, "end map id": 0x10, "end spawn id": 0x12, + "mid region": rname.toe_main, "mid map id": b"\x10", "mid spawn id": b"\x02", + "end region": rname.toe_main, "end map id": b"\x10", "end spawn id": b"\x12", "endzone map offset": 0x109CFF, "endzone spawn offset": 0x109D01, "character": "Reinhardt", "save number offsets": [0x104A7D, 0x104A85], "regions": [rname.toe_main, @@ -140,10 +140,10 @@ }, "Tower of Science": { - "start region": rname.tosci_start, "start map id": 0x12, "start spawn id": 0x00, + "start region": rname.tosci_start, "start map id": b"\x12", "start spawn id": b"\x00", "startzone map offset": 0x109D77, "startzone spawn offset": 0x109D79, - "mid region": rname.tosci_conveyors, "mid map id": 0x12, "mid spawn id": 0x03, - "end region": rname.tosci_conveyors, "end map id": 0x12, "end spawn id": 0x04, + "mid region": rname.tosci_conveyors, "mid map id": b"\x12", "mid spawn id": b"\x03", + "end region": rname.tosci_conveyors, "end map id": b"\x12", "end spawn id": b"\x04", "endzone map offset": 0x109D5F, "endzone spawn offset": 0x109D61, "character": "Carrie", "save number offsets": [0x104A95, 0x104A9D, 0x104AA5], "regions": [rname.tosci_start, @@ -153,28 +153,28 @@ }, "Tower of Sorcery": { - "start region": rname.tosor_main, "start map id": 0x11, "start spawn id": 0x00, + "start region": rname.tosor_main, "start map id": b"\x11", "start spawn id": b"\x00", "startzone map offset": 0x109D47, "startzone spawn offset": 0x109D49, - "mid region": rname.tosor_main, "mid map id": 0x11, "mid spawn id": 0x01, - "end region": rname.tosor_main, "end map id": 0x11, "end spawn id": 0x13, + "mid region": rname.tosor_main, "mid map id": b"\x11", "mid spawn id": b"\x01", + "end region": rname.tosor_main, "end map id": b"\x11", "end spawn id": b"\x13", "endzone map offset": 0x109D2F, "endzone spawn offset": 0x109D31, "character": "Carrie", "save number offsets": [0x104A8D], "regions": [rname.tosor_main] }, "Room of Clocks": { - "start region": rname.roc_main, "start map id": 0x1B, "start spawn id": 0x00, - "mid region": rname.roc_main, "mid map id": 0x1B, "mid spawn id": 0x02, - "end region": rname.roc_main, "end map id": 0x1B, "end spawn id": 0x14, + "start region": rname.roc_main, "start map id": b"\x1B", "start spawn id": b"\x00", + "mid region": rname.roc_main, "mid map id": b"\x1B", "mid spawn id": b"\x02", + "end region": rname.roc_main, "end map id": b"\x1B", "end spawn id": b"\x14", "endzone map offset": 0x109EAF, "endzone spawn offset": 0x109EB1, "save number offsets": [0x104AC5], "regions": [rname.roc_main] }, "Clock Tower": { - "start region": rname.ct_start, "start map id": 0x17, "start spawn id": 0x00, - "mid region": rname.ct_middle, "mid map id": 0x17, "mid spawn id": 0x02, - "end region": rname.ct_end, "end map id": 0x17, "end spawn id": 0x03, + "start region": rname.ct_start, "start map id": b"\x17", "start spawn id": b"\x00", + "mid region": rname.ct_middle, "mid map id": b"\x17", "mid spawn id": b"\x02", + "end region": rname.ct_end, "end map id": b"\x17", "end spawn id": b"\x03", "endzone map offset": 0x109E37, "endzone spawn offset": 0x109E39, "save number offsets": [0x104AB5, 0x104ABD], "regions": [rname.ct_start, @@ -183,8 +183,8 @@ }, "Castle Keep": { - "start region": rname.ck_main, "start map id": 0x14, "start spawn id": 0x02, - "mid region": rname.ck_main, "mid map id": 0x14, "mid spawn id": 0x03, + "start region": rname.ck_main, "start map id": b"\x14", "start spawn id": b"\x02", + "mid region": rname.ck_main, "mid map id": b"\x14", "mid spawn id": b"\x03", "end region": rname.ck_drac_chamber, "save number offsets": [0x104AAD], "regions": [rname.ck_main] diff --git a/worlds/ffmq/docs/setup_en.md b/worlds/ffmq/docs/setup_en.md index de2493df74f2..35d775f1bc9f 100644 --- a/worlds/ffmq/docs/setup_en.md +++ b/worlds/ffmq/docs/setup_en.md @@ -12,7 +12,7 @@ - An SD2SNES, FXPak Pro ([FXPak Pro Store Page](https://krikzz.com/store/home/54-fxpak-pro.html)), or other compatible hardware -- Your legally obtained Final Fantasy Mystic Quest 1.1 ROM file, probably named `Final Fantasy - Mystic Quest (U) (V1.1).sfc` +- Your legally obtained Final Fantasy Mystic Quest NA 1.0 or 1.1 ROM file, probably named `Final Fantasy - Mystic Quest (U) (V1.0).sfc` or `Final Fantasy - Mystic Quest (U) (V1.1).sfc` The Archipelago community cannot supply you with this. ## Installation Procedures @@ -54,7 +54,7 @@ validator page: [YAML Validation page](/mysterycheck) 2. You will be presented with a "Seed Info" page. 3. Click the "Create New Room" link. 4. You will be presented with a server page, from which you can download your `.apmq` patch file. -5. Go to the [FFMQR website](https://ffmqrando.net/Archipelago) and select your Final Fantasy Mystic Quest 1.1 ROM +5. Go to the [FFMQR website](https://ffmqrando.net/Archipelago) and select your Final Fantasy Mystic Quest ROM and the .apmq file you received, choose optional preferences, and click `Generate` to get your patched ROM. 7. Since this is a single-player game, you will no longer need the client, so feel free to close it. @@ -66,7 +66,7 @@ When you join a multiworld game, you will be asked to provide your config file t the host will provide you with either a link to download your patch file, or with a zip file containing everyone's patch files. Your patch file should have a `.apmq` extension. -Go to the [FFMQR website](https://ffmqrando.net/Archipelago) and select your Final Fantasy Mystic Quest 1.1 ROM +Go to the [FFMQR website](https://ffmqrando.net/Archipelago) and select your Final Fantasy Mystic Quest ROM and the .apmq file you received, choose optional preferences, and click `Generate` to get your patched ROM. Manually launch the SNI Client, and run the patched ROM in your chosen software or hardware. diff --git a/worlds/hylics2/Options.py b/worlds/hylics2/Options.py index ac57e666a1a2..85cf36b15640 100644 --- a/worlds/hylics2/Options.py +++ b/worlds/hylics2/Options.py @@ -1,4 +1,5 @@ -from Options import Choice, Toggle, DefaultOnToggle, DeathLink +from dataclasses import dataclass +from Options import Choice, Toggle, DefaultOnToggle, DeathLink, PerGameCommonOptions class PartyShuffle(Toggle): """Shuffles party members into the pool. @@ -31,11 +32,11 @@ class Hylics2DeathLink(DeathLink): Note that this also includes death by using the PERISH gesture. Can be toggled via in-game console command "/deathlink".""" -hylics2_options = { - "party_shuffle": PartyShuffle, - "gesture_shuffle" : GestureShuffle, - "medallion_shuffle" : MedallionShuffle, - "random_start" : RandomStart, - "extra_items_in_logic": ExtraLogic, - "death_link": Hylics2DeathLink -} \ No newline at end of file +@dataclass +class Hylics2Options(PerGameCommonOptions): + party_shuffle: PartyShuffle + gesture_shuffle: GestureShuffle + medallion_shuffle: MedallionShuffle + random_start: RandomStart + extra_items_in_logic: ExtraLogic + death_link: Hylics2DeathLink \ No newline at end of file diff --git a/worlds/hylics2/Rules.py b/worlds/hylics2/Rules.py index 5fd4671958ac..2ecd14909715 100644 --- a/worlds/hylics2/Rules.py +++ b/worlds/hylics2/Rules.py @@ -129,6 +129,12 @@ def set_rules(hylics2world): world = hylics2world.multiworld player = hylics2world.player + extra = hylics2world.options.extra_items_in_logic + party = hylics2world.options.party_shuffle + medallion = hylics2world.options.medallion_shuffle + random_start = hylics2world.options.random_start + start_location = hylics2world.start_location + # Afterlife add_rule(world.get_location("Afterlife: TV", player), lambda state: cave_key(state, player)) @@ -346,7 +352,7 @@ def set_rules(hylics2world): lambda state: upper_chamber_key(state, player)) # extra rules if Extra Items in Logic is enabled - if world.extra_items_in_logic[player]: + if extra: for i in world.get_region("Foglast", player).entrances: add_rule(i, lambda state: charge_up(state, player)) for i in world.get_region("Sage Airship", player).entrances: @@ -368,7 +374,7 @@ def set_rules(hylics2world): )) # extra rules if Shuffle Party Members is enabled - if world.party_shuffle[player]: + if party: for i in world.get_region("Arcade Island", player).entrances: add_rule(i, lambda state: party_3(state, player)) for i in world.get_region("Foglast", player).entrances: @@ -406,7 +412,7 @@ def set_rules(hylics2world): lambda state: party_3(state, player)) # extra rules if Shuffle Red Medallions is enabled - if world.medallion_shuffle[player]: + if medallion: add_rule(world.get_location("New Muldul: Upper House Medallion", player), lambda state: upper_house_key(state, player)) add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player), @@ -461,7 +467,7 @@ def set_rules(hylics2world): lambda state: upper_chamber_key(state, player)) # extra rules if Shuffle Red Medallions and Party Shuffle are enabled - if world.party_shuffle[player] and world.medallion_shuffle[player]: + if party and medallion: add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player), lambda state: party_3(state, player)) add_rule(world.get_location("New Muldul: Vault Rear Right Medallion", player), @@ -493,8 +499,7 @@ def set_rules(hylics2world): add_rule(i, lambda state: enter_hylemxylem(state, player)) # random start logic (default) - if ((not world.random_start[player]) or \ - (world.random_start[player] and hylics2world.start_location == "Waynehouse")): + if not random_start or random_start and start_location == "Waynehouse": # entrances for i in world.get_region("Viewax", player).entrances: add_rule(i, lambda state: ( @@ -509,7 +514,7 @@ def set_rules(hylics2world): add_rule(i, lambda state: airship(state, player)) # random start logic (Viewax's Edifice) - elif (world.random_start[player] and hylics2world.start_location == "Viewax's Edifice"): + elif random_start and start_location == "Viewax's Edifice": for i in world.get_region("Waynehouse", player).entrances: add_rule(i, lambda state: ( air_dash(state, player) @@ -540,7 +545,7 @@ def set_rules(hylics2world): add_rule(i, lambda state: airship(state, player)) # random start logic (TV Island) - elif (world.random_start[player] and hylics2world.start_location == "TV Island"): + elif random_start and start_location == "TV Island": for i in world.get_region("Waynehouse", player).entrances: add_rule(i, lambda state: airship(state, player)) for i in world.get_region("New Muldul", player).entrances: @@ -559,7 +564,7 @@ def set_rules(hylics2world): add_rule(i, lambda state: airship(state, player)) # random start logic (Shield Facility) - elif (world.random_start[player] and hylics2world.start_location == "Shield Facility"): + elif random_start and start_location == "Shield Facility": for i in world.get_region("Waynehouse", player).entrances: add_rule(i, lambda state: airship(state, player)) for i in world.get_region("New Muldul", player).entrances: diff --git a/worlds/hylics2/__init__.py b/worlds/hylics2/__init__.py index cb7ae4498279..93ec43f842bf 100644 --- a/worlds/hylics2/__init__.py +++ b/worlds/hylics2/__init__.py @@ -1,7 +1,8 @@ from typing import Dict, List, Any from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification from worlds.generic.Rules import set_rule -from . import Exits, Items, Locations, Options, Rules +from . import Exits, Items, Locations, Rules +from .Options import Hylics2Options from worlds.AutoWorld import WebWorld, World @@ -32,7 +33,9 @@ class Hylics2World(World): item_name_to_id = {data["name"]: item_id for item_id, data in all_items.items()} location_name_to_id = {data["name"]: loc_id for loc_id, data in all_locations.items()} - option_definitions = Options.hylics2_options + + options_dataclass = Hylics2Options + options: Hylics2Options data_version = 3 @@ -55,7 +58,7 @@ def create_event(self, event: str): # set random starting location if option is enabled def generate_early(self): - if self.multiworld.random_start[self.player]: + if self.options.random_start: i = self.random.randint(0, 3) if i == 0: self.start_location = "Waynehouse" @@ -77,17 +80,17 @@ def create_items(self): pool.append(self.create_item(item["name"])) # add party members if option is enabled - if self.multiworld.party_shuffle[self.player]: + if self.options.party_shuffle: for item in Items.party_item_table.values(): pool.append(self.create_item(item["name"])) # handle gesture shuffle - if not self.multiworld.gesture_shuffle[self.player]: # add gestures to pool like normal + if not self.options.gesture_shuffle: # add gestures to pool like normal for item in Items.gesture_item_table.values(): pool.append(self.create_item(item["name"])) # add '10 Bones' items if medallion shuffle is enabled - if self.multiworld.medallion_shuffle[self.player]: + if self.options.medallion_shuffle: for item in Items.medallion_item_table.values(): for _ in range(item["count"]): pool.append(self.create_item(item["name"])) @@ -98,7 +101,7 @@ def create_items(self): def pre_fill(self): # handle gesture shuffle options - if self.multiworld.gesture_shuffle[self.player] == 2: # vanilla locations + if self.options.gesture_shuffle == 2: # vanilla locations gestures = Items.gesture_item_table self.multiworld.get_location("Waynehouse: TV", self.player)\ .place_locked_item(self.create_item("POROMER BLEB")) @@ -119,13 +122,13 @@ def pre_fill(self): self.multiworld.get_location("Sage Airship: TV", self.player)\ .place_locked_item(self.create_item("BOMBO - GENESIS")) - elif self.multiworld.gesture_shuffle[self.player] == 1: # TVs only + elif self.options.gesture_shuffle == 1: # TVs only gestures = [gesture["name"] for gesture in Items.gesture_item_table.values()] tvs = [tv["name"] for tv in Locations.tv_location_table.values()] # if Extra Items in Logic is enabled place CHARGE UP first and make sure it doesn't get # placed at Sage Airship: TV or Foglast: TV - if self.multiworld.extra_items_in_logic[self.player]: + if self.options.extra_items_in_logic: tv = self.random.choice(tvs) while tv == "Sage Airship: TV" or tv == "Foglast: TV": tv = self.random.choice(tvs) @@ -144,11 +147,11 @@ def pre_fill(self): def fill_slot_data(self) -> Dict[str, Any]: slot_data: Dict[str, Any] = { - "party_shuffle": self.multiworld.party_shuffle[self.player].value, - "medallion_shuffle": self.multiworld.medallion_shuffle[self.player].value, - "random_start" : self.multiworld.random_start[self.player].value, + "party_shuffle": self.options.party_shuffle.value, + "medallion_shuffle": self.options.medallion_shuffle.value, + "random_start" : self.options.random_start.value, "start_location" : self.start_location, - "death_link": self.multiworld.death_link[self.player].value + "death_link": self.options.death_link.value } return slot_data @@ -186,7 +189,7 @@ def create_regions(self) -> None: # create entrance and connect it to parent and destination regions ent = Entrance(self.player, f"{reg.name} {k}", reg) reg.exits.append(ent) - if k == "New Game" and self.multiworld.random_start[self.player]: + if k == "New Game" and self.options.random_start: if self.start_location == "Waynehouse": ent.connect(region_table[2]) elif self.start_location == "Viewax's Edifice": @@ -209,13 +212,13 @@ def create_regions(self) -> None: .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) # add party member locations if option is enabled - if self.multiworld.party_shuffle[self.player]: + if self.options.party_shuffle: for i, data in Locations.party_location_table.items(): region_table[data["region"]].locations\ .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) # add medallion locations if option is enabled - if self.multiworld.medallion_shuffle[self.player]: + if self.options.medallion_shuffle: for i, data in Locations.medallion_location_table.items(): region_table[data["region"]].locations\ .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) diff --git a/worlds/lufia2ac/Client.py b/worlds/lufia2ac/Client.py index 9025a1137b98..3c05e6395d90 100644 --- a/worlds/lufia2ac/Client.py +++ b/worlds/lufia2ac/Client.py @@ -118,10 +118,11 @@ async def game_watcher(self, ctx: SNIContext) -> None: snes_buffered_write(ctx, L2AC_TX_ADDR + 8, total_blue_chests_checked.to_bytes(2, "little")) location_ids: List[int] = [locations_start_id + i for i in range(total_blue_chests_checked)] - loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2) - if loc_data is not None: - location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little") - for i in range(snes_other_locations_checked)) + if snes_other_locations_checked: + loc_data: Optional[bytes] = await snes_read(ctx, L2AC_TX_ADDR + 32, snes_other_locations_checked * 2) + if loc_data is not None: + location_ids.extend(locations_start_id + int.from_bytes(loc_data[2 * i:2 * i + 2], "little") + for i in range(snes_other_locations_checked)) if new_location_ids := [loc_id for loc_id in location_ids if loc_id not in ctx.locations_checked]: await ctx.send_msgs([{"cmd": "LocationChecks", "locations": new_location_ids}]) diff --git a/worlds/noita/locations.py b/worlds/noita/locations.py index cf91ba44fb7a..01801b158509 100644 --- a/worlds/noita/locations.py +++ b/worlds/noita/locations.py @@ -26,7 +26,7 @@ class LocationFlag(IntEnum): # Mapping of items in each region. # Only the first Hidden Chest and Pedestal are mapped here, the others are created in Regions. # ltype key: "chest" = Hidden Chests, "pedestal" = Pedestals, "boss" = Boss, "orb" = Orb. -# 110000-110649 +# 110000-110671 location_region_mapping: Dict[str, Dict[str, LocationData]] = { "Coal Pits Holy Mountain": { "Coal Pits Holy Mountain Shop Item 1": LocationData(110000), @@ -90,6 +90,9 @@ class LocationFlag(IntEnum): "Secret Shop Item 3": LocationData(110044), "Secret Shop Item 4": LocationData(110045), }, + "The Sky": { + "Kivi": LocationData(110670, LocationFlag.main_world, "boss"), + }, "Floating Island": { "Floating Island Orb": LocationData(110658, LocationFlag.main_path, "orb"), }, @@ -104,6 +107,7 @@ class LocationFlag(IntEnum): }, "Lake": { "Syväolento": LocationData(110651, LocationFlag.main_world, "boss"), + "Tapion vasalli": LocationData(110669, LocationFlag.main_world, "boss"), }, "Frozen Vault": { "Frozen Vault Orb": LocationData(110660, LocationFlag.main_world, "orb"), @@ -189,6 +193,9 @@ class LocationFlag(IntEnum): "Deep Underground": { "Limatoukka": LocationData(110647, LocationFlag.main_world, "boss"), }, + "West Meat Realm": { + "Kolmisilmän sydän": LocationData(110671, LocationFlag.main_world, "boss"), + }, "The Laboratory": { "Kolmisilmä": LocationData(110646, LocationFlag.main_path, "boss"), }, diff --git a/worlds/noita/options.py b/worlds/noita/options.py index 2c99e9dd2f38..3600c0ca163e 100644 --- a/worlds/noita/options.py +++ b/worlds/noita/options.py @@ -53,7 +53,7 @@ class BossesAsChecks(Choice): """Makes bosses count as location checks. The boss only needs to die, you do not need the kill credit. The Main Path option includes Gate Guardian, Suomuhauki, and Kolmisilmä. The Side Path option includes the Main Path bosses, Sauvojen Tuntija, and Ylialkemisti. - The All Bosses option includes all 12 bosses.""" + The All Bosses option includes all 15 bosses.""" display_name = "Bosses as Location Checks" option_no_bosses = 0 option_main_path = 1 diff --git a/worlds/noita/regions.py b/worlds/noita/regions.py index 3b7fd3962c89..8ea8a41e85f6 100644 --- a/worlds/noita/regions.py +++ b/worlds/noita/regions.py @@ -72,7 +72,7 @@ def create_all_regions_and_connections(world: "NoitaWorld") -> None: # - Snow Chasm is disconnected from the Snowy Wasteland # - Pyramid is connected to the Hiisi Base instead of the Desert due to similar difficulty # - Frozen Vault is connected to the Vault instead of the Snowy Wasteland due to similar difficulty -# - Lake is connected to The Laboratory, since the boss is hard without specific set-ups (which means late game) +# - Lake is connected to The Laboratory, since the bosses are hard without specific set-ups (which means late game) # - Snowy Depths connects to Lava Lake orb since you need digging for it, so fairly early is acceptable # - Ancient Laboratory is connected to the Coal Pits, so that Ylialkemisti isn't sphere 1 noita_connections: Dict[str, List[str]] = { @@ -99,7 +99,7 @@ def create_all_regions_and_connections(world: "NoitaWorld") -> None: ### "Underground Jungle Holy Mountain": ["Underground Jungle"], - "Underground Jungle": ["Dragoncave", "Overgrown Cavern", "Vault Holy Mountain", "Lukki Lair", "Snow Chasm"], + "Underground Jungle": ["Dragoncave", "Overgrown Cavern", "Vault Holy Mountain", "Lukki Lair", "Snow Chasm", "West Meat Realm"], ### "Vault Holy Mountain": ["The Vault"], @@ -113,7 +113,7 @@ def create_all_regions_and_connections(world: "NoitaWorld") -> None: ### "Laboratory Holy Mountain": ["The Laboratory"], - "The Laboratory": ["The Work", "Friend Cave", "The Work (Hell)", "Lake"], + "The Laboratory": ["The Work", "Friend Cave", "The Work (Hell)", "Lake", "The Sky"], ### } diff --git a/worlds/pokemon_emerald/CHANGELOG.md b/worlds/pokemon_emerald/CHANGELOG.md index dbc1123b7719..ec23ba5c5869 100644 --- a/worlds/pokemon_emerald/CHANGELOG.md +++ b/worlds/pokemon_emerald/CHANGELOG.md @@ -1,3 +1,10 @@ +# 2.0.1 + +### Fixes + +- Changed "Ho-oh" to "Ho-Oh" in options +- Temporarily disable a possible location for Marine Cave to spawn, as its causes an overflow + # 2.0.0 ### Features diff --git a/worlds/pokemon_emerald/__init__.py b/worlds/pokemon_emerald/__init__.py index c7f060a72969..92bad6244f96 100644 --- a/worlds/pokemon_emerald/__init__.py +++ b/worlds/pokemon_emerald/__init__.py @@ -87,7 +87,7 @@ class PokemonEmeraldWorld(World): location_name_groups = LOCATION_GROUPS data_version = 2 - required_client_version = (0, 4, 5) + required_client_version = (0, 4, 6) badge_shuffle_info: Optional[List[Tuple[PokemonEmeraldLocation, PokemonEmeraldItem]]] hm_shuffle_info: Optional[List[Tuple[PokemonEmeraldLocation, PokemonEmeraldItem]]] diff --git a/worlds/pokemon_emerald/client.py b/worlds/pokemon_emerald/client.py index 0be48261cd46..169a5a796364 100644 --- a/worlds/pokemon_emerald/client.py +++ b/worlds/pokemon_emerald/client.py @@ -87,7 +87,8 @@ ] KEY_LOCATION_FLAG_MAP = {data.locations[location_name].flag: location_name for location_name in KEY_LOCATION_FLAGS} -LEGENDARY_NAMES = { +# .lower() keys for backward compatibility between 0.4.5 and 0.4.6 +LEGENDARY_NAMES = {k.lower(): v for k, v in { "Groudon": "GROUDON", "Kyogre": "KYOGRE", "Rayquaza": "RAYQUAZA", @@ -100,7 +101,7 @@ "Deoxys": "DEOXYS", "Ho-Oh": "HO_OH", "Lugia": "LUGIA", -} +}.items()} DEFEATED_LEGENDARY_FLAG_MAP = {data.constants[f"FLAG_DEFEATED_{name}"]: name for name in LEGENDARY_NAMES.values()} CAUGHT_LEGENDARY_FLAG_MAP = {data.constants[f"FLAG_CAUGHT_{name}"]: name for name in LEGENDARY_NAMES.values()} @@ -311,7 +312,7 @@ async def game_watcher(self, ctx: "BizHawkClientContext") -> None: num_caught = 0 for legendary, is_caught in caught_legendaries.items(): - if is_caught and legendary in [LEGENDARY_NAMES[name] for name in ctx.slot_data["allowed_legendary_hunt_encounters"]]: + if is_caught and legendary in [LEGENDARY_NAMES[name.lower()] for name in ctx.slot_data["allowed_legendary_hunt_encounters"]]: num_caught += 1 if num_caught >= ctx.slot_data["legendary_hunt_count"]: diff --git a/worlds/pokemon_emerald/locations.py b/worlds/pokemon_emerald/locations.py index 99d11db9850c..8ae891831bec 100644 --- a/worlds/pokemon_emerald/locations.py +++ b/worlds/pokemon_emerald/locations.py @@ -212,7 +212,7 @@ def set_legendary_cave_entrances(world: "PokemonEmeraldWorld") -> None: "MARINE_CAVE_ROUTE_127_1", "MARINE_CAVE_ROUTE_127_2", "MARINE_CAVE_ROUTE_129_1", - "MARINE_CAVE_ROUTE_129_2", + # "MARINE_CAVE_ROUTE_129_2", # Cave ID too high for internal data type, needs patch update ]) marine_cave_location_location = world.multiworld.get_location("MARINE_CAVE_LOCATION", world.player) diff --git a/worlds/sm64ex/Regions.py b/worlds/sm64ex/Regions.py index 333e2df3a97f..6fc2d74b96dc 100644 --- a/worlds/sm64ex/Regions.py +++ b/worlds/sm64ex/Regions.py @@ -165,11 +165,9 @@ def create_regions(world: MultiWorld, options: SM64Options, player: int): regDDD = create_region("Dire, Dire Docks", player, world) create_locs(regDDD, "DDD: Board Bowser's Sub", "DDD: Chests in the Current", "DDD: Through the Jet Stream", - "DDD: The Manta Ray's Reward", "DDD: Collect the Caps...") - ddd_moving_poles = create_subregion(regDDD, "DDD: Moving Poles", "DDD: Pole-Jumping for Red Coins") - regDDD.subregions = [ddd_moving_poles] + "DDD: The Manta Ray's Reward", "DDD: Collect the Caps...", "DDD: Pole-Jumping for Red Coins") if options.enable_coin_stars: - create_locs(ddd_moving_poles, "DDD: 100 Coins") + create_locs(regDDD, "DDD: 100 Coins") regCotMC = create_region("Cavern of the Metal Cap", player, world) create_default_locs(regCotMC, locCotMC_table) @@ -222,9 +220,9 @@ def create_regions(world: MultiWorld, options: SM64Options, player: int): regTTC = create_region("Tick Tock Clock", player, world) create_locs(regTTC, "TTC: Stop Time for Red Coins") - ttc_lower = create_subregion(regTTC, "TTC: Lower", "TTC: Roll into the Cage", "TTC: Get a Hand", "TTC: 1Up Block Midway Up") + ttc_lower = create_subregion(regTTC, "TTC: Lower", "TTC: Roll into the Cage", "TTC: Get a Hand") ttc_upper = create_subregion(ttc_lower, "TTC: Upper", "TTC: Timed Jumps on Moving Bars", "TTC: The Pit and the Pendulums") - ttc_top = create_subregion(ttc_upper, "TTC: Top", "TTC: Stomp on the Thwomp", "TTC: 1Up Block at the Top") + ttc_top = create_subregion(ttc_upper, "TTC: Top", "TTC: 1Up Block Midway Up", "TTC: Stomp on the Thwomp", "TTC: 1Up Block at the Top") regTTC.subregions = [ttc_lower, ttc_upper, ttc_top] if options.enable_coin_stars: create_locs(ttc_top, "TTC: 100 Coins") diff --git a/worlds/sm64ex/Rules.py b/worlds/sm64ex/Rules.py index 72016b4f4014..9add8d9b2932 100644 --- a/worlds/sm64ex/Rules.py +++ b/worlds/sm64ex/Rules.py @@ -119,14 +119,14 @@ def set_rules(world, options: SM64Options, player: int, area_connections: dict, rf.assign_rule("BoB: Mario Wings to the Sky", "CANN & WC | CAPLESS & CANN") rf.assign_rule("BoB: Behind Chain Chomp's Gate", "GP | MOVELESS") # Whomp's Fortress - rf.assign_rule("WF: Tower", "{{WF: Chip Off Whomp's Block}}") + rf.assign_rule("WF: Tower", "GP") rf.assign_rule("WF: Chip Off Whomp's Block", "GP") rf.assign_rule("WF: Shoot into the Wild Blue", "WK & TJ/SF | CANN") rf.assign_rule("WF: Fall onto the Caged Island", "CL & {WF: Tower} | MOVELESS & TJ | MOVELESS & LJ | MOVELESS & CANN") rf.assign_rule("WF: Blast Away the Wall", "CANN | CANNLESS & LG") # Jolly Roger Bay rf.assign_rule("JRB: Upper", "TJ/BF/SF/WK | MOVELESS & LG") - rf.assign_rule("JRB: Red Coins on the Ship Afloat", "CL/CANN/TJ/BF/WK") + rf.assign_rule("JRB: Red Coins on the Ship Afloat", "CL/CANN/TJ | MOVELESS & BF/WK") rf.assign_rule("JRB: Blast to the Stone Pillar", "CANN+CL | CANNLESS & MOVELESS | CANN & MOVELESS") rf.assign_rule("JRB: Through the Jet Stream", "MC | CAPLESS") # Cool, Cool Mountain @@ -147,9 +147,10 @@ def set_rules(world, options: SM64Options, player: int, area_connections: dict, rf.assign_rule("LLL: Upper Volcano", "CL") # Shifting Sand Land rf.assign_rule("SSL: Upper Pyramid", "CL & TJ/BF/SF/LG | MOVELESS") - rf.assign_rule("SSL: Free Flying for 8 Red Coins", "TJ/SF/BF & TJ+WC | TJ/SF/BF & CAPLESS | MOVELESS & CAPLESS") + rf.assign_rule("SSL: Stand Tall on the Four Pillars", "TJ+WC+GP | CANN+WC+GP | TJ/SF/BF & CAPLESS | MOVELESS") + rf.assign_rule("SSL: Free Flying for 8 Red Coins", "TJ+WC | CANN+WC | TJ/SF/BF & CAPLESS | MOVELESS & CAPLESS") # Dire, Dire Docks - rf.assign_rule("DDD: Moving Poles", "CL & {{Bowser in the Fire Sea Key}} | TJ+DV+LG+WK & MOVELESS") + rf.assign_rule("DDD: Pole-Jumping for Red Coins", "CL & {{Bowser in the Fire Sea Key}} | TJ+DV+LG+WK & MOVELESS") rf.assign_rule("DDD: Through the Jet Stream", "MC | CAPLESS") rf.assign_rule("DDD: Collect the Caps...", "VC+MC | CAPLESS & VC") # Snowman's Land @@ -173,15 +174,14 @@ def set_rules(world, options: SM64Options, player: int, area_connections: dict, rf.assign_rule("THI: Make Wiggler Squirm", "GP | MOVELESS & DV") # Tick Tock Clock rf.assign_rule("TTC: Lower", "LG/TJ/SF/BF/WK") - rf.assign_rule("TTC: Upper", "CL | SF+WK") - rf.assign_rule("TTC: Top", "CL | SF+WK") - rf.assign_rule("TTC: Stomp on the Thwomp", "LG & TJ/SF/BF") + rf.assign_rule("TTC: Upper", "CL | MOVELESS & WK") + rf.assign_rule("TTC: Top", "TJ+LG | MOVELESS & WK/TJ") rf.assign_rule("TTC: Stop Time for Red Coins", "NAR | {TTC: Lower}") # Rainbow Ride rf.assign_rule("RR: Maze", "WK | LJ & SF/BF/TJ | MOVELESS & LG/TJ") rf.assign_rule("RR: Bob-omb Buddy", "WK | MOVELESS & LG") - rf.assign_rule("RR: Swingin' in the Breeze", "LG/TJ/BF/SF") - rf.assign_rule("RR: Tricky Triangles!", "LG/TJ/BF/SF") + rf.assign_rule("RR: Swingin' in the Breeze", "LG/TJ/BF/SF | MOVELESS") + rf.assign_rule("RR: Tricky Triangles!", "LG/TJ/BF/SF | MOVELESS") rf.assign_rule("RR: Cruiser", "WK/SF/BF/LG/TJ") rf.assign_rule("RR: House", "TJ/SF/BF/LG") rf.assign_rule("RR: Somewhere Over the Rainbow", "CANN") @@ -206,8 +206,8 @@ def set_rules(world, options: SM64Options, player: int, area_connections: dict, rf.assign_rule("JRB: 100 Coins", "GP & {JRB: Upper}") rf.assign_rule("HMC: 100 Coins", "GP") rf.assign_rule("SSL: 100 Coins", "{SSL: Upper Pyramid} | GP") - rf.assign_rule("DDD: 100 Coins", "GP") - rf.assign_rule("SL: 100 Coins", "VC | MOVELESS") + rf.assign_rule("DDD: 100 Coins", "GP & {{DDD: Pole-Jumping for Red Coins}}") + rf.assign_rule("SL: 100 Coins", "VC | CAPLESS") rf.assign_rule("WDW: 100 Coins", "GP | {WDW: Downtown}") rf.assign_rule("TTC: 100 Coins", "GP") rf.assign_rule("THI: 100 Coins", "GP") @@ -246,6 +246,7 @@ class RuleFactory: token_table = { "TJ": "Triple Jump", + "DJ": "Triple Jump", "LJ": "Long Jump", "BF": "Backflip", "SF": "Side Flip", @@ -270,7 +271,7 @@ def __init__(self, world, options: SM64Options, player: int, move_rando_bitvec: self.area_randomizer = options.area_rando > 0 self.capless = not options.strict_cap_requirements self.cannonless = not options.strict_cannon_requirements - self.moveless = not options.strict_move_requirements or not move_rando_bitvec > 0 + self.moveless = not options.strict_move_requirements def assign_rule(self, target_name: str, rule_expr: str): target = self.world.get_location(target_name, self.player) if target_name in location_table else self.world.get_entrance(target_name, self.player) diff --git a/worlds/yoshisisland/Items.py b/worlds/yoshisisland/Items.py index c97678ed4ed4..f30c7317798f 100644 --- a/worlds/yoshisisland/Items.py +++ b/worlds/yoshisisland/Items.py @@ -75,7 +75,7 @@ class ItemData(NamedTuple): "1-Up": ItemData("Lives", 0x30208C, ItemClassification.filler, 0), "2-Up": ItemData("Lives", 0x30208D, ItemClassification.filler, 0), "3-Up": ItemData("Lives", 0x30208E, ItemClassification.filler, 0), - "10-Up": ItemData("Lives", 0x30208F, ItemClassification.filler, 5), + "10-Up": ItemData("Lives", 0x30208F, ItemClassification.useful, 5), "Bonus Consumables": ItemData("Events", None, ItemClassification.progression, 0), "Bandit Consumables": ItemData("Events", None, ItemClassification.progression, 0), "Bandit Watermelons": ItemData("Events", None, ItemClassification.progression, 0), diff --git a/worlds/yoshisisland/Options.py b/worlds/yoshisisland/Options.py index d02999309f61..07d0436f6fde 100644 --- a/worlds/yoshisisland/Options.py +++ b/worlds/yoshisisland/Options.py @@ -169,12 +169,12 @@ class BossShuffle(Toggle): class LevelShuffle(Choice): """Disabled: All levels will appear in their normal location. - Bosses Guranteed: All worlds will have a boss on -4 and -8. + Bosses Guaranteed: All worlds will have a boss on -4 and -8. Full: Worlds may have more than 2 or no bosses in them. Regardless of the setting, 6-8 and Extra stages are not shuffled.""" display_name = "Level Shuffle" option_disabled = 0 - option_bosses_guranteed = 1 + option_bosses_guaranteed = 1 option_full = 2 default = 0 diff --git a/worlds/yoshisisland/setup_game.py b/worlds/yoshisisland/setup_game.py index 000420a95b07..04a35f7657b7 100644 --- a/worlds/yoshisisland/setup_game.py +++ b/worlds/yoshisisland/setup_game.py @@ -274,7 +274,7 @@ def setup_gamevars(world: "YoshisIslandWorld") -> None: norm_start_lv.extend([0x24, 0x3C]) hard_start_lv.extend([0x1D, 0x3C]) - if world.options.level_shuffle != LevelShuffle.option_bosses_guranteed: + if world.options.level_shuffle != LevelShuffle.option_bosses_guaranteed: hard_start_lv.extend([0x07, 0x1B, 0x1F, 0x2B, 0x33, 0x37]) if not world.options.shuffle_midrings: easy_start_lv.extend([0x1B]) @@ -286,7 +286,7 @@ def setup_gamevars(world: "YoshisIslandWorld") -> None: if world.options.level_shuffle: world.global_level_list.remove(starting_level) world.random.shuffle(world.global_level_list) - if world.options.level_shuffle == LevelShuffle.option_bosses_guranteed: + if world.options.level_shuffle == LevelShuffle.option_bosses_guaranteed: for i in range(11): world.global_level_list = [item for item in world.global_level_list if item not in boss_lv]