From 16c127603d83ce2a748180537f7d759fc74e3eb8 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 17:10:12 -0800 Subject: [PATCH 1/2] PLZA AutoStory: 03.01-03.06, Hotel Z to Wild Zone 1's gate Ports Main Mission 03's first six checkpoints from plza/autostory with what they first need: - talk_through_map_screen (03.02): A and B in turn through Taunie's talk and the first map until the party bar holds, on the backend. - climb_ladder (03.03): the side street's ladder, on the backend. - talk_to_pokedex_screen (03.04): the scene machine with B for text and for blind presses (new SceneMachineConfig::blind_button), since only B closes the Pokedex screens. - run_to_gate (03.06): upstream's run_towards_gate_with_A_button straight on, console only; replaces plza/autostory's gate-pillar steering and compass heading. No fly at this story point. Saves per the 2026-11-15 review: 03.01, 03.03 and 03.05 autosave; 03.02, 03.04 and 03.06 none (the menu saves are dropped). 03.02 and 03.04 (always) keep reload_when_chained; 03.01 drops it, since 02.07 is unverified. plza_handler's name chain becomes a table to stay under the function length limit. --- .../Actions/PokemonLZA_AutoStoryScenes.cpp | 81 ++++++++++++ .../Actions/PokemonLZA_AutoStoryScenes.h | 41 ++++++ .../AutoStory/PokemonLZA_AutoStoryGame.cpp | 122 ++++++++++++++---- .../AutoStory/PokemonLZA_AutoStoryGame.h | 9 ++ .../PokemonLZA_AutoStoryGame_Tests.cpp | 53 +++++++- .../PokemonLZA_AutoStorySceneMachine.cpp | 18 ++- .../PokemonLZA_AutoStorySceneMachine.h | 15 ++- .../AutoStory/StoryData/plza-03.01.plan.json | 70 ++++++++++ .../AutoStory/StoryData/plza-03.02.plan.json | 74 +++++++++++ .../AutoStory/StoryData/plza-03.03.plan.json | 71 ++++++++++ .../AutoStory/StoryData/plza-03.04.plan.json | 46 +++++++ .../AutoStory/StoryData/plza-03.05.plan.json | 41 ++++++ .../AutoStory/StoryData/plza-03.06.plan.json | 68 ++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 2 + 14 files changed, 677 insertions(+), 34 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.01.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.02.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.03.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.04.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.05.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.06.plan.json diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.cpp new file mode 100644 index 0000000000..47c11443c9 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.cpp @@ -0,0 +1,81 @@ +/* PokemonLZA AutoStory - Scenes + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "PokemonLZA_AutoStoryScenes.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + +using namespace std::chrono_literals; + + +namespace{ + +// How long the map talk may take, and how long the party bar must hold. +constexpr Milliseconds MAP_TALK_TIMEOUT = 120s; +constexpr Milliseconds MAP_TALK_CONTROL_HOLD = 1000ms; +// Each button's press and the wait after it. +constexpr Milliseconds MAP_TALK_HOLD = 160ms; +constexpr Milliseconds MAP_TALK_RELEASE = 840ms; +// How often it looks while the party bar holds. +constexpr Milliseconds MAP_TALK_POLL = 250ms; + +// Free control: the party bar, with no text box over it (it shows between +// the lines of a talk). +bool shows_control(const ScreenObservation& look){ + return look.events.has(ScreenEvent::PLAYER_CAN_MOVE) && !look.events.has(ScreenEvent::DIALOG_BOX); +} + +} // namespace + + +Pokemon::Outcome talk_through_map_screen(PlzaBackend& backend){ + // Each look presses for 2 s or waits; the looks bound a script whose + // time stands still. + const size_t max_looks = (size_t)(MAP_TALK_TIMEOUT / MAP_TALK_POLL) + 1; + std::optional start; + std::optional control_since; + for (size_t looks = 0; looks < max_looks; looks++){ + backend.scope().throw_if_cancelled(); + const Pokemon::Observation look = backend.observe(); + start = start.value_or(look.when); + if (shows_control(look)){ + control_since = control_since.value_or(look.when); + if (look.when - *control_since >= MAP_TALK_CONTROL_HOLD){ + backend.log("[PLZA] talk_through_map_screen: the party bar held: back in the overworld"); + return Pokemon::outcome_ok(); + } + backend.wait(MAP_TALK_POLL); + continue; + } + control_since.reset(); + if (look.when - *start >= MAP_TALK_TIMEOUT){ + break; + } + backend.press(BUTTON_A, MAP_TALK_HOLD, MAP_TALK_RELEASE); + backend.press(BUTTON_B, MAP_TALK_HOLD, MAP_TALK_RELEASE); + } + return Pokemon::outcome_failed("map_talk_timeout", std::format( + "no party bar held {} ms within {} ms of A and B in turn", + MAP_TALK_CONTROL_HOLD.count(), MAP_TALK_TIMEOUT.count() + )); +} + +void climb_ladder(PlzaBackend& backend){ + backend.stick(/*degrees=*/90, /*duration=*/600ms, /*release=*/300ms, Pokemon::StoryPace::WALK); + backend.stick(/*degrees=*/0, /*duration=*/150ms, /*release=*/300ms, Pokemon::StoryPace::WALK); + backend.press(BUTTON_A, /*hold=*/160ms, /*release=*/1000ms); + backend.stick(/*degrees=*/0, /*duration=*/5000ms, /*release=*/500ms, Pokemon::StoryPace::WALK); +} + + + +} // namespace PokemonLZA +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h new file mode 100644 index 0000000000..a28a29da55 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h @@ -0,0 +1,41 @@ +/* PokemonLZA AutoStory - Scenes + * + * From: https://github.com/PokemonAutomation/ + * + * Story steps that press through one particular screen of the story, on + * the engine's backend: Taunie's first map (03.02) and the side street's + * ladder (03.03). + * + */ + +#ifndef PokemonAutomation_PokemonLZA_AutoStoryScenes_H +#define PokemonAutomation_PokemonLZA_AutoStoryScenes_H + +#include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" +#include "VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonLZA{ + + +// Taunie's talk after her battle (03.02), the "Map & Missions" card, the +// first map and the rest of her talk: A then B, a second each, until the +// party bar shows with no text box on looks a second apart. A pages the +// talk and the card; B closes the map, where A would place a pin. The map +// is not looked for: MapDetector needs the Travel Spots icon, which the +// first map lacks (console B, 2026-11-13). No presses once the party bar +// shows. Fails as "map_talk_timeout" after 120 s (by the looks' time). +Pokemon::Outcome talk_through_map_screen(PlzaBackend& backend); + +// Facing the side street's wall (03.03): sidestep right to the ladder +// (0.6 s), face it (150 ms), A at "A Climb Up", then hold up 5 s to the +// top. Reads nothing: the rooftop scene after it is the check. +void climb_ladder(PlzaBackend& backend); + + + +} // namespace PokemonLZA +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp index 0b71a3d129..acb67b6c00 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -17,8 +18,10 @@ #include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" #include "Pokemon/AutoStory/Data/Pokemon_StoryFiles.h" #include "Pokemon/AutoStory/Engine/Pokemon_StoryActionRegistry.h" +#include "VideoGames/PokemonLZA/Programs/PokemonLZA_BasicNavigation.h" #include "VideoGames/PokemonLZA/Programs/PokemonLZA_GameEntry.h" #include "VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryConfirmChoices.h" +#include "VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h" #include "VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryWalkScreenChecks.h" #include "PokemonLZA_AutoStoryReadings.h" #include "PokemonLZA_AutoStorySceneMachine.h" @@ -56,11 +59,15 @@ StoryArgSpec flag(std::string key, std::string why){ return StoryArgSpec{.key = std::move(key), .type = StoryArgType::BOOLEAN, .required = false, .fallback = false, .why = std::move(why)}; } +// `spec`, run only on a console. +StoryActionSpec console_only(StoryActionSpec spec){ + spec.console_only = true; + return spec; +} + std::vector make_specs(){ - StoryActionSpec confirm = game_spec("confirm_new_game"); - confirm.console_only = true; return { - std::move(confirm), + console_only(game_spec("confirm_new_game")), game_spec("wait_for_platform", { optional_ms("timeout_ms", 180000, "no platform this long fails the step"), }), @@ -100,6 +107,12 @@ std::vector make_specs(){ StoryActionSpec{.kind = StoryStepKind::MASH, .name = "a", .args = {}}, game_spec("story_battle_start"), game_spec("story_battle"), + game_spec("talk_through_map_screen"), + game_spec("climb_ladder"), + game_spec("talk_to_pokedex_screen"), + console_only(game_spec("run_to_gate", { + optional_ms("timeout_ms", 8000, "running this long with no A prompt fails the step"), + })), }; } @@ -136,6 +149,38 @@ Handler confirm_handler(StoryEnv* env){ } +// "run_to_gate" on the console `env`; none: fails as console_only. Runs +// straight on with upstream's run_towards_gate_with_A_button() until the +// gate's A prompt; once more after a day/night change, which stops the run. +// Fails as "gate_not_reached" when the run ends with no prompt. +Handler gate_run_handler(StoryEnv* env){ + if (env == nullptr){ + return [](Pokemon::StoryBackend&, const StoryActionCall&, Pokemon::RunState&){ + return Pokemon::outcome_failed(std::string(Pokemon::CONSOLE_ONLY), "run_to_gate runs only on a console"); + }; + } + return [env](Pokemon::StoryBackend& backend, const StoryActionCall& call, Pokemon::RunState&){ + const Milliseconds timeout(Pokemon::story_arg(call.args, "timeout_ms")); + // 0: the A prompt, 1: a day/night change, else no prompt. + int result = 1; + try{ + for (size_t runs = 0; runs < 2 && result == 1; runs++){ + result = run_towards_gate_with_A_button( + env->env.console, env->context, /*run_direction_x=*/0, /*run_direction_y=*/1, timeout + ); + } + }catch (OperationFailedException& e){ + backend.log(std::format("[PLZA] run_to_gate failed: {}", e.message())); + return Pokemon::outcome_failed("gate_not_reached", e.message()); + } + if (result != 0){ + return Pokemon::outcome_failed("gate_not_reached", std::format("no gate A prompt in {} ms of running", timeout.count())); + } + return Pokemon::outcome_ok(); + }; +} + + // What a platform wait needs before the platform counts. enum class PlatformWait{ PLATFORM_ONLY, // "wait_for_platform": a start check @@ -321,6 +366,30 @@ Outcome battle_step(Pokemon::StoryBackend& backend, const StoryActionC } +// "talk_through_map_screen": talk_through_map_screen(). +Outcome map_talk_step(Pokemon::StoryBackend& backend, const StoryActionCall&, Pokemon::RunState&){ + return talk_through_map_screen(backend); +} + +// "climb_ladder": climb_ladder(). +Outcome ladder_step(Pokemon::StoryBackend& backend, const StoryActionCall&, Pokemon::RunState&){ + climb_ladder(backend); + return Pokemon::outcome_ok(); +} + +// "talk_to_pokedex_screen": the nurse's talk and the Pokedex app (03.04) +// until the party bar holds a second, 90 s at most: B at its text and, +// every 2 s while neither text nor control shows, at the Pokedex screens, +// which only B closes (A plays the entry's motions). +Outcome pokedex_step(Pokemon::StoryBackend& backend, const StoryActionCall&, Pokemon::RunState&){ + SceneMachineConfig config; + config.text_button = BUTTON_B; + config.blind_press_after = Milliseconds(0); + config.blind_button = BUTTON_B; + return run_scene_machine(backend, "talk_to_pokedex_screen", config, 90s); +} + + // After A at what the player faces, how long "talk" waits for its text // box, and how often it looks. constexpr Milliseconds TALK_WAIT(5000); @@ -407,45 +476,48 @@ Handler choose_handler(int index){ } +// A handler that needs nothing but its step. +using StepFunction = Outcome (*)(Pokemon::StoryBackend&, const StoryActionCall&, Pokemon::RunState&); + +// The actions run by a StepFunction, by name. +const std::map& step_functions(){ + static const std::map functions{ + {"mash_to_move_hints", move_hints_step}, + {"text_to_choice", text_to_choice_step}, + {"talk", talk_step}, + {"a", scene_step}, + {"walk_to_prompt", walk_to_prompt_step}, + {"story_battle_start", battle_start_step}, + {"story_battle", battle_step}, + {"talk_through_map_screen", map_talk_step}, + {"climb_ladder", ladder_step}, + {"talk_to_pokedex_screen", pokedex_step}, + {"walk", walk_step}, + }; + return functions; +} + // The handler of each of plza_story_specs(), by name. Handler plza_handler(StoryEnv* env, const StoryActionSpec& spec){ if (spec.name == "confirm_new_game"){ return confirm_handler(env); } + if (spec.name == "run_to_gate"){ + return gate_run_handler(env); + } if (spec.name == "wait_for_platform"){ return platform_handler(PlatformWait::PLATFORM_ONLY); } if (spec.name == "opening_to_platform"){ return platform_handler(PlatformWait::AFTER_AUTOSAVE); } - if (spec.name == "mash_to_move_hints"){ - return move_hints_step; - } - if (spec.name == "text_to_choice"){ - return text_to_choice_step; - } if (spec.name == "choose_0"){ return choose_handler(0); } if (spec.name == "choose_1"){ return choose_handler(1); } - if (spec.name == "talk"){ - return talk_step; - } - if (spec.name == "a"){ - return scene_step; - } - if (spec.name == "walk_to_prompt"){ - return walk_to_prompt_step; - } - if (spec.name == "story_battle_start"){ - return battle_start_step; - } - if (spec.name == "story_battle"){ - return battle_step; - } - return walk_step; + return step_functions().at(spec.name); } // PLZA's actions over `env` (none: no console), with no save or reload. diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h index 2debe94f2c..10c68eed83 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h @@ -68,6 +68,15 @@ namespace PokemonLZA{ // the battle tutorial's cards until the battle // HUD (run_scene_machine()) // "story_battle" the battle, by the backend's battle() +// "talk_through_map_screen" A and B in turn through Taunie's talk +// and the first map (03.02) +// "climb_ladder" the side street's ladder (03.03) +// "talk_to_pokedex_screen" B through the nurse's talk and the +// Pokedex app (03.04) +// "run_to_gate" console_only: straight on to a zone gate's A +// prompt (upstream's +// run_towards_gate_with_A_button()), arg +// "timeout_ms" // // Later slices add rows here, each with its handler. const std::vector& plza_story_specs(); diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp index 7b3af7cbc5..ea69e79988 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp @@ -67,7 +67,9 @@ const StoryDataCase STORY_DATA_CASES[] = { .expectation = {.rows = "01.00:new_game:autosave 01.01:from_save:unverified 01.02:from_save:unverified 01.03:from_save:unverified " "02.01:from_save:unverified 02.02:from_save:unverified 02.03:from_save:unverified 02.04:from_save:unverified " - "02.05:from_save:unverified 02.06:from_save:autosave 02.07:from_save:unverified" + "02.05:from_save:unverified 02.06:from_save:autosave 02.07:from_save:unverified " + "03.01:from_save:autosave 03.02:from_save 03.03:from_save:autosave 03.04:from_save " + "03.05:from_save:autosave 03.06:from_save" }, }, }; @@ -510,6 +512,55 @@ const RunCase RUN_CASES[] = { }}, .expectation = {.verdict = "done", .line = "[Save] 02.06: the game autosaved at its end"}, }, + { + .name = "03.02's map talk: A and B in turn, done on the party bar held a second", + .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { + DIALOG, look({}, {}, Milliseconds(2000)), party_bar(Milliseconds(4000)), party_bar(Milliseconds(5100)), + }}, + .expectation = { + .verdict = "done", + .inputs = "press A, press B, press A, press B, wait 250ms", + .line = "[PLZA] talk_through_map_screen: the party bar held: back in the overworld", + }, + }, + { + .name = "03.02's map talk goes on through the party bar under a text box", + .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { + look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, {}, Milliseconds(0)), + look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, {}, Milliseconds(2000)), + party_bar(Milliseconds(4000)), party_bar(Milliseconds(5100)), + }}, + .expectation = {.verdict = "done", .inputs = "press A, press B, press A, press B, wait 250ms"}, + }, + { + .name = "03.02's map talk fails with no party bar in 120 s", + .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { + look({}, {}, Milliseconds(0)), look({}, {}, Milliseconds(121000)), + }}, + .expectation = {.verdict = "failed at after_taunie_battle: map_talk_timeout", .inputs = "press A, press B"}, + }, + { + .name = "03.03 climbs the ladder: sidestep right, face it, A, then up to the top", + .input = {.checkpoint = "03.03", .first_step = 3, .steps = 1, .looks = {CUTSCENE}}, + .expectation = { + .verdict = "done", + .inputs = "stick 90deg 600ms walk, release 300ms, stick 0deg 150ms walk, release 300ms, press A, " + "stick 0deg 5000ms walk, release 500ms", + }, + }, + { + .name = "03.04's Pokedex: B at the app and at its text, done on the party bar held a second", + .input = {.checkpoint = "03.04", .first_step = 2, .steps = 1, .looks = { + look({}, {}, Milliseconds(0)), look({ScreenEvent::DIALOG_BOX}, {}, Milliseconds(500)), + party_bar(Milliseconds(1000)), party_bar(Milliseconds(2100)), + }}, + .expectation = {.verdict = "done", .inputs = "press B, press B, wait 250ms"}, + }, + { + .name = "03.06's run to the gate needs a console", + .input = {.checkpoint = "03.06", .first_step = 4, .steps = 1, .looks = {party_bar(Milliseconds(0))}}, + .expectation = {.verdict = "failed at to_zone_1_gate: console_only", .inputs = ""}, + }, }; UnitTestResult check_run(const RunCase& test, CancellableScope& scope){ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp index d53c79b4a3..b02b22dea5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp @@ -36,7 +36,7 @@ constexpr Milliseconds FADE_WAIT = 30000ms; constexpr Milliseconds STILL_WAIT = 10000ms; // The longest a cutscene may hold one still frame. constexpr Milliseconds SCENE_STILL_WAIT = 60000ms; -// How often blind_press_after presses A. +// How often blind_press_after presses. constexpr Milliseconds BLIND_PRESS_EVERY = 2000ms; // How often a wait looks again. constexpr Milliseconds POLL = 250ms; @@ -278,6 +278,7 @@ class SceneRunner{ : m_backend(backend) , m_label(label) , m_text_button(config.text_button) + , m_blind_button(config.blind_button) , m_timeline(config, start) {} @@ -298,13 +299,25 @@ class SceneRunner{ return; } if (scene_screen_presses(screen)){ - m_backend.press(screen == SceneScreen::DIALOG ? m_text_button : BUTTON_A, 160ms, 240ms); + m_backend.press(button_of(screen), 160ms, 240ms); return; } wait(screen); } private: + // The button `screen`'s step presses. + Button button_of(SceneScreen screen) const{ + switch (screen){ + case SceneScreen::DIALOG: + return m_text_button; + case SceneScreen::BLIND_PRESS: + return m_blind_button; + default: + return BUTTON_A; + } + } + void wait(SceneScreen screen){ switch (screen){ case SceneScreen::FADE_BLACK: @@ -345,6 +358,7 @@ class SceneRunner{ PlzaBackend& m_backend; std::string m_label; Button m_text_button; + Button m_blind_button; SceneTimeline m_timeline; std::optional m_logged_screen; std::string m_logged_events; diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.h index a672b33752..4fb6e6858d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.h @@ -50,10 +50,13 @@ struct SceneMachineConfig{ // ...and this long has passed since the start: a cutscene can hold a // still frame longer than `quiet`. Milliseconds min_length = Milliseconds(0); - // Presses A every 2 s once nothing busy and no sign of control has - // shown for this long, for text the detectors miss (01.01's ad). A does - // not skip a cutscene. + // Presses `blind_button` every 2 s once nothing busy and no sign of + // control has shown for this long, for text the detectors miss (01.01's + // ad). A does not skip a cutscene. std::optional blind_press_after = std::nullopt; + // The button of those blind presses: B on a screen that A does not + // close (03.04's Pokedex entry, where A only plays its motions). + Button blind_button = BUTTON_A; // Ends at the choice box (CHOICE_BOX) instead of taking its top row. bool stop_at_choice = false; // Ends at the battle HUD (BATTLE_STARTED), before anything else. @@ -88,7 +91,7 @@ enum class SceneScreen{ HINT_SHOWING, // wait: the controls hint, not held a second yet NEVER_STARTED, // terminal, failing: no scene within start_window QUIET_END, // terminal, failing unless quiet_is_control: nothing busy for the quiet time, past the minimum length - BLIND_PRESS, // A: nothing busy and no sign of control for blind_press_after + BLIND_PRESS, // blind_button: nothing busy and no sign of control for blind_press_after SCENE_MOVING, // wait: no text, the screen changing SCENE_STILL, // wait: no text, the screen still since the look before }; @@ -100,7 +103,7 @@ std::string_view scene_screen_name(SceneScreen screen); bool scene_screen_terminal(SceneScreen screen); // Whether this state's step presses (DIALOG the config's text button, -// MISSION_COMPLETE and BLIND_PRESS A); the others wait. +// BLIND_PRESS its blind button, MISSION_COMPLETE A); the others wait. bool scene_screen_presses(SceneScreen screen); // The time-dependent part of the machine, apart from the backend so tests @@ -120,7 +123,7 @@ class SceneTimeline{ // without a quiet time. std::optional quiet_end_due() const; - // Whether a blind A press is due at `now` (blind_press_after). + // Whether a blind press is due at `now` (blind_press_after). bool blind_press_due(WallClock now) const; private: diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.01.plan.json new file mode 100644 index 0000000000..0bcb261402 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.01.plan.json @@ -0,0 +1,70 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.01", + "title": "Down to the lobby", + "start": { + "place": "HotelZ" + }, + "events": [ + { + "id": "out_of_room_202", + "kind": "game_action", + "why": "step 36: to the room door's \"A Leave\". Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 1000], [-45, 1000]] + } + }, + { + "id": "leave_room_202", + "kind": "game_action", + "why": "step 36: A Leave, the loading screen, until control in the 2F hall; the hall shows no party bar or prompt, so the quiet time is control (02.04, console B 2026-11-10)", + "action": "mash_to_move_hints", + "args": {"press_a_first": true, "quiet_ms": 3000, "min_length_ms": 5000, "quiet_is_control": true} + }, + { + "id": "to_2f_elevator", + "kind": "game_action", + "why": "step 37: down the 2F hallway to \"A Take Elevator\". Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[-15, 2000]] + } + }, + { + "id": "take_elevator_down", + "kind": "talk", + "why": "step 37: A Take Elevator, \"Which floor?\"" + }, + { + "id": "floor_question", + "kind": "game_action", + "why": "step 37: the elevator line, then \"Which floor?\", before the choice shows; B would close the talk (02.04, console B 2026-11-10)", + "action": "text_to_choice", + "args": {"advance_with_a": true} + }, + { + "id": "ride_to_lobby", + "kind": "game_action", + "why": "step 38: \"1F (Lobby)\", the first floor listed", + "action": "choose_0" + }, + { + "id": "lobby_scene", + "kind": "game_action", + "why": "step 39: the ride, Z-A Royale, the app, the new outfit, AZ, Lida; autosave. The lobby shows no party bar; the ride and the scene start hold 8+ s with no text, and two cards (blind A) close it, so 20 s quiet is control (console B, 2026-11-10)", + "action": "mash_to_move_hints", + "args": {"quiet_ms": 20000, "min_length_ms": 30000, "quiet_is_control": true} + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game. Autosave: seen in a run log at lobby_scene's end (2026-11-15 save review). No reload_when_chained: 02.07 before it is unverified, so a reload could load an older save." + } + }, + "execution": { + "save": "autosave" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.02.plan.json new file mode 100644 index 0000000000..f41a7bc06e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.02.plan.json @@ -0,0 +1,74 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.02", + "title": "Out of Hotel Z, battle Taunie", + "start": { + "place": "HotelZ" + }, + "events": [ + { + "id": "to_hotel_front_door", + "kind": "game_action", + "why": "step 40: across the lobby to the front door's \"A Leave\". Stops at the door. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 6000]] + } + }, + { + "id": "leave_hotel_z", + "kind": "game_action", + "why": "steps 40-41: A Leave at the door (a scene step ends at once on its prompt), the Main Menu tutorial card", + "action": "mash_to_move_hints", + "args": {"press_a_first": true} + }, + { + "id": "to_taunie_at_gate", + "kind": "game_action", + "why": "step 41: to Taunie at the gate, \"A Talk Taunie\". Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 3000]] + } + }, + { + "id": "talk_to_taunie", + "kind": "talk", + "why": "step 42: A at Taunie" + }, + { + "id": "battle_totodile", + "kind": "game_action", + "why": "steps 42-43: A through her talk and challenge (no A hint, a subtitle with no text box), then beat Totodile, until \"We're not done just yet!\"", + "action": "story_battle" + }, + { + "id": "battle_tepig", + "kind": "game_action", + "why": "step 44: A through the Type Matchups tutorial (3 pages) and Tepig's send-out, then beat Tepig, until Taunie's speech", + "action": "story_battle" + }, + { + "id": "after_taunie_battle", + "kind": "game_action", + "why": "step 45: Taunie's talk and the Map & Missions card with A, the map closed with B, her talk with B", + "action": "talk_through_map_screen" + }, + { + "id": "taunie_runs_off", + "kind": "game_action", + "why": "step 45: the Main Missions card (A turns its pages; a scene step only waits on it), Taunie runs off (console B, 2026-11-10)", + "action": "mash_to_move_hints" + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game. No save: the game does not autosave at its end (2026-11-15 save review); the menu save of plza/autostory is dropped." + } + }, + "execution": { + "reload_when_chained": true + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.03.plan.json new file mode 100644 index 0000000000..79618cb7b6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.03.plan.json @@ -0,0 +1,71 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.03", + "title": "Over the rooftops to Station Front", + "start": { + "place": "LumioseCity" + }, + "events": [ + { + "id": "through_hotel_gate", + "kind": "game_action", + "why": "step 46: through the Hotel Z gate passage into the scene. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 7000]] + } + }, + { + "id": "rock_pile_scene", + "kind": "game_action", + "why": "step 46: Taunie at the rocks blocking the street", + "action": "mash_to_move_hints" + }, + { + "id": "side_street_to_wall", + "kind": "game_action", + "why": "step 47: down the side street to the wall across it. 6 s down the side street, 2 s across. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 8000]] + } + }, + { + "id": "climb_ladder", + "kind": "game_action", + "why": "steps 48-49: sidestep right 0.6 s, face up (150 ms), A Climb Up, hold up ~4-6 s", + "action": "climb_ladder" + }, + { + "id": "rooftop_scene", + "kind": "game_action", + "why": "step 50: Taunie on the roof", + "action": "mash_to_move_hints" + }, + { + "id": "off_the_roof", + "kind": "game_action", + "why": "step 51: off the roof's edge, down to South Boulevard. Walks off the edge and drops. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 4000]] + } + }, + { + "id": "south_boulevard", + "kind": "game_action", + "why": "step 52: Taunie walks to the Pokemon Center, until Station Front", + "action": "mash_to_move_hints" + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game. Autosave: seen in a run log at south_boulevard's end (2026-11-15 save review)." + } + }, + "execution": { + "save": "autosave" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.04.plan.json new file mode 100644 index 0000000000..837d27c2ce --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.04.plan.json @@ -0,0 +1,46 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.04", + "title": "Pokemon Center, the Pokedex", + "start": { + "place": "LumioseCity" + }, + "events": [ + { + "id": "into_pokemon_center", + "kind": "game_action", + "why": "step 53: into the Pokemon Center, to the nurse's \"A Talk\". The last turn (\"right\") had no angle recorded: 90 is a guess. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 3000], [20, 2000], [-90, 2000], [90, 0]] + } + }, + { + "id": "talk_to_nurse", + "kind": "talk", + "why": "step 53: A at the nurse" + }, + { + "id": "pokedex_app", + "kind": "game_action", + "why": "step 54: the Pokedex app (\"Ready!\"), Chikorita's entry, B on its screen", + "action": "talk_to_pokedex_screen" + }, + { + "id": "after_pokedex", + "kind": "scene", + "why": "step 55: the nurse's wrap-up, Taunie outside", + "action": "a" + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game. No save: no autosave at its end was seen in a run log (2026-11-15 save review); the menu save of plza/autostory is dropped." + } + }, + "execution": { + "reload_when_chained": "always" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.05.plan.json new file mode 100644 index 0000000000..22c57540b5 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.05.plan.json @@ -0,0 +1,41 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.05", + "title": "Heal at the Pokemon Center", + "start": { + "place": "LumioseCity", + "spot": "PokemonCenter" + }, + "events": [ + { + "id": "back_to_nurse", + "kind": "game_action", + "why": "back to the nurse after 03.04's scene: turn right and walk into the counter, which faces her (user, console B, 2026-11-13); the counter stops the walk, so 2 s is safe.", + "action": "walk", + "args": { + "legs": [[90, 2000]] + } + }, + { + "id": "talk_to_nurse", + "kind": "talk", + "why": "A at the nurse" + }, + { + "id": "heal_party", + "kind": "scene", + "why": "the nurse heals the party (A takes a question's top answer), until control at the counter. Healing writes a save, so the title screen's Up + B + X backup save is this spot after the checkpoint's menu save (user, 2026-11-13). UNVERIFIED, NEEDS CONSOLE: the nurse's lines were not recorded.", + "action": "a" + } + ], + "metadata": { + "phase": "testing", + "source": "added 2026-11-13 so Main Mission 03 has a backup save to retry from; no console recording of its steps: every step is unverified and needs console. Autosave: the heal's save was seen in a run log (2026-11-15 save review)." + } + }, + "execution": { + "save": "autosave" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.06.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.06.plan.json new file mode 100644 index 0000000000..28234db3c9 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-03.06.plan.json @@ -0,0 +1,68 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "03.06", + "title": "To Wild Zone 1", + "start": { + "place": "LumioseCity", + "spot": "PokemonCenter" + }, + "events": [ + { + "id": "out_of_pokemon_center", + "kind": "game_action", + "why": "UNVERIFIED, NEEDS CONSOLE: from the nurse's counter after 03.05's heal back to where 03.04's scene left the player, facing as it did, so the legs below (measured from there) still hold. Reverses 03.05's back_to_nurse (right, then into the counter): turn around, walk back 1.5 s (that walk is under 2 s; the time back is a guess), then right to face as the scene left the player.", + "action": "walk", + "args": { + "legs": [[180, 1500], [90, 0]] + } + }, + { + "id": "center_to_zone_1", + "kind": "game_action", + "why": "step 56: from the Pokemon Center to Wild Zone 1's gate. ~5 units/s; the first 2 s replace a dash test of the same distance. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[0, 2000], [0, 3000], [0, 6000]] + } + }, + { + "id": "toward_zone_1_gate", + "kind": "game_action", + "why": "step 57: toward the gate, into Taunie's scene. Left 45, right 15. Measured 2026-11-08 on console B, walk not run.", + "action": "walk", + "args": { + "legs": [[-45, 0], [15, 2500]] + } + }, + { + "id": "wild_zones_tutorial", + "kind": "scene", + "why": "step 57: Taunie on wild zones, the Wild Zones card", + "action": "a" + }, + { + "id": "to_zone_1_gate", + "kind": "game_action", + "why": "step 58, after Taunie's scene: runs straight on to Wild Zone 1's gate until its A prompt, by upstream's run_towards_gate_with_A_button (user, 2026-11-15: try it before plza/autostory's gate-pillar steering). Replaces the timed 4.3 s walk (22 units at ~5.1 units/s, measured 2026-11-08 on console B), so 8 s of running is ample.", + "action": "run_to_gate", + "args": { + "timeout_ms": 8000 + } + }, + { + "id": "enter_zone_1", + "kind": "game_action", + "why": "step 58: A Enter at the gate (a scene step ends at once on its prompt), Taunie, the Throwing Poke Balls card", + "action": "mash_to_move_hints", + "args": {"press_a_first": true} + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game. No save: no autosave at its end was seen in a run log (2026-11-15 save review); the menu save of plza/autostory is dropped." + } + }, + "execution": {} +} diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 4797665529..7f3cdde25e 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2312,6 +2312,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryConfirmChoices.h Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h + Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.cpp + Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryScenes.h Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryWalkScreenChecks.cpp Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryWalkScreenChecks.h Source/VideoGames/PokemonLZA/Programs/AutoStory/Detectors/PokemonLZA_AutoStoryAdvanceArrowDetector.cpp From dfc23782d067eeb406543ffe0946e202e62ebf98 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 17:40:09 -0800 Subject: [PATCH 2/2] PLZA: style fixes (code health advisories) --- .../AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp index 03a7096699..6e7e0ec5f1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame_Tests.cpp @@ -515,7 +515,7 @@ const RunCase RUN_CASES[] = { { .name = "03.02's map talk: A and B in turn, done on the party bar held a second", .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { - DIALOG, look({}, {}, Milliseconds(2000)), party_bar(Milliseconds(4000)), party_bar(Milliseconds(5100)), + DIALOG, look(/*events=*/{}, /*readings=*/{}, Milliseconds(2000)), party_bar(Milliseconds(4000)), party_bar(Milliseconds(5100)), }}, .expectation = { .verdict = "done", @@ -526,8 +526,8 @@ const RunCase RUN_CASES[] = { { .name = "03.02's map talk goes on through the party bar under a text box", .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { - look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, {}, Milliseconds(0)), - look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, {}, Milliseconds(2000)), + look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, /*readings=*/{}, Milliseconds(0)), + look({ScreenEvent::PLAYER_CAN_MOVE, ScreenEvent::DIALOG_BOX}, /*readings=*/{}, Milliseconds(2000)), party_bar(Milliseconds(4000)), party_bar(Milliseconds(5100)), }}, .expectation = {.verdict = "done", .inputs = "press A, press B, press A, press B, wait 250ms"}, @@ -535,7 +535,7 @@ const RunCase RUN_CASES[] = { { .name = "03.02's map talk fails with no party bar in 120 s", .input = {.checkpoint = "03.02", .first_step = 6, .steps = 1, .looks = { - look({}, {}, Milliseconds(0)), look({}, {}, Milliseconds(121000)), + look(/*events=*/{}, /*readings=*/{}, Milliseconds(0)), look(/*events=*/{}, /*readings=*/{}, Milliseconds(121000)), }}, .expectation = {.verdict = "failed at after_taunie_battle: map_talk_timeout", .inputs = "press A, press B"}, }, @@ -551,7 +551,7 @@ const RunCase RUN_CASES[] = { { .name = "03.04's Pokedex: B at the app and at its text, done on the party bar held a second", .input = {.checkpoint = "03.04", .first_step = 2, .steps = 1, .looks = { - look({}, {}, Milliseconds(0)), look({ScreenEvent::DIALOG_BOX}, {}, Milliseconds(500)), + look(/*events=*/{}, /*readings=*/{}, Milliseconds(0)), look({ScreenEvent::DIALOG_BOX}, /*readings=*/{}, Milliseconds(500)), party_bar(Milliseconds(1000)), party_bar(Milliseconds(2100)), }}, .expectation = {.verdict = "done", .inputs = "press B, press B, wait 250ms"},