Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. void pphard::NewNewAnimationFix(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
  2. {
  3. static float ShotTime[65];
  4.  
  5. static float oldSimtime[65];
  6. static float storedSimtime[65];
  7.  
  8. static Vector oldEyeAngles[65];
  9. static float oldGoalfeetYaw[65];
  10. static Vector oldOrigin[65];
  11.  
  12. float* PosParams = reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(pEnt) + 0x2774);
  13. bool shot = false;
  14.  
  15. auto* AnimState = pEnt->AnimState();
  16. if (!AnimState || !pEnt->AnimOverlays() || !PosParams)
  17. return;
  18.  
  19. if (*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x164) < 0)
  20. * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
  21.  
  22. bool update = false;
  23.  
  24. if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
  25. {
  26. pEnt->ClientAnimations(true);
  27. pEnt->UpdateClientAnimation();
  28. pEnt->ClientAnimations(false);
  29.  
  30. update = true;
  31. }
  32.  
  33. oldGoalfeetYaw[pEnt->EntIndex()] = AnimState->m_flGoalFeetYaw;
  34.  
  35. if (pEnt->GetActiveWeapon() && !pEnt->IsKnifeorNade())
  36. {
  37. if (ShotTime[pEnt->EntIndex()] != pEnt->GetActiveWeapon()->GetLastShotTime())
  38. {
  39. shot = true;
  40. ShotTime[pEnt->EntIndex()] = pEnt->GetActiveWeapon()->GetLastShotTime();
  41. }
  42. else
  43. shot = false;
  44. }
  45. else
  46. {
  47. shot = false;
  48. ShotTime[pEnt->EntIndex()] = 0.f;
  49. }
  50.  
  51. if (pLocalEnt && pLocalEnt->IsAlive())
  52. {
  53. float angToLocal = g_Math.NormalizeYaw(g_Math.CalcAngle(pLocalEnt->GetOrigin(), pEnt->GetOrigin()).y);
  54.  
  55. float Back = g_Math.NormalizeYaw(angToLocal);
  56. float DesyncFix = 0;
  57.  
  58. float Resim = g_Math.NormalizeYaw((TICKS_TO_TIME(16) / (pEnt->GetSimulationTime() - oldSimtime[pEnt->EntIndex()])) * g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y));
  59.  
  60. if (Resim > 60.f)
  61. Resim = 60.f;
  62. if (Resim < -60.f)
  63. Resim = -60.f;
  64.  
  65. if (c_config::get().ResolverType == 0 && !shot && !isnan(angToLocal) && !isinf(angToLocal) && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam())
  66. {
  67. float AntiSide = 0.f;
  68.  
  69. if (Globals::MissedShots[pEnt->EntIndex()] % 2)
  70. {
  71. if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) > 0.f)
  72. AntiSide = -90.f;
  73. else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) < 0.f)
  74. AntiSide = 90.f;
  75. }
  76. else
  77. {
  78. if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) > 0.f)
  79. AntiSide = 180.f;
  80. else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) < 0.f)
  81. AntiSide = 0.f;
  82. }
  83.  
  84. float Brute = g_Math.NormalizeYaw(Back + AntiSide);
  85. float Delta = g_Math.NormalizeYaw(g_Math.NormalizeYaw(Brute - pEnt->GetEyeAngles().y) + Resim);
  86.  
  87. if (Delta > 60.f)
  88. Delta = 60.f;
  89. if (Delta < -60.f)
  90. Delta = -60.f;
  91.  
  92. Resim += Delta;
  93. DesyncFix += Delta;
  94.  
  95. if (Resim > 60.f)
  96. Resim = 60.f;
  97. if (Resim < -60.f)
  98. Resim = -60.f;
  99. }
  100.  
  101. float Equalized;
  102.  
  103. Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y + Resim);
  104.  
  105. if (c_config::get().ResolverType == 0 && !shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND))
  106. AnimState->m_flGoalFeetYaw = Equalized;
  107. }
  108.  
  109. if (c_config::get().ResolverType == 0 && !shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam())
  110. {
  111. switch (Globals::MissedShots[pEnt->EntIndex()] % 3)
  112. {
  113. case 1:PosParams[12] = 89.f; break;
  114. case 2:PosParams[12] = -89.f; break;
  115. }
  116. }
  117.  
  118. if (shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && PosParams[12] <= -80)
  119. PosParams[12] = 89.f;
  120.  
  121. if (update)
  122. {
  123. oldEyeAngles[pEnt->EntIndex()] = pEnt->GetEyeAngles();
  124. oldSimtime[pEnt->EntIndex()] = storedSimtime[pEnt->EntIndex()];
  125. storedSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
  126. oldOrigin[pEnt->EntIndex()] = pEnt->GetOrigin();
  127. }
  128.  
  129. pEnt->SetAbsAngles(Vector(0, oldGoalfeetYaw[pEnt->EntIndex()], 0));
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement