Skip to content

Commit a3907e8

Browse files
authored
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.
1 parent 5c640c6 commit a3907e8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

worlds/smz3/TotalSMZ3/Item.py

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class Item:
181181
keycard = re.compile("^Card")
182182
smMap = re.compile("^SmMap")
183183

184+
def IsNameDungeonItem(item_name): return Item.dungeon.match(item_name)
184185
def IsDungeonItem(self): return self.dungeon.match(self.Type.name)
185186
def IsBigKey(self): return self.bigKey.match(self.Type.name)
186187
def IsKey(self): return self.key.match(self.Type.name)

worlds/smz3/__init__.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ def create_items(self):
221221
if (self.smz3World.Config.Keysanity):
222222
progressionItems = self.progression + self.dungeon + self.keyCardsItems + self.SmMapsItems
223223
else:
224-
progressionItems = self.progression
224+
progressionItems = self.progression
225+
# Dungeons items here are not in the itempool and will be prefilled locally so they must stay local
226+
self.multiworld.non_local_items[self.player].value -= frozenset(item_name for item_name in self.item_names if TotalSMZ3Item.Item.IsNameDungeonItem(item_name))
225227
for item in self.keyCardsItems:
226228
self.multiworld.push_precollected(SMZ3Item(item.Type.name, ItemClassification.filler, item.Type, self.item_name_to_id[item.Type.name], self.player, item))
227229

@@ -548,11 +550,8 @@ def write_spoiler(self, spoiler_handle: TextIO):
548550

549551
def JunkFillGT(self, factor):
550552
poolLength = len(self.multiworld.itempool)
551-
playerGroups = self.multiworld.get_player_groups(self.player)
552-
playerGroups.add(self.player)
553553
junkPoolIdx = [i for i in range(0, poolLength)
554-
if self.multiworld.itempool[i].classification in (ItemClassification.filler, ItemClassification.trap) and
555-
self.multiworld.itempool[i].player in playerGroups]
554+
if self.multiworld.itempool[i].classification in (ItemClassification.filler, ItemClassification.trap)]
556555
toRemove = []
557556
for loc in self.locations.values():
558557
# commenting this for now since doing a partial GT pre fill would allow for non SMZ3 progression in GT
@@ -563,13 +562,15 @@ def JunkFillGT(self, factor):
563562
poolLength = len(junkPoolIdx)
564563
# start looking at a random starting index and loop at start if no match found
565564
start = self.multiworld.random.randint(0, poolLength)
565+
itemFromPool = None
566566
for off in range(0, poolLength):
567567
i = (start + off) % poolLength
568568
candidate = self.multiworld.itempool[junkPoolIdx[i]]
569569
if junkPoolIdx[i] not in toRemove and loc.can_fill(self.multiworld.state, candidate, False):
570570
itemFromPool = candidate
571571
toRemove.append(junkPoolIdx[i])
572572
break
573+
assert itemFromPool is not None, "Can't find anymore item(s) to pre fill GT"
573574
self.multiworld.push_item(loc, itemFromPool, False)
574575
loc.event = False
575576
toRemove.sort(reverse = True)

0 commit comments

Comments
 (0)