Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. CPP:
  2.  
  3. void airstrafe::create_move() {
  4.  
  5.     static auto down = [](ButtonCode_t bt) -> bool {
  6.         return g_csgo.m_inputsys()->IsButtonDown(bt);
  7.     };
  8.  
  9.     if (g_ctx.m_local->get_move_type() == MoveType_t::MOVETYPE_NOCLIP || g_ctx.m_local->get_move_type() == MoveType_t::MOVETYPE_LADDER)
  10.         return;
  11.  
  12.     if (!GetAsyncKeyState(VK_SPACE) || g_ctx.m_local->m_vecVelocity().Length2D() < 0.5)
  13.         return;
  14.  
  15.     if (!(g_ctx.m_local->m_fFlags() & FL_ONGROUND)) {
  16.         static float cl_sidespeed = g_csgo.m_cvar()->FindVar("cl_sidespeed")->GetFloat();
  17.         if (fabsf(g_ctx.get_command()->m_mousedx > 2)) {
  18.             g_ctx.get_command()->m_sidemove = (g_ctx.get_command()->m_mousedx < 0.f) ? -cl_sidespeed : cl_sidespeed;
  19.             return;
  20.         }
  21.  
  22.  
  23.         if (GetAsyncKeyState('S')) {
  24.             g_ctx.get_command()->m_viewangles.y -= 180;
  25.         }
  26.         else if (GetAsyncKeyState('D')) {
  27.             g_ctx.get_command()->m_viewangles.y -= 90;
  28.         }
  29.         else if (GetAsyncKeyState('A')) {
  30.             g_ctx.get_command()->m_viewangles.y += 90;
  31.         }
  32.  
  33.  
  34.         if (!g_ctx.m_local->m_vecVelocity().Length2D() > 0.5 || g_ctx.m_local->m_vecVelocity().Length2D() == NAN || g_ctx.m_local->m_vecVelocity().Length2D() == INFINITE)
  35.         {
  36.             g_ctx.get_command()->m_forwardmove = 400;
  37.             return;
  38.         }
  39.  
  40.         g_ctx.get_command()->m_forwardmove = math::clamp(5850.f / g_ctx.m_local->m_vecVelocity().Length2D(), -400, 400);
  41.         if ((g_ctx.get_command()->m_forwardmove < -400 || g_ctx.get_command()->m_forwardmove > 400))
  42.             g_ctx.get_command()->m_forwardmove = 0;
  43.  
  44.         const auto vel = g_ctx.m_local->m_vecVelocity();
  45.         const float y_vel = RAD2DEG(atan2(vel.y, vel.x));
  46.         const float diff_ang = math::normalize_yaw(g_ctx.get_command()->m_viewangles.y - y_vel);
  47.  
  48.         g_ctx.get_command()->m_sidemove = (diff_ang > 0.0) ? -cl_sidespeed : cl_sidespeed;
  49.         g_ctx.get_command()->m_viewangles.y = math::normalize_yaw(g_ctx.get_command()->m_viewangles.y - diff_ang);
  50.     }
  51. }
  52.  
  53. H:
  54. class airstrafe : public singleton< airstrafe > {
  55. public:
  56.     void create_move( );
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement