The way this weapon is supposed to work is that every time this script onBuffer is called, a variable increases in value. That variable directly affects bullet deviation in a very simple manner. Here are the weapon's scripts:
function BusterCarbineImage::onReady(%this,%obj,%slot)
{
%obj.RecoilCount = 0;
}
function BusterCarbineImage::onFire(%this,%obj,%slot,%recoil)
{
serverPlay3D(gunshot1Sound, %obj.getPosition());
%obj.playthread(0, plant);
%recoil = %obj.RecoilCount;
%spread = 0.1;
%vector = %obj.getMuzzleVector(%slot);
%vector = VectorScale(%vector, 130);
%x = 0;
%y = (%recoil * %spread);
%z = 0;
%mat = MatrixCreateFromEuler(%x SPC %y SPC %z);
%velocity = MatrixMulVector(%mat, %vector);
%p = new projectile()
{
dataBlock = gunProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
missionCleanup.add(%p);
return %p;
}
function BusterCarbineImage::onBuffer(%this,%obj,%slot,%recoil)
{
%obj.playThread(0, root);
if(%obj.RecoilCount >= 1)
{
%obj.RecoilCount = 1;
}
else
{
%obj.RecoilCount += .25;
}
}
A syntax error occurs here (from console log):
function BusterCarbineImage::onBuffer(%this,%obj,%slot,%recoil)
{
^%obj.playThread(0, root);
^if(%obj.RecoilCount >= 1)
^{
^^%obj.RecoilCount = 1;
^}
^else
^{
^^%obj.RecoilCount += .##2##5;
^}
}
>>> Error report complete.
ADD-ON "Weapon_BusterCarbine" CONTAINS SYNTAX ERRORS
What's actually wrong with the code? Other pointers would be appreciated as well. Thank you.