Completionist mode

100% Locations logic fixes
This commit is contained in:
cassidoxa
2023-06-09 19:22:42 -04:00
parent b24c118572
commit 6d19f6c8d1
7 changed files with 63 additions and 12 deletions

View File

@@ -84,6 +84,7 @@ class World(object):
self.spoiler = Spoiler(self)
self.lamps_needed_for_dark_rooms = 1
self.pseudoboots = {player: False for player in range(1, players + 1)}
self.item_counter_hud = {player: False for player in range(1, players + 1)}
def intialize_regions(self):
for region in self.regions:

View File

@@ -55,7 +55,7 @@ def start():
Palace, to allow for an alternative to firerod.
Vanilla: Swords are in vanilla locations.
''')
parser.add_argument('--goal', default='ganon', const='ganon', nargs='?', choices=['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'],
parser.add_argument('--goal', default='ganon', const='ganon', nargs='?', choices=['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals', 'all_items', 'completionist'],
help='''\
Select completion goal. (default: %(default)s)
Ganon: Collect all crystals, beat Agahnim 2 then
@@ -66,6 +66,8 @@ def start():
Agahnim fights and then defeat Ganon.
Triforce Hunt: Places 30 Triforce Pieces in the world, collect
20 of them to beat the game.
All Items: Requires collecting 216 items to defeat Ganon.
Completionist: Same as above, plus All Dungeons
''')
parser.add_argument('--difficulty', default='normal', const='normal', nargs='?', choices=['normal', 'hard', 'expert'],
help='''\
@@ -240,6 +242,10 @@ def start():
Alternatively, can be a ALttP Rom patched with a Link
sprite that will be extracted.
''')
parser.add_argument('--huditemcounter', default=False, help='''\
Displays a (number of items collected) / (total items available) counter
on the HUD.
''', action='store_true')
parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true')
parser.add_argument('--gui', help='Launch the GUI', action='store_true')
parser.add_argument('--jsonout', action='store_true', help='''\

View File

