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 @@ -110,7 +110,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
segment_list.emplace_back(std::make_unique<AutoStory_Segment_31>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_32>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_33>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_34>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_34>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_35>());

return segment_list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,32 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context,
}


int ret = wait_until(
// int ret = wait_until(
// stream, context,
// std::chrono::seconds(seconds_timeout),
// callbacks
// );

WallClock start_inference = current_time();
int ret = run_until<ProControllerContext>(
stream, context,
std::chrono::seconds(seconds_timeout),
[&](ProControllerContext& context){

if (mode == ClearDialogMode::STOP_TIMEOUT){
context.wait_for(Seconds(seconds_timeout));
}else{ // press A every 8 seconds, until we time out.
auto button_press_period = Seconds(8);
while (true){
if (current_time() - start_inference + button_press_period > Seconds(seconds_timeout)){
break;
}
context.wait_for(button_press_period);
pbf_press_button(context, BUTTON_A, 160ms, 0ms);
}
}
},
callbacks
);
// int ret = run_until<ProControllerContext>(
// console, context,
// [&](ProControllerContext& context){
// for (size_t j = 0; j < seconds_timeout/3; j++){
// pbf_press_button(context, BUTTON_A, 20, 3*TICKS_PER_SECOND-20);
// }
// },
// {overworld, prompt, whitebutton, advance_dialog, battle}
// );
context.wait_for(std::chrono::milliseconds(100));
if (ret < 0){
stream.log("clear_dialog(): Timed out.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,19 @@ void checkpoint_88(SingleSwitchProgramEnvironment& env, ProControllerContext& co
SinglesMoveEntry move4{SinglesMoveType::Move4, false}; // Misty Terrain
std::vector<SinglesMoveEntry> move_table1 = {move1, move4, move1};
bool terastallized = false;
// use Moonblast to KO the Whiscash. Then setup Misty Terrain on the second pokemon, Camerupt.
// Then spam Moonblast to finish off the rest of the team.
// We setup Misty Terrain to prevent getting poisoned by the Donphan's Poison Jab, since it survives with Sturdy.
// Getting poisoned will cause us to fail the Elite Four since we have no easy way to heal off poison.
// We don't setup Misty Terrain on the Whiscash since Muddy Water can lower our accuracy.
bool is_won = run_pokemon(env.console, context, move_table1, true, terastallized);
if (!is_won){// throw exception if we lose
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Failed to beat the Ground trainer. Reset.",
env.console
);
}

// finished battle
mash_button_till_overworld(env.console, context, BUTTON_A);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* From: https://github.com/PokemonAutomation/
*
*/

#include "PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h"

#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonTools/Async/InferenceRoutines.h"
Expand All @@ -29,15 +29,15 @@ namespace PokemonSV{


std::string AutoStory_Segment_34::name() const{
return "35: ";
return "34: Battle Nemona, Penny, Arven";
}

std::string AutoStory_Segment_34::start_text() const{
return "Start: Beat Clavell. Beat Elite Four. At Pokemon League Pokecenter.";
}

std::string AutoStory_Segment_34::end_text() const{
return "End: ";
return "End: Beat Nemona, Penny, and Arven. At Los Platos Pokecenter.";
}

void AutoStory_Segment_34::run_segment(
Expand All @@ -53,7 +53,9 @@ void AutoStory_Segment_34::run_segment(
context.wait_for_all_requests();
env.console.log("Start Segment " + name(), COLOR_ORANGE);

// checkpoint_(env, context, options.notif_status_update, stats);
checkpoint_90(env, context, options.notif_status_update, stats);
checkpoint_91(env, context, options.notif_status_update, stats);
checkpoint_92(env, context, options.notif_status_update, stats);

context.wait_for_all_requests();
env.console.log("End Segment " + name(), COLOR_GREEN);
Expand All @@ -63,12 +65,162 @@ void AutoStory_Segment_34::run_segment(


void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
[&](size_t attempt_number){
// Fly to Academy
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 230, 80}, FlyPoint::FAST_TRAVEL);

realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 255, 100);

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_TIME, NavigationMovementMode::DIRECTIONAL_ONLY,
128, 0, 30, 30, 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);
}
);

clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 120, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW});

env.console.log("Battle Nemona.");
run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);


});
}

void checkpoint_91(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
[&](size_t attempt_number){

// walk down
pbf_move_left_joystick(context, 128, 255, 100, 100);
// walk right towards door
pbf_move_left_joystick(context, 255, 128, 200, 100);

wait_for_gradient_arrow(env.program_info(), env.console, context, {0.031, 0.193, 0.047, 0.078}, 10);

env.console.log("Leave dorm for schoolyard.");
pbf_press_dpad(context, DPAD_UP, 13, 20);
pbf_press_dpad(context, DPAD_LEFT, 13, 20);
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
wait_for_gradient_arrow(env.program_info(), env.console, context, {0.031, 0.790, 0.047, 0.078}, 10);
pbf_mash_button(context, BUTTON_A, 1000ms);

// clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 60, {CallbackEnum::PROMPT_DIALOG});
// pbf_mash_button(context, BUTTON_A, 1000ms);
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW, CallbackEnum::PROMPT_DIALOG});
env.console.log("Battle Penny.");
SinglesMoveEntry move1{SinglesMoveType::Move1, true}; // Moonblast
std::vector<SinglesMoveEntry> move_table1 = {move1};
bool terastallized = false;
bool is_won = run_pokemon(env.console, context, move_table1, true, terastallized);
if (!is_won){// throw exception if we lose
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Failed to beat the Ground trainer. Reset.",
env.console
);
}

