Skip to content
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
merged 34 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
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 Feb 9, 2024
bbba542
read quests infra
kichithewolf Feb 9, 2024
673d20f
categorize quests, process quest list
kichithewolf Feb 9, 2024
b6154ea
string to enum
kichithewolf Feb 10, 2024
0626969
make tm
kichithewolf Feb 10, 2024
5bc9ca4
travel 500 units
kichithewolf Feb 10, 2024
84579c6
read and process quests vector, photo fly swim
kichithewolf Feb 13, 2024
b940cef
photo: coastal, canyon, savanna
kichithewolf Feb 13, 2024
94fedab
tera to defeat a wild pokemon, bugfixes
kichithewolf Feb 14, 2024
e19c07b
catch quest, extra complete check, fix time option
kichithewolf Feb 16, 2024
ec2738b
sneak up, photo bug rock, some catchs
kichithewolf Feb 16, 2024
3f67c4b
catch photo ice, kill wild tera
kichithewolf Feb 17, 2024
ba1c78a
wash quest, some work on dark fight
kichithewolf Feb 18, 2024
72f2eb5
separate out catch and photo quests, cleanup
kichithewolf Feb 18, 2024
c5973c1
hatch egg quest
kichithewolf Feb 20, 2024
6f6fbae
sandwiches, num retries option, enable saving
kichithewolf Feb 20, 2024
4c9f589
tera raid, bbq terarium movement functions
kichithewolf Feb 23, 2024
4d4a92c
catch photo fairy dark fly, expand jump_glide_fly
kichithewolf Feb 24, 2024
d201fe9
photo catch electric
kichithewolf Feb 24, 2024
7aa5da4
catch photo steel poison
kichithewolf Feb 25, 2024
ff41bda
out of eggs options, catch photo fighting
kichithewolf Feb 26, 2024
0065577
catch water, fix time for egg option, bugfixes
kichithewolf Feb 26, 2024
7dd901b
unlock options, improve flying, bugfixes
kichithewolf Mar 1, 2024
1385796
catch ice is now lapras, improved make tm, fixes
kichithewolf Mar 2, 2024
b2731c3
autobattle 10/30, move to dev mode
kichithewolf Mar 3, 2024
baf9671
cleanup and fix warnings
kichithewolf Mar 3, 2024
89d89b7
sandwich and navigation fixes for rebase
kichithewolf Mar 31, 2024
3f5c314
remove unused bool
kichithewolf Mar 31, 2024
ac504dd
current_quest, remove unneeded
kichithewolf Apr 11, 2024
1c613b3
const bbq options, adjust num retries
kichithewolf Apr 12, 2024
29e0d8f
unlock options
kichithewolf Apr 12, 2024
a44f36d
throw ball for catch quest
kichithewolf Apr 13, 2024
2b44896
const ball, indentation
kichithewolf Apr 13, 2024
25a5ce3
const ref
kichithewolf Apr 13, 2024
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
8 changes: 8 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,8 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Options/PokemonSV_AutoHostOptions.h
Source/PokemonSV/Options/PokemonSV_BattleMoveTable.cpp
Source/PokemonSV/Options/PokemonSV_BattleMoveTable.h
Source/PokemonSV/Options/PokemonSV_BBQOption.cpp
Source/PokemonSV/Options/PokemonSV_BBQOption.h
Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp
Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.h
Source/PokemonSV/Options/PokemonSV_EncounterActionsTable.cpp
Expand Down Expand Up @@ -1428,6 +1430,12 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.h
Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.h
Source/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h
Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h
Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h
Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h
Source/PokemonSV/Programs/Farming/PokemonSV_FlyingTrialFarmer.cpp
Expand Down
103 changes: 103 additions & 0 deletions SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp
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
Copy link
Member

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

Copy link
Contributor Author

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.

image
image

)
, 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 SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.h
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
4 changes: 4 additions & 0 deletions SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Programs/Farming/PokemonSV_TournamentFarmer2.h"
#include "Programs/Farming/PokemonSV_FlyingTrialFarmer.h"
#include "Programs/Farming/PokemonSV_WildItemFarmer.h"
#include "Programs/Farming/PokemonSV_BBQSoloFarmer.h"

#include "Programs/Eggs/PokemonSV_EggFetcher.h"
#include "Programs/Eggs/PokemonSV_EggHatcher.h"
Expand Down Expand Up @@ -102,6 +103,9 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back(make_single_switch_program<TournamentFarmer_Descriptor, TournamentFarmer>());
ret.emplace_back(make_single_switch_program<TournamentFarmer2_Descriptor, TournamentFarmer2>());
ret.emplace_back(make_single_switch_program<FlyingTrialFarmer_Descriptor, FlyingTrialFarmer>());
if (PreloadSettings::instance().DEVELOPER_MODE) {
ret.emplace_back(make_single_switch_program<BBQSoloFarmer_Descriptor, BBQSoloFarmer>());
}

ret.emplace_back("---- Eggs ----");
ret.emplace_back(make_single_switch_program<EggFetcher_Descriptor, EggFetcher>());
Expand Down
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);
}

}
}
}
Loading