diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp
index 431763d87c..034cb78f8d 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.cpp
@@ -194,6 +194,12 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option)
"Fix Time when Done:
Fix the time after the program finishes.",
LockMode::UNLOCK_WHILE_RUNNING, false
)
+ , SAVE_TARGET_DIAGNOSTICS(
+ "Save Target Diagnostics:
For catch, Sneak Up and photo quests, save a frame at each step of reaching the target to DebugDumps/BBQ/targets/. "
+ "When the target may not have been reached, also save the stream history there, if it is enabled in the global settings. "
+ "For finding out why these quests fail. The log records each attempt either way.",
+ LockMode::UNLOCK_WHILE_RUNNING, false
+ )
{
if (m_language_owner){
PA_ADD_OPTION(LANGUAGE);
@@ -211,6 +217,7 @@ BBQOption::BBQOption(OCR::LanguageOCROption* language_option)
PA_ADD_OPTION(CATCH_ON_WIN);
PA_ADD_OPTION(NUM_RETRIES);
PA_ADD_OPTION(FIX_TIME_WHEN_DONE);
+ PA_ADD_OPTION(SAVE_TARGET_DIAGNOSTICS);
}
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h
index f5715a10c7..c1eaabb1bb 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h
@@ -101,6 +101,8 @@ class BBQOption : public GroupOption{
BooleanCheckBoxOption FIX_TIME_WHEN_DONE;
+ BooleanCheckBoxOption SAVE_TARGET_DIAGNOSTICS;
+
private:
BBQOption(OCR::LanguageOCROption* language_option);
};
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.cpp
new file mode 100644
index 0000000000..4f65662b8d
--- /dev/null
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.cpp
@@ -0,0 +1,160 @@
+/* BBQ Target Diagnostics
+ *
+ * From: https://github.com/PokemonAutomation/
+ *
+ */
+
+#include
+#include
+#include "Common/Cpp/PrettyPrint.h"
+#include "Common/Cpp/Filesystem/Filesystem.h"
+#include "CommonFramework/GlobalAutoPaths.h"
+#include "PokemonSV_BBQTargetDiagnostics.h"
+
+namespace PokemonAutomation{
+namespace NintendoSwitch{
+namespace PokemonSV{
+
+
+namespace{
+
+std::string quest_slug(BBQuests quest){
+ const EnumEntry* entry = BBQuests_database().find(quest);
+ return entry == nullptr ? "unknown" : entry->slug;
+}
+
+std::string seconds_to_string(std::chrono::milliseconds elapsed){
+ std::ostringstream out;
+ out << std::fixed << std::setprecision(1) << elapsed.count() / 1000.0 << "s";
+ return out.str();
+}
+
+std::string target_diagnostics_directory(){
+ return DEBUG_PATH() + "BBQ/targets/";
+}
+
+}
+
+
+TargetAttemptOutcome classify_target_attempt(const TargetAttemptSignals& signals){
+ switch (signals.kind){
+ case TargetAttemptKind::battle:
+ if (signals.encounter_detected){
+ return TargetAttemptOutcome::battle_entered;
+ }
+ return signals.battle_menu_seen
+ ? TargetAttemptOutcome::battle_menu_without_encounter
+ : TargetAttemptOutcome::no_battle;
+ case TargetAttemptKind::photo:
+ if (signals.encounter_detected){
+ return TargetAttemptOutcome::battle_during_photo;
+ }
+ return signals.photo_prompt_seen
+ ? TargetAttemptOutcome::photo_prompt_seen
+ : TargetAttemptOutcome::photo_prompt_timeout;
+ }
+ return TargetAttemptOutcome::no_battle;
+}
+
+const char* target_attempt_outcome_to_string(TargetAttemptOutcome outcome){
+ switch (outcome){
+ case TargetAttemptOutcome::battle_entered: return "battle-entered";
+ case TargetAttemptOutcome::no_battle: return "no-battle";
+ case TargetAttemptOutcome::battle_menu_without_encounter: return "battle-menu-without-encounter";
+ case TargetAttemptOutcome::photo_prompt_seen: return "photo-prompt-seen";
+ case TargetAttemptOutcome::photo_prompt_timeout: return "photo-prompt-timeout";
+ case TargetAttemptOutcome::battle_during_photo: return "battle-during-photo";
+ }
+ return "unknown";
+}
+
+bool target_attempt_needs_history(TargetAttemptOutcome outcome){
+ switch (outcome){
+ case TargetAttemptOutcome::battle_entered:
+ case TargetAttemptOutcome::photo_prompt_seen:
+ return false;
+ case TargetAttemptOutcome::no_battle:
+ case TargetAttemptOutcome::battle_menu_without_encounter:
+ case TargetAttemptOutcome::photo_prompt_timeout:
+ case TargetAttemptOutcome::battle_during_photo:
+ return true;
+ }
+ return true;
+}
+
+std::string target_attempt_summary(
+ BBQuests quest,
+ const TargetAttemptSignals& signals,
+ std::chrono::milliseconds elapsed
+){
+ std::ostringstream out;
+ out << "BBQ event=target-attempt quest=" << quest_slug(quest)
+ << " outcome=" << target_attempt_outcome_to_string(classify_target_attempt(signals))
+ << " encounter=" << signals.encounter_detected;
+ switch (signals.kind){
+ case TargetAttemptKind::battle:
+ out << " battle_menu=" << signals.battle_menu_seen;
+ break;
+ case TargetAttemptKind::photo:
+ out << " photo_prompt=" << signals.photo_prompt_seen;
+ break;
+ }
+ out << " elapsed=" << seconds_to_string(elapsed);
+ return out.str();
+}
+
+
+TargetAttemptRecorder::TargetAttemptRecorder(VideoStream& stream, BBQuests quest, bool save_files)
+ : m_stream(stream)
+ , m_quest(quest)
+ , m_save_files(save_files)
+ , m_start(current_time())
+ , m_file_prefix(target_diagnostics_directory() + now_to_filestring() + "-" + quest_slug(quest))
+{}
+
+void TargetAttemptRecorder::checkpoint(const std::string& name){
+ const auto elapsed = std::chrono::duration_cast(current_time() - m_start);
+ m_stream.log(
+ "BBQ event=target-checkpoint quest=" + quest_slug(m_quest)
+ + " checkpoint=" + name + " elapsed=" + seconds_to_string(elapsed)
+ );
+ if (m_save_files){
+ m_frames.emplace_back(name, m_stream.video().snapshot());
+ }
+}
+
+TargetAttemptOutcome TargetAttemptRecorder::finish(const TargetAttemptSignals& signals){
+ const auto elapsed = std::chrono::duration_cast(current_time() - m_start);
+ m_stream.log(target_attempt_summary(m_quest, signals, elapsed));
+
+ const TargetAttemptOutcome outcome = classify_target_attempt(signals);
+ if (!m_save_files){
+ return outcome;
+ }
+
+ try{
+ Filesystem::create_directories(Filesystem::Path(target_diagnostics_directory()));
+ }catch (...){}
+
+ for (const auto& [name, frame] : m_frames){
+ const std::string path = m_file_prefix + "-" + name + ".png";
+ const bool saved = frame && frame->save(path);
+ m_stream.log("BBQ event=target-file saved=" + std::to_string(saved) + " path=" + path);
+ }
+ m_frames.clear();
+
+ // The stream history covers the approach that led here, if the user has
+ // turned it on in the global settings.
+ if (target_attempt_needs_history(outcome)){
+ const std::string path = m_file_prefix + "-approach.mp4";
+ const bool saved = m_stream.save_stream_history(path);
+ m_stream.log("BBQ event=target-file saved=" + std::to_string(saved) + " path=" + path);
+ }
+ return outcome;
+}
+
+
+
+}
+}
+}
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.h
new file mode 100644
index 0000000000..90b29ae19b
--- /dev/null
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.h
@@ -0,0 +1,99 @@
+/* BBQ Target Diagnostics
+ *
+ * From: https://github.com/PokemonAutomation/
+ *
+ * Records how each attempt to reach a catch, Sneak Up or photo target went,
+ * to find out why so many attempts never find their target. It only observes:
+ * it sends no controller commands and changes no decision.
+ *
+ */
+
+#ifndef PokemonAutomation_PokemonSV_BBQTargetDiagnostics_H
+#define PokemonAutomation_PokemonSV_BBQTargetDiagnostics_H
+
+#include
+#include
+#include
+#include
+#include "Common/Cpp/Time.h"
+#include "CommonFramework/Tools/VideoStream.h"
+#include "CommonFramework/VideoPipeline/VideoFeed.h"
+#include "VideoGames/PokemonSV/Options/PokemonSV_BBQOption.h"
+
+namespace PokemonAutomation{
+namespace NintendoSwitch{
+namespace PokemonSV{
+
+
+enum class TargetAttemptKind{
+ battle, // Catch and Sneak Up: lock on to the target to start a battle.
+ photo, // Photo: frame the target and take a picture.
+};
+
+enum class TargetAttemptOutcome{
+ battle_entered,
+ no_battle,
+ // The battle menu showed up, but the encounter watcher did not fire, so
+ // the route treats the attempt as if no battle started.
+ battle_menu_without_encounter,
+ photo_prompt_seen,
+ // Not proof the photo failed: some photo quests still complete.
+ photo_prompt_timeout,
+ battle_during_photo,
+};
+
+// What the route's detectors reported for one attempt.
+struct TargetAttemptSignals{
+ TargetAttemptKind kind = TargetAttemptKind::battle;
+ bool encounter_detected = false;
+ bool battle_menu_seen = false; // Battle routes only.
+ bool photo_prompt_seen = false; // Photo routes only.
+};
+
+TargetAttemptOutcome classify_target_attempt(const TargetAttemptSignals& signals);
+const char* target_attempt_outcome_to_string(TargetAttemptOutcome outcome);
+
+// Whether the stream history before this outcome is worth keeping: it is,
+// whenever the target may not have been reached.
+bool target_attempt_needs_history(TargetAttemptOutcome outcome);
+
+// The log line for an attempt, in the same "BBQ event=..." form as the other
+// BBQ logs so run audits can grep for it.
+std::string target_attempt_summary(
+ BBQuests quest,
+ const TargetAttemptSignals& signals,
+ std::chrono::milliseconds elapsed
+);
+
+
+// Records one attempt: logs each checkpoint and the outcome. With
+// "save_files", it also saves the frame at each checkpoint, and the stream
+// history when the target may not have been reached, under
+// DebugDumps/BBQ/targets/. Files are written in finish(), after the attempt,
+// so saving them never delays a controller command during the approach.
+class TargetAttemptRecorder{
+public:
+ TargetAttemptRecorder(VideoStream& stream, BBQuests quest, bool save_files);
+
+ // Logs a checkpoint and keeps the current frame. Call it only where the
+ // route already waits for its commands to finish, so the frame shows the
+ // result of the commands sent so far.
+ void checkpoint(const std::string& name);
+
+ TargetAttemptOutcome finish(const TargetAttemptSignals& signals);
+
+private:
+ VideoStream& m_stream;
+ const BBQuests m_quest;
+ const bool m_save_files;
+ const WallClock m_start;
+ const std::string m_file_prefix;
+ std::vector> m_frames;
+};
+
+
+
+}
+}
+}
+#endif
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
index aa8ef76ecb..4ffda9141c 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
@@ -9,6 +9,7 @@
#include "Tests/ImageUnitTest.h"
#include "VideoGames/PokemonSV/Inference/PokemonSV_BlueberryPointsReader.h"
#include "VideoGames/PokemonSV/Options/PokemonSV_BBQuests.h"
+#include "PokemonSV_BBQTargetDiagnostics.h"
#include "PokemonSV_BlueberryQuests.h"
#include "PokemonSV_BBQTests.h"
@@ -122,6 +123,135 @@ static void add_tests_TeraEncounterAction(UnitTestDatabase& database){
}
+namespace{
+
+struct BBQTargetAttemptScenario{
+ std::string name;
+ BBQuests quest = BBQuests::catch_any;
+ TargetAttemptSignals signals;
+ TargetAttemptOutcome expected_outcome = TargetAttemptOutcome::no_battle;
+ bool expected_needs_history = false;
+ std::string expected_summary;
+};
+
+class Test_BBQTargetAttempt : public UnitTest{
+public:
+ Test_BBQTargetAttempt(BBQTargetAttemptScenario scenario)
+ : UnitTest("PokemonSV::BBQTargetAttempt - " + scenario.name)
+ , m_scenario(std::move(scenario))
+ {}
+
+ virtual UnitTestResult run(Logger&, CancellableScope&) const override{
+ const TargetAttemptOutcome outcome = classify_target_attempt(m_scenario.signals);
+ if (outcome != m_scenario.expected_outcome){
+ return std::string("Expected outcome ") + target_attempt_outcome_to_string(m_scenario.expected_outcome)
+ + ", got " + target_attempt_outcome_to_string(outcome);
+ }
+ const bool needs_history = target_attempt_needs_history(outcome);
+ if (needs_history != m_scenario.expected_needs_history){
+ return std::string("Expected needs_history=") + (m_scenario.expected_needs_history ? "true" : "false")
+ + ", got " + (needs_history ? "true" : "false");
+ }
+ const std::string summary = target_attempt_summary(
+ m_scenario.quest, m_scenario.signals, std::chrono::milliseconds(41300)
+ );
+ if (summary != m_scenario.expected_summary){
+ return "Expected summary: " + m_scenario.expected_summary + "\nActual summary: " + summary;
+ }
+ return true;
+ }
+
+private:
+ const BBQTargetAttemptScenario m_scenario;
+};
+
+}
+
+static void add_tests_BBQTargetAttempt(UnitTestDatabase& database){
+ const BBQTargetAttemptScenario scenarios[] = {
+ {
+ .name = "catch enters battle",
+ .signals = {
+ .kind = TargetAttemptKind::battle,
+ .encounter_detected = true,
+ },
+ .expected_outcome = TargetAttemptOutcome::battle_entered,
+ .expected_needs_history = false,
+ .expected_summary = "BBQ event=target-attempt quest=catch-any outcome=battle-entered encounter=1 battle_menu=0 elapsed=41.3s",
+ },
+ {
+ // The failure behind "Did not enter battle. Did target spawn?".
+ .name = "catch finds no battle",
+ .signals = {
+ .kind = TargetAttemptKind::battle,
+ },
+ .expected_outcome = TargetAttemptOutcome::no_battle,
+ .expected_needs_history = true,
+ .expected_summary = "BBQ event=target-attempt quest=catch-any outcome=no-battle encounter=0 battle_menu=0 elapsed=41.3s",
+ },
+ {
+ .name = "sneak up finds no battle",
+ .quest = BBQuests::sneak_up,
+ .signals = {
+ .kind = TargetAttemptKind::battle,
+ },
+ .expected_outcome = TargetAttemptOutcome::no_battle,
+ .expected_needs_history = true,
+ .expected_summary = "BBQ event=target-attempt quest=sneak-up outcome=no-battle encounter=0 battle_menu=0 elapsed=41.3s",
+ },
+ {
+ // The route only acts on the encounter watcher, so it treats this
+ // as no battle: a detector disagreement, not a missing target.
+ .name = "battle menu without the encounter watcher",
+ .quest = BBQuests::catch_normal,
+ .signals = {
+ .kind = TargetAttemptKind::battle,
+ .battle_menu_seen = true,
+ },
+ .expected_outcome = TargetAttemptOutcome::battle_menu_without_encounter,
+ .expected_needs_history = true,
+ .expected_summary = "BBQ event=target-attempt quest=catch-normal outcome=battle-menu-without-encounter encounter=0 battle_menu=1 elapsed=41.3s",
+ },
+ {
+ .name = "photo prompt seen",
+ .quest = BBQuests::photo_savanna,
+ .signals = {
+ .kind = TargetAttemptKind::photo,
+ .photo_prompt_seen = true,
+ },
+ .expected_outcome = TargetAttemptOutcome::photo_prompt_seen,
+ .expected_needs_history = false,
+ .expected_summary = "BBQ event=target-attempt quest=photo-savanna outcome=photo-prompt-seen encounter=0 photo_prompt=1 elapsed=41.3s",
+ },
+ {
+ .name = "photo prompt timeout",
+ .quest = BBQuests::photo_savanna,
+ .signals = {
+ .kind = TargetAttemptKind::photo,
+ },
+ .expected_outcome = TargetAttemptOutcome::photo_prompt_timeout,
+ .expected_needs_history = true,
+ .expected_summary = "BBQ event=target-attempt quest=photo-savanna outcome=photo-prompt-timeout encounter=0 photo_prompt=0 elapsed=41.3s",
+ },
+ {
+ // A wild battle cuts the photo route short; the route retries.
+ .name = "battle during photo",
+ .quest = BBQuests::photo_coastal,
+ .signals = {
+ .kind = TargetAttemptKind::photo,
+ .encounter_detected = true,
+ },
+ .expected_outcome = TargetAttemptOutcome::battle_during_photo,
+ .expected_needs_history = true,
+ .expected_summary = "BBQ event=target-attempt quest=photo-coastal outcome=battle-during-photo encounter=1 photo_prompt=0 elapsed=41.3s",
+ },
+ };
+ for (const BBQTargetAttemptScenario& scenario : scenarios){
+ database.add(scenario);
+ }
+}
+
+
void add_tests_BBQ(UnitTestDatabase& database){
database.add();
@@ -134,6 +264,7 @@ void add_tests_BBQ(UnitTestDatabase& database){
database.add("PokemonSV/BlueberryPoints/6740.png", 6740, 1280, 720);
add_tests_TeraEncounterAction(database);
+ add_tests_BBQTargetAttempt(database);
}
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp
index 3a24e1d187..a43f05c306 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp
@@ -26,6 +26,7 @@
#include "VideoGames/PokemonSV/Programs/PokemonSV_WorldNavigation.h"
#include "VideoGames/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h"
#include "VideoGames/PokemonSV/Programs/PokemonSV_Terarium.h"
+#include "PokemonSV_BBQTargetDiagnostics.h"
#include "PokemonSV_BlueberryCatchPhoto.h"
namespace PokemonAutomation{
@@ -289,6 +290,8 @@ void quest_photo(
CameraAngle move_camera = CameraAngle::none;
while(!took_photo){
+ TargetAttemptRecorder recorder(console, current_quest, BBQ_OPTIONS.SAVE_TARGET_DIAGNOSTICS);
+ bool photo_prompt_seen = false;
EncounterWatcher encounter_watcher(console, COLOR_RED);
int ret = run_until(
console, context,
@@ -311,6 +314,7 @@ void quest_photo(
pbf_move_right_joystick(context, {0, -1}, 400ms, 160ms);
}
context.wait_for_all_requests();
+ recorder.checkpoint("before-shutter");
pbf_press_button(context, BUTTON_A, 160ms, 400ms);
@@ -319,9 +323,11 @@ void quest_photo(
std::chrono::seconds(10),
{ photo_prompt }
);
+ photo_prompt_seen = ret == 0;
if (ret != 0){
console.log("Photo not taken.");
}
+ recorder.checkpoint(photo_prompt_seen ? "photo-prompt" : "photo-prompt-timeout");
//Mash B until overworld
int exit = run_until(
@@ -342,6 +348,11 @@ void quest_photo(
static_cast(encounter_watcher),
}
);
+ recorder.finish({
+ .kind = TargetAttemptKind::photo,
+ .encounter_detected = ret >= 0,
+ .photo_prompt_seen = photo_prompt_seen,
+ });
encounter_watcher.throw_if_no_sound();
if (ret >= 0){
@@ -899,6 +910,8 @@ void quest_catch(
const BBQOption& BBQ_OPTIONS,
BBQuests current_quest
){
+ TargetAttemptRecorder recorder(console, current_quest, BBQ_OPTIONS.SAVE_TARGET_DIAGNOSTICS);
+ bool battle_menu_seen = false;
EncounterWatcher encounter_watcher(console, COLOR_RED);
//Navigate to target and start battle
@@ -908,6 +921,7 @@ void quest_catch(
quest_catch_navi(info, console, context, BBQ_OPTIONS, current_quest);
context.wait_for_all_requests();
+ recorder.checkpoint("after-lock-on");
NormalBattleMenuWatcher battle_menu(COLOR_YELLOW);
int ret2 = wait_until(
@@ -915,8 +929,10 @@ void quest_catch(
std::chrono::seconds(25),
{ battle_menu }
);
+ battle_menu_seen = ret2 == 0;
if (ret2 != 0){
console.log("Did not enter battle. Did target spawn?");
+ recorder.checkpoint("battle-entry-timeout");
}
},
{
@@ -924,6 +940,11 @@ void quest_catch(
static_cast(encounter_watcher),
}
);
+ recorder.finish({
+ .kind = TargetAttemptKind::battle,
+ .encounter_detected = ret >= 0,
+ .battle_menu_seen = battle_menu_seen,
+ });
encounter_watcher.throw_if_no_sound();
if (ret >= 0){
diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp
index c90bae7a04..f7a7688c61 100644
--- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp
+++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp
@@ -42,6 +42,7 @@
#include "VideoGames/PokemonSV/Programs/TeraRaids/PokemonSV_TeraBattler.h"
#include "VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.h"
#include "VideoGames/PokemonSV/Programs/PokemonSV_Terarium.h"
+#include "PokemonSV_BBQTargetDiagnostics.h"
#include "PokemonSV_BlueberryQuests.h"
@@ -661,6 +662,8 @@ void quest_sneak_up(
ConsoleHandle& console, ProControllerContext& context,
const BBQOption& BBQ_OPTIONS
){
+ TargetAttemptRecorder recorder(console, BBQuests::sneak_up, BBQ_OPTIONS.SAVE_TARGET_DIAGNOSTICS);
+ bool battle_menu_seen = false;
EncounterWatcher encounter_watcher(console, COLOR_RED);
console.log("Quest: Sneak up.");
//Navigate to target and start battle
@@ -693,6 +696,7 @@ void quest_sneak_up(
pbf_wait(context, 2400ms);
context.wait_for_all_requests();
+ recorder.checkpoint("after-lock-on");
NormalBattleMenuWatcher battle_menu(COLOR_YELLOW);
int ret2 = wait_until(
@@ -700,8 +704,10 @@ void quest_sneak_up(
std::chrono::seconds(15),
{ battle_menu }
);
+ battle_menu_seen = ret2 == 0;
if (ret2 != 0){
console.log("Did not enter battle. Did target spawn?");
+ recorder.checkpoint("battle-entry-timeout");
}
},
{
@@ -709,6 +715,11 @@ void quest_sneak_up(
static_cast(encounter_watcher),
}
);
+ recorder.finish({
+ .kind = TargetAttemptKind::battle,
+ .encounter_detected = ret >= 0,
+ .battle_menu_seen = battle_menu_seen,
+ });
encounter_watcher.throw_if_no_sound();
if (ret >= 0){
diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake
index 32c8dbf362..75c20cef6e 100644
--- a/SerialPrograms/cmake/SourceFiles.cmake
+++ b/SerialPrograms/cmake/SourceFiles.cmake
@@ -2643,6 +2643,8 @@ file(GLOB LIBRARY_SOURCES
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.h
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h
+ Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.cpp
+ Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTargetDiagnostics.h
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.h
Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryCatchPhoto.cpp