From 88d0f36726d5b99310ef2366fad78c1b5a5c2dfc Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 21 Apr 2025 17:31:18 -0400 Subject: [PATCH 1/8] copy sound detector and listener for LGPE --- SerialPrograms/CMakeLists.txt | 4 + SerialPrograms/SerialPrograms.pro | 4 + .../Sounds/PokemonLGPE_ShinySoundDetector.cpp | 47 +++++++++ .../Sounds/PokemonLGPE_ShinySoundDetector.h | 36 +++++++ .../PokemonLGPE_SoundListener.cpp | 97 +++++++++++++++++++ .../TestPrograms/PokemonLGPE_SoundListener.h | 54 +++++++++++ 6 files changed, 242 insertions(+) create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h create mode 100644 SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp create mode 100644 SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 1b9636eca3..636b7b0c59 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1375,6 +1375,8 @@ file(GLOB MAIN_SOURCES Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h + Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp + Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp @@ -1385,6 +1387,8 @@ file(GLOB MAIN_SOURCES Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.h Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.cpp Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.h + Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp + Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h Source/PokemonLGPE/PokemonLGPE_Panels.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index 2208fc3705..57a04f601b 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -674,11 +674,13 @@ SOURCES += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp \ + Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.cpp \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.cpp \ + Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp \ Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp \ Source/PokemonLGPE/PokemonLGPE_Panels.cpp \ Source/PokemonLGPE/PokemonLGPE_Settings.cpp \ @@ -1869,11 +1871,13 @@ HEADERS += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h \ + Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.h \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.h \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.h \ + Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h \ Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h \ Source/PokemonLGPE/PokemonLGPE_Panels.h \ Source/PokemonLGPE/PokemonLGPE_Settings.h \ diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp b/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp new file mode 100644 index 0000000000..f1d9cdb9c7 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp @@ -0,0 +1,47 @@ +/* Shiny Sound Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonTools/Audio/AudioTemplateCache.h" +#include "CommonTools/Audio/SpectrogramMatcher.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "PokemonLGPE/PokemonLGPE_Settings.h" +#include "PokemonLGPE_ShinySoundDetector.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + + +ShinySoundDetector::ShinySoundDetector(Logger& logger, DetectedCallback detected_callback) + // Use a yellow as the detection color because the shiny animation is yellow. + : AudioPerSpectrumDetectorBase( + logger, + "ShinySoundDetector", + "Shiny sound", + COLOR_YELLOW, + detected_callback + ) +{} + + +float ShinySoundDetector::get_score_threshold() const{ + return (float)GameSettings::instance().SHINY_SOUND_THRESHOLD; +} + +std::unique_ptr ShinySoundDetector::build_spectrogram_matcher(size_t sample_rate){ + return std::make_unique( + "Shiny Sound", + AudioTemplateCache::instance().get_throw("PokemonLGPE/ShinySound", sample_rate), + SpectrogramMatcher::Mode::SPIKE_CONV, sample_rate, + GameSettings::instance().SHINY_SOUND_LOW_FREQUENCY + ); +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h b/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h new file mode 100644 index 0000000000..cd76bcd059 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h @@ -0,0 +1,36 @@ +/* Shiny Sound Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLGPE_ShinySoundDetector_H +#define PokemonAutomation_PokemonLGPE_ShinySoundDetector_H + +#include "CommonTools/Audio/AudioPerSpectrumDetectorBase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + + +class ShinySoundDetector : public AudioPerSpectrumDetectorBase{ +public: + // Warning: The callback will be called from the audio inference thread. + ShinySoundDetector(Logger& logger, DetectedCallback detected_callback); + + // Implement AudioPerSpectrumDetectorBase::get_score_threshold() + virtual float get_score_threshold() const override; + +protected: + // Implement AudioPerSpectrumDetectorBase::build_spectrogram_matcher() + virtual std::unique_ptr build_spectrogram_matcher(size_t sample_rate) override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp new file mode 100644 index 0000000000..7eb3e1ba31 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp @@ -0,0 +1,97 @@ +/* Sound Listener + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Containers/AlignedVector.tpp" +#include "CommonFramework/AudioPipeline/AudioFeed.h" +#include "CommonFramework/AudioPipeline/AudioTemplate.h" +#include "CommonTools/Audio/AudioTemplateCache.h" +#include "CommonTools/Audio/SpectrogramMatcher.h" +#include "CommonTools/Async/InferenceSession.h" +#include "Pokemon/Pokemon_Strings.h" +#include "PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h" +#include "PokemonLGPE_SoundListener.h" + + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + using namespace Pokemon; + + +SoundListener_Descriptor::SoundListener_Descriptor() + : SingleSwitchProgramDescriptor( + "PokemonLGPE:SoundListener", + STRING_POKEMON + " LGPE", "Sound Listener", + "", + "Test sound detectors listening to audio stream.", + FeedbackType::REQUIRED, AllowCommandsWhenRunning::ENABLE_COMMANDS, + {ControllerFeature::NintendoSwitch_ProController} + ) +{} + + +SoundListener::SoundListener() + : SOUND_TYPE("Which Sound to Detect", + { + {SoundType::SHINY, "shiny", "Shiny Sound"}, + }, + LockMode::LOCK_WHILE_RUNNING, + SoundType::SHINY + ) + , STOP_ON_DETECTED_SOUND( + "Stop on the detected sound
Stop program when the sound is detected.", + LockMode::LOCK_WHILE_RUNNING, + false + ) +{ + PA_ADD_OPTION(SOUND_TYPE); + PA_ADD_OPTION(STOP_ON_DETECTED_SOUND); +} + +void SoundListener::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + std::cout << "Running audio test program." << std::endl; + + std::shared_ptr detector; + auto action = [&](float error_coefficient) -> bool{ + // This lambda function will be called when the sound is detected. + // Its return will determine whether to stop the program: + return STOP_ON_DETECTED_SOUND; + }; + + SoundType type = SOUND_TYPE; + switch (type){ + case SoundType::SHINY: + detector = std::make_shared(env.console, action); + break; + default: + throw InternalProgramError( + &env.logger(), PA_CURRENT_FUNCTION, + "Not such sound detector as sound type " + std::to_string((size_t)type) + ); + return; + } + + InferenceSession session( + context, env.console, + {{*detector, std::chrono::milliseconds(20)}} + ); + context.wait_until_cancel(); + + std::cout << "Audio test program Sound listener finished." << std::endl; +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h new file mode 100644 index 0000000000..c4da58aa7b --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h @@ -0,0 +1,54 @@ +/* Sound Listener + * + * From: https://github.com/PokemonAutomation/ + * + * Debug program to test all kinds of sound detectors. + */ + +#ifndef PokemonAutomation_PokemonLGPE_SoundListener_H +#define PokemonAutomation_PokemonLGPE_SoundListener_H + +#include "Common/Cpp/Options/BooleanCheckBoxOption.h" +#include "Common/Cpp/Options/EnumDropdownOption.h" +#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" +//#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + + +class SoundListener_Descriptor : public SingleSwitchProgramDescriptor{ +public: + SoundListener_Descriptor(); +}; + + +class SoundListener : public SingleSwitchProgramInstance{ +public: + SoundListener(); + + virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override; + + virtual void start_program_border_check( + CancellableScope& scope, + VideoStream& stream, + FeedbackType feedback_type + ) override{} + +private: + enum class SoundType{ + SHINY, + }; + + EnumDropdownOption SOUND_TYPE; + BooleanCheckBoxOption STOP_ON_DETECTED_SOUND; +}; + + + + +} +} +} +#endif From ef1c5ab4d71e6776f0144c3b910da7da75d9ecb8 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 21 Apr 2025 17:56:21 -0400 Subject: [PATCH 2/8] setting and panel --- .../Source/PokemonLGPE/PokemonLGPE_Panels.cpp | 7 +++++++ .../Source/PokemonLGPE/PokemonLGPE_Settings.cpp | 15 +++++++++++++++ .../Source/PokemonLGPE/PokemonLGPE_Settings.h | 4 ++++ .../TestPrograms/PokemonLGPE_SoundListener.cpp | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp index 31fff24aa0..70a3d71f98 100644 --- a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp +++ b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp @@ -14,6 +14,8 @@ #include "Programs/ShinyHunting/PokemonLGPE_FossilRevival.h" #include "Programs/ShinyHunting/PokemonLGPE_GiftReset.h" +#include "Programs/TestPrograms/PokemonLGPE_SoundListener.h" + namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonLGPE{ @@ -36,6 +38,11 @@ std::vector PanelListFactory::make_panels() const{ ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); + if (PreloadSettings::instance().DEVELOPER_MODE){ + ret.emplace_back("---- Developer Tools ----"); + ret.emplace_back(make_single_switch_program()); + } + return ret; } diff --git a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.cpp b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.cpp index cf99cdc421..db04e2536b 100644 --- a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.cpp +++ b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.cpp @@ -48,6 +48,17 @@ GameSettings::GameSettings() LockMode::LOCK_WHILE_RUNNING, "15 s" ) + , m_shiny_audio_settings("Shiny Audio Settings:") + , SHINY_SOUND_THRESHOLD( + "Shiny Sound Threshold:
Maximum error coefficient to trigger a shiny detection.", + LockMode::LOCK_WHILE_RUNNING, + 0.95, 0, 1.0 + ) + , SHINY_SOUND_LOW_FREQUENCY( + "Shiny Sound Low Frequency (Hz):
High pass filter frequency for shiny sound.", + LockMode::LOCK_WHILE_RUNNING, + 1000, 0, 48000 + ) { PA_ADD_STATIC(m_general); @@ -59,6 +70,10 @@ GameSettings::GameSettings() PA_ADD_OPTION(START_GAME_WAIT1); PA_ADD_OPTION(ENTER_GAME_MASH0); PA_ADD_OPTION(ENTER_GAME_WAIT0); + + PA_ADD_STATIC(m_shiny_audio_settings); + PA_ADD_OPTION(SHINY_SOUND_THRESHOLD); + PA_ADD_OPTION(SHINY_SOUND_LOW_FREQUENCY); } diff --git a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.h b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.h index 792dd6e0a4..cbaa1135e6 100644 --- a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.h +++ b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Settings.h @@ -32,6 +32,10 @@ class GameSettings : public BatchOption{ MillisecondsOption START_GAME_WAIT1; MillisecondsOption ENTER_GAME_MASH0; MillisecondsOption ENTER_GAME_WAIT0; + + SectionDividerOption m_shiny_audio_settings; + FloatingPointOption SHINY_SOUND_THRESHOLD; + FloatingPointOption SHINY_SOUND_LOW_FREQUENCY; }; diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp index 7eb3e1ba31..86468d6e6f 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp @@ -35,7 +35,7 @@ SoundListener_Descriptor::SoundListener_Descriptor() "", "Test sound detectors listening to audio stream.", FeedbackType::REQUIRED, AllowCommandsWhenRunning::ENABLE_COMMANDS, - {ControllerFeature::NintendoSwitch_ProController} + {ControllerFeature::NintendoSwitch_RightJoycon} ) {} From 0896e03d97f679fc8410a6dcac84c4029b2e3565 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 21 Apr 2025 18:53:27 -0400 Subject: [PATCH 3/8] lgpe battle menu detector --- SerialPrograms/CMakeLists.txt | 2 + SerialPrograms/SerialPrograms.pro | 2 + .../PokemonLGPE_BattleMenuDetector.cpp | 44 ++++++++++++++ .../Battles/PokemonLGPE_BattleMenuDetector.h | 60 +++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 636b7b0c59..6220a3dd35 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1375,6 +1375,8 @@ file(GLOB MAIN_SOURCES Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index 57a04f601b..2875038039 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -674,6 +674,7 @@ SOURCES += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp \ + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp \ Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp \ @@ -1871,6 +1872,7 @@ HEADERS += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h \ + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h \ Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.h \ diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp new file mode 100644 index 0000000000..47ed6cd793 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp @@ -0,0 +1,44 @@ +/* Battle Menu Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#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 "PokemonLGPE_BattleMenuDetector.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +BattleMenuDetector::BattleMenuDetector(Color color) + : m_your_box(0.114, 0.916, 0.016, 0.027) + , m_opponent_box(0.904, 0.048, 0.022, 0.031) +{} +void BattleMenuDetector::make_overlays(VideoOverlaySet& items) const{ + items.add(COLOR_RED, m_your_box); + items.add(COLOR_RED, m_opponent_box); +} +bool BattleMenuDetector::detect(const ImageViewRGB32& screen) const{ + ImageViewRGB32 left_image = extract_box_reference(screen, m_your_box); + ImageViewRGB32 right_image = extract_box_reference(screen, m_opponent_box); + + //Has a bit of a gradient in the box + //TODO: Do more boxes, horizonal so less gradient variation. + if (is_solid(left_image, { 0.040, 0.467, 0.493 }) && is_solid(right_image, { 0.074, 0.458, 0.468 })){ + return true; + } + return false; +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h new file mode 100644 index 0000000000..e88d44f70d --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h @@ -0,0 +1,60 @@ +/* Battle Menu Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLGPE_BattleMenuDetector_H +#define PokemonAutomation_PokemonLGPE_BattleMenuDetector_H + +#include +#include +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "Common/Cpp/Color.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonTools/VisualDetector.h" +#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" + +namespace PokemonAutomation{ + class CancellableScope; + class VideoFeed; +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +//Detect the light blue of your HP box and your opponent's HP box +class BattleMenuDetector : public StaticScreenDetector{ +public: + BattleMenuDetector(Color color); + + virtual void make_overlays(VideoOverlaySet& items) const override; + virtual bool detect(const ImageViewRGB32& screen) const override; + +private: + ImageFloatBox m_your_box; + ImageFloatBox m_opponent_box; +}; +class BattleMenuWatcher : public DetectorToFinder{ +public: + BattleMenuWatcher(Color color) + : DetectorToFinder("BattleMenuWatcher", std::chrono::milliseconds(250), color) + {} +}; + +//Battle dialog detector - white of the box + +/* +Possible future improvements: +Detect arrow and position +|Fight|Pokemon|Bag|Run| for wild battle +|---|Fight|Pokemon|Bag| for trainer battle +(align right) + +Detect Y Info button located next to menu. +Don't know what changes for a double battle. +*/ + +} +} +} + +#endif From 50d66113e5803ad808ad9c22c3ce2672a08fe601 Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 21 Apr 2025 19:56:37 -0400 Subject: [PATCH 4/8] partial working legendary reset, soundlistener fixes --- SerialPrograms/CMakeLists.txt | 2 + SerialPrograms/SerialPrograms.pro | 2 + .../Source/PokemonLGPE/PokemonLGPE_Panels.cpp | 2 + .../PokemonLGPE_LegendaryReset.cpp | 168 ++++++++++++++++++ .../ShinyHunting/PokemonLGPE_LegendaryReset.h | 51 ++++++ .../PokemonLGPE_SoundListener.cpp | 9 +- .../TestPrograms/PokemonLGPE_SoundListener.h | 3 +- 7 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp create mode 100644 SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 6220a3dd35..b2fe03b0e8 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1389,6 +1389,8 @@ file(GLOB MAIN_SOURCES Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.h Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.cpp Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.h + Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp + Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index 2875038039..d8b9911304 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -681,6 +681,7 @@ SOURCES += \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.cpp \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.cpp \ + Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp \ Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp \ Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp \ Source/PokemonLGPE/PokemonLGPE_Panels.cpp \ @@ -1879,6 +1880,7 @@ HEADERS += \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_FossilRevival.h \ Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_GiftReset.h \ + Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h \ Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h \ Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h \ Source/PokemonLGPE/PokemonLGPE_Panels.h \ diff --git a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp index 70a3d71f98..e0d229ac79 100644 --- a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp +++ b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp @@ -13,6 +13,7 @@ #include "Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h" #include "Programs/ShinyHunting/PokemonLGPE_FossilRevival.h" #include "Programs/ShinyHunting/PokemonLGPE_GiftReset.h" +#include "Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h" #include "Programs/TestPrograms/PokemonLGPE_SoundListener.h" @@ -37,6 +38,7 @@ std::vector PanelListFactory::make_panels() const{ ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); + ret.emplace_back(make_single_switch_program()); if (PreloadSettings::instance().DEVELOPER_MODE){ ret.emplace_back("---- Developer Tools ----"); diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp new file mode 100644 index 0000000000..4beff2a3b8 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp @@ -0,0 +1,168 @@ +/* LGPE Legendary Reset + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/ProgramStats/StatsTracking.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "CommonTools/StartupChecks/VideoResolutionCheck.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h" +#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" +#include "Pokemon/Pokemon_Strings.h" +#include "CommonTools/VisualDetectors/BlackScreenDetector.h" +#include "PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h" +#include "PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h" +#include "PokemonLGPE/Programs/PokemonLGPE_GameEntry.h" +#include "PokemonLGPE_LegendaryReset.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +LegendaryReset_Descriptor::LegendaryReset_Descriptor() + : SingleSwitchProgramDescriptor( + "PokemonLGPE:LegendaryReset", + Pokemon::STRING_POKEMON + " LGPE", "Legendary Reset", + "ComputerControl/blob/master/Wiki/Programs/PokemonLGPE/LegendaryReset.md", + "Shiny hunt Legendary Pokemon by resetting the game.", + FeedbackType::VIDEO_AUDIO, + AllowCommandsWhenRunning::DISABLE_COMMANDS, + {ControllerFeature::NintendoSwitch_RightJoycon}, + FasterIfTickPrecise::NOT_FASTER + ) +{} + +struct LegendaryReset_Descriptor::Stats : public StatsTracker{ + Stats() + : resets(m_stats["Resets"]) + , shinies(m_stats["Shinies"]) + { + m_display_order.emplace_back("Resets"); + m_display_order.emplace_back("Shinies"); + } + std::atomic& resets; + std::atomic& shinies; +}; +std::unique_ptr LegendaryReset_Descriptor::make_stats() const{ + return std::unique_ptr(new Stats()); +} + +LegendaryReset::LegendaryReset() + : GO_HOME_WHEN_DONE(true) + , NOTIFICATION_SHINY( + "Shiny Found", + true, true, ImageAttachmentMode::JPG, + {"Notifs", "Showcase"} + ) + , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) + , NOTIFICATIONS({ + &NOTIFICATION_SHINY, + &NOTIFICATION_STATUS_UPDATE, + &NOTIFICATION_PROGRAM_FINISH, + }) +{ + PA_ADD_OPTION(GO_HOME_WHEN_DONE); + PA_ADD_OPTION(NOTIFICATIONS); +} + +bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconContext& context){ + float shiny_coefficient = 1.0; + ShinySoundDetector shiny_detector(env.logger(), [&](float error_coefficient) -> bool{ + shiny_coefficient = error_coefficient; + return true; + }); + BattleMenuWatcher battle_started(COLOR_YELLOW); + + env.log("Starting battle."); + pbf_mash_button(context, BUTTON_A, 25000ms); //10000ms + context.wait_for_all_requests(); + + int res = run_until( + env.console, context, + [&](JoyconContext& context) { + int ret = wait_until( + env.console, context, + std::chrono::seconds(90), + {{battle_started}} + ); + if (ret == 0) { + env.log("HP boxes detected."); + } else { + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "run_battle(): Did not detect battle start.", + env.console + ); + } + pbf_wait(context, 1000ms); + context.wait_for_all_requests(); + }, + {{shiny_detector}} + ); + shiny_detector.throw_if_no_sound(); + if (res == 0){ + env.log("Shiny detected!"); + return true; + } + env.log("Shiny not found."); + + return false; +} + +void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableScope& scope){ + JoyconContext context(scope, env.console.controller()); + assert_16_9_720p_min(env.logger(), env.console); + LegendaryReset_Descriptor::Stats& stats = env.current_stats(); + + /* + Setup: + Stand in front of encounter. (And save) + Start the program in game. + Your lead must not be shiny. + + Settings: + Text Speed fast + Skip cutscene option? + + Mewtwo, Articuno, Zapdos, Moltres, Snorlax, Electrode(?) + Don't do it on the first Snorlax, otherwise have to sit through fuji tutorial + */ + + while (true) { + bool encounter_battle = run_battle(env, context); + if (encounter_battle) { + stats.shinies++; + env.update_stats(); + send_program_notification(env, NOTIFICATION_SHINY, COLOR_YELLOW, "Shiny found!", {}, "", env.console.video().snapshot(), true); + break; + } + env.log("No shiny found. Resetting game."); + send_program_status_notification( + env, NOTIFICATION_STATUS_UPDATE, + "No shiny found. Resetting game." + ); + + //Reset game + pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms); + reset_game_from_home(env, env.console, context, 3000ms); + context.wait_for_all_requests(); + + stats.resets++; + env.update_stats(); + } + + if (GO_HOME_WHEN_DONE) { + pbf_press_button(context, BUTTON_HOME, 200ms, 1000ms); + } + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); +} + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h new file mode 100644 index 0000000000..020e244d7c --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h @@ -0,0 +1,51 @@ +/* LGPE Legendary Reset + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLGPE_LegendaryReset_H +#define PokemonAutomation_PokemonLGPE_LegendaryReset_H + +#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h" +#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" +#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" +#include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +class LegendaryReset_Descriptor : public SingleSwitchProgramDescriptor{ +public: + LegendaryReset_Descriptor(); + struct Stats; + virtual std::unique_ptr make_stats() const override; +}; + +class LegendaryReset : public SingleSwitchProgramInstance{ +public: + LegendaryReset(); + virtual void program(SingleSwitchProgramEnvironment& env, CancellableScope& scope) override; + +private: + bool run_battle(SingleSwitchProgramEnvironment& env, JoyconContext& context); + + GoHomeWhenDoneOption GO_HOME_WHEN_DONE; + + EventNotificationOption NOTIFICATION_SHINY; + EventNotificationOption NOTIFICATION_STATUS_UPDATE; + EventNotificationsOption NOTIFICATIONS; +}; + + + + +} +} +} +#endif + + + diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp index 86468d6e6f..7143770985 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp @@ -18,10 +18,10 @@ #include "CommonTools/Audio/SpectrogramMatcher.h" #include "CommonTools/Async/InferenceSession.h" #include "Pokemon/Pokemon_Strings.h" +#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h" #include "PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h" #include "PokemonLGPE_SoundListener.h" - namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonLGPE{ @@ -35,7 +35,8 @@ SoundListener_Descriptor::SoundListener_Descriptor() "", "Test sound detectors listening to audio stream.", FeedbackType::REQUIRED, AllowCommandsWhenRunning::ENABLE_COMMANDS, - {ControllerFeature::NintendoSwitch_RightJoycon} + {ControllerFeature::NintendoSwitch_RightJoycon}, + FasterIfTickPrecise::NOT_FASTER ) {} @@ -58,7 +59,9 @@ SoundListener::SoundListener() PA_ADD_OPTION(STOP_ON_DETECTED_SOUND); } -void SoundListener::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ +void SoundListener::program(SingleSwitchProgramEnvironment& env, CancellableScope& scope){ + JoyconContext context(scope, env.console.controller()); + std::cout << "Running audio test program." << std::endl; std::shared_ptr detector; diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h index c4da58aa7b..ad31b0add0 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.h @@ -27,8 +27,7 @@ class SoundListener_Descriptor : public SingleSwitchProgramDescriptor{ class SoundListener : public SingleSwitchProgramInstance{ public: SoundListener(); - - virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override; + virtual void program(SingleSwitchProgramEnvironment& env, CancellableScope& scope) override; virtual void start_program_border_check( CancellableScope& scope, From d29f3c9623aaef5016984b14e5300f56223cf04c Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Mon, 21 Apr 2025 20:42:06 -0400 Subject: [PATCH 5/8] target selection --- .../PokemonLGPE_LegendaryReset.cpp | 25 +++++++++++++++++-- .../ShinyHunting/PokemonLGPE_LegendaryReset.h | 7 ++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp index 4beff2a3b8..e0505e15ed 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp @@ -53,7 +53,17 @@ std::unique_ptr LegendaryReset_Descriptor::make_stats() const{ } LegendaryReset::LegendaryReset() - : GO_HOME_WHEN_DONE(true) + : TARGET( + "Target:
", + { + {Target::mewtwo, "mewtwo", "Mewtwo, Articuno, Zapdos, Moltres"}, + {Target::snorlax, "snorlax", "Snorlax"}, + //{Target::snorlax2, "snorlax2", "Snorlax (w/Fuji)"}, + }, + LockMode::LOCK_WHILE_RUNNING, + Target::mewtwo + ) + , GO_HOME_WHEN_DONE(true) , NOTIFICATION_SHINY( "Shiny Found", true, true, ImageAttachmentMode::JPG, @@ -66,6 +76,7 @@ LegendaryReset::LegendaryReset() &NOTIFICATION_PROGRAM_FINISH, }) { + PA_ADD_OPTION(TARGET); PA_ADD_OPTION(GO_HOME_WHEN_DONE); PA_ADD_OPTION(NOTIFICATIONS); } @@ -79,7 +90,17 @@ bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconConte BattleMenuWatcher battle_started(COLOR_YELLOW); env.log("Starting battle."); - pbf_mash_button(context, BUTTON_A, 25000ms); //10000ms + switch (TARGET) { + case Target::mewtwo: + pbf_mash_button(context, BUTTON_A, 5000ms); //untested + break; + case Target::snorlax: + pbf_mash_button(context, BUTTON_A, 15000ms); + break; + case Target::snorlax2: + pbf_mash_button(context, BUTTON_A, 25000ms); //can't test + break; + } context.wait_for_all_requests(); int res = run_until( diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h index 020e244d7c..89ae81ecda 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h @@ -32,6 +32,13 @@ class LegendaryReset : public SingleSwitchProgramInstance{ private: bool run_battle(SingleSwitchProgramEnvironment& env, JoyconContext& context); + enum class Target{ + mewtwo, + snorlax, + snorlax2, + }; + EnumDropdownOption TARGET; + GoHomeWhenDoneOption GO_HOME_WHEN_DONE; EventNotificationOption NOTIFICATION_SHINY; From bfa5836f80624ff0ffca444b7ed536b2782400ce Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Tue, 22 Apr 2025 22:10:33 -0400 Subject: [PATCH 6/8] BattleMenu->Arrow --- SerialPrograms/CMakeLists.txt | 4 +- SerialPrograms/SerialPrograms.pro | 4 +- .../PokemonLGPE_BattleArrowDetector.cpp | 69 +++++++++++++++++++ .../Battles/PokemonLGPE_BattleArrowDetector.h | 53 ++++++++++++++ .../PokemonLGPE_BattleMenuDetector.cpp | 44 ------------ .../Battles/PokemonLGPE_BattleMenuDetector.h | 60 ---------------- .../PokemonLGPE_LegendaryReset.cpp | 7 +- 7 files changed, 129 insertions(+), 112 deletions(-) create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp create mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h delete mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp delete mode 100644 SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index b2fe03b0e8..6b2bdee43c 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1375,8 +1375,8 @@ file(GLOB MAIN_SOURCES Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h - Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp - Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index d8b9911304..9c9db6d84f 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -674,7 +674,7 @@ SOURCES += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp \ - Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp \ + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp \ Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.cpp \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp \ @@ -1873,7 +1873,7 @@ HEADERS += \ Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \ Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \ Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h \ - Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h \ + Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h \ Source/PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h \ Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \ Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.h \ diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp new file mode 100644 index 0000000000..30f15e801e --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.cpp @@ -0,0 +1,69 @@ +/* Battle Arrow Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "Kernels/Waterfill/Kernels_Waterfill_Session.h" +#include "CommonFramework/Globals.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonTools/Images/BinaryImage_FilterRgb32.h" +#include "CommonTools/ImageMatch/ExactImageMatcher.h" +#include "PokemonLGPE_BattleArrowDetector.h" + +//#include +//using std::cout; +//using std::endl; + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +const ImageMatch::ExactImageMatcher& BATTLE_ARROW(){ + static ImageMatch::ExactImageMatcher matcher(RESOURCE_PATH() + "PokemonLGPE/BattleArrow.png"); + return matcher; +} + +BattleArrowDetector::BattleArrowDetector(Color color, const ImageFloatBox& box) + : m_color(color) + , m_box(box) +{} +void BattleArrowDetector::make_overlays(VideoOverlaySet& items) const{ + items.add(m_color, m_box); +} +bool BattleArrowDetector::detect(const ImageViewRGB32& screen) const{ + using namespace Kernels::Waterfill; + + ImageViewRGB32 region = extract_box_reference(screen, m_box); + + const ImageMatch::ExactImageMatcher& matcher = BATTLE_ARROW(); + + auto matrix = compress_rgb32_to_binary_range(region, 0xffc0c0c0, 0xffffffff); + auto session = make_WaterfillSession(matrix); + auto iter = session->make_iterator(100); + WaterfillObject object; + + //static int c = 0; + while (iter->find_next(object, false)){ + double aspect_ratio = object.aspect_ratio(); + if (aspect_ratio < 1.0 || aspect_ratio > 1.3){ + continue; + } + ImageViewRGB32 cropped = extract_box_reference(region, object); + //cropped.save("test-object-" + std::to_string(c++) + ".png"); + double rmsd = matcher.rmsd(cropped); + //cout << rmsd << endl; + if (rmsd < 110){ + return true; + } + } + + return false; +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h new file mode 100644 index 0000000000..ff9e0c0817 --- /dev/null +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h @@ -0,0 +1,53 @@ +/* Battle Arrow Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonLGPE_BattleArrowDetector_H +#define PokemonAutomation_PokemonLGPE_BattleArrowDetector_H + +#include +#include +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "Common/Cpp/Color.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonTools/VisualDetector.h" +#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLGPE{ + +class BattleArrowDetector : public StaticScreenDetector{ +public: + /* + |Fight|Pokemon|Bag|Run| for wild battle + |---|Fight|Pokemon|Bag| for trainer battle + (align right) + Don't know what changes for a double battle. + */ + //Arrow bounces back and forth. + BattleArrowDetector(Color color, const ImageFloatBox& box = {0.546, 0.863, 0.045, 0.068}); //Wild battle. + + virtual void make_overlays(VideoOverlaySet& items) const override; + virtual bool detect(const ImageViewRGB32& screen) const override; + +protected: + Color m_color; + ImageFloatBox m_box; +}; +class BattleArrowWatcher : public DetectorToFinder{ +public: + BattleArrowWatcher(Color color = COLOR_RED) + : DetectorToFinder("BattleArrowWatcher", std::chrono::milliseconds(100), color) + {} +}; + + + +} +} +} + +#endif diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp deleted file mode 100644 index 47ed6cd793..0000000000 --- a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Battle Menu Detector - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#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 "PokemonLGPE_BattleMenuDetector.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonLGPE{ - -BattleMenuDetector::BattleMenuDetector(Color color) - : m_your_box(0.114, 0.916, 0.016, 0.027) - , m_opponent_box(0.904, 0.048, 0.022, 0.031) -{} -void BattleMenuDetector::make_overlays(VideoOverlaySet& items) const{ - items.add(COLOR_RED, m_your_box); - items.add(COLOR_RED, m_opponent_box); -} -bool BattleMenuDetector::detect(const ImageViewRGB32& screen) const{ - ImageViewRGB32 left_image = extract_box_reference(screen, m_your_box); - ImageViewRGB32 right_image = extract_box_reference(screen, m_opponent_box); - - //Has a bit of a gradient in the box - //TODO: Do more boxes, horizonal so less gradient variation. - if (is_solid(left_image, { 0.040, 0.467, 0.493 }) && is_solid(right_image, { 0.074, 0.458, 0.468 })){ - return true; - } - return false; -} - - - -} -} -} diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h deleted file mode 100644 index e88d44f70d..0000000000 --- a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Battle Menu Detector - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_PokemonLGPE_BattleMenuDetector_H -#define PokemonAutomation_PokemonLGPE_BattleMenuDetector_H - -#include -#include -#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" -#include "Common/Cpp/Color.h" -#include "CommonFramework/ImageTools/ImageBoxes.h" -#include "CommonTools/VisualDetector.h" -#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" - -namespace PokemonAutomation{ - class CancellableScope; - class VideoFeed; -namespace NintendoSwitch{ -namespace PokemonLGPE{ - -//Detect the light blue of your HP box and your opponent's HP box -class BattleMenuDetector : public StaticScreenDetector{ -public: - BattleMenuDetector(Color color); - - virtual void make_overlays(VideoOverlaySet& items) const override; - virtual bool detect(const ImageViewRGB32& screen) const override; - -private: - ImageFloatBox m_your_box; - ImageFloatBox m_opponent_box; -}; -class BattleMenuWatcher : public DetectorToFinder{ -public: - BattleMenuWatcher(Color color) - : DetectorToFinder("BattleMenuWatcher", std::chrono::milliseconds(250), color) - {} -}; - -//Battle dialog detector - white of the box - -/* -Possible future improvements: -Detect arrow and position -|Fight|Pokemon|Bag|Run| for wild battle -|---|Fight|Pokemon|Bag| for trainer battle -(align right) - -Detect Y Info button located next to menu. -Don't know what changes for a double battle. -*/ - -} -} -} - -#endif diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp index e0505e15ed..6392d66308 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp @@ -15,7 +15,7 @@ #include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" #include "Pokemon/Pokemon_Strings.h" #include "CommonTools/VisualDetectors/BlackScreenDetector.h" -#include "PokemonLGPE/Inference/Battles/PokemonLGPE_BattleMenuDetector.h" +#include "PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h" #include "PokemonLGPE/Inference/Sounds/PokemonLGPE_ShinySoundDetector.h" #include "PokemonLGPE/Programs/PokemonLGPE_GameEntry.h" #include "PokemonLGPE_LegendaryReset.h" @@ -87,7 +87,7 @@ bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconConte shiny_coefficient = error_coefficient; return true; }); - BattleMenuWatcher battle_started(COLOR_YELLOW); + BattleArrowWatcher battle_started(COLOR_YELLOW); env.log("Starting battle."); switch (TARGET) { @@ -98,7 +98,7 @@ bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconConte pbf_mash_button(context, BUTTON_A, 15000ms); break; case Target::snorlax2: - pbf_mash_button(context, BUTTON_A, 25000ms); //can't test + pbf_mash_button(context, BUTTON_A, 25000ms); //can't test, not really worth it break; } context.wait_for_all_requests(); @@ -120,7 +120,6 @@ bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconConte env.console ); } - pbf_wait(context, 1000ms); context.wait_for_all_requests(); }, {{shiny_detector}} From 618e07b1aabbdf6cb30194e828bb0014bd12fb6d Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Wed, 23 Apr 2025 09:18:54 -0400 Subject: [PATCH 7/8] legendaryreset fixes --- SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp | 4 +++- .../Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp | 9 ++++----- .../Programs/TestPrograms/PokemonLGPE_SoundListener.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp index e0d229ac79..95376aa852 100644 --- a/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp +++ b/SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp @@ -38,7 +38,9 @@ std::vector PanelListFactory::make_panels() const{ ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); ret.emplace_back(make_single_switch_program()); - ret.emplace_back(make_single_switch_program()); + if (IS_BETA_VERSION || PreloadSettings::instance().DEVELOPER_MODE) { + ret.emplace_back(make_single_switch_program()); + } if (PreloadSettings::instance().DEVELOPER_MODE){ ret.emplace_back("---- Developer Tools ----"); diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp index 6392d66308..f63157460e 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp @@ -92,13 +92,12 @@ bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconConte env.log("Starting battle."); switch (TARGET) { case Target::mewtwo: - pbf_mash_button(context, BUTTON_A, 5000ms); //untested + pbf_mash_button(context, BUTTON_A, 3000ms); //untested + pbf_press_button(context, BUTTON_PLUS, 500ms, 500ms); //also untested break; case Target::snorlax: - pbf_mash_button(context, BUTTON_A, 15000ms); - break; - case Target::snorlax2: - pbf_mash_button(context, BUTTON_A, 25000ms); //can't test, not really worth it + pbf_mash_button(context, BUTTON_A, 5000ms); + pbf_mash_button(context, BUTTON_B, 10000ms); break; } context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp index 7143770985..f47c2e6c48 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/TestPrograms/PokemonLGPE_SoundListener.cpp @@ -79,7 +79,7 @@ void SoundListener::program(SingleSwitchProgramEnvironment& env, CancellableScop default: throw InternalProgramError( &env.logger(), PA_CURRENT_FUNCTION, - "Not such sound detector as sound type " + std::to_string((size_t)type) + "No such sound detector as sound type " + std::to_string((size_t)type) ); return; } From 0e059f2c55895bd3ca66d1a46e010492e8cefbde Mon Sep 17 00:00:00 2001 From: kichithewolf Date: Wed, 23 Apr 2025 11:13:10 -0400 Subject: [PATCH 8/8] handle shiny battle --- .../Battles/PokemonLGPE_BattleArrowDetector.h | 6 +- .../PokemonLGPE_LegendaryReset.cpp | 62 +++++++++++++++++-- .../ShinyHunting/PokemonLGPE_LegendaryReset.h | 4 +- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h index ff9e0c0817..5235944b2b 100644 --- a/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h +++ b/SerialPrograms/Source/PokemonLGPE/Inference/Battles/PokemonLGPE_BattleArrowDetector.h @@ -28,7 +28,7 @@ class BattleArrowDetector : public StaticScreenDetector{ Don't know what changes for a double battle. */ //Arrow bounces back and forth. - BattleArrowDetector(Color color, const ImageFloatBox& box = {0.546, 0.863, 0.045, 0.068}); //Wild battle. + BattleArrowDetector(Color color, const ImageFloatBox& box); virtual void make_overlays(VideoOverlaySet& items) const override; virtual bool detect(const ImageViewRGB32& screen) const override; @@ -39,8 +39,8 @@ class BattleArrowDetector : public StaticScreenDetector{ }; class BattleArrowWatcher : public DetectorToFinder{ public: - BattleArrowWatcher(Color color = COLOR_RED) - : DetectorToFinder("BattleArrowWatcher", std::chrono::milliseconds(100), color) + BattleArrowWatcher(Color color = COLOR_RED, ImageFloatBox box = {0.546, 0.863, 0.045, 0.068}) + : DetectorToFinder("BattleArrowWatcher", std::chrono::milliseconds(100), color, box) {} }; diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp index f63157460e..967f4a4743 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.cpp @@ -81,13 +81,13 @@ LegendaryReset::LegendaryReset() PA_ADD_OPTION(NOTIFICATIONS); } -bool LegendaryReset::run_battle(SingleSwitchProgramEnvironment& env, JoyconContext& context){ +bool LegendaryReset::run_encounter(SingleSwitchProgramEnvironment& env, JoyconContext& context){ float shiny_coefficient = 1.0; ShinySoundDetector shiny_detector(env.logger(), [&](float error_coefficient) -> bool{ shiny_coefficient = error_coefficient; return true; }); - BattleArrowWatcher battle_started(COLOR_YELLOW); + BattleArrowWatcher battle_started(COLOR_YELLOW, {0.546, 0.863, 0.045, 0.068}); env.log("Starting battle."); switch (TARGET) { @@ -146,14 +146,15 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco Settings: Text Speed fast - Skip cutscene option? + Skip cutscene On + Skip move animation On Mewtwo, Articuno, Zapdos, Moltres, Snorlax, Electrode(?) Don't do it on the first Snorlax, otherwise have to sit through fuji tutorial */ while (true) { - bool encounter_battle = run_battle(env, context); + bool encounter_battle = run_encounter(env, context); if (encounter_battle) { stats.shinies++; env.update_stats(); @@ -174,6 +175,59 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, CancellableSco stats.resets++; env.update_stats(); } + //Shiny found, complete the battle + WallClock start = current_time(); + BattleArrowWatcher catching_started(COLOR_RED, {0.005, 0.662, 0.049, 0.069}); + int res = run_until( + env.console, context, + [&](JoyconContext& context) { + while(true){ + if (current_time() - start > std::chrono::minutes(5)){ + env.log("Timed out during battle after 5 minutes.", COLOR_RED); + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Timed out during battle after 5 minutes.", + env.console + ); + } + BattleArrowWatcher battle_menu(COLOR_YELLOW, {0.546, 0.863, 0.045, 0.068}); + context.wait_for_all_requests(); + + int ret = wait_until( + env.console, context, + std::chrono::seconds(30), + { battle_menu } + ); + switch (ret){ + case 0: + env.log("Detected battle menu. Mashing A to attack."); + pbf_mash_button(context, BUTTON_A, 3000ms); + context.wait_for_all_requests(); + break; + default: + env.log("Timed out during battle. Stuck, crashed, or took more than 30 seconds for a turn.", COLOR_RED); + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Timed out during battle. Stuck, crashed, or took more than 30 seconds for a turn.", + env.console + ); + } + } + }, + {{catching_started}} + ); + switch (res){ + case 0: + env.log("Catching menu detected."); + break; + default: + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Failed to detect catching menu.", + env.console + ); + break; + } if (GO_HOME_WHEN_DONE) { pbf_press_button(context, BUTTON_HOME, 200ms, 1000ms); diff --git a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h index 89ae81ecda..e186468887 100644 --- a/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h +++ b/SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_LegendaryReset.h @@ -30,12 +30,12 @@ class LegendaryReset : public SingleSwitchProgramInstance{ virtual void program(SingleSwitchProgramEnvironment& env, CancellableScope& scope) override; private: - bool run_battle(SingleSwitchProgramEnvironment& env, JoyconContext& context); + bool run_encounter(SingleSwitchProgramEnvironment& env, JoyconContext& context); enum class Target{ mewtwo, snorlax, - snorlax2, + //snorlax2, }; EnumDropdownOption TARGET;