Author Topic: Shootonclick spread.  (Read 639 times)

Hello, many of you know of and maybe even downloaded my cannon vehicle. You may have seen that many people request a minigun like turret. I have am odel all done but I have quite a few problems. I cannot make it spread. I was trying to impliment the Ak47's spread code to be activated when a state was fired except it wouldn't. Here is the code.

Code: [Select]
datablock ShapeBaseImageData(CannonSmokeImage)
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 1;

stateName[0]                  = "Ready";
stateTransitionOnTimeout[0]   = "FireA";
stateTimeoutValue[0]          = 0.01;

stateName[1]                  = "FireA";
stateTransitionOnTimeout[1]   = "FireB";
stateWaitForTimeout[1]        = True;
stateTimeoutValue[1]          = 0.05;
stateEmitter[1]               = vehicleFinalExplosionEmitter3;
stateEmitterTime[1]           = 0.05;

stateName[2]                  = "FireB";
stateTransitionOnTimeout[2]   = "FireC";
stateWaitForTimeout[2]        = True;
stateTimeoutValue[2]          = 0.05;
stateEmitter[2]               = vehicleExplosionEmitter;
stateEmitterTime[2]           = 0.05;

stateName[3]                  = "FireC";
stateTransitionOnTimeout[3]   = "Done";
stateWaitForTimeout[3]        = True;
stateTimeoutValue[3]          = 0.850;
stateEmitter[3]               = CannonSmokeEmitter;
stateEmitterTime[3]           = 0.850;

stateName[4]                  = "Done";
stateScript[4]                = "onDone";
};

function CannonSmokeImage::onDone(%this,%obj,%slot)
{

%projectile = GravityRocketProjectile;
%spread = 0.0001;
%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) * 2 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 2 * 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;
}

function CannonSmokeImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

datablock WheeledVehicleData(CannonVehicle)
{
category = "Vehicles";
displayName = " ";
shapeFile = "./Cannon.dts";
emap = true;
minMountDist = 3;
};
Could it possibly be this?
Code: [Select]
initialPosition = %obj.getMuzzlePoint(%slot);Because I do not have a muzzlePoint on my turret. Could I change where it says Muzzlepoint to mount0 or something?

Hmm.. not too sure on that. i could learn here too :D


Btw this would make a great minigun turret model :D



well, spread for a minigun turret wouldn't really be nescessary, since spread is caused by vibrations which shake the gun holder's arm, resulting in multi-directional shots. however, a turret is heavy, and/or anchored to the ground, so the vibrations are not as drastic.

well, spread for a minigun turret wouldn't really be nescessary, since spread is caused by vibrations which shake the gun holder's arm, resulting in multi-directional shots. however, a turret is heavy, and/or anchored to the ground, so the vibrations are not as drastic.
Well a minigun that shoots strait in a line would be kind of gay. It needs a little spread just for effect.