From 78a2ed9f036938082c21faa74e88ca6ff8fd7041 Mon Sep 17 00:00:00 2001 From: jw098 Date: Tue, 14 Oct 2025 20:53:45 -0700 Subject: [PATCH 1/9] setup for Segment 32. move_from_west_province_area_one_north_to_alfornada() moved to segment 32 --- .../AutoStory/PokemonSV_AutoStory.cpp | 2 +- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 210 --------------- .../AutoStory/PokemonSV_AutoStoryTools.h | 4 - .../PokemonSV_AutoStory_Segment_32.cpp | 249 +++++++++++++++++- .../PokemonSV_AutoStory_Segment_32.h | 23 +- 5 files changed, 261 insertions(+), 227 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index c8b3087655..d6f1d719c5 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -108,7 +108,7 @@ std::vector> make_autoStory_segment_list(){ segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); - // segment_list.emplace_back(std::make_unique()); + segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 9754bedc72..0752a60a4c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1202,216 +1202,6 @@ void checkpoint_reattempt_loop_tutorial( -void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - context.wait_for_all_requests(); - DirectionDetector direction; - - do_action_and_monitor_for_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - // marker 1 - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 140, 255, 30); - direction.change_direction(env.program_info(), env.console, context, 4.047990); - pbf_move_left_joystick(context, 128, 0, 200, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - }); - - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 2 zoom in{0.605729, 0.30463}, zoom out{0.684375, 0.616667} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_OUT, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.684375, 0.616667} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 24, 8, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 3 {0.767708, 0.45} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 255, 255, 60}, - FlyPoint::POKECENTER, - {0.767708, 0.45} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 60, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - - // marker 4 {0.763021, 0.253704} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.763021, 0.253704} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 5 {0.780729, 0.216667} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.780729, 0.216667} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 6. place the marker at the top of the cliff. {0.633333, 0.304630} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_OUT, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.633333, 0.304630} - ); - - do_action_and_monitor_for_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - // walk towards wall - direction.change_direction(env.program_info(), env.console, context, 2.949863); - - walk_forward_while_clear_front_path(env.program_info(), env.console, context, 700); - - // back away from wall and get on ride - pbf_move_left_joystick(context, 128, 255, 50, 50); - get_on_ride(env.program_info(), env.console, context); - - // move back towards wall - pbf_move_left_joystick(context, 128, 0, 100, 50); - pbf_move_left_joystick(context, 0, 0, 400, 50); - - direction.change_direction(env.program_info(), env.console, context, 2.566167); - - // climb the wall - pbf_press_button(context, BUTTON_B, 31ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 855ms); - pbf_move_left_joystick(context, 128, 0, 7905ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 779ms); - pbf_move_left_joystick(context, 128, 0, 325ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 657ms); - pbf_move_left_joystick(context, 128, 0, 3271ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 860ms); - pbf_move_left_joystick(context, 128, 0, 220ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 993ms); - pbf_move_left_joystick(context, 128, 0, 3572ms, 0ms); - - get_off_ride(env.program_info(), env.console, context); - - // realign to marker 6 - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - - }); - - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - - // marker 7 {0.501042, 0.738889} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 200, 30}, - FlyPoint::POKECENTER, - {0.501042, 0.738889} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 8. set marker to pokecenter - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 128, 255, 30}, - {ZoomChange::KEEP_ZOOM, 0, 0, 0} - ); - - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 9. set marker past pokecenter - handle_unexpected_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 120, 255, 50); - }); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 15, 12, 12, false); // can't wrap in handle_when_stationary_in_overworld(), since we expect to be stationary when walking into the pokecenter - - - fly_to_overlapping_flypoint(env.program_info(), env.console, context); - - - - -} - - } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 23ccaa81ba..eac63b9ad0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -327,10 +327,6 @@ void checkpoint_reattempt_loop_tutorial( -void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context); - - - } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 526e591ae8..9497e5e586 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -4,6 +4,8 @@ * */ +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -28,15 +30,15 @@ namespace PokemonSV{ std::string AutoStory_Segment_32::name() const{ - return ""; + return "32: Alfornada Gym (Psychic)"; } std::string AutoStory_Segment_32::start_text() const{ - return "Start: "; + return "Start: Beat Team Star (Fighting). At North Province Area Two Pokecenter."; } std::string AutoStory_Segment_32::end_text() const{ - return "End: "; + return "End: Beat Alfornada Gym (Psychic). At Alfornada Pokecenter."; } void AutoStory_Segment_32::run_segment( @@ -52,7 +54,10 @@ void AutoStory_Segment_32::run_segment( context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - // checkpoint_(env, context, options.notif_status_update, stats); + checkpoint_82(env, context, options.notif_status_update, stats); + checkpoint_83(env, context, options.notif_status_update, stats); + checkpoint_84(env, context, options.notif_status_update, stats); + checkpoint_85(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -60,17 +65,253 @@ void AutoStory_Segment_32::run_segment( } void checkpoint_82(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); +} + + +void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + context.wait_for_all_requests(); + DirectionDetector direction; + + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + // marker 1 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 140, 255, 30); + direction.change_direction(env.program_info(), env.console, context, 4.047990); + pbf_move_left_joystick(context, 128, 0, 200, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + }); + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 2 zoom in{0.605729, 0.30463}, zoom out{0.684375, 0.616667} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_OUT, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.684375, 0.616667} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 24, 8, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 3 {0.767708, 0.45} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 255, 60}, + FlyPoint::POKECENTER, + {0.767708, 0.45} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 60, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + + // marker 4 {0.763021, 0.253704} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.763021, 0.253704} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 5 {0.780729, 0.216667} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.780729, 0.216667} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 6. place the marker at the top of the cliff. {0.633333, 0.304630} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_OUT, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.633333, 0.304630} + ); + + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + // walk towards wall + direction.change_direction(env.program_info(), env.console, context, 2.949863); + + walk_forward_while_clear_front_path(env.program_info(), env.console, context, 700); + + // back away from wall and get on ride + pbf_move_left_joystick(context, 128, 255, 50, 50); + get_on_ride(env.program_info(), env.console, context); + + // move back towards wall + pbf_move_left_joystick(context, 128, 0, 100, 50); + pbf_move_left_joystick(context, 0, 0, 400, 50); + + direction.change_direction(env.program_info(), env.console, context, 2.566167); + + // climb the wall + pbf_press_button(context, BUTTON_B, 31ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 855ms); + pbf_move_left_joystick(context, 128, 0, 7905ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 779ms); + pbf_move_left_joystick(context, 128, 0, 325ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 657ms); + pbf_move_left_joystick(context, 128, 0, 3271ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 860ms); + pbf_move_left_joystick(context, 128, 0, 220ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 993ms); + pbf_move_left_joystick(context, 128, 0, 3572ms, 0ms); + + get_off_ride(env.program_info(), env.console, context); + + // realign to marker 6 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + + }); + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + + // marker 7 {0.501042, 0.738889} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 200, 30}, + FlyPoint::POKECENTER, + {0.501042, 0.738889} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 8. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 128, 255, 30}, + {ZoomChange::KEEP_ZOOM, 0, 0, 0} + ); + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 9. set marker past pokecenter + handle_unexpected_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 120, 255, 50); + }); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 15, 12, 12, false); // can't wrap in handle_when_stationary_in_overworld(), since we expect to be stationary when walking into the pokecenter + + + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + + + + } + + + + + + void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h index f35d5aef8f..f093250f41 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h @@ -27,22 +27,29 @@ class AutoStory_Segment_32 : public AutoStory_Segment{ }; -// start: -// end: +// start: At North Province Area Two Pokecenter +// end: At Alfornada Pokecenter. void checkpoint_82(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: At Alfornada Pokecenter. +// end: At Alfornada gym building. Spoke to receptionist. void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: At Alfornada gym building. Spoke to receptionist. +// end: Beat Alfornada gym challenge. void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: Beat Alfornada gym challenge (ESP training). +// end: Beat Alfornada gym. void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + + +void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + + + + // start: // end: void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); From b7f77d128b3019d849719219bb9c4dbd839f43a9 Mon Sep 17 00:00:00 2001 From: jw098 Date: Tue, 14 Oct 2025 23:23:46 -0700 Subject: [PATCH 2/9] checkpoint 82 --- .../AutoStory/PokemonSV_AutoStory_Segment_32.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 9497e5e586..2a134f3222 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -68,6 +68,9 @@ void checkpoint_82(SingleSwitchProgramEnvironment& env, ProControllerContext& co checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 0, 170, 550}, FlyPoint::POKECENTER); + move_from_west_province_area_one_north_to_alfornada(env, context); + }); } @@ -124,7 +127,7 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi // marker 2 zoom in{0.605729, 0.30463}, zoom out{0.684375, 0.616667} place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_OUT, 0, 0, 0}, + {ZoomChange::ZOOM_OUT, 0, 150, 15}, FlyPoint::POKECENTER, {0.684375, 0.616667} ); @@ -217,7 +220,7 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi pbf_move_left_joystick(context, 128, 0, 100, 50); pbf_move_left_joystick(context, 0, 0, 400, 50); - direction.change_direction(env.program_info(), env.console, context, 2.566167); + direction.change_direction(env.program_info(), env.console, context, 2.575); //2.566167 // climb the wall pbf_press_button(context, BUTTON_B, 31ms, 0ms); @@ -230,7 +233,7 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 860ms); pbf_move_left_joystick(context, 128, 0, 220ms, 0ms); pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 993ms); - pbf_move_left_joystick(context, 128, 0, 3572ms, 0ms); + pbf_move_left_joystick(context, 128, 0, 4072ms, 0ms); get_off_ride(env.program_info(), env.console, context); From 94e8a8394ade8872c6f80cd0cfc0e83b538b4685 Mon Sep 17 00:00:00 2001 From: jw098 Date: Tue, 14 Oct 2025 23:37:54 -0700 Subject: [PATCH 3/9] update wall climbing in checkpoint 82 --- .../AutoStory/PokemonSV_AutoStory_Segment_32.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 2a134f3222..200077d19e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -233,15 +233,17 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 860ms); pbf_move_left_joystick(context, 128, 0, 220ms, 0ms); pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 993ms); - pbf_move_left_joystick(context, 128, 0, 4072ms, 0ms); - - get_off_ride(env.program_info(), env.console, context); - - // realign to marker 6 - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); }); + // continue climbing wall + pbf_move_left_joystick(context, 128, 0, 4072ms, 0ms); + + get_off_ride(env.program_info(), env.console, context); + + // realign to marker 6 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ overworld_navigation(env.program_info(), env.console, context, From 81db167d28e9439362b4d780a3ea00d67edf5c44 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 16:18:27 -0700 Subject: [PATCH 4/9] another wall climbing update in checkpoint 82 --- .../PokemonSV_AutoStory_Segment_32.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 200077d19e..f04a1511d8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -223,21 +223,17 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi direction.change_direction(env.program_info(), env.console, context, 2.575); //2.566167 // climb the wall - pbf_press_button(context, BUTTON_B, 31ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 855ms); - pbf_move_left_joystick(context, 128, 0, 7905ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 779ms); - pbf_move_left_joystick(context, 128, 0, 325ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 657ms); - pbf_move_left_joystick(context, 128, 0, 3271ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 860ms); - pbf_move_left_joystick(context, 128, 0, 220ms, 0ms); - pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 993ms); + pbf_press_button(context, BUTTON_B, 528ms, 0ms); + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 51ms); + pbf_move_left_joystick(context, 128, 0, 5002ms, 0ms); + pbf_wait(context, 1551ms); + pbf_move_left_joystick(context, 0, 128, 2167ms, 0ms); + pbf_wait(context, 745ms); }); // continue climbing wall - pbf_move_left_joystick(context, 128, 0, 4072ms, 0ms); + pbf_move_left_joystick(context, 128, 0, 8804ms, 0ms); get_off_ride(env.program_info(), env.console, context); From ece45bbb6333750ac8910b18cef301915dc3889f Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 18:07:40 -0700 Subject: [PATCH 5/9] checkpoint 83 draft 1 --- .../PokemonSV_AutoStory_Segment_32.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index f04a1511d8..67fe60c21c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -78,6 +78,50 @@ void checkpoint_82(SingleSwitchProgramEnvironment& env, ProControllerContext& co void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ + DirectionDetector direction; + + direction.change_direction(env.program_info(), env.console, context, 3.104878); + pbf_move_left_joystick(context, 128, 0, 520, 50); + + // {0.251563, 0.428704} {0.251563, 0.440741} {0.259896, 0.440741} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.259896, 0.440741} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + + direction.change_direction(env.program_info(), env.console, context, 0.332923); // 0.225695 0.332923 + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 0, 300, 50); // move left + pbf_move_left_joystick(context, 255, 128, 80, 50); // move right. center on door + pbf_move_left_joystick(context, 128, 0, 300, 50); // move forward + } + ); + + // speak to Nemona + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); + + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 30); + + // speak to receptionist + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); }); From ab4b925ebfcdb080112df66f6fa91ee304152eb6 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 18:29:56 -0700 Subject: [PATCH 6/9] update checkpoint 83 --- .../PokemonSV_AutoStory_Segment_32.cpp | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 67fe60c21c..0628cbbc63 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -80,20 +80,35 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co [&](size_t attempt_number){ DirectionDetector direction; + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 140, 70); + direction.change_direction(env.program_info(), env.console, context, 3.104878); pbf_move_left_joystick(context, 128, 0, 520, 50); - // {0.251563, 0.428704} {0.251563, 0.440741} {0.259896, 0.440741} + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 50, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // {0.326042, 0.438889} place_marker_offset_from_flypoint(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 0, 0, 0}, FlyPoint::POKECENTER, - {0.259896, 0.440741} + {0.326042, 0.438889} ); handle_when_stationary_in_overworld(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 10, false); + 128, 0, 30, 10, false); }, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ pbf_move_left_joystick(context, 0, 255, 40, 50); @@ -102,7 +117,7 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co ); - direction.change_direction(env.program_info(), env.console, context, 0.332923); // 0.225695 0.332923 + direction.change_direction(env.program_info(), env.console, context, 0.225386); // 0.225386 handle_when_stationary_in_overworld(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ @@ -110,7 +125,7 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co }, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ pbf_move_left_joystick(context, 0, 0, 300, 50); // move left - pbf_move_left_joystick(context, 255, 128, 80, 50); // move right. center on door + pbf_move_left_joystick(context, 255, 128, 60, 50); // move right. center on door pbf_move_left_joystick(context, 128, 0, 300, 50); // move forward } ); From b421363e4e7b01d30558491e5d2aa8c5090ffb8e Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 20:40:18 -0700 Subject: [PATCH 7/9] refactor ESP training routine so it can be used in other programs --- .../Farming/PokemonSV_ESPTraining.cpp | 235 ++++++++---------- .../Programs/Farming/PokemonSV_ESPTraining.h | 34 ++- 2 files changed, 141 insertions(+), 128 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp index c0ef7b1990..935ef1bbb8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp @@ -6,7 +6,6 @@ #include "Common/Cpp/PrettyPrint.h" #include "CommonFramework/Notifications/ProgramNotifications.h" -#include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonTools/Async/InferenceRoutines.h" #include "CommonTools/StartupChecks/VideoResolutionCheck.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -34,34 +33,9 @@ ESPTraining_Descriptor::ESPTraining_Descriptor() AllowCommandsWhenRunning::DISABLE_COMMANDS ) {} -struct ESPTraining_Descriptor::Stats : public StatsTracker{ - Stats() - : m_emotions(m_stats["Emotions Shown"]) - , m_joy(m_stats["Joy"]) - , m_surprise(m_stats["Surprise"]) - , m_excitement(m_stats["Excitement"]) - , m_anger(m_stats["Anger"]) - , m_clears(m_stats["Times Cleared"]) - , errors(m_stats["Errors"]) - { - m_display_order.emplace_back("Emotions Shown"); - m_display_order.emplace_back("Joy"); - m_display_order.emplace_back("Surprise"); - m_display_order.emplace_back("Excitement"); - m_display_order.emplace_back("Anger"); - m_display_order.emplace_back("Times Cleared"); - m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO); - } - std::atomic& m_emotions; - std::atomic& m_joy; - std::atomic& m_surprise; - std::atomic& m_excitement; - std::atomic& m_anger; - std::atomic& m_clears; - std::atomic& errors; -}; + std::unique_ptr ESPTraining_Descriptor::make_stats() const{ - return std::unique_ptr(new Stats()); + return std::unique_ptr(new ESPTrainingStats()); } ESPTraining::ESPTraining() : ROUNDS( @@ -89,7 +63,7 @@ ESPTraining::ESPTraining() void ESPTraining::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ assert_16_9_720p_min(env.logger(), env.console); - ESPTraining_Descriptor::Stats& stats = env.current_stats(); + ESPTrainingStats& stats = env.current_stats(); for (uint32_t c = 0; c < ROUNDS; c++){ env.log("Round: " + tostr_u_commas(c)); @@ -122,104 +96,12 @@ void ESPTraining::program(SingleSwitchProgramEnvironment& env, ProControllerCont context.wait_for(std::chrono::milliseconds(13000)); context.wait_for_all_requests(); - //Detect emotion and press the right button - //151 emotions + pauses but the game is inconsistent and sometimes displays an emotion during the transitions - //Note: can hit the wrong emotion and then the right one right after, as long as its before the timer - bool endflag = true; - while (endflag){ - ESPStartDetector ESPstart; - ESPShowNewEmotionDetector ESPstop; - ESPEmotionDetector detector; - { - //Countdown -> Dialog w/emotion - int ret = wait_until( - env.console, context, - std::chrono::seconds(15), - { { ESPstart } } - ); - if (ret < 0){ - env.log("Timeout waiting for dialog."); - endflag = false; - break; - } - int ret2 = wait_until( - env.console, context, - std::chrono::seconds(5), - { { detector } } - ); - if (ret2 < 0){ - env.log("Timeout waiting for emotion."); - } - - Button emotion_button = BUTTON_X; - - switch (detector.result()){ - case Detection::RED: - env.log("ESPEmotionDetector: Angry - Red - Press X", COLOR_BLACK); - emotion_button = BUTTON_X; - stats.m_emotions++; - stats.m_anger++; - break; - case Detection::YELLOW: - env.log("ESPEmotionDetector: Joy - Yellow - Press A", COLOR_BLACK); - emotion_button = BUTTON_A; - stats.m_emotions++; - stats.m_joy++; - break; - case Detection::BLUE: - env.log("ESPEmotionDetector: Surprised - Blue - Press B", COLOR_BLACK); - emotion_button = BUTTON_B; - stats.m_emotions++; - stats.m_surprise++; - break; - case Detection::GREEN: - env.log("ESPEmotionDetector: Excited - Green - Press Y", COLOR_BLACK); - emotion_button = BUTTON_Y; - stats.m_emotions++; - stats.m_excitement++; - break; - case Detection::GREY: - //Press any button to start next round - //Pressing A tends to make Dendra :D two extra times during the transition so press B instead - //Sometimes this is detected as blue, the B press there also works - env.log("ESPEmotionDetector: Grey - Mash though dialog", COLOR_BLACK); - emotion_button = BUTTON_B; - break; - default: - endflag = false; - break; - } - - // Press button and check it did not drop input. Press again if it did. - // This will result in a duplicate press between phases, but the press will do nothing. - pbf_press_button(context, emotion_button, 10, 50); - env.update_stats(); - - ESPPressedEmotionDetector emotion_press_detected; - int check = wait_until( - env.console, context, - std::chrono::seconds(1), - { { emotion_press_detected } } - ); - if (check < 0){ - env.log("Emotion press not detected in bottom right. Pressing button again."); - pbf_press_button(context, emotion_button, 10, 50); - }else{ - env.log("Emotion press detected."); - } - - //Look for the brief moment the dialog bubble vanishes - ret = wait_until( - env.console, context, - std::chrono::seconds(15), - { { ESPstop } } - ); - if (ret < 0){ - env.log("Timeout waiting for dialog to vanish."); - } - } - context.wait_for_all_requests(); - } + + + // Run the ESP training mini game + run_esp_training(env, context, stats); + + //Program done, mash B until overworld detected OverworldWatcher overworld(env.console, COLOR_CYAN); @@ -249,6 +131,105 @@ void ESPTraining::program(SingleSwitchProgramEnvironment& env, ProControllerCont GO_HOME_WHEN_DONE.run_end_of_program(context); send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); } + +void run_esp_training(SingleSwitchProgramEnvironment& env, ProControllerContext& context, ESPTrainingStats& stats){ + bool endflag = true; + while (endflag){ + ESPStartDetector ESPstart; + ESPShowNewEmotionDetector ESPstop; + ESPEmotionDetector detector; + { + //Countdown -> Dialog w/emotion + int ret = wait_until( + env.console, context, + std::chrono::seconds(15), + { { ESPstart } } + ); + if (ret < 0){ + env.log("Timeout waiting for dialog."); + endflag = false; + break; + } + int ret2 = wait_until( + env.console, context, + std::chrono::seconds(5), + { { detector } } + ); + if (ret2 < 0){ + env.log("Timeout waiting for emotion."); + } + + Button emotion_button = BUTTON_X; + + switch (detector.result()){ + case Detection::RED: + env.log("ESPEmotionDetector: Angry - Red - Press X", COLOR_BLACK); + emotion_button = BUTTON_X; + stats.m_emotions++; + stats.m_anger++; + break; + case Detection::YELLOW: + env.log("ESPEmotionDetector: Joy - Yellow - Press A", COLOR_BLACK); + emotion_button = BUTTON_A; + stats.m_emotions++; + stats.m_joy++; + break; + case Detection::BLUE: + env.log("ESPEmotionDetector: Surprised - Blue - Press B", COLOR_BLACK); + emotion_button = BUTTON_B; + stats.m_emotions++; + stats.m_surprise++; + break; + case Detection::GREEN: + env.log("ESPEmotionDetector: Excited - Green - Press Y", COLOR_BLACK); + emotion_button = BUTTON_Y; + stats.m_emotions++; + stats.m_excitement++; + break; + case Detection::GREY: + //Press any button to start next round + //Pressing A tends to make Dendra :D two extra times during the transition so press B instead + //Sometimes this is detected as blue, the B press there also works + env.log("ESPEmotionDetector: Grey - Mash though dialog", COLOR_BLACK); + emotion_button = BUTTON_B; + break; + default: + endflag = false; + break; + } + + // Press button and check it did not drop input. Press again if it did. + // This will result in a duplicate press between phases, but the press will do nothing. + pbf_press_button(context, emotion_button, 10, 50); + env.update_stats(); + + ESPPressedEmotionDetector emotion_press_detected; + int check = wait_until( + env.console, context, + std::chrono::seconds(1), + { { emotion_press_detected } } + ); + if (check < 0){ + env.log("Emotion press not detected in bottom right. Pressing button again."); + pbf_press_button(context, emotion_button, 10, 50); + }else{ + env.log("Emotion press detected."); + } + + //Look for the brief moment the dialog bubble vanishes + ret = wait_until( + env.console, context, + std::chrono::seconds(15), + { { ESPstop } } + ); + if (ret < 0){ + env.log("Timeout waiting for dialog to vanish."); + } + } + context.wait_for_all_requests(); + } + +} } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h index e6da0a788e..399dd8252c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h @@ -7,6 +7,7 @@ #ifndef PokemonAutomation_PokemonSV_ESPTraining_H #define PokemonAutomation_PokemonSV_ESPTraining_H +#include "CommonFramework/ProgramStats/StatsTracking.h" #include "Common/Cpp/Options/BooleanCheckBoxOption.h" #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" @@ -21,10 +22,36 @@ class ESPTraining_Descriptor : public SingleSwitchProgramDescriptor{ public: ESPTraining_Descriptor(); - struct Stats; virtual std::unique_ptr make_stats() const override; }; +struct ESPTrainingStats : public StatsTracker{ + ESPTrainingStats() + : m_emotions(m_stats["Emotions Shown"]) + , m_joy(m_stats["Joy"]) + , m_surprise(m_stats["Surprise"]) + , m_excitement(m_stats["Excitement"]) + , m_anger(m_stats["Anger"]) + , m_clears(m_stats["Times Cleared"]) + , errors(m_stats["Errors"]) + { + m_display_order.emplace_back("Emotions Shown"); + m_display_order.emplace_back("Joy"); + m_display_order.emplace_back("Surprise"); + m_display_order.emplace_back("Excitement"); + m_display_order.emplace_back("Anger"); + m_display_order.emplace_back("Times Cleared"); + m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO); + } + std::atomic& m_emotions; + std::atomic& m_joy; + std::atomic& m_surprise; + std::atomic& m_excitement; + std::atomic& m_anger; + std::atomic& m_clears; + std::atomic& errors; +}; + class ESPTraining : public SingleSwitchProgramInstance{ public: ESPTraining(); @@ -39,6 +66,11 @@ class ESPTraining : public SingleSwitchProgramInstance{ EventNotificationsOption NOTIFICATIONS; }; +//Detect emotion and press the right button +//151 emotions + pauses but the game is inconsistent and sometimes displays an emotion during the transitions +//Note: can hit the wrong emotion and then the right one right after, as long as its before the timer +void run_esp_training(SingleSwitchProgramEnvironment& env, ProControllerContext& context, ESPTrainingStats& stats); + } } } From fa5b7a4b5999ea87d2eaae512e0271a6932992a3 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 22:45:49 -0700 Subject: [PATCH 8/9] checkpoint 84 --- .../PokemonSV_AutoStory_Segment_32.cpp | 85 ++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 0628cbbc63..dcb57941af 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -57,7 +58,6 @@ void AutoStory_Segment_32::run_segment( checkpoint_82(env, context, options.notif_status_update, stats); checkpoint_83(env, context, options.notif_status_update, stats); checkpoint_84(env, context, options.notif_status_update, stats); - checkpoint_85(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -145,7 +145,90 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ + pbf_move_left_joystick(context, 128, 255, 400, 100); + pbf_wait(context, 3 * TICKS_PER_SECOND); + // wait for overworld after leaving gym + wait_for_overworld(env.program_info(), env.console, context, 30); + DirectionDetector direction; + + direction.change_direction(env.program_info(), env.console, context, 4.413989); + pbf_move_left_joystick(context, 128, 0, 180, 50); + + direction.change_direction(env.program_info(), env.console, context, 5.516255); + + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 30); + clear_dialog(env.console, context, ClearDialogMode::STOP_PROMPT, 60, {CallbackEnum::PROMPT_DIALOG}); + + //mash past other dialog + pbf_mash_button(context, BUTTON_A, 360); + + //wait for start + context.wait_for(std::chrono::milliseconds(30000)); + context.wait_for_all_requests(); + + + // Run the ESP training mini game + ESPTrainingStats esp_training_stats; // dummy stats + run_esp_training(env, context, esp_training_stats); + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW}); + + env.console.log("Battle Gym Trainer 1."); + run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + + + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5); + pbf_wait(context, 10000ms); + + //mash past other dialog + pbf_mash_button(context, BUTTON_A, 360); + + //wait for start + context.wait_for(std::chrono::milliseconds(8000)); + context.wait_for_all_requests(); + + + // Run the ESP training mini game + run_esp_training(env, context, esp_training_stats); + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW}); + + env.console.log("Battle Gym Trainer 2."); + run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); + + // Gym challenge now done + + direction.change_direction(env.program_info(), env.console, context, 2.336990); + pbf_move_left_joystick(context, 128, 0, 400, 50); + + direction.change_direction(env.program_info(), env.console, context, 0.156705); + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 30); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 0, 300, 50); // move left + pbf_move_left_joystick(context, 255, 128, 60, 50); // move right. center on door + pbf_move_left_joystick(context, 128, 0, 300, 50); // move forward + } + ); + + + // speak to receptionist. if we fail to detect a battle, then we know we failed the Gym test. we then reset. + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BATTLE, CallbackEnum:: DIALOG_ARROW}); + env.console.log("Battle Psychic Gym leader."); + run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + mash_button_till_overworld(env.console, context, BUTTON_A); + + + pbf_move_left_joystick(context, 128, 255, 400, 100); + pbf_wait(context, 3 * TICKS_PER_SECOND); + // wait for overworld after leaving gym + wait_for_overworld(env.program_info(), env.console, context, 30); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}, FlyPoint::POKECENTER); }); } From 01e7501bbcb04f2626427ae1200d4ff0b4948207 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 15 Oct 2025 22:49:07 -0700 Subject: [PATCH 9/9] tidy up --- .../PokemonSV_AutoStory_Segment_32.cpp | 26 ----------------- .../PokemonSV_AutoStory_Segment_32.h | 29 +------------------ .../PokemonSV_AutoStory_Segment_33.cpp | 28 ++++++++++++++++++ .../PokemonSV_AutoStory_Segment_33.h | 24 +++++++++++++++ 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index dcb57941af..ba3a254f94 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -233,13 +233,6 @@ void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& co }); } -void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ - checkpoint_reattempt_loop(env, context, notif_status_update, stats, - [&](size_t attempt_number){ - - - }); -} void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ @@ -453,25 +446,6 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi - - -void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_87(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_88(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_89(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - - - } } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h index f093250f41..9a10cb8d39 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h @@ -36,13 +36,9 @@ void checkpoint_82(SingleSwitchProgramEnvironment& env, ProControllerContext& co void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); // start: At Alfornada gym building. Spoke to receptionist. -// end: Beat Alfornada gym challenge. +// end: Beat Alfornada gym challenge. Beat Alfornada gym. At Alfronada Pokecenter. void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: Beat Alfornada gym challenge (ESP training). -// end: Beat Alfornada gym. -void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context); @@ -50,29 +46,6 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi -// start: -// end: -void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - -// start: -// end: -void checkpoint_87(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - -// start: -// end: -void checkpoint_88(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - -// start: -// end: -void checkpoint_89(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - -// start: -// end: -void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - - - - } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp index 638a067d28..10c6f52dd8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp @@ -60,6 +60,34 @@ void AutoStory_Segment_33::run_segment( } +void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); +} + + + +void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_87(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_88(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_89(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + + + + } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.h index a072d8b265..ae91b4335e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.h @@ -26,6 +26,30 @@ class AutoStory_Segment_33 : public AutoStory_Segment{ ) const override; }; +// start: Beat Alfornada gym challenge. Beat Alfornada gym. At Alfronada Pokecenter. +// end: +void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_87(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_88(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_89(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); +