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..ba3a254f94 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,9 @@ * */ +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -28,15 +31,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 +55,9 @@ 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); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -60,34 +65,387 @@ 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){ + + 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); + + + }); } 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; + + 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); + + 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.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, 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); + } + ); + + + 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){ + 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, 60, 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}); + + + }); } 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); -void checkpoint_85(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} + DirectionDetector direction; -void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} + direction.change_direction(env.program_info(), env.console, context, 4.413989); + pbf_move_left_joystick(context, 128, 0, 180, 50); -void checkpoint_87(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} + 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 + } + ); -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){ + // 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); + + }); } -void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + + +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, 150, 15}, + 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.575); //2.566167 + + // climb the wall + 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, 8804ms, 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_AutoStory_Segment_32.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h index f35d5aef8f..9a10cb8d39 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.h @@ -27,41 +27,21 @@ 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. Beat Alfornada gym. At Alfronada Pokecenter. void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// 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); +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_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); + 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); + } } }