Skip to content

Commit 3257be6

Browse files
committed
add sweet scent
1 parent c70a96f commit 3257be6

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,38 @@ void go_to_summary(ProControllerContext& context){
256256
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
257257
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
258258
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
259+
// open summary
259260
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
260261
pbf_press_button(context, BUTTON_A, 200ms, 2300ms);
261262
}
262263

264+
bool use_sweet_scent(SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint64_t& DOUBLE_DELAY){
265+
// Navigate to last party slot
266+
pbf_press_button(context, BUTTON_PLUS, 200ms, 800ms);
267+
pbf_move_left_joystick(context, {0, -1}, 200ms, 1800ms);
268+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
269+
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
270+
pbf_move_left_joystick(context, {0, +1}, 200ms, 1300ms);
271+
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
272+
// hover over Sweet Scent (2nd option, maybe HMs change this)
273+
pbf_move_left_joystick(context, {0, -1}, 200ms, std::chrono::milliseconds(DOUBLE_DELAY - 8400));
274+
// 8000ms
275+
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
276+
context.wait_for_all_requests();
277+
BlackScreenWatcher battle_entered(COLOR_RED);
278+
run_until<ProControllerContext>(
279+
env.console, context,
280+
[](ProControllerContext& context) {
281+
while (true){
282+
pbf_wait(context, 100ms);
283+
}
284+
},
285+
{ battle_entered }
286+
);
287+
bool encounter_shiny = handle_encounter(env.console, context, false);
288+
return encounter_shiny;
289+
}
290+
263291
void take_summary_pictures(ProControllerContext& context){
264292
// Capture both summary screens
265293
pbf_wait(context, 2000ms);
@@ -302,7 +330,6 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
302330
RNGManipulator_Descriptor::Stats& stats = env.current_stats<RNGManipulator_Descriptor::Stats>();
303331

304332
bool shiny_found = false;
305-
uint64_t num_resets = 0;
306333

307334
double FRAMERATE = 59.7275; // valid for GBA, but not sure for Switch
308335
uint64_t LOAD_DELAY;
@@ -381,11 +408,8 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
381408
env.console
382409
);
383410
}else if (TARGET == Target::sweetscent){
384-
OperationFailedException::fire(
385-
ErrorReport::SEND_ERROR_REPORT,
386-
"Sweet Scent hunt not implemented",
387-
env.console
388-
);
411+
shiny_found = use_sweet_scent(env, context, DOUBLE_DELAY);
412+
context.wait_for_all_requests();
389413
}else if (TARGET == Target::wildwalk){
390414
shiny_found = grass_walk_after_delay(env, context, DOUBLE_DELAY);
391415
context.wait_for_all_requests();
@@ -403,8 +427,7 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
403427
);
404428
}
405429

406-
num_resets++;
407-
430+
stats.resets++;
408431
if (shiny_found){
409432
env.log("Shiny found!");
410433
stats.shinies++;
@@ -418,7 +441,7 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
418441
true
419442
);
420443
break;
421-
}else if (num_resets >= NUM_RESETS){
444+
}else if (stats.resets >= NUM_RESETS){
422445
send_program_status_notification(
423446
env, NOTIFICATION_STATUS_UPDATE,
424447
"Maximum resets reached."
@@ -431,7 +454,6 @@ void RNGManipulator::program(SingleSwitchProgramEnvironment& env, ProControllerC
431454
env, NOTIFICATION_STATUS_UPDATE,
432455
"Resetting."
433456
);
434-
stats.resets++;
435457
env.update_stats();
436458
context.wait_for_all_requests();
437459
}

0 commit comments

Comments
 (0)