Author Topic: Little problem with rapid fire  (Read 453 times)

Im working on a laser pick, and I did this, but it wont rapid fire.
Code: [Select]
datablock shapeBaseImageData(DiggingLaserPickaxeImage : gunImage)
{
item = DiggingLaserPickaxeItem;
projectile = DiggingLaserPickaxeProjectile;
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.2;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;

stateName[2] = "Fire";
stateTransitionOnTimeOut[2] = "Reload";
stateTimeoutValue[2] = "0.08";
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire";
stateWaitForTimeout[2] = true;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzlePoint";
stateEjectShell[2] = true;
stateScript[2] = "onFire";

stateName[3] = "Fire2";
stateTransitionOnTimeOut[3] = "Reload";
stateTimeoutValue[3] = "0.08";
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateWaitForTimeout[3] = true;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzlePoint";
stateEjectShell[3] = true;
stateScript[3] = "onFire2";

stateName[4] = "Reload";
stateTimeoutValue[4] = 0.01;
stateTransitionOnTriggerUp[4] = "Fire2";
stateTransitionOnTimeout[4] = "Fire2";
};
I even took the states out of a machine gun.
Nvm, I found out I needed the onFire2 and Fire2.
Now I need to make it more straight, cause its annoying how it goes out everywhere.
Code: [Select]
function DiggingLaserPickaxeImage::onFire(%this,%obj,%slot)
{
  gc_FamasZombiesAmmo(%this,%obj,%slot);
  %obj.gc_FamasAmmo -= 1;
  if(%obj.gc_FamasAmmo < 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_weaponRecoil;
    initialVelocity = VectorAdd(%vector1,%vector2);
    initialPosition = %obj.getEyePoint();
    sourceObject = %obj;
    sourceSlot = %slot;
    client = %obj.client;
  };
  %projectile = %this.projectile;
  %spread = 0.001;
  %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;
}

function DiggingLaserPickaxeImage::onFire2(%this,%obj,%slot)
{
  gc_FamasZombiesAmmo(%this,%obj,%slot);
  %obj.gc_FamasAmmo -= 1;
  if(%obj.gc_FamasAmmo < 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_weaponRecoil;
    initialVelocity = VectorAdd(%vector1,%vector2);
    initialPosition = %obj.getEyePoint();
    sourceObject = %obj;
    sourceSlot = %slot;
    client = %obj.client;
  };
  %projectile = %this.projectile;
  %spread = 0.0025;
  %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;
}
Nvm again, I found out, I just made %x, %y, %z = 0.
« Last Edit: July 25, 2010, 03:22:24 PM by Pah1023 »