Skip to content

Commit 8e8d075

Browse files
authored
Legendary Hunt (Emerald) (#537)
* send_out_lead flag for handle_encounter * create files for legendary reset emerald * lugia * ho-oh * regis * remove latis from legenday hunt PokeNav calls possible on Southern Island * deoxys start position option * groudon * kyogre * fixes for nav and deoxys * fixes for legendary hunt emerald
1 parent d01b17b commit 8e8d075

File tree

8 files changed

+673
-33
lines changed

8 files changed

+673
-33
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,8 @@ file(GLOB MAIN_SOURCES
13411341
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.h
13421342
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.cpp
13431343
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h
1344+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.cpp
1345+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.h
13441346
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.cpp
13451347
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h
13461348
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.cpp

SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "CommonTools/Async/InferenceRoutines.h"
1111
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1212
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
13+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1314
#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
1415
#include "PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h"
1516
#include "PokemonRSE/PokemonRSE_Settings.h"
@@ -89,7 +90,7 @@ void flee_battle(VideoStream& stream, ProControllerContext& context) {
8990
}
9091
}
9192

92-
bool handle_encounter(VideoStream& stream, ProControllerContext& context) {
93+
bool handle_encounter(VideoStream& stream, ProControllerContext& context, bool send_out_lead) {
9394
float shiny_coefficient = 1.0;
9495
ShinySoundDetector shiny_detector(stream.logger(), [&](float error_coefficient) -> bool{
9596
shiny_coefficient = error_coefficient;
@@ -130,27 +131,30 @@ bool handle_encounter(VideoStream& stream, ProControllerContext& context) {
130131
}
131132
stream.log("Shiny not found.");
132133

133-
//Send out lead, no shiny detection needed.
134-
BattleMenuWatcher battle_menu(COLOR_RED);
135-
stream.log("Sending out lead Pokemon.");
136-
pbf_press_button(context, BUTTON_A, 40, 40);
134+
if (send_out_lead) {
135+
//Send out lead, no shiny detection needed.
136+
BattleMenuWatcher battle_menu(COLOR_RED);
137+
stream.log("Sending out lead Pokemon.");
138+
pbf_press_button(context, BUTTON_A, 40, 40);
137139

138-
int ret = wait_until(
139-
stream, context,
140-
std::chrono::seconds(15),
141-
{{battle_menu}}
142-
);
143-
if (ret == 0) {
144-
stream.log("Battle menu detecteed!");
145-
} else {
146-
OperationFailedException::fire(
147-
ErrorReport::SEND_ERROR_REPORT,
148-
"handle_encounter(): Did not detect battle menu.",
149-
stream
140+
int ret = wait_until(
141+
stream, context,
142+
std::chrono::seconds(15),
143+
{ {battle_menu} }
150144
);
145+
if (ret == 0) {
146+
stream.log("Battle menu detecteed!");
147+
}
148+
else {
149+
OperationFailedException::fire(
150+
ErrorReport::SEND_ERROR_REPORT,
151+
"handle_encounter(): Did not detect battle menu.",
152+
stream
153+
);
154+
}
155+
pbf_wait(context, 125);
156+
context.wait_for_all_requests();
151157
}
152-
pbf_wait(context, 125);
153-
context.wait_for_all_requests();
154158

155159
return false;
156160
}

SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerConte
2626
void flee_battle(VideoStream& stream, ProControllerContext& context);
2727

2828
// After press A/walking up to enter a battle, run this handle the battle start and to check if opponent is shiny.
29-
// Use flee_battle or soft_reset after this, depending on game.
30-
bool handle_encounter(VideoStream& stream, ProControllerContext& context);
29+
// Set send_out_lead to true and then use flee_battle() after if game is Emerald.
30+
// For R/S, send_out_lead as false and then soft_reset() to save time.
31+
bool handle_encounter(VideoStream& stream, ProControllerContext& context, bool send_out_lead);
3132

3233

3334
}

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

0 commit comments

Comments
 (0)