Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PI 3.14159265358979323846f
- #define PI_F ((float)(PI))
- auto HitChance = [](Vector Point, CBaseEntity* ent) -> bool
- {
- CBaseCombatWeapon* weapon = G::LocalPlayer->GetWeapon();
- if (!weapon)
- return false;
- if (!ent->GetFlags() & FL_ONGROUND && (weapon->WeaponID() != ItemDefinitionIndex::SSG08 || weapon->WeaponID() != ItemDefinitionIndex::AWP))
- {
- float hitchance = 90;
- float inaccuracy = weapon->GetCone();
- if (inaccuracy == 0) inaccuracy = 0.0000001;
- inaccuracy = 1 / inaccuracy;
- hitchance = inaccuracy;
- return hitchance >= g_pVars->Ragebot.Minhitchance;
- }
- else
- {
- //Count hits
- int hitTraces = 0;
- Vector traceStart = G::LocalPlayer->GetEyePosition();
- //Get Angle Vectors
- QAngle angle = Math::CalcAngle(traceStart, Point);
- Vector forward, right, up;
- Math::AngleVectors(angle, forward, right, up);
- //Do this outside of the for statement so we dont loose precious framerate ;)
- float spread = weapon->GetSpread();
- float inaccuracy = weapon->GetInaccuracy();
- float range = weapon->GetCSWpnData()->range;
- weapon->UpdateAccuracyPenalty();
- for (int i = 0; i < 256; i++)
- {
- float random1, random2, random3, random4, sin1, cosine1, sin2, cosine2;
- RandomSeed((i & 0xff) + 1);
- random1 = RandomFloat(-.5f, .5f);
- random2 = RandomFloat(-M_PI, M_PI);
- random3 = RandomFloat(-.5f, .5f);
- random4 = RandomFloat(-M_PI, M_PI);
- sin1 = std::sin(random2);
- cosine1 = std::cos(random2);
- sin2 = std::sin(random4);
- cosine2 = std::cos(random4);
- // calculate spread vector.
- Vector vecSpread = Vector((cosine1 * (random1 * inaccuracy)) + (cosine2 * (random3 * spread)), (sin1 * (random1 * inaccuracy)) + (sin2 * (random3 * spread)), 0.f);
- Vector dir = (forward + (right * vecSpread.x) + (up * vecSpread.y)).Normalized();
- // Start the trace here.
- CGameTrace tr;
- Ray_t ray;
- // get spread direction and normalize.
- Vector traceEnd = traceStart + (dir * range);
- ray.Init(traceStart, traceEnd);
- g_pEngineTrace->ClipRayToCBaseEntity(ray, MASK_SHOT_HULL | CONTENTS_HITBOX, ent, &tr);
- if (tr.DidHit())
- hitTraces++;
- }
- return ((hitTraces / 256.f) * 100 >= g_pVars->Ragebot.Minhitchance);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement