Skip to content

Commit 2b417ec

Browse files
jw098fyex
authored andcommitted
segments 05 to 07 (PokemonAutomation#496)
1 parent 185ebd6 commit 2b417ec

9 files changed

+580
-11
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,13 @@ file(GLOB MAIN_SOURCES
14371437
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp
14381438
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h
14391439
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp
1440-
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h
1440+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h
1441+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp
1442+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h
1443+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp
1444+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h
1445+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp
1446+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h
14411447
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
14421448
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
14431449
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ SOURCES += \
718718
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp \
719719
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp \
720720
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp \
721+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp \
722+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp \
723+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \
721724
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
722725
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \
723726
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
@@ -1812,6 +1815,9 @@ HEADERS += \
18121815
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h \
18131816
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h \
18141817
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h \
1818+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h \
1819+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h \
1820+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \
18151821
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
18161822
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \
18171823
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "PokemonSV_AutoStory_Segment_02.h"
2121
#include "PokemonSV_AutoStory_Segment_03.h"
2222
#include "PokemonSV_AutoStory_Segment_04.h"
23-
// #include "PokemonSV_AutoStory_Segment_05.h"
24-
// #include "PokemonSV_AutoStory_Segment_06.h"
25-
// #include "PokemonSV_AutoStory_Segment_07.h"
23+
#include "PokemonSV_AutoStory_Segment_05.h"
24+
#include "PokemonSV_AutoStory_Segment_06.h"
25+
#include "PokemonSV_AutoStory_Segment_07.h"
2626
// #include "PokemonSV_AutoStory_Segment_08.h"
2727
// #include "PokemonSV_AutoStory_Segment_09.h"
2828
// #include "PokemonSV_AutoStory_Segment_10.h"
@@ -53,9 +53,9 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
5353
segment_list.emplace_back(std::make_unique<AutoStory_Segment_02>());
5454
segment_list.emplace_back(std::make_unique<AutoStory_Segment_03>());
5555
segment_list.emplace_back(std::make_unique<AutoStory_Segment_04>());
56-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_05>());
57-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_06>());
58-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_07>());
56+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_05>());
57+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_06>());
58+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_07>());
5959
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_08>());
6060
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_09>());
6161
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_10>());
@@ -466,10 +466,10 @@ void AutoStory::test_checkpoints(
466466
checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update);});
467467
checkpoint_list.push_back([&](){checkpoint_07(env, context, notif_status_update);});
468468
checkpoint_list.push_back([&](){checkpoint_08(env, context, notif_status_update);});
469-
// checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update);});
470-
// checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);});
471-
// checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);});
472-
// checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);});
469+
checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update);});
470+
checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);});
471+
checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);});
472+
checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);});
473473
// checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);});
474474
// checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);});
475475
// checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);});
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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_05.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_05::name() const{
39+
return "05: First Arven Battle";
40+
}
41+
42+
std::string AutoStory_Segment_05::start_text() const{
43+
return "Start: Saved the Legendary. Escaped from the Houndoom cave.";
44+
}
45+
46+
std::string AutoStory_Segment_05::end_text() const{
47+
return "End: Battled Arven, received Legendary's Pokeball. Talked to Nemona at Lighthouse.";
48+
}
49+
50+
void AutoStory_Segment_05::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 05: First Arven Battle", COLOR_ORANGE);
55+
env.console.overlay().add_log("Start Segment 05: First Arven Battle", COLOR_ORANGE);
56+
57+
checkpoint_09(env, context, options.notif_status_update);
58+
checkpoint_10(env, context, options.notif_status_update);
59+
60+
context.wait_for_all_requests();
61+
env.console.log("End Segment 05: First Arven Battle", COLOR_GREEN);
62+
env.console.overlay().add_log("End Segment 05: First Arven Battle", COLOR_GREEN);
63+
stats.m_segment++;
64+
env.update_stats();
65+
66+
}
67+
68+
69+
void checkpoint_09(
70+
SingleSwitchProgramEnvironment& env,
71+
BotBaseContext& context,
72+
EventNotificationOption& notif_status_update
73+
){
74+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
75+
bool first_attempt = true;
76+
while (true){
77+
try{
78+
if (first_attempt){
79+
checkpoint_save(env, context, notif_status_update);
80+
first_attempt = false;
81+
}
82+
context.wait_for_all_requests();
83+
84+
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 120, 100);
85+
env.console.log("overworld_navigation: Go to Arven at the tower.");
86+
overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, true, true);
87+
88+
context.wait_for_all_requests();
89+
env.console.log("Found Arven");
90+
env.console.overlay().add_log("Found Arven", COLOR_WHITE);
91+
// can lose battle, and story will still continue
92+
mash_button_till_overworld(env.console, context, BUTTON_A);
93+
context.wait_for_all_requests();
94+
env.console.log("Receive legendary ball");
95+
env.console.overlay().add_log("Receive legendary ball", COLOR_WHITE);
96+
97+
break;
98+
}catch(...){
99+
context.wait_for_all_requests();
100+
env.console.log("Resetting from checkpoint.");
101+
reset_game(env.program_info(), env.console, context);
102+
stats.m_reset++;
103+
env.update_stats();
104+
}
105+
}
106+
}
107+
108+
void checkpoint_10(
109+
SingleSwitchProgramEnvironment& env,
110+
BotBaseContext& context,
111+
EventNotificationOption& notif_status_update
112+
){
113+
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
114+
bool first_attempt = true;
115+
while (true){
116+
try{
117+
if (first_attempt){
118+
checkpoint_save(env, context, notif_status_update);
119+
first_attempt = false;
120+
}
121+
context.wait_for_all_requests();
122+
env.console.log("Lighthouse view");
123+
env.console.overlay().add_log("Lighthouse view", COLOR_WHITE);
124+
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
125+
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){
126+
realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 110, 100);
127+
pbf_move_left_joystick(context, 128, 0, 6 * TICKS_PER_SECOND, 8 * TICKS_PER_SECOND);
128+
pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 20);
129+
pbf_move_left_joystick(context, 255, 128, 15, 20);
130+
pbf_press_button(context, BUTTON_L, 20, 20);
131+
pbf_move_left_joystick(context, 128, 0, 7 * TICKS_PER_SECOND, 20);
132+
}
133+
);
134+
135+
env.console.log("overworld_navigation: Go to Nemona on the lighthouse.");
136+
overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 20, true, true);
137+
138+
mash_button_till_overworld(env.console, context, BUTTON_A);
139+
140+
break;
141+
}catch(...){
142+
context.wait_for_all_requests();
143+
env.console.log("Resetting from checkpoint.");
144+
reset_game(env.program_info(), env.console, context);
145+
stats.m_reset++;
146+
env.update_stats();
147+
}
148+
}
149+
}
150+
151+
152+
153+
154+
}
155+
}
156+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Autostory
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_05_H
8+
#define PokemonAutomation_PokemonSV_AutoStory_Segment_05_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_05 : 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+
35+
// start: Rescued Koraidon/Miraidon and escaped from the Houndoom Cave.
36+
// end: Battled Arven and received Legendary's Pokeball.
37+
void checkpoint_09(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
38+
39+
// start: Battled Arven and received Legendary's Pokeball.
40+
// end: Talked to Nemona at the Lighthouse.
41+
void checkpoint_10(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);
42+
43+
}
44+
}
45+
}
46+
#endif

0 commit comments

Comments
 (0)