Skip to content

Commit a93d1bb

Browse files
committed
tidy up
1 parent 3257be6 commit a93d1bb

2 files changed

Lines changed: 38 additions & 109 deletions

File tree

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

Lines changed: 29 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ RNGManipulator::RNGManipulator()
6060
{
6161
{Target::starters, "starters", "Bulbasaur / Squirtle / Charmander"},
6262
{Target::magikarp, "magikarp", "Magikarp"},
63-
{Target::hitmon, "hitmon", "Hitmonlee / Hitmonchan"},
64-
{Target::eevee, "eevee", "Eevee"},
65-
{Target::lapras, "lapras", "Lapras"},
66-
{Target::fossils, "fossils", "Omanyte / Kabuto / Aerodactyl"},
63+
// {Target::hitmon, "hitmon", "Hitmonlee / Hitmonchan"},
64+
// {Target::eevee, "eevee", "Eevee"},
65+
// {Target::lapras, "lapras", "Lapras"},
66+
// {Target::fossils, "fossils", "Omanyte / Kabuto / Aerodactyl"},
6767
{Target::sweetscent, "sweetscent", "Sweet Scent for wild encounters"},
68-
{Target::wildwalk, "wildwalk", "Hit seed and advance when walking in grass"},
69-
{Target::fishing, "fishing", "Hit seed and advance when fishing"}
68+
{Target::grasswalk, "grasswalk", "Walk to trigger wild encounters (inaccurate)."},
69+
// {Target::fishing, "fishing", "Fishing"},
70+
// {Target::static, "static", "Static overworld encounters (including Legendaries)"},
71+
// {Target::roaming, "roaming", "Roaming Legendaries"}
7072
},
7173
LockMode::LOCK_WHILE_RUNNING,
7274
Target::starters
@@ -100,7 +102,16 @@ RNGManipulator::RNGManipulator()
100102
LockMode::UNLOCK_WHILE_RUNNING,
101103
1000, 900 // default, min
102104
)
103-
, TAKE_PICTURES("<b>Take Pictures of Stats:</b><br>Take pictures of the first two pages of the summary screen.<br>Only applies to gifts.", LockMode::UNLOCK_WHILE_RUNNING, true)
105+
, TAKE_PICTURES(
106+
"<b>Take Pictures of Stats:</b><br>Take pictures of the first two pages of the summary screen.<br>Only applies to gifts. Useful for calibrating your seed and advances.",
107+
LockMode::UNLOCK_WHILE_RUNNING,
108+
false // default
109+
)
110+
, TAKE_VIDEO(
111+
"<b>Take Video:</b><br>Record a video when the shiny is found.",
112+
LockMode::UNLOCK_WHILE_RUNNING,
113+
true // default
114+
)
104115
, GO_HOME_WHEN_DONE(true)
105116
, NOTIFICATION_SHINY(
106117
"Shiny found",
@@ -121,71 +132,13 @@ RNGManipulator::RNGManipulator()
121132
PA_ADD_OPTION(LOAD_ADVANCES);
122133
PA_ADD_OPTION(DOUBLE_ADVANCES);
123134
PA_ADD_OPTION(TAKE_PICTURES);
135+
PA_ADD_OPTION(TAKE_VIDEO);
124136
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
125137
PA_ADD_OPTION(NOTIFICATIONS);
126138
}
127139

128140
namespace{
129141

130-
// reset_to_starter(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EnumDropdownOption<ResetType>& RESET_TYPE, SimpleIntegerOption<uint64_t>& SEED_DELAY, SimpleIntegerOption<uint64_t>& LOAD_ADVANCES, SimpleIntegerOption<uint64_t>& DOUBLE_ADVANCES, BooleanCheckBoxOption& TAKE_PICTURES){
131-
// double FRAMERATE = 59.7275; // valid for GBA, but not sure for Switch
132-
// uint64_t LOAD_DELAY = uint64_t((LOAD_ADVANCES)/ FRAMERATE * 1000);
133-
// uint64_t DOUBLE_DELAY = uint64_t((DOUBLE_ADVANCES)/ FRAMERATE * 500);
134-
// env.log("Load screen delay: " + std::to_string(LOAD_DELAY));
135-
// env.log("In-game delay: " + std::to_string(DOUBLE_DELAY));
136-
// if (RESET_TYPE == ResetType::hard){
137-
// // close the game
138-
// pbf_press_button(context, BUTTON_HOME, 200ms, 1300ms);
139-
// pbf_press_button(context, BUTTON_Y, 200ms, 1300ms);
140-
// pbf_press_button(context, BUTTON_A, 200ms, 2800ms);
141-
// // press A to select game
142-
// pbf_press_button(context, BUTTON_A, 200ms, 2300ms);
143-
// // press A to select profile and immediately go back to the home screen
144-
// pbf_press_button(context, BUTTON_A, 100ms, 100ms);
145-
// pbf_press_button(context, BUTTON_HOME, 200ms, 2800ms);
146-
// pbf_press_button(context, BUTTON_A, 200ms, std::chrono::milliseconds(SEED_DELAY - 200));
147-
// }else{
148-
// // perform soft reset and
149-
// pbf_press_button(context, BUTTON_B | BUTTON_A | BUTTON_X | BUTTON_Y, 200ms, std::chrono::milliseconds(SEED_DELAY - 200));
150-
// }
151-
// // Advance to the load game screen and wait
152-
// pbf_press_button(context, BUTTON_A, 200ms, std::chrono::milliseconds(LOAD_DELAY - 200));
153-
// // Load the game (sets the Initial Seed)
154-
// pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
155-
// // Skip through the recap
156-
// pbf_press_button(context, BUTTON_B, 200ms, 2300ms);
157-
// // Advance through starter dialogue and wait on "really quite energetic!"
158-
// pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
159-
// pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
160-
// pbf_press_button(context, BUTTON_A, 200ms, std::chrono::milliseconds(DOUBLE_DELAY - 7200));
161-
// // Finish dialogue (hits the target advance)
162-
// pbf_press_button(context, BUTTON_A, 200ms, 5800ms);
163-
// // Decline nickname
164-
// pbf_press_button(context, BUTTON_B, 200ms, 2300ms);
165-
// // Advance through rival choiec
166-
// pbf_press_button(context, BUTTON_B, 200ms, 4800ms);
167-
// // Navigate to summary
168-
// pbf_press_button(context, BUTTON_PLUS, 200ms, 800ms);
169-
// pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
170-
// pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
171-
// pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
172-
// if (TAKE_PICTURES){
173-
// // Capture both summary screens
174-
// pbf_wait(context, 1000ms);
175-
// pbf_press_button(context, BUTTON_CAPTURE, 200ms, 1900ms);
176-
// pbf_move_left_joystick(context, {+1, 0}, 200ms, 1300ms);
177-
// pbf_press_button(context, BUTTON_CAPTURE, 200ms, 1800ms);
178-
// }else{
179-
// // view both summary screens
180-
// pbf_wait(context, 2000ms);
181-
// pbf_move_left_joystick(context, {+1, 0}, 200ms, 1300ms);
182-
// pbf_wait(context, 2500ms);
183-
// }
184-
185-
// context.wait_for_all_requests();
186-
// env.log("Encounter reached.");
187-
// }
188-
189142
void hard_reset(ProControllerContext& context){
190143
// close the game
191144
pbf_press_button(context, BUTTON_HOME, 200ms, 1300ms);
@@ -250,7 +203,7 @@ void go_to_starter_summary(ProControllerContext& context){
250203
}
251204

252205
void go_to_summary(ProControllerContext& context){
253-
// Navigate to summary (last party slot)
206+
// navigate to summary (last party slot)
254207
pbf_press_button(context, BUTTON_PLUS, 200ms, 800ms);
255208
pbf_move_left_joystick(context, {0, -1}, 200ms, 1300ms);
256209
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
@@ -262,16 +215,15 @@ void go_to_summary(ProControllerContext& context){
262215
}
263216

264217
bool use_sweet_scent(SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint64_t& DOUBLE_DELAY){
265-
// Navigate to last party slot
218+
// navigate to last party slot
266219
pbf_press_button(context, BUTTON_PLUS, 200ms, 800ms);
267220
pbf_move_left_joystick(context, {0, -1}, 200ms, 1800ms);
268221
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
269222
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
270223
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
271224
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
272-
// hover over Sweet Scent (2nd option, maybe HMs change this)
225+
// hover over Sweet Scent (2nd option, but maybe HMs could change this)
273226
pbf_move_left_joystick(context, {0, -1}, 200ms, std::chrono::milliseconds(DOUBLE_DELAY - 8400));
274-
// 8000ms
275227
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
276228
context.wait_for_all_requests();
277229
BlackScreenWatcher battle_entered(COLOR_RED);
@@ -383,46 +335,18 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
383335

384336
ShinySymbolDetector shiny_checker(COLOR_YELLOW);
385337
shiny_found = shiny_checker.read(env.console.logger(), screen);
386-
}else if (TARGET == Target::hitmon){
387-
OperationFailedException::fire(
388-
ErrorReport::SEND_ERROR_REPORT,
389-
"Hitmonchan/Hitmonlee hunt not implemented",
390-
env.console
391-
);
392-
}else if (TARGET == Target::eevee){
393-
OperationFailedException::fire(
394-
ErrorReport::SEND_ERROR_REPORT,
395-
"Eevee hunt not implemented",
396-
env.console
397-
);
398-
}else if (TARGET == Target::lapras){
399-
OperationFailedException::fire(
400-
ErrorReport::SEND_ERROR_REPORT,
401-
"Lapras hunt not implemented",
402-
env.console
403-
);
404-
}else if (TARGET == Target::fossils){
405-
OperationFailedException::fire(
406-
ErrorReport::SEND_ERROR_REPORT,
407-
"Fossil hunt not implemented",
408-
env.console
409-
);
410338
}else if (TARGET == Target::sweetscent){
411339
shiny_found = use_sweet_scent(env, context, DOUBLE_DELAY);
412340
context.wait_for_all_requests();
413-
}else if (TARGET == Target::wildwalk){
341+
env.log("Wild encounter started.");
342+
}else if (TARGET == Target::grasswalk){
414343
shiny_found = grass_walk_after_delay(env, context, DOUBLE_DELAY);
415344
context.wait_for_all_requests();
416-
}else if (TARGET == Target::fishing){
417-
OperationFailedException::fire(
418-
ErrorReport::SEND_ERROR_REPORT,
419-
"Fishing hunt not implemented",
420-
env.console
421-
);
345+
env.log("Wild encounter started.");
422346
}else{
423347
OperationFailedException::fire(
424348
ErrorReport::SEND_ERROR_REPORT,
425-
"Invalid RNG option",
349+
"Option not yet implemented.",
426350
env.console
427351
);
428352
}
@@ -440,6 +364,9 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
440364
screen,
441365
true
442366
);
367+
if (TAKE_VIDEO){
368+
pbf_press_button(context, BUTTON_CAPTURE, 2000ms, 0ms);
369+
}
443370
break;
444371
}else if (stats.resets >= NUM_RESETS){
445372
send_program_status_notification(

SerialPrograms/Source/PokemonFRLG/Programs/ShinyHunting/PokemonFRLG_RNGManipulator.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ class RNGManipulator : public SingleSwitchProgramInstance{
4141
enum class Target{
4242
starters,
4343
magikarp,
44-
hitmon,
45-
eevee,
46-
lapras,
47-
fossils,
44+
// hitmon,
45+
// eevee,
46+
// lapras,
47+
// fossils,
4848
sweetscent,
49-
wildwalk,
50-
fishing,
49+
grasswalk,
50+
// fishing,
51+
// static,
52+
// roaming
5153
};
5254

5355
EnumDropdownOption<Target> TARGET;
@@ -62,8 +64,8 @@ class RNGManipulator : public SingleSwitchProgramInstance{
6264

6365
BooleanCheckBoxOption TAKE_PICTURES;
6466

67+
BooleanCheckBoxOption TAKE_VIDEO;
6568
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
66-
6769
EventNotificationOption NOTIFICATION_SHINY;
6870
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
6971
EventNotificationsOption NOTIFICATIONS;

0 commit comments

Comments
 (0)