Fix AutoDestroy:Plants not working if enabled alone

This commit is contained in:
Joaquin 2022-08-05 05:20:13 -06:00
parent c933f0bfd1
commit 92cc932852

View File

@ -9,32 +9,32 @@
#include <cheat/game/EntityManager.h>
#include <cheat/game/filters.h>
namespace cheat::feature
namespace cheat::feature
{
static void LCAbilityElement_ReduceModifierDurability_Hook(app::LCAbilityElement* __this, int32_t modifierDurabilityIndex, float reduceDurability, app::Nullable_1_Single_ deltaTime, MethodInfo* method);
AutoDestroy::AutoDestroy() : Feature(),
NF(f_Enabled, "Auto Destroy", "AutoDestroy", false),
NF(f_DestroyOres, "Destroy Ores", "AutoDestroy", false),
NF(f_DestroyShields, "Destroy Shields", "AutoDestroy", false),
NF(f_DestroyDoodads, "Destroy Doodads", "AutoDestroy", false),
NF(f_DestroyPlants, "Destroy Plants", "AutoDestroy", false),
NF(f_Range, "Range", "AutoDestroy", 10.0f)
{
AutoDestroy::AutoDestroy() : Feature(),
NF(f_Enabled, "Auto Destroy", "AutoDestroy", false),
NF(f_DestroyOres, "Destroy Ores", "AutoDestroy", false),
NF(f_DestroyShields, "Destroy Shields", "AutoDestroy", false),
NF(f_DestroyDoodads, "Destroy Doodads", "AutoDestroy", false),
NF(f_DestroyPlants, "Destroy Plants", "AutoDestroy", false),
NF(f_Range, "Range", "AutoDestroy", 10.0f)
{
HookManager::install(app::MoleMole_LCAbilityElement_ReduceModifierDurability, LCAbilityElement_ReduceModifierDurability_Hook);
}
const FeatureGUIInfo& AutoDestroy::GetGUIInfo() const
{
static const FeatureGUIInfo info { "Auto Destroy Objects", "World", true };
return info;
}
const FeatureGUIInfo& AutoDestroy::GetGUIInfo() const
{
static const FeatureGUIInfo info{ "Auto Destroy Objects", "World", true };
return info;
}
void AutoDestroy::DrawMain()
{
void AutoDestroy::DrawMain()
{
ImGui::TextColored(ImColor(255, 165, 0, 255), "Note. This feature is not fully tested detection-wise.\n"
"Not recommended for main accounts or used with high values.");
ConfigWidget("Enabled", f_Enabled, "Instantly destroys non-living objects within range.");
ImGui::Indent();
ConfigWidget("Ores", f_DestroyOres, "Ores and variants, e.g. electro crystals, marrows, etc.");
@ -47,15 +47,15 @@ namespace cheat::feature
ConfigWidget("Plants", f_DestroyPlants, "Dandelion Seeds, Sakura Bloom, etc.");
ImGui::Unindent();
ConfigWidget("Range (m)", f_Range, 0.1f, 1.0f, 15.0f);
}
}
bool AutoDestroy::NeedStatusDraw() const
bool AutoDestroy::NeedStatusDraw() const
{
return f_Enabled;
}
return f_Enabled;
}
void AutoDestroy::DrawStatus()
{
void AutoDestroy::DrawStatus()
{
ImGui::Text("Destroy [%.01fm%s%s%s%s%s]",
f_Range.value(),
f_DestroyOres || f_DestroyShields || f_DestroyDoodads || f_DestroyPlants ? "|" : "",
@ -63,13 +63,13 @@ namespace cheat::feature
f_DestroyShields ? "S" : "",
f_DestroyDoodads ? "D" : "",
f_DestroyPlants ? "P" : "");
}
}
AutoDestroy& AutoDestroy::GetInstance()
{
static AutoDestroy instance;
return instance;
}
AutoDestroy& AutoDestroy::GetInstance()
{
static AutoDestroy instance;
return instance;
}
// Thanks to @RyujinZX
// Every ore has ability element component
@ -82,18 +82,17 @@ namespace cheat::feature
auto& manager = game::EntityManager::instance();
auto& autoDestroy = AutoDestroy::GetInstance();
auto entity = __this->fields._._._entity;
if (autoDestroy.f_Enabled &&
if (autoDestroy.f_Enabled &&
autoDestroy.f_Range > manager.avatar()->distance(entity) &&
(
(autoDestroy.f_DestroyOres && game::filters::combined::Ores.IsValid(manager.entity(entity))) ||
(autoDestroy.f_DestroyDoodads && (game::filters::combined::Doodads.IsValid(manager.entity(entity)) || game::filters::chest::SBramble.IsValid(manager.entity(entity)))) ||
(autoDestroy.f_DestroyShields && !game::filters::combined::MonsterBosses.IsValid(manager.entity(entity)) && (
game::filters::combined::MonsterShielded.IsValid(manager.entity(entity)) || // For shields attached to monsters, e.g. abyss mage shields.
game::filters::combined::MonsterEquips.IsValid(manager.entity(entity)) || // For shields/weapons equipped by monsters, e.g. rock shield.
(autoDestroy.f_DestroyPlants && game::filters::combined::PlantDestroy.IsValid(manager.entity(entity))) // For plants e.g dandelion seeds.
))
game::filters::combined::MonsterShielded.IsValid(manager.entity(entity)) || // For shields attached to monsters, e.g. abyss mage shields.
game::filters::combined::MonsterEquips.IsValid(manager.entity(entity)))) || // For shields/weapons equipped by monsters, e.g. rock shield.
(autoDestroy.f_DestroyPlants && game::filters::combined::PlantDestroy.IsValid(manager.entity(entity))) // For plants e.g dandelion seeds.
)
)
)
{
// This value always above any ore durability
reduceDurability = 1000;