Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "../SDK/CEntity.h"
- #include "../SDK/CGlobalVarsBase.h"
- #include "AnimFix.h"
- #include "../SDK/ICvar.h"
- AnimFix g_pAnimFix;
- void UpdateAnimations(C_BaseEntity* player)
- {
- auto state = player->AnimState();
- if (state)
- {
- // backup
- const float curtime = g_pGlobalVars->curtime;
- const float frametime = g_pGlobalVars->frametime;
- static auto host_timescale = g_pCvar->FindVar(("host_timescale"));
- g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick * host_timescale->GetFloat();
- g_pGlobalVars->curtime = player->GetSimulationTime();
- int backup_eflags = player->EFlags();
- // SetLocalVelocity
- player->EFlags() &= ~0x1000; // InvalidatePhysicsRecursive(VELOCITY_CHANGED); EFL_DIRTY_ABSVELOCITY = 0x1000
- player->SetAbsVelocity(player->GetVelocity());
- // invalidates prior animations
- if (state->m_iLastClientSideAnimationUpdateFramecount == g_pGlobalVars->framecount)
- state->m_iLastClientSideAnimationUpdateFramecount = g_pGlobalVars->framecount - 1;
- player->ClientAnimations() = true;
- // updates local animations + poses + calculates new abs angle based on eyeangles and other stuff
- player->UpdateClientAnimation();
- player->ClientAnimations() = false;
- // restore
- player->EFlags() = backup_eflags;
- g_pGlobalVars->curtime = curtime;
- g_pGlobalVars->frametime = frametime;
- player->InvalidateBoneCache();
- player->SetupBones(nullptr, -1, 0x7FF00, g_pGlobalVars->curtime);
- }
- }
- void AnimFix::AnimFixF(C_BaseEntity* player) {
- auto AnimState = player->AnimState();
- if (*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x164) < 0) // onground fix
- * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
- // breaks a check in doextraboneprocessing preventing doproceduralfootplant from being called
- const auto _backup = *(byte*)(uintptr_t(this) + ptrdiff_t(0x270));
- *(byte*)(uintptr_t(this) + ptrdiff_t(0x270)) = 0;
- if (player->GetOldSimulationTime() != player->GetSimulationTime())
- {
- UpdateAnimations(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement