From 296d0020e6d360c275bcc00994e9a3a916324a36 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Sun, 23 Nov 2025 14:31:02 -0600 Subject: [PATCH 1/4] Add saving every X resets --- .../PokemonLZA_ShinyHunt_BenchSit.cpp | 17 ++++++++++++++++- .../PokemonLZA_ShinyHunt_BenchSit.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.cpp b/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.cpp index ed1748ebb..bfbdf07e5 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.cpp +++ b/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.cpp @@ -86,6 +86,13 @@ ShinyHunt_BenchSit::ShinyHunt_BenchSit() LockMode::UNLOCK_WHILE_RUNNING, "2000 ms" ) + , PERIODIC_SAVE( + "Periodically Save:
" + "Save the game every this many bench sits. This reduces the loss to game crashes. Set to zero to disable.", + LockMode::UNLOCK_WHILE_RUNNING, + 100, + 0 + ) , SHINY_DETECTED( "Shiny Detected", "", "2000 ms", @@ -105,6 +112,7 @@ ShinyHunt_BenchSit::ShinyHunt_BenchSit() PA_ADD_OPTION(WALK_DIRECTION); } PA_ADD_OPTION(WALK_FORWARD_DURATION); + PA_ADD_OPTION(PERIODIC_SAVE); PA_ADD_OPTION(SHINY_DETECTED); PA_ADD_OPTION(NOTIFICATIONS); } @@ -167,7 +175,7 @@ void ShinyHunt_BenchSit::program(SingleSwitchProgramEnvironment& env, ProControl run_until( env.console, context, [&](ProControllerContext& context){ - while (true){ + for (uint32_t rounds_since_last_save = 0;; rounds_since_last_save++) { send_program_status_notification(env, NOTIFICATION_STATUS); sit_on_bench(env.console, context); shiny_sound_handler.process_pending(context); @@ -204,6 +212,13 @@ void ShinyHunt_BenchSit::program(SingleSwitchProgramEnvironment& env, ProControl } shiny_sound_handler.process_pending(context); + + uint32_t periodic_save = PERIODIC_SAVE; + if (periodic_save != 0 && rounds_since_last_save >= periodic_save) { + save_game_to_menu(env.console, context); + pbf_mash_button(context, BUTTON_B, 2000ms); + rounds_since_last_save = 0; + } } }, {shiny_detector} diff --git a/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.h b/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.h index b7dfadc07..700d1e435 100644 --- a/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.h +++ b/SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_BenchSit.h @@ -8,6 +8,7 @@ #define PokemonAutomation_PokemonLZA_ShinyHunt_BenchSit_H #include "Common/Cpp/Options/EnumDropdownOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" #include "Common/Cpp/Options/TimeDurationOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" @@ -41,6 +42,8 @@ class ShinyHunt_BenchSit : public SingleSwitchProgramInstance{ IntegerEnumDropdownOption WALK_DIRECTION; MillisecondsOption WALK_FORWARD_DURATION; + SimpleIntegerOption PERIODIC_SAVE; + ShinySoundDetectedActionOption SHINY_DETECTED; EventNotificationOption NOTIFICATION_STATUS; From a4d41015acd1894d0b0cff487f3471864bc77168 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Sun, 23 Nov 2025 20:06:19 -0600 Subject: [PATCH 2/4] Added an option to track shiny sounds without notifications. --- .../Options/PokemonLZA_ShinyDetectedAction.cpp | 17 +++++++++++++++-- .../Options/PokemonLZA_ShinyDetectedAction.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp index 3a7775ca2..7f8517e45 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp @@ -30,6 +30,7 @@ ShinySoundDetectedActionOption::ShinySoundDetectedActionOption( { {ShinySoundDetectedAction::STOP_PROGRAM, "stop", "Stop program and go Home. Send notification."}, {ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY, "notify-first", "Keep running. Notify on first shiny sound only."}, + {ShinySoundDetectedAction::NO_NOTIFICATIONS, "no-notifications", "Keep running. Track shiny sounds without sending notifications."}, // {ShinySoundDetectedAction::NOTIFY_ON_ALL, "notify-all", "Keep running. Notify on all shiny sounds."}, }, LockMode::UNLOCK_WHILE_RUNNING, @@ -84,12 +85,18 @@ bool ShinySoundDetectedActionOption::on_shiny_sound( return false; } + if (action == ShinySoundDetectedAction::NO_NOTIFICATIONS && current_count > 1) { + return false; + } + if (TAKE_VIDEO){ context.wait_for(SCREENSHOT_DELAY); pbf_press_button(context, BUTTON_CAPTURE, 2 * TICKS_PER_SECOND, 0); } - send_shiny_sound_notification(env, stream, error_coefficient); + if (action == ShinySoundDetectedAction::NO_NOTIFICATIONS) { + send_shiny_sound_notification(env, stream, error_coefficient); + } return action == ShinySoundDetectedAction::STOP_PROGRAM; } @@ -141,7 +148,13 @@ bool ShinySoundHandler::on_shiny_sound( return false; } - m_option.send_shiny_sound_notification(env, stream, error_coefficient); + if (action == ShinySoundDetectedAction::NO_NOTIFICATIONS && current_count > 1){ + return false; + } + + if (action != ShinySoundDetectedAction::NO_NOTIFICATIONS){ + m_option.send_shiny_sound_notification(env, stream, error_coefficient); + } if (m_pending_video.load(std::memory_order_acquire)){ stream.log("Back-to-back shiny sounds. Suppressing video.", COLOR_RED); diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h index ac79001c8..01081bbee 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h @@ -27,6 +27,7 @@ enum class ShinySoundDetectedAction{ STOP_PROGRAM, // stop program at first detected shiny sound NOTIFY_ON_FIRST_ONLY, // notify user only on the first shiny sound, keep running the program NOTIFY_ON_ALL, // notify on all shiny sounds, keep running the program + NO_NOTIFICATIONS // no notifications, still track shiny sounds }; From 84e78891cdac8c1b1945f494891f09cb86200741 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Sun, 23 Nov 2025 20:09:44 -0600 Subject: [PATCH 3/4] Should be not equal --- .../PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp index 7f8517e45..a4fbd2649 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp @@ -94,7 +94,7 @@ bool ShinySoundDetectedActionOption::on_shiny_sound( pbf_press_button(context, BUTTON_CAPTURE, 2 * TICKS_PER_SECOND, 0); } - if (action == ShinySoundDetectedAction::NO_NOTIFICATIONS) { + if (action != ShinySoundDetectedAction::NO_NOTIFICATIONS) { send_shiny_sound_notification(env, stream, error_coefficient); } From 20aca9928d6b8c1b8554a591fdd65d0858c39552 Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Mon, 24 Nov 2025 07:52:58 -0600 Subject: [PATCH 4/4] Update Record Video discription --- .../PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp index a4fbd2649..a0e0bd9a1 100644 --- a/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp +++ b/SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp @@ -37,7 +37,8 @@ ShinySoundDetectedActionOption::ShinySoundDetectedActionOption( default_action ) , TAKE_VIDEO( - "Take Video:", + "Take Video:
" + "Records the first shiny sound using the switch capture button.
", LockMode::UNLOCK_WHILE_RUNNING, true )