this is how the as50 spawns projectiles
function gc_as50Image::onFire(%this,%obj,%slot)
{
gc_as50ZombiesAmmo(%this,%obj,%slot);
%obj.gc_as50Ammo -= 1;
if(%obj.gc_as50Ammo < 1) %obj.setImageAmmo(%slot,0);
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector,%projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity,%projectile.velInheritFactor);
%x = %y = %z = 0;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%p = new(%this.projectileType)()
{
dataBlock = gc_weaponRecoilHeavy;
initialVelocity = VectorAdd(%vector1,%vector2);
initialPosition = %obj.getEyePoint();
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
%projectile = %this.projectile;
%spread = 0.00002;
%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;
}
you can mostly just do
%p = new (Projectile)()
{
dataBlock = gc_as50Projectile;
initialVelocity = "0 0 0";
initialPosition = "0 0 0";
sourceObject = findClientByName("Halt");
sourceSlot = 1;
client = findClientByName("Halt");
};
MissionCleanup.add(%p);
not sure if source object is needed, it should be the gun, but instead I made it a client (you)