Guest User

Untitled

a guest
Jan 7th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.45 KB | None | 0 0
  1. #include "LegitBot.h"
  2. #include "Render.h"
  3. #include "SDK.h"
  4. #include "EnginePrediction.h"
  5. #include "Global.h"
  6. #define NOMINMAX
  7. #include <Windows.h>
  8. #include <stdio.h>
  9. #include <random>
  10. #include <string>
  11. #include <vector>
  12.  
  13.  
  14.  
  15. legitbot::legitbot()
  16. {
  17.     best_target = -1;
  18.  
  19.     view_angle = QAngle(0.0f, 0.0f, 0.0f);
  20.     aim_angle = QAngle(0.0f, 0.0f, 0.0f);
  21.     delta_angle = QAngle(0.0f, 0.0f, 0.0f);
  22.     final_angle = QAngle(0.0f, 0.0f, 0.0f);
  23.  
  24.     hitbox_position = Vector(0.0f, 0.0f, 0.0f);
  25.  
  26.     aim_key = 0;
  27.     aim_smooth = 1;
  28.     aim_fov = 0;
  29.     randomized_smooth = 0;
  30.     recoil_min = 0;
  31.     recoil_max = 0;
  32.     randomized_angle = 0;
  33.     shoot = false;
  34. }
  35. float get_fov(const QAngle &viewAngles, const QAngle &aimAngles)
  36. {
  37.     Vector ang, aim;
  38.     AngleVectors(viewAngles, &aim);
  39.     AngleVectors(aimAngles, &ang);
  40.     return RAD2DEG(acos(aim.Dot(ang) / aim.LengthSqr()));
  41. }
  42. float random_number_range(float min, float max)
  43. {
  44.     std::random_device device;
  45.     std::mt19937 engine(device());
  46.     std::uniform_real_distribution<> distribution(min, max);
  47.     return static_cast< float >(distribution(engine));
  48. }
  49.  
  50.  
  51. bool shoot;
  52. static int custom_delay = 0;
  53.  
  54. void legitbot::OnCreateMove(CInput::CUserCmd *pCmd, C_BaseEntity *local, bool& bSendPacket)
  55. {
  56.     if (!g_Options.LegitBot.Enable)
  57.         return;
  58.  
  59.     CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(local->GetActiveWeaponHandle());
  60.  
  61.  
  62.     if (local && local->IsAlive() && pWeapon)
  63.     {
  64.         do_aimbot(local, pWeapon, pCmd);
  65.         if (!G::PressedKeys[g_Options.LegitBot.Triggerbot.Key]) custom_delay = 0;
  66.  
  67.         if (g_Options.LegitBot.Triggerbot.Enabled && g_Options.LegitBot.Triggerbot.Key != 0 && G::PressedKeys[g_Options.LegitBot.Triggerbot.Key])
  68.             triggerbot(pCmd, local, pWeapon);
  69.  
  70.     }
  71.  
  72.  
  73. }
  74.  
  75. void legitbot::triggerbot(CInput::CUserCmd *cmd, C_BaseEntity* local, CBaseCombatWeapon* weapon)
  76. {
  77.     if (!local->IsAlive())
  78.         return;
  79.  
  80.     if (weapon) {
  81.         if (weapon->ammo() == 0)
  82.             return;
  83.         if (MiscFunctions::IsKnife(weapon) || MiscFunctions::IsGrenade(weapon)) return;
  84.         if (*weapon->m_AttributeManager()->m_Item()->ItemDefinitionIndex() == 64) return;
  85.  
  86.     }
  87.  
  88.  
  89.  
  90.     QAngle ViewAngles = cmd->viewangles + local->localPlayerExclusive()->GetAimPunchAngle();
  91.  
  92.  
  93.     Vector CrosshairForward;
  94.     AngleVectors(ViewAngles, &CrosshairForward);
  95.     CrosshairForward *= weapon->GetCSWpnData()->range;
  96.  
  97.  
  98.     Vector TraceSource = local->GetEyePosition();
  99.     Vector TraceDestination = TraceSource + CrosshairForward;
  100.  
  101.     Ray_t Ray;
  102.     trace_t Trace;
  103.     CTraceFilter Filter;
  104.  
  105.     Filter.pSkip = local;
  106.  
  107.     Ray.Init(TraceSource, TraceDestination);
  108.     g_EngineTrace->TraceRay(Ray, MASK_SHOT, &Filter, &Trace);
  109.  
  110.     if (!Trace.m_pEnt)
  111.         return;
  112.     if (!Trace.m_pEnt->IsAlive())
  113.         return;
  114.     if (Trace.m_pEnt->HasGunGameImmunity())
  115.         return;
  116.  
  117.  
  118.     if (local->GetTeamNum() == Trace.m_pEnt->GetTeamNum())
  119.         return;
  120.  
  121.     if (!hit_chance(local, cmd, weapon, Trace.m_pEnt))
  122.         return;
  123.  
  124.     bool didHit = false;
  125.     if ((g_Options.LegitBot.Triggerbot.Filter.Head && Trace.hitgroup == 1)
  126.         || (g_Options.LegitBot.Triggerbot.Filter.Chest && Trace.hitgroup == 2)
  127.         || (g_Options.LegitBot.Triggerbot.Filter.Stomach && Trace.hitgroup == 3)
  128.         || (g_Options.LegitBot.Triggerbot.Filter.Arms && (Trace.hitgroup == 4 || Trace.hitgroup == 5))
  129.         || (g_Options.LegitBot.Triggerbot.Filter.Legs && (Trace.hitgroup == 6 || Trace.hitgroup == 7)))
  130.     {
  131.         didHit = true;
  132.     }
  133.  
  134.     if (g_Options.LegitBot.Triggerbot.Delay >= 1)
  135.     {
  136.         if (custom_delay >= g_Options.LegitBot.Triggerbot.Delay / 30)
  137.         {
  138.             if (didHit)
  139.             {
  140.                 custom_delay = 0;
  141.                 shoot = true;
  142.                 cmd->buttons |= IN_ATTACK;
  143.             }
  144.         }
  145.         else
  146.         {
  147.             custom_delay++;
  148.         }
  149.     }
  150.  
  151. }
  152.  
  153.  
  154. void legitbot::do_aimbot(C_BaseEntity *local, CBaseCombatWeapon *weapon, CInput::CUserCmd *cmd)
  155. {
  156.     if (!g_Options.LegitBot.Enable)
  157.         return;
  158.  
  159.     if (!weapon)
  160.         return;
  161.  
  162.     if (!local)
  163.         return;
  164.     if (!cmd)
  165.         return;
  166.  
  167.     if (!local->IsAlive())
  168.         return;
  169.  
  170.     if (!weapon->ammo() > 0)
  171.         return;
  172.  
  173.  
  174.     if (weapon->ammo() == 0)
  175.         return;
  176.  
  177.     if (MiscFunctions::IsKnife(weapon) || MiscFunctions::IsGrenade(weapon))
  178.         return;
  179.  
  180.  
  181.     weapon_settings(weapon);
  182.  
  183.     if (!aim_key)
  184.         return;
  185.  
  186.     if (!G::PressedKeys[aim_key])
  187.         return;
  188.  
  189.  
  190.  
  191.     best_target = get_target(local, weapon, cmd, hitbox_position);
  192.  
  193.  
  194.     if (best_target == -1)
  195.         return;
  196.  
  197.     C_BaseEntity* entity = (C_BaseEntity*)g_EntityList->GetClientEntity(best_target);
  198.     if (!entity)
  199.         return;
  200.  
  201.  
  202.  
  203.     if (get_distance(local->GetEyePosition(), hitbox_position) > 8192.0f)
  204.         return;
  205.  
  206.  
  207.     compute_angle(local->GetEyePosition(), hitbox_position, aim_angle);
  208.     sanitize_angles(aim_angle);
  209.  
  210.     if (hitbox_position == Vector(0, 0, 0))
  211.         return;
  212.  
  213.     aim_angle -= get_randomized_recoil(local);
  214.     aim_angle += get_randomized_angles(local);
  215.  
  216.     sanitize_angles(view_angle);
  217.  
  218.     delta_angle = view_angle - aim_angle;
  219.     sanitize_angles(delta_angle);
  220.  
  221.     float randomSmoothing = 1.0f;
  222.  
  223.     if (randomized_smooth > 1.0f)
  224.         randomSmoothing = random_number_range(randomized_smooth / 10.0f, 1.0f);
  225.  
  226.     final_angle = view_angle - delta_angle / aim_smooth * randomSmoothing;
  227.     sanitize_angles(final_angle);
  228.  
  229.     if (!sanitize_angles(final_angle))
  230.         return;
  231.  
  232.     cmd->viewangles = final_angle;
  233.     g_Engine->SetViewAngles(cmd->viewangles);
  234. }
  235.  
  236.  
  237. bool legitbot::hit_chance(C_BaseEntity* local, CInput::CUserCmd* cmd, CBaseCombatWeapon* weapon, C_BaseEntity* target)
  238. {
  239.     Vector forward, right, up;
  240.  
  241.     constexpr auto max_traces = 150;
  242.  
  243.     AngleVectors(cmd->viewangles, &forward, &right, &up);
  244.  
  245.     int total_hits = 0;
  246.     int needed_hits = static_cast<int>(max_traces * (g_Options.LegitBot.Triggerbot.hitchance / 100.f));
  247.  
  248.     weapon->UpdateAccuracyPenalty(weapon);
  249.  
  250.     auto eyes = local->GetEyePosition();
  251.     auto flRange = weapon->GetCSWpnData()->range;
  252.  
  253.     for (int i = 0; i < max_traces; i++) {
  254.         RandomSeed(i + 1);
  255.  
  256.         float fRand1 = RandomFloat(0.f, 1.f);
  257.         float fRandPi1 = RandomFloat(0.f, XM_2PI);
  258.         float fRand2 = RandomFloat(0.f, 1.f);
  259.         float fRandPi2 = RandomFloat(0.f, XM_2PI);
  260.  
  261.         float fRandInaccuracy = fRand1 * weapon->GetInaccuracy();
  262.         float fRandSpread = fRand2 * weapon->GetSpread();
  263.  
  264.         float fSpreadX = cos(fRandPi1) * fRandInaccuracy + cos(fRandPi2) * fRandSpread;
  265.         float fSpreadY = sin(fRandPi1) * fRandInaccuracy + sin(fRandPi2) * fRandSpread;
  266.  
  267.         auto viewSpreadForward = (forward + fSpreadX * right + fSpreadY * up).Normalized();
  268.  
  269.         QAngle viewAnglesSpread;
  270.         VectorAngles(viewSpreadForward, viewAnglesSpread);
  271.         sanitize_angles(viewAnglesSpread);
  272.  
  273.         Vector viewForward;
  274.         AngleVectors(viewAnglesSpread, &viewForward);
  275.         viewForward.NormalizeInPlace();
  276.  
  277.         viewForward = eyes + (viewForward * flRange);
  278.  
  279.         trace_t tr;
  280.         Ray_t ray;
  281.         ray.Init(eyes, viewForward);
  282.  
  283.         g_EngineTrace->ClipRayToEntity(ray, MASK_SHOT | CONTENTS_GRATE, target, &tr);
  284.  
  285.  
  286.         if (tr.m_pEnt == target)
  287.             total_hits++;
  288.  
  289.         if (total_hits >= needed_hits)
  290.             return true;
  291.  
  292.         if ((max_traces - i + total_hits) < needed_hits)
  293.             return false;
  294.  
  295.     }
  296.  
  297.     return false;
  298. }
  299.  
  300.  
  301.  
  302.  
  303. void legitbot::weapon_settings(CBaseCombatWeapon* weapon)
  304. {
  305.     if (!weapon)
  306.         return;
  307.  
  308.  
  309.     if (MiscFunctions::IsSniper(weapon))
  310.     {
  311.         aim_key = g_Options.LegitBot.SniperKey;
  312.         aim_smooth = g_Options.LegitBot.SniperSmooth;
  313.         aim_fov = g_Options.LegitBot.Sniperfov;
  314.         randomized_smooth = 1;
  315.         recoil_min = g_Options.LegitBot.sniper_recoil_min;
  316.         recoil_max = g_Options.LegitBot.sniper_recoil_max;
  317.         randomized_angle = 1;
  318.  
  319.         if (g_Options.LegitBot.FilterSniperWeapons.HeadwpSnip)
  320.         {
  321.             hitbox = (int)CSGOHitboxID::Head;
  322.  
  323.             multibone = false;
  324.         }
  325.         else if (g_Options.LegitBot.FilterSniperWeapons.NeckwpSnip)
  326.         {
  327.             hitbox = (int)CSGOHitboxID::Neck;
  328.  
  329.             multibone = false;
  330.         }
  331.         else if (g_Options.LegitBot.FilterSniperWeapons.ChestwpSnip)
  332.         {
  333.             hitbox = (int)CSGOHitboxID::Chest;
  334.  
  335.             multibone = false;
  336.         }
  337.         else if (g_Options.LegitBot.FilterSniperWeapons.StomachwpSnip)
  338.         {
  339.             hitbox = (int)CSGOHitboxID::Stomach;
  340.  
  341.             multibone = false;
  342.         }
  343.         else if (g_Options.LegitBot.FilterSniperWeapons.multiboneswpSnip)
  344.         {
  345.             multibone = true;
  346.         }
  347.  
  348.  
  349.     }
  350.     else if (MiscFunctions::IsPistol(weapon))
  351.     {
  352.         aim_key = g_Options.LegitBot.PistolKey;
  353.         aim_smooth = g_Options.LegitBot.PistolSmooth;
  354.         aim_fov = g_Options.LegitBot.Pistolfov;
  355.         randomized_smooth = 1;
  356.         recoil_min = g_Options.LegitBot.pistol_recoil_min;
  357.         recoil_max = g_Options.LegitBot.pistol_recoil_max;
  358.         randomized_angle = 1;
  359.  
  360.  
  361.         if (g_Options.LegitBot.FilterPistolWeapons.Headwppis)
  362.         {
  363.             hitbox = (int)CSGOHitboxID::Head;
  364.  
  365.             multibone = false;
  366.         }
  367.         else if (g_Options.LegitBot.FilterPistolWeapons.Neckwppis)
  368.         {
  369.             hitbox = (int)CSGOHitboxID::Neck;
  370.  
  371.             multibone = false;
  372.         }
  373.         else if (g_Options.LegitBot.FilterPistolWeapons.Chestwppis)
  374.         {
  375.             hitbox = (int)CSGOHitboxID::Chest;
  376.  
  377.             multibone = false;
  378.         }
  379.         else if (g_Options.LegitBot.FilterPistolWeapons.Stomachwppis)
  380.         {
  381.             hitbox = (int)CSGOHitboxID::Stomach;
  382.  
  383.             multibone = false;
  384.         }
  385.         else if (g_Options.LegitBot.FilterPistolWeapons.multiboneswppis)
  386.         {
  387.             multibone = true;
  388.         }
  389.  
  390.  
  391.     }
  392.     else if (MiscFunctions::IsSmg(weapon))
  393.     {
  394.         aim_key = g_Options.LegitBot.smg_Key;
  395.         aim_smooth = g_Options.LegitBot.smg_Smooth;
  396.         aim_fov = g_Options.LegitBot.smg_fov;
  397.         randomized_smooth = 1;
  398.         recoil_min = g_Options.LegitBot.smg_recoil_min;
  399.         recoil_max = g_Options.LegitBot.smg_recoil_max;
  400.         randomized_angle = 1;
  401.  
  402.         if (g_Options.LegitBot.FiltersmgWeapons.Headwpsmg)
  403.         {
  404.             hitbox = (int)CSGOHitboxID::Head;
  405.  
  406.             multibone = false;
  407.         }
  408.         else if (g_Options.LegitBot.FiltersmgWeapons.Neckwpsmg)
  409.         {
  410.             hitbox = (int)CSGOHitboxID::Neck;
  411.  
  412.             multibone = false;
  413.         }
  414.         else if (g_Options.LegitBot.FiltersmgWeapons.Chestwpsmg)
  415.         {
  416.             hitbox = (int)CSGOHitboxID::Chest;
  417.  
  418.             multibone = false;
  419.         }
  420.         else if (g_Options.LegitBot.FiltersmgWeapons.Stomachwpsmg)
  421.         {
  422.             hitbox = (int)CSGOHitboxID::Stomach;
  423.  
  424.             multibone = false;
  425.         }
  426.         else if (g_Options.LegitBot.FiltersmgWeapons.multiboneswpsmg)
  427.         {
  428.             multibone = true;
  429.         }
  430.  
  431.  
  432.     }
  433.     else if (MiscFunctions::IsHeavy(weapon))
  434.     {
  435.         aim_key = g_Options.LegitBot.heavy_wp_Key;
  436.         aim_smooth = g_Options.LegitBot.heavy_wp_Smooth;
  437.         aim_fov = g_Options.LegitBot.heavy_wp_fov;
  438.         randomized_smooth = 1;
  439.         recoil_min = g_Options.LegitBot.heavy_wp_recoil_min;
  440.         recoil_max = g_Options.LegitBot.heavy_wp_recoil_max;
  441.         randomized_angle = 1;
  442.  
  443.  
  444.         if (g_Options.LegitBot.FilterheavyWeapons.Headwphv)
  445.         {
  446.             hitbox = (int)CSGOHitboxID::Head;
  447.  
  448.             multibone = false;
  449.         }
  450.         else if (g_Options.LegitBot.FilterheavyWeapons.Neckwphv)
  451.         {
  452.             hitbox = (int)CSGOHitboxID::Neck;
  453.  
  454.             multibone = false;
  455.         }
  456.         else if (g_Options.LegitBot.FilterheavyWeapons.Chestwphv)
  457.         {
  458.             hitbox = (int)CSGOHitboxID::Chest;
  459.  
  460.             multibone = false;
  461.         }
  462.         else if (g_Options.LegitBot.FilterheavyWeapons.Stomachwphv)
  463.         {
  464.             hitbox = (int)CSGOHitboxID::Stomach;
  465.  
  466.             multibone = false;
  467.         }
  468.         else if (g_Options.LegitBot.FilterheavyWeapons.multibonewphv)
  469.         {
  470.             multibone = true;
  471.         }
  472.  
  473.     }
  474.     else
  475.     {
  476.         aim_key = g_Options.LegitBot.MainKey;
  477.         aim_smooth = g_Options.LegitBot.MainSmooth;
  478.         aim_fov = g_Options.LegitBot.Mainfov;
  479.         randomized_smooth = 1;
  480.         recoil_min = g_Options.LegitBot.main_recoil_min;
  481.         recoil_max = g_Options.LegitBot.main_recoil_max;
  482.         randomized_angle = 1;
  483.  
  484.         if (g_Options.LegitBot.FilterMainWeapons.Headwpmain)
  485.         {
  486.             hitbox = (int)CSGOHitboxID::Head;
  487.  
  488.             multibone = false;
  489.         }
  490.         else if (g_Options.LegitBot.FilterMainWeapons.Neckwpmain)
  491.         {
  492.             hitbox = (int)CSGOHitboxID::Neck;
  493.  
  494.             multibone = false;
  495.         }
  496.         else if (g_Options.LegitBot.FilterMainWeapons.Chestwpmain)
  497.         {
  498.             hitbox = (int)CSGOHitboxID::Chest;
  499.  
  500.             multibone = false;
  501.         }
  502.         else if (g_Options.LegitBot.FilterMainWeapons.Stomachwpmain)
  503.         {
  504.             hitbox = (int)CSGOHitboxID::Stomach;
  505.  
  506.             multibone = false;
  507.         }
  508.         else if (g_Options.LegitBot.FilterMainWeapons.multiboneswpmain)
  509.         {
  510.             multibone = true;
  511.         }
  512.  
  513.     }
  514.  
  515. }
  516.  
  517.  
  518. QAngle legitbot::get_randomized_recoil(C_BaseEntity *local)
  519. {
  520.     QAngle compensatedAngles = (local->localPlayerExclusive()->GetAimPunchAngle() * 2.0f) * (random_number_range(recoil_min, recoil_max) / 100.0f);
  521.     sanitize_angles(compensatedAngles);
  522.  
  523.     return (local->m_iShotsFired() > 1 ? compensatedAngles : QAngle(0.0f, 0.0f, 0.0f));
  524. }
  525.  
  526. QAngle legitbot::get_randomized_angles(C_BaseEntity *local)
  527. {
  528.     QAngle randomizedValue = QAngle(0.0f, 0.0f, 0.0f);
  529.  
  530.     float randomRate = random_number_range(-randomized_angle, randomized_angle);
  531.     float randomDeviation = random_number_range(-randomized_angle, randomized_angle);
  532.  
  533.     switch (rand() % 2)
  534.     {
  535.     case 0:
  536.         randomizedValue.x = (randomRate * cos(randomDeviation));
  537.         randomizedValue.y = (randomRate * cos(randomDeviation));
  538.         randomizedValue.z = (randomRate * cos(randomDeviation));
  539.         break;
  540.     case 1:
  541.         randomizedValue.x = (randomRate * sin(randomDeviation));
  542.         randomizedValue.y = (randomRate * sin(randomDeviation));
  543.         randomizedValue.z = (randomRate * sin(randomDeviation));
  544.         break;
  545.     }
  546.  
  547.     sanitize_angles(randomizedValue);
  548.     return (local->m_iShotsFired() > 1 ? randomizedValue : QAngle(0.0f, 0.0f, 0.0f));
  549. }
  550. bool get_hitbox_pos(C_BaseEntity* entity, int hitbox, Vector &output)
  551. {
  552.     if (hitbox >= 20)
  553.         return false;
  554.  
  555.     const model_t *model = entity->GetModel();
  556.     if (!model)
  557.         return false;
  558.  
  559.     studiohdr_t *studioHdr = g_ModelInfo->GetStudiomodel(model);
  560.     if (!studioHdr)
  561.         return false;
  562.  
  563.     matrix3x4 matrix[128];
  564.     if (!entity->SetupBones(matrix, 128, 0x100, entity->GetSimulationTime()))
  565.         return false;
  566.  
  567.     mstudiobbox_t *studioBox = studioHdr->GetHitboxSet(0)->GetHitbox(hitbox);
  568.     if (!studioBox)
  569.         return false;
  570.  
  571.     Vector min, max;
  572.  
  573.     VectorTransform(studioBox->bbmin, matrix[studioBox->bone], min);
  574.     VectorTransform(studioBox->bbmax, matrix[studioBox->bone], max);
  575.  
  576.     output = (min + max) * 0.5f;
  577.     return true;
  578. }
  579. bool legitbot::get_hitbox(C_BaseEntity *local, C_BaseEntity *entity, Vector &destination)
  580. {
  581.  
  582.     int bestHitbox = -1;
  583.     float best_fov = aim_fov;
  584.  
  585.  
  586.     std::vector<int> kek(hitbox);
  587.  
  588.     if (!multibone) {
  589.         kek = { hitbox };
  590.     }
  591.     else
  592.     {
  593.         kek = { (int)CSGOHitboxID::Head, (int)CSGOHitboxID::Chest, (int)CSGOHitboxID::Neck, (int)CSGOHitboxID::Stomach };
  594.     }
  595.  
  596.  
  597.     for (const int &hitbox : kek)
  598.     {
  599.         Vector temp;
  600.         if (!get_hitbox_pos(entity, hitbox, temp))
  601.             continue;
  602.  
  603.         float fov = get_fov(view_angle, compute_angle(local->GetEyePosition(), temp));
  604.         if (fov < best_fov)
  605.         {
  606.             best_fov = fov;
  607.             bestHitbox = hitbox;
  608.         }
  609.     }
  610.  
  611.     if (bestHitbox != -1)
  612.     {
  613.         if (!get_hitbox_pos(entity, bestHitbox, destination))
  614.             return true;
  615.     }
  616.     return false;
  617.  
  618. }
  619.  
  620.  
  621. int legitbot::get_target(C_BaseEntity *local, CBaseCombatWeapon *weapon, CInput::CUserCmd *cmd, Vector &destination)
  622. {
  623.     int best_target = -1;
  624.     float best_fov = aim_fov;
  625.  
  626.     g_Engine->GetViewAngles(view_angle);
  627.  
  628.     for (int i = 1; i <= g_Globals->maxClients; i++)
  629.     {
  630.         C_BaseEntity *entity = (C_BaseEntity*)g_EntityList->GetClientEntity(i);
  631.         if (!entity
  632.             || entity == local
  633.             || entity->IsDormant()
  634.             || entity->GetLifeState() != LIFE_ALIVE
  635.             || entity->HasGunGameImmunity()
  636.             || entity->GetClientClass()->m_ClassID != (int)ClassID::CCSPlayer
  637.             || entity->GetTeamNum() == local->GetTeamNum()
  638.             || !(entity->GetFlags() & FL_ONGROUND))
  639.             continue;
  640.  
  641.         Vector hitbox;
  642.         if (get_hitbox(local, entity, hitbox))
  643.             continue;
  644.  
  645.         float fov = get_fov(view_angle + (local->localPlayerExclusive()->GetAimPunchAngle() * 2.0f), compute_angle(local->GetEyePosition(), hitbox));
  646.         if (fov < best_fov && fov < aim_fov)
  647.         {
  648.             if (MiscFunctions::IsVisible(local, entity, 0))
  649.             {
  650.                 best_fov = fov;
  651.                 destination = hitbox;
  652.                 best_target = i;
  653.             }
  654.         }
  655.     }
  656.     return best_target;
  657. }
Advertisement
Add Comment
Please, Sign In to add comment