From c0ed854f981682601461f4ea84a60593e2164204 Mon Sep 17 00:00:00 2001 From: Joaquin <67109235+Taiga74164@users.noreply.github.com> Date: Fri, 2 Sep 2022 20:16:01 -0600 Subject: [PATCH] fixed #398 --- .../src/user/cheat/visuals/PaimonFollow.cpp | 46 +++++++++---------- .../src/user/cheat/visuals/PaimonFollow.h | 4 -- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/cheat-library/src/user/cheat/visuals/PaimonFollow.cpp b/cheat-library/src/user/cheat/visuals/PaimonFollow.cpp index 7f0f3f1..b7e2550 100644 --- a/cheat-library/src/user/cheat/visuals/PaimonFollow.cpp +++ b/cheat-library/src/user/cheat/visuals/PaimonFollow.cpp @@ -12,8 +12,7 @@ namespace cheat::feature } PaimonFollow::PaimonFollow() : Feature(), - NFEX(f_Enabled, "Paimon Follow", "PaimonFollow", "Visuals", false, false), - toBeUpdate(), nextUpdate(0) + NFEX(f_Enabled, "Paimon Follow", "PaimonFollow", "Visuals", false, false) { events::GameUpdateEvent += MY_METHOD_HANDLER(PaimonFollow::OnGameUpdate); } @@ -48,31 +47,32 @@ namespace cheat::feature void PaimonFollow::OnGameUpdate() { - if (!f_Enabled) - return; + UPDATE_DELAY(100); - auto currentTime = util::GetCurrentTimeMillisec(); - if (currentTime < nextUpdate) - return; - - if (GameObject::Paimon == nullptr) { - GameObject::Paimon = app::GameObject_Find(string_to_il2cppi("/EntityRoot/OtherGadgetRoot/NPC_Guide_Paimon(Clone)"), nullptr); - } - - if (GameObject::ProfileLayer == nullptr) { + if (f_Enabled) + { + GameObject::Paimon = app::GameObject_Find(string_to_il2cppi("/EntityRoot/OtherGadgetRoot/NPC_Guide_Paimon(Clone)"), nullptr); + if (GameObject::Paimon == nullptr) + return; + GameObject::ProfileLayer = app::GameObject_Find(string_to_il2cppi("/Canvas/Pages/PlayerProfilePage"), nullptr); - } - - if (GameObject::Paimon != nullptr && GameObject::ProfileLayer != nullptr) { - auto ProfileOpen = app::GameObject_get_active(GameObject::ProfileLayer, nullptr); + if (GameObject::ProfileLayer == nullptr) + return; - if (ProfileOpen) { - app::GameObject_set_active(GameObject::Paimon, false, nullptr); - } - else { - app::GameObject_set_active(GameObject::Paimon, true, nullptr); + if (GameObject::Paimon->fields._.m_CachedPtr != nullptr && GameObject::ProfileLayer->fields._.m_CachedPtr != nullptr) + { + auto ProfileOpen = app::GameObject_get_active(GameObject::ProfileLayer, nullptr); + + if (ProfileOpen) + app::GameObject_set_active(GameObject::Paimon, false, nullptr); + else + app::GameObject_set_active(GameObject::Paimon, true, nullptr); } } - nextUpdate = currentTime + (int)f_DelayUpdate; + else + { + GameObject::Paimon == nullptr; + GameObject::ProfileLayer == nullptr; + } } } \ No newline at end of file diff --git a/cheat-library/src/user/cheat/visuals/PaimonFollow.h b/cheat-library/src/user/cheat/visuals/PaimonFollow.h index 3713d98..39d5e6b 100644 --- a/cheat-library/src/user/cheat/visuals/PaimonFollow.h +++ b/cheat-library/src/user/cheat/visuals/PaimonFollow.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include namespace cheat::feature { @@ -16,9 +15,6 @@ namespace cheat::feature virtual bool NeedStatusDraw() const override; void DrawStatus() override; private: - SafeQueue toBeUpdate; - SafeValue nextUpdate; - int f_DelayUpdate = 100; void OnGameUpdate(); PaimonFollow();