Repository navigation
PokemonFRLG: navigation helpers (Sevii Islands Fly, field moves, items, party order) - #1905
thewhitewolfking wants to merge 1 commit into
Conversation
…tems and party order
| // Then tap across to the town. | ||
| int corner_x = target.corner_right ? SEVII_MAP_WIDTH - 1 : 0; | ||
| int corner_y = target.corner_bottom ? SEVII_MAP_HEIGHT - 1 : 0; | ||
| int dx = target.x - corner_x; | ||
| int dy = target.y - corner_y; | ||
| fly_map_cursor_tap(context, dx > 0 ? DPAD_RIGHT : DPAD_LEFT, dx > 0 ? dx : -dx); | ||
| fly_map_cursor_tap(context, dy > 0 ? DPAD_DOWN : DPAD_UP, dy > 0 ? dy : -dy); |
There was a problem hiding this comment.
Flying from the Kanto map uses long presses rather than a series of taps, and these tend to be quite consistent. I'd prefer not to have two different approaches for the same thing, and the long presses will be slightly faster
| int y; | ||
| bool corner_right; | ||
| bool corner_bottom; | ||
| }; |
There was a problem hiding this comment.
The Kanto don't have their coordinates directly stored (I just recorded inputs manually and replayed them to test for consistency), and they always start from the top left corner for simplicity. This new approach is fine, but I'd prefer not to have two independent approaches for the same thing. See https://github.com/PokemonAutomation/Arduino-Source/blob/main/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp#L1029-L1079 for the Kanto approach
| void use_field_move_from_overworld(ConsoleHandle& console, ProControllerContext& context, int from_last, int field_move){ | ||
| uint16_t errors = 0; | ||
|
|
||
| while (true){ | ||
| if (errors > 5){ | ||
| OperationFailedExceptionWithScreenshot::fire( | ||
| ErrorReportMode::SEND_ERROR_REPORT, | ||
| "use_field_move_from_overworld(): Failed to open the Pokemon's menu 5 times in a row.", | ||
| console | ||
| ); | ||
| } | ||
|
|
||
| open_party_menu_from_overworld(console, context); | ||
| // From slot 1, up goes to CANCEL, then to the last slot, then upward. | ||
| for (int i = 0; i < 2 + from_last; i++){ | ||
| pbf_move_left_joystick(context, {0, +1}, 200ms, 300ms); | ||
| } | ||
|
|
||
| PartySelectionWatcher menu_opened(COLOR_RED); | ||
| context.wait_for_all_requests(); | ||
| int ret = run_until<ProControllerContext>( | ||
| console, context, | ||
| [](ProControllerContext& context){ | ||
| pbf_press_button(context, BUTTON_A, 200ms, 1800ms); | ||
| }, | ||
| { menu_opened } | ||
| ); | ||
| if (ret < 0){ | ||
| console.log("Failed to open the Pokemon's menu."); | ||
| errors++; | ||
| pbf_mash_button(context, BUTTON_B, 3000ms); | ||
| continue; | ||
| } | ||
|
|
||
| // The menu lists SUMMARY, then the field moves in the order the | ||
| // Pokemon knows them, then SWITCH, ITEM and CANCEL. | ||
| for (int i = 0; i < 1 + field_move; i++){ | ||
| pbf_move_left_joystick(context, {0, -1}, 200ms, 300ms); | ||
| } | ||
| pbf_press_button(context, BUTTON_A, 200ms, 800ms); | ||
| context.wait_for_all_requests(); | ||
| console.log("Used field move " + std::to_string(field_move + 1) + " of the Pokemon " + std::to_string(from_last) + " from the last."); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
This is a generalization of some existing functions for using Sweet Scent, Teleport, and Fly. Having this separate to avoid repeated code is good, but we should also incorporate it into open_fly_map_from_overworld, use_teleport_from_overworld, and use_sweet_scent_from_overworld to avoid redundancy
Third split-up piece of #1887: reusable navigation moved into PokemonFRLG_Navigation, as suggested in review. No OCR.
Testing: the timings come from #1887's EXP Farmer runs on hardware (flying to One and Seven Island from the top-left corner, Cut, Surf, Max Repel). New and not yet tested on hardware: flying from the other corners (Three, Four, Five, Six Island) and picking SWITCH by wrapping around the Pokemon's menu.