Skip to content

Commit afe9e12

Browse files
authored
Raft: Fix item prefilling (#1878)
1 parent a75159b commit afe9e12

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

worlds/raft/__init__.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ def create_items(self):
5050
maximumResourcePackAmount = max(minRPSpecified, maxRPSpecified)
5151
# Generate item pool
5252
pool = []
53+
frequencyItems = []
5354
for item in item_table:
5455
raft_item = self.create_item_replaceAsNecessary(item["name"])
56+
if "Frequency" in item["name"]:
57+
frequencyItems.append(raft_item)
5558
pool.append(raft_item)
59+
if self.multiworld.island_frequency_locations[self.player].value <= 3:
60+
if not hasattr(self.multiworld, "raft_frequencyItemsPerPlayer"):
61+
self.multiworld.raft_frequencyItemsPerPlayer = {}
62+
self.multiworld.raft_frequencyItemsPerPlayer[self.player] = frequencyItems
5663

5764
extraItemNamePool = []
5865
extras = len(location_table) - len(item_table) - 1 # Victory takes up 1 unaccounted-for slot
@@ -66,6 +73,16 @@ def create_items(self):
6673
dupeItemPool = item_table.copy()
6774
# Remove frequencies if necessary
6875
if self.multiworld.island_frequency_locations[self.player].value != 5: # Not completely random locations
76+
# If we let frequencies stay in with progressive-frequencies, the progressive-frequency item
77+
# will be included 7 times. This is a massive flood of progressive-frequency items, so we
78+
# instead add progressive-frequency as its own item a smaller amount of times to prevent
79+
# flooding the duplicate item pool with them.
80+
if self.multiworld.island_frequency_locations[self.player].value == 4:
81+
for _ in range(2):
82+
# Progressives are not in item_pool, need to create faux item for duplicate item pool
83+
# This can still be filtered out later by duplicate_items setting
84+
dupeItemPool.append({ "name": "progressive-frequency", "progression": True }) # Progressive frequencies need to be included
85+
# Always remove non-progressive Frequency items
6986
dupeItemPool = (itm for itm in dupeItemPool if "Frequency" not in itm["name"])
7087

7188
# Remove progression or non-progression items if necessary
@@ -129,15 +146,15 @@ def collect_item(self, state, item, remove=False):
129146
return super(RaftWorld, self).collect_item(state, item, remove)
130147

131148
def pre_fill(self):
132-
if self.multiworld.island_frequency_locations[self.player] == 0:
149+
if self.multiworld.island_frequency_locations[self.player] == 0: # Vanilla
133150
self.setLocationItem("Radio Tower Frequency to Vasagatan", "Vasagatan Frequency")
134151
self.setLocationItem("Vasagatan Frequency to Balboa", "Balboa Island Frequency")
135152
self.setLocationItem("Relay Station quest", "Caravan Island Frequency")
136153
self.setLocationItem("Caravan Island Frequency to Tangaroa", "Tangaroa Frequency")
137154
self.setLocationItem("Tangaroa Frequency to Varuna Point", "Varuna Point Frequency")
138155
self.setLocationItem("Varuna Point Frequency to Temperance", "Temperance Frequency")
139156
self.setLocationItem("Temperance Frequency to Utopia", "Utopia Frequency")
140-
elif self.multiworld.island_frequency_locations[self.player] == 1:
157+
elif self.multiworld.island_frequency_locations[self.player] == 1: # Random on island
141158
self.setLocationItemFromRegion("RadioTower", "Vasagatan Frequency")
142159
self.setLocationItemFromRegion("Vasagatan", "Balboa Island Frequency")
143160
self.setLocationItemFromRegion("BalboaIsland", "Caravan Island Frequency")
@@ -173,9 +190,9 @@ def pre_fill(self):
173190
else:
174191
currentLocation = availableLocationList[0] # Utopia (only one left in list)
175192
availableLocationList.remove(currentLocation)
176-
if self.multiworld.island_frequency_locations[self.player] == 2:
193+
if self.multiworld.island_frequency_locations[self.player] == 2: # Random island order
177194
self.setLocationItem(locationToVanillaFrequencyLocationMap[previousLocation], locationToFrequencyItemMap[currentLocation])
178-
elif self.multiworld.island_frequency_locations[self.player] == 3:
195+
elif self.multiworld.island_frequency_locations[self.player] == 3: # Random on island random order
179196
self.setLocationItemFromRegion(previousLocation, locationToFrequencyItemMap[currentLocation])
180197
previousLocation = currentLocation
181198

@@ -184,12 +201,14 @@ def pre_fill(self):
184201
RaftItem("Victory", ItemClassification.progression, None, player=self.player))
185202

186203
def setLocationItem(self, location: str, itemName: str):
187-
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.itempool))
204+
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.raft_frequencyItemsPerPlayer[self.player]))
205+
self.multiworld.raft_frequencyItemsPerPlayer[self.player].remove(itemToUse)
188206
self.multiworld.itempool.remove(itemToUse)
189207
self.multiworld.get_location(location, self.player).place_locked_item(itemToUse)
190208

191209
def setLocationItemFromRegion(self, region: str, itemName: str):
192-
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.itempool))
210+
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.raft_frequencyItemsPerPlayer[self.player]))
211+
self.multiworld.raft_frequencyItemsPerPlayer[self.player].remove(itemToUse)
193212
self.multiworld.itempool.remove(itemToUse)
194213
location = random.choice(list(loc for loc in location_table if loc["region"] == region))
195214
self.multiworld.get_location(location["name"], self.player).place_locked_item(itemToUse)

0 commit comments

Comments
 (0)