Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
(Improved animfix) Fix eyeAngles hook not working
Browse files Browse the repository at this point in the history
Now the model will "lean" accordingly
  • Loading branch information
notgoodusename committed Sep 11, 2022
1 parent 0d5b39a commit 09eec0b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
20 changes: 20 additions & 0 deletions Osiris/Hacks/Animations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnimationLayer, 13> staticLayers{};
static std::array<AnimationLayer, 13> layers{};
static float primaryCycle{ 0.0f };
Expand Down Expand Up @@ -60,6 +62,8 @@ void Animations::reset() noexcept
gotMatrixFakelag = false;
gotMatrixReal = false;
viewangles = Vector{};
correctAngle = Vector{};
buildTransformsIndex = -1;
staticLayers = {};
layers = {};
primaryCycle = 0.0f;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Osiris/Hacks/Animations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 13 additions & 8 deletions Osiris/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,12 @@ static void __fastcall buildTransformationsHook(void* thisPointer, void* edx, CS
{
static auto original = hooks->buildTransformations.getOriginal<void>(hdr, pos, q, cameraTransform, boneMask, boneComputed);

const UtlVector<int> backupFlags = hdr->boneFlags;
const auto entity = reinterpret_cast<Entity*>(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<int> backupFlags = hdr->boneFlags;

for (int i = 0; i < hdr->boneFlags.size; i++)
{
if(config->visuals.disableJiggleBones)
Expand Down Expand Up @@ -1432,15 +1436,16 @@ static Vector* __fastcall eyeAnglesHook(void* thisPointer, void* edx) noexcept
const auto entity = reinterpret_cast<Entity*>(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
Expand Down
2 changes: 0 additions & 2 deletions Osiris/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions Osiris/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 09eec0b

Please sign in to comment.