nahbr0

Untitled

Sep 5th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. void c_ragebot::autostop(c_cs_player* local, c_user_cmd* cmd)
  2. {
  3. if (cmd->buttons & c_user_cmd::jump)
  4. return;
  5.  
  6. static const auto nospread = cvar()->find_var(_("weapon_accuracy_nospread"));
  7.  
  8. const auto weapon = reinterpret_cast<c_base_combat_weapon*>(
  9. client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle()));
  10.  
  11. if (nospread->get_int() || !local->is_on_ground() ||
  12. (weapon && weapon->get_item_definition() == weapon_taser) && local->is_on_ground())
  13. return;
  14.  
  15. const auto wpn_info = weapon_system->get_weapon_data(weapon->get_item_definition());
  16.  
  17. if (!wpn_info)
  18. return;
  19.  
  20. auto& info = get_autostop_info();
  21.  
  22. if (info.call_time == global_vars_base->curtime)
  23. {
  24. info.did_stop = true;
  25. return;
  26. }
  27.  
  28. info.did_stop = false;
  29. info.call_time = global_vars_base->curtime;
  30.  
  31. if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon))
  32. return;
  33. else
  34. {
  35. cmd->forwardmove = 0.f;
  36. cmd->sidemove = 0.f;
  37.  
  38. prediction_system->repredict(local, cmd);
  39.  
  40. if (config.rage.slow_walk && GetAsyncKeyState(config.rage.slow_walk))
  41. {
  42. info.did_stop = true;
  43. return;
  44. }
  45.  
  46. if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon))
  47. return;
  48. }
  49.  
  50. c_qangle dir;
  51. math::vector_angles(prediction_system->unpredicted_velocity, dir);
  52. const auto angles = engine_client()->get_view_angles();
  53. dir.y = angles.y - dir.y;
  54.  
  55. c_vector3d move;
  56. math::angle_vectors(dir, move);
  57.  
  58. if (prediction_system->unpredicted_velocity.length2d() > .1f)
  59. move *= -math::forward_bounds / std::max(std::abs(move.x), std::abs(move.y));
  60.  
  61. cmd->forwardmove = move.x;
  62. cmd->sidemove = move.y;
  63.  
  64. const auto backup = cmd->viewangles;
  65. cmd->viewangles = angles;
  66. prediction_system->repredict(local, cmd);
  67. cmd->viewangles = backup;
  68.  
  69. if (local->get_velocity().length2d() > prediction_system->unpredicted_velocity.length2d())
  70. {
  71. cmd->forwardmove = 0.f;
  72. cmd->sidemove = 0.f;
  73. }
  74.  
  75. prediction_system->repredict(local, cmd);
  76. }
Add Comment
Please, Sign In to add comment