From 98b0bf745603c278792da5b95f4c6ef493709e5e Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 15 May 2023 09:34:56 +0200 Subject: [PATCH] LttP: use local_early_items for Small Key HC in Standard Keyshuffle (#1799) --- worlds/alttp/__init__.py | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 5ea936cc..1ea927fb 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -247,6 +247,13 @@ class ALTTPWorld(World): player = self.player world = self.multiworld + if world.mode[player] == 'standard' \ + and world.smallkey_shuffle[player] \ + and world.smallkey_shuffle[player] != smallkey_shuffle.option_universal \ + and world.smallkey_shuffle[player] != smallkey_shuffle.option_own_dungeons \ + and world.smallkey_shuffle[player] != smallkey_shuffle.option_start_with: + self.multiworld.local_early_items[self.player]["Small Key (Hyrule Castle)"] = 1 + # system for sharing ER layouts self.er_seed = str(world.random.randint(0, 2 ** 64)) @@ -543,12 +550,8 @@ class ALTTPWorld(World): @classmethod def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fill_locations): trash_counts = {} - standard_keyshuffle_players = set() + for player in world.get_game_players("A Link to the Past"): - if world.mode[player] == 'standard' and world.smallkey_shuffle[player] \ - and world.smallkey_shuffle[player] != smallkey_shuffle.option_universal and \ - world.smallkey_shuffle[player] != smallkey_shuffle.option_own_dungeons: - standard_keyshuffle_players.add(player) if not world.ganonstower_vanilla[player] or \ world.logic[player] in {'owglitches', 'hybridglitches', "nologic"}: pass @@ -558,27 +561,6 @@ class ALTTPWorld(World): else: trash_counts[player] = world.random.randint(0, world.crystals_needed_for_gt[player] * 2) - # Make sure the escape small key is placed first in standard with key shuffle to prevent running out of spots - # TODO: this might be worthwhile to introduce as generic option for various games and then optimize it - if standard_keyshuffle_players: - viable = {} - for location in world.get_locations(): - if location.player in standard_keyshuffle_players \ - and location.item is None \ - and location.can_reach(world.state): - viable.setdefault(location.player, []).append(location) - - for player in standard_keyshuffle_players: - loc = world.random.choice(viable[player]) - key = world.create_item("Small Key (Hyrule Castle)", player) - loc.place_locked_item(key) - fill_locations.remove(loc) - world.random.shuffle(fill_locations) - # TODO: investigate not creating the key in the first place - progitempool[:] = [item for item in progitempool if - item.player not in standard_keyshuffle_players or - item.name != "Small Key (Hyrule Castle)"] - if trash_counts: locations_mapping = {player: [] for player in trash_counts} for location in fill_locations: