Skip to content

Commit

Permalink
Landstalker: Fixed rare generation issues (ArchipelagoMW#3353)
Browse files Browse the repository at this point in the history
Co-authored-by: Fabian Dill <[email protected]>
  • Loading branch information
2 people authored and sflavelle committed Jun 20, 2024
1 parent ebf570e commit fb01ab5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion worlds/landstalker/Hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def generate_lithograph_hint(world: "LandstalkerWorld"):
jewel_items = world.jewel_items

for item in jewel_items:
if item.location is None:
continue

# Jewel hints are composed of 4 'words' shuffled randomly:
# - the name of the player whose world contains said jewel (if not ours)
# - the color of the jewel (if relevant)
Expand Down Expand Up @@ -61,7 +64,7 @@ def generate_random_hints(world: "LandstalkerWorld"):
excluded_items = ["Life Stock", "EkeEke"]

progression_items = [item for item in multiworld.itempool if item.advancement and
item.name not in excluded_items]
item.name not in excluded_items and item.location is not None]

local_own_progression_items = [item for item in progression_items if item.player == this_player
and item.location.player == this_player]
Expand Down
15 changes: 14 additions & 1 deletion worlds/landstalker/Locations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Dict, Optional

from BaseClasses import Location
from BaseClasses import Location, ItemClassification, Item
from .Regions import LandstalkerRegion
from .data.item_source import ITEM_SOURCES_JSON
from .data.world_path import WORLD_PATHS_JSON

BASE_LOCATION_ID = 4000
BASE_GROUND_LOCATION_ID = BASE_LOCATION_ID + 256
Expand All @@ -28,6 +29,18 @@ def create_locations(player: int, regions_table: Dict[str, LandstalkerRegion], n
new_location = LandstalkerLocation(player, data["name"], name_to_id_table[data["name"]], region, data["type"])
region.locations.append(new_location)

# Create fake event locations that will be used to determine if some key regions has been visited
regions_with_entrance_checks = []
for data in WORLD_PATHS_JSON:
if "requiredNodes" in data:
regions_with_entrance_checks.extend([region_id for region_id in data["requiredNodes"]])
regions_with_entrance_checks = list(set(regions_with_entrance_checks))
for region_id in regions_with_entrance_checks:
region = regions_table[region_id]
location = LandstalkerLocation(player, 'event_visited_' + region_id, None, region, "event")
location.place_locked_item(Item("event_visited_" + region_id, ItemClassification.progression, None, player))
region.locations.append(location)

# Create a specific end location that will contain a fake win-condition item
end_location = LandstalkerLocation(player, "End", None, regions_table["end"], "reward")
regions_table["end"].locations.append(end_location)
Expand Down
2 changes: 1 addition & 1 deletion worlds/landstalker/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_regions(world: "LandstalkerWorld"):
for code, region_data in WORLD_NODES_JSON.items():
random_hint_name = None
if "hints" in region_data:
random_hint_name = multiworld.random.choice(region_data["hints"])
random_hint_name = world.random.choice(region_data["hints"])
region = LandstalkerRegion(code, region_data["name"], player, multiworld, random_hint_name)
regions_table[code] = region
multiworld.regions.append(region)
Expand Down
2 changes: 1 addition & 1 deletion worlds/landstalker/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def _landstalker_has_visited_regions(state: CollectionState, player: int, regions):
return all([state.can_reach(region, None, player) for region in regions])
return all(state.has("event_visited_" + region.code, player) for region in regions)


def _landstalker_has_health(state: CollectionState, player: int, health):
Expand Down
3 changes: 3 additions & 0 deletions worlds/landstalker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def set_rules(self):
for location in self.multiworld.get_locations(self.player):
if location.parent_region.name in excluded_regions:
location.progress_type = LocationProgressType.EXCLUDED
# We need to make that event non-progression since it would crash generation in reach_kazalt goal
if location.item is not None and location.item.name == "event_visited_king_nole_labyrinth_raft_entrance":
location.item.classification = ItemClassification.filler

def get_starting_health(self):
spawn_id = self.options.spawn_region.current_key
Expand Down

0 comments on commit fb01ab5

Please sign in to comment.