Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,8 @@ file(GLOB MAIN_SOURCES
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.h
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.cpp
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.cpp
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.h
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.cpp
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.cpp
Expand Down
42 changes: 23 additions & 19 deletions SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
#include "PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h"
#include "PokemonRSE/PokemonRSE_Settings.h"
Expand Down Expand Up @@ -89,7 +90,7 @@ void flee_battle(VideoStream& stream, ProControllerContext& context) {
}
}

bool handle_encounter(VideoStream& stream, ProControllerContext& context) {
bool handle_encounter(VideoStream& stream, ProControllerContext& context, bool send_out_lead) {
float shiny_coefficient = 1.0;
ShinySoundDetector shiny_detector(stream.logger(), [&](float error_coefficient) -> bool{
shiny_coefficient = error_coefficient;
Expand Down Expand Up @@ -130,27 +131,30 @@ bool handle_encounter(VideoStream& stream, ProControllerContext& context) {
}
stream.log("Shiny not found.");

//Send out lead, no shiny detection needed.
BattleMenuWatcher battle_menu(COLOR_RED);
stream.log("Sending out lead Pokemon.");
pbf_press_button(context, BUTTON_A, 40, 40);
if (send_out_lead) {
//Send out lead, no shiny detection needed.
BattleMenuWatcher battle_menu(COLOR_RED);
stream.log("Sending out lead Pokemon.");
pbf_press_button(context, BUTTON_A, 40, 40);

int ret = wait_until(
stream, context,
std::chrono::seconds(15),
{{battle_menu}}
);
if (ret == 0) {
stream.log("Battle menu detecteed!");
} else {
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"handle_encounter(): Did not detect battle menu.",
stream
int ret = wait_until(
stream, context,
std::chrono::seconds(15),
{ {battle_menu} }
);
if (ret == 0) {
stream.log("Battle menu detecteed!");
}
else {
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"handle_encounter(): Did not detect battle menu.",
stream
);
}
pbf_wait(context, 125);
context.wait_for_all_requests();
}
pbf_wait(context, 125);
context.wait_for_all_requests();

return false;
}
Expand Down
5 changes: 3 additions & 2 deletions SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerConte
void flee_battle(VideoStream& stream, ProControllerContext& context);

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


}
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/Source/PokemonRSE/PokemonRSE_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "PokemonRSE_Settings.h"

#include "Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h"
#include "Programs/ShinyHunting/PokemonRSE_LegendaryHunt-Emerald.h"
#include "Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h"

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

ret.emplace_back("---- Shiny Hunting (Emerald) ----");
ret.emplace_back(make_single_switch_program<LegendaryHuntEmerald_Descriptor, LegendaryHuntEmerald>());
ret.emplace_back(make_single_switch_program<ShinyHuntDeoxys_Descriptor, ShinyHuntDeoxys>());


Expand Down
Loading
Loading