Skip to content

Commit

Permalink
SMZ3: 0.4.2 non local items fix (ArchipelagoMW#2212)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lordlou authored and Jouramie committed Feb 28, 2024
1 parent 90e00c0 commit 868a370
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions worlds/smz3/TotalSMZ3/Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions worlds/smz3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand All @@ -563,13 +562,15 @@ 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]]
if junkPoolIdx[i] not in toRemove and loc.can_fill(self.multiworld.state, candidate, False):
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)
Expand Down

0 comments on commit 868a370

Please sign in to comment.