Skip to content

Commit

Permalink
Add option to fully exclude Special Zone levels from the seed
Browse files Browse the repository at this point in the history
  • Loading branch information
PoryGone committed Dec 22, 2022
1 parent a84e36c commit 4a2eab8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
25 changes: 17 additions & 8 deletions worlds/smw/Levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def __init__(self, levelName: str, levelIDAddress: int, eventIDValue: int, exit1
0x3B,
0x3A,
0x37,
]

special_zone_levels = [
0x4E,
0x4F,
0x50,
Expand Down Expand Up @@ -517,6 +520,7 @@ def generate_level_list(world, player):
world.random.shuffle(easy_single_levels_copy)
hard_single_levels_copy = hard_single_levels.copy()
world.random.shuffle(hard_single_levels_copy)
special_zone_levels_copy = special_zone_levels.copy()
easy_double_levels_copy = easy_double_levels.copy()
world.random.shuffle(easy_double_levels_copy)
hard_double_levels_copy = hard_double_levels.copy()
Expand Down Expand Up @@ -548,6 +552,8 @@ def generate_level_list(world, player):
shuffled_level_list.append(0x16)

single_levels_copy = (easy_single_levels_copy.copy() + hard_single_levels_copy.copy())
if not world.exclude_special_zone[player]:
single_levels_copy.extend(special_zone_levels_copy)
world.random.shuffle(single_levels_copy)

castle_fortress_levels_copy = (easy_castle_fortress_levels_copy.copy() + hard_castle_fortress_levels_copy.copy())
Expand Down Expand Up @@ -640,14 +646,17 @@ def generate_level_list(world, player):

# Special Zone
shuffled_level_list.append(0x4D)
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
if not world.exclude_special_zone[player]:
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
shuffled_level_list.append(single_levels_copy.pop(0))
else:
shuffled_level_list.extend(special_zone_levels_copy)
shuffled_level_list.append(0x48)

return shuffled_level_list
22 changes: 22 additions & 0 deletions worlds/smw/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@ def __init__(self, player: int, name: str = '', address: int = None, parent=None
**yoshi_house_location_table,
}

special_zone_level_names = [
LocationName.special_zone_1_exit_1,
LocationName.special_zone_2_exit_1,
LocationName.special_zone_3_exit_1,
LocationName.special_zone_4_exit_1,
LocationName.special_zone_5_exit_1,
LocationName.special_zone_6_exit_1,
LocationName.special_zone_7_exit_1,
LocationName.special_zone_8_exit_1,
]

special_zone_dragon_coin_names = [
LocationName.special_zone_1_dragon,
LocationName.special_zone_2_dragon,
LocationName.special_zone_3_dragon,
LocationName.special_zone_4_dragon,
LocationName.special_zone_5_dragon,
LocationName.special_zone_6_dragon,
LocationName.special_zone_7_dragon,
LocationName.special_zone_8_dragon,
]

location_table = {}


Expand Down
9 changes: 9 additions & 0 deletions worlds/smw/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class LevelShuffle(Toggle):
display_name = "Level Shuffle"


class ExcludeSpecialZone(Toggle):
"""
If active, this option will prevent any progression items from being placed in Special Zone levels.
Additionally, if Level Shuffle is active, Special Zone levels will not be shuffled away from their vanilla tiles.
"""
display_name = "Exclude Special Zone"


class SwapDonutGhostHouseExits(Toggle):
"""
If enabled, this option will swap which overworld direction the two exits of the level at the Donut Ghost House
Expand Down Expand Up @@ -289,6 +297,7 @@ class StartingLifeCount(Range):
"bowser_castle_doors": BowserCastleDoors,
"bowser_castle_rooms": BowserCastleRooms,
"level_shuffle": LevelShuffle,
"exclude_special_zone": ExcludeSpecialZone,
"boss_shuffle": BossShuffle,
"swap_donut_gh_exits": SwapDonutGhostHouseExits,
#"display_sent_item_popups": DisplaySentItemPopups,
Expand Down
13 changes: 11 additions & 2 deletions worlds/smw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from BaseClasses import Item, MultiWorld, Tutorial, ItemClassification
from .Items import SMWItem, ItemData, item_table
from .Locations import SMWLocation, all_locations, setup_locations
from .Locations import SMWLocation, all_locations, setup_locations, special_zone_level_names, special_zone_dragon_coin_names
from .Options import smw_options
from .Regions import create_regions, connect_regions
from .Levels import full_level_list, generate_level_list, location_id_to_level_id
from .Rules import set_rules
from ..generic.Rules import add_rule
from ..generic.Rules import add_rule, exclusion_rules
from .Names import ItemName, LocationName
from .Client import SMWSNIClient
from ..AutoWorld import WebWorld, World
Expand Down Expand Up @@ -93,6 +93,15 @@ def generate_basic(self):
add_rule(self.multiworld.get_region(LocationName.chocolate_island_1_tile, self.player).entrances[0], lambda state: state.has(ItemName.koopaling, self.player, 5))
add_rule(self.multiworld.get_region(LocationName.valley_of_bowser_1_tile, self.player).entrances[0], lambda state: state.has(ItemName.koopaling, self.player, 6))

if self.multiworld.exclude_special_zone[self.player]:
exclusion_pool = set()
if self.multiworld.dragon_coin_checks[self.player]:
exclusion_pool.update(special_zone_level_names)
exclusion_pool.update(special_zone_dragon_coin_names)
elif self.multiworld.number_of_yoshi_eggs[self.player].value <= 72:
exclusion_pool.update(special_zone_level_names)
exclusion_rules(self.multiworld, self.player, exclusion_pool)

total_required_locations = 96
if self.multiworld.dragon_coin_checks[self.player]:
total_required_locations += 49
Expand Down

0 comments on commit 4a2eab8

Please sign in to comment.