Skip to content

Commit 0fb3b4a

Browse files
ZiktofelMatthewMarinets
authored andcommitted
SC2: 0.4.3 bugfixes (ArchipelagoMW#2273)
Co-authored-by: Matthew <matthew.marinets@gmail.com>
1 parent 577d224 commit 0fb3b4a

File tree

6 files changed

+41
-25
lines changed

6 files changed

+41
-25
lines changed

worlds/sc2wol/Client.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os.path
1010
import re
1111
import sys
12+
import tempfile
1213
import typing
1314
import queue
1415
import zipfile
@@ -286,6 +287,8 @@ async def server_auth(self, password_requested: bool = False):
286287
await super(SC2Context, self).server_auth(password_requested)
287288
await self.get_username()
288289
await self.send_connect()
290+
if self.ui:
291+
self.ui.first_check = True
289292

290293
def on_package(self, cmd: str, args: dict):
291294
if cmd in {"Connected"}:
@@ -1166,10 +1169,12 @@ def download_latest_release_zip(owner: str, repo: str, api_version: str, metadat
11661169

11671170
r2 = requests.get(download_url, headers=headers)
11681171
if r2.status_code == 200 and zipfile.is_zipfile(io.BytesIO(r2.content)):
1169-
with open(f"{repo}.zip", "wb") as fh:
1172+
tempdir = tempfile.gettempdir()
1173+
file = tempdir + os.sep + f"{repo}.zip"
1174+
with open(file, "wb") as fh:
11701175
fh.write(r2.content)
11711176
sc2_logger.info(f"Successfully downloaded {repo}.zip.")
1172-
return f"{repo}.zip", latest_metadata
1177+
return file, latest_metadata
11731178
else:
11741179
sc2_logger.warning(f"Status code: {r2.status_code}")
11751180
sc2_logger.warning("Download failed.")

worlds/sc2wol/Locations.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def get_locations(multiworld: Optional[MultiWorld], player: Optional[int]) -> Tu
6868
lambda state: state._sc2wol_has_common_unit(multiworld, player) and
6969
(logic_level > 0 and state._sc2wol_has_anti_air(multiworld, player)
7070
or state._sc2wol_has_competent_anti_air(multiworld, player))),
71-
LocationData("Evacuation", "Evacuation: First Chrysalis", SC2WOL_LOC_ID_OFFSET + 401, LocationType.BONUS),
72-
LocationData("Evacuation", "Evacuation: Second Chrysalis", SC2WOL_LOC_ID_OFFSET + 402, LocationType.BONUS,
71+
LocationData("Evacuation", "Evacuation: North Chrysalis", SC2WOL_LOC_ID_OFFSET + 401, LocationType.BONUS),
72+
LocationData("Evacuation", "Evacuation: West Chrysalis", SC2WOL_LOC_ID_OFFSET + 402, LocationType.BONUS,
7373
lambda state: state._sc2wol_has_common_unit(multiworld, player)),
74-
LocationData("Evacuation", "Evacuation: Third Chrysalis", SC2WOL_LOC_ID_OFFSET + 403, LocationType.BONUS,
74+
LocationData("Evacuation", "Evacuation: East Chrysalis", SC2WOL_LOC_ID_OFFSET + 403, LocationType.BONUS,
7575
lambda state: state._sc2wol_has_common_unit(multiworld, player)),
7676
LocationData("Evacuation", "Evacuation: Reach Hanson", SC2WOL_LOC_ID_OFFSET + 404, LocationType.MISSION_PROGRESS),
7777
LocationData("Evacuation", "Evacuation: Secret Resource Stash", SC2WOL_LOC_ID_OFFSET + 405, LocationType.BONUS),
@@ -419,7 +419,7 @@ def get_locations(multiworld: Optional[MultiWorld], player: Optional[int]) -> Tu
419419
lambda state: state._sc2wol_has_protoss_medium_units(multiworld, player)),
420420
LocationData("A Sinister Turn", "A Sinister Turn: Northeast Base", SC2WOL_LOC_ID_OFFSET + 2304, LocationType.MISSION_PROGRESS,
421421
lambda state: state._sc2wol_has_protoss_medium_units(multiworld, player)),
422-
LocationData("A Sinister Turn", "A Sinister Turn: Southeast Base", SC2WOL_LOC_ID_OFFSET + 2305, LocationType.MISSION_PROGRESS,
422+
LocationData("A Sinister Turn", "A Sinister Turn: Southwest Base", SC2WOL_LOC_ID_OFFSET + 2305, LocationType.MISSION_PROGRESS,
423423
lambda state: state._sc2wol_has_protoss_medium_units(multiworld, player)),
424424
LocationData("A Sinister Turn", "A Sinister Turn: Maar", SC2WOL_LOC_ID_OFFSET + 2306, LocationType.MISSION_PROGRESS,
425425
lambda state: logic_level > 0 or state._sc2wol_has_protoss_medium_units(multiworld, player)),

worlds/sc2wol/Options.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class FinalMap(Choice):
4141
4242
Vanilla mission order always ends with All in mission!
4343
44+
Warning: Using All-in with a short mission order (7 or fewer missions) is not recommended,
45+
as there might not be enough locations to place all the required items,
46+
any excess required items will be placed into the player's starting inventory!
47+
4448
This option is short-lived. It may be changed in the future
4549
"""
4650
display_name = "Final Map"
@@ -265,7 +269,6 @@ class MissionProgressLocations(LocationInclusion):
265269
Nothing: No rewards for this type of tasks, effectively disabling such locations
266270
267271
Note: Individual locations subject to plando are always enabled, so the plando can be placed properly.
268-
Warning: The generation may fail if too many locations are excluded by this way.
269272
See also: Excluded Locations, Item Plando (https://archipelago.gg/tutorial/Archipelago/plando/en#item-plando)
270273
"""
271274
display_name = "Mission Progress Locations"
@@ -282,7 +285,6 @@ class BonusLocations(LocationInclusion):
282285
Nothing: No rewards for this type of tasks, effectively disabling such locations
283286
284287
Note: Individual locations subject to plando are always enabled, so the plando can be placed properly.
285-
Warning: The generation may fail if too many locations are excluded by this way.
286288
See also: Excluded Locations, Item Plando (https://archipelago.gg/tutorial/Archipelago/plando/en#item-plando)
287289
"""
288290
display_name = "Bonus Locations"
@@ -300,7 +302,6 @@ class ChallengeLocations(LocationInclusion):
300302
Nothing: No rewards for this type of tasks, effectively disabling such locations
301303
302304
Note: Individual locations subject to plando are always enabled, so the plando can be placed properly.
303-
Warning: The generation may fail if too many locations are excluded by this way.
304305
See also: Excluded Locations, Item Plando (https://archipelago.gg/tutorial/Archipelago/plando/en#item-plando)
305306
"""
306307
display_name = "Challenge Locations"
@@ -317,7 +318,6 @@ class OptionalBossLocations(LocationInclusion):
317318
Nothing: No rewards for this type of tasks, effectively disabling such locations
318319
319320
Note: Individual locations subject to plando are always enabled, so the plando can be placed properly.
320-
Warning: The generation may fail if too many locations are excluded by this way.
321321
See also: Excluded Locations, Item Plando (https://archipelago.gg/tutorial/Archipelago/plando/en#item-plando)
322322
"""
323323
display_name = "Optional Boss Locations"

worlds/sc2wol/PoolFilter.py

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Callable, Dict, List, Set
22
from BaseClasses import MultiWorld, ItemClassification, Item, Location
3-
from .Items import get_full_item_list, spider_mine_sources, second_pass_placeable_items, filler_items
3+
from .Items import get_full_item_list, spider_mine_sources, second_pass_placeable_items, filler_items, \
4+
progressive_if_nco
45
from .MissionTables import no_build_regions_list, easy_regions_list, medium_regions_list, hard_regions_list,\
56
mission_orders, MissionInfo, alt_final_mission_locations, MissionPools
67
from .Options import get_option_value, MissionOrder, FinalMap, MissionProgressLocations, LocationInclusion
@@ -15,7 +16,7 @@
1516
]
1617

1718
BARRACKS_UNITS = {"Marine", "Medic", "Firebat", "Marauder", "Reaper", "Ghost", "Spectre"}
18-
FACTORY_UNITS = {"Hellion", "Vulture", "Goliath", "Diamondback", "Siege Tank", "Thor", "Predator", "Widow Mine"}
19+
FACTORY_UNITS = {"Hellion", "Vulture", "Goliath", "Diamondback", "Siege Tank", "Thor", "Predator", "Widow Mine", "Cyclone"}
1920
STARPORT_UNITS = {"Medivac", "Wraith", "Viking", "Banshee", "Battlecruiser", "Hercules", "Science Vessel", "Raven", "Liberator", "Valkyrie"}
2021

2122
PROTOSS_REGIONS = {"A Sinister Turn", "Echoes of the Future", "In Utter Darkness"}
@@ -93,7 +94,10 @@ def get_item_upgrades(inventory: List[Item], parent_item: Item or str):
9394
]
9495

9596

96-
def get_item_quantity(item):
97+
def get_item_quantity(item: Item, multiworld: MultiWorld, player: int):
98+
if (not get_option_value(multiworld, player, "nco_items")) \
99+
and item.name in progressive_if_nco:
100+
return 1
97101
return get_full_item_list()[item.name].quantity
98102

99103

@@ -138,13 +142,13 @@ def attempt_removal(item: Item) -> bool:
138142
if not all(requirement(self) for requirement in requirements):
139143
# If item cannot be removed, lock or revert
140144
self.logical_inventory.add(item.name)
141-
for _ in range(get_item_quantity(item)):
145+
for _ in range(get_item_quantity(item, self.multiworld, self.player)):
142146
locked_items.append(copy_item(item))
143147
return False
144148
return True
145-
149+
146150
# Limit the maximum number of upgrades
147-
maxUpgrad = get_option_value(self.multiworld, self.player,
151+
maxUpgrad = get_option_value(self.multiworld, self.player,
148152
"max_number_of_upgrades")
149153
if maxUpgrad != -1:
150154
unit_avail_upgrades = {}
@@ -197,15 +201,16 @@ def attempt_removal(item: Item) -> bool:
197201
# Don't process general upgrades, they may have been pre-locked per-level
198202
for item in items_to_lock:
199203
if item in inventory:
204+
item_quantity = inventory.count(item)
200205
# Unit upgrades, lock all levels
201-
for _ in range(inventory.count(item)):
206+
for _ in range(item_quantity):
202207
inventory.remove(item)
203208
if item not in locked_items:
204209
# Lock all the associated items if not already locked
205-
for _ in range(get_item_quantity(item)):
210+
for _ in range(item_quantity):
206211
locked_items.append(copy_item(item))
207-
if item in existing_items:
208-
existing_items.remove(item)
212+
if item in existing_items:
213+
existing_items.remove(item)
209214

210215
if self.min_units_per_structure > 0 and self.has_units_per_structure():
211216
requirements.append(lambda state: state.has_units_per_structure())
@@ -216,7 +221,13 @@ def attempt_removal(item: Item) -> bool:
216221

217222
while len(inventory) + len(locked_items) > inventory_size:
218223
if len(inventory) == 0:
219-
raise Exception("Reduced item pool generation failed - not enough locations available to place items.")
224+
# There are more items than locations and all of them are already locked due to YAML or logic.
225+
# Random items from locked ones will go to starting items
226+
self.multiworld.random.shuffle(locked_items)
227+
while len(locked_items) > inventory_size:
228+
item: Item = locked_items.pop()
229+
self.multiworld.push_precollected(item)
230+
break
220231
# Select random item from removable items
221232
item = self.multiworld.random.choice(inventory)
222233
# Cascade removals to associated items
@@ -245,7 +256,7 @@ def attempt_removal(item: Item) -> bool:
245256
for _ in range(inventory.count(transient_item)):
246257
inventory.remove(transient_item)
247258
if transient_item not in locked_items:
248-
for _ in range(get_item_quantity(transient_item)):
259+
for _ in range(get_item_quantity(transient_item, self.multiworld, self.player)):
249260
locked_items.append(copy_item(transient_item))
250261
if transient_item.classification in (ItemClassification.progression, ItemClassification.progression_skip_balancing):
251262
self.logical_inventory.add(transient_item.name)

worlds/sc2wol/Starcraft2.kv

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
markup: True
1212
halign: 'center'
1313
valign: 'middle'
14-
padding_x: 5
14+
padding: [5,0,5,0]
1515
markup: True
1616
outline_width: 1

worlds/sc2wol/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SC2WoLWorld(World):
3434

3535
game = "Starcraft 2 Wings of Liberty"
3636
web = Starcraft2WoLWebWorld()
37-
data_version = 4
37+
data_version = 5
3838

3939
item_name_to_id = {name: data.code for name, data in get_full_item_list().items()}
4040
location_name_to_id = {location.name: location.code for location in get_locations(None, None)}
@@ -46,7 +46,7 @@ class SC2WoLWorld(World):
4646
mission_req_table = {}
4747
final_mission_id: int
4848
victory_item: str
49-
required_client_version = 0, 3, 6
49+
required_client_version = 0, 4, 3
5050

5151
def __init__(self, multiworld: MultiWorld, player: int):
5252
super(SC2WoLWorld, self).__init__(multiworld, player)

0 commit comments

Comments
 (0)