Skip to content
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

Fix reset_to_pokecenter() #521

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,11 +773,22 @@ void jump_off_wall_until_map_open(const ProgramInfo& info, ConsoleHandle& consol

// Open map and teleport back to town pokecenter to reset the hunting path.
void reset_to_pokecenter(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){
size_t MAX_FAILURES = 5;
size_t num_failures = 0;
while (true){
try {
open_map_from_overworld(info, console, context);
fly_to_closest_pokecenter_on_map(info, console, context);
return;
}catch (UnexpectedBattleException&){
num_failures++;
if (num_failures > MAX_FAILURES){
throw OperationFailedException(
ErrorReport::SEND_ERROR_REPORT, console,
"reset_to_pokecenter(): Failed to reset to pokecenter. Repeatedly stuck in battle.",
true
);
}
run_battle_press_A(console, context, BattleStopCondition::STOP_OVERWORLD);
}
}
Expand Down
Loading