Skip to content

Commit

Permalink
Implement Sealed Chamber puzzle in Puzzle Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pekempy committed Jan 13, 2025
1 parent ae4b91b commit 9963b38
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 27 deletions.
5 changes: 3 additions & 2 deletions modules/menuing.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,7 @@ def use_party_hm_move(move_name: str):
case "WATERFALL":
if not get_event_flag("BADGE08_GET"):
raise BotModeError("You do not have the Rain Badge to use Waterfall outside of battle.")
case _:
raise BotModeError("Invalid HM move name.")

if context.rom.is_frlg:
match move_name_upper:
case "FLASH":
Expand Down Expand Up @@ -929,6 +928,8 @@ def use_party_hm_move(move_name: str):
yield from PokemonPartyMenuNavigator(move_pokemon.index, "", cursor.WATERFALL).step()
case "DIVE":
yield from PokemonPartyMenuNavigator(move_pokemon.index, "", cursor.DIVE).step()
case "DIG":
yield from PokemonPartyMenuNavigator(move_pokemon.index, "", cursor.DIG).step()
case _:
raise BotModeError("Invalid HM move name.")
return
Expand Down
23 changes: 23 additions & 0 deletions modules/modes/_asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,26 @@ def assert_party_has_damaging_move(error_message: str, check_in_saved_game: bool
return

raise BotModeError(error_message)


def assert_pokemon_in_party_slot(
pokemon: str, slot: int, error_message: str, check_in_saved_game: bool = False
) -> None:
"""
Raises an exception if the pokemon specified is not in the party slot required
:param pokemon: The pokemon to check for in the party.
:param slot: The slot in the party (0 indexed) to check for the pokemon.
:param error_message: Error message to display if the assertion fails.
:param check_in_saved_game: If True, this assertion will check the saved game instead of the
current party (which is the default.)
"""
if not isinstance(pokemon, str):
raise BotModeError("Pokemon must be a string")
if not isinstance(slot, int):
raise BotModeError("Slot must be an integer")
if slot < 0 or slot > 5:
raise BotModeError("Slot must be between 0 and 5")

party = get_party() if not check_in_saved_game else get_save_data().get_party()
if party[slot].species.name != pokemon:
raise BotModeError(error_message)
47 changes: 45 additions & 2 deletions modules/modes/puzzle_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from modules.map_data import MapFRLG, MapRSE
from modules.memory import get_event_flag, get_event_var
from modules.menuing import use_party_hm_move
from modules.modes.util.higher_level_actions import dive, surface_from_dive
from modules.player import get_player_avatar
from modules.tasks import get_global_script_context
from . import BattleAction
from ._asserts import assert_has_pokemon_with_any_move, assert_registered_item, assert_item_exists_in_bag
from ._asserts import assert_has_pokemon_with_any_move, assert_registered_item, assert_pokemon_in_party_slot
from ._interface import BotMode, BotModeError
from .util import (
follow_path,
Expand Down Expand Up @@ -58,6 +59,7 @@ def is_selectable() -> bool:
MapRSE.ANCIENT_TOMB,
MapRSE.BIRTH_ISLAND_EXTERIOR,
MapRSE.MIRAGE_TOWER_1F,
MapRSE.PACIFIDLOG_TOWN,
]
elif context.rom.is_frlg:
return get_player_avatar().map_group_and_number in [
Expand Down Expand Up @@ -86,7 +88,7 @@ def run(self) -> Generator:
context.message = "Solving Mirage Tower..."
use_repel = True
assert_registered_item("Mach Bike", "This mode requires the Mach Bike registered to the Select button.")
assert_has_pokemon_with_any_move(["Rock Smash"], "This mode requires Pokémon with Rock Smash.")
assert_(["Rock Smash"], "This mode requires Pokémon with Rock Smash.")

def path():
# floor 1
Expand Down Expand Up @@ -139,6 +141,47 @@ def path():
context.message = "Sky Pillar puzzle complete!"
context.set_manual_mode()

# Regi Initial Puzzle
case MapRSE.PACIFIDLOG_TOWN:
context.message = "Solving Sealed Chamber Puzzle...\nNavigating to Sealed Chamber..."

use_repel = True
assert_has_pokemon_with_any_move(["Dig"], "Regi Initial Puzzle requires Pokémon with Dig.")
assert_has_pokemon_with_any_move(["Dive"], "Regi Initial Puzzle requires Pokémon with Dive.")
assert_has_pokemon_with_any_move(["Surf"], "Regi Initial Puzzle requires Pokémon with Surf.")
if context.rom.is_emerald:
assert_pokemon_in_party_slot(
"Wailord", 0, "Sealed Chamber Puzzle requires Wailord in the first party slot."
)
assert_pokemon_in_party_slot(
"Relicanth", 5, "Sealed Chamber Puzzle requires Relicanth in the last party slot."
)
if context.rom.is_rs:
assert_pokemon_in_party_slot(
"Relicanth", 0, "Sealed Chamber Puzzle requires Relicanth in the first party slot."
)
assert_pokemon_in_party_slot(
"Wailord", 5, "Sealed Chamber Puzzle requires Wailord in the last party slot."
)

def path():
yield from navigate_to(MapRSE.ROUTE134, (61, 31))
yield from dive()
yield from navigate_to(MapRSE.UNDERWATER_ROUTE134, (8, 8))
yield from navigate_to(MapRSE.UNDERWATER_SEALED_CHAMBER, (12, 44))
yield from surface_from_dive()
context.message = "Solving Sealed Chamber Puzzle...\nStarting solution..."
yield from navigate_to(MapRSE.SEALED_CHAMBER_OUTER_ROOM, (10, 3))
yield from use_party_hm_move("Dig")
yield from wait_for_task_to_start_and_finish("Task_DuckBGMForPokemonCry")
yield from navigate_to(MapRSE.SEALED_CHAMBER_OUTER_ROOM, (10, 2))
yield from navigate_to(MapRSE.SEALED_CHAMBER_INNER_ROOM, (10, 5))
while get_event_flag("REGI_DOORS_OPENED") == 0:
context.emulator.press_button("A")
yield
context.message = "Sealed Chamber puzzle complete!\nEncounters for Regis are now available."
context.set_manual_mode()

# Regirock
case MapRSE.DESERT_RUINS:
context.message = "Solving Regirock Puzzle..."
Expand Down
Binary file added wiki/images/puzzle_sealed_chamber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 44 additions & 23 deletions wiki/pages/Mode - Puzzle Solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ For `Fire Red / Leaf Green`

![image](../images/puzzle_deoxys_frlg.png)

## Sealed Chamber (Regi-Trio) Puzzle

Navigates to [Sealed Chamber](https://bulbapedia.bulbagarden.net/wiki/Sealed_Chamber) from [Pacifidlog Town](https://bulbapedia.bulbagarden.net/wiki/Pacifidlog_Town), and solves the puzzle required to access the regi trio.

### Requirements

- Pokemon which knows [Surf](<https://bulbapedia.bulbagarden.net/wiki/Surf_(move)>)
- Pokemon which knows [Dive](<https://bulbapedia.bulbagarden.net/wiki/Dive_(move)>)
- Pokemon which knows [Dig](<https://bulbapedia.bulbagarden.net/wiki/Dig_(move)>)
- Wailord in the **first** party slot (Emerald) or **last** party slot (Ruby/Sapphire)
- Relicanth in the **last** party slot (Emerald) or **first** party slot (Ruby/Sapphire)

### Starting Location

Start anywhere in Pacifidlog town with all of the above requirements fulfilled.

![image](../images/puzzle_sealed_chamber.png)

## Regice

For [Regice](<https://bulbapedia.bulbagarden.net/wiki/Regice_(Pok%C3%A9mon)>), start the bot mode _inside_ [Island Cave](https://bulbapedia.bulbagarden.net/wiki/Island_Cave).
Expand Down Expand Up @@ -141,29 +159,32 @@ Start bot mode anywhere inside the glass workshop.

# Game Support

| Puzzle | Game | English | Japanese | German | Spanish | French | Italian |
|:-----------------|:-------------|:-------:|:--------:|:------:|:-------:|:------:|:-------:|
| **Mirage Tower** | 🟢 Emerald |||||||
| **Sky Pillar** | 🟢 Emerald |||||||
| | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| **Deoxys** | 🟢 Emerald |||||||
| | 🔥 Fire Red |||||||
| | 🌿 LeafGreen |||||||
| **Regice** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Regirock** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Registeel** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Tanoby Key** | 🔥 Fire Red |||||||
| | 🌿 LeafGreen |||||||
| **White Flute** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| Puzzle | Game | English | Japanese | German | Spanish | French | Italian |
| :----------------- | :----------- | :-----: | :------: | :----: | :-----: | :----: | :-----: |
| **Mirage Tower** | 🟢 Emerald |||||||
| **Sky Pillar** | 🟢 Emerald |||||||
| | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| **Deoxys** | 🟢 Emerald |||||||
| | 🔥 Fire Red |||||||
| | 🌿 LeafGreen |||||||
| **Sealed Chamber** | 🟥 Ruby | 🟨 | 🟨 | 🟨 | 🟨 | 🟨 | 🟨 |
| | 🔷 Sapphire || 🟨 | 🟨 | 🟨 | 🟨 | 🟨 |
| | 🟢 Emerald || 🟨 | 🟨 | 🟨 | 🟨 | 🟨 |
| **Regice** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Regirock** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Registeel** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||
| **Tanoby Key** | 🔥 Fire Red |||||||
| | 🌿 LeafGreen |||||||
| **White Flute** | 🟥 Ruby |||||||
| | 🔷 Sapphire |||||||
| | 🟢 Emerald |||||||

✅ Tested, working

Expand Down

0 comments on commit 9963b38

Please sign in to comment.