Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. #define PI 3.14159265358979323846f
  2. #define PI_F ((float)(PI))
  3.  
  4. auto HitChance = [](Vector Point, CBaseEntity* ent) -> bool
  5. {
  6. CBaseCombatWeapon* weapon = G::LocalPlayer->GetWeapon();
  7.  
  8. if (!weapon)
  9. return false;
  10. if (!ent->GetFlags() & FL_ONGROUND && (weapon->WeaponID() != ItemDefinitionIndex::SSG08 || weapon->WeaponID() != ItemDefinitionIndex::AWP))
  11. {
  12. float hitchance = 90;
  13.  
  14. float inaccuracy = weapon->GetCone();
  15. if (inaccuracy == 0) inaccuracy = 0.0000001;
  16. inaccuracy = 1 / inaccuracy;
  17. hitchance = inaccuracy;
  18. return hitchance >= g_pVars->Ragebot.Minhitchance;
  19. }
  20. else
  21. {
  22. //Count hits
  23. int hitTraces = 0;
  24.  
  25. Vector traceStart = G::LocalPlayer->GetEyePosition();
  26.  
  27. //Get Angle Vectors
  28. QAngle angle = Math::CalcAngle(traceStart, Point);
  29. Vector forward, right, up;
  30. Math::AngleVectors(angle, forward, right, up);
  31.  
  32. //Do this outside of the for statement so we dont loose precious framerate ;)
  33. float spread = weapon->GetSpread();
  34. float inaccuracy = weapon->GetInaccuracy();
  35. float range = weapon->GetCSWpnData()->range;
  36.  
  37. weapon->UpdateAccuracyPenalty();
  38.  
  39.  
  40.  
  41. for (int i = 0; i < 256; i++)
  42. {
  43. float random1, random2, random3, random4, sin1, cosine1, sin2, cosine2;
  44.  
  45. RandomSeed((i & 0xff) + 1);
  46.  
  47. random1 = RandomFloat(-.5f, .5f);
  48. random2 = RandomFloat(-M_PI, M_PI);
  49. random3 = RandomFloat(-.5f, .5f);
  50. random4 = RandomFloat(-M_PI, M_PI);
  51.  
  52. sin1 = std::sin(random2);
  53. cosine1 = std::cos(random2);
  54. sin2 = std::sin(random4);
  55. cosine2 = std::cos(random4);
  56.  
  57. // calculate spread vector.
  58. Vector vecSpread = Vector((cosine1 * (random1 * inaccuracy)) + (cosine2 * (random3 * spread)), (sin1 * (random1 * inaccuracy)) + (sin2 * (random3 * spread)), 0.f);
  59.  
  60. Vector dir = (forward + (right * vecSpread.x) + (up * vecSpread.y)).Normalized();
  61.  
  62. // Start the trace here.
  63. CGameTrace tr;
  64. Ray_t ray;
  65.  
  66. // get spread direction and normalize.
  67. Vector traceEnd = traceStart + (dir * range);
  68. ray.Init(traceStart, traceEnd);
  69.  
  70. g_pEngineTrace->ClipRayToCBaseEntity(ray, MASK_SHOT_HULL | CONTENTS_HITBOX, ent, &tr);
  71.  
  72. if (tr.DidHit())
  73. hitTraces++;
  74.  
  75. }
  76.  
  77.  
  78.  
  79. return ((hitTraces / 256.f) * 100 >= g_pVars->Ragebot.Minhitchance);
  80.  
  81. }
  82.  
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement