stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = CarbonShotgunDrawSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateTransitionOnNoAmmo[1] = "AmmoCheck";
stateAllowImageChange[1] = true;
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.14;
stateAllowImageChange[2] = false;
stateSequence[2] = "trigger";
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = CarbonShotgunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = CarbonShotgunShotSound;
stateName[3] = "Smoke";
stateEmitter[3] = CarbonShotgunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "shellpump";
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "PreReload";
stateTransitionOnAmmo[4] = "Ready";
stateTimeoutValue[4] = 0.65;
stateSequence[4] = "load";
stateSound[4] = CarbonShotgunReloadSound;
stateName[5] = "PreReload";
stateWaitForTimeout[5] = true;
stateTransitionOnTimeout[5] = "Reload";
stateTimeoutValue[5] = 0.2;
stateName[6] = "AmmoCheck";
stateScript[6] = "onAmmoCheck";
stateTransitionOnAmmo[6] = "Ready";
stateTransitionOnNoAmmo[6] = "PreReload";
stateAllowImageChange[6] = true;
statename[7] = "shellpump";
stateScript[7] = "onPump";
stateSequence[7] = "pump";
stateSound[7] = CarbonShotgunPumpSound;
stateWaitForTimeout[7] = true;
stateTimeoutValue[7] = 0.2;
stateEjectShell[7] = true;
stateTransitionOnTimeout[7] = "AmmoCheck";
};
function CarbonShotgunImage::onFire(%this, %obj, %slot)
{
%obj.playThread(2, shiftAway);
if(%obj.CarbonShotgunAmmo < 1)
{
%obj.CarbonShotgunAmmo --;
%projectile = CarbonShotgunProjectile;
%spread = 0.007;
%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 Projectile()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}
else
{
%obj.setImageAmmo(%slot, 0);
}
}
function CarbonShotgunImage::onReload(%this, %obj, %slot)
{
if(%obj.CarbonShotgunAmmo == 6)
{
%obj.setImageAmmo(%slot, 1);
%obj.playThread(2, shiftRight);
}
else
{
%obj.CarbonShotgunAmmo++;
}
}
function CarbonShotgunImage::onAmmoCheck(%this, %obj, %slot)
{
if(%obj.CarbonShotgunAmmo < 1)
%obj.setImageAmmo(%slot, 0);
}
function CarbonShotgunImage::onPump(%this, %obj, %slot)
{
%obj.playThread(2, plant);
}
This isn't working
It is supposed to load 6 shells when you run out, then be able to fire 6 more, then load, etc.
BUT
It just lets you fire infinitely. Help!