-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sweet Scent method #163
Closed
Closed
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
03ab293
First commit, not working properly
jaytheidiot 9fb0825
Working and removed quest_log case
jaytheidiot b06a17d
Changed rng file names
jaytheidiot a567081
Fixed cursor options for FRLG
jaytheidiot 2813027
Undid file names, made FRLG run instead of reset
jaytheidiot a383a50
Made menuing press a for sweet scent instead of waiting
jaytheidiot 92d484f
Made PartyMenuNavigator take any CursorOption
jaytheidiot 738ef5d
forgot to remove filename from files.py
jaytheidiot 9b801a4
- added a `wait_for_init` function to allow the party menu to open be…
Mowlawner ca36f2b
Merge pull request #2 from Mowlawner/sweet-scent-bugfixes
MythicWebsite fe28d42
Removed unused imports and fixed for FRLG + RS
MythicWebsite cad16a9
Fixed double encounter checking
MythicWebsite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"Fishing", | ||
"Bunny Hop", | ||
"Static Soft Resets", | ||
"Sweet Scent", | ||
"Tower Duo", | ||
"Ancient Legendaries", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import random | ||
from enum import Enum, auto | ||
|
||
from modules.context import context | ||
from modules.encounter import encounter_pokemon | ||
from modules.memory import ( | ||
read_symbol, | ||
get_game_state, | ||
GameState, | ||
write_symbol, | ||
unpack_uint32, | ||
pack_uint32, | ||
) | ||
from modules.pokemon import get_opponent, opponent_changed | ||
from modules.tasks import task_is_active | ||
from modules.menuing import StartMenuNavigator, PokemonPartyMenuNavigator | ||
from modules.pokemon import get_party | ||
|
||
|
||
class ModeSweetScentStates(Enum): | ||
RESET = auto() | ||
SELECT_SCENT = auto() | ||
OVERWORLD = auto() | ||
BATTLE = auto() | ||
OPPONENT_CRY_START = auto() | ||
OPPONENT_CRY_END = auto() | ||
LOG_OPPONENT = auto() | ||
|
||
|
||
class ModeSweetScent: | ||
def __init__(self) -> None: | ||
self.navigator = None | ||
self.state: ModeSweetScentStates = ModeSweetScentStates.RESET | ||
|
||
def update_state(self, state: ModeSweetScentStates) -> None: | ||
self.state: ModeSweetScentStates = state | ||
|
||
def step(self): | ||
while True: | ||
match self.state: | ||
case ModeSweetScentStates.RESET: | ||
if task_is_active("Task_HandleChooseMonInput"): | ||
self.update_state(ModeSweetScentStates.SELECT_SCENT) | ||
elif not task_is_active("Task_RunPerStepCallback") or task_is_active("Task_ShowStartMenu"): | ||
context.emulator.press_button("B") | ||
yield | ||
else: | ||
self.update_state(ModeSweetScentStates.OVERWORLD) | ||
continue | ||
|
||
case ModeSweetScentStates.OVERWORLD: | ||
if self.navigator is None: | ||
self.navigator = StartMenuNavigator("POKEMON") | ||
else: | ||
yield from self.navigator.step() | ||
match self.navigator.current_step: | ||
case "exit": | ||
self.navigator = None | ||
self.update_state(ModeSweetScentStates.SELECT_SCENT) | ||
continue | ||
continue | ||
|
||
case ModeSweetScentStates.SELECT_SCENT: | ||
scent_poke = None | ||
for num, poke in enumerate(get_party()): | ||
if "Sweet Scent" in str(poke.moves): | ||
scent_poke = num | ||
break | ||
if scent_poke is None: | ||
raise Exception("No Pokemon with Sweet Scent in party") | ||
context.set_manual_mode() | ||
break | ||
else: | ||
if self.navigator is None: | ||
self.navigator = PokemonPartyMenuNavigator(scent_poke, "SWEET_SCENT") | ||
else: | ||
yield from self.navigator.step() | ||
match self.navigator.current_step: | ||
case "exit": | ||
self.navigator = None | ||
self.update_state(ModeSweetScentStates.BATTLE) | ||
continue | ||
continue | ||
|
||
case ModeSweetScentStates.BATTLE: | ||
if get_game_state() != GameState.BATTLE: | ||
context.emulator.press_button("A") | ||
else: | ||
self.update_state(ModeSweetScentStates.OPPONENT_CRY_START) | ||
continue | ||
|
||
case ModeSweetScentStates.OPPONENT_CRY_START: | ||
if not task_is_active("Task_DuckBGMForPokemonCry"): | ||
context.emulator.press_button("B") | ||
else: | ||
self.update_state(ModeSweetScentStates.OPPONENT_CRY_END) | ||
continue | ||
|
||
case ModeSweetScentStates.OPPONENT_CRY_END: | ||
if task_is_active("Task_DuckBGMForPokemonCry"): | ||
pass | ||
else: | ||
self.update_state(ModeSweetScentStates.LOG_OPPONENT) | ||
continue | ||
|
||
case ModeSweetScentStates.LOG_OPPONENT: | ||
encounter_pokemon(get_opponent()) | ||
return | ||
|
||
yield |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you're running the frame instead of yielding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It randomly breaks when yielding. Works about 50% with yield, 100% with single frame