Skip to content

Commit 765f62e

Browse files
committed
create files for legendary reset emerald
1 parent 1bfd14e commit 765f62e

File tree

4 files changed

+246
-0
lines changed

4 files changed

+246
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,8 @@ file(GLOB MAIN_SOURCES
13391339
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.h
13401340
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.cpp
13411341
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h
1342+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.cpp
1343+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.h
13421344
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.cpp
13431345
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h
13441346
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.cpp

SerialPrograms/Source/PokemonRSE/PokemonRSE_Panels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "PokemonRSE_Settings.h"
1212

1313
#include "Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h"
14+
#include "Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.h"
1415
#include "Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h"
1516

1617
#include "Programs/ShinyHunting/PokemonRSE_StarterReset.h"
@@ -38,6 +39,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
3839
ret.emplace_back(make_single_switch_program<AudioStarterReset_Descriptor, AudioStarterReset>());
3940

4041
ret.emplace_back("---- Shiny Hunting (Emerald) ----");
42+
ret.emplace_back(make_single_switch_program<LegendaryHuntEmerald_Descriptor, LegendaryHuntEmerald>());
4143
ret.emplace_back(make_single_switch_program<ShinyHuntDeoxys_Descriptor, ShinyHuntDeoxys>());
4244

4345

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/* Legendary Hunt - Emerald
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Common/Cpp/PrettyPrint.h"
8+
#include "CommonFramework/Exceptions/OperationFailedException.h"
9+
#include "CommonTools/Async/InferenceRoutines.h"
10+
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
11+
#include "CommonFramework/Notifications/ProgramNotifications.h"
12+
#include "CommonFramework/ProgramStats/StatsTracking.h"
13+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
14+
#include "Pokemon/Pokemon_Strings.h"
15+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
16+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
17+
#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
18+
#include "PokemonRSE/PokemonRSE_Navigation.h"
19+
#include "PokemonRSE_LegendaryHunt-Emerald.h"
20+
21+
namespace PokemonAutomation{
22+
namespace NintendoSwitch{
23+
namespace PokemonRSE{
24+
25+
LegendaryHuntEmerald_Descriptor::LegendaryHuntEmerald_Descriptor()
26+
: SingleSwitchProgramDescriptor(
27+
"PokemonRSE:LegendaryHuntEmerald",
28+
Pokemon::STRING_POKEMON + " RSE", "Legendary Hunt (Emerald)",
29+
"ComputerControl/blob/master/Wiki/Programs/PokemonRSE/LegendaryHuntEmerald.md",
30+
"Use the Run Away method to shiny hunt legendaries in Emerald.",
31+
FeedbackType::VIDEO_AUDIO,
32+
AllowCommandsWhenRunning::DISABLE_COMMANDS,
33+
{SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS}
34+
)
35+
{}
36+
37+
struct LegendaryHuntEmerald_Descriptor::Stats : public StatsTracker{
38+
Stats()
39+
: resets(m_stats["Resets"])
40+
, shinies(m_stats["Shinies"])
41+
{
42+
m_display_order.emplace_back("Resets");
43+
m_display_order.emplace_back("Shinies");
44+
}
45+
std::atomic<uint64_t>& resets;
46+
std::atomic<uint64_t>& shinies;
47+
};
48+
std::unique_ptr<StatsTracker> LegendaryHuntEmerald_Descriptor::make_stats() const{
49+
return std::unique_ptr<StatsTracker>(new Stats());
50+
}
51+
52+
LegendaryHuntEmerald::LegendaryHuntEmerald()
53+
: TARGET(
54+
"<b>Starter:</b><br>",
55+
{
56+
{Target::regis, "regis", "Regirock/Regice/Registeel"},
57+
{Target::hooh, "hooh", "Ho-Oh"},
58+
{Target::lugia, "lugia", "Lugia"},
59+
{Target::latis, "latis", "Latias/Latios (Southern Island)"},
60+
},
61+
LockMode::LOCK_WHILE_RUNNING,
62+
Target::hooh
63+
)
64+
, NOTIFICATION_SHINY(
65+
"Shiny Found",
66+
true, true, ImageAttachmentMode::JPG,
67+
{"Notifs", "Showcase"}
68+
)
69+
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
70+
, NOTIFICATIONS({
71+
&NOTIFICATION_SHINY,
72+
&NOTIFICATION_STATUS_UPDATE,
73+
&NOTIFICATION_PROGRAM_FINISH,
74+
})
75+
{
76+
PA_ADD_OPTION(TARGET);
77+
PA_ADD_OPTION(NOTIFICATIONS);
78+
}
79+
80+
void LegendaryHuntEmerald::reset_room(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) {
81+
switch (TARGET) {
82+
case Target::regis:
83+
//turn around, walk down 4
84+
85+
//black screen over
86+
87+
//turn around, up one
88+
89+
//black screen over
90+
91+
//reverse the above
92+
93+
break;
94+
case Target::hooh:
95+
//Turn around
96+
97+
//10 steps down
98+
99+
//Turn right
100+
101+
//Take one step
102+
103+
//Wait for black screen over
104+
105+
//Turn left and take a step
106+
107+
//now turn right and take a step
108+
109+
//wait for black screen over
110+
111+
//now reverse the above, but only take 9 steps up
112+
break;
113+
case Target::lugia:
114+
//Turn around
115+
116+
//5 steps down
117+
118+
//Turn right
119+
120+
//3 steps right
121+
122+
123+
//Wait for black screen over
124+
125+
//turn up, take one step
126+
127+
//now turn back down and take a step
128+
129+
//wait for black screen over
130+
131+
//reverse above steps
132+
break;
133+
case Target::latis:
134+
135+
break;
136+
default:
137+
break;
138+
}
139+
context.wait_for_all_requests();
140+
}
141+
142+
void LegendaryHuntEmerald::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
143+
LegendaryHuntEmerald_Descriptor::Stats& stats = env.current_stats<LegendaryHuntEmerald_Descriptor::Stats>();
144+
145+
/*
146+
* Text speed fast, battle animations off
147+
* smoke ball or fast pokemon req.
148+
*
149+
* Don't need to worry about PokeNav or random encounters for any of these targets.
150+
*
151+
* Stand in front of Regis/Ho-Oh/Lugia. Save the game.
152+
*/
153+
154+
while (true) {
155+
//Start battle.
156+
if (TARGET == Target::hooh) {
157+
//Step forward to start the encounter.
158+
pbf_press_dpad(context, DPAD_UP, 10, 50);
159+
}
160+
else {
161+
//All other legendaries.
162+
pbf_press_button(context, BUTTON_A, 20, 40);
163+
}
164+
165+
bool legendary_shiny = handle_encounter(env.console, context, true);
166+
if (legendary_shiny) {
167+
stats.shinies++;
168+
env.update_stats();
169+
send_program_notification(env, NOTIFICATION_SHINY, COLOR_YELLOW, "Shiny found!", {}, "", env.console.video().snapshot(), true);
170+
break;
171+
}
172+
env.log("No shiny found.");
173+
flee_battle(env.console, context);
174+
175+
//Close out dialog box
176+
pbf_mash_button(context, BUTTON_B, 250);
177+
context.wait_for_all_requests();
178+
179+
//Exit and reenter
180+
reset_room(env, context);
181+
182+
stats.resets++;
183+
env.update_stats();
184+
}
185+
186+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
187+
}
188+
189+
}
190+
}
191+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Legendary Hunt - Emerald
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonRSE_LegendaryHuntEmerald_H
8+
#define PokemonAutomation_PokemonRSE_LegendaryHuntEmerald_H
9+
10+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11+
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "CommonFramework/Notifications/EventNotificationsTable.h"
13+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
14+
15+
namespace PokemonAutomation{
16+
namespace NintendoSwitch{
17+
namespace PokemonRSE{
18+
19+
class LegendaryHuntEmerald_Descriptor : public SingleSwitchProgramDescriptor{
20+
public:
21+
LegendaryHuntEmerald_Descriptor();
22+
struct Stats;
23+
virtual std::unique_ptr<StatsTracker> make_stats() const override;
24+
};
25+
26+
class LegendaryHuntEmerald : public SingleSwitchProgramInstance{
27+
public:
28+
LegendaryHuntEmerald();
29+
virtual void program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) override;
30+
31+
private:
32+
enum class Target{
33+
regis,
34+
hooh,
35+
lugia,
36+
latis,
37+
};
38+
EnumDropdownOption<Target> TARGET;
39+
40+
EventNotificationOption NOTIFICATION_SHINY;
41+
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
42+
EventNotificationsOption NOTIFICATIONS;
43+
44+
void reset_room(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context);
45+
};
46+
47+
}
48+
}
49+
}
50+
#endif
51+

0 commit comments

Comments
 (0)