From 21ea2e22fd837429664c4cf1e29702d0adcc1e08 Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 29 Oct 2026 22:17:34 -0700 Subject: [PATCH] BBQ Farmer: fail the egg quest when the box has no egg, and check for one at start With no egg in the current box, quest_hatch_egg() logged "No egg found" and returned with the game still in the box system. The farmer's next quest-panel read then pressed right from the box, read the wrong screen and either counted the quest as done or stopped the program on an unreadable quest. Two Switch runs ended this way. The egg scan is now find_egg_in_box(). When it finds nothing, the quest leaves the box and returns to Central Plaza like a finished attempt, so the panel check sees the quest still there and the usual retry, reroll or stop handling applies. Before the first round, the farmer also checks its setup: - It presses B once and waits. The Switch dims the screen after a few idle minutes, and a dimmed overworld is not detected, so a farmer started after a break stopped within 10 seconds. - With Number of eggs above 0, box_has_egg() opens the box once; if there is no egg it stops with a setup error that names the setting and says how to fix it: put eggs in the current box, or set Number of Eggs to 0 and choose Reroll or Keep Going in Zero Eggs (with Stop, the default, the farmer would stop at once). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Farming/PokemonSV_BBQSoloFarmer.cpp | 21 ++++++ .../Farming/PokemonSV_BlueberryQuests.cpp | 64 +++++++++++++------ .../Farming/PokemonSV_BlueberryQuests.h | 3 + 3 files changed, 67 insertions(+), 21 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 84fd26495c..fba6815df5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -298,6 +298,25 @@ class BBQSoloFarmerGameActions : public BBQGameActions{ EventNotificationOption& m_status_update; }; +//Checks before the first round, so that a setup problem stops the program at once instead of +//in the middle of a quest. +void check_before_start(SingleSwitchProgramEnvironment& env, ProControllerContext& context, const BBQOption& options){ + //The Switch dims the screen after a few idle minutes, which hides the overworld. Any button + //wakes it, and B is harmless on the overworld. + pbf_press_button(context, BUTTON_B, 160ms, 1000ms); + context.wait_for_all_requests(); + + if (options.NUM_EGGS > 0 && !box_has_egg(env.program_info(), env.console, context)){ + throw UserSetupError( + env.console, + "\"Hatch Quest - Number of Eggs\" is " + std::to_string((int)options.NUM_EGGS) + + ", but the current box (the one the box system opens on) has no egg. " + "Put eggs in that box, or set it to 0 and choose Reroll or Keep Going in " + "\"Hatch Quest - Zero Eggs\"." + ); + } +} + } void BBQSoloFarmer::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ @@ -313,6 +332,8 @@ void BBQSoloFarmer::program(SingleSwitchProgramEnvironment& env, ProControllerCo // Connect the controller. require_player(env.console, context, BUTTON_LCLICK); + + check_before_start(env, context, BBQ_OPTIONS); //Fly to plaza open_map_from_overworld(env.program_info(), env.console, context); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 83145f1e77..eac14a6f91 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -1178,6 +1178,43 @@ void quest_wash_pokemon(const ProgramInfo& info, VideoStream& stream, ProControl context.wait_for_all_requests(); } +namespace{ + +//Look through the current box for an egg, from the box system. Leaves the cursor on the egg and +//returns its slot, or returns false if the box has none. +bool find_egg_in_box( + const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context, + uint8_t& row, uint8_t& col +){ + BoxCurrentEggDetector egg_detector; + SomethingInBoxSlotDetector sth_in_box_detector(COLOR_RED); + for (row = 0; row < 5; row++){ + for (uint8_t j_col = 0; j_col < 6; j_col++){ + col = (row % 2 == 0 ? j_col : 5 - j_col); + move_box_cursor(info, console, context, BoxCursorLocation::SLOTS, row, col); + context.wait_for_all_requests(); + auto snapshot = console.video().snapshot(); + if (sth_in_box_detector.detect(snapshot) && egg_detector.detect(snapshot)){ + console.log("Found egg."); + return true; + } + } + } + return false; +} + +} + +bool box_has_egg(const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context){ + enter_box_system_from_overworld(info, console, context); + context.wait_for(std::chrono::milliseconds(400)); + uint8_t row = 0; + uint8_t col = 0; + const bool found = find_egg_in_box(info, console, context, row, col); + leave_box_system_to_overworld(info, console, context); + return found; +} + void quest_hatch_egg( ProgramEnvironment& env, ConsoleHandle& console, ProControllerContext& context, @@ -1210,30 +1247,15 @@ void quest_hatch_egg( context.wait_for(std::chrono::milliseconds(400)); //move_to_left_box(context); - BoxCurrentEggDetector egg_detector; - SomethingInBoxSlotDetector sth_in_box_detector(COLOR_RED); - bool egg_found = false; uint8_t row = 0; uint8_t col = 0; - for ( ; row < 5; row++){ - for (uint8_t j_col = 0; j_col < 6; j_col++){ - col = (row % 2 == 0 ? j_col : 5 - j_col); - move_box_cursor(env.program_info(), console, context, BoxCursorLocation::SLOTS, row, col); - context.wait_for_all_requests(); - auto snapshot = console.video().snapshot(); - if (sth_in_box_detector.detect(snapshot) && egg_detector.detect(snapshot)){ - console.log("Found egg."); - egg_found = true; - break; - } - } - if (egg_found){ - break; - } - } - - if (!egg_found){ + if (!find_egg_in_box(env.program_info(), console, context, row, col)){ + //Leave the box and go back, so the quest fails instead of leaving the game in the box. console.log("No egg found during egg hatching quest!", COLOR_RED); + leave_box_system_to_overworld(env.program_info(), console, context); + pbf_press_button(context, BUTTON_PLUS, 160ms, 400ms); + return_to_plaza(env.program_info(), console, context); + context.wait_for_all_requests(); }else{ swap_two_box_slots(env.program_info(), console, context, BoxCursorLocation::SLOTS, row, col, diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index f3f91cd04d..64032f11c5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -211,6 +211,9 @@ void quest_wash_pokemon( VideoStream& stream, ProControllerContext& context ); +//Open the box system from the overworld and check that the current box has an egg. +bool box_has_egg(const ProgramInfo& info, ConsoleHandle& console, ProControllerContext& context); + //Withdraw and hatch an egg void quest_hatch_egg( ProgramEnvironment& env,