Skip to content

Commit 48a713e

Browse files
committed
adding weather finder and helioptile hunt for LZA
1 parent 0215f32 commit 48a713e

File tree

8 files changed

+777
-0
lines changed

8 files changed

+777
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include "CommonFramework/Globals.h"
2+
#include "CommonFramework/ImageTools/ImageDiff.h"
3+
#include "CommonTools/Images/ImageFilter.h"
4+
#include "PokemonLZA_WeatherDetector.h"
5+
6+
namespace PokemonAutomation {
7+
namespace NintendoSwitch {
8+
namespace PokemonLZA {
9+
10+
11+
//-----------------------------------------------------
12+
// Weather Info Table (two images per weather)
13+
//-----------------------------------------------------
14+
15+
static const WeatherTemplateInfo WEATHER_TABLE[] = {
16+
17+
// Clear
18+
{
19+
"PokemonLZA/Weather/sun_drop.png",
20+
"PokemonLZA/Weather/clear_core.png",
21+
ImageFloatBox(0.8945, 0.0570, 0.0050, 0.0100),
22+
ImageFloatBox(0.8910, 0.0360, 0.0110, 0.0210),
23+
COLOR_RED,
24+
COLOR_GREEN
25+
},
26+
27+
// Sunny
28+
{
29+
"PokemonLZA/Weather/sun_drop.png",
30+
"PokemonLZA/Weather/sunny_core.png",
31+
ImageFloatBox(0.8945, 0.0570, 0.0050, 0.0100),
32+
ImageFloatBox(0.8910, 0.0360, 0.0110, 0.0210),
33+
COLOR_RED,
34+
COLOR_GREEN
35+
},
36+
37+
// Rain
38+
{
39+
"PokemonLZA/Weather/rain_cloud.png",
40+
"PokemonLZA/Weather/rain_drop.png",
41+
ImageFloatBox(0.8865, 0.0265, 0.0210, 0.0270),
42+
ImageFloatBox(0.8885, 0.0525, 0.0050, 0.0150),
43+
COLOR_RED,
44+
COLOR_GREEN
45+
},
46+
47+
// Cloudy
48+
{
49+
"PokemonLZA/Weather/cloudy_cloud.png",
50+
"PokemonLZA/Weather/cloudy_drop.png",
51+
ImageFloatBox(0.8895, 0.0430, 0.0210, 0.0265),
52+
ImageFloatBox(0.8915, 0.0255, 0.0050, 0.0100),
53+
COLOR_RED,
54+
COLOR_GREEN
55+
},
56+
57+
// Foggy
58+
{
59+
"PokemonLZA/Weather/foggy_tray_1.png",
60+
"PokemonLZA/Weather/foggy_tray_2.png",
61+
ImageFloatBox(0.8893, 0.0487, 0.0218, 0.0080),
62+
ImageFloatBox(0.8880, 0.0555, 0.0225, 0.0080),
63+
COLOR_RED,
64+
COLOR_GREEN
65+
},
66+
67+
// Rainbow
68+
{
69+
"PokemonLZA/Weather/rainbow_cloud.png",
70+
"PokemonLZA/Weather/rainbow_arch.png",
71+
ImageFloatBox(0.8840, 0.0465, 0.0140, 0.0165),
72+
ImageFloatBox(0.8930, 0.0420, 0.0120, 0.0100),
73+
COLOR_RED,
74+
COLOR_GREEN
75+
},
76+
};
77+
78+
79+
const WeatherTemplateInfo& weather_template_info(WeatherIconType icon){
80+
return WEATHER_TABLE[(int)icon];
81+
}
82+
83+
//-----------------------------------------------------
84+
// Detector
85+
//-----------------------------------------------------
86+
87+
WeatherIconDetector::WeatherIconDetector(WeatherIconType type, VideoOverlay* overlay)
88+
{
89+
m_info = &weather_template_info(type);
90+
91+
if (overlay){
92+
m_overlay1.emplace(*overlay, m_info->box1, m_info->color1);
93+
m_overlay2.emplace(*overlay, m_info->box2, m_info->color2);
94+
}
95+
}
96+
97+
void WeatherIconDetector::make_overlays(VideoOverlaySet& items) const {
98+
items.add(m_info->color1, m_info->box1);
99+
items.add(m_info->color2, m_info->box2);
100+
}
101+
102+
bool WeatherIconDetector::detect(const ImageViewRGB32& screen){
103+
104+
// Extract screen patches
105+
ImageRGB32 c1 = extract_box_reference(screen, m_info->box1).copy();
106+
ImageRGB32 c2 = extract_box_reference(screen, m_info->box2).copy();
107+
108+
// Load templates
109+
ImageRGB32 t1(RESOURCE_PATH() + m_info->path1);
110+
ImageRGB32 t2(RESOURCE_PATH() + m_info->path2);
111+
112+
if (t1.width() == 0 || t2.width() == 0){
113+
return false;
114+
}
115+
116+
double rms1 = ImageMatch::pixel_RMSD(c1, t1);
117+
double rms2 = ImageMatch::pixel_RMSD(c2, t2);
118+
119+
return rms1 < 90 && rms2 < 90;
120+
}
121+
122+
123+
}
124+
}
125+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef PokemonAutomation_PokemonLZA_WeatherDetector_H
2+
#define PokemonAutomation_PokemonLZA_WeatherDetector_H
3+
4+
#include <optional>
5+
#include "Common/Cpp/Color.h"
6+
#include "CommonFramework/ImageTools/ImageBoxes.h"
7+
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
8+
#include "CommonTools/VisualDetector.h"
9+
#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h"
10+
11+
namespace PokemonAutomation {
12+
namespace NintendoSwitch {
13+
namespace PokemonLZA {
14+
15+
16+
enum class WeatherIconType {
17+
Clear,
18+
Sunny,
19+
Rain,
20+
Cloudy,
21+
Foggy,
22+
Rainbow,
23+
Unknown,
24+
};
25+
26+
27+
//-----------------------------------------------------
28+
// Template Info Struct
29+
//-----------------------------------------------------
30+
struct WeatherTemplateInfo{
31+
const char* path1; // template for box1
32+
const char* path2; // template for box2
33+
ImageFloatBox box1;
34+
ImageFloatBox box2;
35+
Color color1;
36+
Color color2;
37+
};
38+
39+
40+
const WeatherTemplateInfo& weather_template_info(WeatherIconType icon);
41+
42+
43+
//-----------------------------------------------------
44+
// Detector
45+
//-----------------------------------------------------
46+
class WeatherIconDetector : public StaticScreenDetector {
47+
public:
48+
WeatherIconDetector(WeatherIconType type, VideoOverlay* overlay = nullptr);
49+
50+
virtual void make_overlays(VideoOverlaySet& items) const override;
51+
52+
virtual bool detect(const ImageViewRGB32& screen) override;
53+
54+
private:
55+
const WeatherTemplateInfo* m_info;
56+
57+
std::optional<OverlayBoxScope> m_overlay1;
58+
std::optional<OverlayBoxScope> m_overlay2;
59+
};
60+
61+
62+
}
63+
}
64+
}
65+
#endif

SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
#include "Programs/ShinyHunting/PokemonLZA_ShinyHunt_FlySpotReset.h"
3636
#include "Programs/ShinyHunting/PokemonLZA_ShuttleRun.h"
3737
#include "Programs/ShinyHunting/PokemonLZA_SewerHunter.h"
38+
#include "Programs/ShinyHunting/PokemonLZA_ShinyHunt_OverworldMacro.h"
39+
#include "Programs/ShinyHunting/PokemonLZA_ShinyHunt_HelioptileHunter.h"
3840

3941
// Non-Shiny Hunting
4042
#include "Programs/NonShinyHunting/PokemonLZA_StatsReset.h"
43+
#include "Programs/NonShinyHunting/PokemonLZA_WeatherFinder.h"
4144

4245
// Developer
4346
#include "Programs/TestPrograms/PokemonLZA_OverworldWatcher.h"
@@ -86,6 +89,9 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
8689
ret.emplace_back(make_single_switch_program<ShinyHunt_WildZoneCafe_Descriptor, ShinyHunt_WildZoneCafe>());
8790
ret.emplace_back(make_single_switch_program<ShinyHunt_FlySpotReset_Descriptor, ShinyHunt_FlySpotReset>());
8891
if (IS_BETA_VERSION){
92+
ret.emplace_back(make_single_switch_program<ShinyHunt_HelioptileHunter_Descriptor, ShinyHunt_HelioptileHunter>());
93+
ret.emplace_back(make_single_switch_program<ShinyHunt_OverworldMacro_Descriptor, ShinyHunt_OverworldMacro>());
94+
ret.emplace_back(make_single_switch_program<WeatherFinder_Descriptor, WeatherFinder>());
8995
}
9096
if (PreloadSettings::instance().DEVELOPER_MODE){
9197
ret.emplace_back(make_single_switch_program<BeldumHunter_Descriptor, BeldumHunter>());

0 commit comments

Comments
 (0)