Skip to content

Commit cb5a532

Browse files
authored
Merge pull request #588 from kichithewolf/bbq-updates
BBQ updates
2 parents a2eccab + dfacac8 commit cb5a532

File tree

4 files changed

+258
-28
lines changed

4 files changed

+258
-28
lines changed

SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,127 @@ namespace PokemonAutomation{
1212
namespace NintendoSwitch{
1313
namespace PokemonSV{
1414

15+
//Does not include multiplayer quests
16+
const EnumDropdownDatabase<BBQuests>& BBQuests_database(){
17+
static EnumDropdownDatabase<BBQuests> database{
18+
{BBQuests::auto_10, "auto-10", "Defeat 10 wild Pokemon using Auto Battle!"},
19+
{BBQuests::make_tm, "make-tm", "Make yourself a TM!"},
20+
//{BBQuests::pickup_10, "pickup-10", "Pick up items on the ground 10 times!"},
21+
{BBQuests::sneak_up, "sneak-up", "Successfully sneak up on 1 Pokemon and surprise them with a battle!"},
22+
{BBQuests::photo_fly, "photo-fly", "Take a photo of a wild Pokemon in flight!"},
23+
{BBQuests::photo_swim, "photo-swim", "Take a photo of a wild Pokemon that is swimming!"},
24+
{BBQuests::photo_canyon, "photo-canyon", "Take a photo of a wild Pokemon in the Canyon Biome!"},
25+
{BBQuests::photo_coastal, "photo-coastal", "Take a photo of a wild Pokemon in the Coastal Biome!"},
26+
{BBQuests::photo_polar, "photo-polar", "Take a photo of a wild Pokemon in the Polar Biome!"},
27+
{BBQuests::photo_savanna, "photo-savanna", "Take a photo of a wild Pokemon in the Savanna Biome!"},
28+
{BBQuests::tera_self_defeat,"tera-self-defeat", "Terastallize your Pokemon to defeat a wild Pokemon!"},
29+
{BBQuests::travel_500, "travel-500", "Travel over 500 yards!"},
30+
{BBQuests::catch_any, "catch-any", "Catch 1 Pokemon!"},
31+
{BBQuests::catch_normal, "catch-normal", "Catch 1 Normal-type Pokemon!"},
32+
{BBQuests::catch_fighting, "catch-fighting", "Catch 1 Fighting-type Pokemon!"},
33+
{BBQuests::catch_flying, "catch-flying", "Catch 1 Flying-type Pokemon!"},
34+
{BBQuests::catch_poison, "catch-poison", "Catch 1 Poison-type Pokemon!"},
35+
{BBQuests::catch_ground, "catch-ground", "Catch 1 Ground-type Pokemon!"},
36+
{BBQuests::catch_rock, "catch-rock", "Catch 1 Rock-type Pokemon!"},
37+
{BBQuests::catch_bug, "catch-bug", "Catch 1 Bug-type Pokemon!"},
38+
{BBQuests::catch_ghost, "catch-ghost", "Catch 1 Ghost-type Pokemon!"},
39+
{BBQuests::catch_steel, "catch-steel", "Catch 1 Steel-type Pokemon!"},
40+
{BBQuests::catch_fire, "catch-fire", "Catch 1 Fire-type Pokemon!"},
41+
{BBQuests::catch_water, "catch-water", "Catch 1 Water-type Pokemon!"},
42+
{BBQuests::catch_grass, "catch-grass", "Catch 1 Grass-type Pokemon!"},
43+
{BBQuests::catch_electric, "catch-electric", "Catch 1 Electric-type Pokemon!"},
44+
{BBQuests::catch_psychic, "catch-psychic", "Catch 1 Psychic-type Pokemon!"},
45+
{BBQuests::catch_ice, "catch-ice", "Catch 1 Ice-type Pokemon!"},
46+
{BBQuests::catch_dragon, "catch-dragon", "Catch 1 Dragon-type Pokemon!"},
47+
{BBQuests::catch_dark, "catch-dark", "Catch 1 Dark-type Pokemon!"},
48+
{BBQuests::catch_fairy, "catch-fairy", "Catch 1 Fairy-type Pokemon!"},
49+
{BBQuests::wash_pokemon, "wash-pokemon", "Give your Pokemon a nice washing!"},
50+
{BBQuests::wild_tera, "wild-tera", "Battle a wild Tera Pokemon!"},
51+
{BBQuests::auto_30, "auto-30", "Defeat 30 wild Pokemon using Auto Battle!"},
52+
{BBQuests::tera_raid, "tera-raid", "Claim victory in a Tera Raid Battle!"},
53+
{BBQuests::sandwich_three, "sandwich-three", "Make a sandwich that uses at least 3 ingredients!"},
54+
{BBQuests::bitter_sandwich, "bitter-sandwich", "Make a bitter sandwich!"},
55+
{BBQuests::sweet_sandwich, "sweet-sandwich", "Make a sweet sandwich!"},
56+
{BBQuests::salty_sandwich, "salty-sandwich", "Make a salty sandwich!"},
57+
{BBQuests::sour_sandwich, "sour-sandwich", "Make a sour sandwich!"},
58+
{BBQuests::spicy_sandwich, "spicy-sandwich", "Make a spicy sandwich!"},
59+
//{BBQuests::hatch_egg, "hatch-egg", "Hatch a Pokemon Egg!"},
60+
{BBQuests::photo_normal, "photo-normal", "Take a photo of a wild Normal-type Pokemon!"},
61+
{BBQuests::photo_fighting, "photo-fighting", "Take a photo of a wild Fighting-type Pokemon!"},
62+
{BBQuests::photo_flying, "photo-flying", "Take a photo of a wild Flying-type Pokemon!"},
63+
{BBQuests::photo_poison, "photo-poison", "Take a photo of a wild Poison-type Pokemon!"},
64+
{BBQuests::photo_ground, "photo-ground", "Take a photo of a wild Ground-type Pokemon!"},
65+
{BBQuests::photo_rock, "photo-rock", "Take a photo of a wild Rock-type Pokemon!"},
66+
{BBQuests::photo_bug, "photo-bug", "Take a photo of a wild Bug-type Pokemon!"},
67+
{BBQuests::photo_ghost, "photo-ghost", "Take a photo of a wild Ghost-type Pokemon!"},
68+
{BBQuests::photo_steel, "photo-steel", "Take a photo of a wild Steel-type Pokemon!"},
69+
{BBQuests::photo_fire, "photo-fire", "Take a photo of a wild Fire-type Pokemon!"},
70+
{BBQuests::photo_water, "photo-water", "Take a photo of a wild Water-type Pokemon!"},
71+
{BBQuests::photo_grass, "photo-grass", "Take a photo of a wild Grass-type Pokemon!"},
72+
{BBQuests::photo_electric, "photo-electric", "Take a photo of a wild Electric-type Pokemon!"},
73+
{BBQuests::photo_psychic, "photo-psychic", "Take a photo of a wild Psychic-type Pokemon!"},
74+
{BBQuests::photo_ice, "photo-ice", "Take a photo of a wild Ice-type Pokemon!"},
75+
{BBQuests::photo_dragon, "photo-dragon", "Take a photo of a wild Dragon-type Pokemon!"},
76+
{BBQuests::photo_dark, "photo-dark", "Take a photo of a wild Dark-type Pokemon!"},
77+
{BBQuests::photo_fairy, "photo-fairy", "Take a photo of a wild Fairy-type Pokemon!"},
78+
};
79+
return database;
80+
}
81+
82+
const EnumDropdownDatabase<BBQAction>& BBQAction_database(){
83+
static EnumDropdownDatabase<BBQAction> database{
84+
{BBQAction::run, "run", "Run Quest"},
85+
{BBQAction::skip, "skip", "Skip"},
86+
{BBQAction::reroll, "reroll", "Reroll"},
87+
};
88+
return database;
89+
}
90+
91+
BBQuestTableRow::BBQuestTableRow(EditableTableOption& parent_table)
92+
: EditableTableRow(parent_table)
93+
, quest(BBQuests_database(), LockMode::UNLOCK_WHILE_RUNNING, BBQuests::auto_10)
94+
, action(BBQAction_database(), LockMode::UNLOCK_WHILE_RUNNING, BBQAction::skip)
95+
{
96+
PA_ADD_OPTION(quest);
97+
PA_ADD_OPTION(action);
98+
}
99+
std::unique_ptr<EditableTableRow> BBQuestTableRow::clone() const{
100+
std::unique_ptr<BBQuestTableRow> ret(new BBQuestTableRow(parent()));
101+
ret->quest.set(quest);
102+
ret->action.set(action);
103+
return ret;
104+
}
105+
106+
BBQuestTable::BBQuestTable()
107+
: EditableTableOption_t<BBQuestTableRow>(
108+
"<b>Quest Exclusions:</b><br>"
109+
"<b>Warning: Skipping Bonus quests will block the bonus slot.</b><br>"
110+
"Exclude the quests in the table. If you want to skip a quest, select it below. "
111+
"(Quests can be explicitly included, but this is not necessary.) "
112+
"Do not exclude too many quests, as rerolling costs BP. "
113+
"The program will automatically reroll all quests if none are possible, but will not handle being out of BP. "
114+
"Does not include egg hatching or pickup quests, as eggs are handled in other options and pickup is not possible. ",
115+
//"Duplicates of the same quest",
116+
//duplicates will work in table order. might lead to weird behavior like rerolling and then marking a quest as complete.
117+
//won't break the program though.
118+
LockMode::LOCK_WHILE_RUNNING,
119+
make_defaults()
120+
)
121+
{}
122+
123+
std::vector<std::string> BBQuestTable::make_header() const{
124+
return {
125+
"Quest",
126+
"Action",
127+
};
128+
}
129+
std::vector<std::unique_ptr<EditableTableRow>> BBQuestTable::make_defaults(){
130+
std::vector<std::unique_ptr<EditableTableRow>> ret;
131+
ret.emplace_back(new BBQuestTableRow(*this));
132+
return ret;
133+
}
134+
135+
15136
BBQOption::BBQOption(OCR::LanguageOCROption* language_option)
16137
: GroupOption("Blueberry Quests", LockMode::UNLOCK_WHILE_RUNNING)
17138
, m_language_owner(language_option == nullptr
@@ -81,6 +202,7 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option)
81202
}
82203
PA_ADD_OPTION(NUM_QUESTS);
83204
PA_ADD_OPTION(SAVE_NUM_QUESTS);
205+
PA_ADD_OPTION(QUEST_EXCLUSIONS);
84206
PA_ADD_OPTION(INVERTED_FLIGHT);
85207
PA_ADD_OPTION(QUICKBALL);
86208
PA_ADD_OPTION(BALL_SELECT);

SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "Common/Cpp/Options/GroupOption.h"
1111
#include "Common/Cpp/Options/EnumDropdownOption.h"
12+
#include "Common/Cpp/Options/EditableTableOption.h"
1213
#include "Common/Cpp/Options/SimpleIntegerOption.h"
1314
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
1415
#include "CommonTools/Options/LanguageOCROption.h"
@@ -20,6 +21,47 @@ namespace PokemonAutomation{
2021
namespace NintendoSwitch{
2122
namespace PokemonSV{
2223

24+
enum class BBQuests{
25+
auto_10, make_tm, pickup_10, sneak_up, photo_fly, photo_swim, photo_canyon, photo_coastal, photo_polar, photo_savanna, tera_self_defeat,
26+
travel_500, catch_any, catch_normal, catch_fighting, catch_flying, catch_poison, catch_ground, catch_rock, catch_bug, catch_ghost, catch_steel,
27+
catch_fire, catch_water, catch_grass, catch_electric, catch_psychic, catch_ice, catch_dragon, catch_dark, catch_fairy,
28+
wash_pokemon, wild_tera, auto_30, tera_raid, sandwich_three, bitter_sandwich, sweet_sandwich, salty_sandwich, sour_sandwich, spicy_sandwich, hatch_egg,
29+
photo_normal, photo_fighting, photo_flying, photo_poison, photo_ground, photo_rock, photo_bug, photo_ghost, photo_steel, photo_fire, photo_water,
30+
photo_grass, photo_electric, photo_psychic, photo_ice, photo_dragon, photo_dark, photo_fairy,
31+
ditto_central, ditto_canyon, ditto_coastal, ditto_polar, ditto_savanna, group_canyon, group_coastal, group_polar, group_savanna, group_eyewear, group_nonuniform,
32+
group_masks, sandwich_four, catch_hint, catch_hint2,
33+
UnableToDetect
34+
};
35+
36+
enum class BBQAction{
37+
run,
38+
skip,
39+
reroll
40+
};
41+
42+
//Quest exclusion table
43+
const EnumDropdownDatabase<BBQuests>& BBQuests_database();
44+
45+
class BBQuestTableRow : public EditableTableRow{
46+
public:
47+
BBQuestTableRow(EditableTableOption& parent_table);
48+
virtual std::unique_ptr<EditableTableRow> clone() const override;
49+
50+
public:
51+
EnumDropdownCell<BBQuests> quest;
52+
EnumDropdownCell<BBQAction> action;
53+
};
54+
55+
class BBQuestTable : public EditableTableOption_t<BBQuestTableRow>{
56+
public:
57+
BBQuestTable();
58+
59+
virtual std::vector<std::string> make_header() const;
60+
std::vector<std::unique_ptr<EditableTableRow>> make_defaults();
61+
};
62+
63+
64+
//BBQ Options
2365
class BBQOption : public GroupOption{
2466

2567
public:
@@ -48,6 +90,8 @@ class BBQOption : public GroupOption{
4890
SimpleIntegerOption<uint64_t> NUM_QUESTS;
4991
SimpleIntegerOption<uint64_t> SAVE_NUM_QUESTS;
5092

93+
BBQuestTable QUEST_EXCLUSIONS;
94+
5195
BooleanCheckBoxOption INVERTED_FLIGHT;
5296

5397
//For catching pokemon quests

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ std::vector<BBQuests> process_quest_list(
229229
uint8_t& eggs_hatched
230230
){
231231
std::vector<BBQuests> quests_to_do;
232+
bool rerolled = false;
233+
std::vector<std::unique_ptr<BBQuestTableRow>> exclusions_table = BBQ_OPTIONS.QUEST_EXCLUSIONS.copy_snapshot();
234+
int questpos = 0;
232235

233236
stream.log("Processing quests.");
234237
//Put all do-able quests into a different list
@@ -268,6 +271,7 @@ std::vector<BBQuests> process_quest_list(
268271
pbf_wait(context, 100);
269272
context.wait_for_all_requests();
270273

274+
rerolled = true;
271275
press_Bs_to_back_to_overworld(info, stream, context);
272276

273277
break;
@@ -285,26 +289,97 @@ std::vector<BBQuests> process_quest_list(
285289
);
286290
break;
287291
}
288-
}else{
289-
stream.log("Quest possible");
290-
quests_to_do.push_back(n);
292+
}
293+
else{
294+
bool quest_in_table = false;
295+
for(const std::unique_ptr<BBQuestTableRow>& row : exclusions_table){
296+
if(n == row->quest) {
297+
stream.log("Quest found in inclusions/exclusions table.");
298+
quest_in_table = true;
299+
300+
WhiteButtonWatcher rp2(COLOR_BLUE, WhiteButton::ButtonB, {0.484, 0.117, 0.022, 0.037});
301+
int result2;
302+
switch (row->action) {
303+
case BBQAction::run:
304+
stream.log("Run selected. Adding quest to list.");
305+
quests_to_do.push_back(n);
306+
break;
307+
case BBQAction::reroll:
308+
stream.log("Reroll selected. Rerolling quest. New quest will be run in the next batch of quests.");
309+
result2 = run_until<ProControllerContext>(
310+
stream, context,
311+
[&](ProControllerContext& context){
312+
for (int i = 0; i < 6; i++){
313+
pbf_press_dpad(context, DPAD_RIGHT, 50, 20);
314+
pbf_wait(context, 200);
315+
context.wait_for_all_requests();
316+
}
317+
},
318+
{{ rp2 }}
319+
);
320+
if (result2 == 0){
321+
stream.log("Found quest panel.");
322+
}
323+
context.wait_for_all_requests();
324+
325+
//Move cursor down to quest
326+
for (int i = 0; i < questpos; i++) {
327+
pbf_press_dpad(context, DPAD_DOWN, 20, 20);
328+
pbf_wait(context, 100);
329+
context.wait_for_all_requests();
330+
}
331+
332+
//Reroll
333+
pbf_press_button(context, BUTTON_A, 20, 50);
334+
pbf_press_button(context, BUTTON_A, 20, 50);
335+
pbf_wait(context, 100);
336+
context.wait_for_all_requests();
337+
338+
//Prevent error/rerolling again at the end (allows program to read the rerolled quests)
339+
rerolled = true;
340+
341+
press_Bs_to_back_to_overworld(info, stream, context);
342+
break;
343+
case BBQAction::skip:
344+
stream.log("Skip selected. Skipping quest.");
345+
break;
346+
}
347+
}
348+
}
349+
if(!quest_in_table){
350+
stream.log("Quest not in inclusion/exclusions table. Adding to list.");
351+
quests_to_do.push_back(n);
352+
}
291353
}
292354
}
355+
questpos++;
293356
}
294-
295-
/*
296-
Old logic that assumes most quests are not possible. Written when first starting on the program.
297-
Should not be necessary anymore. Keeping around in case anyone wants to try making a multiplayer version.
298357

299358
//Check that quests_to_do is not empty (after completing all quests on the list, be sure to erase it.
300359
//Lag might be a problem in multi - look into making slots like menu-left navigation
301-
if (quests_to_do.size() == 0){
302-
console.log("No possible quests! Rerolling all quests.");
360+
if (!rerolled && quests_to_do.size() == 0){
361+
stream.log("No possible quests! Rerolling all quests.");
303362

304-
//Open quest panel - see above
305-
//Reroll all.
363+
//Open quest panel and reroll all quests.
306364
//This does not handle out of BP.
307-
for (int i = 0; i < quest_list.size(); i++){
365+
WhiteButtonWatcher panel(COLOR_BLUE, WhiteButton::ButtonB, {0.484, 0.117, 0.022, 0.037});
366+
int result = run_until<ProControllerContext>(
367+
stream, context,
368+
[&](ProControllerContext& context){
369+
for (int i = 0; i < 6; i++){
370+
pbf_press_dpad(context, DPAD_RIGHT, 50, 20);
371+
pbf_wait(context, 200);
372+
context.wait_for_all_requests();
373+
}
374+
},
375+
{{ panel }}
376+
);
377+
if (result == 0){
378+
stream.log("Found quest panel.");
379+
}
380+
context.wait_for_all_requests();
381+
382+
for (string::size_type i = 0; i < quest_list.size(); i++){
308383
pbf_press_button(context, BUTTON_A, 20, 50);
309384
pbf_press_button(context, BUTTON_A, 20, 50); //Yes.
310385
pbf_wait(context, 100);
@@ -314,16 +389,17 @@ std::vector<BBQuests> process_quest_list(
314389
context.wait_for_all_requests();
315390
}
316391
//Close quest panel - mash b
317-
}*/
318-
319-
if (quests_to_do.size() == 0){
392+
press_Bs_to_back_to_overworld(info, stream, context);
393+
}
394+
/*
395+
if (!rerolled && quests_to_do.size() == 0){
320396
OperationFailedException::fire(
321397
ErrorReport::SEND_ERROR_REPORT,
322398
"No possible quests! Check language selection.",
323399
stream
324400
);
325401
}
326-
402+
*/
327403
return quests_to_do;
328404
}
329405

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ namespace PokemonAutomation{
1717
namespace NintendoSwitch{
1818
namespace PokemonSV{
1919

20-
enum class BBQuests{
21-
auto_10, make_tm, pickup_10, sneak_up, photo_fly, photo_swim, photo_canyon, photo_coastal, photo_polar, photo_savanna, tera_self_defeat,
22-
travel_500, catch_any, catch_normal, catch_fighting, catch_flying, catch_poison, catch_ground, catch_rock, catch_bug, catch_ghost, catch_steel,
23-
catch_fire, catch_water, catch_grass, catch_electric, catch_psychic, catch_ice, catch_dragon, catch_dark, catch_fairy,
24-
wash_pokemon, wild_tera, auto_30, tera_raid, sandwich_three, bitter_sandwich, sweet_sandwich, salty_sandwich, sour_sandwich, spicy_sandwich, hatch_egg,
25-
photo_normal, photo_fighting, photo_flying, photo_poison, photo_ground, photo_rock, photo_bug, photo_ghost, photo_steel, photo_fire, photo_water,
26-
photo_grass, photo_electric, photo_psychic, photo_ice, photo_dragon, photo_dark, photo_fairy,
27-
ditto_central, ditto_canyon, ditto_coastal, ditto_polar, ditto_savanna, group_canyon, group_coastal, group_polar, group_savanna, group_eyewear, group_nonuniform,
28-
group_masks, sandwich_four, catch_hint, catch_hint2,
29-
UnableToDetect
30-
};
31-
3220
BBQuests BBQuests_string_to_enum(const std::string& token);
3321

3422
enum class CameraAngle{

0 commit comments

Comments
 (0)