Skip to content
Closed
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 @@ -656,6 +656,36 @@ TeraEncounterAction tera_encounter_action(
return TeraEncounterAction::Recover;
}

bool send_out_and_look_around(
ConsoleHandle& console, ProControllerContext& context,
std::chrono::seconds first_wait, const std::string& target
){
auto try_battle = [&](std::chrono::seconds timeout){
ssf_press_button(context, BUTTON_ZR, 0ms, 1600ms);
ssf_press_button(context, BUTTON_ZL, 800ms, 400ms);
ssf_press_button(context, BUTTON_ZL, 1200ms, 400ms);

pbf_wait(context, 2400ms);
context.wait_for_all_requests();

NormalBattleMenuWatcher battle_menu(COLOR_YELLOW);
return wait_until(console, context, timeout, { battle_menu }) == 0;
};

if (try_battle(first_wait)){
return true;
}
for (int turn = 1; turn <= 3; turn++){
console.log("Did not enter battle. Did " + target + " spawn? Looking around (" + std::to_string(turn) + "/3).");
pbf_move_right_joystick(context, {+1, 0}, 480ms, 320ms);
if (try_battle(std::chrono::seconds(6))){
return true;
}
}
console.log("Did not enter battle after looking around.");
return false;
}

void quest_tera_self_defeat(
const ProgramInfo& info,
ConsoleHandle& console, ProControllerContext& context,
Expand All @@ -680,23 +710,9 @@ void quest_tera_self_defeat(
jump_glide_fly(console, context, BBQ_OPTIONS.INVERTED_FLIGHT, 8000ms, 12800ms, 2400ms);
}

ssf_press_button(context, BUTTON_ZR, 0ms, 1600ms);
ssf_press_button(context, BUTTON_ZL, 800ms, 400ms);
ssf_press_button(context, BUTTON_ZL, 1200ms, 400ms);

pbf_wait(context, 2400ms);
context.wait_for_all_requests();

NormalBattleMenuWatcher battle_menu(COLOR_YELLOW);
int ret2 = wait_until(
console, context,
std::chrono::seconds(15),
{ battle_menu }
);
battle_menu_detected = ret2 == 0;
if (!battle_menu_detected){
console.log("Did not enter battle. Did Kleavor spawn?");
}
//The glide lands in the right place, but Kleavor is absent ~40% of the time.
//Any wild Pokemon counts, and Scyther roam the area.
battle_menu_detected = send_out_and_look_around(console, context, std::chrono::seconds(15), "Kleavor");
},
{
static_cast<VisualInferenceCallback&>(encounter_watcher),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef PokemonAutomation_PokemonSV_BlueberryQuests_H
#define PokemonAutomation_PokemonSV_BlueberryQuests_H

#include <chrono>
#include <string>
#include <vector>
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
Expand Down Expand Up @@ -97,6 +99,14 @@ void quest_travel_500(
);

//Run around until you encounter a pokemon. Tera, then defeat it by spamming your first move.
// Send out the lead at whatever is in front and wait for a battle. If none starts,
// turn the camera about a quarter at a time, up to three times, and try again.
// Returns true once the battle menu shows.
bool send_out_and_look_around(
ConsoleHandle& console, ProControllerContext& context,
std::chrono::seconds first_wait, const std::string& target
);

void quest_tera_self_defeat(
const ProgramInfo& info,
ConsoleHandle& console, ProControllerContext& context,
Expand Down
Loading