Author Topic: Bullet Spread  (Read 983 times)

Where in a script can I change the amount of bullet spread on a weapon.

In weapons like shotguns it's just a variable named spread:
Code: [Select]
%spread = 0.000;
Only change it by tiny amounts though.

In weapons like shotguns it's just a variable named spread:
Code: [Select]
%spread = 0.000;
Only change it by tiny amounts though.

where though? Like what part. Weapon image? Bullet, particles, etc.?

Well, it's not really a required part of any weapon, so most won't have it at all.
Can you tell me what weapon you're editing?

Well, it's not really a required part of any weapon, so most won't have it at all.
Can you tell me what weapon you're editing?

my new HK G36C

using a Standard GUN script

You should look at Ephi's shotgun. It explains all.

well, i found this in an assault rifle script:

Code: [Select]
function [GUNHERE]Image::onFire(%this,%obj,%slot)
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1")));

%projectile = %this.projectile;
%spread = 0.00185;
%shellcount = 1;

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;
}



would I need all of this for spread?

:C

Edit:

the script above seems to be missing:

Code: [Select]
{
if(%obj.getDamagePercent() < 1.0)
Parent::onFire(%this,%obj,%slot);
}

is that bad?
« Last Edit: April 18, 2010, 01:29:27 PM by ShadowsfeaR »

well, i found this in an assault rifle script:

Code: [Select]
-snip-

is that bad?

You don't need all that, you mostly need:

Code: [Select]
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;


You don't need all that, you mostly need:

Code: [Select]
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;



im a noob scripter. :C

so what would i cut out of the chunk of script i had posted?

im a noob scripter. :C

so what would i cut out of the chunk of script i had posted?
Nothing. Just change the gunhere image thing.

You don't need all that, you mostly need:

Code: [Select]
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;


Uh.
You need the entire thing.

Uh.
You need the entire thing.
I know, but that's the main code, that adds a bit of randomness to the base velocity times the spread variable.