diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 8e65e03c2c..504befe9b1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -656,6 +656,36 @@ TeraEncounterAction tera_encounter_action( return TeraEncounterAction::Recover; } +bool send_out_and_look_around( + ConsoleHandle& console, ProControllerContext& context, + std::chrono::seconds first_wait, const std::string& target +){ + auto try_battle = [&](std::chrono::seconds timeout){ + ssf_press_button(context, BUTTON_ZR, 0ms, 1600ms); + ssf_press_button(context, BUTTON_ZL, 800ms, 400ms); + ssf_press_button(context, BUTTON_ZL, 1200ms, 400ms); + + pbf_wait(context, 2400ms); + context.wait_for_all_requests(); + + NormalBattleMenuWatcher battle_menu(COLOR_YELLOW); + return wait_until(console, context, timeout, { battle_menu }) == 0; + }; + + if (try_battle(first_wait)){ + return true; + } + for (int turn = 1; turn <= 3; turn++){ + console.log("Did not enter battle. Did " + target + " spawn? Looking around (" + std::to_string(turn) + "/3)."); + pbf_move_right_joystick(context, {+1, 0}, 480ms, 320ms); + if (try_battle(std::chrono::seconds(6))){ + return true; + } + } + console.log("Did not enter battle after looking around."); + return false; +} + void quest_tera_self_defeat( const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context, @@ -680,23 +710,9 @@ void quest_tera_self_defeat( jump_glide_fly(console, context, BBQ_OPTIONS.INVERTED_FLIGHT, 8000ms, 12800ms, 2400ms); } - ssf_press_button(context, BUTTON_ZR, 0ms, 1600ms); - ssf_press_button(context, BUTTON_ZL, 800ms, 400ms); - ssf_press_button(context, BUTTON_ZL, 1200ms, 400ms); - - pbf_wait(context, 2400ms); - context.wait_for_all_requests(); - - NormalBattleMenuWatcher battle_menu(COLOR_YELLOW); - int ret2 = wait_until( - console, context, - std::chrono::seconds(15), - { battle_menu } - ); - battle_menu_detected = ret2 == 0; - if (!battle_menu_detected){ - console.log("Did not enter battle. Did Kleavor spawn?"); - } + //The glide lands in the right place, but Kleavor is absent ~40% of the time. + //Any wild Pokemon counts, and Scyther roam the area. + battle_menu_detected = send_out_and_look_around(console, context, std::chrono::seconds(15), "Kleavor"); }, { static_cast(encounter_watcher), diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index 16593da3ac..a6b36e982c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -7,6 +7,8 @@ #ifndef PokemonAutomation_PokemonSV_BlueberryQuests_H #define PokemonAutomation_PokemonSV_BlueberryQuests_H +#include +#include #include #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" @@ -97,6 +99,14 @@ void quest_travel_500( ); //Run around until you encounter a pokemon. Tera, then defeat it by spamming your first move. +// Send out the lead at whatever is in front and wait for a battle. If none starts, +// turn the camera about a quarter at a time, up to three times, and try again. +// Returns true once the battle menu shows. +bool send_out_and_look_around( + ConsoleHandle& console, ProControllerContext& context, + std::chrono::seconds first_wait, const std::string& target +); + void quest_tera_self_defeat( const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context,