@@ -127,7 +127,7 @@ difficulties = {
}
def generate_itempool(world, player):
if (world.difficulty not in ['normal', 'hard', 'expert'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals']
if (world.difficulty not in ['normal', 'hard', 'expert'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals', 'all_items', 'completionist']
or world.mode not in ['open', 'standard', 'inverted'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']):
raise NotImplementedError('Not supported yet')

View File

@@ -38,6 +38,10 @@ def main(args, seed=None):
if args.securerandom:
world.seed = None
if world.goal in ['all_items', 'completionist'] and world.accessibility != 'locations':
raise Exception("Goals requiring all items must use 'locations' accessibility")
if args.huditemcounter:
world.item_counter_hud = {player: True for player in range(1, world.players + 1)}
world.crystals_needed_for_ganon = random.randint(0, 7) if args.crystals_ganon == 'random' else int(args.crystals_ganon)
world.crystals_needed_for_gt = random.randint(0, 7) if args.crystals_gt == 'random' else int(args.crystals_gt)

14
Rom.py
View File

@@ -19,7 +19,7 @@ from EntranceShuffle import door_addresses
JAP10HASH = '03a63945398191337e896e5771f77173'
RANDOMIZERBASEHASH = '86370c0770e368b7f863c5b7399d93a6'
RANDOMIZERBASEHASH = '3ede1a12d9a8c6a915e45d60da8b4913'
class JsonRom(object):
@@ -901,6 +901,10 @@ def patch_rom(world, player, rom):
rom.write_byte(0x18003E, 0x02) # make ganon invincible until all dungeons are beat
elif world.goal in ['crystals']:
rom.write_byte(0x18003E, 0x04) # make ganon invincible until all crystals
elif world.goal in ['all_items']:
rom.write_byte(0x18003E, 0x0A) # make ganon invincible until all items
elif world.goal in ['completionist']:
rom.write_byte(0x18003E, 0x0B) # make ganon invincible until all items and dungeons
else:
rom.write_byte(0x18003E, 0x03) # make ganon invincible until all crystals and aga 2 are collected
@@ -1032,6 +1036,14 @@ def patch_rom(world, player, rom):
# fix trock doors for reverse entrances
if world.fix_trock_doors:
rom.initial_sram.pre_open_tr_bomb_doors() # preopen bombable exits
# write total item count and item counter hud mode
item_total = len(world.get_filled_locations()) - 18 # minus non-item locations
rom.write_int16(0x180196, item_total+1)
if world.item_counter_hud[player] and world.goal != 'triforcehunt':
rom.write_byte(0x180039, 0x01)
else:
rom.write_byte(0x180039, 0x00)
write_strings(rom, world, player)

View File

@@ -290,8 +290,9 @@ def global_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize', player))
for location in ['Tower of Hera - Boss', 'Tower of Hera - Big Chest', 'Tower of Hera - Compass Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Tower of Hera)', player)
# for location in ['Tower of Hera - Big Key Chest']:
# forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player)
if world.accessibility == 'locations':
for location in ['Tower of Hera - Big Key Chest']:
forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player)
set_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player))
add_rule(world.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player))
@@ -306,6 +307,9 @@ def global_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Prize', player))
for location in ['Swamp Palace - Entrance']:
forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player)
if world.accessibility == 'locations':
for location in ['Swamp Palace - Big Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player)
set_rule(world.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player))
set_rule(world.get_entrance('Blind Fight', player), lambda state: state.has_key('Small Key (Thieves Town)', player))
@@ -319,6 +323,9 @@ def global_rules(world, player):
forbid_item(world.get_location(location, player), 'Big Key (Thieves Town)', player)
for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Boss']:
forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player)
if world.accessibility == 'locations':
for location in ['Thieves\' Town - Big Chest']:
forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player)
set_rule(world.get_entrance('Skull Woods First Section South Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player))
set_rule(world.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player))
@@ -332,6 +339,9 @@ def global_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Prize', player))
for location in ['Skull Woods - Boss']:
forbid_item(world.get_location(location, player), 'Small Key (Skull Woods)', player)
if world.accessibility == 'locations':
for location in ['Skull Woods - Big Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Skull Woods)', player)
set_rule(world.get_entrance('Ice Palace Entrance Room', player), lambda state: state.can_melt_things(player))
set_rule(world.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player))
@@ -403,6 +413,9 @@ def global_rules(world, player):
set_rule(world.get_entrance('Palace of Darkness Maze Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss', player))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize', player))
if world.accessibility == 'locations':
for location in ['Palace of Darkness - Big Key Chest', 'Palace of Darkness - Harmless Hellway']:
forbid_item(world.get_location(location, player), 'Small Key (Palace of Darkness)', player)
# 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']
@@ -415,7 +428,7 @@ def global_rules(world, player):
set_rule(world.get_entrance('Ganons Tower (Map Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_name(state, 'Ganons Tower - Map Chest', player) in [('Big Key (Ganons Tower)', player), ('Small Key (Ganons Tower)', player)] and state.has_key('Small Key (Ganons Tower)', player, 3)))
if world.accessibility != 'locations':
set_always_allow(world.get_location('Ganons Tower - Map Chest', player), lambda state, item: item.name == 'Small Key (Ganons Tower)' and item.player == player and state.has_key('Small Key (Ganons Tower)', player, 3))
else:
elif world.accessibility == 'locations':
forbid_item(world.get_location('Ganons Tower - Map Chest', player), 'Small Key (Ganons Tower)', player)
# It is possible to need more than 2 keys to get through this entrance if you spend keys elsewhere. We reflect this in the chest requirements.
@@ -685,8 +698,9 @@ def inverted_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize', player))
for location in ['Tower of Hera - Boss', 'Tower of Hera - Big Chest', 'Tower of Hera - Compass Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Tower of Hera)', player)
# for location in ['Tower of Hera - Big Key Chest']:
# forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player)
if world.accessibility == 'locations':
for location in ['Tower of Hera - Big Key Chest']:
forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player)
set_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player))
add_rule(world.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player))
@@ -701,6 +715,9 @@ def inverted_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Prize', player))
for location in ['Swamp Palace - Entrance']:
forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player)
if world.accessibility == 'locations':
for location in ['Swamp Palace - Big Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player)
set_rule(world.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player))
set_rule(world.get_entrance('Blind Fight', player), lambda state: state.has_key('Small Key (Thieves Town)', player))
@@ -714,6 +731,9 @@ def inverted_rules(world, player):
forbid_item(world.get_location(location, player), 'Big Key (Thieves Town)', player)
for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Boss']:
forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player)
if world.accessibility == 'locations':
for location in ['Thieves\' Town - Big Chest']:
forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player)
set_rule(world.get_entrance('Skull Woods First Section South Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player))
set_rule(world.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player))
@@ -728,6 +748,9 @@ def inverted_rules(world, player):
set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Prize', player))
for location in ['Skull Woods - Boss']:
forbid_item(world.get_location(location, player), 'Small Key (Skull Woods)', player)
if world.accessibility == 'locations':
for location in ['Skull Woods - Big Chest']:
forbid_item(world.get_location(location, player), 'Big Key (Skull Woods)', player)
set_rule(world.get_entrance('Ice Palace Entrance Room', player), lambda state: state.can_melt_things(player))
set_rule(world.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player))
@@ -800,6 +823,9 @@ def inverted_rules(world, player):
set_rule(world.get_entrance('Palace of Darkness Maze Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss', player))
set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize', player))
if world.accessibility == 'locations':
for location in ['Palace of Darkness - Big Key Chest', 'Palace of Darkness - Harmless Hellway']:
forbid_item(world.get_location(location, player), 'Small Key (Palace of Darkness)', player)
# 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']
@@ -812,7 +838,7 @@ def inverted_rules(world, player):
set_rule(world.get_entrance('Ganons Tower (Map Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_name(state, 'Ganons Tower - Map Chest', player) in [('Big Key (Ganons Tower)', player), ('Small Key (Ganons Tower)', player)] and state.has_key('Small Key (Ganons Tower)', player, 3)))
if world.accessibility != 'locations':
set_always_allow(world.get_location('Ganons Tower - Map Chest', player), lambda state, item: item.name == 'Small Key (Ganons Tower)' and item.player == player and state.has_key('Small Key (Ganons Tower)', player, 3))
else:
elif world.accessibility == 'locations':
forbid_item(world.get_location('Ganons Tower - Map Chest', player), 'Small Key (Ganons Tower)', player)
# It is possible to need more than 2 keys to get through this entance if you spend keys elsewhere. We reflect this in the chest requirements.
@@ -998,7 +1024,9 @@ def standard_rules(world, player):
def set_trock_key_rules(world, player):
if world.accessibility == 'locations':
for location in ['Turtle Rock - Big Key Chest']:
forbid_item(world.get_location(location, player), 'Small Key (Turtle Rock)', player)
# First set all relevant locked doors to impassible.
for entrance in ['Turtle Rock Dark Room Staircase', 'Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)', 'Turtle Rock Pokey Room']:
@@ -1027,7 +1055,7 @@ def set_trock_key_rules(world, player):
# No matter what, the Big Key cannot be in the Big Chest or held by Trinexx.
non_big_key_locations = ['Turtle Rock - Big Chest', 'Turtle Rock - Boss']
def tr_big_key_chest_keys_needed(state):
def tr_big_key_chest_keys_needed(world, state):
# This function handles the key requirements for the TR Big Chest in the situations it having the Big Key should logically require 2 keys, small key
# should logically require no keys, and anything else should logically require 4 keys.
item = item_name(state, 'Turtle Rock - Big Key Chest', player)

File diff suppressed because one or more lines are too long