|
| 1 | +/* Legendary Hunt - Emerald |
| 2 | + * |
| 3 | + * From: https://github.com/PokemonAutomation/Arduino-Source |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +#include "Common/Cpp/PrettyPrint.h" |
| 8 | +#include "CommonFramework/Exceptions/OperationFailedException.h" |
| 9 | +#include "CommonTools/Async/InferenceRoutines.h" |
| 10 | +#include "CommonTools/VisualDetectors/BlackScreenDetector.h" |
| 11 | +#include "CommonFramework/Notifications/ProgramNotifications.h" |
| 12 | +#include "CommonFramework/ProgramStats/StatsTracking.h" |
| 13 | +#include "CommonFramework/VideoPipeline/VideoFeed.h" |
| 14 | +#include "Pokemon/Pokemon_Strings.h" |
| 15 | +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" |
| 16 | +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h" |
| 17 | +#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h" |
| 18 | +#include "PokemonRSE/PokemonRSE_Navigation.h" |
| 19 | +#include "PokemonRSE_LegendaryHunt-Emerald.h" |
| 20 | + |
| 21 | +namespace PokemonAutomation{ |
| 22 | +namespace NintendoSwitch{ |
| 23 | +namespace PokemonRSE{ |
| 24 | + |
| 25 | +LegendaryHuntEmerald_Descriptor::LegendaryHuntEmerald_Descriptor() |
| 26 | + : SingleSwitchProgramDescriptor( |
| 27 | + "PokemonRSE:LegendaryHuntEmerald", |
| 28 | + Pokemon::STRING_POKEMON + " RSE", "Legendary Hunt (Emerald)", |
| 29 | + "ComputerControl/blob/master/Wiki/Programs/PokemonRSE/LegendaryHuntEmerald.md", |
| 30 | + "Use the Run Away method to shiny hunt legendaries in Emerald.", |
| 31 | + FeedbackType::VIDEO_AUDIO, |
| 32 | + AllowCommandsWhenRunning::DISABLE_COMMANDS, |
| 33 | + {SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS} |
| 34 | + ) |
| 35 | +{} |
| 36 | + |
| 37 | +struct LegendaryHuntEmerald_Descriptor::Stats : public StatsTracker{ |
| 38 | + Stats() |
| 39 | + : resets(m_stats["Resets"]) |
| 40 | + , shinies(m_stats["Shinies"]) |
| 41 | + { |
| 42 | + m_display_order.emplace_back("Resets"); |
| 43 | + m_display_order.emplace_back("Shinies"); |
| 44 | + } |
| 45 | + std::atomic<uint64_t>& resets; |
| 46 | + std::atomic<uint64_t>& shinies; |
| 47 | +}; |
| 48 | +std::unique_ptr<StatsTracker> LegendaryHuntEmerald_Descriptor::make_stats() const{ |
| 49 | + return std::unique_ptr<StatsTracker>(new Stats()); |
| 50 | +} |
| 51 | + |
| 52 | +LegendaryHuntEmerald::LegendaryHuntEmerald() |
| 53 | + : TARGET( |
| 54 | + "<b>Starter:</b><br>", |
| 55 | + { |
| 56 | + {Target::regis, "regis", "Regirock/Regice/Registeel"}, |
| 57 | + {Target::hooh, "hooh", "Ho-Oh"}, |
| 58 | + {Target::lugia, "lugia", "Lugia"}, |
| 59 | + {Target::latis, "latis", "Latias/Latios (Southern Island)"}, |
| 60 | + }, |
| 61 | + LockMode::LOCK_WHILE_RUNNING, |
| 62 | + Target::hooh |
| 63 | + ) |
| 64 | + , NOTIFICATION_SHINY( |
| 65 | + "Shiny Found", |
| 66 | + true, true, ImageAttachmentMode::JPG, |
| 67 | + {"Notifs", "Showcase"} |
| 68 | + ) |
| 69 | + , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) |
| 70 | + , NOTIFICATIONS({ |
| 71 | + &NOTIFICATION_SHINY, |
| 72 | + &NOTIFICATION_STATUS_UPDATE, |
| 73 | + &NOTIFICATION_PROGRAM_FINISH, |
| 74 | + }) |
| 75 | +{ |
| 76 | + PA_ADD_OPTION(TARGET); |
| 77 | + PA_ADD_OPTION(NOTIFICATIONS); |
| 78 | +} |
| 79 | + |
| 80 | +void LegendaryHuntEmerald::reset_room(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) { |
| 81 | + switch (TARGET) { |
| 82 | + case Target::regis: |
| 83 | + //turn around, walk down 4 |
| 84 | + |
| 85 | + //black screen over |
| 86 | + |
| 87 | + //turn around, up one |
| 88 | + |
| 89 | + //black screen over |
| 90 | + |
| 91 | + //reverse the above |
| 92 | + |
| 93 | + break; |
| 94 | + case Target::hooh: |
| 95 | + //Turn around |
| 96 | + |
| 97 | + //10 steps down |
| 98 | + |
| 99 | + //Turn right |
| 100 | + |
| 101 | + //Take one step |
| 102 | + |
| 103 | + //Wait for black screen over |
| 104 | + |
| 105 | + //Turn left and take a step |
| 106 | + |
| 107 | + //now turn right and take a step |
| 108 | + |
| 109 | + //wait for black screen over |
| 110 | + |
| 111 | + //now reverse the above, but only take 9 steps up |
| 112 | + break; |
| 113 | + case Target::lugia: |
| 114 | + //Turn around |
| 115 | + |
| 116 | + //5 steps down |
| 117 | + |
| 118 | + //Turn right |
| 119 | + |
| 120 | + //3 steps right |
| 121 | + |
| 122 | + |
| 123 | + //Wait for black screen over |
| 124 | + |
| 125 | + //turn up, take one step |
| 126 | + |
| 127 | + //now turn back down and take a step |
| 128 | + |
| 129 | + //wait for black screen over |
| 130 | + |
| 131 | + //reverse above steps |
| 132 | + break; |
| 133 | + case Target::latis: |
| 134 | + |
| 135 | + break; |
| 136 | + default: |
| 137 | + break; |
| 138 | + } |
| 139 | + context.wait_for_all_requests(); |
| 140 | +} |
| 141 | + |
| 142 | +void LegendaryHuntEmerald::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){ |
| 143 | + LegendaryHuntEmerald_Descriptor::Stats& stats = env.current_stats<LegendaryHuntEmerald_Descriptor::Stats>(); |
| 144 | + |
| 145 | + /* |
| 146 | + * Text speed fast, battle animations off |
| 147 | + * smoke ball or fast pokemon req. |
| 148 | + * |
| 149 | + * Don't need to worry about PokeNav or random encounters for any of these targets. |
| 150 | + * |
| 151 | + * Stand in front of Regis/Ho-Oh/Lugia. Save the game. |
| 152 | + */ |
| 153 | + |
| 154 | + while (true) { |
| 155 | + //Start battle. |
| 156 | + if (TARGET == Target::hooh) { |
| 157 | + //Step forward to start the encounter. |
| 158 | + pbf_press_dpad(context, DPAD_UP, 10, 50); |
| 159 | + } |
| 160 | + else { |
| 161 | + //All other legendaries. |
| 162 | + pbf_press_button(context, BUTTON_A, 20, 40); |
| 163 | + } |
| 164 | + |
| 165 | + bool legendary_shiny = handle_encounter(env.console, context, true); |
| 166 | + if (legendary_shiny) { |
| 167 | + stats.shinies++; |
| 168 | + env.update_stats(); |
| 169 | + send_program_notification(env, NOTIFICATION_SHINY, COLOR_YELLOW, "Shiny found!", {}, "", env.console.video().snapshot(), true); |
| 170 | + break; |
| 171 | + } |
| 172 | + env.log("No shiny found."); |
| 173 | + flee_battle(env.console, context); |
| 174 | + |
| 175 | + //Close out dialog box |
| 176 | + pbf_mash_button(context, BUTTON_B, 250); |
| 177 | + context.wait_for_all_requests(); |
| 178 | + |
| 179 | + //Exit and reenter |
| 180 | + reset_room(env, context); |
| 181 | + |
| 182 | + stats.resets++; |
| 183 | + env.update_stats(); |
| 184 | + } |
| 185 | + |
| 186 | + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); |
| 187 | +} |
| 188 | + |
| 189 | +} |
| 190 | +} |
| 191 | +} |
0 commit comments