From 868a370057de09092b8ba9498ba74dcd3ac85a92 Mon Sep 17 00:00:00 2001 From: lordlou <87331798+lordlou@users.noreply.github.com> Date: Sat, 30 Sep 2023 15:05:07 -0400 Subject: [PATCH] SMZ3: 0.4.2 non local items fix (#2212) fixed generation failure when using non_local_items set to "Everything" For this, GT prefill now allows non local non progression items to be placed. --- worlds/smz3/TotalSMZ3/Item.py | 1 + worlds/smz3/__init__.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/worlds/smz3/TotalSMZ3/Item.py b/worlds/smz3/TotalSMZ3/Item.py index b4fc9d592550..28e9658ce1d0 100644 --- a/worlds/smz3/TotalSMZ3/Item.py +++ b/worlds/smz3/TotalSMZ3/Item.py @@ -181,6 +181,7 @@ class Item: keycard = re.compile("^Card") smMap = re.compile("^SmMap") + def IsNameDungeonItem(item_name): return Item.dungeon.match(item_name) def IsDungeonItem(self): return self.dungeon.match(self.Type.name) def IsBigKey(self): return self.bigKey.match(self.Type.name) def IsKey(self): return self.key.match(self.Type.name) diff --git a/worlds/smz3/__init__.py b/worlds/smz3/__init__.py index 79ba17db82b1..e2eb2ac80a13 100644 --- a/worlds/smz3/__init__.py +++ b/worlds/smz3/__init__.py @@ -221,7 +221,9 @@ def create_items(self): if (self.smz3World.Config.Keysanity): progressionItems = self.progression + self.dungeon + self.keyCardsItems + self.SmMapsItems else: - progressionItems = self.progression + progressionItems = self.progression + # Dungeons items here are not in the itempool and will be prefilled locally so they must stay local + self.multiworld.non_local_items[self.player].value -= frozenset(item_name for item_name in self.item_names if TotalSMZ3Item.Item.IsNameDungeonItem(item_name)) for item in self.keyCardsItems: self.multiworld.push_precollected(SMZ3Item(item.Type.name, ItemClassification.filler, item.Type, self.item_name_to_id[item.Type.name], self.player, item)) @@ -548,11 +550,8 @@ def write_spoiler(self, spoiler_handle: TextIO): def JunkFillGT(self, factor): poolLength = len(self.multiworld.itempool) - playerGroups = self.multiworld.get_player_groups(self.player) - playerGroups.add(self.player) junkPoolIdx = [i for i in range(0, poolLength) - if self.multiworld.itempool[i].classification in (ItemClassification.filler, ItemClassification.trap) and - self.multiworld.itempool[i].player in playerGroups] + if self.multiworld.itempool[i].classification in (ItemClassification.filler, ItemClassification.trap)] toRemove = [] for loc in self.locations.values(): # commenting this for now since doing a partial GT pre fill would allow for non SMZ3 progression in GT @@ -563,6 +562,7 @@ def JunkFillGT(self, factor): poolLength = len(junkPoolIdx) # start looking at a random starting index and loop at start if no match found start = self.multiworld.random.randint(0, poolLength) + itemFromPool = None for off in range(0, poolLength): i = (start + off) % poolLength candidate = self.multiworld.itempool[junkPoolIdx[i]] @@ -570,6 +570,7 @@ def JunkFillGT(self, factor): itemFromPool = candidate toRemove.append(junkPoolIdx[i]) break + assert itemFromPool is not None, "Can't find anymore item(s) to pre fill GT" self.multiworld.push_item(loc, itemFromPool, False) loc.event = False toRemove.sort(reverse = True)