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 @@ -135,7 +135,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
segment_list.emplace_back(std::make_unique<AutoStory_Segment_37>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_38>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_39>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_40>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_40>());
}
return segment_list;
};
Expand Down Expand Up @@ -311,7 +311,7 @@ std::vector<std::unique_ptr<AutoStory_Checkpoint>> make_autoStory_checkpoint_lis
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_101>());
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_102>());
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_103>());
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_104>());
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_104>());
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_105>());

}
Expand Down Expand Up @@ -479,8 +479,9 @@ AutoStory::AutoStory()
}
, MAINSTORY_NOTE{
"Ensure you have a level 100 Gardevoir with the moves in the following order: Moonblast, Mystical Fire, Psychic, Misty Terrain."
"Ensure PP is maxed out. Ensure Modest nature with max Special Attack and Speed EVs, with max IVs.<br>"
"Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames)<br>"
"Ensure PP is maxed out (Moonblast should have 24 PP). Ensure Modest nature with max Special Attack and Speed EVs, with max IVs. "
"After vitamins, mint and hypertraining, the stats should be as follows: HP 277, Attack [doesn't matter], Defense 167, Speed 259, Sp. Def 266, Sp. Atk 383.<br>"
"Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames), ideally with a strong first move (e.g. Acrobatics for Talonflame).<br>"
"Refer to the documentation on github for more details."
}
, START_DESCRIPTION(
Expand Down Expand Up @@ -1053,7 +1054,7 @@ void AutoStory::test_checkpoints(
checkpoint_list.push_back([&](){checkpoint_101(env, context, notif_status_update, stats);});
checkpoint_list.push_back([&](){checkpoint_102(env, context, notif_status_update, stats);});
checkpoint_list.push_back([&](){checkpoint_103(env, context, notif_status_update, stats);});
// checkpoint_list.push_back([&](){checkpoint_104(env, context, notif_status_update, stats);});
checkpoint_list.push_back([&](){checkpoint_104(env, context, notif_status_update, stats);});
// checkpoint_list.push_back([&](){checkpoint_105(env, context, notif_status_update, stats);});


Expand Down Expand Up @@ -1303,7 +1304,7 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont
// move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444);
// move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688);



return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ void clear_tutorial(VideoStream& stream, ProControllerContext& context, uint16_t

void clear_dialog(VideoStream& stream, ProControllerContext& context,
ClearDialogMode mode, uint16_t seconds_timeout,
std::vector<CallbackEnum> enum_optional_callbacks
std::vector<CallbackEnum> enum_optional_callbacks,
bool press_A
){
bool seen_dialog = false;
WallClock start = current_time();
Expand Down Expand Up @@ -148,12 +149,12 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context,
stream, context,
[&](ProControllerContext& context){

if (mode == ClearDialogMode::STOP_TIMEOUT){
if (mode == ClearDialogMode::STOP_TIMEOUT || !press_A){
context.wait_for(Seconds(seconds_timeout));
}else{ // press A every 8 seconds, until we time out.
auto button_press_period = Seconds(8);
}else{ // press A every 25 seconds, until we time out.
auto button_press_period = Seconds(25);
while (true){
if (current_time() - start_inference + button_press_period > Seconds(seconds_timeout)){
if (current_time() - start_inference > Seconds(seconds_timeout)){
break;
}
context.wait_for(button_press_period);
Expand Down Expand Up @@ -208,6 +209,9 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context,
case CallbackEnum::DIALOG_ARROW:
stream.log("clear_dialog: Detected dialog arrow.");
seen_dialog = true;
if (mode == ClearDialogMode::STOP_BATTLE_DIALOG_ARROW){
return;
}
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case CallbackEnum::BATTLE:
Expand Down Expand Up @@ -358,9 +362,9 @@ void overworld_navigation(
if (movement_mode == NavigationMovementMode::CLEAR_WITH_LETS_GO){
walk_forward_while_clear_front_path(info, stream, context, forward_ticks, y);
}else{
ssf_press_left_joystick(context, x, y, 0, seconds_realign * TICKS_PER_SECOND);
ssf_press_left_joystick(context, x, y, 0ms, Seconds(seconds_realign));
if (movement_mode == NavigationMovementMode::DIRECTIONAL_ONLY){
pbf_wait(context, seconds_realign * TICKS_PER_SECOND);
pbf_wait(context, Seconds(seconds_realign));
} else if (movement_mode == NavigationMovementMode::DIRECTIONAL_SPAM_A){
for (size_t j = 0; j < 5 * seconds_realign; j++){
pbf_press_button(context, BUTTON_A, 20, 5);
Expand Down Expand Up @@ -1059,9 +1063,9 @@ void press_A_until_dialog(
int ret = run_until<ProControllerContext>(
stream, context,
[seconds_between_button_presses](ProControllerContext& context){
pbf_wait(context, seconds_between_button_presses * TICKS_PER_SECOND); // avoiding pressing A if dialog already present
pbf_wait(context, Seconds(seconds_between_button_presses)); // avoiding pressing A if dialog already present
for (size_t c = 0; c < 10; c++){
pbf_press_button(context, BUTTON_A, 20, seconds_between_button_presses * TICKS_PER_SECOND);
pbf_press_button(context, BUTTON_A, 20*8ms, Seconds(seconds_between_button_presses));
}
},
{advance_dialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum class ClearDialogMode{
STOP_TIMEOUT,
STOP_BATTLE,
STOP_TUTORIAL,
STOP_BATTLE_DIALOG_ARROW,
};


Expand Down Expand Up @@ -123,9 +124,11 @@ void clear_tutorial(VideoStream& stream, ProControllerContext& context, uint16_t
// stop depending on ClearDialogMode: stop when detect overworld, or dialog prompt, or A button prompt. Or if times out
// throw exception if times out, unless this is the intended stop condition.
// also throw exception if dialog is never detected.
// NOTE: seconds_timeout is rounded up to a multiple of 25, unless press_A is false or ClearDialogMode == STOP_TIMEOUT
void clear_dialog(VideoStream& stream, ProControllerContext& context,
ClearDialogMode mode, uint16_t seconds_timeout = 60,
std::vector<CallbackEnum> optional_callbacks = {}
ClearDialogMode mode, uint16_t seconds_timeout = 75,
std::vector<CallbackEnum> optional_callbacks = {},
bool press_A = true
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ void checkpoint_18(
pbf_mash_button(context, BUTTON_A, 6 * TICKS_PER_SECOND);

env.console.log("Talk to Clavell in his office, and the professor.");
// clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 25,
// {CallbackEnum::PROMPT_DIALOG}); // max time between dialog: 17s. set timeout to 25 seconds for buffer.
// // mash A to get through the Random A press that you need. when the professor shows you area zero.
// pbf_mash_button(context, BUTTON_A, 3 * TICKS_PER_SECOND);
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 25,
{CallbackEnum::PROMPT_DIALOG}); // max time between dialog: 17s. set timeout to 25 seconds for buffer.
// mash A to get through the Random A press that you need. when the professor shows you area zero.
pbf_mash_button(context, BUTTON_A, 3 * TICKS_PER_SECOND);

clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60,
{CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG});
Expand Down Expand Up @@ -280,11 +280,11 @@ void checkpoint_20(
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60, 128, 0);

env.console.log("Talk to Nemona, Arven, Cassiopeia.");
// clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 16,
// {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX}); // max time between dialog: 11
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 16,
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX}); // max time between dialog: 11

// // mash A to get through the Random A press that you need. when the Nemona shows you a Poke Gym.
// pbf_mash_button(context, BUTTON_A, 250);
// mash A to get through the Random A press that you need. when the Nemona shows you a Poke Gym.
pbf_mash_button(context, BUTTON_A, 250);

clear_dialog(env.console, context, ClearDialogMode::STOP_TUTORIAL, 20,
{CallbackEnum::TUTORIAL, CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
*/

#include "CommonFramework/VideoPipeline/VideoFeed.h"

#include "CommonTools/Async/InferenceRoutines.h"
#include "NintendoSwitch/NintendoSwitch_Settings.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
Expand Down Expand Up @@ -113,6 +115,13 @@ void checkpoint_24(
[&](size_t attempt_number){
context.wait_for_all_requests();
DirectionDetector direction;
VideoSnapshot snapshot = env.console.video().snapshot();
double current_direction = direction.get_current_direction(env.console, snapshot);
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
}

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, 2.71);
Expand Down Expand Up @@ -188,6 +197,8 @@ void checkpoint_25(

// section 3
DirectionDetector direction;
// we just hope the minimap Direction isn't covered

direction.change_direction(env.program_info(), env.console, context, 6.0);
pbf_move_left_joystick(context, 128, 0, 700, 100);

Expand Down Expand Up @@ -292,6 +303,8 @@ void checkpoint_26(

// section 1b. realign using fence corner
DirectionDetector direction;
// we just hope the minimap Direction isn't covered

direction.change_direction(env.program_info(), env.console, context, 2.74);
pbf_move_left_joystick(context, 128, 0, 200, 50);
direction.change_direction(env.program_info(), env.console, context, 4.328);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
*/

#include "CommonFramework/VideoPipeline/VideoFeed.h"

#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "CommonTools/Async/InferenceRoutines.h"
Expand Down Expand Up @@ -83,6 +85,13 @@ void checkpoint_28(
[&](size_t attempt_number){
context.wait_for_all_requests();
DirectionDetector direction;
VideoSnapshot snapshot = env.console.video().snapshot();
double current_direction = direction.get_current_direction(env.console, snapshot);
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
}

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, 2.71);
Expand Down
Loading