Skip to content

Commit

Permalink
SC2: Adding race-swapping with 6 variant missions
Browse files Browse the repository at this point in the history
  • Loading branch information
EnvyDragon committed Jul 1, 2024
1 parent cb19c52 commit 143f9aa
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 25 deletions.
101 changes: 85 additions & 16 deletions worlds/sc2/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,39 @@ def get_locations(world: Optional['SC2World']) -> Tuple[LocationData, ...]:
LocationData("Liberation Day", "Liberation Day: Sixth Statue", SC2WOL_LOC_ID_OFFSET + 106, LocationType.VANILLA),
LocationData("Liberation Day", "Liberation Day: Special Delivery", SC2WOL_LOC_ID_OFFSET + 107, LocationType.EXTRA),
LocationData("Liberation Day", "Liberation Day: Transport", SC2WOL_LOC_ID_OFFSET + 108, LocationType.EXTRA),
LocationData("The Outlaws", "The Outlaws: Victory", SC2WOL_LOC_ID_OFFSET + 200, LocationType.VICTORY,
LocationData("The Outlaws (T)", "The Outlaws (Terran): Victory", SC2WOL_LOC_ID_OFFSET + 200, LocationType.VICTORY,
lambda state: logic.terran_early_tech(state)),
LocationData("The Outlaws", "The Outlaws: Rebel Base", SC2WOL_LOC_ID_OFFSET + 201, LocationType.VANILLA,
LocationData("The Outlaws (T)", "The Outlaws (Terran): Rebel Base", SC2WOL_LOC_ID_OFFSET + 201, LocationType.VANILLA,
lambda state: logic.terran_early_tech(state)),
LocationData("The Outlaws", "The Outlaws: North Resource Pickups", SC2WOL_LOC_ID_OFFSET + 202, LocationType.EXTRA,
LocationData("The Outlaws (T)", "The Outlaws (Terran): North Resource Pickups", SC2WOL_LOC_ID_OFFSET + 202, LocationType.EXTRA,
lambda state: logic.terran_early_tech(state)),
LocationData("The Outlaws", "The Outlaws: Bunker", SC2WOL_LOC_ID_OFFSET + 203, LocationType.VANILLA,
LocationData("The Outlaws (T)", "The Outlaws (Terran): Bunker", SC2WOL_LOC_ID_OFFSET + 203, LocationType.VANILLA,
lambda state: logic.terran_early_tech(state)),
LocationData("The Outlaws", "The Outlaws: Close Resource Pickups", SC2WOL_LOC_ID_OFFSET + 204, LocationType.EXTRA),
LocationData("Zero Hour", "Zero Hour: Victory", SC2WOL_LOC_ID_OFFSET + 300, LocationType.VICTORY,
LocationData("The Outlaws (T)", "The Outlaws (Terran): Close Resource Pickups", SC2WOL_LOC_ID_OFFSET + 204, LocationType.EXTRA),
LocationData("Zero Hour (T)", "Zero Hour (Terran): Victory", SC2WOL_LOC_ID_OFFSET + 300, LocationType.VICTORY,
lambda state: logic.terran_common_unit(state) and
logic.terran_defense_rating(state, True) >= 2 and
(adv_tactics or logic.terran_basic_anti_air(state))),
LocationData("Zero Hour", "Zero Hour: First Group Rescued", SC2WOL_LOC_ID_OFFSET + 301, LocationType.VANILLA),
LocationData("Zero Hour", "Zero Hour: Second Group Rescued", SC2WOL_LOC_ID_OFFSET + 302, LocationType.VANILLA,
LocationData("Zero Hour (T)", "Zero Hour (Terran): First Group Rescued", SC2WOL_LOC_ID_OFFSET + 301, LocationType.VANILLA),
LocationData("Zero Hour (T)", "Zero Hour (Terran): Second Group Rescued", SC2WOL_LOC_ID_OFFSET + 302, LocationType.VANILLA,
lambda state: logic.terran_common_unit(state)),
LocationData("Zero Hour", "Zero Hour: Third Group Rescued", SC2WOL_LOC_ID_OFFSET + 303, LocationType.VANILLA,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Third Group Rescued", SC2WOL_LOC_ID_OFFSET + 303, LocationType.VANILLA,
lambda state: logic.terran_common_unit(state) and
logic.terran_defense_rating(state, True) >= 2),
LocationData("Zero Hour", "Zero Hour: First Hatchery", SC2WOL_LOC_ID_OFFSET + 304, LocationType.CHALLENGE,
LocationData("Zero Hour (T)", "Zero Hour (Terran): First Hatchery", SC2WOL_LOC_ID_OFFSET + 304, LocationType.CHALLENGE,
lambda state: logic.terran_competent_comp(state)),
LocationData("Zero Hour", "Zero Hour: Second Hatchery", SC2WOL_LOC_ID_OFFSET + 305, LocationType.CHALLENGE,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Second Hatchery", SC2WOL_LOC_ID_OFFSET + 305, LocationType.CHALLENGE,
lambda state: logic.terran_competent_comp(state)),
LocationData("Zero Hour", "Zero Hour: Third Hatchery", SC2WOL_LOC_ID_OFFSET + 306, LocationType.CHALLENGE,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Third Hatchery", SC2WOL_LOC_ID_OFFSET + 306, LocationType.CHALLENGE,
lambda state: logic.terran_competent_comp(state)),
LocationData("Zero Hour", "Zero Hour: Fourth Hatchery", SC2WOL_LOC_ID_OFFSET + 307, LocationType.CHALLENGE,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Fourth Hatchery", SC2WOL_LOC_ID_OFFSET + 307, LocationType.CHALLENGE,
lambda state: logic.terran_competent_comp(state)),
LocationData("Zero Hour", "Zero Hour: Ride's on its Way", SC2WOL_LOC_ID_OFFSET + 308, LocationType.EXTRA,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Ride's on its Way", SC2WOL_LOC_ID_OFFSET + 308, LocationType.EXTRA,
lambda state: logic.terran_common_unit(state)),
LocationData("Zero Hour", "Zero Hour: Hold Just a Little Longer", SC2WOL_LOC_ID_OFFSET + 309, LocationType.EXTRA,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Hold Just a Little Longer", SC2WOL_LOC_ID_OFFSET + 309, LocationType.EXTRA,
lambda state: logic.terran_common_unit(state) and
logic.terran_defense_rating(state, True) >= 2),
LocationData("Zero Hour", "Zero Hour: Cavalry's on the Way", SC2WOL_LOC_ID_OFFSET + 310, LocationType.EXTRA,
LocationData("Zero Hour (T)", "Zero Hour (Terran): Cavalry's on the Way", SC2WOL_LOC_ID_OFFSET + 310, LocationType.EXTRA,
lambda state: logic.terran_common_unit(state) and
logic.terran_defense_rating(state, True) >= 2),
LocationData("Evacuation", "Evacuation: Victory", SC2WOL_LOC_ID_OFFSET + 400, LocationType.VICTORY,
Expand Down Expand Up @@ -1622,6 +1622,75 @@ def get_locations(world: Optional['SC2World']) -> Tuple[LocationData, ...]:
lambda state: logic.end_game_requirement(state)),

# Mission Variants
# 10X/20X - Liberation Day
LocationData("The Outlaws (Z)", "The Outlaws (Zerg): Victory", SC2_RACESWAP_LOC_ID_OFFSET + 300, LocationType.VICTORY,
lambda state: logic.zerg_common_unit(state)),
LocationData("The Outlaws (Z)", "The Outlaws (Zerg): Rebel Base", SC2_RACESWAP_LOC_ID_OFFSET + 301, LocationType.VANILLA,
lambda state: logic.zerg_common_unit(state)),
LocationData("The Outlaws (Z)", "The Outlaws (Zerg): North Resource Pickups", SC2_RACESWAP_LOC_ID_OFFSET + 302, LocationType.EXTRA,
lambda state: logic.zerg_common_unit(state)),
LocationData("The Outlaws (Z)", "The Outlaws (Zerg): Bunker", SC2_RACESWAP_LOC_ID_OFFSET + 303, LocationType.VANILLA,
lambda state: logic.zerg_common_unit(state)),
LocationData("The Outlaws (Z)", "The Outlaws (Zerg): Close Resource Pickups", SC2_RACESWAP_LOC_ID_OFFSET + 304, LocationType.EXTRA),
LocationData("The Outlaws (P)", "The Outlaws (Protoss): Victory", SC2_RACESWAP_LOC_ID_OFFSET + 400, LocationType.VICTORY,
lambda state: logic.protoss_common_unit(state)),
LocationData("The Outlaws (P)", "The Outlaws (Protoss): Rebel Base", SC2_RACESWAP_LOC_ID_OFFSET + 401, LocationType.VANILLA,
lambda state: logic.protoss_common_unit(state)),
LocationData("The Outlaws (P)", "The Outlaws (Protoss): North Resource Pickups", SC2_RACESWAP_LOC_ID_OFFSET + 402, LocationType.EXTRA,
lambda state: logic.protoss_common_unit(state)),
LocationData("The Outlaws (P)", "The Outlaws (Protoss): Bunker", SC2_RACESWAP_LOC_ID_OFFSET + 403, LocationType.VANILLA,
lambda state: logic.protoss_common_unit(state)),
LocationData("The Outlaws (P)", "The Outlaws (Protoss): Close Resource Pickups", SC2_RACESWAP_LOC_ID_OFFSET + 404, LocationType.EXTRA),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Victory", SC2_RACESWAP_LOC_ID_OFFSET + 500, LocationType.VICTORY,
lambda state: logic.zerg_competent_defense(state) and
logic.zerg_basic_kerriganless_anti_air(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): First Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 501, LocationType.VANILLA),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Second Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 502, LocationType.VANILLA,
lambda state: logic.zerg_common_unit(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Third Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 503, LocationType.VANILLA,
lambda state: logic.zerg_competent_defense(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): First Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 504, LocationType.CHALLENGE,
lambda state: logic.zerg_competent_comp(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Second Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 505, LocationType.CHALLENGE,
lambda state: logic.zerg_competent_comp(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Third Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 506, LocationType.CHALLENGE,
lambda state: logic.zerg_competent_comp(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Fourth Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 507, LocationType.CHALLENGE,
lambda state: logic.zerg_competent_comp(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Ride's on its Way", SC2_RACESWAP_LOC_ID_OFFSET + 508, LocationType.EXTRA,
lambda state: logic.zerg_common_unit(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Hold Just a Little Longer", SC2_RACESWAP_LOC_ID_OFFSET + 509,
LocationType.EXTRA,
lambda state: logic.zerg_competent_defense(state)),
LocationData("Zero Hour (Z)", "Zero Hour (Zerg): Cavalry's on the Way", SC2_RACESWAP_LOC_ID_OFFSET + 510, LocationType.EXTRA,
lambda state: logic.zerg_competent_defense(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Victory", SC2_RACESWAP_LOC_ID_OFFSET + 600, LocationType.VICTORY,
lambda state: logic.protoss_common_unit(state) and
(adv_tactics or logic.protoss_basic_anti_air(state))),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): First Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 601, LocationType.VANILLA),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Second Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 602, LocationType.VANILLA,
lambda state: logic.protoss_common_unit(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Third Group Rescued", SC2_RACESWAP_LOC_ID_OFFSET + 603, LocationType.VANILLA,
lambda state: logic.protoss_common_unit(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): First Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 604, LocationType.CHALLENGE,
lambda state: logic.protoss_competent_comp(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Second Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 605, LocationType.CHALLENGE,
lambda state: logic.protoss_competent_comp(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Third Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 606, LocationType.CHALLENGE,
lambda state: logic.protoss_competent_comp(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Fourth Hatchery", SC2_RACESWAP_LOC_ID_OFFSET + 607, LocationType.CHALLENGE,
lambda state: logic.protoss_competent_comp(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Ride's on its Way", SC2_RACESWAP_LOC_ID_OFFSET + 608, LocationType.EXTRA,
lambda state: logic.protoss_common_unit(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Hold Just a Little Longer", SC2_RACESWAP_LOC_ID_OFFSET + 609,
LocationType.EXTRA,
lambda state: logic.protoss_common_unit(state)),
LocationData("Zero Hour (P)", "Zero Hour (Protoss): Cavalry's on the Way", SC2_RACESWAP_LOC_ID_OFFSET + 610, LocationType.EXTRA,
lambda state: logic.protoss_common_unit(state)),
# 70X/80X - Evacuation
# 90X/100X - Outbreak
# 110X/120X - Safe Haven
# 130X/140X - Haven's Fall
LocationData("Smash and Grab (Z)", "Smash and Grab (Zerg): Victory", SC2_RACESWAP_LOC_ID_OFFSET + 1500, LocationType.VICTORY,
lambda state: logic.zerg_common_unit(state) and
(adv_tactics and logic.zerg_basic_anti_air(state)
Expand Down
13 changes: 11 additions & 2 deletions worlds/sc2/mission_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def __init__(self, mission_id: int, name: str, campaign: SC2Campaign, area: str,

# Wings of Liberty
LIBERATION_DAY = 1, "Liberation Day", SC2Campaign.WOL, "Mar Sara", SC2Race.ANY, MissionPools.STARTER, "ap_liberation_day", MissionFlag.Terran|MissionFlag.NoBuild|MissionFlag.VsTerran
THE_OUTLAWS = 2, "The Outlaws", SC2Campaign.WOL, "Mar Sara", SC2Race.TERRAN, MissionPools.EASY, "ap_the_outlaws", MissionFlag.Terran|MissionFlag.VsTerran
ZERO_HOUR = 3, "Zero Hour", SC2Campaign.WOL, "Mar Sara", SC2Race.TERRAN, MissionPools.EASY, "ap_zero_hour", MissionFlag.Terran|MissionFlag.TimedDefense|MissionFlag.VsZerg
THE_OUTLAWS = 2, "The Outlaws (T)", SC2Campaign.WOL, "Mar Sara", SC2Race.TERRAN, MissionPools.EASY, "ap_the_outlaws", MissionFlag.Terran|MissionFlag.VsTerran|MissionFlag.HasRaceSwap
ZERO_HOUR = 3, "Zero Hour (T)", SC2Campaign.WOL, "Mar Sara", SC2Race.TERRAN, MissionPools.EASY, "ap_zero_hour", MissionFlag.Terran|MissionFlag.TimedDefense|MissionFlag.VsZerg|MissionFlag.HasRaceSwap
EVACUATION = 4, "Evacuation", SC2Campaign.WOL, "Colonist", SC2Race.TERRAN, MissionPools.EASY, "ap_evacuation", MissionFlag.Terran|MissionFlag.AutoScroller|MissionFlag.VsZerg
OUTBREAK = 5, "Outbreak", SC2Campaign.WOL, "Colonist", SC2Race.TERRAN, MissionPools.EASY, "ap_outbreak", MissionFlag.Terran|MissionFlag.Defense|MissionFlag.VsZerg
SAFE_HAVEN = 6, "Safe Haven", SC2Campaign.WOL, "Colonist", SC2Race.TERRAN, MissionPools.MEDIUM, "ap_safe_haven", MissionFlag.Terran|MissionFlag.Countdown|MissionFlag.VsProtoss
Expand Down Expand Up @@ -197,6 +197,15 @@ def __init__(self, mission_id: int, name: str, campaign: SC2Campaign, area: str,
END_GAME = 83, "End Game", SC2Campaign.NCO, "_3", SC2Race.TERRAN, MissionPools.VERY_HARD, "ap_end_game", MissionFlag.Terran|MissionFlag.Nova|MissionFlag.Defense|MissionFlag.VsTerran

# Race-Swapped Variants
# 84/85 - Liberation Day
THE_OUTLAWS_Z = 86, "The Outlaws (Z)", SC2Campaign.WOL, "Mar Sara", SC2Race.ZERG, MissionPools.EASY, "ap_the_outlaws", MissionFlag.Zerg|MissionFlag.VsTerran|MissionFlag.RaceSwap
THE_OUTLAWS_P = 87, "The Outlaws (P)", SC2Campaign.WOL, "Mar Sara", SC2Race.PROTOSS, MissionPools.EASY, "ap_the_outlaws", MissionFlag.Protoss|MissionFlag.VsTerran|MissionFlag.RaceSwap
ZERO_HOUR_Z = 88, "Zero Hour (Z)", SC2Campaign.WOL, "Mar Sara", SC2Race.ZERG, MissionPools.EASY, "ap_zero_hour", MissionFlag.Zerg|MissionFlag.TimedDefense|MissionFlag.VsZerg|MissionFlag.RaceSwap
ZERO_HOUR_P = 89, "Zero Hour (P)", SC2Campaign.WOL, "Mar Sara", SC2Race.PROTOSS, MissionPools.EASY, "ap_zero_hour", MissionFlag.Protoss|MissionFlag.TimedDefense|MissionFlag.VsZerg|MissionFlag.RaceSwap
# 90/91 - Evacuation
# 92/93 - Outbreak
# 94/95 - Safe Haven
# 96/97 - Haven's Fall
SMASH_AND_GRAB_Z = 98, "Smash and Grab (Z)", SC2Campaign.WOL, "Artifact", SC2Race.ZERG, MissionPools.EASY, "ap_smash_and_grab", MissionFlag.Zerg|MissionFlag.Countdown|MissionFlag.VsPZ|MissionFlag.RaceSwap
SMASH_AND_GRAB_P = 99, "Smash and Grab (P)", SC2Campaign.WOL, "Artifact", SC2Race.PROTOSS, MissionPools.EASY, "ap_smash_and_grab", MissionFlag.Protoss|MissionFlag.Countdown|MissionFlag.VsPZ|MissionFlag.RaceSwap

Expand Down
13 changes: 6 additions & 7 deletions worlds/sc2/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class MaximumCampaignSize(Range):
"""
display_name = "Maximum Campaign Size"
range_start = 1
range_end = 85
range_end = 89
default = 83


Expand Down Expand Up @@ -263,15 +263,16 @@ class EnableNCOMissions(DefaultOnToggle):
class EnableRaceSwapVariants(Choice):
"""
Allow mission variants where you play a faction other than the one the map was initially
designed for.
designed for. NOTE: Cutscenes are always skipped on race-swapped mission variants.
Disabled: Don't shuffle any non-vanilla map variants into the pool.
Pick One: Only allow one version of each map at a time
Shuffle All: Each version of a map can appear in the same pool (so a map can appear up to 3 times as different races)
("Pick Just One At Random" coming soon)
"""
display_name = "Enable Race-Swapped Mission Variants"
option_disabled = 0
option_pick_one = 1
# TODO: Implement pick-one logic
# option_pick_one = 1
option_shuffle_all = 2
default = option_disabled

Expand Down Expand Up @@ -1012,7 +1013,7 @@ def get_enabled_campaigns(world: 'SC2World') -> Set[SC2Campaign]:
enabled_campaigns.add(SC2Campaign.EPILOGUE)
if get_option_value(world, "enable_nco_missions"):
enabled_campaigns.add(SC2Campaign.NCO)
return set([campaign for campaign in enabled_campaigns if campaign.race in get_enabled_races(world)])
return enabled_campaigns


def get_disabled_campaigns(world: 'SC2World') -> Set[SC2Campaign]:
Expand All @@ -1039,7 +1040,6 @@ def get_excluded_missions(world: 'SC2World') -> Set[SC2Mission]:
excluded_mission_names = world.options.excluded_missions.value
disabled_campaigns = get_disabled_campaigns(world)
disabled_flags = get_disabled_flags(world)
just_one_variant = get_option_value(world, "enable_race_swap") == EnableRaceSwapVariants.option_pick_one

excluded_missions: Set[SC2Mission] = set([lookup_name_to_mission[name] for name in excluded_mission_names])

Expand All @@ -1060,7 +1060,6 @@ def get_excluded_missions(world: 'SC2World') -> Set[SC2Mission]:
# Omitting missions not in enabled campaigns
for campaign in disabled_campaigns:
excluded_missions = excluded_missions.union(campaign_mission_table[campaign])
# TODO: if just_one_variant:

return excluded_missions

Expand Down

0 comments on commit 143f9aa

Please sign in to comment.