Skip to content

Commit

Permalink
SMW v2 - More small adjustments (ArchipelagoMW#29)
Browse files Browse the repository at this point in the history
* Very small logic tweaks

* Adjusted levels with vertical scroll

* Added a small failsafe on reading the amount of items received
  • Loading branch information
TheLX5 authored Feb 11, 2024
1 parent 5698486 commit 1420729
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
5 changes: 4 additions & 1 deletion worlds/smw/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,10 @@ async def game_watcher(self, ctx):
return

recv_count = await snes_read(ctx, SMW_RECV_PROGRESS_ADDR, 2)
recv_index = recv_count[0]+(recv_count[1]<<8)
if recv_count is None:
# Add a small failsafe in case we get a None. Other SNI games do this...
return
recv_index = recv_count[0] | (recv_count[1] << 8)

if recv_index < len(ctx.items_received):
item = ctx.items_received[recv_index]
Expand Down
38 changes: 21 additions & 17 deletions worlds/smw/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.forest_secret_region, LocationName.forest_secret_dragon)
add_location_to_region(multiworld, player, active_locations, LocationName.forest_castle_region, LocationName.forest_castle_dragon)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_1_region, LocationName.chocolate_island_1_dragon,
lambda state: state.has(ItemName.mario_swim, player))
lambda state: state.has(ItemName.p_switch, player))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_2_region, LocationName.chocolate_island_2_dragon,
lambda state: (state.has(ItemName.blue_switch_palace, player) and
(state.has(ItemName.p_switch, player) or
Expand All @@ -811,8 +811,7 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
lambda state: (state.has(ItemName.p_switch, player) and
state.has(ItemName.progressive_powerup, player, 3)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_5_region, LocationName.chocolate_island_5_dragon,
lambda state: (state.has(ItemName.mario_swim, player) or
(state.has(ItemName.mario_carry, player) and state.has(ItemName.p_switch, player))))
lambda state: (state.has(ItemName.mario_carry, player) and state.has(ItemName.p_switch, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.sunken_ghost_ship_region, LocationName.sunken_ghost_ship_dragon,
lambda state: (state.has(ItemName.mario_swim, player) and
state.has(ItemName.super_star_active, player) and
Expand Down Expand Up @@ -849,8 +848,9 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc

if world.options.moon_checks:
add_location_to_region(multiworld, player, active_locations, LocationName.yoshis_island_1_region, LocationName.yoshis_island_1_moon,
lambda state: (state.has(ItemName.mario_run, player) and
state.has(ItemName.progressive_powerup, player, 3)))
lambda state: ((state.has(ItemName.mario_run, player) and
state.has(ItemName.progressive_powerup, player, 3)) or
state.has(ItemName.yoshi_activate, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.donut_plains_4_region, LocationName.donut_plains_4_moon,
lambda state: (state.has(ItemName.mario_run, player) and
state.has(ItemName.progressive_powerup, player, 3)))
Expand All @@ -864,8 +864,9 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.forest_ghost_house_region, LocationName.forest_ghost_house_moon,
lambda state: state.has(ItemName.p_switch, player))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_1_region, LocationName.chocolate_island_1_moon,
lambda state: (state.has(ItemName.mario_run, player) and
state.has(ItemName.progressive_powerup, player, 3)))
lambda state: ((state.has(ItemName.mario_run, player) and
state.has(ItemName.progressive_powerup, player, 3)) or
state.has(ItemName.yoshi_activate, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.valley_of_bowser_1_region, LocationName.valley_of_bowser_1_moon)

if world.options.hidden_1up_checks:
Expand All @@ -887,9 +888,12 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
state.has(ItemName.yoshi_activate, player) or
(state.has(ItemName.mario_run, player, player) and
state.has(ItemName.progressive_powerup, player, 3))))
add_location_to_region(multiworld, player, active_locations, LocationName.forest_of_illusion_3_region, LocationName.forest_of_illusion_3_hidden_1up)
add_location_to_region(multiworld, player, active_locations, LocationName.forest_of_illusion_3_region, LocationName.forest_of_illusion_3_hidden_1up,
lambda state: (state.has(ItemName.mario_carry, player) or
state.has(ItemName.yoshi_activate, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_2_region, LocationName.chocolate_island_2_hidden_1up)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_castle_region, LocationName.chocolate_castle_hidden_1up)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_castle_region, LocationName.chocolate_castle_hidden_1up,
lambda state: (state.has(ItemName.progressive_powerup, player, 1)))
add_location_to_region(multiworld, player, active_locations, LocationName.valley_of_bowser_2_region, LocationName.valley_of_bowser_2_hidden_1up)
add_location_to_region(multiworld, player, active_locations, LocationName.valley_castle_region, LocationName.valley_castle_hidden_1up)
add_location_to_region(multiworld, player, active_locations, LocationName.special_zone_1_region, LocationName.special_zone_1_hidden_1up,
Expand Down Expand Up @@ -1107,11 +1111,11 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.sunken_ghost_ship_region, LocationName.sunken_ghost_ship_star_block_1,
lambda state: state.has(ItemName.mario_swim, player))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_castle_region, LocationName.chocolate_castle_yellow_block_1,
lambda state: state.has(ItemName.yellow_switch_palace, player))
lambda state: (state.has(ItemName.progressive_powerup, player, 1) and state.has(ItemName.yellow_switch_palace, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_castle_region, LocationName.chocolate_castle_yellow_block_2,
lambda state: state.has(ItemName.yellow_switch_palace, player))
lambda state: (state.has(ItemName.progressive_powerup, player, 1) and state.has(ItemName.yellow_switch_palace, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_castle_region, LocationName.chocolate_castle_green_block_1,
lambda state: state.has(ItemName.green_switch_palace, player))
lambda state: (state.has(ItemName.progressive_powerup, player, 1) and state.has(ItemName.yellow_switch_palace, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_fortress_region, LocationName.chocolate_fortress_powerup_block_1)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_fortress_region, LocationName.chocolate_fortress_powerup_block_2)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_fortress_region, LocationName.chocolate_fortress_coin_block_1)
Expand All @@ -1123,7 +1127,7 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_5_region, LocationName.chocolate_island_5_life_block_1,
lambda state:( (state.has(ItemName.mario_carry, player)) or (state.has(ItemName.progressive_powerup, player, 3))))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_5_region, LocationName.chocolate_island_5_yellow_block_1,
lambda state: (state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.p_switch, player)))
lambda state: (state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.p_switch, player) and state.has(ItemName.mario_carry, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_4_region, LocationName.chocolate_island_4_yellow_block_1,
lambda state: (state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.blue_switch_palace, player)))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_4_region, LocationName.chocolate_island_4_blue_pow_block_1)
Expand Down Expand Up @@ -1161,7 +1165,7 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_1_region, LocationName.chocolate_island_1_yoshi_block_1,
lambda state: state.has(ItemName.p_switch, player))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_1_region, LocationName.chocolate_island_1_green_block_1,
lambda state:( ((state.has(ItemName.green_switch_palace, player) and state.has(ItemName.blue_switch_palace, player))) or ((state.has(ItemName.green_switch_palace, player) and state.has(ItemName.progressive_powerup, player, 3))) or ((state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.blue_switch_palace, player))) or ((state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.progressive_powerup, player, 3)))))
lambda state:( ((state.has(ItemName.green_switch_palace, player) and state.has(ItemName.blue_switch_palace, player) and state.has(ItemName.p_switch, player))) or ((state.has(ItemName.green_switch_palace, player) and state.has(ItemName.progressive_powerup, player, 3) and state.has(ItemName.p_switch, player))) or ((state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.blue_switch_palace, player) and state.has(ItemName.p_switch, player))) or ((state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.progressive_powerup, player, 3) and state.has(ItemName.p_switch, player)))))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_1_region, LocationName.chocolate_island_1_life_block_1,
lambda state: state.has(ItemName.p_switch, player))
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_island_3_region, LocationName.chocolate_island_3_powerup_block_1)
Expand Down Expand Up @@ -1372,7 +1376,8 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
lambda state: (state.has(ItemName.yellow_switch_palace, player) and state.has(ItemName.progressive_powerup, player, 3)))
add_location_to_region(multiworld, player, active_locations, LocationName.valley_of_bowser_1_region, LocationName.valley_of_bowser_1_vine_block_1)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_secret_region, LocationName.chocolate_secret_powerup_block_1)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_secret_region, LocationName.chocolate_secret_powerup_block_2)
add_location_to_region(multiworld, player, active_locations, LocationName.chocolate_secret_region, LocationName.chocolate_secret_powerup_block_2,
lambda state: state.has(ItemName.mario_run, player))
add_location_to_region(multiworld, player, active_locations, LocationName.vanilla_dome_2_region, LocationName.vanilla_dome_2_coin_block_1,
lambda state: state.has(ItemName.mario_swim, player))
add_location_to_region(multiworld, player, active_locations, LocationName.vanilla_dome_2_region, LocationName.vanilla_dome_2_powerup_block_1,
Expand Down Expand Up @@ -1737,7 +1742,7 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.star_road_2_region, LocationName.star_road_2_star_block_1,
lambda state: state.has(ItemName.mario_swim, player))
add_location_to_region(multiworld, player, active_locations, LocationName.star_road_3_region, LocationName.star_road_3_key_block_1,
lambda state: state.has(ItemName.mario_carry, player))
lambda state:( (state.has(ItemName.mario_carry, player)) or (state.has(ItemName.progressive_powerup, player, 2))))
add_location_to_region(multiworld, player, active_locations, LocationName.star_road_4_region, LocationName.star_road_4_powerup_block_1)
add_location_to_region(multiworld, player, active_locations, LocationName.star_road_4_region, LocationName.star_road_4_green_block_1,
lambda state: (state.has(ItemName.green_switch_palace, player) and state.has(ItemName.yoshi_activate, player) and state.has(ItemName.mario_carry, player)))
Expand Down Expand Up @@ -1841,7 +1846,6 @@ def create_regions(multiworld: MultiWorld, player: int, world: World, active_loc
add_location_to_region(multiworld, player, active_locations, LocationName.star_road_5_region, LocationName.star_road_5_green_block_20,
lambda state: (state.has(ItemName.green_switch_palace, player) and state.has(ItemName.yoshi_activate, player) and state.has(ItemName.mario_carry, player) and state.has(ItemName.special_world_clear, player)))


def connect_regions(multiworld: MultiWorld, player: int, world: World, level_to_tile_dict):
names: typing.Dict[str, int] = {}

Expand Down
2 changes: 1 addition & 1 deletion worlds/smw/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def handle_vertical_scroll(rom):

vertical_scroll_table = [
0x02, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, # Levels 000-00F
0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, # Levels 010-01F
0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, # Levels 010-01F
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, # Levels 020-02F
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, # Levels 030-03F
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, # Levels 040-04F
Expand Down

0 comments on commit 1420729

Please sign in to comment.