Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. void aimbot::work(CUserCmd* cmd)
  2. {
  3. if (!ctx::csgo.engine->IsInGame() || !ctx::csgo.engine->IsConnected())
  4. return;
  5.  
  6. functions::handle_configs();
  7.  
  8. details::best_fov = FLT_MAX;
  9. ctx::csgo.engine->GetViewAngles(details::local_angles);
  10.  
  11. game::for_every_player(
  12. [cmd](player_t* pl) -> bool
  13. {
  14. if (!pl)
  15. return false;
  16.  
  17. if (pl->IsDormant() || !pl->is_alive())
  18. return false;
  19. bool attack_enemies = config::get<bool>(ctx::cfg.attack_enemies);
  20. if (!attack_enemies && pl->is_enemy())
  21. return false;
  22.  
  23. if (!config::get<bool>(ctx::cfg.attack_friendlies) && !pl->is_enemy())
  24. return false;
  25.  
  26. if (lagcomp::records[pl->EntIndex()].m_vecRecords.empty())
  27. return false;
  28.  
  29. int hitbox_id = config::get<int>(ctx::cfg.legit_hitbox);
  30. bool target_bt = config::get<bool>(ctx::cfg.legit_target_backtrack);
  31. math::vec3_t vector_hitbox = math::vec3_t(0.f, 0.f, 0.f);
  32.  
  33. /*if (target_bt)
  34. vector_hitbox = functions::closest_record(pl);
  35. else
  36. {
  37. auto record = lagcomp::records[pl->EntIndex()].m_vecRecords.back();
  38. vector_hitbox = math::calculate_hitbox(record.m_Matrix,
  39. record.m_arrHitboxes[hitbox_id].m_vecMins,
  40. record.m_arrHitboxes[hitbox_id].m_vecMaxs,
  41. record.m_arrHitboxes[hitbox_id].m_iBone);
  42. }*/
  43. auto record = lagcomp::records[pl->EntIndex()].m_vecRecords.back();
  44. int closest_hitbox = get_nearest_bone(pl);
  45.  
  46. auto get_bone_position = [&](int bone) {
  47. return math::vec3_t{ record.m_Matrix[bone][0][3], record.m_Matrix[bone][1][3], record.m_Matrix[bone][2][3] };
  48. };
  49.  
  50. vector_hitbox = get_bone_position(closest_hitbox);
  51. Globals::closest_hitbox = closest_hitbox;
  52.  
  53. if (vector_hitbox.is_zero())
  54. return false;
  55.  
  56. if (!ctx::client.local->can_see_hitbox(pl, vector_hitbox))
  57. return false;
  58.  
  59. float fov = math::get_fov(details::local_angles, ctx::client.local->get_eye_pos(), vector_hitbox);
  60.  
  61. if (fov < details::best_fov)
  62. {
  63. details::best_fov = fov;
  64. details::best_player = pl->EntIndex();
  65. details::hitbox_pos = vector_hitbox;
  66. }
  67.  
  68. return false;
  69. }, { game::ENEMY_ONLY });
  70.  
  71. if (details::best_player != -1)
  72. {
  73. player_t* pl = entity_t::get<player_t>(details::best_player);
  74.  
  75. if (!pl)
  76. return;
  77.  
  78. if (pl->IsDormant() || !pl->is_alive())
  79. return;
  80.  
  81. if (details::hitbox_pos.is_zero())
  82. return;
  83.  
  84. float fov = math::get_fov(details::local_angles, ctx::client.local->get_eye_pos(), details::hitbox_pos);
  85. float config_fov = details::aimbot_fov;
  86.  
  87. if (fov > config_fov)
  88. return;
  89.  
  90. math::angle_t angle = math::calc_angle(ctx::client.local->get_eye_pos(), details::hitbox_pos);
  91. details::final_angle = angle;
  92.  
  93. if (cmd->buttons.has_flag(IN_ATTACK))
  94. {
  95. int smooth_type = config::get<int>(ctx::cfg.legit_smooth_type);
  96.  
  97. math::angle_t aimPunchAngle = ctx::client.local->get_punch_angle();
  98. float legit_rcs_x = config::get<float>(ctx::cfg.legit_rcs_x);
  99. float legit_rcs_y = config::get<float>(ctx::cfg.legit_rcs_y);
  100.  
  101. details::final_angle.x -= aimPunchAngle.x * legit_rcs_x;
  102. details::final_angle.y -= aimPunchAngle.y * legit_rcs_y;
  103. details::final_angle.z = 0.f;
  104. math::correct(details::final_angle);
  105.  
  106. functions::pick_smoothing(smooth_type);
  107. math::correct(details::final_angle);
  108.  
  109. if (!ctx::client.local->can_see_hitbox(pl, details::hitbox_pos))
  110. return;
  111.  
  112. cmd->viewangles = details::final_angle;
  113. math::correct(cmd->viewangles);
  114.  
  115. bool rcs_standalone = config::get<bool>(ctx::cfg.legit_rcs_standalone);
  116. if (rcs_standalone)
  117. functions::standalone_rcs(cmd);
  118. math::correct(cmd->viewangles);
  119.  
  120. ctx::csgo.engine->SetViewAngles(cmd->viewangles);
  121.  
  122. float shot_delay = config::get<float>(ctx::cfg.legit_delay);
  123. auto weap_handle = ctx::client.local->get_weapon_handle();
  124. if (!weap_handle)
  125. return;
  126.  
  127. auto weapon = entity_t::get<weapon_t>(weap_handle);
  128. if (!weapon)
  129. return;
  130.  
  131. if (!timer::delay(shot_delay) &&
  132. cmd->buttons.has_flag(IN_ATTACK) &&
  133. ctx::client.local->m_iShotsFired() == 0 &&
  134. weapon->get_definition_index() != WEAPON_REVOLVER)
  135. {
  136. cmd->buttons.remove_flag(IN_ATTACK);
  137. }
  138. else
  139. {
  140. timer::reset();
  141. }
  142.  
  143. //draw_eyes(ctx::client.local->get_eye_pos(), pl->get_eye_pos());//debug
  144. }
  145. else
  146. {
  147. timer::reset();
  148. }
  149. }
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement