Skip to content

Commit 880e83f

Browse files
authored
Frlg random fixes (#1104)
* improve opening summary, move shiny box * random wait in soft reset for rng * 10 sec random to 5 sec
1 parent e3235f0 commit 880e83f

8 files changed

Lines changed: 102 additions & 48 deletions

SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_ShinySymbolDetector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace NintendoSwitch{
2222
namespace PokemonFRLG{
2323

2424
ShinySymbolDetector::ShinySymbolDetector(Color color)
25-
: m_box_symbol(0.430, 0.208, 0.048, 0.078)
25+
: m_box_symbol(0.436, 0.211, 0.033, 0.060)
2626
{}
2727
void ShinySymbolDetector::make_overlays(VideoOverlaySet& items) const{
2828
items.add(COLOR_RED, m_box_symbol);

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1414
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
1515
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
16+
#include "PokemonSwSh/MaxLair/Ai/PokemonSwSh_MaxLair_AI.h"
1617
#include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h"
1718
#include "PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h"
1819
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.h"
@@ -24,37 +25,78 @@ namespace NintendoSwitch{
2425
namespace PokemonFRLG{
2526

2627

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

31-
pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH1);
32+
pbf_mash_button(context, BUTTON_MINUS, GameSettings::instance().SELECT_BUTTON_MASH0);
3233
context.wait_for_all_requests();
3334

35+
//Random wait before pressing start/A
36+
console.log("Randomly waiting...");
37+
Milliseconds rng_wait = std::chrono::milliseconds(PokemonSwSh::MaxLairInternal::random(0, 5000));
38+
pbf_wait(context, rng_wait);
39+
context.wait_for_all_requests();
40+
41+
//Mash A until white screen to game load menu
42+
WhiteScreenOverWatcher whitescreen(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
43+
44+
int ls = run_until<ProControllerContext>(
45+
console, context,
46+
[](ProControllerContext& context) {
47+
pbf_mash_button(context, BUTTON_A, 1000ms);
48+
pbf_wait(context, 5000ms);
49+
context.wait_for_all_requests();
50+
},
51+
{ whitescreen }
52+
);
53+
context.wait_for_all_requests();
54+
if (ls == 0){
55+
console.log("Entered load menu.");
56+
}else{
57+
console.log("Unable to enter load menu.", COLOR_RED);
58+
OperationFailedException::fire(
59+
ErrorReport::SEND_ERROR_REPORT,
60+
"soft_reset(): Unable to enter load menu.",
61+
console
62+
);
63+
}
64+
//Let the animation finish
65+
pbf_wait(context, 500ms);
66+
context.wait_for_all_requests();
67+
68+
//Load game
3469
pbf_press_button(context, BUTTON_A, 160ms, 320ms);
3570

3671
//Wait for game to load in
3772
BlackScreenOverWatcher detector(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
3873
int ret = wait_until(
39-
stream, context,
74+
console, context,
4075
GameSettings::instance().ENTER_GAME_WAIT0,
4176
{detector}
4277
);
4378
if (ret == 0){
44-
stream.log("Entered game!");
79+
console.log("Entered game!");
4580
}else{
46-
stream.log("Timed out waiting to enter game.", COLOR_RED);
81+
console.log("Timed out waiting to enter game.", COLOR_RED);
4782
OperationFailedException::fire(
4883
ErrorReport::SEND_ERROR_REPORT,
4984
"soft_reset(): Timed out waiting to enter game.",
50-
stream
85+
console
5186
);
5287
}
5388

5489
//Mash past "previously on..."
5590
pbf_mash_button(context, BUTTON_B, GameSettings::instance().ENTER_GAME_MASH0);
91+
context.wait_for_all_requests();
5692

93+
//Random wait no.2
94+
console.log("Randomly waiting...");
95+
Milliseconds rng_wait2 = std::chrono::milliseconds(PokemonSwSh::MaxLairInternal::random(0, 5000));
96+
pbf_wait(context, rng_wait2);
5797
context.wait_for_all_requests();
98+
99+
console.log("Soft reset completed.");
58100
}
59101

60102
void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
@@ -85,20 +127,23 @@ void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
85127
}
86128

87129
console.log("Navigating to party menu.");
88-
pbf_wait(context, 200ms);
89-
context.wait_for_all_requests();
90-
pbf_press_dpad(context, DPAD_DOWN, 320ms, 320ms);
91-
context.wait_for_all_requests();
92-
93-
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
94-
95130
BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
96-
int ret1 = wait_until(
131+
132+
int pm = run_until<ProControllerContext>(
97133
console, context,
98-
5s,
99-
{blk1}
134+
[](ProControllerContext& context) {
135+
pbf_wait(context, 200ms);
136+
context.wait_for_all_requests();
137+
pbf_press_dpad(context, DPAD_DOWN, 320ms, 320ms);
138+
context.wait_for_all_requests();
139+
140+
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
141+
pbf_wait(context, 5000ms);
142+
context.wait_for_all_requests();
143+
},
144+
{ blk1 }
100145
);
101-
if (ret1 == 0){
146+
if (pm == 0){
102147
console.log("Entered party menu.");
103148
}else{
104149
console.log("Unable to enter Party menu.", COLOR_RED);
@@ -115,16 +160,18 @@ void open_slot_six(ConsoleHandle& console, ProControllerContext& context){
115160
pbf_press_dpad(context, DPAD_UP, 320ms, 320ms);
116161

117162
//Two presses to open summary
118-
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
119-
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
120-
121163
BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
122-
int ret2 = wait_until(
164+
int sm = run_until<ProControllerContext>(
123165
console, context,
124-
5s,
125-
{blk2}
166+
[](ProControllerContext& context) {
167+
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
168+
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
169+
pbf_wait(context, 5000ms);
170+
context.wait_for_all_requests();
171+
},
172+
{ blk2 }
126173
);
127-
if (ret2 == 0){
174+
if (sm == 0){
128175
console.log("Entered summary.");
129176
}else{
130177
console.log("Unable to enter summary.", COLOR_RED);

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ namespace NintendoSwitch{
2020
namespace PokemonFRLG{
2121

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

2628
// From the overworld, open the summary of the Pokemon in slot 6. This assumes the menu cursor is in the top slot (POKEDEX)
2729
void open_slot_six(ConsoleHandle& console, ProControllerContext& context);

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ GameSettings& GameSettings::instance(){
2323
GameSettings::GameSettings()
2424
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
2525
, m_soft_reset_timings("<font size=4><b>Soft Reset Timings:</b></font>")
26-
, START_BUTTON_MASH1(
27-
"<b>Start Button Mash:</b><br>Mash Start for this long after a soft reset to get to the main menu.",
26+
, SELECT_BUTTON_MASH0(
27+
"<b>Start Button Mash:</b><br>Mash select for this long after a soft reset to get to Press Start.",
2828
LockMode::LOCK_WHILE_RUNNING,
29-
"6000 ms"
29+
"5000 ms"
3030
)
3131
, ENTER_GAME_WAIT0(
3232
"<b>Enter Game Wait:</b><br>Wait this long for the game to load.",
@@ -51,7 +51,7 @@ GameSettings::GameSettings()
5151
)
5252
{
5353
PA_ADD_STATIC(m_soft_reset_timings);
54-
PA_ADD_OPTION(START_BUTTON_MASH1);
54+
PA_ADD_OPTION(SELECT_BUTTON_MASH0);
5555
PA_ADD_OPTION(ENTER_GAME_WAIT0);
5656
PA_ADD_STATIC(m_shiny_audio_settings);
5757
PA_ADD_OPTION(SHINY_SOUND_THRESHOLD);

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GameSettings : public BatchOption{
2323
static GameSettings& instance();
2424

2525
SectionDividerOption m_soft_reset_timings;
26-
MillisecondsOption START_BUTTON_MASH1;
26+
MillisecondsOption SELECT_BUTTON_MASH0;
2727
MillisecondsOption ENTER_GAME_WAIT0;
2828
MillisecondsOption ENTER_GAME_MASH0;
2929

SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_GiftReset.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,19 @@ void GiftReset::open_summary(SingleSwitchProgramEnvironment& env, ProControllerC
246246
} //For starters, no Pokedex yet, do Pokemon is on top and we skip this
247247

248248
//Open party menu
249-
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
250-
251249
BlackScreenOverWatcher blk1(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
252-
int ret1 = wait_until(
250+
251+
int pm = run_until<ProControllerContext>(
253252
env.console, context,
254-
5s,
255-
{blk1}
253+
[](ProControllerContext& context) {
254+
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
255+
pbf_wait(context, 5000ms);
256+
context.wait_for_all_requests();
257+
},
258+
{ blk1 }
256259
);
257-
if (ret1 == 0){
260+
context.wait_for_all_requests();
261+
if (pm == 0){
258262
env.log("Entered party menu.");
259263
}else{
260264
env.log("Unable to enter party menu.", COLOR_RED);
@@ -264,7 +268,6 @@ void GiftReset::open_summary(SingleSwitchProgramEnvironment& env, ProControllerC
264268
env.console
265269
);
266270
}
267-
context.wait_for_all_requests();
268271

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

275278
//Two presses to open summary
276-
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
277-
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
278-
279279
BlackScreenOverWatcher blk2(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
280-
int ret2 = wait_until(
280+
int sm = run_until<ProControllerContext>(
281281
env.console, context,
282-
5s,
283-
{blk2}
282+
[](ProControllerContext& context) {
283+
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
284+
pbf_press_button(context, BUTTON_A, 320ms, 320ms);
285+
pbf_wait(context, 5000ms);
286+
context.wait_for_all_requests();
287+
},
288+
{ blk2 }
284289
);
285-
if (ret2 == 0){
290+
if (sm == 0){
286291
env.log("Entered summary.");
287292
}else{
288293
env.log("Unable to enter summary.", COLOR_RED);
@@ -339,7 +344,7 @@ void GiftReset::program(SingleSwitchProgramEnvironment& env, ProControllerContex
339344
env, NOTIFICATION_STATUS_UPDATE,
340345
"Soft resetting."
341346
);
342-
soft_reset(env.program_info(), env.console, context);
347+
soft_reset(env.console, context);
343348
stats.resets++;
344349
env.update_stats();
345350
context.wait_for_all_requests();

SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_LegendaryReset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void LegendaryReset::program(SingleSwitchProgramEnvironment& env, ProControllerC
140140
"Soft resetting."
141141
);
142142

143-
soft_reset(env.program_info(), env.console, context);
143+
soft_reset(env.console, context);
144144
stats.resets++;
145145
env.update_stats();
146146
context.wait_for_all_requests();

SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_PrizeCornerReset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void PrizeCornerReset::program(SingleSwitchProgramEnvironment& env, ProControlle
165165
env, NOTIFICATION_STATUS_UPDATE,
166166
"Soft resetting."
167167
);
168-
soft_reset(env.program_info(), env.console, context);
168+
soft_reset(env.console, context);
169169
stats.resets++;
170170
context.wait_for_all_requests();
171171
}

0 commit comments

Comments
 (0)