package AR2AltFire
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
if(%player.getMountedImage(0) $= HL2AR2Image.getID() && %slot $= 4 && %val) // Make sure the "HL2AR2Image" is changed to your weaponImage.
{
if(%player.lastAlt !$= "" && getSimTime() - %player.lastAlt < 10000)
{
%player.playThread(2, plant);
serverPlay3D(HL2PistolClickSound,%player.getPosition()); // Unable to fire sound, I used my pistolClick.
return;
}
serverPlay3D(HL2AR2ChargeSound,%player.getPosition()); // This is the charge sound, you can probably just rip this straight out of hl2 for it to work, just make sure it lasts about 1000ms.
%player.schedule(0,0,playThread, 2, shiftLeft);
%player.schedule(111,0,playThread, 2, plant);
%player.schedule(222,0,playThread, 2, shiftRight);
%player.schedule(333,0,playThread, 2, shiftLeft);
%player.schedule(444,0,playThread, 2, plant);
%player.schedule(555,0,playThread, 2, shiftRight);
%player.schedule(666,0,playThread, 2, shiftLeft);
%player.schedule(777,0,playThread, 2, plant);
%player.schedule(888,0,playThread, 2, shiftRight);
%player.schedule(999,0,playThread, 2, plant);
schedule(1000 ,0,HL2AR2AltFire,%this, %player, %slot, %val);
%player.lastAlt = getSimTime();
}
Parent::onTrigger(%this, %player, %slot, %val);
}
};
ActivatePackage(AR2AltFire);
function HL2AR2AltFire(%this, %player, %slot, %val)
{
%projectile = energyBallProjectile;
%vector = %player.getMuzzleVector(0);
%objectVelocity = %player.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %player.getMuzzlePoint(0);
sourceObject = %player;
sourceSlot = 0;
client = %player.client;
};
serverPlay3D(HL2AR2AltFireSound,%player.getPosition()); // Find a fire sound for the AR2 blast.
%player.playThread(2, activate);
MissionCleanup.add(%p);
return %p;
}
AR2 Balls anyone? Code segment free to use, just make sure space guy's energy ball is enabled.
EDIT: I just realized I swapped %obj and %player randomly in this code segment, silly me, anyways fixed it.