Skip to content

Commit 1e205f9

Browse files
Landstalker: Fixed rare generation issues (#3353)
Co-authored-by: Fabian Dill <[email protected]>
1 parent 97c9c53 commit 1e205f9

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

worlds/landstalker/Hints.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def generate_lithograph_hint(world: "LandstalkerWorld"):
3030
jewel_items = world.jewel_items
3131

3232
for item in jewel_items:
33+
if item.location is None:
34+
continue
35+
3336
# Jewel hints are composed of 4 'words' shuffled randomly:
3437
# - the name of the player whose world contains said jewel (if not ours)
3538
# - the color of the jewel (if relevant)
@@ -61,7 +64,7 @@ def generate_random_hints(world: "LandstalkerWorld"):
6164
excluded_items = ["Life Stock", "EkeEke"]
6265

6366
progression_items = [item for item in multiworld.itempool if item.advancement and
64-
item.name not in excluded_items]
67+
item.name not in excluded_items and item.location is not None]
6568

6669
local_own_progression_items = [item for item in progression_items if item.player == this_player
6770
and item.location.player == this_player]

worlds/landstalker/Locations.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Dict, Optional
22

3-
from BaseClasses import Location
3+
from BaseClasses import Location, ItemClassification, Item
44
from .Regions import LandstalkerRegion
55
from .data.item_source import ITEM_SOURCES_JSON
6+
from .data.world_path import WORLD_PATHS_JSON
67

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

32+
# Create fake event locations that will be used to determine if some key regions has been visited
33+
regions_with_entrance_checks = []
34+
for data in WORLD_PATHS_JSON:
35+
if "requiredNodes" in data:
36+
regions_with_entrance_checks.extend([region_id for region_id in data["requiredNodes"]])
37+
regions_with_entrance_checks = list(set(regions_with_entrance_checks))
38+
for region_id in regions_with_entrance_checks:
39+
region = regions_table[region_id]
40+
location = LandstalkerLocation(player, 'event_visited_' + region_id, None, region, "event")
41+
location.place_locked_item(Item("event_visited_" + region_id, ItemClassification.progression, None, player))
42+
region.locations.append(location)
43+
3144
# Create a specific end location that will contain a fake win-condition item
3245
end_location = LandstalkerLocation(player, "End", None, regions_table["end"], "reward")
3346
regions_table["end"].locations.append(end_location)

worlds/landstalker/Regions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create_regions(world: "LandstalkerWorld"):
3737
for code, region_data in WORLD_NODES_JSON.items():
3838
random_hint_name = None
3939
if "hints" in region_data:
40-
random_hint_name = multiworld.random.choice(region_data["hints"])
40+
random_hint_name = world.random.choice(region_data["hints"])
4141
region = LandstalkerRegion(code, region_data["name"], player, multiworld, random_hint_name)
4242
regions_table[code] = region
4343
multiworld.regions.append(region)

worlds/landstalker/Rules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

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

1515

1616
def _landstalker_has_health(state: CollectionState, player: int, health):

worlds/landstalker/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def set_rules(self):
204204
for location in self.multiworld.get_locations(self.player):
205205
if location.parent_region.name in excluded_regions:
206206
location.progress_type = LocationProgressType.EXCLUDED
207+
# We need to make that event non-progression since it would crash generation in reach_kazalt goal
208+
if location.item is not None and location.item.name == "event_visited_king_nole_labyrinth_raft_entrance":
209+
location.item.classification = ItemClassification.filler
207210

208211
def get_starting_health(self):
209212
spawn_id = self.options.spawn_region.current_key

0 commit comments

Comments
 (0)