Merge pull request #148 from Fanixtar/auto-pickup-filter

Add pickup filter for Auto Pickup
This commit is contained in:
Callow 2022-06-21 23:05:09 +03:00 committed by GitHub
commit dae38fadae
2 changed files with 40 additions and 12 deletions

View File

@ -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),
@ -98,21 +102,29 @@ 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() : ""
);
}
@ -215,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;
}

View File

@ -12,6 +12,7 @@ namespace cheat::feature
config::Field<config::Toggle<Hotkey>> f_AutoPickup;
config::Field<config::Toggle<Hotkey>> f_AutoTreasure;
config::Field<config::Toggle<Hotkey>> f_UseCustomRange;
config::Field<config::Toggle<Hotkey>> f_PickupFilter;
config::Field<int> f_DelayTime;
config::Field<float> f_CustomRange;
@ -22,6 +23,10 @@ namespace cheat::feature
config::Field<bool> f_QuestInteract;
config::Field<bool> f_Others;
config::Field<bool> f_PickupFilter_Animals;
config::Field<bool> f_PickupFilter_DropItems;
config::Field<bool> f_PickupFilter_Resources;
static AutoLoot& GetInstance();
const FeatureGUIInfo& GetGUIInfo() const override;