|
| 1 | +/* LGPE Daily Item Respawn Farmer |
| 2 | + * |
| 3 | + * From: https://github.com/PokemonAutomation/ |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +#include "CommonFramework/Exceptions/OperationFailedException.h" |
| 8 | +#include "CommonFramework/Notifications/ProgramNotifications.h" |
| 9 | +#include "CommonFramework/ProgramStats/StatsTracking.h" |
| 10 | +#include "CommonFramework/VideoPipeline/VideoFeed.h" |
| 11 | +#include "CommonTools/Async/InferenceRoutines.h" |
| 12 | +#include "CommonTools/StartupChecks/VideoResolutionCheck.h" |
| 13 | +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" |
| 14 | +#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h" |
| 15 | +#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h" |
| 16 | +#include "Pokemon/Pokemon_Strings.h" |
| 17 | +#include "CommonTools/VisualDetectors/BlackScreenDetector.h" |
| 18 | +#include "PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h" |
| 19 | +#include "PokemonLGPE/Programs/PokemonLGPE_GameEntry.h" |
| 20 | +#include "PokemonLGPE_DailyItemRespawnFarmer.h" |
| 21 | + |
| 22 | +namespace PokemonAutomation{ |
| 23 | +namespace NintendoSwitch{ |
| 24 | +namespace PokemonLGPE{ |
| 25 | + |
| 26 | +DailyItemRespawnFarmer_Descriptor::DailyItemRespawnFarmer_Descriptor() |
| 27 | + : SingleSwitchProgramDescriptor( |
| 28 | + "PokemonLGPE:DailyItemRespawnFarmer", |
| 29 | + Pokemon::STRING_POKEMON + " LGPE", "Daily Item Respawn Farmer", |
| 30 | + "", |
| 31 | + "Farm daily item respawns, such as fossils, by date-skipping.", |
| 32 | + FeedbackType::NONE, |
| 33 | + AllowCommandsWhenRunning::DISABLE_COMMANDS, |
| 34 | + {ControllerFeature::NintendoSwitch_RightJoycon}, |
| 35 | + FasterIfTickPrecise::NOT_FASTER |
| 36 | + ) |
| 37 | +{} |
| 38 | + |
| 39 | +struct DailyItemRespawnFarmer_Descriptor::Stats : public StatsTracker{ |
| 40 | + Stats() |
| 41 | + : trades(m_stats["Trades"]) |
| 42 | + , resets(m_stats["Resets"]) |
| 43 | + { |
| 44 | + m_display_order.emplace_back("Trades"); |
| 45 | + m_display_order.emplace_back("Resets"); |
| 46 | + } |
| 47 | + std::atomic<uint64_t>& trades; |
| 48 | + std::atomic<uint64_t>& resets; |
| 49 | +}; |
| 50 | +std::unique_ptr<StatsTracker> DailyItemRespawnFarmer_Descriptor::make_stats() const{ |
| 51 | + return std::unique_ptr<StatsTracker>(new Stats()); |
| 52 | +} |
| 53 | + |
| 54 | +DailyItemRespawnFarmer::DailyItemRespawnFarmer() |
| 55 | + : ATTEMPTS( |
| 56 | + "<b>Number of attempts:</b>", |
| 57 | + LockMode::LOCK_WHILE_RUNNING, |
| 58 | + 30, 1 |
| 59 | + ) |
| 60 | + , LINK_CODE( |
| 61 | + "<b>Link Code:</b><br>Only needed when running multiple LGPE date-skip programs at the same time. The link code used when matching for a trade/battle.", |
| 62 | + { //Combinations of 3 different symbols is possible but 10 choices seems like enough. |
| 63 | + {LinkCode::Pikachu, "pikachu", "Pikachu"}, |
| 64 | + {LinkCode::Eevee, "eevee", "Eevee"}, |
| 65 | + {LinkCode::Bulbasaur, "bulbasaur", "Bulbasaur"}, |
| 66 | + {LinkCode::Charmander, "charmander", "Charmander"}, |
| 67 | + {LinkCode::Squirtle, "squirtle", "Squirtle"}, |
| 68 | + {LinkCode::Pidgey, "pidgey", "Pidgey"}, |
| 69 | + {LinkCode::Caterpie, "caterpie", "Caterpie"}, |
| 70 | + {LinkCode::Rattata, "rattata", "Rattata"}, |
| 71 | + {LinkCode::Jigglypuff, "jigglypuff", "Jigglypuff"}, |
| 72 | + {LinkCode::Diglett, "diglett", "Diglett"}, |
| 73 | + }, |
| 74 | + LockMode::LOCK_WHILE_RUNNING, |
| 75 | + LinkCode::Pikachu |
| 76 | + ) |
| 77 | + , GO_HOME_WHEN_DONE(false) |
| 78 | + , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) |
| 79 | + , NOTIFICATIONS({ |
| 80 | + &NOTIFICATION_STATUS_UPDATE, |
| 81 | + &NOTIFICATION_PROGRAM_FINISH, |
| 82 | + }) |
| 83 | +{ |
| 84 | + PA_ADD_OPTION(ATTEMPTS); |
| 85 | + PA_ADD_OPTION(LINK_CODE); |
| 86 | + PA_ADD_OPTION(GO_HOME_WHEN_DONE); |
| 87 | + PA_ADD_OPTION(NOTIFICATIONS); |
| 88 | +} |
| 89 | + |
| 90 | +void DailyItemRespawnFarmer::program(SingleSwitchProgramEnvironment& env, CancellableScope& scope){ |
| 91 | + JoyconContext context(scope, env.console.controller<JoyconController>()); |
| 92 | + assert_16_9_720p_min(env.logger(), env.console); |
| 93 | + //DailyItemRespawnFarmer_Descriptor::Stats& stats = env.current_stats<DailyItemRespawnFarmer_Descriptor::Stats>(); |
| 94 | + |
| 95 | + /* Stand in front of the fossil spawn near Mewtwo. |
| 96 | + * Use a repel to keep wild encounters away. |
| 97 | + * Start program in-game. |
| 98 | + * 100% daily spawn. Only works near Mewtwo. |
| 99 | + * Other cave item spawns are tied to steps taken. |
| 100 | + * Should work for other hidden daily items, game corner, mt moon moonstones, etc. |
| 101 | + */ |
| 102 | + |
| 103 | + for (uint32_t count = 0; count < ATTEMPTS; count++) { |
| 104 | + //Pick up item |
| 105 | + pbf_mash_button(context, BUTTON_A, 3000ms); |
| 106 | + |
| 107 | + //Open Menu -> Communication -> Nearby player -> Local Trade |
| 108 | + pbf_press_button(context, BUTTON_X, 200ms, 500ms); |
| 109 | + pbf_move_joystick(context, 255, 128, 100ms, 100ms); |
| 110 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 111 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 112 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 113 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 114 | + |
| 115 | + //Enter link code |
| 116 | + switch(LINK_CODE) { |
| 117 | + case LinkCode::Pikachu: |
| 118 | + break; |
| 119 | + case LinkCode::Eevee: |
| 120 | + pbf_move_joystick(context, 255, 128, 100ms, 100ms); |
| 121 | + break; |
| 122 | + case LinkCode::Bulbasaur: |
| 123 | + pbf_move_joystick(context, 255, 128, 100ms, 100ms); |
| 124 | + pbf_move_joystick(context, 255, 128, 100ms, 100ms); |
| 125 | + break; |
| 126 | + case LinkCode::Charmander: |
| 127 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 128 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 129 | + break; |
| 130 | + case LinkCode::Squirtle: |
| 131 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 132 | + break; |
| 133 | + case LinkCode::Pidgey: |
| 134 | + pbf_move_joystick(context, 128, 255, 100ms, 100ms); |
| 135 | + break; |
| 136 | + case LinkCode::Caterpie: |
| 137 | + pbf_move_joystick(context, 128, 255, 100ms, 100ms); |
| 138 | + pbf_move_joystick(context, 255, 128, 100ms, 100ms); |
| 139 | + break; |
| 140 | + case LinkCode::Rattata: |
| 141 | + pbf_move_joystick(context, 128, 255, 100ms, 100ms); |
| 142 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 143 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 144 | + break; |
| 145 | + case LinkCode::Jigglypuff: |
| 146 | + pbf_move_joystick(context, 128, 255, 100ms, 100ms); |
| 147 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 148 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 149 | + break; |
| 150 | + case LinkCode::Diglett: |
| 151 | + pbf_move_joystick(context, 128, 255, 100ms, 100ms); |
| 152 | + pbf_move_joystick(context, 0, 128, 100ms, 100ms); |
| 153 | + |
| 154 | + break; |
| 155 | + default: |
| 156 | + break; |
| 157 | + } |
| 158 | + //Select symbol three times, then enter link search |
| 159 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 160 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 161 | + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); |
| 162 | + |
| 163 | + //Dateskip |
| 164 | + |
| 165 | + //Re-enter game |
| 166 | + |
| 167 | + //Close out link menu |
| 168 | + |
| 169 | + //stats. |
| 170 | + } |
| 171 | + |
| 172 | + |
| 173 | + if (GO_HOME_WHEN_DONE) { |
| 174 | + pbf_press_button(context, BUTTON_HOME, 200ms, 1000ms); |
| 175 | + } |
| 176 | + send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH); |
| 177 | +} |
| 178 | + |
| 179 | + |
| 180 | +} |
| 181 | +} |
| 182 | +} |
0 commit comments