diff --git a/DoorShuffle.py b/DoorShuffle.py index 49af732c..ec14349f 100644 --- a/DoorShuffle.py +++ b/DoorShuffle.py @@ -15,6 +15,7 @@ from RoomData import DoorKind, PairedDoor, reset_rooms from DungeonGenerator import ExplorationState, convert_regions, generate_dungeon, pre_validate, determine_required_paths, drop_entrances from DungeonGenerator import create_dungeon_builders, split_dungeon_builder, simple_dungeon_builder, default_dungeon_entrances from DungeonGenerator import dungeon_portals, dungeon_drops, GenerationException +from DungeonGenerator import valid_region_to_explore as valid_region_to_explore_lim from KeyDoorShuffle import analyze_dungeon, build_key_layout, validate_key_layout, determine_prize_lock from Utils import ncr, kth_combination @@ -1393,6 +1394,8 @@ def combine_layouts(recombinant_builders, dungeon_builders, entrances_map): dungeon_builders[recombine.name] = recombine +# todo: this allows cross-dungeon exploring via HC Ledge or Inaccessible Regions +# todo: @deprecated def valid_region_to_explore(region, world, player): return region and (region.type == RegionType.Dungeon or region.name in world.inaccessible_regions[player] @@ -1584,7 +1587,7 @@ okay_normals = [DoorKind.Normal, DoorKind.SmallKey, DoorKind.Bombable, DoorKind. def find_key_door_candidates(region, checked, world, player): - dungeon = region.dungeon + dungeon_name = region.dungeon.name candidates = [] checked_doors = list(checked) queue = deque([(region, None, None)]) @@ -1594,14 +1597,16 @@ def find_key_door_candidates(region, checked, world, player): d = ext.door if d and d.controller: d = d.controller - if d and not d.blocked and not d.entranceFlag and d.dest is not last_door and d.dest is not last_region and d not in checked_doors: + if d and not d.blocked and d.dest is not last_door and d.dest is not last_region and d not in checked_doors: valid = False - if 0 <= d.doorListPos < 4 and d.type in [DoorType.Interior, DoorType.Normal, DoorType.SpiralStairs]: + if (0 <= d.doorListPos < 4 and d.type in [DoorType.Interior, DoorType.Normal, DoorType.SpiralStairs] + and not d.entranceFlag): room = world.get_room(d.roomIndex, player) position, kind = room.doorList[d.doorListPos] - if d.type == DoorType.Interior: valid = kind in [DoorKind.Normal, DoorKind.SmallKey, DoorKind.Bombable, DoorKind.Dashable] + if valid and d.dest not in candidates: # interior doors are not separable yet + candidates.append(d.dest) elif d.type == DoorType.SpiralStairs: valid = kind in [DoorKind.StairKey, DoorKind.StairKey2, DoorKind.StairKeyLow] elif d.type == DoorType.Normal: @@ -1620,7 +1625,7 @@ def find_key_door_candidates(region, checked, world, player): if valid and d not in candidates: candidates.append(d) connected = ext.connected_region - if connected and (connected.type != RegionType.Dungeon or connected.dungeon == dungeon): + if valid_region_to_explore_lim(connected, dungeon_name, world, player): queue.append((ext.connected_region, d, current)) if d is not None: checked_doors.append(d) diff --git a/README.md b/README.md index 31ff824b..6cb67700 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,11 @@ Alternatively, run ```Gui.py``` for a simple graphical user interface. # Commonly Missed Things and Differences from other Randomizers +Most of these apply only when the door shuffle is not vanilla. + ### Starting Item -You start with a “Mirror Scroll”, a dumbed-down mirror that only works in dungeons, not the overworld and can’t erase blocks like the Mirror +You start with a “Mirror Scroll”, a dumbed-down mirror that only works in dungeons, not the overworld and can’t erase blocks like the Mirror. ### Navigation @@ -58,7 +60,7 @@ You start with a “Mirror Scroll”, a dumbed-down mirror that only works in du ### Boss Differences -* You have to find the attic floor and bomb it open and bring the maiden to the light to fight Blind. In cross dungeon door shuffle, the attic can be in any dungeon. If hints are on, there is a special one about a cracked floor. +* You have to find the attic floor and bomb it open and bring the maiden to the light to fight Blind. In cross dungeon door shuffle, the attic can be in any dungeon. If you bring the maiden to the boss arena, she will hint were the cracked floor can be found. If hints are on, there is a special one about the cracked floor. * GT Bosses do not respawn after killing them in this mode. * Enemizer change: The attic/maiden sequence is now active and required when Blind is the boss of Theives' Town even when bosses are shuffled. @@ -70,7 +72,7 @@ You start with a “Mirror Scroll”, a dumbed-down mirror that only works in du ### Misc -* Compass counts no longer function after you get the Triforce +* Compass counts no longer function after you get the Triforce (this is actually true in all randomizers) # Settings @@ -124,7 +126,7 @@ The rooms are left alone and it is up to the discretion of the player whether to #### Force -The two disjointed sections are forced to be in the same dungeon but the glitches are never logically required to complete that game. +The two disjointed sections are forced to be in the same dungeon but the glitches are never logically required to complete that game.cause then you would need time to check the map in a d ### Standardize Palettes (--standardize_palettes) No effect if door shuffle is not on crossed @@ -239,6 +241,45 @@ Arrow Capacity upgrades are now replaced by Rupees wherever it might end up. The Ten Arrows and 5 randomly selected Small Hearts or Blue Shields are replaced by the quiver item (represented by the Single Arrow in game.) 5 Red Potion refills are replaced by the Universal small key. It is assured that at least one shop sells Universal Small Keys. The quiver may thus not be found in shops. The quiver and small keys retain their original base price, but may be discounted. +## Logic Level + +### Overworld Glitches + +Set `--logic` to `owglitches` to make overworld glitches required in the logic. + +## Shuffle Links House + +In certain ER shuffles, (not dungeonssimple or dungeonsfulls), you can now control whether Links House is shuffled or remains vanilla. Previously, inverted seeds had this behavior and would shuffle links house, but now if will only do so if this is specified. Now, also works for open modes, but links house is never shuffled in standard mode. + +## Bomb Logic (--bombbag) + +When enabling this option, you do not start with bomb capacity but rather you must find 1 of 2 bomb bags. (They are represented by the +10 capacity item.) Bomb capacity upgrades are otherwise unavailable. + +## Reduce Flashing + +Accessibility option to reducing some flashing animations in the game. + +## Pseudo-boots + +Option to start with ability to dash, but not able to make any boots required logical checks or traversal. + +## SFX Shuffle (--shuffle_sfx) + +Shuffles a large portion of the sounds effects. Can be used with the adjuster. + +## Experimental Features + +The treasure check counter is turned on. Also, you will start as a bunny if your spawn point is in the dark world. + +## Triforce Hunt Settings + +A collection of settings to control the triforce piece pool. + +* --triforce_goal_min: Minimum number of pieces to collect to win +* --triforce_goal_max: Maximum number of pieces to collect to win +* --triforce_pool_min: Minimum number of pieces in item pool +* --triforce_pool_max: Maximum number of pieces in item pool +* --triforce_min_difference: Minimum difference between pool and goal to win ## Seed @@ -280,6 +321,30 @@ Include mobs and pots drop in the item pool. (default: not enabled) Includes shop locations in the item pool. +``` +--pseudoboots +``` + +Start with dash ability, but no way to use boots to accomplish checks + +``` +--shufflelinks +``` + +Whether to shuffle links house in most ER modes. + + +``` +--bombbag +``` +Need to find the bombbag upgrade to used bombs + +``` +--experimental +``` + +Enables experimental features + ``` --mixed_travel ``` @@ -290,4 +355,19 @@ How to handle certain glitches in crossed dungeon mode. (default: prevent) --standardize_palettes (mode) ``` -Whether to standardize dungeon palettes in crossed dungeon mode. (default: standardize) \ No newline at end of file +Whether to standardize dungeon palettes in crossed dungeon mode. (default: standardize) + +``` +--reduce_flashing +``` + +Reduces amount of flashing in some animations + +``` +--shuffle_sfx +``` + +Shuffles a bunch of the sounds effects + + + diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0b8bae71..4caa9c55 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -98,7 +98,7 @@ In multiworld, the districts chosen apply to all players. ## New Hints -Based on the district algorithm above (whether it is enabled or not,) new hints can appear stating that a district or dungeon is considered a "foolish" choice. The means there are no advancement items in that district (or that the district was not chosen if the district restriction is used). +Based on the district algorithm above (whether it is enabled or not,) new hints can appear about that district or dungeon. For each district and dungeon, it is evaluated whether it contains vital items and how many. If it has not any vital item, items then it moves onto useful items. Useful items are generally safeties or convenience items: shields, mails, half magic, bottles, medallions that aren't required, etc. If it contains none of those and is an overworld district, then it check for a couple more things. First, if dungeons are shuffled, it looks to see if any are in the district, if so, one of those dungeons is picked for the hint. Then, if connectors are shuffled, it checks to see if you can get to unique region through a connector in that district. If none of the above apply, the district or dungeon is considered completely foolish. At least two "foolish" districts are chosen and the rest are random. ### Overworld Map shows dungeon location @@ -150,6 +150,7 @@ Same as above but both small keys and bigs keys of the dungeon are not allowed o * 1.0.1.10 * More location count fixes * Add major_only algorithm to code + * Include 1.0.0.2 fixes * 1.0.1.9 * Every pot you pick up that wasn't part of the location pool does not count toward the location count * Fix for items spawning where a thrown pot was @@ -210,5 +211,14 @@ Same as above but both small keys and bigs keys of the dungeon are not allowed o #### Unstable +* 1.0.0.2 + * Include 1.0.1 fixes + * District hint rework * 1.0.0.1 - * Add Light Hype Fairy to bombbag mode as needing bombs \ No newline at end of file + * Add Light Hype Fairy to bombbag mode as needing bombs + +### From stable DoorDev + +* 1.0.1 + * Fixed a bug with key doors not detecting one side of an interior door + * Sprite selector fix for systems with SSL issues \ No newline at end of file diff --git a/Regions.py b/Regions.py index 85a7938a..7667b080 100644 --- a/Regions.py +++ b/Regions.py @@ -94,17 +94,17 @@ def create_regions(world, player): create_lw_region(player, 'Lake Hylia Island', ['Lake Hylia Island']), create_cave_region(player, 'Capacity Upgrade', 'the queen of fairies', ['Capacity Upgrade - Left', 'Capacity Upgrade - Right']), create_cave_region(player, 'Two Brothers House', 'a connector', None, ['Two Brothers House Exit (East)', 'Two Brothers House Exit (West)']), - create_lw_region(player, 'Maze Race Ledge', ['Maze Race'], ['Two Brothers House (West)']), + create_lw_region(player, 'Maze Race Ledge', ['Maze Race'], ['Two Brothers House (West)'], 'a race against time'), create_cave_region(player, '50 Rupee Cave', 'a cave with some cash'), - create_lw_region(player, 'Desert Ledge', ['Desert Ledge'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)']), + create_lw_region(player, 'Desert Ledge', ['Desert Ledge'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)'], 'the desert ledge'), create_lw_region(player, 'Desert Ledge (Northeast)', None, ['Checkerboard Cave']), create_lw_region(player, 'Desert Palace Stairs', None, ['Desert Palace Entrance (South)']), - create_lw_region(player, 'Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)']), - create_lw_region(player, 'Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks']), + create_lw_region(player, 'Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)'], 'a sandy vista'), + create_lw_region(player, 'Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks'], 'the desert ledge'), create_lw_region(player, 'Master Sword Meadow', ['Master Sword Pedestal']), create_cave_region(player, 'Lost Woods Gamble', 'a game of chance'), create_lw_region(player, 'Hyrule Castle Courtyard', None, ['Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Entrance (South)']), - create_lw_region(player, 'Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Agahnims Tower', 'Hyrule Castle Ledge Courtyard Drop']), + create_lw_region(player, 'Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Agahnims Tower', 'Hyrule Castle Ledge Courtyard Drop'], 'the castle rampart'), create_dungeon_region(player, 'Sewer Drop', 'a drop\'s exit', None, ['Sewer Drop']), # This exists only to be referenced for access checks create_cave_region(player, 'Old Man Cave', 'a connector', ['Old Man'], ['Old Man Cave Exit (East)']), @@ -114,7 +114,7 @@ def create_regions(world, player): create_lw_region(player, 'Death Mountain', None, ['Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave', 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)', 'Broken Bridge (West)', 'Death Mountain Teleporter']), create_cave_region(player, 'Death Mountain Return Cave (left)', 'a connector', None, ['Death Mountain Return Cave Exit (West)', 'Death Mountain Return Cave E']), create_cave_region(player, 'Death Mountain Return Cave (right)', 'a connector', None, ['Death Mountain Return Cave Exit (East)', 'Death Mountain Return Cave W']), - create_lw_region(player, 'Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)']), + create_lw_region(player, 'Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)'], 'a ledge in the foothills'), create_cave_region(player, 'Spectacle Rock Cave (Top)', 'a connector', ['Spectacle Rock Cave'], ['Spectacle Rock Cave Drop', 'Spectacle Rock Cave Exit (Top)']), create_cave_region(player, 'Spectacle Rock Cave (Bottom)', 'a connector', None, ['Spectacle Rock Cave Exit']), create_cave_region(player, 'Spectacle Rock Cave (Peak)', 'a connector', None, ['Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave Exit (Peak)']), @@ -181,10 +181,10 @@ def create_regions(world, player): create_cave_region(player, 'Red Shield Shop', 'the rare shop', ['Red Shield Shop - Left', 'Red Shield Shop - Middle', 'Red Shield Shop - Right']), create_cave_region(player, 'Dark Sanctuary Hint', 'a storyteller'), create_cave_region(player, 'Bumper Cave', 'a connector', None, ['Bumper Cave Exit (Bottom)', 'Bumper Cave Exit (Top)']), - create_dw_region(player, 'Bumper Cave Ledge', ['Bumper Cave Ledge'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)', 'Bumper Cave Ledge Mirror Spot']), + create_dw_region(player, 'Bumper Cave Ledge', ['Bumper Cave Ledge'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)', 'Bumper Cave Ledge Mirror Spot'], 'a ledge with an item'), create_dw_region(player, 'Skull Woods Forest', None, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', 'Skull Woods First Section Door', 'Skull Woods Second Section Door (East)']), - create_dw_region(player, 'Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section']), + create_dw_region(player, 'Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section'], 'a deep, dark forest'), create_dw_region(player, 'Dark Desert', None, ['Misery Mire', 'Mire Shed', 'Desert Ledge (Northeast) Mirror Spot', 'Desert Ledge Mirror Spot', 'Desert Palace Stairs Mirror Spot', 'Desert Palace Entrance (North) Mirror Spot', 'Dark Desert Hint', 'Dark Desert Fairy']), create_cave_region(player, 'Mire Shed', 'a cave with two chests', ['Mire Shed - Left', 'Mire Shed - Right']), @@ -192,8 +192,8 @@ def create_regions(world, player): create_dw_region(player, 'Dark Death Mountain (West Bottom)', None, ['Spike Cave', 'Spectacle Rock Mirror Spot', 'Dark Death Mountain Fairy']), create_dw_region(player, 'Dark Death Mountain (Top)', None, ['Dark Death Mountain Drop (East)', 'Dark Death Mountain Drop (West)', 'Ganons Tower', 'Superbunny Cave (Top)', 'Hookshot Cave', 'East Death Mountain (Top) Mirror Spot', 'Turtle Rock']), - create_dw_region(player, 'Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)', 'Mimic Cave Mirror Spot', 'Spiral Cave Mirror Spot']), - create_dw_region(player, 'Dark Death Mountain Isolated Ledge', None, ['Isolated Ledge Mirror Spot', 'Turtle Rock Isolated Ledge Entrance']), + create_dw_region(player, 'Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)', 'Mimic Cave Mirror Spot', 'Spiral Cave Mirror Spot'], 'a dark ledge'), + create_dw_region(player, 'Dark Death Mountain Isolated Ledge', None, ['Isolated Ledge Mirror Spot', 'Turtle Rock Isolated Ledge Entrance'], 'a dark vista'), create_dw_region(player, 'Dark Death Mountain (East Bottom)', None, ['Superbunny Cave (Bottom)', 'Cave Shop (Dark Death Mountain)', 'Fairy Ascension Mirror Spot']), create_cave_region(player, 'Superbunny Cave (Top)', 'a connector', ['Superbunny Cave - Top', 'Superbunny Cave - Bottom'], ['Superbunny Cave Exit (Top)']), create_cave_region(player, 'Superbunny Cave (Bottom)', 'a connector', None, ['Superbunny Cave Climb', 'Superbunny Cave Exit (Bottom)']), @@ -205,7 +205,7 @@ def create_regions(world, player): create_cave_region(player, 'Hookshot Cave (Back)', 'a connector', None, ['Hookshot Cave Back to Middle', 'Hookshot Cave Back Exit']), create_cave_region(player, 'Hookshot Cave (Middle)', 'a connector', None, ['Hookshot Cave Middle to Back', 'Hookshot Cave Middle to Front']), - create_dw_region(player, 'Death Mountain Floating Island (Dark World)', None, ['Floating Island Drop', 'Hookshot Cave Back Entrance', 'Floating Island Mirror Spot']), + create_dw_region(player, 'Death Mountain Floating Island (Dark World)', None, ['Floating Island Drop', 'Hookshot Cave Back Entrance', 'Floating Island Mirror Spot'], 'a dark island'), create_lw_region(player, 'Death Mountain Floating Island (Light World)', ['Floating Island']), create_dw_region(player, 'Turtle Rock (Top)', None, ['Turtle Rock Drop']), create_lw_region(player, 'Mimic Cave Ledge', None, ['Mimic Cave']), @@ -904,12 +904,12 @@ def create_menu_region(player, name, locations=None, exits=None): return _create_region(player, name, RegionType.Menu, 'Menu', locations, exits) -def create_lw_region(player, name, locations=None, exits=None): - return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits) +def create_lw_region(player, name, locations=None, exits=None, hint='Light World'): + return _create_region(player, name, RegionType.LightWorld, hint, locations, exits) -def create_dw_region(player, name, locations=None, exits=None): - return _create_region(player, name, RegionType.DarkWorld, 'Dark World', locations, exits) +def create_dw_region(player, name, locations=None, exits=None, hint='Dark World'): + return _create_region(player, name, RegionType.DarkWorld, hint, locations, exits) def create_cave_region(player, name, hint='Hyrule', locations=None, exits=None): diff --git a/Rom.py b/Rom.py index 31879821..ffeef339 100644 --- a/Rom.py +++ b/Rom.py @@ -2274,29 +2274,60 @@ def write_strings(rom, world, player, team): else: tt[hint_locations.pop(0)] = this_hint - if world.algorithm != 'district': - hint_candidates = [] - for name, district in world.districts[player].items(): - foolish = True - for loc_name in district.locations: - location = world.get_location(loc_name, player) - if location.item.advancement: - foolish = False - break - if foolish: - hint_candidates.append(f'{name} is a foolish choice') - foolish_choice_hints = min(len(hint_candidates), len(hint_locations)) - for i in range(0, foolish_choice_hints): - tt[hint_locations.pop(0)] = hint_candidates.pop(0) - if world.algorithm == 'district': - hint_candidates = [] - for name, district in world.districts[player].items(): - if name not in world.item_pool_config.recorded_choices and not district.sphere_one: - hint_candidates.append(f'{name} is a foolish choice') - random.shuffle(hint_candidates) - foolish_choice_hints = min(len(hint_candidates), len(hint_locations)) - for i in range(0, foolish_choice_hints): - tt[hint_locations.pop(0)] = hint_candidates.pop(0) + hint_candidates = [] + for name, district in world.districts[player].items(): + hint_type = 'foolish' + choice_set = set() + item_count, item_type = 0, 'useful' + for loc_name in district.locations: + location_item = world.get_location(loc_name, player).item + if location_item.advancement: + if 'Heart Container' in location_item.name: + continue + itm_type = 'useful' if useful_item_for_hint(location_item, world) else 'vital' + hint_type = 'path' + if item_type == itm_type: + choice_set.add(location_item) + item_count += 1 + elif itm_type == 'vital': + item_type = 'vital' + item_count = 1 + choice_set.clear() + choice_set.add(location_item) + if hint_type == 'foolish': + if district.dungeons and world.shuffle[player] != 'vanilla': + choice_set.update(district.dungeons) + hint_type = 'dungeon_path' + elif district.access_points and world.shuffle[player] not in ['vanilla', 'dungeonssimple', + 'dungeonsfull']: + choice_set.update([x.hint_text for x in district.access_points]) + hint_type = 'connector' + if hint_type == 'foolish': + hint_candidates.append((hint_type, f'{name} is a foolish choice')) + elif hint_type == 'dungeon_path': + choices = sorted(list(choice_set)) + dungeon_choice = random.choice(choices) # prefer required dungeons... + hint_candidates.append((hint_type, f'{name} is on the path to {dungeon_choice}')) + elif hint_type == 'connector': + choices = sorted(list(choice_set)) + access_point = random.choice(choices) # prefer required access... + hint_candidates.append((hint_type, f'{name} can reach {access_point}')) + elif hint_type == 'path': + if item_count == 1: + the_item = text_for_item(next(iter(choice_set)), world, player, team) + hint_candidates.append((hint_type, f'{name} conceals {the_item}')) + else: + hint_candidates.append((hint_type, f'{name} conceals {item_count} {item_type} items')) + district_hints = min(len(hint_candidates), len(hint_locations)) + random.shuffle(hint_candidates) + hint_candidates.sort(key=lambda x: 1 if x[0] == 'foolish' else 0) + foolish_only = min(2, district_hints) # 2 foolish only + for i in range(0, foolish_only): + tt[hint_locations.pop(0)] = hint_candidates.pop(0)[1] + random.shuffle(hint_candidates) + district_hints -= foolish_only # the rest can be anything + for i in range(0, district_hints): + tt[hint_locations.pop(0)] = hint_candidates.pop(0)[1] if len(hint_locations) > 0: # All remaining hint slots are filled with junk hints. It is done this way to ensure the same junk hint # isn't selected twice. @@ -2450,6 +2481,25 @@ def write_strings(rom, world, player, team): rom.write_bytes(0x181500, data) rom.write_bytes(0x76CC0, [byte for p in pointers for byte in [p & 0xFF, p >> 8 & 0xFF]]) + +useful_item_names = { + 'Mushroom', 'Shovel', 'Magic Powder', 'Progressive Shield', 'Progressive Armor', 'Blue Mail', 'Red Mail', + 'Mirror Shield', 'Blue Boomerang', 'Red Boomerang', 'Bug Catching Net', 'Cane of Byrna', 'Cape', + 'Magic Upgrade (1/2)', 'Magic Upgrade (1/4)', 'Ether', 'Quake'} + + +def useful_item_for_hint(item, world): + return 'Bottle' in item.name or (item.name in useful_item_names + and item.name not in world.required_medallions[item.player]) + + +def text_for_item(item, world, player, team): + if item.player == player: + return item.hint_text + else: + return f'{item.hint_text} for {world.player_names[item.player][team]}' + + def set_inverted_mode(world, player, rom): rom.write_byte(snes_to_pc(0x0283E0), 0xF0) # residual portals rom.write_byte(snes_to_pc(0x02B34D), 0xF0) diff --git a/Utils.py b/Utils.py index f84ec6f4..a307a6cd 100644 --- a/Utils.py +++ b/Utils.py @@ -131,7 +131,7 @@ def kth_combination(k, l, r): def ncr(n, r): - if r == 0: + if r == 0 or r >= n: return 1 return factorial(n) // factorial(r) // factorial(n-r) diff --git a/source/item/District.py b/source/item/District.py index b6f1ca9d..b4e2aec0 100644 --- a/source/item/District.py +++ b/source/item/District.py @@ -13,6 +13,9 @@ class District(object): self.entrances = entrances if entrances else [] self.sphere_one = False + self.dungeons = set() + self.access_points = set() + def create_districts(world): world.districts = {} @@ -26,14 +29,14 @@ def create_district_helper(world, player): kak_locations = {'Bottle Merchant', 'Kakariko Tavern', 'Maze Race'} nw_lw_locations = {'Mushroom', 'Master Sword Pedestal'} central_lw_locations = {'Sunken Treasure', 'Flute Spot'} - desert_locations = {'Purple Chest', 'Desert Ledge'} - lake_locations = {'Hobo'} + desert_locations = {'Purple Chest', 'Desert Ledge', 'Bombos Tablet'} + lake_locations = {'Hobo', 'Lake Hylia Island'} east_lw_locations = {"Zora's Ledge", 'King Zora'} - lw_dm_locations = {'Old Man', 'Spectacle Rock', 'Ether Tablet'} + lw_dm_locations = {'Old Man', 'Spectacle Rock', 'Ether Tablet', 'Floating Island'} east_dw_locations = {'Pyramid', 'Catfish'} - south_dw_locations = {'Stumpy', 'Digging Game', 'Bombos Tablet', 'Lake Hylia Island'} + south_dw_locations = {'Stumpy', 'Digging Game'} voo_north_locations = {'Bumper Cave Ledge'} - ddm_locations = {'Floating Island'} + ddm_locations = set() kak_entrances = ['Kakariko Well Cave', 'Bat Cave Cave', 'Elder House (East)', 'Elder House (West)', 'Two Brothers House (East)', 'Two Brothers House (West)', 'Blinds Hideout', 'Chicken House', @@ -43,67 +46,48 @@ def create_district_helper(world, player): nw_lw_entrances = ['North Fairy Cave', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Sanctuary', 'Old Man Cave (West)', 'Death Mountain Return Cave (West)', 'Kings Grave', 'Lost Woods Gamble', 'Fortune Teller (Light)', 'Bonk Rock Cave', 'Lumberjack House', 'North Fairy Cave Drop', - 'Lost Woods Hideout Drop', 'Lumberjack Tree Tree', 'Sanctuary Grave'] + 'Lost Woods Hideout Drop', 'Lumberjack Tree Tree', 'Sanctuary Grave', 'Graveyard Cave'] central_lw_entrances = ['Links House', 'Hyrule Castle Entrance (South)', 'Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)', 'Agahnims Tower', 'Hyrule Castle Secret Entrance Stairs', - 'Dam', 'Bonk Fairy (Light)', 'Light Hype Fairy', 'Cave Shop (Lake Hylia)', - 'Lake Hylia Fortune Teller', 'Hyrule Castle Secret Entrance Drop'] + 'Dam', 'Bonk Fairy (Light)', 'Light Hype Fairy', 'Hyrule Castle Secret Entrance Drop', + 'Cave 45'] desert_entrances = ['Desert Palace Entrance (South)', 'Desert Palace Entrance (West)', 'Desert Palace Entrance (North)', 'Desert Palace Entrance (East)', 'Desert Fairy', - 'Aginahs Cave', '50 Rupee Cave'] - lake_entrances = ['Capacity Upgrade', 'Mini Moldorm Cave', 'Good Bee Cave', '20 Rupee Cave', 'Ice Rod Cave'] + 'Aginahs Cave', '50 Rupee Cave', 'Checkerboard Cave'] + lake_entrances = ['Capacity Upgrade', 'Mini Moldorm Cave', 'Good Bee Cave', '20 Rupee Cave', 'Ice Rod Cave', + 'Cave Shop (Lake Hylia)', 'Lake Hylia Fortune Teller'] east_lw_entrances = ['Eastern Palace', 'Waterfall of Wishing', 'Lake Hylia Fairy', 'Sahasrahlas Hut', 'Long Fairy Cave', 'Potion Shop'] lw_dm_entrances = ['Tower of Hera', 'Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave', 'Spectacle Rock Cave (Bottom)', 'Paradox Cave (Bottom)', 'Paradox Cave (Middle)', 'Paradox Cave (Top)', 'Fairy Ascension Cave (Bottom)', 'Fairy Ascension Cave (Top)', - 'Spiral Cave', 'Spiral Cave (Bottom)', 'Hookshot Fairy'] + 'Spiral Cave', 'Spiral Cave (Bottom)', 'Hookshot Fairy', 'Mimic Cave'] east_dw_entrances = ['Palace of Darkness', 'Pyramid Entrance', 'Pyramid Fairy', 'East Dark World Hint', 'Palace of Darkness Hint', 'Dark Lake Hylia Fairy', 'Dark World Potion Shop', 'Pyramid Hole'] south_dw_entrances = ['Ice Palace', 'Swamp Palace', 'Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Spike Cave', 'Dark Lake Hylia Ledge Hint', 'Hype Cave', - 'Bonk Fairy (Dark)', 'Archery Game', 'Big Bomb Shop', 'Dark Lake Hylia Shop', 'Cave 45'] + 'Bonk Fairy (Dark)', 'Archery Game', 'Big Bomb Shop', 'Dark Lake Hylia Shop', ] voo_north_entrances = ['Thieves Town', 'Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section', 'Bumper Cave (Bottom)', 'Bumper Cave (Top)', 'Brewery', 'C-Shaped House', 'Chest Game', 'Dark World Hammer Peg Cave', 'Red Shield Shop', 'Dark Sanctuary Hint', - 'Fortune Teller (Dark)', 'Dark World Shop', 'Dark World Lumberjack Shop', 'Graveyard Cave', + 'Fortune Teller (Dark)', 'Dark World Shop', 'Dark World Lumberjack Shop', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (North)', 'Skull Woods Second Section Hole'] - mire_entrances = ['Misery Mire', 'Mire Shed', 'Dark Desert Hint', 'Dark Desert Fairy', 'Checkerboard Cave'] + mire_entrances = ['Misery Mire', 'Mire Shed', 'Dark Desert Hint', 'Dark Desert Fairy'] ddm_entrances = ['Turtle Rock', 'Dark Death Mountain Ledge (West)', 'Dark Death Mountain Ledge (East)', 'Turtle Rock Isolated Ledge Entrance', 'Superbunny Cave (Top)', 'Superbunny Cave (Bottom)', 'Hookshot Cave', 'Hookshot Cave Back Entrance', 'Ganons Tower', 'Spike Cave', - 'Cave Shop (Dark Death Mountain)', 'Dark Death Mountain Fairy', 'Mimic Cave'] + 'Cave Shop (Dark Death Mountain)', 'Dark Death Mountain Fairy'] if inverted: - south_dw_locations.remove('Bombos Tablet') - south_dw_locations.remove('Lake Hylia Island') - voo_north_locations.remove('Bumper Cave Ledge') - ddm_locations.remove('Floating Island') - desert_locations.add('Bombos Tablet') - lake_locations.add('Lake Hylia Island') - nw_lw_locations.add('Bumper Cave Ledge') - lw_dm_locations.add('Floating Island') - - south_dw_entrances.remove('Cave 45') - central_lw_entrances.append('Cave 45') - voo_north_entrances.remove('Graveyard Cave') - nw_lw_entrances.append('Graveyard Cave') - mire_entrances.remove('Checkerboard Cave') - desert_entrances.append('Checkerboard Cave') - ddm_entrances.remove('Mimic Cave') - lw_dm_entrances.append('Mimic Cave') - south_dw_entrances.remove('Big Bomb Shop') central_lw_entrances.append('Inverted Big Bomb Shop') central_lw_entrances.remove('Links House') south_dw_entrances.append('Inverted Links House') voo_north_entrances.remove('Dark Sanctuary Hint') voo_north_entrances.append('Inverted Dark Sanctuary') - voo_north_entrances.remove('Bumper Cave (Top)') - nw_lw_entrances.append('Bumper Cave (Top)') ddm_entrances.remove('Ganons Tower') central_lw_entrances.append('Inverted Ganons Tower') central_lw_entrances.remove('Agahnims Tower') @@ -116,7 +100,7 @@ def create_district_helper(world, player): districts['Kakariko'] = District('Kakariko', kak_locations, entrances=kak_entrances) districts['Northwest Hyrule'] = District('Northwest Hyrule', nw_lw_locations, entrances=nw_lw_entrances) districts['Central Hyrule'] = District('Central Hyrule', central_lw_locations, entrances=central_lw_entrances) - districts['Desert'] = District('Desert', desert_locations, entrances=desert_entrances) + districts['The Desert Area'] = District('Desert', desert_locations, entrances=desert_entrances) districts['Lake Hylia'] = District('Lake Hylia', lake_locations, entrances=lake_entrances) districts['Eastern Hyrule'] = District('Eastern Hyrule', east_lw_locations, entrances=east_lw_entrances) districts['Death Mountain'] = District('Death Mountain', lw_dm_locations, entrances=lw_dm_entrances) @@ -124,7 +108,7 @@ def create_district_helper(world, player): districts['South Dark World'] = District('South Dark World', south_dw_locations, entrances=south_dw_entrances) districts['Northwest Dark World'] = District('Northwest Dark World', voo_north_locations, entrances=voo_north_entrances) - districts['The Mire'] = District('The Mire', set(), entrances=mire_entrances) + districts['The Mire Area'] = District('The Mire', set(), entrances=mire_entrances) districts['Dark Death Mountain'] = District('Dark Death Mountain', ddm_locations, entrances=ddm_entrances) districts.update({x: District(x, set(), dungeon=x) for x in dungeon_table.keys()}) @@ -136,8 +120,9 @@ def resolve_districts(world): state = CollectionState(world) state.sweep_for_events() for player in range(1, world.players + 1): + # these are not static for OWR - but still important + inaccessible = inaccessible_regions_inv if world.mode[player] == 'inverted' else inaccessible_regions_std check_set = find_reachable_locations(state, player) - used_locations = {l for d in world.districts[player].values() for l in d.locations} for name, district in world.districts[player].items(): if district.dungeon: layout = world.dungeon_layouts[player][district.dungeon] @@ -153,12 +138,16 @@ def resolve_districts(world): visited.add(region) if region.type == RegionType.Cave: for location in region.locations: - if location.name not in used_locations and not location.item and location.real: + if not location.item and location.real: district.locations.add(location.name) - used_locations.add(location.name) for ext in region.exits: if ext.connected_region not in visited: queue.appendleft(ext.connected_region) + elif region.type == RegionType.Dungeon and region.dungeon: + district.dungeons.add(region.dungeon.name) + elif region.name in inaccessible: + district.access_points.add(region) + district.sphere_one = len(check_set.intersection(district.locations)) > 0 @@ -169,3 +158,12 @@ def find_reachable_locations(state, player): if location.can_reach(state) and not location.forced_item and location.real: check_set.add(location.name) return check_set + + +inaccessible_regions_std = {'Desert Palace Lone Stairs', 'Bumper Cave Ledge', 'Skull Woods Forest (West)', + 'Dark Death Mountain Ledge', 'Dark Death Mountain Isolated Ledge', + 'Death Mountain Floating Island (Dark World)'} + + +inaccessible_regions_inv = {'Desert Palace Lone Stairs', 'Maze Race Ledge', 'Desert Ledge', + 'Desert Palace Entrance (North) Spot', 'Hyrule Castle Ledge', 'Death Mountain Return Ledge'}