Skip to content

Commit b076742

Browse files
jw098fyex
authored andcommitted
segments 8 to 9 (PokemonAutomation#498)
1 parent 2037acb commit b076742

File tree

7 files changed

+686
-15
lines changed

7 files changed

+686
-15
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,11 @@ file(GLOB MAIN_SOURCES
14491449
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp
14501450
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h
14511451
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp
1452-
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h
1452+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h
1453+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp
1454+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h
1455+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp
1456+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h
14531457
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
14541458
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
14551459
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,9 @@ SOURCES += \
723723
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp \
724724
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp \
725725
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp \
726-
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \
726+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \
727+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp \
728+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp \
727729
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
728730
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \
729731
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
@@ -1823,7 +1825,9 @@ HEADERS += \
18231825
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h \
18241826
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h \
18251827
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h \
1826-
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \
1828+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \
1829+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h \
1830+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h \
18271831
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
18281832
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \
18291833
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include "PokemonSV_AutoStory_Segment_05.h"
2424
#include "PokemonSV_AutoStory_Segment_06.h"
2525
#include "PokemonSV_AutoStory_Segment_07.h"
26-
// #include "PokemonSV_AutoStory_Segment_08.h"
27-
// #include "PokemonSV_AutoStory_Segment_09.h"
26+
#include "PokemonSV_AutoStory_Segment_08.h"
27+
#include "PokemonSV_AutoStory_Segment_09.h"
2828
// #include "PokemonSV_AutoStory_Segment_10.h"
2929
// #include "PokemonSV_AutoStory_Segment_11.h"
3030
// #include "PokemonSV_AutoStory_Segment_12.h"
@@ -56,8 +56,8 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
5656
segment_list.emplace_back(std::make_unique<AutoStory_Segment_05>());
5757
segment_list.emplace_back(std::make_unique<AutoStory_Segment_06>());
5858
segment_list.emplace_back(std::make_unique<AutoStory_Segment_07>());
59-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_08>());
60-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_09>());
59+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_08>());
60+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_09>());
6161
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_10>());
6262
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_11>());
6363
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_12>());
@@ -470,14 +470,14 @@ void AutoStory::test_checkpoints(
470470
checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);});
471471
checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);});
472472
checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);});
473-
// checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);});
474-
// checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);});
475-
// checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);});
476-
// checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update);});
477-
// checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update);});
478-
// checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);});
479-
// checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);});
480-
// checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);});
473+
checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);});
474+
checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);});
475+
checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);});
476+
checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update);});
477+
checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update);});
478+
checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);});
479+
checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);});
480+
checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);});
481481
// checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update);});
482482
// checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update);});
483483
// checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update);});
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
/* AutoStory
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "CommonFramework/GlobalSettingsPanel.h"
8+
#include "CommonFramework/Exceptions/FatalProgramException.h"
9+
#include "CommonFramework/Exceptions/OperationFailedException.h"
10+
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
11+
#include "CommonFramework/Notifications/ProgramNotifications.h"
12+
#include "CommonFramework/Tools/StatsTracking.h"
13+
#include "CommonFramework/Tools/VideoResolutionCheck.h"
14+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15+
#include "Pokemon/Pokemon_Strings.h"
16+
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
17+
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
18+
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
19+
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
20+
#include "PokemonSV_AutoStoryTools.h"
21+
#include "PokemonSV_AutoStory_Segment_08.h"
22+
23+
//#include <iostream>
24+
//using std::cout;
25+
//using std::endl;
26+
//#include <unordered_map>
27+
//#include <algorithm>
28+
29+
namespace PokemonAutomation{
30+
namespace NintendoSwitch{
31+
namespace PokemonSV{
32+
33+
using namespace Pokemon;
34+
35+
36+
37+
38+
std::string AutoStory_Segment_08::name() const{
39+
return "08: Beat Team Star and arrive at School";
40+
}
41+
42+
std::string AutoStory_Segment_08::start_text() const{
43+
return "Start: At Mesagoza South Pokecenter.";
44+
}
45+
46+
std::string AutoStory_Segment_08::end_text() const{
47+
return "End: Battled Team Star, talked to Jacq, standing in classroom.";
48+
}
49+
50+
void AutoStory_Segment_08::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{
51+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
52+
53+
context.wait_for_all_requests();
54+
env.console.log("Start Segment 08: Beat Team Star and arrive at School", COLOR_ORANGE);
55+
56+
checkpoint_13(env, context, options.notif_status_update);
57+
checkpoint_14(env, context, options.notif_status_update);
58+
checkpoint_15(env, context, options.notif_status_update);
59+
60+
61+
context.wait_for_all_requests();
62+
env.console.log("End Segment 08: Beat Team Star and arrive at School", COLOR_GREEN);
63+
stats.m_segment++;
64+
env.update_stats();
65+
66+
}
67+
68+
69+
void checkpoint_13(
70+
SingleSwitchProgramEnvironment& env,
71+
BotBaseContext& context,
72+
EventNotificationOption& notif_status_update
73+
){
74+
// reset rate: 0%. 0 resets out of 70.
75+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
76+
bool first_attempt = true;
77+
while (true){
78+
try{
79+
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
80+
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){
81+
82+
if (first_attempt){
83+
checkpoint_save(env, context, notif_status_update);
84+
first_attempt = false;
85+
}
86+
87+
fly_to_overlapping_flypoint(info, env.console, context);
88+
89+
context.wait_for_all_requests();
90+
realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 80, 50);
91+
walk_forward_while_clear_front_path(info, env.console, context, 500);
92+
walk_forward_until_dialog(info, env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30);
93+
});
94+
95+
env.console.log("clear_dialog: Talk with Nemona at Mesagoza gate. Stop when detect battle.");
96+
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60,
97+
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW, CallbackEnum::BATTLE});
98+
99+
env.console.log("run_battle_press_A: Battle with Nemona at Mesagoza gate. Stop when detect dialog.");
100+
// story continues even if you lose
101+
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);
102+
103+
env.console.log("clear_dialog: Talk with Nemona within Mesagoza. Stop when detect overworld.");
104+
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60,
105+
{CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG, CallbackEnum::WHITE_A_BUTTON});
106+
107+
108+
break;
109+
}catch(...){
110+
context.wait_for_all_requests();
111+
env.console.log("Resetting from checkpoint.");
112+
reset_game(env.program_info(), env.console, context);
113+
stats.m_reset++;
114+
env.update_stats();
115+
}
116+
}
117+
118+
}
119+
120+
void checkpoint_14(
121+
SingleSwitchProgramEnvironment& env,
122+
BotBaseContext& context,
123+
EventNotificationOption& notif_status_update
124+
){
125+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
126+
bool first_attempt = true;
127+
while (true){
128+
try{
129+
if (first_attempt){
130+
checkpoint_save(env, context, notif_status_update);
131+
first_attempt = false;
132+
}
133+
context.wait_for_all_requests();
134+
// realign diagonally to the left
135+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 80, 0, 100);
136+
// walk forward so you're off center
137+
pbf_move_left_joystick(context, 128, 0, 100, 100);
138+
// realign going straight
139+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
140+
// walk forward, while still off center
141+
pbf_move_left_joystick(context, 128, 0, 2000, 100);
142+
// realign diagonally to the right
143+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 178, 0, 100);
144+
// walk forward so you're closer to the center
145+
pbf_move_left_joystick(context, 128, 0, 150, 100);
146+
// realign going straight
147+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
148+
// walk forward until hit dialog at top of stairs
149+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60);
150+
// clear dialog until battle. with prompt, battle
151+
env.console.log("clear_dialog: Talk with Team Star at the top of the stairs. Stop when detect battle.");
152+
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW});
153+
// run battle until dialog
154+
env.console.log("run_battle_press_A: Battle with Team Star grunt 1. Stop when detect dialog.");
155+
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {}, true);
156+
// clear dialog until battle, with prompt, white button, tutorial, battle
157+
env.console.log("clear_dialog: Talk with Team Star and Nemona. Receive Tera orb. Stop when detect battle.");
158+
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60,
159+
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::WHITE_A_BUTTON, CallbackEnum::TUTORIAL, CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW});
160+
// run battle until dialog
161+
env.console.log("run_battle_press_A: Battle with Team Star grunt 2. Stop when detect dialog.");
162+
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {}, true);
163+
// clear dialog until overworld
164+
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD});
165+
166+
break;
167+
}catch(...){
168+
context.wait_for_all_requests();
169+
env.console.log("Resetting from checkpoint.");
170+
reset_game(env.program_info(), env.console, context);
171+
stats.m_reset++;
172+
env.update_stats();
173+
}
174+
}
175+
176+
}
177+
178+
void checkpoint_15(
179+
SingleSwitchProgramEnvironment& env,
180+
BotBaseContext& context,
181+
EventNotificationOption& notif_status_update
182+
){
183+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
184+
bool first_attempt = true;
185+
while (true){
186+
try{
187+
if (first_attempt){
188+
checkpoint_save(env, context, notif_status_update);
189+
first_attempt = false;
190+
}
191+
context.wait_for_all_requests();
192+
// realign diagonally to the right
193+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 178, 0, 100);
194+
// walk forward so you're closer to the center
195+
pbf_move_left_joystick(context, 128, 0, 100, 100);
196+
// realign going straight
197+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
198+
// walk forward up stairs
199+
pbf_move_left_joystick(context, 128, 0, 1000, 100);
200+
// realign going straight
201+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER);
202+
// walk forward until hit dialog inside the school
203+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60);
204+
205+
env.console.log("clear_dialog: Talk with Nemona, Clavell, and Jacq inside the school. Stop when detect overworld.");
206+
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60,
207+
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::OVERWORLD});
208+
209+
break;
210+
}catch(...){
211+
context.wait_for_all_requests();
212+
env.console.log("Resetting from checkpoint.");
213+
reset_game(env.program_info(), env.console, context);
214+
stats.m_reset++;
215+
env.update_stats();
216+
}
217+
}
218+
219+
}
220+
221+
222+
223+
}
224+
}
225+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Autostory
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_08_H
8+
#define PokemonAutomation_PokemonSV_AutoStory_Segment_08_H
9+
10+
#include <functional>
11+
#include "Common/Cpp/Options/EnumDropdownOption.h"
12+
#include "CommonFramework/Notifications/EventNotificationsTable.h"
13+
#include "CommonFramework/Options/LanguageOCROption.h"
14+
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
15+
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
16+
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
17+
#include "PokemonSV_AutoStoryTools.h"
18+
19+
namespace PokemonAutomation{
20+
namespace NintendoSwitch{
21+
namespace PokemonSV{
22+
23+
class AutoStory_Segment_08 : public AutoStory_Segment{
24+
public:
25+
virtual std::string name() const override;
26+
virtual std::string start_text() const override;
27+
virtual std::string end_text() const override;
28+
virtual void run_segment(
29+
SingleSwitchProgramEnvironment& env,
30+
BotBaseContext& context,
31+
AutoStoryOptions options) const override;
32+
};
33+
34+
// start: Arrived at Mesagoza (South) Pokecenter
35+
// end: Battled Nemona at Mesagoza gate. Entered Mesagoza.
36+
void checkpoint_13(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
37+
38+
// start: Battled Nemona at Mesagoza gate. Entered Mesagoza.
39+
// end: Battled Team Star at school entrance.
40+
void checkpoint_14(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
41+
42+
// start: Battled Team Star at school entrance.
43+
// end: Talked to Jacq in classroom. Standing in classroom.
44+
void checkpoint_15(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
45+
46+
47+
48+
}
49+
}
50+
}
51+
#endif

0 commit comments

Comments
 (0)