I made a sword add-on that would fire an extra projectile every second. that works fine, but the only problem is that now my sword fires the slash projectiles from the sword too, making it extremely inacurate.
// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;
function SuperswordImage::onFire(%this,%obj,%slot)
{
if(!%obj.lastSuperSword)
{
%obj.lastSuperSword = getSimTime();
}
%spread = 00;
%vector = %obj.getMuzzleVector(%slot);
%vector = VectorScale(%vector, 35);
%x = (getRandom() - 0.5) * %spread;
%y = (getRandom() - 0.5) * %spread;
%z = (getRandom() - 0.5) * %spread;
%mat = MatrixCreateFromEuler(%x SPC %y SPC %z);
%velocity = MatrixMulVector(%mat, %vector);
%p = new projectile()
{
dataBlock = SuperswordProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
if((%obj.lastSuperSword + 1000) <= getSimTime())
{
%obj.lastSuperSword = getSimTime();
new projectile()
{
dataBlock = SuperswordSwordProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
}
MissionCleanup.add(%p);
return %p;
}
I know how to change where the initial position of the projectile is, but i dont know how to change it to the eye.