@@ -251,6 +251,52 @@ bool confirm_marker_present(
251251
252252}
253253
254+ void realign_player (const ProgramInfo& info, VideoStream& stream, ProControllerContext& context,
255+ PlayerRealignMode realign_mode,
256+ uint8_t move_x, uint8_t move_y, uint16_t move_duration
257+ ){
258+ stream.log (" Realigning player direction..." );
259+ switch (realign_mode){
260+ case PlayerRealignMode::REALIGN_NEW_MARKER:
261+ stream.log (" Setting new map marker..." );
262+
263+ handle_unexpected_battles (info, stream, context,
264+ [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
265+ open_map_from_overworld (info, stream, context);
266+ });
267+
268+ pbf_press_button (context, BUTTON_ZR, 20 , 105 );
269+ pbf_move_left_joystick (context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND);
270+ pbf_press_button (context, BUTTON_A, 20 , 105 );
271+ pbf_press_button (context, BUTTON_A, 20 , 105 );
272+
273+ handle_unexpected_battles (info, stream, context,
274+ [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
275+ leave_phone_to_overworld (info, stream, context);
276+ });
277+ return ;
278+ case PlayerRealignMode::REALIGN_OLD_MARKER:
279+ handle_unexpected_battles (info, stream, context,
280+ [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
281+ open_map_from_overworld (info, stream, context, false );
282+ });
283+
284+ handle_unexpected_battles (info, stream, context,
285+ [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
286+ leave_phone_to_overworld (info, stream, context);
287+ });
288+
289+ pbf_press_button (context, BUTTON_L, 20 , 105 );
290+ return ;
291+ case PlayerRealignMode::REALIGN_NO_MARKER:
292+ pbf_move_left_joystick (context, move_x, move_y, move_duration, 1 * TICKS_PER_SECOND);
293+ pbf_press_button (context, BUTTON_L, 20 , 105 );
294+ return ;
295+ }
296+
297+ }
298+
299+
254300void overworld_navigation (
255301 const ProgramInfo& info,
256302 VideoStream& stream,
@@ -1090,6 +1136,8 @@ void checkpoint_reattempt_loop(
10901136
10911137 context.wait_for_all_requests ();
10921138 action (i);
1139+
1140+ enter_menu_from_overworld (env.program_info (), env.console , context, -1 );
10931141
10941142 break ;
10951143 }catch (OperationFailedException& e){
@@ -1154,216 +1202,6 @@ void checkpoint_reattempt_loop_tutorial(
11541202
11551203
11561204
1157- void move_from_glaseado_mountain_to_casseroya_watchtower3 (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
1158- context.wait_for_all_requests ();
1159-
1160- DirectionDetector direction;
1161- direction.change_direction (env.program_info (), env.console , context, 1.448679 );
1162-
1163- pbf_move_left_joystick (context, 128 , 0 , 200 , 50 );
1164-
1165-
1166- // marker 1 x=0.548438, y=0.273148
1167- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1168- {ZoomChange::ZOOM_OUT, 0 , 0 , 0 },
1169- FlyPoint::POKECENTER,
1170- {0.548438 , 0.273148 }
1171- );
1172-
1173- get_on_ride (env.program_info (), env.console , context);
1174-
1175- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1176- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1177- overworld_navigation (env.program_info (), env.console , context,
1178- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1179- 128 , 0 , 20 , 10 , false );
1180- },
1181- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1182- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1183- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1184- }
1185- );
1186-
1187- // marker 2. : x=0.693229, y=0.459259
1188- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1189- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 },
1190- FlyPoint::POKECENTER,
1191- {0.693229 , 0.459259 }
1192- );
1193- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1194- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1195- overworld_navigation (env.program_info (), env.console , context,
1196- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1197- 128 , 0 , 20 , 10 , false );
1198- },
1199- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1200- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1201- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1202- }
1203- );
1204-
1205- fly_to_overlapping_flypoint (env.program_info (), env.console , context);
1206-
1207- }
1208-
1209-
1210- void move_from_casseroya_watchtower3_to_dondozo_titan (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
1211- context.wait_for_all_requests ();
1212-
1213- // marker 1 x=0.779167, y=0.274074
1214- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1215- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 },
1216- FlyPoint::POKECENTER,
1217- {0.779167 , 0.274074 }
1218- );
1219-
1220- get_on_ride (env.program_info (), env.console , context);
1221-
1222- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1223- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1224- overworld_navigation (env.program_info (), env.console , context,
1225- NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY,
1226- 128 , 0 , 20 , 10 , false );
1227- },
1228- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1229- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1230- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1231- }
1232- );
1233-
1234- mash_button_till_overworld (env.console , context, BUTTON_A);
1235-
1236- // resume marker 1
1237- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1238- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1239- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1240- overworld_navigation (env.program_info (), env.console , context,
1241- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1242- 128 , 0 , 20 , 10 , false );
1243- },
1244- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1245- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1246- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1247- }
1248- );
1249-
1250- // marker 2. : x=0.76875, y=0.298148
1251- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1252- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 },
1253- FlyPoint::FAST_TRAVEL,
1254- {0.76875 , 0.298148 }
1255- );
1256- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1257- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1258- overworld_navigation (env.program_info (), env.console , context,
1259- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1260- 128 , 0 , 30 , 10 , false );
1261- },
1262- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1263- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1264- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1265- }
1266- );
1267-
1268-
1269- // marker 3. : x=0.752604, y=0.401852
1270- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1271- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 },
1272- FlyPoint::FAST_TRAVEL,
1273- {0.752604 , 0.401852 }
1274- );
1275- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1276- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1277- overworld_navigation (env.program_info (), env.console , context,
1278- NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A,
1279- 128 , 0 , 20 , 10 , false );
1280- },
1281- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1282- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1283- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1284- }
1285- );
1286-
1287- clear_dialog (env.console , context, ClearDialogMode::STOP_BATTLE, 60 , {CallbackEnum::BATTLE});
1288- env.console .log (" Battle Dondozo/Tatsugiri Titan phase 1." );
1289- run_wild_battle_press_A (env.console , context, BattleStopCondition::STOP_OVERWORLD);
1290-
1291-
1292- }
1293-
1294- void move_from_dondozo_titan_phase1_to_phase2 (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
1295- context.wait_for_all_requests ();
1296-
1297- // marker 1 x=0.832292, y=0.54537
1298- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1299- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 },
1300- FlyPoint::FAST_TRAVEL,
1301- {0.832292 , 0.54537 }
1302- );
1303-
1304- get_on_ride (env.program_info (), env.console , context);
1305-
1306- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1307- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1308- overworld_navigation (env.program_info (), env.console , context,
1309- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1310- 128 , 0 , 20 , 10 , false );
1311- },
1312- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1313- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1314- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1315- }
1316- );
1317-
1318- // marker 2 x=0.393229, y=0.748148
1319- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1320- {ZoomChange::ZOOM_IN, 0 , 0 , 0 },
1321- FlyPoint::FAST_TRAVEL,
1322- {0.393229 , 0.748148 }
1323- );
1324- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1325- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1326- overworld_navigation (env.program_info (), env.console , context,
1327- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1328- 128 , 0 , 20 , 10 , false );
1329- },
1330- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1331- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1332- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1333- }
1334- );
1335-
1336-
1337- // marker 3. go to Dondozo/Tatsugiri part 2 x=0.55625, y=0.324074
1338- place_marker_offset_from_flypoint (env.program_info (), env.console , context,
1339- {ZoomChange::KEEP_ZOOM, 0 , 255 , 100 },
1340- FlyPoint::FAST_TRAVEL,
1341- {0.55625 , 0.324074 }
1342- );
1343- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1344- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1345- overworld_navigation (env.program_info (), env.console , context,
1346- NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY,
1347- 128 , 0 , 80 , 40 , false );
1348- },
1349- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1350- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1351- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1352- }
1353- );
1354-
1355- clear_dialog (env.console , context, ClearDialogMode::STOP_BATTLE, 60 , {CallbackEnum::BATTLE});
1356-
1357- env.console .log (" Battle Dondozo/Tatsugiri Titan phase 2." );
1358- run_wild_battle_press_A (env.console , context, BattleStopCondition::STOP_DIALOG);
1359- clear_dialog (env.console , context, ClearDialogMode::STOP_BATTLE, 60 , {CallbackEnum::BATTLE});
1360-
1361- env.console .log (" Battle Dondozo/Tatsugiri Titan phase 3." );
1362- run_wild_battle_press_A (env.console , context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::DIALOG_ARROW});
1363- mash_button_till_overworld (env.console , context, BUTTON_A, 360 );
1364-
1365- }
1366-
13671205void move_from_glaseado_mountain_to_montenevera (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
13681206 context.wait_for_all_requests ();
13691207
@@ -1723,49 +1561,13 @@ void move_from_montenevera_to_glaseado_gym(SingleSwitchProgramEnvironment& env,
17231561
17241562}
17251563
1726- void move_from_glaseado_mountain_to_north_province_area_three (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
1727-
1728- context.wait_for_all_requests ();
1729-
1730- // marker 1. set marker to pokecenter
1731- realign_player_from_landmark (
1732- env.program_info (), env.console , context,
1733- {ZoomChange::KEEP_ZOOM, 128 , 0 , 50 },
1734- {ZoomChange::KEEP_ZOOM, 0 , 0 , 0 }
1735- );
1736- handle_when_stationary_in_overworld (env.program_info (), env.console , context,
1737- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1738- overworld_navigation (env.program_info (), env.console , context,
1739- NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
1740- 128 , 0 , 80 , 10 , false );
1741- },
1742- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1743- pbf_move_left_joystick (context, 255 , 255 , 40 , 50 );
1744- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_OLD_MARKER);
1745- }
1746- );
1747-
1748-
1749- // marker 2. set marker past pokecenter
1750- handle_unexpected_battles (env.program_info (), env.console , context,
1751- [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
1752- realign_player (env.program_info (), env.console , context, PlayerRealignMode::REALIGN_NEW_MARKER, 128 , 0 , 50 );
1753- });
1754- overworld_navigation (env.program_info (), env.console , context,
1755- NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY,
1756- 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
1757-
1758-
1759- fly_to_overlapping_flypoint (env.program_info (), env.console , context);
1760-
1761- }
17621564
17631565
17641566void move_from_glaseado_gym_to_north_province_area_one (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
17651567 context.wait_for_all_requests ();
17661568
17671569 DirectionDetector direction;
1768- handle_unexpected_battles (env.program_info (), env.console , context,
1570+ do_action_and_monitor_for_battles (env.program_info (), env.console , context,
17691571 [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
17701572
17711573 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
18761678
18771679void move_from_north_province_area_one_to_fighting_base (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
18781680 DirectionDetector direction;
1879- handle_unexpected_battles (env.program_info (), env.console , context,
1681+ do_action_and_monitor_for_battles (env.program_info (), env.console , context,
18801682 [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
18811683
18821684 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
23312133 context.wait_for_all_requests ();
23322134 DirectionDetector direction;
23332135
2334- handle_unexpected_battles (env.program_info (), env.console , context,
2136+ do_action_and_monitor_for_battles (env.program_info (), env.console , context,
23352137 [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
23362138 // marker 1
23372139 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
24322234 {0.633333 , 0.304630 }
24332235 );
24342236
2435- handle_unexpected_battles (env.program_info (), env.console , context,
2237+ do_action_and_monitor_for_battles (env.program_info (), env.console , context,
24362238 [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
24372239 // walk towards wall
24382240 direction.change_direction (env.program_info (), env.console , context, 2.949863 );
0 commit comments