function ARX160Image::onFire(%this, %obj, %slot){
initContainerRadiusSearch(%obj.getPosition(), 150, $TypeMasks::PlayerObjectType, %obj); // %obj is the player, not %this
while(%player = containerSearchNext()) {
if(!isObject(%player.client))
continue; // ignore bots
%dist = vectorDist(%obj.getPosition(), %player.getPosition());
if(%dist < 50)
%player.client.play3D(ARX160Fire, %obj.getPosition());
else if(%dist < 100)
%player.client.play3D(ARX160Med, %obj.getPosition());
else
%player.client.play3D(ARX160Long, %obj.getPosition());
}
}
%obj.spawnExplosion(testRecoilProjectile,"1 1 1");
if(%obj.getDamagePercent() >= 1.0)
return;
if(vectorLen(%obj.getVelocity()) < 0.1 && (getSimTime() - %obj.lastShotTime) > 50)
{
%projectile = ARX160Projectile;
%spread = 0.0025;
}
else
{
%projectile = ARX160Projectile;
%spread = 0.0030;
}
%obj.lastShotTime = getSimTime();
%shellcount = 1;
%obj.playThread(2, root);
%shellcount = 1;
%obj.toolAmmo[%obj.currTool]--;
commandToClient(%obj.client,'bottomPrint',"<color:0aa000><just:right><font:Arial:20>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ "32 " @ "", 4, 2, 3, 4);
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;
}
here you go.