From a8ef837f773f0ae48faf29ef4479c40553a450d0 Mon Sep 17 00:00:00 2001 From: Fanixtar <96950043+Fanixtar@users.noreply.github.com> Date: Tue, 21 Jun 2022 12:55:09 +0700 Subject: [PATCH 1/2] Add pickup filter for Auto Pickup --- .../src/user/cheat/world/AutoLoot.cpp | 46 ++++++++++++++----- cheat-library/src/user/cheat/world/AutoLoot.h | 5 ++ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/cheat-library/src/user/cheat/world/AutoLoot.cpp b/cheat-library/src/user/cheat/world/AutoLoot.cpp index c4181de..884cd56 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.cpp +++ b/cheat-library/src/user/cheat/world/AutoLoot.cpp @@ -17,6 +17,10 @@ namespace cheat::feature NF(f_AutoPickup, "Auto-pickup drops", "AutoLoot", false), NF(f_AutoTreasure, "Auto-open treasures", "AutoLoot", false), NF(f_UseCustomRange, "Use custom pickup range", "AutoLoot", false), + NF(f_PickupFilter, "Pickup filter", "AutoLoot", false), + NF(f_PickupFilter_Animals, "Animals filter", "AutoLoot", true), + NF(f_PickupFilter_DropItems, "Drop items filter", "AutoLoot", true), + NF(f_PickupFilter_Resources, "Resources filter", "AutoLoot", true), NF(f_Chest, "Chests", "AutoLoot", false), NF(f_Leyline, "Leylines", "AutoLoot", false), NF(f_Investigate, "Search points", "AutoLoot", false), @@ -57,7 +61,7 @@ namespace cheat::feature ImGui::TextColored(ImColor(255, 165, 0, 255), "Read the note!"); } ImGui::EndGroupPanel(); - + ImGui::BeginGroupPanel("Custom Pickup Range"); { ConfigWidget("Enabled", f_UseCustomRange, "Enable custom pickup range.\n" \ @@ -69,7 +73,7 @@ namespace cheat::feature ConfigWidget("Range (m)", f_CustomRange, 0.1f, 0.5f, 40.0f, "Modifies pickup/open range to this value (in meters)."); } ImGui::EndGroupPanel(); - + ImGui::BeginGroupPanel("Looting Speed"); { ImGui::SetNextItemWidth(100.0f); @@ -77,7 +81,7 @@ namespace cheat::feature "Values under 200ms are unsafe.\nNot used if no auto-functions are on."); } ImGui::EndGroupPanel(); - + ImGui::TableSetColumnIndex(1); ImGui::BeginGroupPanel("Auto-Treasure"); { @@ -97,22 +101,30 @@ namespace cheat::feature } ImGui::EndGroupPanel(); ImGui::EndTable(); - } + } + + ImGui::BeginGroupPanel("Pickup Filter"); + { + ConfigWidget("Enabled", f_PickupFilter, "Enable pickup filter.\n"); + ConfigWidget("Animals", f_PickupFilter_Animals, "Fish, Lizard, Frog, Flying animals."); ImGui::SameLine(); + ConfigWidget("Drop Items", f_PickupFilter_DropItems, "Material, Mineral, Artifact."); ImGui::SameLine(); + ConfigWidget("Resources", f_PickupFilter_Resources, "Everything beside Animals and Drop Items (Plants, Books, etc)."); + } + ImGui::EndGroupPanel(); } bool AutoLoot::NeedStatusDraw() const -{ - return f_AutoPickup || f_AutoTreasure || f_UseCustomRange; + { + return f_AutoPickup || f_AutoTreasure || f_UseCustomRange || f_PickupFilter; } void AutoLoot::DrawStatus() { - ImGui::Text("Auto Loot\n[%s%s%s%s%s%s]", + ImGui::Text("Auto Loot\n[%s%s%s%s%s]", f_AutoPickup ? "AP" : "", - f_AutoPickup && (f_AutoTreasure || f_UseCustomRange) ? "|" : "", - f_AutoTreasure ? "AT" : "", - f_AutoTreasure && f_UseCustomRange ? "|" : "", - f_UseCustomRange ? fmt::format("CR{:.1f}m", f_CustomRange.value()).c_str() : "", + 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() : "" ); } @@ -132,6 +144,18 @@ namespace cheat::feature if (itemModule == nullptr) return false; + if (f_PickupFilter) + { + if (!f_PickupFilter_Animals && entity->fields.entityType == app::EntityType__Enum_1::EnvAnimal) + return false; + + if (!f_PickupFilter_DropItems && entity->fields.entityType == app::EntityType__Enum_1::DropItem) + return false; + + if (!f_PickupFilter_Resources && entity->fields.entityType == app::EntityType__Enum_1::GatherObject) + return false; + } + auto entityId = entity->fields._runtimeID_k__BackingField; if (f_DelayTime == 0) { diff --git a/cheat-library/src/user/cheat/world/AutoLoot.h b/cheat-library/src/user/cheat/world/AutoLoot.h index baa9866..cf7fb30 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.h +++ b/cheat-library/src/user/cheat/world/AutoLoot.h @@ -12,6 +12,7 @@ namespace cheat::feature config::Field> f_AutoPickup; config::Field> f_AutoTreasure; config::Field> f_UseCustomRange; + config::Field> f_PickupFilter; config::Field f_DelayTime; config::Field f_CustomRange; @@ -21,6 +22,10 @@ namespace cheat::feature config::Field f_Investigate; config::Field f_QuestInteract; config::Field f_Others; + + config::Field f_PickupFilter_Animals; + config::Field f_PickupFilter_DropItems; + config::Field f_PickupFilter_Resources; static AutoLoot& GetInstance(); From 3e9f1e3225bb8695387839256ea73551899006a0 Mon Sep 17 00:00:00 2001 From: Fanixtar <96950043+Fanixtar@users.noreply.github.com> Date: Tue, 21 Jun 2022 13:41:43 +0700 Subject: [PATCH 2/2] Better method for pickup filter --- .../src/user/cheat/world/AutoLoot.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cheat-library/src/user/cheat/world/AutoLoot.cpp b/cheat-library/src/user/cheat/world/AutoLoot.cpp index 884cd56..2eb6971 100644 --- a/cheat-library/src/user/cheat/world/AutoLoot.cpp +++ b/cheat-library/src/user/cheat/world/AutoLoot.cpp @@ -143,18 +143,6 @@ namespace cheat::feature auto itemModule = GET_SINGLETON(MoleMole_ItemModule); if (itemModule == nullptr) return false; - - if (f_PickupFilter) - { - if (!f_PickupFilter_Animals && entity->fields.entityType == app::EntityType__Enum_1::EnvAnimal) - return false; - - if (!f_PickupFilter_DropItems && entity->fields.entityType == app::EntityType__Enum_1::DropItem) - return false; - - if (!f_PickupFilter_Resources && entity->fields.entityType == app::EntityType__Enum_1::GatherObject) - return false; - } auto entityId = entity->fields._runtimeID_k__BackingField; if (f_DelayTime == 0) @@ -239,6 +227,17 @@ namespace cheat::feature { if (f_AutoPickup || f_UseCustomRange) { float pickupRange = f_UseCustomRange ? f_CustomRange : 3.5f; + if (f_PickupFilter) + { + if (!f_PickupFilter_Animals && entity->fields.entityType == app::EntityType__Enum_1::EnvAnimal || + !f_PickupFilter_DropItems && entity->fields.entityType == app::EntityType__Enum_1::DropItem || + !f_PickupFilter_Resources && entity->fields.entityType == app::EntityType__Enum_1::GatherObject) + { + result = false; + return; + } + } + auto& manager = game::EntityManager::instance(); result = manager.avatar()->distance(entity) < pickupRange; }