From 12e0ef7156695bce6a8447d09d051689d52ac990 Mon Sep 17 00:00:00 2001 From: Mysticial Date: Sun, 14 Jan 2024 21:48:35 -0800 Subject: [PATCH] More cloning fixes. --- .../Source/CommonFramework/Globals.cpp | 2 +- .../Farming/PokemonSV_WildItemFarmer.cpp | 40 +++++++++++++++---- .../Farming/PokemonSV_WildItemFarmer.h | 1 + 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/Globals.cpp b/SerialPrograms/Source/CommonFramework/Globals.cpp index e1c4a15d5..bc894231c 100644 --- a/SerialPrograms/Source/CommonFramework/Globals.cpp +++ b/SerialPrograms/Source/CommonFramework/Globals.cpp @@ -25,7 +25,7 @@ namespace PokemonAutomation{ const bool IS_BETA_VERSION = true; const int PROGRAM_VERSION_MAJOR = 0; const int PROGRAM_VERSION_MINOR = 46; -const int PROGRAM_VERSION_PATCH = 1; +const int PROGRAM_VERSION_PATCH = 2; const std::string PROGRAM_VERSION_BASE = "v" + std::to_string(PROGRAM_VERSION_MAJOR) + diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.cpp index 1541f034b..7c61973b9 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.cpp @@ -4,7 +4,7 @@ * */ -#include "CommonFramework/Exceptions/ProgramFinishedException.h" +//#include "CommonFramework/Exceptions/ProgramFinishedException.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/ImageTools/SolidColorTest.h" @@ -87,7 +87,7 @@ WildItemFarmer::WildItemFarmer() , INITIAL_TRICK_PP( "Initial Trick PP:", LockMode::UNLOCK_WHILE_RUNNING, - 0, 0, 16 + 1, 0, 16 ) , VERIFY_ITEM_CLONED( "Verify Item Cloned:
Verify each run that the item has actually been cloned. " @@ -95,6 +95,12 @@ WildItemFarmer::WildItemFarmer() LockMode::UNLOCK_WHILE_RUNNING, true ) + , ENABLE_FORWARD_RUN( + "Forward Run:
Run forward a bit before throwing ball. This will correct for " + "the clone moving away, but may cause your position to wander more.", + LockMode::UNLOCK_WHILE_RUNNING, + true + ) , NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600)) , NOTIFICATIONS({ &NOTIFICATION_STATUS_UPDATE, @@ -106,6 +112,7 @@ WildItemFarmer::WildItemFarmer() // PA_ADD_OPTION(TRICK_MOVE_SLOT); PA_ADD_OPTION(INITIAL_TRICK_PP); PA_ADD_OPTION(VERIFY_ITEM_CLONED); + PA_ADD_OPTION(ENABLE_FORWARD_RUN); PA_ADD_OPTION(NOTIFICATIONS); } @@ -241,8 +248,13 @@ void WildItemFarmer::run_program(SingleSwitchProgramEnvironment& env, BotBaseCon assert_16_9_720p_min(env.logger(), env.console); WildItemFarmer_Descriptor::Stats& stats = env.current_stats(); - uint16_t items_cloned = 0; + const std::vector> MANUVERS{ + {128, 0}, + {96, 0}, + {160, 0}, + }; + uint16_t items_cloned = 0; bool trick_used = false; bool overworld_seen = false; int8_t trick_PP = INITIAL_TRICK_PP; @@ -292,25 +304,37 @@ void WildItemFarmer::run_program(SingleSwitchProgramEnvironment& env, BotBaseCon continue; } - consecutive_throw_attempts++; - if (consecutive_throw_attempts > 3){ + if (consecutive_throw_attempts >= MANUVERS.size()){ stats.errors++; env.update_stats(); throw OperationFailedException( ErrorReport::SEND_ERROR_REPORT, env.console, - "Failed to start battle after 3 attempts.", + "Failed to start battle after " + std::to_string(MANUVERS.size()) + " attempts.", true ); } pbf_press_button(context, BUTTON_L, 20, 23); - pbf_move_left_joystick(context, 128, 0, 50, 0); + if (ENABLE_FORWARD_RUN){ + const std::pair& direction = MANUVERS[consecutive_throw_attempts]; + pbf_move_left_joystick(context, (uint8_t)direction.first, (uint8_t)direction.second, 50, 0); + } pbf_mash_button(context, BUTTON_ZR, 250); pbf_wait(context, 350); + + consecutive_throw_attempts++; + continue; case 1: env.log("Detected battle menu."); + if (current_time() - std::chrono::seconds(5) < last_trick_attempt){ + env.log("Unable to use move. Assume out of PP."); + trick_PP = 0; +// pbf_mash_button(context, BUTTON_B, 30); +// continue; + } + consecutive_throw_attempts = 0; if (overworld_seen){ stats.battles++; @@ -318,7 +342,7 @@ void WildItemFarmer::run_program(SingleSwitchProgramEnvironment& env, BotBaseCon } overworld_seen = false; - if (trick_used && VERIFY_ITEM_CLONED){ + if (trick_used && trick_PP > 0 && VERIFY_ITEM_CLONED){ if (verify_item_held(env, context, battle_menu)){ items_cloned++; stats.items++; diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.h b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.h index 64adabe0f..cdff86a21 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.h +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_WildItemFarmer.h @@ -43,6 +43,7 @@ class WildItemFarmer : public SingleSwitchProgramInstance{ // IntegerEnumDropdownOption TRICK_MOVE_SLOT; SimpleIntegerOption INITIAL_TRICK_PP; BooleanCheckBoxOption VERIFY_ITEM_CLONED; + BooleanCheckBoxOption ENABLE_FORWARD_RUN; EventNotificationOption NOTIFICATION_STATUS_UPDATE; EventNotificationsOption NOTIFICATIONS; };