Author Topic: functions  (Read 1207 times)

I added a function to my gun script and it doesnt seem to be working

contains syntax errors
Code: [Select]
function gunImage::onFire(%this,%obj,%slot)
{
  Parent::onFire(%this, %obj, %slot);
  %random = getRandom(1,3);
  switch(%random)
  {
    case 1:
      serverplay3d("gunShot1", %obj.getHackPosition() SPC "0 0 1 0");
    case 2:
      serverplay3d("gunShot2", %obj.getHackPosition() SPC "0 0 1 0");
    case 3:
      serverplay3d("gunShot3", %obj.getHackPosition() SPC "0 0 1 0");
    default:
      echo("Error on Falco's Rage");
  }
}

{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftLeft);
%obj.playThread(0, shiftRight);
Parent::onFire(%this,%obj,%slot);
%spread = 0.0005;
%shellcount = 2;

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;
}

that's just the part where the syntax errors are coming up

Can anyone fix this


The sounds still don't sound randomized

instead of

 %random = getRandom(1,3);
  switch(%random)
  {
    case 1:
      serverplay3d("gunShot1", %obj.getHackPosition() SPC "0 0 1 0");
    case 2:
      serverplay3d("gunShot2", %obj.getHackPosition() SPC "0 0 1 0");
    case 3:
      serverplay3d("gunShot3", %obj.getHackPosition() SPC "0 0 1 0");
    default:
      echo("Error on Falco's Rage");
  }

try

 %random = getRandom(1,3);
 serverplay3D("gunShot" @ %random, %obj.getPosition());

 Make sure you have the gunshot sounds coded too. (that may be why they aren't playing)

Code: [Select]
%random = getRandom(1,3);
 serverplay3D("gunShot" @ %random, %obj.getPosition());

How do you continue and end that and how do you make sure the sounds are coded

How do you continue and end that and how do you make sure the sounds are coded

Well, do the datablocks even exist? You did code them in, right?
« Last Edit: April 12, 2014, 04:03:14 PM by Electrk. »

default:
      echo("Error on Falco's Rage");
  }
} ←remove this
Nope, try again

Well, do the datablocks even exist? You did code them in, right?

ya