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

Update adjustment table for recovery sequence for fly_to_closest_pokecenter_on_map() #491

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
24 changes: 18 additions & 6 deletions SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,15 @@ bool fly_to_visible_closest_pokecenter_cur_zoom_level(


void fly_to_closest_pokecenter_on_map(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){
const int max_try_count = 6;
const int max_try_count = 17;
int try_count = 0;
// Part 1: Tries to detect a pokecenter that is very close to the player
// Zoom in one level onto the map.
// If the player character icon or any wild pokemon icon overlaps with the PokeCenter icon, the code cannot
// detect it. So we zoom in as much as we can to prevent any icon overlap.
const std::array<double, max_try_count + 1> adjustment_table = {1, 1, 1, 1.1, 1.2, 0.9, 0.8};

// failures to fly to pokecenter are often when the Switch lags. from my testing, a 1.4-1.5 adjustment factor seems to work
const std::array<double, max_try_count> adjustment_table = {1, 1.4, 1, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 0.9, 0.8, 1.4}; // {1, 1.4, 1.5};

while(true){
try {
Expand All @@ -628,9 +630,14 @@ void fly_to_closest_pokecenter_on_map(const ProgramInfo& info, ConsoleHandle& co
// no visible pokecenters at this zoom level. Move on to part 2.
break;
}catch (OperationFailedException& e){ // pokecenter was detected, but failed to fly there
(void) e;
try_count++;
if (try_count > max_try_count){
throw e;
if (try_count >= max_try_count){
throw OperationFailedException(
ErrorReport::SEND_ERROR_REPORT, console,
"fly_to_closest_pokecenter_on_map(): At min warpable map level, pokecenter was detected, but failed to fly there.",
true
);
}
console.log("Failed to find the fly menu item. Restart the closest Pokecenter travel process.");
press_Bs_to_back_to_overworld(info, console, context);
Expand Down Expand Up @@ -676,9 +683,14 @@ void fly_to_closest_pokecenter_on_map(const ProgramInfo& info, ConsoleHandle& co
);
}
}catch (OperationFailedException& e){ // pokecenter was detected, but failed to fly there
(void) e;
try_count++;
if (try_count > max_try_count){
throw e;
if (try_count >= max_try_count){
throw OperationFailedException(
ErrorReport::SEND_ERROR_REPORT, console,
"fly_to_closest_pokecenter_on_map(): At max warpable map level, pokecenter was detected, but failed to fly there.",
true
);
}
console.log("Failed to find the fly menuitem. Restart the closest Pokecenter travel process.");
press_Bs_to_back_to_overworld(info, console, context);
Expand Down
Loading