mash_button_till_overworld(env.console, context, BUTTON_A);

// now back in dorm room.

// walk right towards door
pbf_move_left_joystick(context, 255, 128, 200, 100);

wait_for_gradient_arrow(env.program_info(), env.console, context, {0.031, 0.193, 0.047, 0.078}, 10);

env.console.log("Leave dorm for Director's office.");
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
pbf_press_dpad(context, DPAD_RIGHT, 13, 20);
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
wait_for_gradient_arrow(env.program_info(), env.console, context, {0.031, 0.345, 0.047, 0.078}, 10);
pbf_mash_button(context, BUTTON_A, 1000ms);

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

walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30);

mash_button_till_overworld(env.console, context, BUTTON_A);

// walk right towards door
pbf_move_left_joystick(context, 255, 128, 200, 100);

wait_for_gradient_arrow(env.program_info(), env.console, context, {0.031, 0.193, 0.047, 0.078}, 10);
mash_button_till_overworld(env.console, context, BUTTON_A);

// now in school lobby

context.wait_for_all_requests();
context.wait_for(1000ms);

pbf_move_left_joystick(context, 128, 255, 1000, 100);
// wait for dialog when leaving school lobby
pbf_wait(context, 3 * TICKS_PER_SECOND);

mash_button_till_overworld(env.console, context, BUTTON_A);

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_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A,
128, 0, 60, 60, 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);
}
);

mash_button_till_overworld(env.console, context, BUTTON_A);

move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 0, 0, 0}, FlyPoint::FAST_TRAVEL);


});
}

void checkpoint_92(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_IN, 145, 255, 350}, FlyPoint::FAST_TRAVEL);
handle_unexpected_battles(env.program_info(), env.console, context,
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
pbf_move_left_joystick(context, 0, 128, 1000ms, 100ms);
});
mash_button_till_overworld(env.console, context, BUTTON_A);
// clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG});

// leave the inside of the lighthouse and go outside
pbf_move_left_joystick(context, 128, 255, 100, 50);
pbf_move_left_joystick(context, 0, 128, 300, 50);
pbf_move_left_joystick(context, 255, 255, 100, 50);

pbf_wait(context, 3 * TICKS_PER_SECOND);
// wait for overworld after building
wait_for_overworld(env.program_info(), env.console, context, 30);

realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 190, 50);
overworld_navigation(env.program_info(), env.console, context,
NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A,
128, 0, 30, 30, false);


clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW, CallbackEnum::PROMPT_DIALOG});
env.console.log("Battle Arven.");
run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);

mash_button_till_overworld(env.console, context, BUTTON_A);

move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}, FlyPoint::POKECENTER);
});
}

void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,42 @@ class AutoStory_Segment_34 : public AutoStory_Segment{
) const override;
};

static constexpr std::string segment_num = "34";


// start:
// end:

inline std::string checkpoint90_start(){ return segment_num + ": Beat Geeta. At Pokemon League Pokecenter.";}
inline std::string checkpoint90_end(){ return segment_num + ": Beat Nemona. At dormitory room, next to bed.";}
// start: Beat Geeta. At Pokemon League Pokecenter.
// end: Beat Nemona. At dormitory room, next to bed.
void checkpoint_90(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);

// start:
// end:
inline std::string checkpoint91_start(){ return checkpoint90_end();}
inline std::string checkpoint91_end(){ return segment_num + ": Beat Penny. At Academy fly point.";}
// start: Beat Nemona. At dormitory room, next to bed."
// end: Beat Penny. At Academy fly point.
void checkpoint_91(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);

// start:
// end:
inline std::string checkpoint92_start(){ return checkpoint91_end();}
inline std::string checkpoint92_end(){ return segment_num + ": Beat Arven. At Los Platos Pokecenter.";}
// start: Beat Penny. At Academy fly point.
// end: Beat Arven. At Los Platos Pokecenter.
void checkpoint_92(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);

// std::string checkpoint_start(){ return segment_num + "";}
// std::string checkpoint_end(){ return segment_num + "";}
// start:
// end:
void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);

// std::string checkpoint_start(){ return segment_num + "";}
// std::string checkpoint_end(){ return segment_num + "";}
// start:
// end:
void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);

// std::string checkpoint_start(){ return segment_num + "";}
// std::string checkpoint_end(){ return segment_num + "";}
// start:
// end:
void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ void run_battle_press_A(

int ret = wait_until(
stream, context,
std::chrono::seconds(90),
std::chrono::seconds(360),
callbacks
);
context.wait_for(std::chrono::milliseconds(100));
Expand Down