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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace NintendoSwitch{
namespace PokemonFRLG{

ShinySymbolDetector::ShinySymbolDetector(Color color)
: m_box_symbol(0.430, 0.208, 0.048, 0.078)
: m_box_symbol(0.436, 0.211, 0.033, 0.060)
{}
void ShinySymbolDetector::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_RED, m_box_symbol);
Expand Down
95 changes: 71 additions & 24 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
#include "PokemonSwSh/MaxLair/Ai/PokemonSwSh_MaxLair_AI.h"
#include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h"
#include "PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h"
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.h"
Expand All @@ -24,37 +25,78 @@ namespace NintendoSwitch{
namespace PokemonFRLG{


void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
void soft_reset(ConsoleHandle& console, ProControllerContext& context){
// A + B + Select + Start
pbf_press_button(context, BUTTON_B | BUTTON_A | BUTTON_MINUS | BUTTON_PLUS, 360ms, 1440ms);

pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH1);
pbf_mash_button(context, BUTTON_MINUS, GameSettings::instance().SELECT_BUTTON_MASH0);
context.wait_for_all_requests();

//Random wait before pressing start/A
console.log("Randomly waiting...");
Milliseconds rng_wait = std::chrono::milliseconds(PokemonSwSh::MaxLairInternal::random(0, 5000));
pbf_wait(context, rng_wait);
context.wait_for_all_requests();

//Mash A until white screen to game load menu
WhiteScreenOverWatcher whitescreen(COLOR_RED, {0.282, 0.064, 0.448, 0.871});

int ls = run_until<ProControllerContext>(
console, context,
[](ProControllerContext& context) {
pbf_mash_button(context, BUTTON_A, 1000ms);
pbf_wait(context, 5000ms);
context.wait_for_all_requests();
},
{ whitescreen }
);
context.wait_for_all_requests();
if (ls == 0){
console.log("Entered load menu.");
}else{
console.log("Unable to enter load menu.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"soft_reset(): Unable to enter load menu.",
console
);
}
//Let the animation finish
pbf_wait(context, 500ms);
context.wait_for_all_requests();

//Load game
pbf_press_button(context, BUTTON_A, 160ms, 320ms);

//Wait for game to load in
BlackScreenOverWatcher detector(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
int ret = wait_until(
stream, context,
console, context,
GameSettings::instance().ENTER_GAME_WAIT0,
{detector}
);
if (ret == 0){
stream.log("Entered game!");
console.log("Entered game!");
}else{
stream.log("Timed out waiting to enter game.", COLOR_RED);
console.log("Timed out waiting to enter game.", COLOR_RED);
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"soft_reset(): Timed out waiting to enter game.",
stream
console
);
}

//Mash past "previously on..."
pbf_mash_button(context, BUTTON_B, GameSettings::instance().ENTER_GAME_MASH0);
context.wait_for_all_requests();

//Random wait no.2
console.log("Randomly waiting...");
Milliseconds rng_wait2 = std::chrono::milliseconds(PokemonSwSh::MaxLairInternal::random(0, 5000));
pbf_wait(context, rng_wait2);
context.wait_for_all_requests();

console.log("Soft reset completed.");
}

void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
Expand Down Expand Up @@ -85,20 +127,23 @@ void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
}

console.log("Navigating to party menu.");
pbf_wait(context, 200ms);
context.wait_for_all_requests();
pbf_press_dpad(context, DPAD_DOWN, 320ms, 320ms);
context.wait_for_all_requests();

pbf_press_button(context, BUTTON_A, 320ms, 640ms);

BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
int ret1 = wait_until(

int pm = run_until<ProControllerContext>(
console, context,
5s,
{blk1}
[](ProControllerContext& context) {
pbf_wait(context, 200ms);
context.wait_for_all_requests();
pbf_press_dpad(context, DPAD_DOWN, 320ms, 320ms);
context.wait_for_all_requests();

pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_wait(context, 5000ms);
context.wait_for_all_requests();
},
{ blk1 }
);
if (ret1 == 0){
if (pm == 0){
console.log("Entered party menu.");
}else{
console.log("Unable to enter Party menu.", COLOR_RED);
Expand All @@ -115,16 +160,18 @@ void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
pbf_press_dpad(context, DPAD_UP, 320ms, 320ms);

//Two presses to open summary
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_press_button(context, BUTTON_A, 320ms, 640ms);

BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
int ret2 = wait_until(
int sm = run_until<ProControllerContext>(
console, context,
5s,
{blk2}
[](ProControllerContext& context) {
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_wait(context, 5000ms);
context.wait_for_all_requests();
},
{ blk2 }
);
if (ret2 == 0){
if (sm == 0){
console.log("Entered summary.");
}else{
console.log("Unable to enter summary.", COLOR_RED);
Expand Down
4 changes: 3 additions & 1 deletion SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace NintendoSwitch{
namespace PokemonFRLG{

// Press A+B+Select+Start at the same time to soft reset, then re-enters the game.
// There are two random waits, one before pressing start and another after loading in the game.
// This is to prevent repeatedly getting the same pokemon, due to FRLG's RNG
// For now this assumes no dry battery.
void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerContext &context);
void soft_reset(ConsoleHandle& console, ProControllerContext &context);

// From the overworld, open the summary of the Pokemon in slot 6. This assumes the menu cursor is in the top slot (POKEDEX)
void open_slot_six(ConsoleHandle& console, ProControllerContext& context);
Expand Down
8 changes: 4 additions & 4 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ GameSettings& GameSettings::instance(){
GameSettings::GameSettings()
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
, m_soft_reset_timings("<font size=4><b>Soft Reset Timings:</b></font>")
, START_BUTTON_MASH1(
"<b>Start Button Mash:</b><br>Mash Start for this long after a soft reset to get to the main menu.",
, SELECT_BUTTON_MASH0(
"<b>Start Button Mash:</b><br>Mash select for this long after a soft reset to get to Press Start.",
LockMode::LOCK_WHILE_RUNNING,
"6000 ms"
"5000 ms"
)
, ENTER_GAME_WAIT0(
"<b>Enter Game Wait:</b><br>Wait this long for the game to load.",
Expand All @@ -51,7 +51,7 @@ GameSettings::GameSettings()
)
{
PA_ADD_STATIC(m_soft_reset_timings);
PA_ADD_OPTION(START_BUTTON_MASH1);
PA_ADD_OPTION(SELECT_BUTTON_MASH0);
PA_ADD_OPTION(ENTER_GAME_WAIT0);
PA_ADD_STATIC(m_shiny_audio_settings);
PA_ADD_OPTION(SHINY_SOUND_THRESHOLD);
Expand Down
2 changes: 1 addition & 1 deletion SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GameSettings : public BatchOption{
static GameSettings& instance();

SectionDividerOption m_soft_reset_timings;
MillisecondsOption START_BUTTON_MASH1;
MillisecondsOption SELECT_BUTTON_MASH0;
MillisecondsOption ENTER_GAME_WAIT0;
MillisecondsOption ENTER_GAME_MASH0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,19 @@ void GiftReset::open_summary(SingleSwitchProgramEnvironment& env, ProControllerC
} //For starters, no Pokedex yet, do Pokemon is on top and we skip this

//Open party menu
pbf_press_button(context, BUTTON_A, 320ms, 640ms);

BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
int ret1 = wait_until(

int pm = run_until<ProControllerContext>(
env.console, context,
5s,
{blk1}
[](ProControllerContext& context) {
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
pbf_wait(context, 5000ms);
context.wait_for_all_requests();
},
{ blk1 }
);
if (ret1 == 0){
context.wait_for_all_requests();
if (pm == 0){
env.log("Entered party menu.");
}else{
env.log("Unable to enter party menu.", COLOR_RED);
Expand All @@ -264,7 +268,6 @@ void GiftReset::open_summary(SingleSwitchProgramEnvironment& env, ProControllerC
env.console
);
}
context.wait_for_all_requests();

//Press up twice to get to the last slot
if (TARGET != Target::starters) {
Expand All @@ -273,16 +276,18 @@ void GiftReset::open_summary(SingleSwitchProgramEnvironment& env, ProControllerC
}

//Two presses to open summary
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
pbf_press_button(context, BUTTON_A, 320ms, 320ms);

BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
int ret2 = wait_until(
int sm = run_until<ProControllerContext>(
env.console, context,
5s,
{blk2}
[](ProControllerContext& context) {
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
pbf_wait(context, 5000ms);
context.wait_for_all_requests();
},
{ blk2 }
);
if (ret2 == 0){
if (sm == 0){
env.log("Entered summary.");
}else{
env.log("Unable to enter summary.", COLOR_RED);
Expand Down Expand Up @@ -339,7 +344,7 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, ProControllerContex
env, NOTIFICATION_STATUS_UPDATE,
"Soft resetting."
);
soft_reset(env.program_info(), env.console, context);
soft_reset(env.console, context);
stats.resets++;
env.update_stats();
context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, ProControllerC
"Soft resetting."
);

soft_reset(env.program_info(), env.console, context);
soft_reset(env.console, context);
stats.resets++;
env.update_stats();
context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void PrizeCornerReset::program(SingleSwitchProgramEnvironment& env, ProControlle
env, NOTIFICATION_STATUS_UPDATE,
"Soft resetting."
);
soft_reset(env.program_info(), env.console, context);
soft_reset(env.console, context);
stats.resets++;
context.wait_for_all_requests();
}
Expand Down
Loading