diff --git a/lib/private/ClientHelper.cpp b/lib/private/ClientHelper.cpp index 6fd1b30..46beb25 100644 --- a/lib/private/ClientHelper.cpp +++ b/lib/private/ClientHelper.cpp @@ -21,6 +21,28 @@ bool IsHost() return app::BoltNetwork_get_IsServer(NULL); } +app::Survival* GetSurvivalObject() +{ + static app::Survival* cachedSurvival = nullptr; + + if (cachedSurvival == nullptr || Object::IsNull((app::Object_1*)cachedSurvival)) { + cachedSurvival = Object::FindObjectOfType("Survival"); + } + + return cachedSurvival; +} + +app::OptionsHelpers* GetOptionsHelpersObject() +{ + static app::OptionsHelpers* cachedOptionsHelpers = nullptr; + + if (cachedOptionsHelpers == nullptr || Object::IsNull((app::Object_1*)cachedOptionsHelpers)) { + cachedOptionsHelpers = Object::FindObjectOfType("OptionsHelpers"); + } + + return cachedOptionsHelpers; +} + bool IsLocalPlayer(app::NolanBehaviour* player) { auto boltEntity = app::EntityBehaviour_get_entity((app::EntityBehaviour*)player, NULL); @@ -59,7 +81,7 @@ bool IsPlayerCrawling(app::GameObject* go) bool IsInGame() { - app::OptionsHelpers* optionsHelpers = Object::FindObjectOfType("OptionsHelpers"); + app::OptionsHelpers* optionsHelpers = GetOptionsHelpersObject(); if (optionsHelpers) return optionsHelpers->fields._inGame_k__BackingField; @@ -69,20 +91,17 @@ bool IsInGame() bool IsSequencePlaying() { - app::Survival* survival = Object::FindObjectOfType("Survival"); + app::Survival* survival = GetSurvivalObject(); // Return false if the object was not found. if (survival == nullptr) return false; - if (app::Survival_IsEndingPlaying != nullptr || app::Survival_IsJumpScarePlaying != nullptr || app::Survival_StartingToPlayFailEnding != nullptr) { - bool isEndingPlaying = app::Survival_IsEndingPlaying(survival, nullptr); - bool isJumpScarePlaying = app::Survival_IsJumpScarePlaying(survival, nullptr); - bool isStartingToPlayFailEnding = app::Survival_StartingToPlayFailEnding(survival, nullptr); + // Check if any of the sequences are playing and return the result directly. + if (app::Survival_IsEndingPlaying && app::Survival_IsEndingPlaying(survival, nullptr)) return true; + if (app::Survival_IsJumpScarePlaying && app::Survival_IsJumpScarePlaying(survival, nullptr)) return true; + if (app::Survival_StartingToPlayFailEnding && app::Survival_StartingToPlayFailEnding(survival, nullptr)) return true; - // Return true if any sequence is playing. - return isEndingPlaying || isJumpScarePlaying || isStartingToPlayFailEnding; - } - + // If none of the sequences are playing, return false. return false; } @@ -98,6 +117,7 @@ app::GameObject* GetAzazel(app::Survival* survival) } + std::string SceneName() { if (app::SaveHelpers_get_singleton != nullptr) { diff --git a/lib/public/ClientHelper.h b/lib/public/ClientHelper.h index e345e5a..1d7ba81 100644 --- a/lib/public/ClientHelper.h +++ b/lib/public/ClientHelper.h @@ -4,15 +4,14 @@ bool IsSinglePlayer(); bool IsOnline(); bool IsHost(); +app::Survival* GetSurvivalObject(); +app::OptionsHelpers* GetOptionsHelpersObject(); bool IsLocalPlayer(app::NolanBehaviour* player); bool IsPlayerCrawling(); bool IsPlayerCrawling(app::GameObject* go); bool IsInGame(); bool IsSequencePlaying(); - app::GameObject* GetAzazel(app::Survival* survival); - std::string SceneName(); std::string GetAzazelName(); - float Time_DeltaTime(); \ No newline at end of file diff --git a/lib/public/UnityEngine/Transform.h b/lib/public/UnityEngine/Transform.h index 46fcc90..607357f 100644 --- a/lib/public/UnityEngine/Transform.h +++ b/lib/public/UnityEngine/Transform.h @@ -20,6 +20,10 @@ namespace Transform { { if (!component) return nullptr; - return app::Component_get_transform((app::Component*)component, nullptr); + if (app::Component_get_transform != nullptr) { + return app::Component_get_transform((app::Component*)component, nullptr); + } + + return nullptr; } } \ No newline at end of file diff --git a/user/features/esp/esp.cpp b/user/features/esp/esp.cpp index 146b230..325e4a3 100644 --- a/user/features/esp/esp.cpp +++ b/user/features/esp/esp.cpp @@ -78,7 +78,7 @@ void DrawNameESP(app::Vector3 pos, std::string name, ImColor color) void ComputePositionAndDrawESP(app::Object_1__Array* ents, ImColor color, bool use_prefab = false, std::string name = "") { for (int i = 0; i < ents->max_length; i++) { app::Object_1 *ent = ents->vector[i]; - if (ent == nullptr) + if (Object::IsNull(ent)) continue; app::Transform* _transform = Transform::GetTransform(ent); @@ -144,14 +144,14 @@ void ESP::RunItemsESP() { ImColor col = ImColor{ settings::item_esp_color[0], settings::item_esp_color[1], settings::item_esp_color[2], settings::item_esp_color[3] }; app::Object_1__Array *ents = Object::FindObjectsOfType("SurvivalInteractable", ""); - if (ents != nullptr && ents->vector[0] != nullptr) { + if (ents != nullptr || !Object::IsNull(ents->vector[0])) { ComputePositionAndDrawESP(ents, col, true); } if (SceneName() != "Menu") return; ents = Object::FindObjectsOfType("KeyBehaviour", ""); - if (ents != nullptr && ents->vector[0] != nullptr) { + if (ents != nullptr || !Object::IsNull(ents->vector[0])) { ComputePositionAndDrawESP(ents, col, false, "Key"); } } @@ -159,7 +159,7 @@ void ESP::RunItemsESP() { void ESP::RunGoatsESP() { app::Object_1__Array *goats = Object::FindObjectsOfType("GoatBehaviour", ""); - if (goats == nullptr || goats->vector[0] == nullptr) + if (goats == nullptr || Object::IsNull(goats->vector[0])) return; ComputePositionAndDrawESP(goats, ImColor{ settings::goat_esp_color[0], settings::goat_esp_color[1], settings::goat_esp_color[2], settings::goat_esp_color[3] }); diff --git a/user/hooks/hooks.cpp b/user/hooks/hooks.cpp index 75e6cb5..7b8ea61 100644 --- a/user/hooks/hooks.cpp +++ b/user/hooks/hooks.cpp @@ -766,17 +766,19 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval if (settings::player_esp) ESP::RunPlayersESP(); - if (settings::goat_esp && SceneName() != "Menu") - ESP::RunGoatsESP(); + if (IsInGame() && !IsSequencePlaying()) { + if (settings::goat_esp && SceneName() != "Menu") + ESP::RunGoatsESP(); - if (settings::item_esp && SceneName() != "Menu") - ESP::RunItemsESP(); + if (settings::item_esp && SceneName() != "Menu") + ESP::RunItemsESP(); - if (settings::demon_esp) - ESP::RunDemonESP(); + if (settings::demon_esp) + ESP::RunDemonESP(); - if (settings::azazel_esp && SceneName() != "Menu") - ESP::RunAzazelESP(); + if (settings::azazel_esp && SceneName() != "Menu") + ESP::RunAzazelESP(); + } ImGui::GetIO().MouseDrawCursor = open_menu;