Author Topic: Secondary Fire  (Read 2763 times)

I was just wondering, what is the function for finding if the player has their right click down?

You have to package the armor::onTrigger function.

Code: [Select]
package altFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= <weaponimagenamegoeshere>.getID() && %slot $= 4)
      {
         if(%val)
         {
            // blah blah weapon code goes here
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(altFire);

like this?, sorry im not all that good with coding yet

Code: [Select]
package altFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= <flamethrowerImage>.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamethrowerAirprojectile;
       %spread = 0.0001;
       %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) * 2 * 3.1415926 * %spread;
     %y = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
     %z = (getRandom() - 0.5) * 2 * 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;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(altFire);

There is actually an armor::onAltTrigger you'd need to modify the client code somewhat which isn't really feasible.

Everyone seems to be basing their onFire stuff off the code in my shotgun for some reason, so everyone ends up having spread for something that really needs no spread. Kind of weird.

Assigning altTrigger to something clientside forces the left gun in Guns Akimbo to fire by itself, which is interesting.

Maybe Badspot could implement altTrigger(); as a keybind, and an option to have it bound to the same as the jets, for alternate fire weapons?

It'd trigger the weaponimage in the left hand by default I assume.

altTrigger does trigger left hand by default, aslong as the left image has the states.
I do think Badspot should add a default keybind for altTrigger.

I used the code a posted earlier, but it works in-game, but right click does nothing

Console: http://dantheracer.googlepages.com/console.log

Code: [Select]
>>> Some error context, with ## on sides of error halt:
   function armor::onAltTrigger(%this, %player, %slot, %val)

   {

      if(%player.getMountedImage(0) $= <F##l##amerImage>.getID() && %slot $= 0)

      {

         if(%val)

         {
>>> Error report complete.

Take out the <> on FlamerImage.

ha didn't see that, but it still does nothing in-game, is this right?

Code: [Select]
package altFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamerProjectile;
       %spread = 0.0001;
       %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) * 2 * 3.1415926 * %spread;
     %y = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
     %z = (getRandom() - 0.5) * 2 * 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;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(altFire);

Everyone seems to be basing their onFire stuff off the code in my shotgun for some reason, so everyone ends up having spread for something that really needs no spread. Kind of weird.
Code: [Select]
package flameraltFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamerProjectile;
     %vector = %obj.getMuzzleVector(%slot);
     %objectVelocity = %obj.getVelocity();
     %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
     %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
     %velocity = VectorAdd(%vector1,%vector2);
     %p = new (%this.projectileType)()
     {
      dataBlock = %projectile;
      initialVelocity = %velocity;
      initialPosition = %obj.getMuzzlePoint(%slot);
      sourceObject = %obj;
      sourceSlot = %slot;
      client = %obj.client;
     };
     MissionCleanup.add(%p);
        return %p;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(flameraltFire);
Took out spread and shellcount loop.
Changed package name just incase that package name is in use.

Hmmm still not working

Hahaha I see the problem.
%p = new (%this.projectileType)()
is wrong.
%p = new Projectile()

like this? and thank for this your a great help
Code: [Select]
package flameraltFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamerProjectile;
     %vector = %obj.getMuzzleVector(%slot);
     %objectVelocity = %obj.getVelocity();
     %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
     %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
     %velocity = VectorAdd(%vector1,%vector2);
     %p = new Projectile();
     {
      dataBlock = %projectile;
      initialVelocity = %velocity;
      initialPosition = %obj.getMuzzlePoint(%slot);
      sourceObject = %obj;
      sourceSlot = %slot;
      client = %obj.client;
     };
     MissionCleanup.add(%p);
        return %p;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(flameraltFire);

It was for a more flexible system where you could fire items and stuff instead of a projectile. I figured most people would go with the flow and have projectileType = "Projectile" in their weapon image datablocks.

(And no ; after the new Projectile() )