Game Development Community

Firing two mounted guns

by James Laker (BurNinG) · in Torque Game Engine · 01/09/2007 (2:02 pm) · 5 replies

I've looked through alot af code from deathcar to the deepest corners of the Tribes Scout, without a solution which brings me back to the forum.

Im trying to fire my weapons at the SAME time here. Not one after the other. With my current code, when I click my mousebutton, both ShapeBaseImages fire the first shot. When I hold my mousebutton down only the first ShapeBaseImage keeps on firing.

Im trying to get as much done without actually having to go into the code. So here's some of my code, if you wanna take a look.

Im inheriting from the image which only has Mountpoint as 0:
datablock ShapeBaseImageData(RepeaterCannonImage1:RepeaterCannonImage)
{
   mountPoint = 0;
}

My fighter Trigger code:
function Fighter::onTrigger(%data, %obj, %trigger, %state)
{
   // data = datablock
   // obj = object number
   // trigger = 0 for "Cannon", 1 for "Laser", 3 for "Thrust"
   // state = 1 for firing, 0 for not firing or stopping

   switch (%trigger) {
      // Primary
      case 0:
         switch (%state) {
            case 0:
               %obj.setImageTrigger(0, false);
               %obj.setImageTrigger(1, false);
            case 1:
               %obj.setImageTrigger(0, true);
               %obj.setImageTrigger(1, true);
         }
      
      //Secondary
      case 1:
         switch (%state) {
            case 0:
               %obj.fireWeapon = false;
               %obj.setImageTrigger(2, false);
            case 1:
               %obj.fireWeapon = true;
               %obj.setImageTrigger(2, true);
         }      
   }
}

Any help would be great!

#1
01/09/2007 (2:46 pm)
The script look ok.
Are you mounting the guns on 2 diff slots ?
#2
01/09/2007 (2:58 pm)
If you haven't already tried it, let me recommend Zod's multigame starter kit. It has exactly what you are describing -- it can be found in the buggy.cs script. There's a lot of cool stuff in Zod's kit.

Anyway, here's a link . . .

www.garagegames.com/blogs/22555/11876
#3
01/10/2007 (2:32 am)
@Billy L: Yep...
@Aaron: Thanx... Will get right to it.

Got it working when reading Billy's question... It was late and the old thinker let me down. Since the weapons are mounted to 2 mounts (0 & 1), I just needed add the $mvTriggerCount1++; in the client fire scripts (default.bind.cs).... duh!

Thanx!
#4
01/10/2007 (4:23 am)
Perhaps this is obvious but you can remove the onTrigger additions and just keep the $mvTriggerCount stuff. Alot simpler :)
#5
01/10/2007 (2:06 pm)
@Stefan: Thanx... It works as it is now. Not sure what you mean by removing the onTrigger. Can you explain a little bit clearer? Or did you mean what i did, is the obvious/correct way?