Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. void Resolver::AnimationFix(C_BaseEntity* pEnt)
  2. {
  3. if (pEnt == Globals::LocalPlayer) {
  4. auto* player_animation_state = pEnt->AnimState();
  5. static AnimationLayer backup_layers[15];
  6. if (!backup_layers)
  7. {
  8. std::memcpy(backup_layers, Globals::LocalPlayer->GetAnimOverlays4(), (sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays()));
  9. }
  10.  
  11. static float proper_abs = Globals::LocalPlayer->AnimState()->m_flGoalFeetYaw;
  12. static float sent_pose_params = *Globals::LocalPlayer->m_flPoseParameter();
  13. //static std::array<float, 24> sent_pose_params = *Globals::LocalPlayer->m_flPoseParameter();
  14. static int oldtickcount = 0;
  15.  
  16. if (Globals::LocalPlayer->AnimState()->m_iLastClientSideAnimationUpdateFramecount == g_pGlobalVars->framecount)
  17. {
  18. Globals::LocalPlayer->AnimState()->m_iLastClientSideAnimationUpdateFramecount = g_pGlobalVars->framecount - 1;
  19. }
  20.  
  21. if (oldtickcount != CUserCmd().tick_count) // Only update animations each tick, though we are doing this each frame.
  22. {
  23. oldtickcount = CUserCmd().tick_count;
  24. std::memcpy(backup_layers, Globals::LocalPlayer->GetAnimOverlays4(), (sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays()));
  25. Globals::LocalPlayer->ClientAnimations(true); //just does stuff like set m_bClientSideAnimation and m_iLastAnimUpdateFrameCount
  26. Globals::LocalPlayer->UpdateState(Globals::LocalPlayer->AnimState(), Globals::pCmd->viewangles); Globals::LocalPlayer->SetAbsAngles(Vector(0, Globals::RealAngle.y, 0));
  27.  
  28. if (Globals::bSendPacket)
  29. {
  30. proper_abs = Globals::LocalPlayer->AnimState()->m_flGoalFeetYaw;
  31. sent_pose_params = *Globals::LocalPlayer->m_flPoseParameter();
  32. }
  33.  
  34. Globals::LocalPlayer->ClientAnimations(false);
  35. Globals::LocalPlayer->AnimState()->m_flGoalFeetYaw = proper_abs;
  36. Globals::LocalPlayer->AnimState()->m_flUnknownFraction = 0.f; // Lol.
  37. std::memcpy(Globals::LocalPlayer->GetAnimOverlays4(), backup_layers, (sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays()));
  38. *Globals::LocalPlayer->m_flPoseParameter() = sent_pose_params;
  39. Globals::LocalPlayer->SetAbsAngles(Vector(0, proper_abs, 0));
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement