diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index f692b69d96..7213f0b7c8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -251,6 +251,52 @@ bool confirm_marker_present( } +void realign_player(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, + PlayerRealignMode realign_mode, + uint8_t move_x, uint8_t move_y, uint16_t move_duration +){ + stream.log("Realigning player direction..."); + switch (realign_mode){ + case PlayerRealignMode::REALIGN_NEW_MARKER: + stream.log("Setting new map marker..."); + + handle_unexpected_battles(info, stream, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + open_map_from_overworld(info, stream, context); + }); + + pbf_press_button(context, BUTTON_ZR, 20, 105); + pbf_move_left_joystick(context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_A, 20, 105); + pbf_press_button(context, BUTTON_A, 20, 105); + + handle_unexpected_battles(info, stream, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + leave_phone_to_overworld(info, stream, context); + }); + return; + case PlayerRealignMode::REALIGN_OLD_MARKER: + handle_unexpected_battles(info, stream, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + open_map_from_overworld(info, stream, context, false); + }); + + handle_unexpected_battles(info, stream, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + leave_phone_to_overworld(info, stream, context); + }); + + pbf_press_button(context, BUTTON_L, 20, 105); + return; + case PlayerRealignMode::REALIGN_NO_MARKER: + pbf_move_left_joystick(context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_L, 20, 105); + return; + } + +} + + void overworld_navigation( const ProgramInfo& info, VideoStream& stream, @@ -1090,6 +1136,8 @@ void checkpoint_reattempt_loop( context.wait_for_all_requests(); action(i); + + enter_menu_from_overworld(env.program_info(), env.console, context, -1); break; }catch(OperationFailedException& e){ @@ -1154,216 +1202,6 @@ void checkpoint_reattempt_loop_tutorial( -void move_from_glaseado_mountain_to_casseroya_watchtower3(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - context.wait_for_all_requests(); - - DirectionDetector direction; - direction.change_direction(env.program_info(), env.console, context, 1.448679); - - pbf_move_left_joystick(context, 128, 0, 200, 50); - - - // marker 1 x=0.548438, y=0.273148 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_OUT, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.548438, 0.273148} - ); - - get_on_ride(env.program_info(), env.console, context); - - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 2. : x=0.693229, y=0.459259 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.693229, 0.459259} - ); - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - fly_to_overlapping_flypoint(env.program_info(), env.console, context); - -} - - -void move_from_casseroya_watchtower3_to_dondozo_titan(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - context.wait_for_all_requests(); - - // marker 1 x=0.779167, y=0.274074 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.779167, 0.274074} - ); - - get_on_ride(env.program_info(), env.console, context); - - 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_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - mash_button_till_overworld(env.console, context, BUTTON_A); - - // resume marker 1 - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 2. : x=0.76875, y=0.298148 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::FAST_TRAVEL, - {0.76875, 0.298148} - ); - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - - // marker 3. : x=0.752604, y=0.401852 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::FAST_TRAVEL, - {0.752604, 0.401852} - ); - 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_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, - 128, 0, 20, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); - env.console.log("Battle Dondozo/Tatsugiri Titan phase 1."); - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - - -} - -void move_from_dondozo_titan_phase1_to_phase2(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - context.wait_for_all_requests(); - - // marker 1 x=0.832292, y=0.54537 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::FAST_TRAVEL, - {0.832292, 0.54537} - ); - - get_on_ride(env.program_info(), env.console, context); - - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 2 x=0.393229, y=0.748148 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_IN, 0, 0, 0}, - FlyPoint::FAST_TRAVEL, - {0.393229, 0.748148} - ); - 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, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - - // marker 3. go to Dondozo/Tatsugiri part 2 x=0.55625, y=0.324074 - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 255, 100}, - FlyPoint::FAST_TRAVEL, - {0.55625, 0.324074} - ); - 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_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 80, 40, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); - - env.console.log("Battle Dondozo/Tatsugiri Titan phase 2."); - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); - clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); - - env.console.log("Battle Dondozo/Tatsugiri Titan phase 3."); - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::DIALOG_ARROW}); - mash_button_till_overworld(env.console, context, BUTTON_A, 360); - -} - void move_from_glaseado_mountain_to_montenevera(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ context.wait_for_all_requests(); @@ -1723,49 +1561,13 @@ void move_from_montenevera_to_glaseado_gym(SingleSwitchProgramEnvironment& env, } -void move_from_glaseado_mountain_to_north_province_area_three(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ - - context.wait_for_all_requests(); - - // marker 1. set marker to pokecenter - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 128, 0, 50}, - {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, 80, 10, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - - // marker 2. 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, 128, 0, 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 move_from_glaseado_gym_to_north_province_area_one(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ context.wait_for_all_requests(); DirectionDetector direction; - handle_unexpected_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 3.855289); @@ -1876,7 +1678,7 @@ void move_from_glaseado_gym_to_north_province_area_one(SingleSwitchProgramEnviro void move_from_north_province_area_one_to_fighting_base(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ DirectionDetector direction; - handle_unexpected_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 1.798578); @@ -2331,7 +2133,7 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi context.wait_for_all_requests(); DirectionDetector direction; - handle_unexpected_battles(env.program_info(), env.console, context, + 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); @@ -2432,7 +2234,7 @@ void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvi {0.633333, 0.304630} ); - handle_unexpected_battles(env.program_info(), env.console, context, + 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); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index d74969747c..aac7dfe7e4 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -117,6 +117,28 @@ bool confirm_marker_present( ProControllerContext& context ); +// align player orientation based on the alignment mode +// The direction is specified by (x, y): +// x = 0 : left +// x = 128 : neutral +// x = 255 : right +// y = 0 : up +// y = 128 : neutral +// y = 255 : down +// - REALIGN_NEW_MARKER: place down a map marker, which will align the player towards the marker +// location of the marker is set with move_x, move_y, move_duration +// - REALIGN_OLD_MARKER: assuming a marker is already set, open and close the map, +// which will align the player towards the marker +// - REALIGN_NO_MARKER: move player towards in the direction set by move_x, move_y, move_duration +// then re-align the camera +void realign_player( + const ProgramInfo& info, + VideoStream& stream, ProControllerContext& context, + PlayerRealignMode realign_mode, + uint8_t move_x = 0, uint8_t move_y = 0, uint16_t move_duration = 0 +); + + // move character with ssf left joystick, as per given x, y, until // stop_condition is met (e.g. Dialog detected). // throw exception if reaches timeout before detecting stop condition @@ -298,14 +320,7 @@ void checkpoint_reattempt_loop_tutorial( -// moves player from Glaseado Mountain Pokecenter to Casseroya Watchtower 3 -void move_from_glaseado_mountain_to_casseroya_watchtower3(SingleSwitchProgramEnvironment& env, ProControllerContext& context); - -// moves player from Casseroya Watchtower 3 to Dondozo Titan. Defeat Dondozo Titan phase 1. -void move_from_casseroya_watchtower3_to_dondozo_titan(SingleSwitchProgramEnvironment& env, ProControllerContext& context); -// moves player from Dondozo Titan phase 1 to phase 2. Defeat Dondozo Titan phase 2-3. -void move_from_dondozo_titan_phase1_to_phase2(SingleSwitchProgramEnvironment& env, ProControllerContext& context); // moves player from Glaseado Mountain Pokecenter to Montenevera Pokecenter void move_from_glaseado_mountain_to_montenevera(SingleSwitchProgramEnvironment& env, ProControllerContext& context); @@ -313,8 +328,7 @@ void move_from_glaseado_mountain_to_montenevera(SingleSwitchProgramEnvironment& // moves player from Montenevera Pokecenter to Glaseado Gym Pokecenter void move_from_montenevera_to_glaseado_gym(SingleSwitchProgramEnvironment& env, ProControllerContext& context); -// moves player from Glaseado Mountain Pokecenter to North Province Area Three Pokecenter -void move_from_glaseado_mountain_to_north_province_area_three(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + // moves player from Glaseado Gym Pokecenter to North Province Area One void move_from_glaseado_gym_to_north_province_area_one(SingleSwitchProgramEnvironment& env, ProControllerContext& context); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp index 11c43938e0..27f4c475eb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.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_27::name() const{ - return ""; + return "27: Dondozo/Tatsugiri Titan"; } std::string AutoStory_Segment_27::start_text() const{ - return "Start: "; + return "Start: Beat Medali Gym (Normal). At Glaseado Mountain Pokecenter."; } std::string AutoStory_Segment_27::end_text() const{ - return "End: "; + return "End: Beat Dondozo/Tatsugiri Titan. At North Province Area Three Pokecenter."; } void AutoStory_Segment_27::run_segment( @@ -52,7 +54,10 @@ void AutoStory_Segment_27::run_segment( context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - // checkpoint_(env, context, options.notif_status_update, stats); + checkpoint_64(env, context, options.notif_status_update, stats); + checkpoint_65(env, context, options.notif_status_update, stats); + checkpoint_66(env, context, options.notif_status_update, stats); + checkpoint_67(env, context, options.notif_status_update, stats); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -60,15 +65,41 @@ void AutoStory_Segment_27::run_segment( } void checkpoint_64(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); + move_from_glaseado_mountain_to_casseroya_watchtower3(env, context); + + }); } void checkpoint_65(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); + move_from_casseroya_watchtower3_to_dondozo_titan(env, context); + + }); } void checkpoint_66(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); + move_from_dondozo_titan_phase1_to_phase2(env, context); + + }); } void checkpoint_67(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + context.wait_for_all_requests(); + // fly to Glaseado Mountain Pokecenter + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 0, 0, 0}, FlyPoint::POKECENTER); + move_from_glaseado_mountain_to_north_province_area_three(env, context); + + }); } void checkpoint_68(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ @@ -81,6 +112,202 @@ void checkpoint_70(SingleSwitchProgramEnvironment& env, ProControllerContext& co } + +void move_from_glaseado_mountain_to_casseroya_watchtower3(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + context.wait_for_all_requests(); + + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 1.448679); + + pbf_move_left_joystick(context, 128, 0, 200, 50); + + + // marker 1 x=0.548438, y=0.273148 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_OUT, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.548438, 0.273148} + ); + + get_on_ride(env.program_info(), env.console, context); + + 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, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 2. : x=0.693229, y=0.459259 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.693229, 0.459259} + ); + 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, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + +} + + +void move_from_casseroya_watchtower3_to_dondozo_titan(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + context.wait_for_all_requests(); + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + + // marker 1 x=0.779167, y=0.274074 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.779167, 0.274074} + ); + + // get_on_ride(env.program_info(), env.console, context); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + + mash_button_till_overworld(env.console, context, BUTTON_A); + + // resume marker 1 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // marker 2. : x=0.76875, y=0.298148 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::FAST_TRAVEL, + {0.76875, 0.298148} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + + + // marker 3. : x=0.752604, y=0.401852 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::FAST_TRAVEL, + {0.752604, 0.401852} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, + 128, 0, 20, 10, false); + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); + env.console.log("Battle Dondozo/Tatsugiri Titan phase 1."); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + + +} + +void move_from_dondozo_titan_phase1_to_phase2(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + context.wait_for_all_requests(); + + // marker 1 x=0.832292, y=0.54537 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::FAST_TRAVEL, + {0.832292, 0.54537} + ); + + get_on_ride(env.program_info(), env.console, context); + + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // marker 2 x=0.393229, y=0.748148 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 0, 0}, + FlyPoint::FAST_TRAVEL, + {0.393229, 0.748148} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + + // marker 3. go to Dondozo/Tatsugiri part 2 x=0.55625, y=0.324074 + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 128, 255, 40}, + FlyPoint::FAST_TRAVEL, + {0.55625, 0.324074} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 80, 40, false); + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); + + env.console.log("Battle Dondozo/Tatsugiri Titan phase 2."); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); + + env.console.log("Battle Dondozo/Tatsugiri Titan phase 3."); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::DIALOG_ARROW}); + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + +} + + +void move_from_glaseado_mountain_to_north_province_area_three(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + + context.wait_for_all_requests(); + + // marker 1. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 128, 0, 50}, + {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, 80, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + + // marker 2. 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, 128, 0, 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_27.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.h index e1f39de7ad..0f78c38974 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.h @@ -26,20 +26,20 @@ class AutoStory_Segment_27 : public AutoStory_Segment{ ) const override; }; -// start: -// end: +// start: At Glaseado Mountain Pokecenter +// end: At Casseroya Watchtower 3 void checkpoint_64(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: At Casseroya Watchtower 3 +// end: Defeat Dondozo Titan phase 1. void checkpoint_65(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: Defeat Dondozo Titan phase 1. +// end: Defeat Dondozo Titan phase 2-3. void checkpoint_66(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: Defeat Dondozo Titan phase 2-3. +// end: At North Province Area Three Pokecenter void checkpoint_67(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); // start: @@ -56,6 +56,17 @@ void checkpoint_70(SingleSwitchProgramEnvironment& env, ProControllerContext& co +// moves player from Glaseado Mountain Pokecenter to Casseroya Watchtower 3 +void move_from_glaseado_mountain_to_casseroya_watchtower3(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + +// moves player from Casseroya Watchtower 3 to Dondozo Titan. Defeat Dondozo Titan phase 1. +void move_from_casseroya_watchtower3_to_dondozo_titan(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + +// moves player from Dondozo Titan phase 1 to phase 2. Defeat Dondozo Titan phase 2-3. +void move_from_dondozo_titan_phase1_to_phase2(SingleSwitchProgramEnvironment& env, ProControllerContext& context); + +// moves player from Glaseado Mountain Pokecenter to North Province Area Three Pokecenter +void move_from_glaseado_mountain_to_north_province_area_three(SingleSwitchProgramEnvironment& env, ProControllerContext& context); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp index 09e8f8df0a..4a4ffef65e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp @@ -57,6 +57,7 @@ bool fly_to_overworld_from_map(const ProgramInfo& info, VideoStream& stream, Pro } int ret = 0; + NormalBattleMenuWatcher battle(COLOR_BLUE); OverworldWatcher overworld(stream.logger(), COLOR_CYAN); WhiteButtonWatcher map(COLOR_RED, WhiteButton::ButtonY, {0.800, 0.118, 0.030, 0.060}); GradientArrowWatcher spot_dialog_watcher(COLOR_YELLOW, GradientArrowType::RIGHT, {0.469, 0.500, 0.215, 0.150}); @@ -66,8 +67,8 @@ bool fly_to_overworld_from_map(const ProgramInfo& info, VideoStream& stream, Pro context.wait_for_all_requests(); - std::vector callbacks{overworld, map, spot_dialog_watcher, confirm_watcher}; - if (check_fly_menuitem){ + std::vector callbacks{overworld, map, spot_dialog_watcher, confirm_watcher, battle}; + if (check_fly_menuitem){ // callbacks: overworld, map, flyMenuItemWatcher, confirm_watcher, battle, destinationMenuItemWatcher callbacks[2] = flyMenuItemWatcher; callbacks.push_back(destinationMenuItemWatcher); } @@ -75,24 +76,31 @@ bool fly_to_overworld_from_map(const ProgramInfo& info, VideoStream& stream, Pro ret = wait_until(stream, context, std::chrono::minutes(2), callbacks); context.wait_for(std::chrono::milliseconds(100)); switch (ret){ - case 0: + case 0: // overworld stream.log("Detected overworld. Fly successful."); return true; - case 1: + case 1: // map stream.log("Detected map. Pressing A to open map menu."); // Press A to bring up the promp dialog on choosing "Fly here", "Set as destination", "Never mind". pbf_press_button(context, BUTTON_A, 20, 130); continue; - case 2: + case 2: // spot_dialog_watcher or flyMenuItemWatcher stream.log("Detected fly here prompt dialog."); stream.overlay().add_log("Fly"); pbf_press_button(context, BUTTON_A, 20, 130); continue; - case 3: + case 3: //confirm_watcher stream.log("Detected fly confirmation prompt."); pbf_press_button(context, BUTTON_A, 20, 130); continue; - case 4: + case 4: //battle + stream.log("Detected battle."); + throw_and_log( + stream.logger(), ErrorReport::SEND_ERROR_REPORT, + "fly_to_overworld_from_map(): Unexpectedly detected battle.", + stream + ); + case 5: //destinationMenuItemWatcher stream.log("Detected no fly spot here."); stream.overlay().add_log("No fly spot", COLOR_RED); return false; @@ -640,33 +648,6 @@ void reset_to_pokecenter(const ProgramInfo& info, VideoStream& stream, ProContro } -void realign_player(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, - PlayerRealignMode realign_mode, - uint8_t move_x, uint8_t move_y, uint16_t move_duration -){ - stream.log("Realigning player direction..."); - switch (realign_mode){ - case PlayerRealignMode::REALIGN_NEW_MARKER: - stream.log("Setting new map marker..."); - open_map_from_overworld(info, stream, context); - pbf_press_button(context, BUTTON_ZR, 20, 105); - pbf_move_left_joystick(context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND); - pbf_press_button(context, BUTTON_A, 20, 105); - pbf_press_button(context, BUTTON_A, 20, 105); - leave_phone_to_overworld(info, stream, context); - return; - case PlayerRealignMode::REALIGN_OLD_MARKER: - open_map_from_overworld(info, stream, context, false); - leave_phone_to_overworld(info, stream, context); - pbf_press_button(context, BUTTON_L, 20, 105); - return; - case PlayerRealignMode::REALIGN_NO_MARKER: - pbf_move_left_joystick(context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND); - pbf_press_button(context, BUTTON_L, 20, 105); - return; - } - -} void walk_forward_until_dialog( diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h index e0af2cbb32..c3eb1add63 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h @@ -127,27 +127,7 @@ void jump_off_wall_until_map_open(const ProgramInfo& info, VideoStream& stream, void reset_to_pokecenter(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context); -// align player orientation based on the alignment mode -// if battle detected, propagates UnexpectedBattleException to the calling function -// The direction is specified by (x, y): -// x = 0 : left -// x = 128 : neutral -// x = 255 : right -// y = 0 : up -// y = 128 : neutral -// y = 255 : down -// - REALIGN_NEW_MARKER: place down a map marker, which will align the player towards the marker -// location of the marker is set with move_x, move_y, move_duration -// - REALIGN_OLD_MARKER: assuming a marker is already set, open and close the map, -// which will align the player towards the marker -// - REALIGN_NO_MARKER: move player towards in the direction set by move_x, move_y, move_duration -// then re-align the camera -void realign_player( - const ProgramInfo& info, - VideoStream& stream, ProControllerContext& context, - PlayerRealignMode realign_mode, - uint8_t move_x = 0, uint8_t move_y = 0, uint16_t move_duration = 0 -); +