Fix AutoDestroy:Plants not working if enabled alone

This commit is contained in:
Joaquin 2022-08-05 05:20:13 -06:00
parent 8daea28f75
commit 32796600c4

View File

@ -13,25 +13,25 @@ namespace cheat::feature
{ {
static void LCAbilityElement_ReduceModifierDurability_Hook(app::LCAbilityElement* __this, int32_t modifierDurabilityIndex, float reduceDurability, app::Nullable_1_Single_ deltaTime, MethodInfo* method); static void LCAbilityElement_ReduceModifierDurability_Hook(app::LCAbilityElement* __this, int32_t modifierDurabilityIndex, float reduceDurability, app::Nullable_1_Single_ deltaTime, MethodInfo* method);
AutoDestroy::AutoDestroy() : Feature(), AutoDestroy::AutoDestroy() : Feature(),
NF(f_Enabled, "Auto Destroy", "AutoDestroy", false), NF(f_Enabled, "Auto Destroy", "AutoDestroy", false),
NF(f_DestroyOres, "Destroy Ores", "AutoDestroy", false), NF(f_DestroyOres, "Destroy Ores", "AutoDestroy", false),
NF(f_DestroyShields, "Destroy Shields", "AutoDestroy", false), NF(f_DestroyShields, "Destroy Shields", "AutoDestroy", false),
NF(f_DestroyDoodads, "Destroy Doodads", "AutoDestroy", false), NF(f_DestroyDoodads, "Destroy Doodads", "AutoDestroy", false),
NF(f_DestroyPlants, "Destroy Plants", "AutoDestroy", false), NF(f_DestroyPlants, "Destroy Plants", "AutoDestroy", false),
NF(f_Range, "Range", "AutoDestroy", 10.0f) NF(f_Range, "Range", "AutoDestroy", 10.0f)
{ {
HookManager::install(app::MoleMole_LCAbilityElement_ReduceModifierDurability, LCAbilityElement_ReduceModifierDurability_Hook); HookManager::install(app::MoleMole_LCAbilityElement_ReduceModifierDurability, LCAbilityElement_ReduceModifierDurability_Hook);
} }
const FeatureGUIInfo& AutoDestroy::GetGUIInfo() const const FeatureGUIInfo& AutoDestroy::GetGUIInfo() const
{ {
static const FeatureGUIInfo info { "Auto Destroy Objects", "World", true }; static const FeatureGUIInfo info{ "Auto Destroy Objects", "World", true };
return info; 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" 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."); "Not recommended for main accounts or used with high values.");
@ -47,15 +47,15 @@ namespace cheat::feature
ConfigWidget("Plants", f_DestroyPlants, "Dandelion Seeds, Sakura Bloom, etc."); ConfigWidget("Plants", f_DestroyPlants, "Dandelion Seeds, Sakura Bloom, etc.");
ImGui::Unindent(); ImGui::Unindent();
ConfigWidget("Range (m)", f_Range, 0.1f, 1.0f, 15.0f); 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]", ImGui::Text("Destroy [%.01fm%s%s%s%s%s]",
f_Range.value(), f_Range.value(),
f_DestroyOres || f_DestroyShields || f_DestroyDoodads || f_DestroyPlants ? "|" : "", f_DestroyOres || f_DestroyShields || f_DestroyDoodads || f_DestroyPlants ? "|" : "",
@ -63,13 +63,13 @@ namespace cheat::feature
f_DestroyShields ? "S" : "", f_DestroyShields ? "S" : "",
f_DestroyDoodads ? "D" : "", f_DestroyDoodads ? "D" : "",
f_DestroyPlants ? "P" : ""); f_DestroyPlants ? "P" : "");
} }
AutoDestroy& AutoDestroy::GetInstance() AutoDestroy& AutoDestroy::GetInstance()
{ {
static AutoDestroy instance; static AutoDestroy instance;
return instance; return instance;
} }
// Thanks to @RyujinZX // Thanks to @RyujinZX
// Every ore has ability element component // Every ore has ability element component
@ -88,12 +88,11 @@ namespace cheat::feature
(autoDestroy.f_DestroyOres && game::filters::combined::Ores.IsValid(manager.entity(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_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)) && ( (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::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. 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. (autoDestroy.f_DestroyPlants && game::filters::combined::PlantDestroy.IsValid(manager.entity(entity))) // For plants e.g dandelion seeds.
)) )
) )
)
{ {
// This value always above any ore durability // This value always above any ore durability
reduceDurability = 1000; reduceDurability = 1000;