From ec789283356e0deeb936c9e0a9e751a5f4702553 Mon Sep 17 00:00:00 2001 From: Red Dango Date: Fri, 19 Aug 2022 12:20:11 +0800 Subject: [PATCH 1/2] Added setting to add randomise fluctuation delay for autoloot Paranoid feature to added certain amount of random delay to autoloot to mimic human tapping --- .../src/user/cheat/world/AutoLoot.cpp | 38 ++++++++++++++++--- cheat-library/src/user/cheat/world/AutoLoot.h | 2 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/cheat-library/src/user/cheat/world/AutoLoot.cpp b/cheat-library/src/user/cheat/world/AutoLoot.cpp index 2eb6971..ff9ad14 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.cpp +++ b/cheat-library/src/user/cheat/world/AutoLoot.cpp @@ -13,6 +13,10 @@ namespace cheat::feature static bool LCSelectPickup_IsInPosition_Hook(void* __this, app::BaseEntity* entity, MethodInfo* method); static bool LCSelectPickup_IsOutPosition_Hook(void* __this, app::BaseEntity* entity, MethodInfo* method); + float g_default_range = 3.0f; + static std::random_device rd; + static std::mt19937 rng(rd()); + AutoLoot::AutoLoot() : Feature(), NF(f_AutoPickup, "Auto-pickup drops", "AutoLoot", false), NF(f_AutoTreasure, "Auto-open treasures", "AutoLoot", false), @@ -26,7 +30,9 @@ namespace cheat::feature NF(f_Investigate, "Search points", "AutoLoot", false), NF(f_QuestInteract, "Quest interacts", "AutoLoot", false), NF(f_Others, "Other treasures", "AutoLoot", false), - NF(f_DelayTime, "Delay time (in ms)", "AutoLoot", 150), + NF(f_DelayTime, "Delay time (in ms)", "AutoLoot", 200), + NF(f_UseDelayTimeFluctuation, "Use delay fluctuation", "AutoLoot", false), + NF(f_DelayTimeFluctuation, "Delay fluctuation +(in ms)", "AutoLoot", 200), NF(f_CustomRange, "Pickup Range", "AutoLoot", 5.0f), toBeLootedItems(), nextLootTime(0) { @@ -81,6 +87,17 @@ namespace cheat::feature "Values under 200ms are unsafe.\nNot used if no auto-functions are on."); } ImGui::EndGroupPanel(); + + ImGui::BeginGroupPanel("Looting delay fluctuation"); + { + ConfigWidget("Enabled", f_UseDelayTimeFluctuation, "Enable delay fluctuation.\n" \ + "Simulates human clicking delay as manual clickling never consistent."); + ImGui::SameLine(); + ImGui::TextColored(ImColor(255, 165, 0, 255), "Read the note!"); + ImGui::SetNextItemWidth(100.0f); + ConfigWidget("Delay range +(ms)", f_DelayTimeFluctuation, 1, 0, 1000, "Delay randomly fluctuates between 'Delay Time'+'Delay Time+range'"); + } + ImGui::EndGroupPanel(); ImGui::TableSetColumnIndex(1); ImGui::BeginGroupPanel("Auto-Treasure"); @@ -120,12 +137,13 @@ namespace cheat::feature void AutoLoot::DrawStatus() { - ImGui::Text("Auto Loot\n[%s%s%s%s%s]", + ImGui::Text("Auto Loot\n[%s%s%s%s%s%s]", f_AutoPickup ? "AP" : "", f_AutoTreasure ? fmt::format("{}AT", f_AutoPickup ? "|" : "").c_str() : "", f_UseCustomRange ? fmt::format("{}CR{:.1f}m", f_AutoPickup || f_AutoTreasure ? "|" : "", f_CustomRange.value()).c_str() : "", f_PickupFilter ? fmt::format("{}PF", f_AutoPickup || f_AutoTreasure || f_UseCustomRange ? "|" : "").c_str() : "", - f_AutoPickup || f_AutoTreasure ? fmt::format("|{}ms", f_DelayTime.value()).c_str() : "" + f_AutoPickup || f_AutoTreasure ? fmt::format("|{}ms", f_DelayTime.value()).c_str() : "", + f_UseDelayTimeFluctuation ? fmt::format("|FL+{}ms", f_DelayTimeFluctuation.value()).c_str() : "" ); } @@ -171,7 +189,7 @@ namespace cheat::feature auto& manager = game::EntityManager::instance(); for (auto& entity : manager.entities(game::filters::combined::Chests)) { - float range = f_UseCustomRange ? f_CustomRange : 3.5f; + float range = f_UseCustomRange ? f_CustomRange : g_default_range; if (manager.avatar()->distance(entity) >= range) continue; @@ -220,13 +238,21 @@ namespace cheat::feature return; app::MoleMole_ItemModule_PickItem(itemModule, *entityId, nullptr); - nextLootTime = currentTime + (int)f_DelayTime; + + int fluctuation = 0; + if (f_UseDelayTimeFluctuation) + { + std::uniform_int_distribution uni(0, f_DelayTimeFluctuation); + fluctuation = uni(rng); + } + + nextLootTime = currentTime + (int)f_DelayTime + fluctuation; } void AutoLoot::OnCheckIsInPosition(bool& result, app::BaseEntity* entity) { if (f_AutoPickup || f_UseCustomRange) { - float pickupRange = f_UseCustomRange ? f_CustomRange : 3.5f; + float pickupRange = f_UseCustomRange ? f_CustomRange : g_default_range; if (f_PickupFilter) { if (!f_PickupFilter_Animals && entity->fields.entityType == app::EntityType__Enum_1::EnvAnimal || diff --git a/cheat-library/src/user/cheat/world/AutoLoot.h b/cheat-library/src/user/cheat/world/AutoLoot.h index cf7fb30..5b7503f 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.h +++ b/cheat-library/src/user/cheat/world/AutoLoot.h @@ -12,9 +12,11 @@ namespace cheat::feature config::Field> f_AutoPickup; config::Field> f_AutoTreasure; config::Field> f_UseCustomRange; + config::Field> f_UseDelayTimeFluctuation; config::Field> f_PickupFilter; config::Field f_DelayTime; + config::Field f_DelayTimeFluctuation; config::Field f_CustomRange; config::Field f_Chest; From 2250d86f3a4e117865f687f9e02a20fbc065a914 Mon Sep 17 00:00:00 2001 From: Red Dango <23718392+RedDango@users.noreply.github.com> Date: Fri, 19 Aug 2022 17:02:38 +0800 Subject: [PATCH 2/2] Change MT to C rand Because I don't want to be like Mihoyo --- cheat-library/src/user/cheat/world/AutoLoot.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cheat-library/src/user/cheat/world/AutoLoot.cpp b/cheat-library/src/user/cheat/world/AutoLoot.cpp index ff9ad14..602ad44 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.cpp +++ b/cheat-library/src/user/cheat/world/AutoLoot.cpp @@ -14,8 +14,6 @@ namespace cheat::feature static bool LCSelectPickup_IsOutPosition_Hook(void* __this, app::BaseEntity* entity, MethodInfo* method); float g_default_range = 3.0f; - static std::random_device rd; - static std::mt19937 rng(rd()); AutoLoot::AutoLoot() : Feature(), NF(f_AutoPickup, "Auto-pickup drops", "AutoLoot", false), @@ -242,8 +240,7 @@ namespace cheat::feature int fluctuation = 0; if (f_UseDelayTimeFluctuation) { - std::uniform_int_distribution uni(0, f_DelayTimeFluctuation); - fluctuation = uni(rng); + fluctuation = std::rand() % (f_DelayTimeFluctuation + 1); } nextLootTime = currentTime + (int)f_DelayTime + fluctuation;