Skip to content

PokemonLZA AutoStory: timed walks, walk screen checks and step checks - #561

Draft
dayfine wants to merge 7 commits into
plza/upstream/p2-03from
plza/upstream/p2-04
Draft

dayfine wants to merge 7 commits into
plza/upstream/p2-03from
plza/upstream/p2-04

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #560

Adds the overworld walks: timed legs of the left stick turned by the minimap's heading, the screen checks that end a walk early (a fade, a dialog, an A prompt), and PLZA's checks of a walk step's arguments beyond their types, run when the plans are linted. The story game in #568 calls them for every "walk" step. They are tested through the engine tests in #568 (PokemonLZA::AutoStoryEngine), which run the walks of the built-in checkpoints against a fake backend.

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

API review (claude-sonnet-5-5) at 4cf3a21: changes_requested

One real bug: walk_until holds a full 250 ms slice even when fewer ms remain, so the last leg overshoots its time. The rest is style: the heading turn may not be normalized, output parameters in the validator, a header comment that contradicts the code, repeated magic numbers, a stray //., and an include with no visible use.

  • [bug] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryWalkScreenChecks.cpp:97 Every slice holds the full HOLD_SLICE, so a last leg whose walk is not a multiple of 250 ms overshoots (a 1200 ms leg walks 1250 ms, and a 100 ms leg walks 250 ms). The documented upper bound is not kept, and the "after {} ms" log values are wrong on the last slice. Fix: Hold std::min(HOLD_SLICE, hold - held) each slice and log held + slice rather than held + HOLD_SLICE.
  • [bug] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp:81 heading - *now is passed to story_turn() as a raw difference. get_angle_between_facing_directions() handles wraparound, but the turn does not: facing 10 deg and wanting 350 turns +340 instead of -20. That is the long way round, and it is outside the -180..180 range the validator enforces for legs. A turn that big can also miss the tolerance within the 4 attempts. Fix: Normalize the difference to (-180, 180] before the turn, unless story_turn() already does so (then say so in a comment).
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp:99 add_legs_errors() and add_turn_errors() append to a non-const std::vector<std::string>& errors output parameter, while starter_walk_errors() and plza_step_arg_errors() return the vector by value. This is the output-parameter pattern (TotW AutoStory: FRLG demo work plan (startup with SID Helper and Starter RNG) #176). add_turn_errors() is also named for 'turn' but checks 'heading'. Fix: Have the helpers return std::vector<std::string> and let the caller insert them. Rename add_turn_errors to heading_errors.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp:109 Layout: the anonymous namespace is split in two around the public functions, and the closing } // namespace is followed directly by the next function's comment with no blank line. Fix: Put the anonymous-namespace helpers together at the top and separate declarations with a blank line.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryWalkScreenChecks.h:28 The comment says "two looks 150 ms apart show no box, choice, fade or battle". The code looks every FREE_CONTROL_LOOK = 250 ms, waits up to 15 s, and also rejects a mission banner and an advance arrow. Fix: Describe the real behavior: two consecutive looks 250 ms apart with no banner, advance arrow, choice, dialog box, battle or fade, within 15 s.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp:96 The same literals are scattered with no names or reason: press(BUTTON_L, 100ms, 150ms) is repeated four times, plus stick(..., 150ms, 100ms), the attempt < 4 retry limit, and the 10.0-degree tolerance at the call in run_story_move. The comment above this press ends in a stray //.. Fix: Add named constants with a short why-comment (for example RECENTER_CAMERA_HOLD, RECENTER_CAMERA_RECOVERY, FACE_HEADING_ATTEMPTS, FACE_HEADING_TOLERANCE) and one recenter_camera(backend) helper. Drop the stray //..
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp:173 The comment on map_shows_travel_spots() is garbled ("pressed + every 5 s, closing the map it had opened, and gave up after 30 s") and tells the history of open_map() rather than what this function does. Fix: Rewrite it as: opens the map, waits up to TRAVEL_SPOTS_WAIT for the Travel Spots icon, closes the map, and returns whether the icon showed. Add a one-line why: before fast travel unlocks, the Y line is the main mission.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/PokemonLZA_Tests.cpp:30 The diff adds an include of PokemonLZA_AutoStorySceneMachine.h to PokemonLZA_Tests.cpp but nothing in this PR uses it. The PR description says the walks are tested through the engine tests in PokemonLZA AutoStory: the story game and its table #568. Fix: Drop the include here, or add it in the PR that registers tests needing it.

walk_until() held a full 250 ms slice even when less of the last leg was
left, so a 1200 ms leg walked 1250 ms and a 100 ms leg 250 ms, and the log
counted the full slice. It now holds min(HOLD_SLICE, what is left). The
heading turn says why a difference past 180 needs no normalizing (the
stick's direction wraps), and check_can_walk()'s comment matches its
code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant