-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BBQ Solo Farmer #407
Merged
Mysticial
merged 34 commits into
PokemonAutomation:main
from
kichithewolf:BBQ-solo-farm
Apr 13, 2024
Merged
BBQ Solo Farmer #407
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8798cac
BBQ farmer, options, functions file created
kichithewolf bbba542
read quests infra
kichithewolf 673d20f
categorize quests, process quest list
kichithewolf b6154ea
string to enum
kichithewolf 0626969
make tm
kichithewolf 5bc9ca4
travel 500 units
kichithewolf 84579c6
read and process quests vector, photo fly swim
kichithewolf b940cef
photo: coastal, canyon, savanna
kichithewolf 94fedab
tera to defeat a wild pokemon, bugfixes
kichithewolf e19c07b
catch quest, extra complete check, fix time option
kichithewolf ec2738b
sneak up, photo bug rock, some catchs
kichithewolf 3f67c4b
catch photo ice, kill wild tera
kichithewolf ba1c78a
wash quest, some work on dark fight
kichithewolf 72f2eb5
separate out catch and photo quests, cleanup
kichithewolf c5973c1
hatch egg quest
kichithewolf 6f6fbae
sandwiches, num retries option, enable saving
kichithewolf 4c9f589
tera raid, bbq terarium movement functions
kichithewolf 4d4a92c
catch photo fairy dark fly, expand jump_glide_fly
kichithewolf d201fe9
photo catch electric
kichithewolf 7aa5da4
catch photo steel poison
kichithewolf ff41bda
out of eggs options, catch photo fighting
kichithewolf 0065577
catch water, fix time for egg option, bugfixes
kichithewolf 7dd901b
unlock options, improve flying, bugfixes
kichithewolf 1385796
catch ice is now lapras, improved make tm, fixes
kichithewolf b2731c3
autobattle 10/30, move to dev mode
kichithewolf baf9671
cleanup and fix warnings
kichithewolf 89d89b7
sandwich and navigation fixes for rebase
kichithewolf 3f5c314
remove unused bool
kichithewolf ac504dd
current_quest, remove unneeded
kichithewolf 1c613b3
const bbq options, adjust num retries
kichithewolf 29e0d8f
unlock options
kichithewolf a44f36d
throw ball for catch quest
kichithewolf 2b44896
const ball, indentation
kichithewolf 25a5ce3
const ref
kichithewolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
#include "PokemonSV_BlueberryQuests.h" | ||
|
||
#include<vector> | ||
#include "PokemonSV_BlueberryCatchPhoto.h" | ||
|
||
namespace PokemonAutomation{ | ||
namespace NintendoSwitch{ | ||
|
@@ -324,9 +325,10 @@ void quest_photo(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext | |
static_cast<AudioInferenceCallback&>(encounter_watcher), | ||
} | ||
); | ||
if (ret == 0) { | ||
encounter_watcher.throw_if_no_sound(); | ||
|
||
if (ret >= 0) { | ||
console.log("Battle menu detected."); | ||
encounter_watcher.throw_if_no_sound(); | ||
|
||
bool is_shiny = (bool)encounter_watcher.shiny_screenshot(); | ||
if (is_shiny) { | ||
|
@@ -608,6 +610,57 @@ void quest_catch_navi(const ProgramInfo& info, ConsoleHandle& console, BotBaseCo | |
|
||
} | ||
|
||
void quest_catch_throw_ball(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context, Language language, std::string selected_ball) { | ||
BattleBallReader reader(console, language); | ||
std::string ball_reader = ""; | ||
WallClock start = current_time(); | ||
|
||
console.log("Opening ball menu..."); | ||
while (ball_reader == "") { | ||
if (current_time() - start > std::chrono::minutes(2)) { | ||
console.log("Timed out trying to read ball after 2 minutes.", COLOR_RED); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Timed out trying to read ball after 2 minutes.", | ||
true | ||
); | ||
} | ||
|
||
//Mash B to exit anything else | ||
pbf_mash_button(context, BUTTON_B, 125); | ||
context.wait_for_all_requests(); | ||
|
||
//Press X to open Ball menu | ||
pbf_press_button(context, BUTTON_X, 20, 100); | ||
context.wait_for_all_requests(); | ||
|
||
VideoSnapshot screen = console.video().snapshot(); | ||
ball_reader = reader.read_ball(screen); | ||
} | ||
|
||
console.log("Selecting ball."); | ||
int quantity = move_to_ball(reader, console, context, selected_ball); | ||
if (quantity == 0) { | ||
console.log("Unable to find ball."); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Unable to find ball.", | ||
true | ||
); | ||
} | ||
if (quantity < 0) { | ||
console.log("Unable to read ball quantity.", COLOR_RED); | ||
} | ||
|
||
//Throw ball | ||
console.log("Throwing ball."); | ||
pbf_mash_button(context, BUTTON_A, 150); | ||
context.wait_for_all_requests(); | ||
|
||
pbf_mash_button(context, BUTTON_B, 900); | ||
context.wait_for_all_requests(); | ||
} | ||
|
||
void quest_catch_handle_battle(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context, const BBQOption& BBQ_OPTIONS, BBQuests current_quest) { | ||
console.log("Catching Pokemon."); | ||
AdvanceDialogWatcher advance_dialog(COLOR_MAGENTA); | ||
|
@@ -664,158 +717,71 @@ void quest_catch_handle_battle(const ProgramInfo& info, ConsoleHandle& console, | |
//Do not throw if target is a tera pokemon. | ||
if (use_quickball && !quickball_thrown && tera_target == false) { | ||
console.log("Quick Ball option checked. Throwing Quick Ball."); | ||
BattleBallReader reader(console, BBQ_OPTIONS.LANGUAGE); | ||
std::string ball_reader = ""; | ||
WallClock start = current_time(); | ||
|
||
console.log("Opening ball menu..."); | ||
while (ball_reader == "") { | ||
if (current_time() - start > std::chrono::minutes(2)) { | ||
console.log("Timed out trying to read ball after 2 minutes.", COLOR_RED); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Timed out trying to read ball after 2 minutes.", | ||
true | ||
); | ||
} | ||
|
||
//Mash B to exit anything else | ||
pbf_mash_button(context, BUTTON_B, 125); | ||
context.wait_for_all_requests(); | ||
|
||
//Press X to open Ball menu | ||
pbf_press_button(context, BUTTON_X, 20, 100); | ||
context.wait_for_all_requests(); | ||
|
||
VideoSnapshot screen = console.video().snapshot(); | ||
ball_reader = reader.read_ball(screen); | ||
} | ||
|
||
console.log("Selecting Quick Ball."); | ||
int quantity = move_to_ball(reader, console, context, "quick-ball"); | ||
if (quantity == 0) { | ||
//Stop so user can check they have quick balls. | ||
console.log("Unable to find Quick Ball on turn 1."); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Unable to find Quick Ball on turn 1.", | ||
true | ||
); | ||
} | ||
if (quantity < 0) { | ||
console.log("Unable to read ball quantity.", COLOR_RED); | ||
} | ||
|
||
//Throw ball | ||
console.log("Throwing Quick Ball."); | ||
pbf_mash_button(context, BUTTON_A, 150); | ||
context.wait_for_all_requests(); | ||
|
||
quest_catch_throw_ball(info, console, context, BBQ_OPTIONS.LANGUAGE, "quick-ball"); | ||
quickball_thrown = true; | ||
pbf_mash_button(context, BUTTON_B, 900); | ||
context.wait_for_all_requests(); | ||
} | ||
else { | ||
BattleBallReader reader(console, BBQ_OPTIONS.LANGUAGE); | ||
std::string ball_reader = ""; | ||
WallClock start = current_time(); | ||
|
||
console.log("Opening ball menu..."); | ||
while (ball_reader == "") { | ||
if (current_time() - start > std::chrono::minutes(2)) { | ||
console.log("Timed out trying to read ball after 2 minutes.", COLOR_RED); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Timed out trying to read ball after 2 minutes.", | ||
true | ||
); | ||
} | ||
|
||
//Mash B to exit anything else | ||
pbf_mash_button(context, BUTTON_B, 125); | ||
context.wait_for_all_requests(); | ||
console.log("Throwing selected ball."); | ||
quest_catch_throw_ball(info, console, context, BBQ_OPTIONS.LANGUAGE, BBQ_OPTIONS.BALL_SELECT.slug()); | ||
} | ||
|
||
//Press X to open Ball menu | ||
pbf_press_button(context, BUTTON_X, 20, 100); | ||
//Check for battle menu, if found use fourth attack this turn | ||
NormalBattleMenuWatcher battle_menu(COLOR_YELLOW); | ||
int ret = wait_until( | ||
console, context, | ||
std::chrono::seconds(4), | ||
{ battle_menu } | ||
); | ||
if (ret == 0) { | ||
console.log("Battle menu detected early. Using fourth attack."); | ||
MoveSelectWatcher move_watcher(COLOR_BLUE); | ||
MoveSelectDetector move_select(COLOR_BLUE); | ||
|
||
int ret_move_select = run_until( | ||
console, context, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation |
||
[&](BotBaseContext& context) { | ||
pbf_press_button(context, BUTTON_A, 10, 50); | ||
pbf_wait(context, 100); | ||
context.wait_for_all_requests(); | ||
|
||
VideoSnapshot screen = console.video().snapshot(); | ||
ball_reader = reader.read_ball(screen); | ||
} | ||
|
||
console.log("Selecting ball."); | ||
int quantity = move_to_ball(reader, console, context, BBQ_OPTIONS.BALL_SELECT.slug()); | ||
if (quantity == 0) { | ||
console.log("Unable to find appropriate ball/out of balls."); | ||
break; | ||
}, | ||
{ move_watcher } | ||
); | ||
if (ret_move_select != 0) { | ||
console.log("Could not find move select."); | ||
} | ||
if (quantity < 0) { | ||
console.log("Unable to read ball quantity.", COLOR_RED); | ||
else { | ||
console.log("Move select found!"); | ||
} | ||
|
||
//Throw ball | ||
console.log("Throwing selected ball."); | ||
context.wait_for_all_requests(); | ||
move_select.move_to_slot(console, context, 3); | ||
pbf_mash_button(context, BUTTON_A, 150); | ||
pbf_wait(context, 100); | ||
context.wait_for_all_requests(); | ||
|
||
//Check for battle menu, if found use fourth attack this turn | ||
NormalBattleMenuWatcher battle_menu(COLOR_YELLOW); | ||
int ret = wait_until( | ||
//Check for battle menu | ||
//If found after a second, assume out of PP and stop as this is a setup issue | ||
//None of the target pokemon for this program have disable, taunt, etc. | ||
NormalBattleMenuWatcher battle_menu2(COLOR_YELLOW); | ||
int ret3 = wait_until( | ||
console, context, | ||
std::chrono::seconds(4), | ||
{ battle_menu } | ||
{ battle_menu2 } | ||
); | ||
if (ret == 0) { | ||
console.log("Battle menu detected early. Using fourth attack."); | ||
MoveSelectWatcher move_watcher(COLOR_BLUE); | ||
MoveSelectDetector move_select(COLOR_BLUE); | ||
|
||
int ret_move_select = run_until( | ||
console, context, | ||
[&](BotBaseContext& context) { | ||
pbf_press_button(context, BUTTON_A, 10, 50); | ||
pbf_wait(context, 100); | ||
context.wait_for_all_requests(); | ||
}, | ||
{ move_watcher } | ||
); | ||
if (ret_move_select != 0) { | ||
console.log("Could not find move select."); | ||
} | ||
else { | ||
console.log("Move select found!"); | ||
} | ||
|
||
context.wait_for_all_requests(); | ||
move_select.move_to_slot(console, context, 3); | ||
pbf_mash_button(context, BUTTON_A, 150); | ||
pbf_wait(context, 100); | ||
context.wait_for_all_requests(); | ||
|
||
//Check for battle menu | ||
//If found after a second, assume out of PP and stop as this is a setup issue | ||
//None of the target pokemon for this program have disable, taunt, etc. | ||
NormalBattleMenuWatcher battle_menu2(COLOR_YELLOW); | ||
int ret3 = wait_until( | ||
console, context, | ||
std::chrono::seconds(4), | ||
{ battle_menu2 } | ||
if (ret3 == 0) { | ||
console.log("Battle menu detected early. Out of PP/No move in slot, please check your setup."); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Battle menu detected early. Out of PP, please check your setup.", | ||
true | ||
); | ||
if (ret3 == 0) { | ||
console.log("Battle menu detected early. Out of PP/No move in slot, please check your setup."); | ||
throw OperationFailedException( | ||
ErrorReport::SEND_ERROR_REPORT, console, | ||
"Battle menu detected early. Out of PP, please check your setup.", | ||
true | ||
); | ||
} | ||
} | ||
else { | ||
//Wild pokemon's turn/wait for catch animation | ||
pbf_mash_button(context, BUTTON_B, 900); | ||
context.wait_for_all_requests(); | ||
} | ||
} | ||
else { | ||
//Wild pokemon's turn/wait for catch animation | ||
pbf_mash_button(context, BUTTON_B, 900); | ||
context.wait_for_all_requests(); | ||
} | ||
} | ||
|
||
NormalBattleMenuWatcher battle_menu(COLOR_YELLOW); | ||
|
@@ -900,9 +866,10 @@ void quest_catch(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext | |
static_cast<AudioInferenceCallback&>(encounter_watcher), | ||
} | ||
); | ||
if (ret == 0) { | ||
encounter_watcher.throw_if_no_sound(); | ||
|
||
if (ret >= 0) { | ||
console.log("Battle menu detected."); | ||
encounter_watcher.throw_if_no_sound(); | ||
|
||
bool is_shiny = (bool)encounter_watcher.shiny_screenshot(); | ||
if (is_shiny) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string selected_ball
->const std::string& selected_ball
since it's not being modified and is not a primitive.