Author Topic: Bullet Spread  (Read 1567 times)

I simply want to know the code for playing fire/reload animations as well as how to make bullets spread out over a large area. Please?
« Last Edit: September 18, 2011, 06:33:58 AM by QuantumEagle »

Look at Ephialtes' shotgun script. It has random bullet spread, also, look at T+T, it has spread, too.

Code: [Select]
function tttpolterImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, plant);
%projectile = %this.projectile;
%spread = 0.000001;
%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;
}

Thanks, I'll try it after school today.
« Last Edit: September 19, 2011, 04:13:54 AM by QuantumEagle »

Look at Ephialtes' shotgun script. It has random bullet spread, also, look at T+T, it has spread, too.
it's not random, well, there's a few different spreads which it then chooses i think, as there's a horizontal 3 spread EXACTLY the same which keeps popping up

it's not random, well, there's a few different spreads which it then chooses i think, as there's a horizontal 3 spread EXACTLY the same which keeps popping up
it's random lol.

it's random lol.
then why is there a pattern?
:I
same with the Gshotgun, it just toggles between 2 spreads


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;
oh, just so few possibilities that it creates a pattern

i was still right about it repeating itself a lot
hur dur

It has about a 1 in 99999999 x pi chance to repeat itself.
« Last Edit: September 21, 2011, 08:17:56 AM by Extrude »

It has about a 1 in 99999999 x pi chance to repeat itself.
so getRandom() wouldn't give 0 or 1 by itself? it sure seems like it does
and i know for sure that it keeps having the same spread every so often

You are completely wrong.

interesting, it is between 0 and 1, and yet it still produces patterns
so overall,
You are completely wrong.
about me being completely wrong
the same formations keep coming up over and over

I thought you were the one who knew something about scripting. It's between 0 and 1 including all the stuff in-between probably starting at 00001.

...
No, you are wrong. It's possible you're using a weird random seed that will produce the same numbers in a pattern, but this will almost never occur.


so getRandom() wouldn't give 0 or 1 by itself? it sure seems like it does
Code: [Select]
==> for(%i = 0; %i < 10; %i++){echo(getRandom());}
0.902336
0.556847
0.922807
0.6125
0.281929
0.385547
0.882077
0.0635692
0.40794
0.247588
It's just as likely to return 0 or 1 as 0.902336.