Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions SerialPrograms/Source/Pokemon/Pokemon_AdvRng.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ void level_up_observed_pokemon(AdvObservedPokemon& pokemon, const StatReads& new
// returns the appropriate NatureAdjustments for an AdvNature
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);

// returns the appropriate NatureAdjustments for an AdvNature
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);

// returns search filters that correspond with observed stats
AdvRngFilters observation_to_filters(const AdvObservedPokemon& observation, const BaseStats& basestats, AdvRngMethod method = AdvRngMethod::Method1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ bool BattleMenuDetector::detect(const ImageViewRGB32& screen){
if ((is_white(menu_top_image) //All languages except japanese
&& is_white(menu_right_image)
&& is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) //40, 81, 106 teal
&& is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20))
&& is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20)
&& !is_white(dialog_top_image))
||
(is_white(menu_top_jpn_image) //japanese
&& is_white(menu_right_jpn_image)
&& is_solid(dialog_top_jpn_image, { 0.176, 0.357, 0.467 }, 0.25, 20)
&& is_solid(dialog_right_jpn_image, { 0.176, 0.357, 0.467 }, 0.25, 20))
&& is_solid(dialog_right_jpn_image, { 0.176, 0.357, 0.467 }, 0.25, 20)
&& !is_white(dialog_top_jpn_image))
){
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Dex Registration Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "Common/Cpp/Exceptions.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/ImageTypes/ImageRGB32.h"
#include "CommonFramework/ImageTools/ImageStats.h"
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/ImageFilter.h"
#include "CommonTools/Images/WaterfillUtilities.h"
#include "PokemonFRLG_DexRegistrationDetector.h"


namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


DexRegistrationDetector::DexRegistrationDetector(Color color)
: m_top_box(0.940865, 0.013942, 0.049519, 0.071394)
, m_header_box(0.037019, 0.147355, 0.928365, 0.015865)
, m_divider_box(0.016827, 0.560577, 0.961827, 0.002885)
, m_body_box(0.016827, 0.582577, 0.961827, 0.002885)
, m_bottom_box(0.007692, 0.912500, 0.688942, 0.075721)
{}
void DexRegistrationDetector::make_overlays(VideoOverlaySet& items) const{
const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX;
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); // Green RGB(189, 205, 0)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_header_box)); // White
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_divider_box)); // Brown RGB(136, 100, 38)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_body_box)); // Beige RGB(255, 245, 204)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); // Green

}
bool DexRegistrationDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX);

ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box);
ImageViewRGB32 header_image = extract_box_reference(game_screen, m_header_box);
ImageViewRGB32 divider_image = extract_box_reference(game_screen, m_divider_box);
ImageViewRGB32 body_image = extract_box_reference(game_screen, m_body_box);
ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box);


if ( is_solid(top_image, { 0.480, 0.520, 0.000 }, 0.25, 20)
&& is_white(header_image)
&& is_solid(divider_image, { 0.496, 0.365, 0.139 }, 0.25, 20)
&& is_solid(body_image, { 0.362, 0.348, 0.290 }, 0.25, 20)
&& is_solid(bottom_image, { 0.480, 0.520, 0.000 }, 0.25, 20)
&& !is_white(top_image)
&& !is_white(divider_image)
&& !is_white(bottom_image)
){
return true;
}
return false;
}



}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Dex Registration Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonFRLG_DexRegistrationDetector_H
#define PokemonAutomation_PokemonFRLG_DexRegistrationDetector_H

#include <chrono>
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/VisualDetector.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"
#include "PokemonFRLG/PokemonFRLG_Settings.h"

namespace PokemonAutomation{
class CancellableScope;
class VideoFeed;
namespace NintendoSwitch{
namespace PokemonFRLG{

class DexRegistrationDetector : public StaticScreenDetector{
public:
DexRegistrationDetector(Color color);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
ImageFloatBox m_top_box;
ImageFloatBox m_header_box;
ImageFloatBox m_divider_box;
ImageFloatBox m_body_box;
ImageFloatBox m_bottom_box;
};
class DexRegistrationWatcher : public DetectorToFinder<DexRegistrationDetector>{
public:
DexRegistrationWatcher(Color color)
: DetectorToFinder("DexRegistrationWatcher", std::chrono::milliseconds(50), color)
{}
};



}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ namespace NintendoSwitch {
namespace PokemonFRLG {

StatsReader::StatsReader(Color color)
: m_color(color), m_box_nature(0.028976, 0.729610, 0.502487, 0.065251),
: m_color(color), m_box_nature(0.028976, 0.729610, 0.502487, 0.066639),
m_box_level(0.052000, 0.120140, 0.099000, 0.069416),
m_box_name(0.163158, 0.122917, 0.262811, 0.066639),
m_box_gender(0.430769, 0.114423, 0.034615, 0.081731),
m_box_hp(0.815558, 0.131247, 0.173049, 0.065251),
m_box_attack(0.891000, 0.245089, 0.097607, 0.063862),
m_box_hp(0.815558, 0.131247, 0.173049, 0.066639),
m_box_attack(0.891000, 0.245089, 0.097607, 0.066639),
m_box_defense(0.891000, 0.325612, 0.097607, 0.066639),
m_box_sp_attack(0.891000, 0.406134, 0.097607, 0.066639),
m_box_sp_defense(0.891000, 0.486657, 0.097607, 0.063862),
m_box_sp_defense(0.891000, 0.486657, 0.097607, 0.066639),
m_box_speed(0.891000, 0.567180, 0.097607, 0.066639){}

void StatsReader::make_overlays(VideoOverlaySet &items) const {
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Programs/RngManipulation/PokemonFRLG_SidHelper.h"
#include "Programs/RngManipulation/PokemonFRLG_StarterRng.h"
#include "Programs/RngManipulation/PokemonFRLG_GiftRng.h"
#include "Programs/RngManipulation/PokemonFRLG_StaticRng.h"
#include "Programs/TestPrograms/PokemonFRLG_SoundListener.h"
#include "Programs/TestPrograms/PokemonFRLG_ReadStats.h"
#include "Programs/TestPrograms/PokemonFRLG_ReadBattleLevelUp.h"
Expand Down Expand Up @@ -71,6 +72,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back(make_single_switch_program<SidHelper_Descriptor, SidHelper>());
ret.emplace_back(make_single_switch_program<StarterRng_Descriptor, StarterRng>());
ret.emplace_back(make_single_switch_program<GiftRng_Descriptor, GiftRng>());
ret.emplace_back(make_single_switch_program<StaticRng_Descriptor, StaticRng>());
}

if (PreloadSettings::instance().DEVELOPER_MODE){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void set_seed_after_delay(ProControllerContext& context, SeedButton SEED_BUTTON,
default:
b_button = BUTTON_L;
}
Milliseconds blackout_wait = 3600ms; // wait for the copyright text to disappear
Milliseconds blackout_wait = 3800ms; // wait for the copyright text to disappear
Milliseconds blackout_delay = std::chrono::milliseconds(SEED_DELAY) - blackout_wait;
Milliseconds blackout_hold = 30000ms; // wait for leaves/flames to appear on the title screen. It's okay if this is held over the seed button press
ssf_do_nothing(context, blackout_wait);
Expand Down Expand Up @@ -365,10 +365,10 @@ void check_timings(
console
);
}
if (SEED_DELAY < 28000){
if (SEED_DELAY < 29500){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"The title screen delay cannot be less than 28000ms. Check your seed calibration.",
"The title screen delay cannot be less than 29.5s. Check your seed calibration.",
console
);
}
Expand Down Expand Up @@ -652,6 +652,13 @@ void perform_blind_sequence(
case PokemonFRLG_RngTarget::togepi:
collect_togepi_egg_after_delay(context, INGAME_DELAY);
return;
case PokemonFRLG_RngTarget::electrode:
case PokemonFRLG_RngTarget::articuno:
case PokemonFRLG_RngTarget::zapdos:
case PokemonFRLG_RngTarget::moltres:
case PokemonFRLG_RngTarget::lugia:
case PokemonFRLG_RngTarget::deoxys_attack:
case PokemonFRLG_RngTarget::deoxys_defense:
case PokemonFRLG_RngTarget::staticencounter:
encounter_static_after_delay(context, INGAME_DELAY);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ namespace PokemonFRLG{
gamecornerpinsir,
gamecornerporygon,
togepi,
electrode,
articuno,
zapdos,
moltres,
lugia,
deoxys_attack,
deoxys_defense,
staticencounter,
snorlax,
mewtwo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ GiftRng::GiftRng()
, SEED_DELAY(
"<b>Seed Delay Time (ms):</b><br>The delay between starting the game and advancing past the title screen. Set this to match your target seed.",
LockMode::LOCK_WHILE_RUNNING,
31338, 28000 // default, min
31338, 30470 // default, min
)
, ADVANCES(
"<b>Advances:</b><br>The total number of RNG advances for your target.<br>This should be the combined amount of continue screen and in-game advances.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ void rng_reset_and_return_home(
ConsoleType console_type = console.state().console_type(); // go_home() has already been called, so this should already be detected
Milliseconds launch_delay = (console_type == ConsoleType::Switch1) ? 450ms : 950ms;

bool extra_resume_press = false;
bool update_popup = false;
bool connect_popup = false;
WallClock deadline = current_time() + std::chrono::minutes(5);
while (true){
if (current_time() > deadline){
Expand Down Expand Up @@ -111,7 +112,11 @@ void rng_reset_and_return_home(
// but we can make sure we've gotten back to the home screen and pause there

// open the game and go back home ASAP
if (extra_resume_press){
if (update_popup){
pbf_press_button(context, BUTTON_A, 160ms, 840ms);
pbf_press_dpad(context, DPAD_UP, 40ms, 0ms);
}
if (connect_popup){
pbf_press_button(context, BUTTON_A, 160ms, 840ms);
}
pbf_press_button(context, BUTTON_A, 50ms, launch_delay);
Expand All @@ -124,7 +129,7 @@ void rng_reset_and_return_home(
BlackScreenWatcher black_screen(COLOR_BLUE, {0.1, 0.15, 0.8, 0.7});
int ret3 = wait_until(
console, context,
std::chrono::seconds(2),
std::chrono::seconds(2 + (update_popup ? 1 : 0) + (connect_popup ? 1 : 0)),
{ black_screen, update_menu, failed_to_connect },
1ms
);
Expand All @@ -136,10 +141,10 @@ void rng_reset_and_return_home(
break;
case 1:
console.log("Update menu detected.", COLOR_BLUE);
extra_resume_press = true;
update_popup = true;
case 2:
console.log("Failed to connect detected.", COLOR_BLUE);
extra_resume_press = true;
connect_popup = true;
}

context.wait_for_all_requests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ RngHelper::RngHelper()
"<b>Seed Delay Time (ms):</b><br>"
"The delay between starting the game and advancing past the title screen. Set this to match your target seed.",
LockMode::LOCK_WHILE_RUNNING,
35000, 28000 // default, min
35000, 30470 // default, min
)
, SEED_CALIBRATION(
"<b>Seed Calibration (ms):</b>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ bool check_for_shiny(ConsoleHandle& console, ProControllerContext& context, Poke
case PokemonFRLG_RngTarget::gamecornerbug:
case PokemonFRLG_RngTarget::gamecornerporygon:
return shiny_check_summary(console, context);
case PokemonFRLG_RngTarget::electrode:
case PokemonFRLG_RngTarget::articuno:
case PokemonFRLG_RngTarget::zapdos:
case PokemonFRLG_RngTarget::moltres:
case PokemonFRLG_RngTarget::lugia:
case PokemonFRLG_RngTarget::deoxys_attack:
case PokemonFRLG_RngTarget::deoxys_defense:
case PokemonFRLG_RngTarget::staticencounter:
case PokemonFRLG_RngTarget::snorlax:
case PokemonFRLG_RngTarget::mewtwo:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ StarterRng::StarterRng()
, SEED_DELAY(
"<b>Seed Delay Time (ms):</b><br>The delay between starting the game and advancing past the title screen. Set this to match your target seed.",
LockMode::LOCK_WHILE_RUNNING,
31338, 28000 // default, min
31338, 30470 // default, min
)
, ADVANCES(
"<b>Advances:</b><br>The total number of RNG advances for your target.<br>This should be the combined amount of continue screen and in-game advances.",
Expand Down
Loading