@@ -182,6 +182,13 @@ std::unique_ptr<StatsTracker> OutbreakFinder_Descriptor::make_stats() const{
182182
183183OutbreakFinder::OutbreakFinder ()
184184 : GO_HOME_WHEN_DONE(false )
185+ , RESET_GAME_AND_CONTINUE_SEARCHING(
186+ " <b>Reset game and continue searching at start</b><br>If the last outbreak found by the program does not yield what you want, check "
187+ " this option to let the program reset the game and skip the ongoing outbreaks at start, before continuing the search.<br>"
188+ " Note: you must have saved at Jubilife Village front gate beforehand." ,
189+ LockMode::LOCK_WHILE_RUNNING,
190+ false
191+ )
185192 , LANGUAGE(
186193 " <b>Game Language:</b>" ,
187194 Pokemon::PokemonNameReader::instance ().languages(),
@@ -218,6 +225,7 @@ OutbreakFinder::OutbreakFinder()
218225 &NOTIFICATION_ERROR_FATAL,
219226 })
220227{
228+ PA_ADD_OPTION (RESET_GAME_AND_CONTINUE_SEARCHING);
221229 PA_ADD_OPTION (GO_HOME_WHEN_DONE);
222230 PA_ADD_OPTION (LANGUAGE);
223231 PA_ADD_OPTION (DESIRED_MO_SLUGS);
@@ -336,6 +344,8 @@ std::set<std::string> OutbreakFinder::read_travel_map_outbreaks(
336344void OutbreakFinder::goto_region_and_return (SingleSwitchProgramEnvironment& env, ProControllerContext& context,
337345 bool inside_travel_map
338346){
347+ env.log (" Go to a random region and back to refresh outbreaks..." );
348+ env.console .overlay ().add_log (" Refresh outbreaks" );
339349 OutbreakFinder_Descriptor::Stats& stats = env.current_stats <OutbreakFinder_Descriptor::Stats>();
340350
341351 if (inside_travel_map == false ){
@@ -730,12 +740,14 @@ bool OutbreakFinder::run_iteration(
730740 os << " Found desired MMO pokemon (including desired MMO pokemon with star symbols): " ;
731741 for (const auto & pokemon : found_pokemon){
732742 os << pokemon << " , " ;
743+ env.console .overlay ().add_log (" Found " + pokemon);
733744 }
734745 env.log (os.str ());
735746 return true ;
736747 }
737748
738749 env.log (" No target MMO sprite found. Reset game..." );
750+ env.console .overlay ().add_log (" No target MMO" );
739751 pbf_press_button (context, BUTTON_HOME, 160ms, GameSettings::instance ().GAME_TO_HOME_DELAY0 );
740752 reset_game_from_home (env, env.console , context, ConsoleSettings::instance ().TOLERATE_SYSTEM_UPDATE_MENU_FAST );
741753 }
@@ -745,7 +757,6 @@ bool OutbreakFinder::run_iteration(
745757 send_program_status_notification (env, NOTIFICATION_STATUS);
746758
747759 // Go to region and return.
748- env.log (" Go to a random region and back to refresh outbreaks..." );
749760 goto_region_and_return (env, context, inside_travel_map);
750761
751762 return false ;
@@ -761,10 +772,20 @@ std::set<std::string> OutbreakFinder::to_set(const StringSelectTableOption& opti
761772}
762773
763774void OutbreakFinder::program (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
764- // OutbreakFinder_Descriptor::Stats& stats = env.current_stats<OutbreakFinder_Descriptor::Stats>();
765775
766- // goto_Mai_from_camp(env.logger(), context, Camp::HIGHLANDS_HIGHLANDS);
767- // return;
776+ if (RESET_GAME_AND_CONTINUE_SEARCHING){
777+ // press a random button to let Switch register the wired controller
778+ pbf_press_button (context, BUTTON_ZL, 10ms, 30ms);
779+ // the outbreak found by the last program run did not yield what the user wants.
780+ // so we reset the game now and skip the ongoing outbreaks
781+ env.log (" Reset game and skip ongoing outbreaks" );
782+ pbf_press_button (context, BUTTON_HOME, 160ms, GameSettings::instance ().GAME_TO_HOME_DELAY0 );
783+ reset_game_from_home (env, env.console , context, ConsoleSettings::instance ().TOLERATE_SYSTEM_UPDATE_MENU_FAST );
784+
785+ // Go to region and return.
786+ bool inside_travel_map = false ;
787+ goto_region_and_return (env, context, inside_travel_map);
788+ }
768789
769790 std::set<std::string> desired_outbreaks = to_set (DESIRED_MO_SLUGS);
770791 std::set<std::string> desired_MMO_pokemon = to_set (DESIRED_MMO_SLUGS);
0 commit comments