Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #pragma once
  2. #include "../SDK/CEntity.h"
  3. #include "../SDK/CGlobalVarsBase.h"
  4. #include "AnimFix.h"
  5. #include "../SDK/ICvar.h"
  6.  
  7. AnimFix g_pAnimFix;
  8.  
  9. void UpdateAnimations(C_BaseEntity* player)
  10. {
  11. auto state = player->AnimState();
  12. if (state)
  13. {
  14. // backup
  15. const float curtime = g_pGlobalVars->curtime;
  16. const float frametime = g_pGlobalVars->frametime;
  17.  
  18. static auto host_timescale = g_pCvar->FindVar(("host_timescale"));
  19.  
  20. g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick * host_timescale->GetFloat();
  21. g_pGlobalVars->curtime = player->GetSimulationTime();
  22.  
  23. int backup_eflags = player->EFlags();
  24.  
  25. // SetLocalVelocity
  26. player->EFlags() &= ~0x1000; // InvalidatePhysicsRecursive(VELOCITY_CHANGED); EFL_DIRTY_ABSVELOCITY = 0x1000
  27.  
  28. player->SetAbsVelocity(player->GetVelocity());
  29.  
  30. // invalidates prior animations
  31. if (state->m_iLastClientSideAnimationUpdateFramecount == g_pGlobalVars->framecount)
  32. state->m_iLastClientSideAnimationUpdateFramecount = g_pGlobalVars->framecount - 1;
  33.  
  34. player->ClientAnimations() = true;
  35.  
  36. // updates local animations + poses + calculates new abs angle based on eyeangles and other stuff
  37. player->UpdateClientAnimation();
  38.  
  39. player->ClientAnimations() = false;
  40.  
  41. // restore
  42. player->EFlags() = backup_eflags;
  43.  
  44. g_pGlobalVars->curtime = curtime;
  45. g_pGlobalVars->frametime = frametime;
  46.  
  47. player->InvalidateBoneCache();
  48. player->SetupBones(nullptr, -1, 0x7FF00, g_pGlobalVars->curtime);
  49. }
  50. }
  51.  
  52. void AnimFix::AnimFixF(C_BaseEntity* player) {
  53. auto AnimState = player->AnimState();
  54. if (*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x164) < 0) // onground fix
  55. * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
  56.  
  57. // breaks a check in doextraboneprocessing preventing doproceduralfootplant from being called
  58. const auto _backup = *(byte*)(uintptr_t(this) + ptrdiff_t(0x270));
  59.  
  60. *(byte*)(uintptr_t(this) + ptrdiff_t(0x270)) = 0;
  61.  
  62. if (player->GetOldSimulationTime() != player->GetSimulationTime())
  63. {
  64. UpdateAnimations(player);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement