diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 061457edd2..3a59ae015a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -474,7 +474,7 @@ AutoStory::AutoStory() } void AutoStory::on_config_value_changed(void* object){ - ConfigOptionState state = (STARTPOINT_TUTORIAL.index() <= 1) + ConfigOptionState state = (STARTPOINT_TUTORIAL.index() <= 1 && STORY_SECTION == StorySection::TUTORIAL) ? ConfigOptionState::ENABLED : ConfigOptionState::HIDDEN; STARTERCHOICE.set_visibility(state); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 21ba30670f..ec7232f5bb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -556,52 +556,47 @@ void config_option(ProControllerContext& context, int change_option_value){ pbf_press_dpad(context, DPAD_DOWN, 15, 20); } -void swap_starter_moves(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, Language language){ - WallClock start = current_time(); - while (true){ - if (current_time() - start > std::chrono::minutes(3)){ - OperationFailedException::fire( - ErrorReport::SEND_ERROR_REPORT, - "swap_starter_moves(): Failed to swap the starter moves after 3 minutes.", - stream - ); - } - // start in the overworld - press_Bs_to_back_to_overworld(info, stream, context); - - // open menu, select your starter - enter_menu_from_overworld(info, stream, context, 0, MenuSide::LEFT); +void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language){ + const ProgramInfo& info = env.program_info(); + VideoStream& stream = env.console; - // enter Pokemon summary screen - pbf_press_button(context, BUTTON_A, 20, 5 * TICKS_PER_SECOND); - pbf_press_dpad(context, DPAD_RIGHT, 15, 1 * TICKS_PER_SECOND); - pbf_press_button(context, BUTTON_Y, 20, 40); + // start in the overworld + press_Bs_to_back_to_overworld(info, stream, context); - // select move 1 - pbf_press_button(context, BUTTON_A, 20, 40); - pbf_press_dpad(context, DPAD_DOWN, 15, 40); - pbf_press_dpad(context, DPAD_DOWN, 15, 40); - // extra button presses to avoid drops - pbf_press_dpad(context, DPAD_DOWN, 15, 40); - pbf_press_dpad(context, DPAD_DOWN, 15, 40); + // open menu, select your starter + enter_menu_from_overworld(info, stream, context, 0, MenuSide::LEFT); - // select move 3. swap move 1 and move 3. - pbf_press_button(context, BUTTON_A, 20, 40); + // enter Pokemon summary screen + pbf_press_button(context, BUTTON_A, 20, 5 * TICKS_PER_SECOND); + pbf_press_dpad(context, DPAD_RIGHT, 15, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_Y, 20, 40); - // confirm that Ember/Leafage/Water Gun is in slot 1 - context.wait_for_all_requests(); - VideoSnapshot screen = stream.video().snapshot(); - PokemonMovesReader reader(language); - std::string top_move = reader.read_move(stream.logger(), screen, 0); - stream.log("Current top move: " + top_move); - if (top_move != "ember" && top_move != "leafage" && top_move != "water-gun"){ - stream.log("Failed to swap moves. Re-try."); - continue; - } + // select move 1 + pbf_press_button(context, BUTTON_A, 20, 40); + pbf_press_dpad(context, DPAD_DOWN, 15, 40); + pbf_press_dpad(context, DPAD_DOWN, 15, 40); + // extra button presses to avoid drops + pbf_press_dpad(context, DPAD_DOWN, 15, 40); + pbf_press_dpad(context, DPAD_DOWN, 15, 40); + // select move 3. swap move 1 and move 3. + pbf_press_button(context, BUTTON_A, 20, 40); - break; - } + // confirm that Ember/Leafage/Water Gun is in slot 1 + context.wait_for_all_requests(); + VideoSnapshot screen = stream.video().snapshot(); + PokemonMovesReader reader(language); + std::string top_move = reader.read_move(stream.logger(), screen, 0); + stream.log("Current top move: " + top_move); + if (top_move != "ember" && top_move != "leafage" && top_move != "water-gun"){ + stream.log("Failed to swap moves."); + OperationFailedException exception( + ErrorReport::SEND_ERROR_REPORT, + "swap_starter_moves: Failed to swap moves.\n" + language_warning(language), + stream + ); + exception.send_recoverable_notification(env); + } } @@ -1220,6 +1215,85 @@ void check_num_sunflora_found(SingleSwitchProgramEnvironment& env, ProController } +void checkpoint_reattempt_loop( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update, + AutoStoryStats& stats, + std::function&& action +){ + size_t max_attempts = 100; + for (size_t i = 0;;i++){ + try{ + if (i==0){ + checkpoint_save(env, context, notif_status_update, stats); + } + + context.wait_for_all_requests(); + action(i); + + break; + }catch(OperationFailedException& e){ + if (i > max_attempts){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Autostory checkpoint failed " + std::to_string(max_attempts) + " times.\n" + "Make sure you selected the correct Start Point, and your character is in the exactly correct starting position." + "Also, make sure you have set the correct Language.\n" + e.message(), + env.console + ); + } + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + +void checkpoint_reattempt_loop_tutorial( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update, + AutoStoryStats& stats, + std::function&& action +){ + size_t max_attempts = 100; + for (size_t i = 0;;i++){ + try{ + if(i==0){ + save_game_tutorial(env.program_info(), env.console, context); + stats.m_checkpoint++; + env.update_stats(); + send_program_status_notification(env, notif_status_update, "Saved at checkpoint."); + } + + context.wait_for_all_requests(); + action(i); + + break; + }catch(OperationFailedException& e){ + if (i > max_attempts){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Autostory checkpoint failed " + std::to_string(max_attempts) + " times.\n" + "Make sure you selected the correct Start Point, and your character is in the exactly correct starting position." + "Also, make sure you have set the correct Language.\n" + e.message(), + env.console + ); + } + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } +} + + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index ff4be97ce8..6f6bc40c96 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -179,7 +179,7 @@ void overworld_navigation(const ProgramInfo& info, VideoStream& stream, ProContr void config_option(ProControllerContext& context, int change_option_value); // enter menu and swap the first and third moves for your starter -void swap_starter_moves(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, Language language); +void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language); // run the given `action`. if detect a battle, stop the action, and throw exception void do_action_and_monitor_for_battles( @@ -337,6 +337,27 @@ void move_cursor_towards_flypoint_and_go_there( void check_num_sunflora_found(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int expected_number); +// run given action, with max_attempts number of attempts +// save prior to first attempt +// throw exception if we try to exceed max_attempts. +void checkpoint_reattempt_loop( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update, + AutoStoryStats& stats, + std::function&& action +); + +void checkpoint_reattempt_loop_tutorial( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update, + AutoStoryStats& stats, + std::function&& action +); + + + } } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp index faba217822..7a5b28c40d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp @@ -75,34 +75,17 @@ void checkpoint_01( AutoStoryStats& stats, Language language ){ - bool first_attempt = true; - while (true){ - try{ - if(first_attempt){ - save_game_tutorial(env.program_info(), env.console, context); - stats.m_checkpoint++; - env.update_stats(); - send_program_status_notification(env, notif_status_update, "Saved at checkpoint."); - } + checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // set settings enter_menu_from_overworld(env.program_info(), env.console, context, 0, MenuSide::RIGHT, false); - change_settings(env, context, language, first_attempt); + change_settings(env, context, language, attempt_number==0); pbf_mash_button(context, BUTTON_B, 2 * TICKS_PER_SECOND); context.wait_for_all_requests(); - break; - }catch(OperationFailedException&){ - // (void)e; - first_attempt = false; - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } void checkpoint_02( @@ -111,16 +94,8 @@ void checkpoint_02( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if(first_attempt){ - save_game_tutorial(env.program_info(), env.console, context); - stats.m_checkpoint++; - env.update_stats(); - send_program_status_notification(env, notif_status_update, "Saved at checkpoint."); - first_attempt = false; - } + checkpoint_reattempt_loop_tutorial(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); env.console.log("Go downstairs, get stopped by Skwovet"); @@ -184,15 +159,7 @@ void checkpoint_02( open_map_from_overworld(env.program_info(), env.console, context, true); leave_phone_to_overworld(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } void checkpoint_03( @@ -203,13 +170,8 @@ void checkpoint_03( Language language, StarterChoice starter_choice ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; @@ -274,19 +236,12 @@ void checkpoint_03( clear_tutorial(env.console, context); env.console.log("Change move order."); - swap_starter_moves(env.program_info(), env.console, context, language); - leave_box_system_to_overworld(env.program_info(), env.console, context); + swap_starter_moves(env, context, language); + press_Bs_to_back_to_overworld(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } } - + ); + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp index 6b410e8aa9..007694d30d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp @@ -67,13 +67,8 @@ void checkpoint_04( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; @@ -92,15 +87,8 @@ void checkpoint_04( context.wait_for_all_requests(); env.console.log("Finished battle."); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } } + ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp index 5fc9ca1068..a8952586f0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp @@ -64,13 +64,8 @@ void checkpoint_05( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; @@ -83,15 +78,8 @@ void checkpoint_05( env.console.log("Get mom's sandwich"); env.console.overlay().add_log("Get mom's sandwich", COLOR_WHITE); mash_button_till_overworld(env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + + }); } void checkpoint_06( @@ -100,13 +88,8 @@ void checkpoint_06( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); @@ -133,15 +116,8 @@ void checkpoint_06( env.console.log("Finished catch tutorial"); env.console.overlay().add_log("Finished catch tutorial", COLOR_WHITE); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); + } void checkpoint_07( @@ -150,13 +126,8 @@ void checkpoint_07( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); env.console.log("Move to cliff"); @@ -187,15 +158,9 @@ void checkpoint_07( env.console.log("Mystery cry"); env.console.overlay().add_log("Mystery cry", COLOR_WHITE); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); + + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp index b2e98e0865..e38d58e6d8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp @@ -67,13 +67,9 @@ void checkpoint_08( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 70, 100); @@ -192,15 +188,9 @@ void checkpoint_08( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + + }); + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp index 41e13620fb..f816d38bb3 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp @@ -68,13 +68,9 @@ void checkpoint_09( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 110, 50); @@ -101,15 +97,8 @@ void checkpoint_09( env.console.log("Receive legendary ball"); env.console.overlay().add_log("Receive legendary ball", COLOR_WHITE); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); + } void checkpoint_10( @@ -118,13 +107,9 @@ void checkpoint_10( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); env.console.log("Lighthouse view"); env.console.overlay().add_log("Lighthouse view", COLOR_WHITE); @@ -143,15 +128,7 @@ void checkpoint_10( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp index 4ecd447c33..bd1de5c60e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp @@ -67,13 +67,8 @@ void checkpoint_11( EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -109,15 +104,7 @@ void checkpoint_11( env.console.log("Reached Los Platos"); env.console.overlay().add_log("Reached Los Platos", COLOR_WHITE); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp index 5ec8ee36d2..0afbe3746d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp @@ -70,57 +70,44 @@ void checkpoint_12( // resets due to: getting attacked by wild pokemon, either from behind, // or when lead pokemon not strong enough to clear them with Let's go - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + context.wait_for_all_requests(); + + // re-orient camera + pbf_press_button(context, BUTTON_L, 20, 20); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + walk_forward_while_clear_front_path(env.program_info(), env.console, context, 35); + + // place the marker elsewhere + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 128, 50); + + DirectionDetector direction; + direction.change_direction(info, env.console, context, 0); + walk_forward_while_clear_front_path(info, env.console, context, 3300, 0, 125, 125); + + // check we're not still at the Los Platos Pokecenter. + confirm_no_overlapping_flypoint(info, env.console, context); + // not stuck at Los Platos Pokecenter + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + press_Bs_to_back_to_overworld(info, env.console, context, 7); + + direction.change_direction(info, env.console, context, 0.29); + walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); + direction.change_direction(info, env.console, context, 0.61); + walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); + + fly_to_overlapping_flypoint(info, env.console, context); } + ); - fly_to_overlapping_flypoint(env.program_info(), env.console, context); - context.wait_for_all_requests(); - - // re-orient camera - pbf_press_button(context, BUTTON_L, 20, 20); - do_action_and_monitor_for_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - walk_forward_while_clear_front_path(env.program_info(), env.console, context, 35); - - // place the marker elsewhere - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 128, 50); - - DirectionDetector direction; - direction.change_direction(info, env.console, context, 0); - walk_forward_while_clear_front_path(info, env.console, context, 3300, 0, 125, 125); - - // check we're not still at the Los Platos Pokecenter. - confirm_no_overlapping_flypoint(info, env.console, context); - // not stuck at Los Platos Pokecenter - pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); - pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); - press_Bs_to_back_to_overworld(info, env.console, context, 7); - - direction.change_direction(info, env.console, context, 0.29); - walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); - direction.change_direction(info, env.console, context, 0.61); - walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); - - fly_to_overlapping_flypoint(info, env.console, context); - } - ); - - env.console.log("Reached Mesagoza (South) Pokecenter."); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + env.console.log("Reached Mesagoza (South) Pokecenter."); + + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp index 6c6fa83a72..585d99de3d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp @@ -70,16 +70,10 @@ void checkpoint_13( ){ // reset rate: 0%. 0 resets out of 70. - bool first_attempt = true; - while (true){ - try{ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ do_action_and_monitor_for_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ fly_to_overlapping_flypoint(info, env.console, context); @@ -102,15 +96,7 @@ void checkpoint_13( {CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG, CallbackEnum::WHITE_A_BUTTON}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -121,13 +107,9 @@ void checkpoint_14( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // realign diagonally to the left realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 80, 0, 100); @@ -161,15 +143,7 @@ void checkpoint_14( // clear dialog until overworld clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -180,13 +154,9 @@ void checkpoint_15( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // realign diagonally to the right realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 178, 0, 100); @@ -205,15 +175,7 @@ void checkpoint_15( clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::OVERWORLD}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp index 42d7bcd0cf..18aafad705 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp @@ -72,13 +72,9 @@ void checkpoint_16( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // walk left @@ -107,15 +103,7 @@ void checkpoint_16( mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -126,13 +114,9 @@ void checkpoint_17( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // walk backwards until dialog @@ -163,15 +147,7 @@ void checkpoint_17( - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -182,13 +158,9 @@ void checkpoint_18( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // walk down @@ -210,15 +182,7 @@ void checkpoint_18( clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -229,13 +193,9 @@ void checkpoint_19( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); // walk right @@ -255,15 +215,7 @@ void checkpoint_19( mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -275,13 +227,9 @@ void checkpoint_20( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); //walk right towards door @@ -309,15 +257,7 @@ void checkpoint_20( mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp index daa31ad47f..df5e94e5e7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp @@ -70,13 +70,8 @@ void checkpoint_21( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ fly_to_overlapping_flypoint(env.program_info(), env.console, context); context.wait_for_all_requests(); @@ -118,15 +113,7 @@ void checkpoint_21( context.wait_for_all_requests(); fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -137,13 +124,8 @@ void checkpoint_22( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 realign_player_from_landmark( @@ -186,15 +168,7 @@ void checkpoint_22( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -207,13 +181,8 @@ void checkpoint_23( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 @@ -306,15 +275,7 @@ void checkpoint_23( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp index be66172178..6a401689f9 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp @@ -78,13 +78,8 @@ void checkpoint_24( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -125,15 +120,7 @@ void checkpoint_24( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -145,13 +132,8 @@ void checkpoint_25( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1. align to Olive roll NPC @@ -168,6 +150,8 @@ void checkpoint_25( ); mash_button_till_overworld(env.console, context, BUTTON_A); + context.wait_for_all_requests(); + // section 2 pbf_move_left_joystick(context, 128, 0, 1300, 100); @@ -215,15 +199,7 @@ void checkpoint_25( wait_for_overworld(env.program_info(), env.console, context); enter_menu_from_overworld(env.program_info(), env.console, context, -1); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -234,13 +210,8 @@ void checkpoint_26( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // change the time of day: close game, change time to 5:45 am. @@ -582,15 +553,7 @@ void checkpoint_26( enter_menu_from_overworld(env.program_info(), env.console, context, -1); - break; - }catch (...){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - // reset_game(env.program_info(), env.console, context); // the checkpoint itself already resets the game, so need to reset twice - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -601,25 +564,12 @@ void checkpoint_27( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 40}); - break; - }catch (...){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp index 755fb9beca..6ed841c7af 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp @@ -72,13 +72,8 @@ void checkpoint_28( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -137,15 +132,7 @@ void checkpoint_28( pbf_move_left_joystick(context, 128, 0, 1600, 100); fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp index b57cef2fd8..5a3cc63880 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp @@ -59,7 +59,6 @@ void AutoStory_Segment_13::run_segment( } -// todo: shift all checkpoint numbers to make space for the Cortondo checkpoints void checkpoint_29( SingleSwitchProgramEnvironment& env, ProControllerContext& context, @@ -67,13 +66,8 @@ void checkpoint_29( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); fly_to_overlapping_flypoint(env.program_info(), env.console, context); @@ -312,15 +306,7 @@ void checkpoint_29( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp index 029e71b484..579d2dcd2f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp @@ -70,13 +70,8 @@ void checkpoint_30( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 @@ -237,15 +232,7 @@ void checkpoint_30( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -257,13 +244,8 @@ void checkpoint_31( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1. fall down the mountain realign_player_from_landmark( @@ -304,15 +286,7 @@ void checkpoint_31( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp index ee42908645..0eb7cb6de7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp @@ -75,13 +75,8 @@ void checkpoint_32( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 50, 0, 25); @@ -134,15 +129,7 @@ void checkpoint_32( clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -153,13 +140,8 @@ void checkpoint_33( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // enter the base @@ -262,15 +244,7 @@ void checkpoint_33( mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -281,13 +255,8 @@ void checkpoint_34( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 realign_player_from_landmark( @@ -327,15 +296,7 @@ void checkpoint_34( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp index 6c1788a2be..f58736978b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp @@ -69,13 +69,8 @@ void checkpoint_35( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -101,15 +96,7 @@ void checkpoint_35( walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -120,13 +107,8 @@ void checkpoint_36( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 100, 0, 80}); @@ -181,15 +163,7 @@ void checkpoint_36( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp index d28ecb05f9..1debf7da6e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp @@ -69,13 +69,8 @@ void checkpoint_37( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -105,15 +100,7 @@ void checkpoint_37( mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -124,13 +111,8 @@ void checkpoint_38( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 180, 170}); DirectionDetector direction; @@ -188,15 +170,7 @@ void checkpoint_38( // fly to Porto Marinada pokecenter move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 80, 150}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp index 5aa3f2a7de..2d0409d993 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp @@ -70,13 +70,8 @@ void checkpoint_39( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; @@ -224,15 +219,7 @@ void checkpoint_39( run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::DIALOG_ARROW}); mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -243,13 +230,8 @@ void checkpoint_40( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // fly to Mesagoza East move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 185, 440}); @@ -349,15 +331,7 @@ void checkpoint_40( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp index 5df735fed7..789dc614d1 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp @@ -70,13 +70,8 @@ void checkpoint_41( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 @@ -249,15 +244,7 @@ void checkpoint_41( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -268,13 +255,8 @@ void checkpoint_42( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // section 1 @@ -361,15 +343,7 @@ void checkpoint_42( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp index ce1729f8e0..78633f0a0f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp @@ -73,19 +73,8 @@ void checkpoint_43( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // place the marker somewhere else. the current location disrupts the Stationary detector @@ -134,15 +123,7 @@ void checkpoint_43( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -153,19 +134,8 @@ void checkpoint_44( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); @@ -481,15 +451,7 @@ void checkpoint_44( clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -500,19 +462,8 @@ void checkpoint_45( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); @@ -546,15 +497,7 @@ void checkpoint_45( run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -567,19 +510,8 @@ void checkpoint_46( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); @@ -612,15 +544,7 @@ void checkpoint_46( fly_to_overlapping_flypoint(env.program_info(), env.console, context); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp index 3e6c41e5e7..bda462f8f6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp @@ -72,19 +72,8 @@ void checkpoint_47( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 100); @@ -122,15 +111,7 @@ void checkpoint_47( mash_button_till_overworld(env.console, context, BUTTON_A); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -142,19 +123,8 @@ void checkpoint_48( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -279,15 +249,7 @@ void checkpoint_48( run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A, 360); - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } @@ -299,19 +261,8 @@ void checkpoint_49( AutoStoryStats& stats ){ - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ context.wait_for_all_requests(); // marker 1 @@ -413,15 +364,7 @@ void checkpoint_49( - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index f9551bc163..bf62ec7240 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp @@ -60,220 +60,88 @@ void AutoStory_Segment_22::run_segment( } -// todo: uncomment checkpoint_save void checkpoint_50( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } -// todo: uncomment checkpoint_save void checkpoint_51( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } -// todo: uncomment checkpoint_save void checkpoint_52( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } -// todo: uncomment checkpoint_save void checkpoint_53( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } -// todo: uncomment checkpoint_save void checkpoint_54( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } -// todo: uncomment checkpoint_save void checkpoint_55( SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats ){ - - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update, stats); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); }