Skip to content

Commit 8adcbaf

Browse files
committed
Rename bench-sit. Add overworld SR,
1 parent 231ac63 commit 8adcbaf

File tree

8 files changed

+247
-26
lines changed

8 files changed

+247
-26
lines changed

SerialPrograms/Source/CommonFramework/ProgramStats/StatsDatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const std::map<std::string, std::string> STATS_DATABASE_ALIASES{
3535
{"Shiny Hunt Autonomous - Fishing", "PokemonSwSh:ShinyHuntAutonomousFishing"},
3636
{"Shiny Hunt Autonomous - Overworld", "PokemonSwSh:ShinyHuntAutonomousOverworld"},
3737
{"PokemonSV:StatsResetBloodmoon", "PokemonSV:StatsResetEventBattle"},
38+
{"PokemonLZA:ShinyHunt-Bench", "PokemonLZA:ShinyHunt-BenchSit"},
3839
};
3940

4041

SerialPrograms/Source/PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
#include <sstream>
78
//#include "Common/Cpp/Exceptions.h"
89
#include "CommonFramework/Notifications/ProgramNotifications.h"
910
#include "CommonFramework/VideoPipeline/VideoFeed.h"

SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#include "Programs/PokemonLZA_BeldumHunter.h"
1414
#include "Programs/PokemonLZA_ClothingBuyer.h"
1515
#include "Programs/PokemonLZA_RestaurantFarmer.h"
16-
#include "Programs/PokemonLZA_ShinyHunt_Bench.h"
16+
#include "Programs/PokemonLZA_ShinyHunt_BenchSit.h"
17+
#include "Programs/PokemonLZA_ShinyHunt_OverworldReset.h"
1718
#include "Programs/TestPrograms/PokemonLZA_OverworldWatcher.h"
1819

1920
namespace PokemonAutomation{
@@ -38,7 +39,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
3839

3940
if (PreloadSettings::instance().DEVELOPER_MODE){
4041
ret.emplace_back("---- Shiny Hunting ----");
41-
ret.emplace_back(make_single_switch_program<ShinyHunt_Bench_Descriptor, ShinyHunt_Bench>());
42+
ret.emplace_back(make_single_switch_program<ShinyHunt_BenchSit_Descriptor, ShinyHunt_BenchSit>());
43+
ret.emplace_back(make_single_switch_program<ShinyHunt_OverworldReset_Descriptor, ShinyHunt_OverworldReset>());
4244
ret.emplace_back(make_single_switch_program<BeldumHunter_Descriptor, BeldumHunter>());
4345
}
4446

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_Bench.cpp renamed to SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
/* Shiny Hunt - Bench
1+
/* Shiny Hunt - Bench Sit
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
55
*/
66

7-
//#include <sstream>
87
#include "CommonFramework/ProgramStats/StatsTracking.h"
98
#include "CommonFramework/Notifications/ProgramNotifications.h"
109
#include "CommonTools/Async/InferenceRoutines.h"
1110
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
1211
#include "Pokemon/Pokemon_Strings.h"
1312
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
1413
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
15-
#include "PokemonLZA_ShinyHunt_Bench.h"
14+
#include "PokemonLZA_ShinyHunt_BenchSit.h"
1615

1716
namespace PokemonAutomation{
1817
namespace NintendoSwitch{
@@ -24,19 +23,19 @@ using namespace Pokemon;
2423

2524

2625

27-
ShinyHunt_Bench_Descriptor::ShinyHunt_Bench_Descriptor()
26+
ShinyHunt_BenchSit_Descriptor::ShinyHunt_BenchSit_Descriptor()
2827
: SingleSwitchProgramDescriptor(
29-
"PokemonLZA:ShinyHunt-Bench",
30-
STRING_POKEMON + " LZA", "Shiny Hunt - Bench",
31-
"Programs/PokemonLZA/ShinyHunt-Bench.html",
28+
"PokemonLZA:ShinyHunt-BenchSit",
29+
STRING_POKEMON + " LZA", "Shiny Hunt - Bench Sit",
30+
"Programs/PokemonLZA/ShinyHunt-BenchSit.html",
3231
"Shiny hunt by repeatedly sitting on a bench to reset spawns.",
3332
ProgramControllerClass::StandardController_NoRestrictions,
3433
FeedbackType::REQUIRED,
3534
AllowCommandsWhenRunning::DISABLE_COMMANDS,
3635
{}
3736
)
3837
{}
39-
class ShinyHunt_Bench_Descriptor::Stats : public StatsTracker{
38+
class ShinyHunt_BenchSit_Descriptor::Stats : public StatsTracker{
4039
public:
4140
Stats()
4241
: resets(m_stats["Bench Sits"])
@@ -55,18 +54,18 @@ class ShinyHunt_Bench_Descriptor::Stats : public StatsTracker{
5554
std::atomic<uint64_t>& shinies;
5655
std::atomic<uint64_t>& errors;
5756
};
58-
std::unique_ptr<StatsTracker> ShinyHunt_Bench_Descriptor::make_stats() const{
57+
std::unique_ptr<StatsTracker> ShinyHunt_BenchSit_Descriptor::make_stats() const{
5958
return std::unique_ptr<StatsTracker>(new Stats());
6059
}
6160

6261

6362

6463

6564

66-
ShinyHunt_Bench::ShinyHunt_Bench()
65+
ShinyHunt_BenchSit::ShinyHunt_BenchSit()
6766
: SHINY_DETECTED(
6867
"Shiny Detected", "",
69-
"2000ms",
68+
"2000 ms",
7069
ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY
7170
)
7271
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
@@ -83,8 +82,8 @@ ShinyHunt_Bench::ShinyHunt_Bench()
8382
PA_ADD_OPTION(NOTIFICATIONS);
8483
}
8584

86-
void ShinyHunt_Bench::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
87-
ShinyHunt_Bench_Descriptor::Stats& stats = env.current_stats<ShinyHunt_Bench_Descriptor::Stats>();
85+
void ShinyHunt_BenchSit::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
86+
ShinyHunt_BenchSit_Descriptor::Stats& stats = env.current_stats<ShinyHunt_BenchSit_Descriptor::Stats>();
8887

8988
uint8_t shiny_count = 0;
9089

@@ -117,8 +116,6 @@ void ShinyHunt_Bench::program(SingleSwitchProgramEnvironment& env, ProController
117116
continue;
118117
}
119118

120-
shiny_count++;
121-
122119
// Wait for the day/night transition to finish.
123120
context.wait_for(std::chrono::milliseconds(2000));
124121

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_Bench.h renamed to SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* Shiny Hunt - Bench
1+
/* Shiny Hunt - Bench Sit
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
55
*/
66

7-
#ifndef PokemonAutomation_PokemonLZA_ShinyHunt_Bench_H
8-
#define PokemonAutomation_PokemonLZA_ShinyHunt_Bench_H
7+
#ifndef PokemonAutomation_PokemonLZA_ShinyHunt_BenchSit_H
8+
#define PokemonAutomation_PokemonLZA_ShinyHunt_BenchSit_H
99

1010
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1111
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
@@ -19,18 +19,18 @@ namespace PokemonLZA{
1919

2020

2121

22-
class ShinyHunt_Bench_Descriptor : public SingleSwitchProgramDescriptor{
22+
class ShinyHunt_BenchSit_Descriptor : public SingleSwitchProgramDescriptor{
2323
public:
24-
ShinyHunt_Bench_Descriptor();
24+
ShinyHunt_BenchSit_Descriptor();
2525

2626
class Stats;
2727
virtual std::unique_ptr<StatsTracker> make_stats() const override;
2828
};
2929

3030

31-
class ShinyHunt_Bench : public SingleSwitchProgramInstance{
31+
class ShinyHunt_BenchSit : public SingleSwitchProgramInstance{
3232
public:
33-
ShinyHunt_Bench();
33+
ShinyHunt_BenchSit();
3434

3535
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
3636

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/* Shiny Hunt - Overworld Reset
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonFramework/ProgramStats/StatsTracking.h"
8+
#include "CommonFramework/Notifications/ProgramNotifications.h"
9+
#include "CommonTools/Async/InferenceRoutines.h"
10+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
11+
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
12+
#include "Pokemon/Pokemon_Strings.h"
13+
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
14+
#include "PokemonLZA/Programs/PokemonLZA_GameEntry.h"
15+
#include "PokemonLZA_ShinyHunt_OverworldReset.h"
16+
17+
namespace PokemonAutomation{
18+
namespace NintendoSwitch{
19+
namespace PokemonLZA{
20+
21+
using namespace Pokemon;
22+
23+
24+
25+
26+
27+
ShinyHunt_OverworldReset_Descriptor::ShinyHunt_OverworldReset_Descriptor()
28+
: SingleSwitchProgramDescriptor(
29+
"PokemonLZA:ShinyHunt-OverworldReset",
30+
STRING_POKEMON + " LZA", "Shiny Hunt - Overworld Reset",
31+
"Programs/PokemonLZA/ShinyHunt-OverworldReset.html",
32+
"Shiny hunt by repeatedly sitting on a bench to reset spawns.",
33+
ProgramControllerClass::StandardController_NoRestrictions,
34+
FeedbackType::REQUIRED,
35+
AllowCommandsWhenRunning::DISABLE_COMMANDS,
36+
{}
37+
)
38+
{}
39+
class ShinyHunt_OverworldReset_Descriptor::Stats : public StatsTracker{
40+
public:
41+
Stats()
42+
: resets(m_stats["Resets"])
43+
, shinies(m_stats["Shinies"])
44+
, errors(m_stats["Errors"])
45+
{
46+
m_display_order.emplace_back("Resets");
47+
m_display_order.emplace_back("Shinies");
48+
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
49+
}
50+
51+
std::atomic<uint64_t>& resets;
52+
std::atomic<uint64_t>& shinies;
53+
std::atomic<uint64_t>& errors;
54+
};
55+
std::unique_ptr<StatsTracker> ShinyHunt_OverworldReset_Descriptor::make_stats() const{
56+
return std::unique_ptr<StatsTracker>(new Stats());
57+
}
58+
59+
60+
61+
62+
63+
ShinyHunt_OverworldReset::ShinyHunt_OverworldReset()
64+
: RESET_DELAY(
65+
"<b>Reset Delay:</b><br>Wait this long after the game loads before resetting.",
66+
LockMode::UNLOCK_WHILE_RUNNING,
67+
"5000 ms"
68+
)
69+
, ROTATE_CAMERA(
70+
"<b>Rotate Camera:</b><br>Rotate camera upon entering the game.",
71+
LockMode::UNLOCK_WHILE_RUNNING,
72+
false
73+
)
74+
, SHINY_DETECTED(
75+
"Shiny Detected", "",
76+
"5000 ms",
77+
ShinySoundDetectedAction::STOP_PROGRAM
78+
)
79+
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
80+
, NOTIFICATIONS({
81+
&NOTIFICATION_STATUS,
82+
&SHINY_DETECTED.NOTIFICATIONS,
83+
&NOTIFICATION_PROGRAM_FINISH,
84+
&NOTIFICATION_ERROR_RECOVERABLE,
85+
&NOTIFICATION_ERROR_FATAL,
86+
})
87+
{
88+
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
89+
PA_ADD_OPTION(RESET_DELAY);
90+
PA_ADD_OPTION(ROTATE_CAMERA);
91+
PA_ADD_OPTION(SHINY_DETECTED);
92+
PA_ADD_OPTION(NOTIFICATIONS);
93+
}
94+
95+
void ShinyHunt_OverworldReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
96+
ShinyHunt_OverworldReset_Descriptor::Stats& stats = env.current_stats<ShinyHunt_OverworldReset_Descriptor::Stats>();
97+
98+
uint8_t shiny_count = 0;
99+
100+
while (true){
101+
go_home(env.console, context);
102+
send_program_status_notification(env, NOTIFICATION_STATUS);
103+
104+
105+
float shiny_coefficient = 1.0;
106+
PokemonLA::ShinySoundDetector shiny_detector(env.console, [&](float error_coefficient) -> bool{
107+
// Warning: This callback will be run from a different thread than this function.
108+
shiny_count++;
109+
stats.shinies++;
110+
env.update_stats();
111+
shiny_coefficient = error_coefficient;
112+
return true;
113+
});
114+
115+
int ret = run_until<ProControllerContext>(
116+
env.console, context,
117+
[&](ProControllerContext& context){
118+
reset_game_from_home(env, env.console, context);
119+
120+
if (ROTATE_CAMERA){
121+
pbf_move_right_joystick(context, 255, 128, RESET_DELAY, 0ms);
122+
}else{
123+
pbf_wait(context, RESET_DELAY);
124+
}
125+
126+
stats.resets++;
127+
env.update_stats();
128+
},
129+
{{shiny_detector}}
130+
);
131+
132+
if (ret < 0){
133+
continue;
134+
}
135+
136+
if (SHINY_DETECTED.on_shiny_sound(
137+
env, env.console, context,
138+
shiny_count,
139+
shiny_coefficient
140+
)){
141+
break;
142+
}
143+
}
144+
145+
go_home(env.console, context);
146+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
147+
}
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
158+
}
159+
}
160+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Shiny Hunt - Overworld Reset
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLZA_ShinyHunt_OverworldReset_H
8+
#define PokemonAutomation_PokemonLZA_ShinyHunt_OverworldReset_H
9+
10+
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
11+
#include "Common/Cpp/Options/TimeDurationOption.h"
12+
#include "CommonFramework/Notifications/EventNotificationsTable.h"
13+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
14+
#include "PokemonLA/Options/PokemonLA_ShinyDetectedAction.h"
15+
#include "PokemonLZA/Options/PokemonLZA_ShinyDetectedAction.h"
16+
17+
namespace PokemonAutomation{
18+
namespace NintendoSwitch{
19+
namespace PokemonLZA{
20+
21+
22+
23+
24+
class ShinyHunt_OverworldReset_Descriptor : public SingleSwitchProgramDescriptor{
25+
public:
26+
ShinyHunt_OverworldReset_Descriptor();
27+
28+
class Stats;
29+
virtual std::unique_ptr<StatsTracker> make_stats() const override;
30+
};
31+
32+
33+
class ShinyHunt_OverworldReset : public SingleSwitchProgramInstance{
34+
public:
35+
ShinyHunt_OverworldReset();
36+
37+
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
38+
39+
private:
40+
PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;
41+
42+
MillisecondsOption RESET_DELAY;
43+
BooleanCheckBoxOption ROTATE_CAMERA;
44+
45+
ShinySoundDetectedActionOption SHINY_DETECTED;
46+
47+
EventNotificationOption NOTIFICATION_STATUS;
48+
EventNotificationsOption NOTIFICATIONS;
49+
};
50+
51+
52+
53+
54+
55+
}
56+
}
57+
}
58+
#endif

SerialPrograms/SourceFiles.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,10 @@ file(GLOB LIBRARY_SOURCES
15611561
Source/PokemonLZA/Programs/PokemonLZA_GameEntry.h
15621562
Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp
15631563
Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h
1564-
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_Bench.cpp
1565-
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_Bench.h
1564+
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.cpp
1565+
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.h
1566+
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_OverworldReset.cpp
1567+
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_OverworldReset.h
15661568
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.cpp
15671569
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.h
15681570
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp

0 commit comments

Comments
 (0)