Skip to content

Commit ba77395

Browse files
authored
segment 21 (#518)
1 parent cd671ab commit ba77395

File tree

7 files changed

+226
-184
lines changed

7 files changed

+226
-184
lines changed

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
2121
#include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h"
2222
#include "PokemonSV/Inference/Overworld/PokemonSV_OliveDetector.h"
23+
#include "PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h"
2324
#include "PokemonSV_AutoStory_Segment_00.h"
2425
#include "PokemonSV_AutoStory_Segment_01.h"
2526
#include "PokemonSV_AutoStory_Segment_02.h"
@@ -47,9 +48,9 @@
4748
#include "PokemonSV_AutoStory_Segment_24.h"
4849
#include "PokemonSV_AutoStory.h"
4950

50-
// #include <iostream>
51-
// using std::cout;
52-
// using std::endl;
51+
#include <iostream>
52+
using std::cout;
53+
using std::endl;
5354
//#include <unordered_map>
5455
//#include <algorithm>
5556

@@ -85,7 +86,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
8586
segment_list.emplace_back(std::make_unique<AutoStory_Segment_18>());
8687
segment_list.emplace_back(std::make_unique<AutoStory_Segment_19>());
8788
segment_list.emplace_back(std::make_unique<AutoStory_Segment_20>());
88-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_21>());
89+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_21>());
8990
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_22>());
9091
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_23>());
9192
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_24>());
@@ -213,6 +214,7 @@ AutoStory::AutoStory()
213214
)
214215
, MAINSTORY_NOTE{
215216
"Ensure you have a level 100 Gardevoir with the moves in the following order: Moonblast, Dazzling Gleam, Psychic, Mystical Fire.<br>"
217+
"Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames)<br>"
216218
"Refer to the documentation on github for more details."
217219
}
218220
, START_DESCRIPTION(
@@ -620,6 +622,10 @@ void AutoStory::test_checkpoints(
620622
checkpoint_list[checkpoint]();
621623
continue;
622624
}
625+
bool has_minimap = true;
626+
if (checkpoint < 3){
627+
has_minimap = false;
628+
}
623629

624630
const size_t DIGITS = 3;
625631
std::string number = std::to_string(checkpoint);
@@ -629,11 +635,21 @@ void AutoStory::test_checkpoints(
629635
if (checkpoint >= start_loop && checkpoint <= end_loop){
630636
for (int i = 0; i < loop; i++){
631637
if (i > 0){
632-
reset_game(env.program_info(), console, context);
633-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
634-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
635-
env.log("Wait 10 seconds.");
636-
context.wait_for(Milliseconds(10 * 1000));
638+
try {
639+
reset_game(env.program_info(), console, context);
640+
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
641+
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
642+
env.log("Wait 5 seconds.");
643+
context.wait_for(Milliseconds(5 * 1000));
644+
}catch(...){
645+
// try one more time
646+
reset_game(env.program_info(), console, context);
647+
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
648+
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
649+
env.log("Wait 5 seconds.");
650+
context.wait_for(Milliseconds(5 * 1000));
651+
652+
}
637653
}
638654
console.log("checkpoint_" + number + ": loop " + std::to_string(i));
639655
checkpoint_list[checkpoint]();
@@ -740,7 +756,7 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, BotBaseContext& c
740756
// 128, 0, 60, 10, false);
741757

742758
DirectionDetector direction;
743-
759+
744760
return;
745761
}
746762

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -554,157 +554,6 @@ void checkpoint_45(
554554

555555
}
556556

557-
// todo: uncomment checkpoint_save
558-
void checkpoint_46(
559-
SingleSwitchProgramEnvironment& env,
560-
BotBaseContext& context,
561-
EventNotificationOption& notif_status_update
562-
){
563-
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
564-
bool first_attempt = true;
565-
while (true){
566-
try{
567-
if (first_attempt){
568-
// checkpoint_save(env, context, notif_status_update);
569-
first_attempt = false;
570-
}else{
571-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
572-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
573-
env.log("Wait 10 seconds.");
574-
context.wait_for(Milliseconds(10 * 1000));
575-
save_game_from_overworld(env.program_info(), env.console, context);
576-
}
577-
578-
context.wait_for_all_requests();
579-
580-
581-
582-
break;
583-
}catch (...){
584-
context.wait_for_all_requests();
585-
env.console.log("Resetting from checkpoint.");
586-
reset_game(env.program_info(), env.console, context);
587-
stats.m_reset++;
588-
env.update_stats();
589-
}
590-
}
591-
592-
}
593-
594-
595-
// todo: uncomment checkpoint_save
596-
void checkpoint_47(
597-
SingleSwitchProgramEnvironment& env,
598-
BotBaseContext& context,
599-
EventNotificationOption& notif_status_update
600-
){
601-
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
602-
bool first_attempt = true;
603-
while (true){
604-
try{
605-
if (first_attempt){
606-
// checkpoint_save(env, context, notif_status_update);
607-
first_attempt = false;
608-
}else{
609-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
610-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
611-
env.log("Wait 10 seconds.");
612-
context.wait_for(Milliseconds(10 * 1000));
613-
save_game_from_overworld(env.program_info(), env.console, context);
614-
}
615-
616-
context.wait_for_all_requests();
617-
618-
619-
620-
break;
621-
}catch (...){
622-
context.wait_for_all_requests();
623-
env.console.log("Resetting from checkpoint.");
624-
reset_game(env.program_info(), env.console, context);
625-
stats.m_reset++;
626-
env.update_stats();
627-
}
628-
}
629-
630-
}
631-
632-
633-
// todo: uncomment checkpoint_save
634-
void checkpoint_48(
635-
SingleSwitchProgramEnvironment& env,
636-
BotBaseContext& context,
637-
EventNotificationOption& notif_status_update
638-
){
639-
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
640-
bool first_attempt = true;
641-
while (true){
642-
try{
643-
if (first_attempt){
644-
// checkpoint_save(env, context, notif_status_update);
645-
first_attempt = false;
646-
}else{
647-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
648-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
649-
env.log("Wait 10 seconds.");
650-
context.wait_for(Milliseconds(10 * 1000));
651-
save_game_from_overworld(env.program_info(), env.console, context);
652-
}
653-
654-
context.wait_for_all_requests();
655-
656-
657-
658-
break;
659-
}catch (...){
660-
context.wait_for_all_requests();
661-
env.console.log("Resetting from checkpoint.");
662-
reset_game(env.program_info(), env.console, context);
663-
stats.m_reset++;
664-
env.update_stats();
665-
}
666-
}
667-
668-
}
669-
670-
671-
// todo: uncomment checkpoint_save
672-
void checkpoint_49(
673-
SingleSwitchProgramEnvironment& env,
674-
BotBaseContext& context,
675-
EventNotificationOption& notif_status_update
676-
){
677-
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
678-
bool first_attempt = true;
679-
while (true){
680-
try{
681-
if (first_attempt){
682-
// checkpoint_save(env, context, notif_status_update);
683-
first_attempt = false;
684-
}else{
685-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
686-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
687-
env.log("Wait 10 seconds.");
688-
context.wait_for(Milliseconds(10 * 1000));
689-
save_game_from_overworld(env.program_info(), env.console, context);
690-
}
691-
692-
context.wait_for_all_requests();
693-
694-
695-
696-
break;
697-
}catch (...){
698-
context.wait_for_all_requests();
699-
env.console.log("Resetting from checkpoint.");
700-
reset_game(env.program_info(), env.console, context);
701-
stats.m_reset++;
702-
env.update_stats();
703-
}
704-
}
705-
706-
}
707-
708557

709558

710559

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@ void checkpoint_44(SingleSwitchProgramEnvironment& env, BotBaseContext& context,
4444
// end: Defeated Artazon Gym (Grass). Inside gym building.
4545
void checkpoint_45(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
4646

47-
// start: Defeated Artazon Gym (Grass). Inside gym building.
48-
// end:
49-
void checkpoint_46(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
50-
51-
// start:
52-
// end:
53-
void checkpoint_47(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
54-
55-
// start:
56-
// end:
57-
void checkpoint_48(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
58-
59-
// start:
60-
// end:
61-
void checkpoint_49(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
62-
6347

6448

6549
}

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ using namespace Pokemon;
3737

3838

3939
std::string AutoStory_Segment_21::name() const{
40-
return "";
40+
return "17.1: Team Star (Fire): Go to East Province (Area One) Pokecenter";
4141
}
4242

4343
std::string AutoStory_Segment_21::start_text() const{
44-
return "Start: ";
44+
return "Start: Defeated Artazon Gym (Grass). Inside gym building.";
4545
}
4646

4747
std::string AutoStory_Segment_21::end_text() const{
48-
return "End: ";
48+
return "End: At East Province (Area One) Pokecenter.";
4949
}
5050

5151
void AutoStory_Segment_21::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{
@@ -54,7 +54,7 @@ void AutoStory_Segment_21::run_segment(SingleSwitchProgramEnvironment& env, BotB
5454
context.wait_for_all_requests();
5555
env.console.overlay().add_log("Start Segment ", COLOR_ORANGE);
5656

57-
// checkpoint_(env, context, options.notif_status_update);
57+
checkpoint_46(env, context, options.notif_status_update);
5858

5959
context.wait_for_all_requests();
6060
env.console.log("End Segment ", COLOR_GREEN);
@@ -63,6 +63,69 @@ void AutoStory_Segment_21::run_segment(SingleSwitchProgramEnvironment& env, BotB
6363

6464
}
6565

66+
void checkpoint_46(
67+
SingleSwitchProgramEnvironment& env,
68+
BotBaseContext& context,
69+
EventNotificationOption& notif_status_update
70+
){
71+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
72+
bool first_attempt = true;
73+
while (true){
74+
try{
75+
if (first_attempt){
76+
checkpoint_save(env, context, notif_status_update);
77+
first_attempt = false;
78+
}else{
79+
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
80+
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
81+
env.log("Wait 10 seconds.");
82+
context.wait_for(Milliseconds(10 * 1000));
83+
save_game_from_overworld(env.program_info(), env.console, context);
84+
}
85+
86+
context.wait_for_all_requests();
87+
88+
pbf_move_left_joystick(context, 128, 255, 500, 100);
89+
pbf_wait(context, 3 * TICKS_PER_SECOND);
90+
// wait for overworld after leaving Gym
91+
wait_for_overworld(env.program_info(), env.console, context, 30);
92+
93+
// fly to Porto Marinada pokecenter
94+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 255, 128, 50});
95+
96+
// section 1. set marker to pokecenter
97+
realign_player_from_landmark(
98+
env.program_info(), env.console, context,
99+
{ZoomChange::KEEP_ZOOM, 255, 0, 50},
100+
{ZoomChange::ZOOM_IN, 0, 0, 0}
101+
);
102+
overworld_navigation(env.program_info(), env.console, context,
103+
NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY,
104+
128, 0, 80, 20, false);
105+
106+
// section 2. set marker past pokecenter
107+
handle_unexpected_battles(env.program_info(), env.console, context,
108+
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){
109+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 180, 0, 30);
110+
});
111+
overworld_navigation(env.program_info(), env.console, context,
112+
NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY,
113+
128, 15, 12, 12, false);
114+
115+
fly_to_overlapping_flypoint(env.program_info(), env.console, context);
116+
117+
break;
118+
}catch (...){
119+
context.wait_for_all_requests();
120+
env.console.log("Resetting from checkpoint.");
121+
reset_game(env.program_info(), env.console, context);
122+
stats.m_reset++;
123+
env.update_stats();
124+
}
125+
}
126+
127+
}
128+
66129

67130

68131
}

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class AutoStory_Segment_21 : public AutoStory_Segment{
3131
AutoStoryOptions options) const override;
3232
};
3333

34-
34+
// start: Defeated Artazon Gym (Grass). Inside gym building.
35+
// end: At East Province (Area One) Pokecenter.
36+
void checkpoint_46(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
3537

3638

3739
}

0 commit comments

Comments
 (0)