-
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 all commits
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
103 changes: 103 additions & 0 deletions
103
SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* BBQ Option | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#include <map> | ||
#include "PokemonSV_BBQOption.h" | ||
#include "PokemonSV/Inference/Boxes/PokemonSV_IvJudgeReader.h" | ||
|
||
namespace PokemonAutomation{ | ||
namespace NintendoSwitch{ | ||
namespace PokemonSV{ | ||
|
||
BBQOption::BBQOption(OCR::LanguageOCROption* language_option) | ||
: GroupOption( | ||
"Blueberry Quests", | ||
LockMode::UNLOCK_WHILE_RUNNING, | ||
false, true | ||
) | ||
, m_language_owner(language_option == nullptr | ||
? new OCR::LanguageOCROption( | ||
"<b>Game Language:</b><br>This is required to read quests.", | ||
IV_READER().languages(), | ||
LockMode::LOCK_WHILE_RUNNING, | ||
true | ||
) | ||
: nullptr | ||
) | ||
, LANGUAGE(language_option == nullptr ? *m_language_owner : *language_option) | ||
, NUM_QUESTS( | ||
"<b>Number of Quests to run:</b>", | ||
LockMode::UNLOCK_WHILE_RUNNING, | ||
1000 | ||
) | ||
, SAVE_NUM_QUESTS( | ||
"<b>Save and reset the game after attempting this many quests:</b><br>This preserves progress and prevents potential game lags from long runs.<br>0 disables this option.", | ||
LockMode::UNLOCK_WHILE_RUNNING, 50 | ||
) | ||
, INVERTED_FLIGHT( | ||
"<b>Inverted Flight:</b><br>Check this box if inverted flight controls are set.", | ||
LockMode::LOCK_WHILE_RUNNING, | ||
false | ||
) | ||
, QUICKBALL( | ||
"<b>Catch Quest - Throw Quick Ball:</b><br>When attempting to catch a non-tera Pokemon, use a Quick Ball on the first turn.", | ||
LockMode::UNLOCK_WHILE_RUNNING, | ||
true | ||
) | ||
, BALL_SELECT( | ||
"<b>Catch Quest - Ball Select:</b><br>What ball to use when performing a catch quest.", | ||
LockMode::UNLOCK_WHILE_RUNNING, | ||
"ultra-ball" | ||
) | ||
, NUM_EGGS( | ||
"<b>Hatch Quest - Number of Eggs:</b><br>Amount of eggs located in your current box.", | ||
LockMode::UNLOCK_WHILE_RUNNING, 30, 0, 30 | ||
) | ||
, OUT_OF_EGGS( | ||
"<b>Hatch Quest - Zero Eggs:</b><br>When out of eggs to hatch, do the selected option.", | ||
{ | ||
{OOEggs::Stop, "stop", "Stop Program"}, | ||
{OOEggs::Reroll, "reroll", "Reroll Quest - Costs 50BP"}, | ||
{OOEggs::KeepGoing, "keep-going", "Keep Going - Warning: Bonus(Red) quests will be blocked!"}, | ||
}, | ||
LockMode::UNLOCK_WHILE_RUNNING, | ||
OOEggs::Stop | ||
) | ||
, FIX_TIME_FOR_HATCH( | ||
"<b>Hatch Quest - Fix time for eggs:</b><br>Fix the time before doing a hatch egg quest.", | ||
LockMode::UNLOCK_WHILE_RUNNING, false | ||
) | ||
, CATCH_ON_WIN(true) | ||
, NUM_RETRIES( | ||
"<b>Number of Retries:</b><br>Reattempt a quest this many times if it fails.", | ||
LockMode::UNLOCK_WHILE_RUNNING, 1, 0, 5 | ||
) | ||
, FIX_TIME_WHEN_DONE( | ||
"<b>Fix time when done:</b><br>Fix the time after the program finishes.", | ||
LockMode::UNLOCK_WHILE_RUNNING, false | ||
) | ||
{ | ||
if (m_language_owner){ | ||
PA_ADD_OPTION(LANGUAGE); | ||
} | ||
PA_ADD_OPTION(NUM_QUESTS); | ||
PA_ADD_OPTION(SAVE_NUM_QUESTS); | ||
PA_ADD_OPTION(INVERTED_FLIGHT); | ||
PA_ADD_OPTION(QUICKBALL); | ||
PA_ADD_OPTION(BALL_SELECT); | ||
PA_ADD_OPTION(NUM_EGGS); | ||
PA_ADD_OPTION(OUT_OF_EGGS); | ||
PA_ADD_OPTION(FIX_TIME_FOR_HATCH); | ||
PA_ADD_OPTION(BATTLE_AI); | ||
PA_ADD_OPTION(CATCH_ON_WIN); | ||
PA_ADD_OPTION(NUM_RETRIES); | ||
PA_ADD_OPTION(FIX_TIME_WHEN_DONE); | ||
} | ||
|
||
|
||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.h
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* BBQ Option | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#ifndef PokemonAutomation_PokemonSV_BBQOption_H | ||
#define PokemonAutomation_PokemonSV_BBQOption_H | ||
|
||
#include "Common/Cpp/Options/StaticTextOption.h" | ||
#include "Common/Cpp/Options/GroupOption.h" | ||
#include "Common/Cpp/Options/EnumDropdownOption.h" | ||
#include "Common/Cpp/Options/SimpleIntegerOption.h" | ||
#include "Common/Cpp/Options/BooleanCheckBoxOption.h" | ||
#include "CommonFramework/Options/LanguageOCROption.h" | ||
#include "PokemonSwSh/Options/PokemonSwSh_BallSelectOption.h" | ||
#include "PokemonSV/Options/PokemonSV_BattleMoveTable.h" | ||
#include "PokemonSV/Options/PokemonSV_TeraAIOption.h" | ||
#include "PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.h" | ||
|
||
namespace PokemonAutomation{ | ||
namespace NintendoSwitch{ | ||
namespace PokemonSV{ | ||
|
||
class BBQOption : public GroupOption { | ||
|
||
public: | ||
// Include the language option in the box. | ||
BBQOption() | ||
: BBQOption(nullptr) | ||
{} | ||
|
||
// Don't include language option. Give it one instead. | ||
BBQOption(OCR::LanguageOCROption& language_option) | ||
: BBQOption(&language_option) | ||
{} | ||
|
||
private: | ||
std::unique_ptr<OCR::LanguageOCROption> m_language_owner; | ||
|
||
public: | ||
enum class OOEggs { | ||
Stop, | ||
Reroll, | ||
KeepGoing, | ||
}; | ||
|
||
OCR::LanguageOCROption& LANGUAGE; | ||
|
||
SimpleIntegerOption<uint64_t> NUM_QUESTS; | ||
SimpleIntegerOption<uint64_t> SAVE_NUM_QUESTS; | ||
|
||
BooleanCheckBoxOption INVERTED_FLIGHT; | ||
|
||
//For catching pokemon quests | ||
BooleanCheckBoxOption QUICKBALL; | ||
PokemonSwSh::PokemonBallSelectOption BALL_SELECT; | ||
//BattleMoveTable BATTLE_MOVES; No need, not catching legendaries. | ||
|
||
//For egg hatching quest | ||
SimpleIntegerOption<uint8_t> NUM_EGGS; | ||
EnumDropdownOption<OOEggs> OUT_OF_EGGS; | ||
BooleanCheckBoxOption FIX_TIME_FOR_HATCH; | ||
|
||
//Tera raid | ||
TeraAIOption BATTLE_AI; | ||
TeraFarmerCatchOnWin CATCH_ON_WIN; | ||
|
||
SimpleIntegerOption<uint8_t> NUM_RETRIES; | ||
|
||
BooleanCheckBoxOption FIX_TIME_WHEN_DONE; | ||
|
||
private: | ||
BBQOption(OCR::LanguageOCROption* language_option); | ||
}; | ||
|
||
} | ||
} | ||
} | ||
#endif |
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
168 changes: 168 additions & 0 deletions
168
SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp
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 |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* BBQ Solo Farmer | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#include "CommonFramework/InferenceInfra/InferenceRoutines.h" | ||
#include "CommonFramework/Notifications/ProgramNotifications.h" | ||
#include "CommonFramework/Tools/StatsTracking.h" | ||
#include "CommonFramework/Tools/VideoResolutionCheck.h" | ||
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" | ||
#include "NintendoSwitch/NintendoSwitch_Settings.h" | ||
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" | ||
#include "PokemonSV/Programs/PokemonSV_GameEntry.h" | ||
#include "PokemonSV/Programs/PokemonSV_SaveGame.h" | ||
#include "PokemonSV/Programs/PokemonSV_Navigation.h" | ||
#include "Pokemon/Pokemon_Strings.h" | ||
#include "PokemonSV/PokemonSV_Settings.h" | ||
#include "PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.h" | ||
#include "PokemonSV/Inference/Battles/PokemonSV_NormalBattleMenus.h" | ||
#include "PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h" | ||
#include "PokemonSV_BBQSoloFarmer.h" | ||
|
||
namespace PokemonAutomation { | ||
namespace NintendoSwitch { | ||
namespace PokemonSV { | ||
|
||
using namespace Pokemon; | ||
|
||
BBQSoloFarmer_Descriptor::BBQSoloFarmer_Descriptor() | ||
: SingleSwitchProgramDescriptor( | ||
"PokemonSV:BBQSoloFarmer", | ||
STRING_POKEMON + " SV", "BBQ Farmer", | ||
"ComputerControl/blob/master/Wiki/Programs/PokemonSV/BBQSoloFarmer.md", | ||
"Farm Blueberry Quests in the Terarium for BP.", | ||
FeedbackType::REQUIRED, | ||
AllowCommandsWhenRunning::DISABLE_COMMANDS, | ||
PABotBaseLevel::PABOTBASE_12KB | ||
) | ||
{} | ||
struct BBQSoloFarmer_Descriptor::Stats : public StatsTracker { | ||
Stats() | ||
: questsCompleted(m_stats["Quests Completed"]) | ||
, saves(m_stats["Saves"]) | ||
, errors(m_stats["Errors"]) | ||
{ | ||
m_display_order.emplace_back("Quests Completed"); | ||
m_display_order.emplace_back("Saves"); | ||
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO); | ||
} | ||
std::atomic<uint64_t>& questsCompleted; | ||
std::atomic<uint64_t>& saves; | ||
std::atomic<uint64_t>& errors; | ||
}; | ||
std::unique_ptr<StatsTracker> BBQSoloFarmer_Descriptor::make_stats() const { | ||
return std::unique_ptr<StatsTracker>(new Stats()); | ||
} | ||
BBQSoloFarmer::BBQSoloFarmer() | ||
: GO_HOME_WHEN_DONE(true) | ||
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) | ||
, NOTIFICATIONS({ | ||
&NOTIFICATION_STATUS_UPDATE, | ||
& NOTIFICATION_PROGRAM_FINISH, | ||
& NOTIFICATION_ERROR_FATAL, | ||
}) | ||
{ | ||
PA_ADD_OPTION(BBQ_OPTIONS); | ||
PA_ADD_OPTION(GO_HOME_WHEN_DONE); | ||
PA_ADD_OPTION(NOTIFICATIONS); | ||
} | ||
|
||
void BBQSoloFarmer::program(SingleSwitchProgramEnvironment& env, BotBaseContext& context) { | ||
assert_16_9_720p_min(env.logger(), env.console); | ||
BBQSoloFarmer_Descriptor::Stats& stats = env.current_stats<BBQSoloFarmer_Descriptor::Stats>(); | ||
|
||
//Fly to plaza | ||
open_map_from_overworld(env.program_info(), env.console, context); | ||
fly_to_overworld_from_map(env.program_info(), env.console, context); | ||
|
||
std::vector<BBQuests> quest_list; //all quests | ||
std::vector<BBQuests> quests_to_do; //do-able quests | ||
uint8_t eggs_hatched = 0; //Track eggs | ||
uint64_t num_completed_quests = 0; | ||
|
||
//Test a specific quest | ||
/* | ||
BBQuests test_quest = BBQuests::catch_bug; | ||
bool questTest = process_and_do_quest(env, env.console, context, BBQ_OPTIONS, test_quest, eggs_hatched); | ||
if (questTest) { | ||
env.log("Finished quest."); | ||
} | ||
*/ | ||
|
||
while (num_completed_quests < BBQ_OPTIONS.NUM_QUESTS) { | ||
if (BBQ_OPTIONS.OUT_OF_EGGS == BBQOption::OOEggs::Stop && eggs_hatched >= BBQ_OPTIONS.NUM_EGGS) { | ||
env.log("Stop when out of eggs selected. Stopping program."); | ||
break; | ||
} | ||
|
||
//Get and reroll quests until we can at least one | ||
while (quests_to_do.size() < 1) { | ||
quest_list = read_quests(env.program_info(), env.console, context, BBQ_OPTIONS); | ||
quests_to_do = process_quest_list(env.program_info(), env.console, context, BBQ_OPTIONS, quest_list, eggs_hatched); | ||
|
||
//Clear out the regular quest list. | ||
quest_list.clear(); | ||
} | ||
|
||
for (auto current_quest : quests_to_do) { | ||
//Check if quest was already completed (ex. 500 meters completed while navigating to take a photo) | ||
quest_list = read_quests(env.program_info(), env.console, context, BBQ_OPTIONS); | ||
if (std::find(quest_list.begin(), quest_list.end(), current_quest) != quest_list.end()) { | ||
env.log("Current quest exists on list. Doing quest."); | ||
bool questSuccess = process_and_do_quest(env, env.console, context, BBQ_OPTIONS, current_quest, eggs_hatched); | ||
if (questSuccess) { | ||
env.log("Quest completed successfully."); | ||
stats.questsCompleted++; | ||
env.update_stats(); | ||
num_completed_quests++; | ||
} | ||
else { | ||
env.log("Quest did not complete successfully."); | ||
} | ||
} | ||
else { | ||
//Note: This doesn't account for case such as "sneak up" being added and then completed alongside the next quest | ||
env.log("Current quest does not exist on list. Quest completed at some point."); | ||
stats.questsCompleted++; | ||
env.update_stats(); | ||
num_completed_quests++; | ||
} | ||
quest_list.clear(); | ||
} | ||
//Clear out the todo list | ||
quests_to_do.clear(); | ||
|
||
uint64_t temp_save_num_option = BBQ_OPTIONS.SAVE_NUM_QUESTS; | ||
if (temp_save_num_option != 0 && num_completed_quests % temp_save_num_option == 0) { | ||
env.log("Saving and resetting."); | ||
save_game_from_overworld(env.program_info(), env.console, context); | ||
reset_game(env.program_info(), env.console, context); | ||
stats.saves++; | ||
} | ||
|
||
env.update_stats(); | ||
send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE); | ||
} | ||
env.update_stats(); | ||
|
||
if (BBQ_OPTIONS.FIX_TIME_WHEN_DONE) { | ||
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY); | ||
home_to_date_time(context, false, false); | ||
pbf_press_button(context, BUTTON_A, 20, 105); | ||
pbf_press_button(context, BUTTON_A, 20, 105); | ||
pbf_press_button(context, BUTTON_HOME, 20, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY); | ||
resume_game_from_home(env.console, context); | ||
|
||
open_map_from_overworld(env.program_info(), env.console, context); | ||
fly_to_overworld_from_map(env.program_info(), env.console, context); | ||
} | ||
|
||
GO_HOME_WHEN_DONE.run_end_of_program(context); | ||
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Any reason not to do KeepGoing ? From my experience, it seems you can "stack up" red quest, meaining even if you do not complete the current red quest, you're already working on unlocking the next red quest
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.
It only stacks up an additional two red quests. The bar fills green->gold->red and then stops there.