diff --git a/Osiris/Hacks/Animations.cpp b/Osiris/Hacks/Animations.cpp index 70f137ff..c1af60fb 100644 --- a/Osiris/Hacks/Animations.cpp +++ b/Osiris/Hacks/Animations.cpp @@ -29,6 +29,8 @@ static bool gotMatrix{ false }; static bool gotMatrixFakelag{ false }; static bool gotMatrixReal{ false }; static Vector viewangles{}; +static Vector correctAngle{}; +static int buildTransformsIndex = -1; static std::array staticLayers{}; static std::array layers{}; static float primaryCycle{ 0.0f }; @@ -60,6 +62,8 @@ void Animations::reset() noexcept gotMatrixFakelag = false; gotMatrixReal = false; viewangles = Vector{}; + correctAngle = Vector{}; + buildTransformsIndex = -1; staticLayers = {}; layers = {}; primaryCycle = 0.0f; @@ -660,6 +664,22 @@ void Animations::postDataUpdate() noexcept localPlayer->getAnimstate()->moveWeight = moveWeight; } +void Animations::saveCorrectAngle(int entityIndex, Vector correctAng) noexcept +{ + buildTransformsIndex = entityIndex; + correctAngle = correctAng; +} + +int& Animations::buildTransformationsIndex() noexcept +{ + return buildTransformsIndex; +} + +Vector* Animations::getCorrectAngle() noexcept +{ + return &correctAngle; +} + Vector* Animations::getViewAngles() noexcept { return &viewangles; diff --git a/Osiris/Hacks/Animations.h b/Osiris/Hacks/Animations.h index fb28fa4b..eb3d2dde 100644 --- a/Osiris/Hacks/Animations.h +++ b/Osiris/Hacks/Animations.h @@ -26,6 +26,11 @@ namespace Animations void packetStart() noexcept; void postDataUpdate() noexcept; + void saveCorrectAngle(int entityIndex, Vector correctAngle) noexcept; + + int& buildTransformationsIndex() noexcept; + + Vector* getCorrectAngle() noexcept; Vector* getViewAngles() noexcept; Vector* getLocalAngle() noexcept; diff --git a/Osiris/Hooks.cpp b/Osiris/Hooks.cpp index f002ae9f..6377b216 100644 --- a/Osiris/Hooks.cpp +++ b/Osiris/Hooks.cpp @@ -781,8 +781,12 @@ static void __fastcall buildTransformationsHook(void* thisPointer, void* edx, CS { static auto original = hooks->buildTransformations.getOriginal(hdr, pos, q, cameraTransform, boneMask, boneComputed); - const UtlVector backupFlags = hdr->boneFlags; + const auto entity = reinterpret_cast(thisPointer); + if (entity && entity->isAlive() && localPlayer && localPlayer.get() == entity && entity->getAnimstate()) + Animations::saveCorrectAngle(entity->index(), Vector{ entity->getAnimstate()->eyePitch, entity->getAnimstate()->eyeYaw, Animations::getLocalAngle()->z }); + const UtlVector backupFlags = hdr->boneFlags; + for (int i = 0; i < hdr->boneFlags.size; i++) { if(config->visuals.disableJiggleBones) @@ -1432,15 +1436,16 @@ static Vector* __fastcall eyeAnglesHook(void* thisPointer, void* edx) noexcept const auto entity = reinterpret_cast(thisPointer); if (!localPlayer || entity != localPlayer.get()) return original(thisPointer); - - if (std::uintptr_t(_ReturnAddress()) == memory->eyeAnglesYaw - || std::uintptr_t(_ReturnAddress()) == memory->eyeAnglesPitch) - return Animations::getViewAngles(); - if (std::uintptr_t(_ReturnAddress()) == memory->eyePositionAndVectors) - return Animations::getLocalAngle(); + if (std::uintptr_t(_ReturnAddress()) != memory->eyePositionAndVectors) + return original(thisPointer); - return original(thisPointer); + if (Animations::buildTransformationsIndex() == -1 || Animations::buildTransformationsIndex() != entity->index()) + return original(thisPointer); + + Animations::buildTransformationsIndex() = -1; + + return Animations::getCorrectAngle(); } void resetAll(int resetType) noexcept diff --git a/Osiris/Memory.cpp b/Osiris/Memory.cpp index 063219a6..0bf462a2 100644 --- a/Osiris/Memory.cpp +++ b/Osiris/Memory.cpp @@ -216,8 +216,6 @@ Memory::Memory() noexcept isDepthOfFieldEnabled = findPattern(CLIENT_DLL, "\x8B\x0D????\x56\x8B\x01\xFF\x50\x34\x8B\xF0\x85\xF6\x75\x04"); eyeAngles = findPattern(CLIENT_DLL, "\x56\x8B\xF1\x85\xF6\x74\x32"); eyePositionAndVectors = findPattern(CLIENT_DLL, "\x8B\x55\x0C\x8B\xC8\xE8????\x83\xC4\x08\x5E\x8B\xE5"); - eyeAnglesYaw = findPattern(CLIENT_DLL, "\xF3\x0F\x10\x55?\x51\x8B\x8E????"); - eyeAnglesPitch = findPattern(CLIENT_DLL, "\x8B\xCE\xF3\x0F\x10\x00\x8B\x06\xF3\x0F\x11\x45?\xFF\x90????\xF3\x0F\x10\x55?"); calcViewBob = findPattern(CLIENT_DLL, "\x55\x8B\xEC\xA1????\x83\xEC\x10\x56\x8B\xF1\xB9????"); getClientModelRenderable = findPattern(CLIENT_DLL, "\x56\x8B\xF1\x80\xBE?????\x0F\x84????\x80\xBE"); physicsSimulate = findPattern(CLIENT_DLL, "\x56\x8B\xF1\x8B?????\x83\xF9\xFF\x74\x23"); diff --git a/Osiris/Memory.h b/Osiris/Memory.h index 885d377f..74c07d36 100644 --- a/Osiris/Memory.h +++ b/Osiris/Memory.h @@ -194,8 +194,6 @@ class Memory { std::uintptr_t isDepthOfFieldEnabled; std::uintptr_t eyeAngles; std::uintptr_t eyePositionAndVectors; - std::uintptr_t eyeAnglesYaw; - std::uintptr_t eyeAnglesPitch; std::uintptr_t calcViewBob; std::uintptr_t getClientModelRenderable; std::uintptr_t physicsSimulate;