Now the problem is in both, normal shooting and spawning. I was thinking of going back a few steps. And making it if the damage is < 0 it defaults to 7.
function BlunderBussImage::onFire(%this,%obj,%slot)
{
%projectile = %this.projectile;
%spread = 0.010;
%shellcount = getrandom(5,15);
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;
}
package Bluderbusspackage
{
function projectile::onAdd(%obj,%a,%b)
{
parent::onAdd(%obj,%a,%b);
if(%obj.dataBlock $= "BlunderBussProjectile")
{
%obj.spawntime = getsimtime();
}
}
};
activatePackage(BlunderBussPackage);
function BlunderbussProjectile::Damage(%this,%obj,%col,%fade,%pos,%norm)
{
%obj.deathtime = getsimtime();
%damage = 10 - ((%obj.deathtime - %obj.spawntime) / 1000 * 4);
echo("Damage :" SPC %damage);
if(%Damage < 0)
{
%damage = 1;
}
%col.damage(%obj,%pos,%damage,%this.directDamageType);
}