Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ bool WhiteDialogDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
if (is_white(right_image)
&& is_white(top_image)
&& is_white(bottom_image)
){
return true;
}
Expand All @@ -66,7 +66,7 @@ bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){
//Filter out background
ImageRGB32 filtered_region = filter_rgb32_range(
extract_box_reference(screen, m_dialog_box),
combine_rgb(185, 0, 1), combine_rgb(255, 32, 33), Color(0), replace_color_within_range
combine_rgb(164, 0, 0), combine_rgb(255, 114, 87), Color(0), replace_color_within_range
);
ImageStats stats = image_stats(filtered_region);

Expand All @@ -81,11 +81,11 @@ bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);

if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
&& (stats.average.r > stats.average.b + 200)
&& (stats.average.r > stats.average.g + 200)
if (is_white(right_image)
&& is_white(top_image)
&& is_white(bottom_image)
&& (stats.average.r > stats.average.b + 180)
&& (stats.average.r > stats.average.g + 180)
)
{
return true;
Expand All @@ -110,10 +110,10 @@ bool SelectionDialogDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box);
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
&& is_solid(selection_image, { 0.25, 0.38, 0.369 })
if (is_white(right_image)
&& is_white(top_image)
&& is_white(bottom_image)
&& is_white(selection_image)
){
return true;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ bool AdvanceBattleDialogDetector::detect(const ImageViewRGB32& screen){
//Filter out background
ImageRGB32 filtered_region = filter_rgb32_range(
extract_box_reference(screen, m_dialog_box),
combine_rgb(185, 0, 1), combine_rgb(255, 32, 33), Color(0), replace_color_within_range
combine_rgb(164, 0, 0), combine_rgb(255, 114, 87), Color(0), replace_color_within_range
);
ImageStats stats = image_stats(filtered_region);

Expand All @@ -205,8 +205,8 @@ bool AdvanceBattleDialogDetector::detect(const ImageViewRGB32& screen){

if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 })
&& is_solid(dialog_right_image, { 0.176, 0.357, 0.467 })
&& (stats.average.r > stats.average.b + 200)
&& (stats.average.r > stats.average.g + 200)
&& (stats.average.r > stats.average.b + 180)
&& (stats.average.r > stats.average.g + 180)
)
{
return true;
Expand Down
14 changes: 14 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "CommonTools/Random.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
#include "CommonTools/StartupChecks/StartProgramChecks.h"
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
Expand Down Expand Up @@ -333,6 +335,18 @@ void flee_battle(ConsoleHandle& console, ProControllerContext& context){
}
}

