Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. / Ragebot class
  2. int m_iRotate = 0;
  3. int m_iRotateIteration = 0;
  4.  
  5. float m_flCurrentFeetYaw = 0.0f;
  6. float m_flPreviousFeetYaw = 0.0f;
  7.  
  8. bool m_bAutomaticDir = false;
  9. int m_iAutoDirection = 0;
  10.  
  11. // Autodirection stuff
  12. float distance = g_LocalPlayer->m_vecOrigin().Dot(player->m_vecOrigin());
  13. m_iAutoDirection = 2 * ( distance <= 0.0f ) - 1;
  14. m_bAutomaticDir = true;
  15.  
  16. // Desync
  17. void Ragebot::DesyncAnimations( int type ) {
  18. enum DesyncAA {
  19. Still = 1,
  20. Balance,
  21. Stretch,
  22. Jitter
  23. };
  24.  
  25. if ( m_bAutomaticDir ) {
  26. if ( rbot_antiaim_autodir == 2 ) {
  27. type = 3 - ( m_iAutoDirection != 1 );
  28. g_Context->m_Cmd->viewangles.y -= 90.0f * static_cast< float >( m_iAutoDirection );
  29. } else if ( rbot_antiaim_autodir == 3 ) {
  30. type = Jitter;
  31. }
  32. }
  33.  
  34. if ( !type )
  35. return;
  36.  
  37. g_Context->m_Cmd->viewangles.y = Math::AngleNormalize( g_Context->m_Cmd->viewangles.y );
  38.  
  39. if ( type == Jitter ) {
  40. int jitter_side = 1;
  41. if ( rbot_antiaim_autodir ) {
  42. jitter_side = m_iAutoDirection;
  43. if ( !m_bAutomaticDir )
  44. g_Context->m_Cmd->viewangles.y += 90.0f * static_cast< float >( m_iAutoDirection );
  45. } else {
  46. g_Context->m_Cmd->viewangles.y += 90.0f;
  47. }
  48.  
  49. float desync = g_LocalPlayer->m_PlayerAnimState()->GetDesyncDelta();
  50. float inverse_desync = 190.0f - desync;
  51. float jitter = 180.0f - inverse_desync * 0.5f;
  52.  
  53. if ( jitter_side == 1 )
  54. g_Context->m_Cmd->viewangles.y += jitter;
  55. else if ( jitter_side == -1 )
  56. g_Context->m_Cmd->viewangles.y -= jitter;
  57.  
  58. #if 0
  59. float jitterRotate = 90.0f * jitter_side + g_Context->m_Cmd->viewangles.yaw;
  60. if ( DesyncRotate( jitterRotate, jitter_side ) ) {
  61. m_iRotate = 0;
  62. return;
  63. }
  64. #endif
  65.  
  66. int rotate = 0;
  67. if ( g_GlobalVars->curtime < g_Context->m_flLBYUpdateTime ) {
  68. rotate = m_iRotate;
  69. } else {
  70. m_iRotate = 0;
  71. }
  72.  
  73. rotate--;
  74. if ( rotate ) {
  75. if ( rotate == 1 ) {
  76. if ( jitter_side == 1 )
  77. g_Context->m_Cmd->viewangles.yaw += inverse_desync;
  78. else
  79. g_Context->m_Cmd->viewangles.yaw += desync - 190.0f;
  80. }
  81. } else {
  82. if ( jitter_side == 1 )
  83. g_Context->m_Cmd->viewangles.yaw += desync - 190.0f;
  84. else
  85. g_Context->m_Cmd->viewangles.yaw += inverse_desync;
  86. g_Context->m_bShouldChoke = true;
  87. }
  88.  
  89. if ( ++m_iRotate >= 3 )
  90. m_iRotate = 0;
  91. } else {
  92. #if 0
  93. float stretch = g_Context->m_Cmd->viewangles.y;
  94. if ( type == Stretch )
  95. stretch -= 90.0f;
  96. else
  97. stretch += 90.0f;
  98. stretch = Math::AngleNormalize( stretch );
  99. if ( DesyncRotate( stretch, type == Stretch ) )
  100. return;
  101. #endif
  102.  
  103. float desync = g_LocalPlayer->m_PlayerAnimState()->GetDesyncDelta();
  104. float balance = 1.0f;
  105. if ( type == Balance )
  106. balance = -1.0f;
  107.  
  108. if ( g_Context->m_flLBYUpdateTime >= g_GlobalVars->curtime ) {
  109. if ( !g_Context->m_bShouldChoke && g_ClientState->chokedcommands >= 2 ) {
  110. g_Context->m_Cmd->viewangles.yaw = Math::AngleNormalize( g_Context->m_Cmd->viewangles.yaw );
  111. return;
  112. }
  113.  
  114. if ( type == Still )
  115. g_Context->m_Cmd->viewangles.yaw -= 100.0f;
  116. else
  117. g_Context->m_Cmd->viewangles.yaw += ( balance * 120.0f );
  118. } else if ( type != Still ) {
  119. // lby breaker
  120. g_Context->m_Cmd->viewangles.yaw -= ( desync + 30.0f ) * balance;
  121. }
  122.  
  123. g_Context->m_bShouldChoke = true;
  124. }
  125.  
  126. g_Context->m_Cmd->viewangles.yaw = Math::AngleNormalize( g_Context->m_Cmd->viewangles.yaw );
  127. }
  128.  
  129. bool Ragebot::DesyncRotate( float rotation, int direction ) {
  130. CCSGOPlayerAnimState* animState = g_LocalPlayer->m_PlayerAnimState();
  131. float feetYaw = DEG2RAD( animState->m_flGoalFeetYaw );
  132.  
  133. float feetSin, feetCos;
  134. DirectX::XMScalarSinCos( &feetSin, &feetCos, feetYaw );
  135.  
  136. float feetSin1, feetCos1;
  137. DirectX::XMScalarSinCos( &feetSin1, &feetCos1, m_flGoalFeetYaw );
  138.  
  139. float feetSin2, feetCos2;
  140. DirectX::XMScalarSinCos( &feetSin2, &feetCos2, m_flPreviousFeetYaw );
  141.  
  142. m_flPreviousFeetYaw = m_flGoalFeetYaw;
  143. m_flGoalFeetYaw = animState->m_flGoalFeetYaw;
  144.  
  145. float totalRotation = atan2( feetSin1 + feetSin + feetSin2, feetCos1 + feetCos + feetCos2 );
  146. totalRotation = Math::AngleNormalize( RAD2DEG( totalRotation ) - rotation );
  147. if ( direction == 1 ) {
  148. if ( totalRotation >= 0.0f ) {
  149. m_iRotateIteration = 1;
  150. return false;
  151. }
  152. } else if ( totalRotation <= 0.0f ) {
  153. m_iRotateIteration = 1;
  154. return false;
  155. }
  156.  
  157. float rotate = static_cast< float >( 30 * ( m_iRotateIteration % 12 ) );
  158. if ( direction == 1 )
  159. g_Context->m_Cmd->viewangles.y -= rotate;
  160. else
  161. g_Context->m_Cmd->viewangles.y += rotate;
  162.  
  163. g_Context->m_Cmd->viewangles.y = Math::AngleNormalize( g_Context->m_Cmd->viewangles.y );
  164. g_Context->m_bShouldChoke = true;
  165. ++m_iRotateIteration;
  166. return true;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement