Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
segment_list.emplace_back(std::make_unique<AutoStory_Segment_22>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_23>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_24>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_25>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_25>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_26>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_27>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_28>());
Expand Down Expand Up @@ -210,25 +210,25 @@ AutoStory::AutoStory()
StorySection::TUTORIAL
)
, STARTPOINT_TUTORIAL(
"<b>Start Point:</b><br>Program will start with this segment.",
"<b>Start Point:</b>", //<br>Program will start with this segment.
TUTORIAL_SEGMENTS_SELECT_DATABASE(),
LockMode::LOCK_WHILE_RUNNING,
"0"
)
, ENDPOINT_TUTORIAL(
"<b>End Point:</b><br>Program will stop after completing this segment.",
"<b>End Point:</b>", //<br>Program will stop after completing this segment.
TUTORIAL_SEGMENTS_SELECT_DATABASE(),
LockMode::UNLOCK_WHILE_RUNNING,
"9"
)
, STARTPOINT_MAINSTORY(
"<b>Start Point:</b><br>Program will start with this segment.",
"<b>Start Point:</b>", //<br>Program will start with this segment.
MAINSTORY_SEGMENTS_SELECT_DATABASE(),
LockMode::UNLOCK_WHILE_RUNNING,
"10"
)
, ENDPOINT_MAINSTORY(
"<b>End Point:</b><br>Program will stop after completing this segment.",
"<b>End Point:</b>", //<br>Program will stop after completing this segment.
MAINSTORY_SEGMENTS_SELECT_DATABASE(),
LockMode::UNLOCK_WHILE_RUNNING,
"10"
Expand All @@ -237,7 +237,7 @@ AutoStory::AutoStory()
"NOTE: Make sure you have selected the correct Start Point. "
"Make sure your player character is in the exact correct start position for that Start Point, "
"especially if your start point is NOT at the beginning of the Tutorial/Main Story. "
"Read the Start Point's description to help with finding the correct start position."
"Read the Start Point's description to help with finding the correct start position. "
"For Start Points that are at Pokecenters, ensure that you fly there so that your character is in the exactly correct start position."
}
, MAINSTORY_NOTE{
Expand Down Expand Up @@ -846,6 +846,7 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont
if (ENABLE_TEST_CHECKPOINTS){
// test individual checkpoints
test_checkpoints(env, env.console, context, START_CHECKPOINT, END_CHECKPOINT, LOOP_CHECKPOINT, START_LOOP, END_LOOP);
GO_HOME_WHEN_DONE.run_end_of_program(context);
return;
}

Expand Down Expand Up @@ -882,7 +883,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex


// test code
if (ENABLE_TEST_CHECKPOINTS || ENABLE_TEST_REALIGN || ENABLE_MISC_TEST || TEST_PBF_LEFT_JOYSTICK || TEST_PBF_LEFT_JOYSTICK2 || TEST_CHANGE_DIRECTION || TEST_CURRENT_DIRECTION){
if (TEST_FLYPOINT_LOCATIONS || TEST_MOVE_CURSOR_OFFSET_FROM_FLYPOINT || ENABLE_TEST_CHECKPOINTS || ENABLE_TEST_REALIGN || ENABLE_MISC_TEST || TEST_PBF_LEFT_JOYSTICK || TEST_PBF_LEFT_JOYSTICK2 || TEST_CHANGE_DIRECTION || TEST_CURRENT_DIRECTION){
test_code(env, context);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ void realign_player_from_landmark(
stream.log("Realigning player direction, using a landmark...");
WallClock start = current_time();

const int MAX_TRY_COUNT = 17;
int try_count = 0;

// failures to fly to pokecenter are often when the Switch lags. from my testing, a 1.4-1.5 adjustment factor seems to work
const std::array<double, MAX_TRY_COUNT> adjustment_table = {1, 1.4, 1, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 0.9, 0.8, 1.4}; // {1, 1.4, 1.5};

while (true){
if (current_time() - start > std::chrono::minutes(5)){
OperationFailedException::fire(
Expand Down Expand Up @@ -888,7 +894,8 @@ void realign_player_from_landmark(
pbf_move_left_joystick(context, move_x1, move_y1, move_duration1, 1 * TICKS_PER_SECOND);

// move cursor to pokecenter
if (!detect_closest_flypoint_and_move_map_cursor_there(info, stream, context, FlyPoint::POKECENTER, 0.29)){
double push_scale = 0.29 * adjustment_table[try_count];
if (!detect_closest_flypoint_and_move_map_cursor_there(info, stream, context, FlyPoint::POKECENTER, push_scale)){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"realign_player_from_landmark(): No visible pokecenter found on map.",
Expand Down Expand Up @@ -932,8 +939,16 @@ void realign_player_from_landmark(
}catch (UnexpectedBattleException&){
run_wild_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
}catch (OperationFailedException&){
// reset to overworld if failed to center on the pokecenter, and re-try
leave_phone_to_overworld(info, stream, context);
try_count++;
if (try_count >= MAX_TRY_COUNT){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"fly_to_closest_pokecenter_on_map(): At min warpable map level, pokecenter was detected, but failed to fly there.",
stream
);
}
stream.log("Failed to find the fly menu item. Restart the closest Pokecenter travel process.");
press_Bs_to_back_to_overworld(info, stream, context);
}
}

Expand Down Expand Up @@ -966,6 +981,12 @@ void move_cursor_towards_flypoint_and_go_there(
){
WallClock start = current_time();

const int MAX_TRY_COUNT = 17;
int try_count = 0;

// failures to fly to pokecenter are often when the Switch lags. from my testing, a 1.4-1.5 adjustment factor seems to work
const std::array<double, MAX_TRY_COUNT> adjustment_table = {1, 1.4, 1, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 0.9, 0.8, 1.4}; // {1, 1.4, 1.5};

while (true){
if (current_time() - start > std::chrono::minutes(5)){
OperationFailedException::fire(
Expand Down Expand Up @@ -1002,7 +1023,8 @@ void move_cursor_towards_flypoint_and_go_there(
uint16_t move_duration1 = move_cursor_near_flypoint.move_duration;
pbf_move_left_joystick(context, move_x1, move_y1, move_duration1, 1 * TICKS_PER_SECOND);

if (!fly_to_visible_closest_flypoint_cur_zoom_level(info, stream, context, fly_point)){
double push_scale = 0.29 * adjustment_table[try_count];
if (!fly_to_visible_closest_flypoint_cur_zoom_level(info, stream, context, fly_point, push_scale)){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"move_cursor_towards_flypoint_and_go_there(): No visible pokecenter found on map.",
Expand All @@ -1015,8 +1037,16 @@ void move_cursor_towards_flypoint_and_go_there(
}catch (UnexpectedBattleException&){
run_wild_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
}catch (OperationFailedException&){
// reset to overworld if failed to center on the pokecenter, and re-try
leave_phone_to_overworld(info, stream, context);
try_count++;
if (try_count >= MAX_TRY_COUNT){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"move_cursor_towards_flypoint_and_go_there(): At given zoom level, pokecenter was detected, but failed to fly there.",
stream
);
}
stream.log("Failed to find the fly menu item. Restart the closest Pokecenter travel process.");
press_Bs_to_back_to_overworld(info, stream, context);
}
}

Expand Down Expand Up @@ -1122,197 +1152,6 @@ void checkpoint_reattempt_loop_tutorial(
}
}

void move_from_porto_marinada_to_medali(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
context.wait_for_all_requests();

// marker 1
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 110, 75);

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, 255, 255, 40, 50);
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER);
}
);

// marker 2. x=0.3875, y=0.60463
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::ZOOM_OUT, 0, 0, 0},
FlyPoint::POKECENTER,
{0.3875, 0.60463}
);
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 3. : x=0.316146, y=0.623148
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::ZOOM_OUT, 0, 0, 0},
FlyPoint::POKECENTER,
{0.316146, 0.623148}
);
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);
}
);

get_on_ride(env.program_info(), env.console, context);

// marker 4. cross bridge 1 x=0.310417, y=0.712963.
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::ZOOM_OUT, 0, 0, 0},
FlyPoint::POKECENTER,
{0.310417, 0.712963}
);
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, 128, 0, 500ms, 0ms);
pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 1000ms);
pbf_move_left_joystick(context, 128, 0, 500ms, 0ms);
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER);
}
);

get_off_ride(env.program_info(), env.console, context);


// marker 5. : x=0.582292, y=0.692593
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::ZOOM_OUT, 0, 0, 0},
FlyPoint::POKECENTER,
{0.582292, 0.692593}
);
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);
}
);

get_on_ride(env.program_info(), env.console, context);

// marker 6. cross bridge 2 : x=0.555208, y=0.627778
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::ZOOM_OUT, 0, 0, 0},
FlyPoint::POKECENTER,
{0.555208, 0.627778}
);
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, 128, 0, 500ms, 0ms);
pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 1000ms);
pbf_move_left_joystick(context, 128, 0, 500ms, 0ms);
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER);
}
);

get_off_ride(env.program_info(), env.console, context);

// marker 7. : x=0.678646, y=0.669444
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::KEEP_ZOOM, 255, 255, 30},
FlyPoint::POKECENTER,
{0.678646, 0.669444}
);
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 8. : x=0.533333, y=0.640741
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
{ZoomChange::KEEP_ZOOM, 255, 255, 50},
FlyPoint::POKECENTER,
{0.533333, 0.640741}
);
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 to pokecenter
realign_player_from_landmark(
env.program_info(), env.console, context,
{ZoomChange::ZOOM_IN, 128, 255, 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, 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 10. 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, 180, 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 move_from_medali_to_glaseado_mountain(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ void checkpoint_reattempt_loop_tutorial(
std::function<void(size_t attempt_number)>&& action
);

// moves player from Porto Marinada Pokecenter to Medali West Pokecenter
void move_from_porto_marinada_to_medali(SingleSwitchProgramEnvironment& env, ProControllerContext& context);

// moves player from Medali West Pokecenter to Glaseado Mountain Pokecenter
void move_from_medali_to_glaseado_mountain(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
Expand Down
Loading