Skip to content

PLZA: shared ball throw helper for InPlaceCatcher and PostKillCatcher - #590

Draft
dayfine wants to merge 3 commits into
upstream-mainfrom
plza/throw-helper
Draft

dayfine wants to merge 3 commits into
upstream-mainfrom
plza/throw-helper

Conversation

@dayfine

@dayfine dayfine commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Base: upstream-main (mirror of upstream main). No parent PRs; the diff shows only this change.

InPlaceCatcher and PostKillCatcher each wrote their own ZL + ZR throw, and our AutoStory catch has a third. This adds throw_ball() in Programs/PokemonLZA_BallThrow.{h,cpp}: optional ZL-only lock-on lead, ZL + ZR aim, optional D-pad ball scroll while both are held (negative = left), release to throw, then a wait. Both catchers now call it with their old timings (InPlaceCatcher: 500 ms hold + 3500 ms before its L press; PostKillCatcher: its scroll options and Post-Throw Wait). The only command-level difference: InPlaceCatcher's single pbf_press_button(ZL|ZR, 500ms, 3500ms) becomes a 500 ms press plus a 3500 ms pbf_wait, the same timeline. The lock-on lead is unused by upstream programs; it's there for the AutoStory catch (ZL 500 ms, then ZL + ZR 1500 ms).

Testing: new unit tests PokemonLZA::BallThrow::* cover the scroll direction/count and the ZL + ZR hold length (runs in Fork Draft CI). The presses themselves are not tested on a console.

throw_ball() presses ZL + ZR, scrolls balls with the D-pad while both are
held, lets go to throw and waits. An optional ZL-only lead locks on first.
Both catchers call it with their old presses and timings; ball_scrolls()
and throw_buttons_hold() get unit tests.
}

pbf_wait(context, POST_THROW_WAIT);
BallThrowOptions ball_throw;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intialize list this whole thing?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2394ee3: one BallThrowOptions{.aim = ..., .right_scrolls = ..., ...} passed straight to throw_ball().

BUTTON_ZL | BUTTON_ZR,
500ms, 3500ms
);
BallThrowOptions ball_throw;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intializer list the whole thing

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2394ee3, same shape.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop this unit test for this one

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in 2394ee3, with its registration in PokemonLZA_Tests.cpp.


void throw_ball(ProControllerContext& context, const BallThrowOptions& options){
if (options.lock_on > 0ms){
pbf_controller_state(context, BUTTON_ZL, DPAD_NONE, {0, 0}, {0, 0}, options.lock_on);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically any constants values in a function that takes more than 1 or 2 parameters should have a parameter comments

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: /*delay=*/, /*hold=*/, /*cool=*/ on ssf_press_button, and /*left_joystick=*/, /*right_joystick=*/, /*duration=*/ on the lock-on pbf_controller_state.

Milliseconds after_throw = Milliseconds(0);
};


Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hide

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: BallScrolls, ball_scrolls() and throw_buttons_hold() moved into the .cpp's anonymous namespace; the header now has only BallThrowOptions and throw_ball().

…private, no unit tests

Review on #590: the callers build BallThrowOptions in one initializer, ball_scrolls() and throw_buttons_hold() move into the .cpp's anonymous namespace, constant arguments get parameter comments, and the tests go (they only restated the arithmetic).
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