Fix inaccessible key locations being randomized
@@ -323,14 +323,14 @@ class Randomizer:
# Place progress items.
while self.logic.unplaced_progress_items:
- accessible_locations = self.logic.get_accessible_remaining_locations()
+ accessible_undone_locations = self.logic.get_accessible_remaining_locations()
- if not accessible_locations:
+ if not accessible_undone_locations:
raise Exception("No locations left to place progress items!")
# If the player gained access to any unrandomized locations, we need to give them those items.
newly_accessible_unrandomized_locations = [
- loc for loc in accessible_locations
+ loc for loc in accessible_undone_locations
if loc in self.logic.unrandomized_item_locations
]
if newly_accessible_unrandomized_locations:
@@ -343,9 +343,15 @@ class Randomizer:
# TODO: prioritize useful items over useless items
item_name = random.choice(self.logic.unplaced_progress_items)
- location_name = random.choice(accessible_locations)
+ location_name = random.choice(accessible_undone_locations)
self.logic.set_location_to_item(location_name, item_name)
+ # Make sure locations that shouldn't be randomized aren't, even if above logic missed them for some reason.
+ for location_name in self.logic.unrandomized_item_locations:
+ if location_name in self.logic.remaining_item_locations:
+ unrandomized_item_name = self.logic.item_locations[location_name]["Original item"]
+ self.logic.set_location_to_item(location_name, unrandomized_item_name)
+
# Place unique non-progress items.
while self.logic.unplaced_nonprogress_items:
item_name = random.choice(self.logic.unplaced_nonprogress_items)
