Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. void c_animations::local::correct_client_anims() {
  2. if (!cheat::local || !cheat::local->alive())
  3. return;
  4.  
  5. sdk::c_animstate* animstate = cheat::local->animstate();
  6.  
  7. if (!animstate)
  8. return;
  9.  
  10. // Backing up current values for restoring later.
  11. float old_curtime = cheat::globals->curtime, old_frametime = cheat::globals->frametime;
  12.  
  13. // Resimulate recent commands to refresh the data for animstate.
  14. cheat::prediction->run_command(cheat::vars::local_cmd);
  15.  
  16. // Syncing our predicted current time with the server.
  17. cheat::globals->curtime = cheat::globals->realtime * cheat::local->anim_layer(0);
  18.  
  19. // Fixes the client fucking up frametime under certain conditions.
  20. cheat::globals->frametime = ((cheat::globals->curtime % 2.f) == 0.f) ?
  21. (cheat::local->poseparam(ePoses::BODY_YAW /*11*/) * cheat::globals->tick_interval) :
  22. (cheat::local->tickbase() * cheat::globals->tick_interval);
  23.  
  24. float corrected_abs_yaw = animstate->old_absyaw;
  25.  
  26. // Always negate the old position.
  27. if (corrected_abs_yaw > 0.f)
  28. corrected_abs_yaw *= -1.f;
  29.  
  30. // The clients abs yaw is desynced when the yaw is at a certain position at a certain time.
  31. // We correct it by negating the old value which is negated when required, to mimic server functionality.
  32. if ((cheat::local->eye_angles().yaw >= -45.f && cheat::local->eye_angles().yaw <= 45.f) && ((cheat::globals->curtime % 2.f) == 0.f))
  33. cheat::local->set_abs_angles(sdk::angle_t(0.f, animstate->abs_yaw - corrected_abs_yaw, 0.f));
  34.  
  35. // Rebuilding bones with corrected values, we'll need to do this twice.
  36. // Once here, and once after updating bones. This is to maintain correct shootpos.
  37. sdk::c_matrix3x4 temp_matrix[128];
  38. local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix);
  39.  
  40. // Forcing the client to update anims under all circumstances.
  41. animstate->last_update_framecount = 0.f;
  42.  
  43. // Update clientside anims.
  44. cheat::local->client_anims = true;
  45. cheat::local->update_client_anims();
  46. cheat::local->client_anims = false;
  47.  
  48. // Explained above.
  49. local->setup_bones(cheat::globals->curtime, 0x00000100, temp_matrix);
  50.  
  51. // Restore values to not mess with the game.
  52. cheat::globals->curtime = old_curtime;
  53. cheat::globals->frametime = old_frametime;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement