Author Topic: Reducing weapon spread?  (Read 855 times)

/title
I've been having a hard time trying to reduce weapon spread on some weapons, they just don't look good with wild spread (LMG sprays bullets everywhere)
How would I reduce weapon spread?

Spread is handled in the OnFire method for guns. I forgot what it's called, but it's a big equation like 3x10 * pi or something. all you need to do is edit the coefficient its being modified by for the x y and z values.

I dont have a computer in front of me so i dont know exactly what its called

code from the shotgun
everything uses pretty much the same code as this
Code: [Select]
function shotgunImage::onFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();
     
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3")));
%obj.playThread(2, shiftAway);

%projectile = %this.projectile;
%spread = 0.0015;
%shellcount = 3;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

in this case you would change %spread = 0.0015; to something lower

Would 0.0 make it have NO spread at all?

yes.. %x %y and %z will all be 0 since you multiplied it by 0

At that rate you might as well remove all the spread code.
You can cut out from %x to the %velocity that's just before %p, as well as removing the %spread = 0.0015;