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
38 changes: 38 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,44 @@ int grass_spin(ConsoleHandle& console, ProControllerContext& context, bool leftr
return encounter_shiny ? 1 : 0;
}

int fish_encounter(ConsoleHandle& console, ProControllerContext& context, Seconds timeout){
WhiteDialogWatcher fishing_dialog(COLOR_RED);
BlackScreenWatcher battle_entered(COLOR_RED);
AdvanceBattleDialogWatcher battle_dialog(COLOR_RED);
BattleMenuWatcher battle_menu(COLOR_RED);

context.wait_for_all_requests();
console.log("Starting fish encounter.");
WallClock start = current_time();

while (true){
if (current_time() - start > timeout){
console.log("No pokemon hooked after timeout.");
return -1;
}

pbf_press_button(context, BUTTON_MINUS, 200ms, 200ms);
context.wait_for_all_requests();

int ret = wait_until(
console, context,
std::chrono::milliseconds(2000),
{ fishing_dialog, battle_entered, battle_dialog, battle_menu }
);

if (ret == 0){
console.log("Fishing dialog detected.");
pbf_press_button(context, BUTTON_B, 200ms, 200ms);
context.wait_for_all_requests();
} else if (ret == 1 || ret == 2 || ret == 3){
console.log("Battle entered.");
break;
}
}

bool encounter_shiny = handle_encounter(console, context, true);
return encounter_shiny ? 1 : 0;
}

}
}
Expand Down
4 changes: 4 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ void heal_at_pokecenter(ConsoleHandle& console, ProControllerContext& context);
// returns -1 if no encounter is triggered, 0 if a non-shiny is encounter, and 1 if a shiny is encountered
int grass_spin(ConsoleHandle& console, ProControllerContext& context, bool leftright, Seconds timeout = 60s);

// Trigger encounters by fishing with a registered rod. The player must be facing water.
// returns -1 if no encounter is triggered, 0 if a non-shiny is encounter, and 1 if a shiny is encountered
int fish_encounter(ConsoleHandle& console, ProControllerContext& context, Seconds timeout = 300s);

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

Expand Down
Loading
Loading