bool bForceMaxInaccuracy = weapon_debug_max_inaccuracy.GetBool();
bool bForceInaccuracyDirection = weapon_debug_inaccuracy_only_up.GetBool();
bool bWeaponAccuracyShotgunSpreadPatterns = weapon_accuracy_shotgun_spread_patterns.GetBool();
Math::RandomSeed(nRandomSeed + 1);
float flRadiusCurveDensity = Math::RandomFloat(0.0f, 1.0f);
if (nItemIndex == 64 && nMode == nSecondaryMode) {
// R8 Revolver secondary fire
flRadiusCurveDensity = 1.0f - flRadiusCurveDensity * flRadiusCurveDensity;
}
else if (nItemIndex == 28 && flRecoilIndex < 3) {
// Negev Wild Beast
for (int nIndex = 3; nIndex > flRecoilIndex; --nIndex) {
flRadiusCurveDensity *= flRadiusCurveDensity;
}
flRadiusCurveDensity = 1.0f - flRadiusCurveDensity;
}
if (bForceMaxInaccuracy) {
flRadiusCurveDensity = 1.0f;
}
float flTheta0 = Math::RandomFloat(0.0f, 2.0f * M_PI);
if (bForceInaccuracyDirection) {
flTheta0 = M_PI * 0.5f;
}
if (bWeaponAccuracyShotgunSpreadPatterns)
{
// Missing.
}
float flRadius0 = flRadiusCurveDensity * flInaccuracy;
float flX0 = flRadius0 * cosf(flTheta0);
float flY0 = flRadius0 * sinf(flTheta0);
float flSpreadCurveDensity = Math::RandomFloat(0.0f, 1.0f);
if (nItemIndex == 64 && nMode == nSecondaryMode) {
// R8 Revolver secondary fire
flSpreadCurveDensity = 1.0f - flSpreadCurveDensity * flSpreadCurveDensity;
}
else if (nItemIndex == 28 && flRecoilIndex < 3) {
// Negev Wild Beast
for (int nIndex = 3; nIndex > flRecoilIndex; --nIndex) {
flSpreadCurveDensity *= flSpreadCurveDensity;
}
flSpreadCurveDensity = 1.0f - flSpreadCurveDensity;
}
if (bForceMaxInaccuracy) {
flSpreadCurveDensity = 1.0f;
}
float flTheta1 = Math::RandomFloat(0.0f, 2.0f * M_PI);
if (bForceInaccuracyDirection) {
flTheta1 = M_PI * 0.5f;
}
float flRadius1 = flSpreadCurveDensity * flSpread;
float flX1 = flRadius1 * cosf(flTheta1);
float flY1 = flRadius1 * sinf(flTheta1);
double flYResult = (double)(flY1 * flRadius0) +
(double)(flY0 * flRadius1);
double flXResult = (double)(flX1 * flRadius0) +
(double)(flX0 * flRadius1);