Copy pasters go to hell, sellers that sell this go to hell. You will be cracked, your shit will be leaked and you will be publicly embarrassed. Meant for non-profit consumption only.
Code:
double SpreadCone = GetSpread();
double CosineInput, CosinePitch, InputRoll, PitchBreakingPoint, PitchInput, RadiansPitch;
double ReciprocalYaw_1, ReciprocalYaw_2, TrapGodConstant, UpVal, Yaw_1;
QAngle QAdjusterAngles, QAngles, QInputAngles, QInputRoll, QNewAngles, QOldAngles;
Vector vecRandom;
Vector vecDir, vecForward, vecRight, vecUp;
Vector vecReciprocalVector, vecInputRight, vecInputRight2;
TrapGodConstant = 0;
// Trap God Constant computation goes here
QAngles.Init ( cmd->viewangles, 0, 0 );
QOldAngles = QAngles;
QAngles = ( QAngle )0;
QAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
vecDir = vecForward + ( -SpreadCone * vecRandom[0] * vecRight ) + ( -SpreadCone * vecRandom[1] * vecUp );
vecDir.Normalize();
PitchBreakingPoint = ( atan2 ( vecDir[1], sqrt ( ( 1 - ( vecDir[1] * vecDir[1] ) ) ) ) * 180 / M_PI );
if ( PitchBreakingPoint < 0 )
{
PitchBreakingPoint += 360;
}
if ( PitchBreakingPoint > 180 )
{
PitchBreakingPoint -= 360;
}
else if ( PitchBreakingPoint < -180 )
{
PitchBreakingPoint += 360;
}
if ( PitchBreakingPoint < 0 )
{
PitchBreakingPoint = 90 + PitchBreakingPoint;
}
else
{
PitchBreakingPoint = 90 - PitchBreakingPoint;
}
QAngles = vecDir.ToEulerAngles();
QAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
UpVal = vecUp[2];
QAngles = QOldAngles;
CosineInput = QAngles[0] * ( M_PI * 2 / 360 );
CosinePitch = cos ( CosineInput );
if ( CosinePitch != 0 )
{
Yaw_1 = 1 / CosinePitch;
}
else
{
Yaw_1 = 0;
}
Yaw_1 *= vecDir[1];
vecInputRight[1] = Yaw_1;
if ( Yaw_1 >= 1 || Yaw_1 <= -1 )
{
vecInputRight[0] = 0;
}
else
{
vecInputRight[0] = sqrt ( ( 1 - ( vecInputRight[1] * vecInputRight[1] ) ) );
}
vecInputRight[2] = 0;
QAdjusterAngles[1] = ( atan2 ( vecInputRight[1], vecInputRight[0] ) * 180 / M_PI );
if ( QAdjusterAngles[1] < 0 )
{
QAdjusterAngles[1] += 360;
}
QAdjusterAngles.Normalize();
vecInputRight2[1] = vecDir[1];
if ( vecDir[1] >= 1 || vecDir[1] <= -1 )
{
vecInputRight[0] = 0;
}
else
{
vecInputRight2[0] = sqrt ( ( 1 - ( vecInputRight2[1] * vecInputRight2[1] ) ) );
}
vecInputRight2[2] = 0;
if ( vecInputRight[0] != 0 )
{
ReciprocalYaw_1 = vecInputRight[1] / vecInputRight[0];
}
else
{
ReciprocalYaw_1 = 0;
}
if ( vecInputRight2[0] != 0 )
{
ReciprocalYaw_2 = vecInputRight2[1] / vecInputRight2[0];
}
else
{
ReciprocalYaw_2 = 0;
}
vecReciprocalVector[0] = ReciprocalYaw_1;
vecReciprocalVector[1] = ReciprocalYaw_2;
vecReciprocalVector[2] = 0;
vecReciprocalVector.Normalize();
if ( vecReciprocalVector[0] != 0 )
{
PitchInput = 1 / vecReciprocalVector[0];
}
else
{
PitchInput = 0;
}
PitchInput *= vecReciprocalVector[1];
if ( QAngles[0] < 0 )
{
QInputAngles[0] = asin ( -PitchInput ) * 180 / M_PI;
}
else
{
QInputAngles[0] = asin ( PitchInput ) * 180 / M_PI;
}
if ( QInputAngles[0] < 0 )
{
QInputAngles[0] += 360;
}
QInputAngles.Normalize();
double TempPitch = QAngles[0];
if ( TempPitch < 0 )
{
TempPitch = -TempPitch;
}
if ( QAngles[0] < 0 )
{
QInputAngles[0] += ( 45 - TempPitch ) * 2;
}
else
{
QInputAngles[0] -= ( 45 - TempPitch ) * 2;
}
QInputAngles[1] = 0;
QInputAngles[2] = 0;
QInputAngles.Normalize();
QInputAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
vecDir[0] = vecForward[0] + ( SpreadCone * vecRandom[0] * vecRight[0] ) + ( SpreadCone * vecRandom[1] * vecUp[0] );
vecDir[1] = 0;
vecDir[2] = vecForward[2] + ( SpreadCone * vecRandom[0] * vecRight[2] ) + ( SpreadCone * vecRandom[1] * vecUp[2] );
vecDir.Normalize();
if ( QAngles[0] < 0 )
{
QAdjusterAngles[0] = ( asin ( vecDir[2] ) * 180 / M_PI );
}
else
{
QAdjusterAngles[0] = ( asin ( -vecDir[2] ) * 180 / M_PI );
}
if ( QAdjusterAngles[0] < 0 )
{
QAdjusterAngles[0] += 360;
}
QAdjusterAngles.Normalize();
QNewAngles = QOldAngles;
if ( QAngles[0] < 0 )
{
QNewAngles[0] += QNewAngles[0] + QAdjusterAngles[0];
}
else
{
QNewAngles[0] += QNewAngles[0] - QAdjusterAngles[0];
}
QNewAngles[1] = QNewAngles[1] + QAdjusterAngles[1];
QNewAngles[2] = 0;
QNewAngles.Normalize();
if ( QAngles[0] < -PitchBreakingPoint || QAngles[0] > PitchBreakingPoint )
{
QNewAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
InputRoll = vecUp[1] / UpVal;
QInputRoll[0] = ( asin ( InputRoll ) * 180 / M_PI );
if ( QInputRoll[0] < 0 )
{
QInputRoll[0] += 360;
}
QInputRoll.Normalize();
QInputRoll[0] *= -1;
QNewAngles = QOldAngles;
QNewAngles[2] = QInputRoll[0] + TrapGodConstant;
QNewAngles.AngleVectors ( &vecForward, &vecRight, &vecUp );
vecDir = vecForward + ( -SpreadCone * vecRandom[0] * vecRight ) + ( -SpreadCone * vecRandom[1] * vecUp );
vecDir.Normalize();
QNewAngles = vecDir.ToEulerAngles ( &vecUp );
QNewAngles.Normalize();
QNewAngles[2] += TrapGodConstant;
QNewAngles.Normalize();
}
Credits: wav