From 3590e222865cae7176c688b2c9580eeda489423d Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Thu, 5 Mar 2026 23:11:08 -0800 Subject: [PATCH 1/2] Refactor FRLG to use game cropping. --- .../Dialogs/PokemonFRLG_DialogDetector.cpp | 152 ++++++++++-------- .../Dialogs/PokemonFRLG_DialogDetector.h | 27 +++- .../PokemonFRLG_PrizeSelectDetector.cpp | 36 ++--- .../Menus/PokemonFRLG_LoadMenuDetector.cpp | 30 ++-- .../Menus/PokemonFRLG_StartMenuDetector.cpp | 27 ++-- .../PokemonFRLG_ShinySymbolDetector.cpp | 10 +- .../PokemonFRLG/PokemonFRLG_Navigation.cpp | 11 +- .../PokemonFRLG/PokemonFRLG_Settings.cpp | 8 + .../Source/PokemonFRLG/PokemonFRLG_Settings.h | 3 + .../ShinyHunting/PokemonFRLG_GiftReset.cpp | 5 +- .../PokemonFRLG_LegendaryReset.cpp | 2 - .../PokemonFRLG_LegendaryRunAway.cpp | 8 +- 12 files changed, 185 insertions(+), 134 deletions(-) diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp index ee93a8f46e..24d93462fc 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp @@ -26,46 +26,52 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ WhiteDialogDetector::WhiteDialogDetector(Color color) - : m_right_box(0.844, 0.725, 0.005, 0.197) - , m_top_box(0.151, 0.719, 0.698, 0.006) - , m_bottom_box(0.152, 0.913, 0.692, 0.009) + : m_right_box(0.923385, 0.748077, 0.00615385, 0.204577) + , m_top_box(0.0704615, 0.741846, 0.859077, 0.00623077) + , m_bottom_box(0.0716923, 0.943308, 0.851692, 0.00934615) {} void WhiteDialogDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_right_box); - items.add(COLOR_RED, m_top_box); - items.add(COLOR_RED, m_bottom_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); } bool WhiteDialogDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box); - ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); + ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); if (is_white(right_image) && is_white(top_image) && is_white(bottom_image) - ){ + ){ return true; } return false; } AdvanceWhiteDialogDetector::AdvanceWhiteDialogDetector(Color color) - : m_dialog_box(0.145, 0.727, 0.707, 0.193) - , m_right_box(0.844, 0.725, 0.005, 0.197) - , m_top_box(0.151, 0.719, 0.698, 0.006) - , m_bottom_box(0.152, 0.913, 0.692, 0.009) + : m_dialog_box(0.0630769, 0.750154, 0.870154, 0.200423) + , m_right_box(0.923385, 0.748077, 0.00615385, 0.204577) + , m_top_box(0.0704615, 0.741846, 0.859077, 0.00623077) + , m_bottom_box(0.0716923, 0.943308, 0.851692, 0.00934615) {} void AdvanceWhiteDialogDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_dialog_box); - items.add(COLOR_RED, m_right_box); - items.add(COLOR_RED, m_top_box); - items.add(COLOR_RED, m_bottom_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); } bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){ + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + const bool replace_color_within_range = false; //Filter out background ImageRGB32 filtered_region = filter_rgb32_range( - extract_box_reference(screen, m_dialog_box), + extract_box_reference(game_screen, m_dialog_box), combine_rgb(164, 0, 0), combine_rgb(255, 114, 87), Color(0), replace_color_within_range ); ImageStats stats = image_stats(filtered_region); @@ -77,64 +83,69 @@ bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){ cout << stats.average.b << endl; */ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box); - ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box); + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); + ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); if (is_white(right_image) && is_white(top_image) && is_white(bottom_image) && (stats.average.r > stats.average.b + 180) && (stats.average.r > stats.average.g + 180) - ) - { + ){ return true; } return false; } SelectionDialogDetector::SelectionDialogDetector(Color color) - : m_right_box(0.844, 0.725, 0.005, 0.197) - , m_top_box(00.151, 0.719, 0.698, 0.006) - , m_bottom_box(0.152, 0.913, 0.692, 0.009) - , m_selection_box(0.813, 0.436, 0.013, 0.195) + : m_right_box(0.923385, 0.748077, 0.00615385, 0.204577) + , m_top_box(0.0704615, 0.741846, 0.859077, 0.00623077) + , m_bottom_box(0.0716923, 0.943308, 0.851692, 0.00934615) + , m_selection_box(0.885231, 0.447962, 0.016, 0.2025) {} void SelectionDialogDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_right_box); - items.add(COLOR_RED, m_top_box); - items.add(COLOR_RED, m_bottom_box); - items.add(COLOR_RED, m_selection_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_selection_box)); } bool SelectionDialogDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box); - ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box); - ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); + ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); + ImageViewRGB32 selection_image = extract_box_reference(game_screen, m_selection_box); if (is_white(right_image) && is_white(top_image) && is_white(bottom_image) && is_white(selection_image) - ){ + ){ return true; } return false; } BattleDialogDetector::BattleDialogDetector(Color color) - : m_dialog_top_box(0.124, 0.727, 0.752, 0.009) - , m_dialog_right_box(0.871, 0.736, 0.005, 0.179) + : m_dialog_top_box(0.0372308, 0.750154, 0.925538, 0.00934615) + , m_dialog_right_box(0.956615, 0.7595, 0.00615385, 0.185885) {} void BattleDialogDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_dialog_top_box); - items.add(COLOR_RED, m_dialog_right_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_right_box)); } bool BattleDialogDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); - ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 dialog_top_image = extract_box_reference(game_screen, m_dialog_top_box); + ImageViewRGB32 dialog_right_image = extract_box_reference(game_screen, m_dialog_right_box); if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) - ){ + ){ return true; } return false; @@ -142,31 +153,34 @@ bool BattleDialogDetector::detect(const ImageViewRGB32& screen){ BattleMenuDetector::BattleMenuDetector(Color color) - : m_menu_top_box(0.523, 0.720, 0.357, 0.008) //top of the white dialog box - , m_menu_right_box(0.875, 0.729, 0.005, 0.193) - , m_dialog_top_box(0.123, 0.726, 0.373, 0.013) - , m_dialog_right_box(0.492, 0.739, 0.005, 0.172) //right side, closest to the menu + : m_menu_top_box(0.528308, 0.742885, 0.439385, 0.00830769) //top of the white dialog box + , m_menu_right_box(0.961538, 0.752231, 0.00615385, 0.200423) + , m_dialog_top_box(0.036, 0.749115, 0.459077, 0.0135) + , m_dialog_right_box(0.490154, 0.762615, 0.00615385, 0.178615) //right side, closest to the menu {} void BattleMenuDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_menu_top_box); - items.add(COLOR_RED, m_menu_right_box); - items.add(COLOR_RED, m_dialog_top_box); - items.add(COLOR_RED, m_dialog_right_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_menu_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_menu_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_right_box)); } bool BattleMenuDetector::detect(const ImageViewRGB32& screen){ + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + //Menu is white - ImageViewRGB32 menu_top_image = extract_box_reference(screen, m_menu_top_box); - ImageViewRGB32 menu_right_image = extract_box_reference(screen, m_menu_right_box); + ImageViewRGB32 menu_top_image = extract_box_reference(game_screen, m_menu_top_box); + ImageViewRGB32 menu_right_image = extract_box_reference(game_screen, m_menu_right_box); //Background dialog is teal - ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); - ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); + ImageViewRGB32 dialog_top_image = extract_box_reference(game_screen, m_dialog_top_box); + ImageViewRGB32 dialog_right_image = extract_box_reference(game_screen, m_dialog_right_box); if (is_white(menu_top_image) && is_white(menu_right_image) && is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) //40, 81, 106 teal && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) - ){ + ){ return true; } return false; @@ -174,21 +188,24 @@ bool BattleMenuDetector::detect(const ImageViewRGB32& screen){ AdvanceBattleDialogDetector::AdvanceBattleDialogDetector(Color color) - : m_dialog_box(0.123, 0.725, 0.753, 0.197) - , m_dialog_top_box(0.124, 0.727, 0.752, 0.009) - , m_dialog_right_box(0.871, 0.736, 0.005, 0.179) + : m_dialog_box(0.036, 0.748077, 0.926769, 0.204577) + , m_dialog_top_box(0.0372308, 0.750154, 0.925538, 0.00934615) + , m_dialog_right_box(0.956615, 0.7595, 0.00615385, 0.185885) {} void AdvanceBattleDialogDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_dialog_box); - items.add(COLOR_RED, m_dialog_top_box); - items.add(COLOR_RED, m_dialog_right_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_dialog_right_box)); } bool AdvanceBattleDialogDetector::detect(const ImageViewRGB32& screen){ + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + const bool replace_color_within_range = false; //Filter out background ImageRGB32 filtered_region = filter_rgb32_range( - extract_box_reference(screen, m_dialog_box), + extract_box_reference(game_screen, m_dialog_box), combine_rgb(164, 0, 0), combine_rgb(255, 114, 87), Color(0), replace_color_within_range ); ImageStats stats = image_stats(filtered_region); @@ -200,15 +217,14 @@ bool AdvanceBattleDialogDetector::detect(const ImageViewRGB32& screen){ cout << stats.average.b << endl; */ - ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); - ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); + ImageViewRGB32 dialog_top_image = extract_box_reference(game_screen, m_dialog_top_box); + ImageViewRGB32 dialog_right_image = extract_box_reference(game_screen, m_dialog_right_box); if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) && (stats.average.r > stats.average.b + 180) && (stats.average.r > stats.average.g + 180) - ) - { + ){ return true; } return false; diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h index ffaf3f020a..539df1d019 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h @@ -8,12 +8,13 @@ #define PokemonAutomation_PokemonFRLG_DialogDetector_H #include -#include -#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "Common/Cpp/Color.h" #include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/VisualDetector.h" +#include "CommonTools/VisualDetectors/BlackScreenDetector.h" #include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" +#include "PokemonFRLG/PokemonFRLG_Settings.h" namespace PokemonAutomation{ class CancellableScope; @@ -21,6 +22,28 @@ namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonFRLG{ + +class BlackScreenOverWatcher : public PokemonAutomation::BlackScreenOverWatcher{ +public: + BlackScreenOverWatcher(Color color = COLOR_RED) + : PokemonAutomation::BlackScreenOverWatcher( + color, + GameSettings::instance().GAME_BOX.inner_to_outer({0.231692, 0.0616538, 0.551385, 0.9045}) + ) + {} +}; +class WhiteScreenOverWatcher : public PokemonAutomation::WhiteScreenOverWatcher{ +public: + WhiteScreenOverWatcher(Color color = COLOR_RED) + : PokemonAutomation::WhiteScreenOverWatcher( + color, + GameSettings::instance().GAME_BOX.inner_to_outer({0.231692, 0.0616538, 0.551385, 0.9045}) + ) + {} +}; + + + // When given a choice popup, there is no advance arrow. // FRLG doesn't have an advance arrow on the final line of dialog when speaking to an npc! diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.cpp index 29e02d2534..95d84dd360 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_PrizeSelectDetector.cpp @@ -4,17 +4,14 @@ * */ -#include "CommonTools/Images/SolidColorTest.h" -#include "CommonTools/Images/ImageFilter.h" #include "CommonFramework/ImageTools/ImageBoxes.h" -#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/Images/SolidColorTest.h" +#include "CommonTools/Images/ImageFilter.h" #include "CommonTools/Images/WaterfillUtilities.h" -#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" +#include "PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_PrizeSelectDetector.h" namespace PokemonAutomation{ @@ -22,27 +19,30 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ PrizeSelectDetector::PrizeSelectDetector(Color color) - : m_right_box(0.812, 0.726, 0.013, 0.169) - , m_top_box(0.175, 0.715, 0.649, 0.005) - , m_bottom_box(0.177, 0.896, 0.645, 0.008) - , m_selection_box(0.667, 0.514, 0.173, 0.058) + : m_right_box(0.884, 0.749115, 0.016, 0.1755) + , m_top_box(0.1, 0.737692, 0.798769, 0.00519231) + , m_bottom_box(0.102462, 0.925654, 0.793846, 0.00830769) + , m_selection_box(0.705538, 0.528962, 0.212923, 0.0602308) {} void PrizeSelectDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_right_box); - items.add(COLOR_RED, m_top_box); - items.add(COLOR_RED, m_bottom_box); - items.add(COLOR_RED, m_selection_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_selection_box)); } bool PrizeSelectDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box); - ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box); - ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); + ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); + ImageViewRGB32 selection_image = extract_box_reference(game_screen, m_selection_box); if (is_solid(right_image, { 0.25, 0.38, 0.369 }) && is_solid(top_image, { 0.25, 0.38, 0.369 }) && is_solid(bottom_image, { 0.25, 0.38, 0.369 }) && is_solid(selection_image, { 0.25, 0.38, 0.369 }) - ){ + ){ return true; } return false; diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp index cbde7f37ba..239605f398 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.cpp @@ -4,17 +4,14 @@ * */ -#include "CommonTools/Images/SolidColorTest.h" -#include "CommonTools/Images/ImageFilter.h" #include "CommonFramework/ImageTools/ImageBoxes.h" -#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/Images/SolidColorTest.h" +#include "CommonTools/Images/ImageFilter.h" #include "CommonTools/Images/WaterfillUtilities.h" -#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" +#include "PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_LoadMenuDetector.h" namespace PokemonAutomation{ @@ -22,24 +19,27 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ LoadMenuDetector::LoadMenuDetector(Color color) - : m_right_box(0.859, 0.023, 0.042, 0.925) - , m_left_box(0.099, 0.022, 0.046, 0.926) - , m_save_box(0.773, 0.062, 0.047, 0.072) + : m_right_box(0.941846, 0.0190769, 0.0516923, 0.960577) + , m_left_box(0.00646154, 0.0180385, 0.0566154, 0.961615) + , m_save_box(0.836, 0.0595769, 0.0578462, 0.0747692) {} void LoadMenuDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_BLUE, m_right_box); - items.add(COLOR_BLUE, m_left_box); - items.add(COLOR_BLUE, m_save_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_BLUE, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_BLUE, GAME_BOX.inner_to_outer(m_left_box)); + items.add(COLOR_BLUE, GAME_BOX.inner_to_outer(m_save_box)); } bool LoadMenuDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 left_image = extract_box_reference(screen, m_left_box); - ImageViewRGB32 save_image = extract_box_reference(screen, m_save_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 left_image = extract_box_reference(game_screen, m_left_box); + ImageViewRGB32 save_image = extract_box_reference(game_screen, m_save_box); if (is_solid(right_image, { 0.244, 0.282, 0.474 }) //blue && is_solid(left_image, { 0.244, 0.282, 0.474 }) //blue && is_solid(save_image, { 0.25, 0.38, 0.369 }) //white - ){ + ){ return true; } return false; diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.cpp index fc955753a8..615acddbc8 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.cpp @@ -7,14 +7,12 @@ #include "CommonTools/Images/SolidColorTest.h" #include "CommonTools/Images/ImageFilter.h" #include "CommonFramework/ImageTools/ImageBoxes.h" -#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/Images/SolidColorTest.h" #include "CommonTools/Images/WaterfillUtilities.h" -#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" +#include "PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_StartMenuDetector.h" namespace PokemonAutomation{ @@ -22,23 +20,26 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ StartMenuDetector::StartMenuDetector(Color color) - : m_right_box(0.898, 0.751, 0.003, 0.195) - , m_top_box(0.097, 0.746, 0.804, 0.005) - , m_bottom_box(0.095, 0.941, 0.803, 0.006) + : m_right_box(0.989846, 0.775077, 0.00369231, 0.2025) + , m_top_box(0.004, 0.769885, 0.989538, 0.00519231) + , m_bottom_box(0.00153846, 0.972385, 0.988308, 0.00623077) {} void StartMenuDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_right_box); - items.add(COLOR_RED, m_top_box); - items.add(COLOR_RED, m_bottom_box); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); } bool StartMenuDetector::detect(const ImageViewRGB32& screen){ - ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); - ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box); - ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box); + ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + + ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); + ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); + ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); if (is_solid(right_image, { 0.00, 0.38, 0.62 }) && is_solid(top_image, { 0.00, 0.38, 0.62 }) && is_solid(bottom_image, { 0.00, 0.38, 0.62 }) - ){ + ){ return true; } return false; diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_ShinySymbolDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_ShinySymbolDetector.cpp index 30bd5b7184..0a3b816485 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_ShinySymbolDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_ShinySymbolDetector.cpp @@ -11,6 +11,7 @@ #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "CommonTools/Images/ImageFilter.h" +#include "PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_ShinySymbolDetector.h" //#include @@ -22,17 +23,20 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ ShinySymbolDetector::ShinySymbolDetector(Color color) - : m_box_symbol(0.436, 0.211, 0.033, 0.060) + : m_box_symbol(0.421231, 0.214308, 0.0406154, 0.0623077) {} void ShinySymbolDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_box_symbol); + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_box_symbol)); } bool ShinySymbolDetector::read(Logger& logger, const ImageViewRGB32& frame){ + ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + const bool replace_color_within_range = false; //Filter out background ImageRGB32 filtered_region = filter_rgb32_range( - extract_box_reference(frame, m_box_symbol), + extract_box_reference(game_screen, m_box_symbol), combine_rgb(193, 152, 0), combine_rgb(255, 255, 162), Color(0), replace_color_within_range ); ImageStats stats = image_stats(filtered_region); diff --git a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp index 31c885597d..8405dab656 100644 --- a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp +++ b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp @@ -9,7 +9,6 @@ #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Random.h" #include "CommonTools/Async/InferenceRoutines.h" -#include "CommonTools/VisualDetectors/BlackScreenDetector.h" #include "CommonTools/StartupChecks/StartProgramChecks.h" #include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -41,7 +40,7 @@ bool try_soft_reset(ConsoleHandle& console, ProControllerContext& context){ context.wait_for_all_requests(); //Mash A until white screen to game load menu - WhiteScreenOverWatcher whitescreen(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + WhiteScreenOverWatcher whitescreen(COLOR_RED); LoadMenuWatcher load_menu(COLOR_BLUE); int ls = run_until( @@ -70,7 +69,7 @@ bool try_soft_reset(ConsoleHandle& console, ProControllerContext& context){ pbf_press_button(context, BUTTON_A, 160ms, 320ms); //Wait for game to load in - BlackScreenOverWatcher detector(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher detector(COLOR_RED); int ret = wait_until( console, context, GameSettings::instance().ENTER_GAME_WAIT0, @@ -136,7 +135,7 @@ bool try_open_slot_six(ConsoleHandle& console, ProControllerContext& context){ } console.log("Navigating to party menu."); - BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher blk1(COLOR_RED); int pm = run_until( console, context, @@ -165,7 +164,7 @@ bool try_open_slot_six(ConsoleHandle& console, ProControllerContext& context){ pbf_press_dpad(context, DPAD_UP, 320ms, 320ms); //Two presses to open summary - BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher blk2(COLOR_RED); int sm = run_until( console, context, [](ProControllerContext& context) { @@ -317,7 +316,7 @@ void flee_battle(ConsoleHandle& console, ProControllerContext& context){ ); } - BlackScreenOverWatcher battle_over(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher battle_over(COLOR_RED); int ret3 = run_until( console, context, [](ProControllerContext& context) { diff --git a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp index e9cb60b166..40a6f6195d 100644 --- a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp +++ b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp @@ -22,6 +22,13 @@ GameSettings& GameSettings::instance(){ } GameSettings::GameSettings() : BatchOption(LockMode::LOCK_WHILE_RUNNING) + , GAME_BOX( + "Game Box: The part of the screen containing the actual video feed.", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::ALWAYS_ENABLED, + true, + {0.09375, 0.00462963, 0.8125, 0.962963} + ) , m_soft_reset_timings("Soft Reset Timings:") , SELECT_BUTTON_MASH0( "Start Button Mash:
Mash select for this long after a soft reset to get to Press Start.", @@ -50,6 +57,7 @@ GameSettings::GameSettings() 1000, 0, 48000 //2000 ) { + PA_ADD_STATIC(GAME_BOX); PA_ADD_STATIC(m_soft_reset_timings); PA_ADD_OPTION(SELECT_BUTTON_MASH0); PA_ADD_OPTION(ENTER_GAME_WAIT0); diff --git a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h index f899ccc96a..78a02bc066 100644 --- a/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h +++ b/SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h @@ -10,6 +10,7 @@ #include "Common/Cpp/Options/StaticTextOption.h" #include "Common/Cpp/Options/FloatingPointOption.h" #include "Common/Cpp/Options/TimeDurationOption.h" +#include "CommonFramework/Options/BoxOption.h" #include "CommonFramework/Panels/SettingsPanel.h" namespace PokemonAutomation{ @@ -22,6 +23,8 @@ class GameSettings : public BatchOption{ public: static GameSettings& instance(); + BoxOption GAME_BOX; + SectionDividerOption m_soft_reset_timings; MillisecondsOption SELECT_BUTTON_MASH0; MillisecondsOption ENTER_GAME_WAIT0; diff --git a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_GiftReset.cpp b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_GiftReset.cpp index 9e0606c7d5..ef31f9305f 100644 --- a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_GiftReset.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_GiftReset.cpp @@ -10,7 +10,6 @@ #include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" -#include "CommonTools/VisualDetectors/BlackScreenDetector.h" #include "CommonTools/StartupChecks/StartProgramChecks.h" #include "Pokemon/Pokemon_Strings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -267,7 +266,7 @@ bool GiftReset::try_open_summary(SingleSwitchProgramEnvironment& env, ProControl } //For starters, no Pokedex yet, do Pokemon is on top and we skip this //Open party menu - BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher blk1(COLOR_RED); int pm = run_until( env.console, context, @@ -293,7 +292,7 @@ bool GiftReset::try_open_summary(SingleSwitchProgramEnvironment& env, ProControl } //Two presses to open summary - BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher blk2(COLOR_RED); int sm = run_until( env.console, context, [](ProControllerContext& context) { diff --git a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp index f447d0d00a..70bbb1cbd1 100644 --- a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp @@ -11,11 +11,9 @@ #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" #include "CommonTools/VisualDetectors/BlackScreenDetector.h" -#include "CommonTools/StartupChecks/StartProgramChecks.h" #include "Pokemon/Pokemon_Strings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" -#include "PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h" #include "PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_LegendaryReset.h" diff --git a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryRunAway.cpp b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryRunAway.cpp index e5b58d3a1b..f6c845a77f 100644 --- a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryRunAway.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryRunAway.cpp @@ -114,7 +114,7 @@ LegendaryRunAway::LegendaryRunAway() } void LegendaryRunAway::reset_hooh(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - BlackScreenOverWatcher exit_area(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher exit_area(COLOR_RED); //Turn around, 10 steps down ssf_press_button(context, BUTTON_B, 0ms, HOOH_UP_DOWN); pbf_press_dpad(context, DPAD_DOWN, HOOH_UP_DOWN, 160ms); @@ -141,7 +141,7 @@ void LegendaryRunAway::reset_hooh(SingleSwitchProgramEnvironment& env, ProContro env.log("Left area."); } - BlackScreenOverWatcher enter_area(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher enter_area(COLOR_RED); //turn left, take one step. now turn back right and take a step. wait for black screen over. int ret2 = run_until( env.console, context, @@ -178,7 +178,7 @@ void LegendaryRunAway::reset_hooh(SingleSwitchProgramEnvironment& env, ProContro } void LegendaryRunAway::reset_lugia(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - BlackScreenOverWatcher exit_area(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher exit_area(COLOR_RED); //Turn around, 5 steps down ssf_press_button(context, BUTTON_B, 0ms, LUGIA_UP_DOWN); pbf_press_dpad(context, DPAD_DOWN, LUGIA_UP_DOWN, 160ms); @@ -206,7 +206,7 @@ void LegendaryRunAway::reset_lugia(SingleSwitchProgramEnvironment& env, ProContr env.log("Left area."); } - BlackScreenOverWatcher enter_area(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenOverWatcher enter_area(COLOR_RED); //turn up, take one step. then turn back down and take a step. wait for black screen over. int ret2 = run_until( env.console, context, From 49e1e3e8b31f6447fb2dced1a04c31d497d8c553 Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Fri, 6 Mar 2026 00:39:33 -0800 Subject: [PATCH 2/2] rebase --- .../Dialogs/PokemonFRLG_DialogDetector.h | 21 +++++++++++++------ .../PokemonFRLG_LegendaryReset.cpp | 5 ++--- .../PokemonFRLG_ShinyHunt-Overworld.cpp | 17 ++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h index 539df1d019..0a0c42eb2c 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h @@ -23,19 +23,28 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -class BlackScreenOverWatcher : public PokemonAutomation::BlackScreenOverWatcher{ +class WhiteScreenOverWatcher : public PokemonAutomation::WhiteScreenOverWatcher{ public: - BlackScreenOverWatcher(Color color = COLOR_RED) - : PokemonAutomation::BlackScreenOverWatcher( + WhiteScreenOverWatcher(Color color = COLOR_RED) + : PokemonAutomation::WhiteScreenOverWatcher( color, GameSettings::instance().GAME_BOX.inner_to_outer({0.231692, 0.0616538, 0.551385, 0.9045}) ) {} }; -class WhiteScreenOverWatcher : public PokemonAutomation::WhiteScreenOverWatcher{ +class BlackScreenWatcher : public PokemonAutomation::BlackScreenWatcher{ public: - WhiteScreenOverWatcher(Color color = COLOR_RED) - : PokemonAutomation::WhiteScreenOverWatcher( + BlackScreenWatcher(Color color = COLOR_RED) + : PokemonAutomation::BlackScreenWatcher( + color, + GameSettings::instance().GAME_BOX.inner_to_outer({0.231692, 0.0616538, 0.551385, 0.9045}) + ) + {} +}; +class BlackScreenOverWatcher : public PokemonAutomation::BlackScreenOverWatcher{ +public: + BlackScreenOverWatcher(Color color = COLOR_RED) + : PokemonAutomation::BlackScreenOverWatcher( color, GameSettings::instance().GAME_BOX.inner_to_outer({0.231692, 0.0616538, 0.551385, 0.9045}) ) diff --git a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp index 70bbb1cbd1..584db054d7 100644 --- a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp @@ -10,9 +10,8 @@ #include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" -#include "CommonTools/VisualDetectors/BlackScreenDetector.h" -#include "Pokemon/Pokemon_Strings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Pokemon/Pokemon_Strings.h" #include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" #include "PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_LegendaryReset.h" @@ -101,7 +100,7 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, ProControllerC pbf_press_button(context, BUTTON_A, 320ms, 320ms); //Mash B until black screen detected but not over (entered battle) - BlackScreenWatcher battle_entered(COLOR_RED, {0.282, 0.064, 0.448, 0.871}); + BlackScreenWatcher battle_entered(COLOR_RED); int ret = run_until( env.console, context, [](ProControllerContext& context){ diff --git a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_ShinyHunt-Overworld.cpp b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_ShinyHunt-Overworld.cpp index 1b47950a2d..a1d8016d82 100644 --- a/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_ShinyHunt-Overworld.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_ShinyHunt-Overworld.cpp @@ -4,19 +4,15 @@ * */ -#include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" -#include "CommonTools/VisualDetectors/BlackScreenDetector.h" -#include "CommonTools/StartupChecks/StartProgramChecks.h" -#include "Pokemon/Pokemon_Strings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h" +#include "Pokemon/Pokemon_Strings.h" #include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" -#include "PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h" #include "PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_ShinyHunt-Overworld.h" @@ -50,7 +46,7 @@ struct ShinyHuntOverworld_Descriptor::Stats : public StatsTracker{ std::atomic& shinies; std::atomic& errors; }; -std::unique_ptr ShinyHuntOverworld_Descriptor::make_stats() const { +std::unique_ptr ShinyHuntOverworld_Descriptor::make_stats() const{ return std::unique_ptr(new Stats()); } @@ -149,16 +145,15 @@ void ShinyHuntOverworld::program(SingleSwitchProgramEnvironment& env, ProControl bool ShinyHuntOverworld::find_encounter(SingleSwitchProgramEnvironment& env, ProControllerContext& context) const { - BlackScreenWatcher battle_entered(COLOR_RED, { 0.282, 0.064, 0.448, 0.871 }); + BlackScreenWatcher battle_entered(COLOR_RED); Milliseconds normal_duration = MOVE_DURATION0; Milliseconds biased_duration = MOVE_DURATION0.get() + 200ms; Milliseconds mash_duration = normal_duration - 64ms; int ret = 1; - while (ret != 0) - { - switch (TRIGGER_METHOD) { + while (ret != 0){ + switch (TRIGGER_METHOD){ case TriggerMethod::HORIZONTAL_NO_BIAS: ret = run_until( env.console, context, @@ -240,4 +235,4 @@ bool ShinyHuntOverworld::find_encounter(SingleSwitchProgramEnvironment& env, Pro } } -} \ No newline at end of file +}