Skip to content

Commit 76bd659

Browse files
committed
Post-Kill Catcher
1 parent 9e51275 commit 76bd659

File tree

5 files changed

+158
-1
lines changed

5 files changed

+158
-1
lines changed

SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// General
1414
#include "Programs/PokemonLZA_ClothingBuyer.h"
1515
#include "Programs/PokemonLZA_StallBuyer.h"
16+
#include "Programs/PokemonLZA_PostKillCatcher.h"
1617

1718
// Trading
1819
#include "Programs/Trading/PokemonLZA_SelfBoxTrade.h"
@@ -55,6 +56,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
5556
ret.emplace_back(make_single_switch_program<StallBuyer_Descriptor, StallBuyer>());
5657
if (IS_BETA_VERSION){
5758
ret.emplace_back(make_multi_switch_program<SelfBoxTrade_Descriptor, SelfBoxTrade>());
59+
ret.emplace_back(make_single_switch_program<PostKillCatcher_Descriptor, PostKillCatcher>());
5860
}
5961

6062
ret.emplace_back("---- Farming ----");

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_ClothingBuyer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef PokemonAutomation_PokemonLZA_ClothingBuyer_H
88
#define PokemonAutomation_PokemonLZA_ClothingBuyer_H
99

10-
#include "CommonFramework/ImageTypes/ImageRGB32.h"
1110
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1211
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1312
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
@@ -17,6 +16,8 @@ namespace PokemonAutomation{
1716
namespace NintendoSwitch{
1817
namespace PokemonLZA{
1918

19+
20+
2021
class ClothingBuyer_Descriptor : public SingleSwitchProgramDescriptor{
2122
public:
2223
ClothingBuyer_Descriptor();
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/* Post-Kill Catcher
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
8+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
9+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
10+
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
11+
#include "Pokemon/Pokemon_Strings.h"
12+
#include "PokemonLZA/Programs/PokemonLZA_GameEntry.h"
13+
#include "PokemonLZA_PostKillCatcher.h"
14+
15+
namespace PokemonAutomation{
16+
namespace NintendoSwitch{
17+
namespace PokemonLZA{
18+
19+
using namespace Pokemon;
20+
21+
PostKillCatcher_Descriptor::PostKillCatcher_Descriptor()
22+
: SingleSwitchProgramDescriptor(
23+
"PokemonLZA:PostKillCatcher",
24+
STRING_POKEMON + " LZA", "Post-Kill Catcher",
25+
"Programs/PokemonLZA/PostKillCatcher.html",
26+
"Save the game immediately after knocking out a " + STRING_POKEMON + ". "
27+
"Then use this program to repeatedly try to catch it by throwing a ball and resetting.",
28+
ProgramControllerClass::StandardController_NoRestrictions,
29+
FeedbackType::REQUIRED,
30+
AllowCommandsWhenRunning::DISABLE_COMMANDS
31+
)
32+
{}
33+
34+
PostKillCatcher::PostKillCatcher()
35+
: RIGHT_SCROLLS(
36+
"<b>" + STRING_POKEBALL + " Right-Scrolls:</b><br>"
37+
"Scroll this many balls to the right. Negative will scroll to the left.",
38+
LockMode::UNLOCK_WHILE_RUNNING,
39+
0, -10, 10
40+
)
41+
, SCROLL_HOLD(
42+
"<b>Scroll Hold:</b><br>"
43+
"When scrolling to the desired ball, hold the dpad button for this long.",
44+
LockMode::UNLOCK_WHILE_RUNNING,
45+
"120 ms"
46+
)
47+
, SCROLL_RELEASE(
48+
"<b>Scroll Release:</b><br>"
49+
"When scrolling to the desired ball, release dpad button for this long before the next scroll.",
50+
LockMode::UNLOCK_WHILE_RUNNING,
51+
"80 ms"
52+
)
53+
, POST_THROW_WAIT(
54+
"<b>Post-Throw Wait:</b><br>Wait this long after throwing a ball before resetting.",
55+
LockMode::UNLOCK_WHILE_RUNNING,
56+
"6000 ms"
57+
)
58+
{
59+
PA_ADD_OPTION(RIGHT_SCROLLS);
60+
PA_ADD_OPTION(SCROLL_HOLD);
61+
PA_ADD_OPTION(SCROLL_RELEASE);
62+
PA_ADD_OPTION(POST_THROW_WAIT);
63+
}
64+
65+
void PostKillCatcher::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
66+
assert_16_9_720p_min(env.logger(), env.console);
67+
68+
69+
while (true){
70+
int8_t scrolls = RIGHT_SCROLLS;
71+
DpadPosition direction;
72+
if (scrolls >= 0){
73+
direction = DPAD_RIGHT;
74+
}else{
75+
direction = DPAD_LEFT;
76+
scrolls = -scrolls;
77+
}
78+
79+
Milliseconds hold = SCROLL_HOLD;
80+
Milliseconds cool = SCROLL_RELEASE;
81+
82+
ssf_press_button(
83+
context,
84+
BUTTON_ZL | BUTTON_ZR,
85+
500ms, 500ms + (hold + cool) * scrolls,
86+
0ms
87+
);
88+
89+
while (scrolls != 0){
90+
pbf_press_dpad(context, direction, hold, cool);
91+
scrolls--;
92+
}
93+
94+
pbf_wait(context, POST_THROW_WAIT);
95+
96+
go_home(env.console, context);
97+
reset_game_from_home(env, env.console, context);
98+
99+
}
100+
101+
}
102+
103+
104+
105+
}
106+
}
107+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Post-Kill Catcher
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLZA_PostKillCatcher_H
8+
#define PokemonAutomation_PokemonLZA_PostKillCatcher_H
9+
10+
#include "Common/Cpp/Options/TimeDurationOption.h"
11+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
12+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
13+
14+
namespace PokemonAutomation{
15+
namespace NintendoSwitch{
16+
namespace PokemonLZA{
17+
18+
19+
20+
class PostKillCatcher_Descriptor : public SingleSwitchProgramDescriptor{
21+
public:
22+
PostKillCatcher_Descriptor();
23+
};
24+
25+
class PostKillCatcher : public SingleSwitchProgramInstance{
26+
public:
27+
PostKillCatcher();
28+
29+
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
30+
31+
private:
32+
SimpleIntegerOption<int8_t> RIGHT_SCROLLS;
33+
MillisecondsOption SCROLL_HOLD;
34+
MillisecondsOption SCROLL_RELEASE;
35+
MillisecondsOption POST_THROW_WAIT;
36+
};
37+
38+
39+
40+
41+
42+
}
43+
}
44+
}
45+
#endif

SerialPrograms/SourceFiles.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,8 @@ file(GLOB LIBRARY_SOURCES
15951595
Source/PokemonLZA/Programs/PokemonLZA_MegaShardFarmer.h
15961596
Source/PokemonLZA/Programs/PokemonLZA_MenuNavigation.cpp
15971597
Source/PokemonLZA/Programs/PokemonLZA_MenuNavigation.h
1598+
Source/PokemonLZA/Programs/PokemonLZA_PostKillCatcher.cpp
1599+
Source/PokemonLZA/Programs/PokemonLZA_PostKillCatcher.h
15981600
Source/PokemonLZA/Programs/PokemonLZA_StallBuyer.cpp
15991601
Source/PokemonLZA/Programs/PokemonLZA_StallBuyer.h
16001602
Source/PokemonLZA/Programs/PokemonLZA_TrainerBattle.cpp

0 commit comments

Comments
 (0)