void home_black_border_check(ConsoleHandle& console, ProControllerContext& context){
console.log("Going to home to check for black border.");
go_home(console, context);
ensure_at_home(console, context);
context.wait_for_all_requests();
StartProgramChecks::check_border(console);
console.log("Returning to game.");
resume_game_from_home(console, context);
context.wait_for_all_requests();
console.log("Entered game.");
}


}
}
Expand Down
3 changes: 3 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ bool handle_encounter(ConsoleHandle& console, ProControllerContext& context, boo
// Run from battle. Cursor must start on the FIGHT button. Assumes fleeing will always work. (Smoke Ball)
void flee_battle(ConsoleHandle& console, ProControllerContext& context);

// Go to home to check that scaling is 100%. Then resume game.
void home_black_border_check(ConsoleHandle& console, ProControllerContext& context);

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GiftReset_Descriptor::GiftReset_Descriptor()
Pokemon::STRING_POKEMON + " FRLG", "Gift Reset",
"Programs/PokemonFRLG/GiftReset.html",
"Soft reset for a shiny gift Pokemon.",
ProgramControllerClass::StandardController_RequiresPrecision,
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
)
Expand Down Expand Up @@ -67,6 +67,7 @@ GiftReset::GiftReset()
LockMode::LOCK_WHILE_RUNNING,
Target::starters
)
, TAKE_VIDEO("<b>Take Video:</b><br>Record a video when the shiny is found.", LockMode::UNLOCK_WHILE_RUNNING, true)
, GO_HOME_WHEN_DONE(true)
, NOTIFICATION_SHINY(
"Shiny found",
Expand All @@ -81,6 +82,7 @@ GiftReset::GiftReset()
})
{
PA_ADD_OPTION(TARGET);
PA_ADD_OPTION(TAKE_VIDEO);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
PA_ADD_OPTION(NOTIFICATIONS);
}
Expand All @@ -100,8 +102,33 @@ void GiftReset::obtain_pokemon(SingleSwitchProgramEnvironment& env, ProControlle
*/

env.log("Obtaining Pokemon.");
pbf_press_button(context, BUTTON_A, 320ms, 640ms);

if (TARGET == Target::starters) {
AdvanceWhiteDialogWatcher adv_white_start(COLOR_RED);
int rets = run_until<ProControllerContext>(
env.console, context,
[](ProControllerContext& context) {
for (int i = 0; i < 10; i++) {
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_wait(context, 2000ms);
context.wait_for_all_requests();
}
},
{ adv_white_start }
);
context.wait_for_all_requests();
if (rets < 0) {
env.update_stats();
env.log("obtain_pokemon(): Unable to start starter dialog after 10 attempts.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"obtain_pokemon(): Unable to start starter dialog after 10 attempts.",
env.console
);
}
env.log("Initial A press completed.");
} else {
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
}
bool seen_selection_arrow = false;
//bool seen_nickname_arrow = false;
while (true){
Expand Down Expand Up @@ -310,6 +337,8 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, ProControllerContex

GiftReset_Descriptor::Stats& stats = env.current_stats<GiftReset_Descriptor::Stats>();

home_black_border_check(env.console, context);

/*
* Settings: Text Speed fast. Default borders.
* Setup: 5 pokemon in your party. None for starter. Stand in front of the pokemon. Save the game.
Expand Down Expand Up @@ -346,6 +375,9 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, ProControllerContex
screen,
true
);
if (TAKE_VIDEO){
pbf_press_button(context, BUTTON_CAPTURE, 2000ms, 0ms);
}
break;
}else{
env.log("Pokemon is not shiny.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_PokemonFRLG_GiftReset_H
#define PokemonAutomation_PokemonFRLG_GiftReset_H

#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
#include "CommonFramework/Notifications/EventNotificationsTable.h"
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
Expand Down Expand Up @@ -47,6 +48,8 @@ class GiftReset : public SingleSwitchProgramInstance{
};
EnumDropdownOption<Target> TARGET;

BooleanCheckBoxOption TAKE_VIDEO;

GoHomeWhenDoneOption GO_HOME_WHEN_DONE;

EventNotificationOption NOTIFICATION_SHINY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LegendaryReset_Descriptor::LegendaryReset_Descriptor()
Pokemon::STRING_POKEMON + " FRLG", "Legendary Reset",
"Programs/PokemonFRLG/LegendaryReset.html",
"Shiny hunt legendary Pokemon using soft resets.",
ProgramControllerClass::StandardController_RequiresPrecision,
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
)
Expand Down Expand Up @@ -59,6 +59,7 @@ LegendaryReset::LegendaryReset()
LockMode::LOCK_WHILE_RUNNING,
false
)
, TAKE_VIDEO("<b>Take Video:</b><br>Record a video when the shiny is found.", LockMode::UNLOCK_WHILE_RUNNING, true)
, GO_HOME_WHEN_DONE(true)
, NOTIFICATION_SHINY(
"Shiny found",
Expand All @@ -72,14 +73,18 @@ LegendaryReset::LegendaryReset()
&NOTIFICATION_PROGRAM_FINISH,
})
{
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
PA_ADD_OPTION(WALK_UP);
PA_ADD_OPTION(TAKE_VIDEO);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
PA_ADD_OPTION(NOTIFICATIONS);
}

void LegendaryReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
LegendaryReset_Descriptor::Stats& stats = env.current_stats<LegendaryReset_Descriptor::Stats>();

home_black_border_check(env.console, context);

/*
* Settings: Text Speed fast. Default borders. Audio required.
* Setup: Stand in front of target. Save the game.
Expand Down Expand Up @@ -138,6 +143,9 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, ProControllerC
env.console.video().snapshot(),
true
);
if (TAKE_VIDEO){
pbf_press_button(context, BUTTON_CAPTURE, 2000ms, 0ms);
}
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
#include "Common/Cpp/Options/EnumDropdownOption.h"
#include "Common/Cpp/Options/SimpleIntegerOption.h"
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
#include "PokemonLA/Options/PokemonLA_ShinyDetectedAction.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand All @@ -35,7 +37,10 @@ class LegendaryReset : public SingleSwitchProgramInstance{
) override{}

private:
PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;

BooleanCheckBoxOption WALK_UP;
BooleanCheckBoxOption TAKE_VIDEO;

GoHomeWhenDoneOption GO_HOME_WHEN_DONE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LegendaryRunAway_Descriptor::LegendaryRunAway_Descriptor()
Pokemon::STRING_POKEMON + " FRLG", "Legendary Run Away",
"Programs/PokemonFRLG/LegendaryRunAway.html",
"Shiny hunt legendary Pokemon using the run away method.",
ProgramControllerClass::StandardController_RequiresPrecision,
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
)
Expand Down Expand Up @@ -64,6 +64,7 @@ LegendaryRunAway::LegendaryRunAway()
LockMode::LOCK_WHILE_RUNNING,
Target::hooh
)
, TAKE_VIDEO("<b>Take Video:</b><br>Record a video when the shiny is found.", LockMode::UNLOCK_WHILE_RUNNING, true)
, GO_HOME_WHEN_DONE(true)
, NOTIFICATION_SHINY(
"Shiny found",
Expand Down Expand Up @@ -100,7 +101,9 @@ LegendaryRunAway::LegendaryRunAway()
"550 ms"
)
{
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
PA_ADD_OPTION(TARGET);
PA_ADD_OPTION(TAKE_VIDEO);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
PA_ADD_OPTION(NOTIFICATIONS);
PA_ADD_STATIC(m_advanced_options);
Expand Down Expand Up @@ -243,6 +246,8 @@ void LegendaryRunAway::reset_lugia(SingleSwitchProgramEnvironment& env, ProContr
void LegendaryRunAway::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
LegendaryRunAway_Descriptor::Stats& stats = env.current_stats<LegendaryRunAway_Descriptor::Stats>();

home_black_border_check(env.console, context);

/*
* Settings: Text Speed fast. Default borders. Battle animations off. Audio required.
* Smoke Ball or fast pokemon required.
Expand All @@ -264,7 +269,17 @@ void LegendaryRunAway::program(SingleSwitchProgramEnvironment& env, ProControlle
if (legendary_shiny){
stats.shinies++;
env.update_stats();
send_program_notification(env, NOTIFICATION_SHINY, COLOR_YELLOW, "Shiny found!", {}, "", env.console.video().snapshot(), true);
send_program_notification(env,
NOTIFICATION_SHINY,
COLOR_YELLOW,
"Shiny found!",
{}, "",
env.console.video().snapshot(),
true
);
if (TAKE_VIDEO){
pbf_press_button(context, BUTTON_CAPTURE, 2000ms, 0ms);
}
break;
}
env.log("No shiny found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "Common/Cpp/Options/EnumDropdownOption.h"
#include "Common/Cpp/Options/SimpleIntegerOption.h"
#include "Common/Cpp/Options/TimeDurationOption.h"
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
#include "PokemonLA/Options/PokemonLA_ShinyDetectedAction.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand Down Expand Up @@ -46,6 +48,9 @@ class LegendaryRunAway : public SingleSwitchProgramInstance{
void reset_hooh(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
void reset_lugia(SingleSwitchProgramEnvironment& env, ProControllerContext& context);

PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;
BooleanCheckBoxOption TAKE_VIDEO;

GoHomeWhenDoneOption GO_HOME_WHEN_DONE;

EventNotificationOption NOTIFICATION_SHINY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PrizeCornerReset_Descriptor::PrizeCornerReset_Descriptor()
Pokemon::STRING_POKEMON + " FRLG", "Prize Corner Reset",
"Programs/PokemonFRLG/PrizeCornerReset.html",
"Redeem and soft reset for a shiny Game Corner prize.",
ProgramControllerClass::StandardController_RequiresPrecision,
ProgramControllerClass::StandardController_NoRestrictions,
FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS
)
Expand Down Expand Up @@ -68,6 +68,7 @@ PrizeCornerReset::PrizeCornerReset()
LockMode::LOCK_WHILE_RUNNING,
0
)
, TAKE_VIDEO("<b>Take Video:</b><br>Record a video when the shiny is found.", LockMode::UNLOCK_WHILE_RUNNING, true)
, GO_HOME_WHEN_DONE(true)
, NOTIFICATION_SHINY(
"Shiny found",
Expand All @@ -82,6 +83,7 @@ PrizeCornerReset::PrizeCornerReset()
})
{
PA_ADD_OPTION(SLOT);
PA_ADD_OPTION(TAKE_VIDEO);
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
PA_ADD_OPTION(NOTIFICATIONS);
}
Expand Down Expand Up @@ -136,6 +138,8 @@ void PrizeCornerReset::obtain_prize(SingleSwitchProgramEnvironment& env, ProCont
void PrizeCornerReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
PrizeCornerReset_Descriptor::Stats& stats = env.current_stats<PrizeCornerReset_Descriptor::Stats>();

home_black_border_check(env.console, context);

/*
* Settings: Text Speed fast. Default borders.
* Setup: Have a party of 5. Stand in front of the prize redemption. Save game. Move cursor back to top.
Expand Down Expand Up @@ -165,6 +169,9 @@ void PrizeCornerReset::program(SingleSwitchProgramEnvironment& env, ProControlle
screen,
true
);
if (TAKE_VIDEO){
pbf_press_button(context, BUTTON_CAPTURE, 2000ms, 0ms);
}
break;
}else{
env.log("Prize is not shiny.");
Expand Down
Loading