Game Development Community

Secondary Weapon Fire

by ccamilleri · in Torque Game Engine · 07/26/2006 (12:53 pm) · 1 replies

I am currently trying to implement a secondary fire for the crossbow (to start with) and I followed this resource.

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5546

I then tried to implement the scripting code to add an alt fire. I modified config.cs, default.bind.cs, and optionDlg.cs to map button1 of the mouse to the altrigger function which increaments $mvTriggerCount1++;. Here is a bit of the script

function altTrigger(%val)
{
   echo("alt trigger fire");
   $mvTriggerCount1++;
}

moveMap.bind( mouse, button0, mouseFire );
moveMap.bind( mouse, button1, altTrigger );

From there we lose what function is called since that just increments a variable. We modified the crossbow.cs files datablock to look like this:

datablock ShapeBaseImageData(CrossbowImage)
{
   ...
   // Initial start up state
   stateName[0]                     = "Preactivate";
   stateTransitionOnLoaded[0]       = "Activate";
   stateTransitionOnNoAmmo[0]       = "NoAmmo";

   // Activating the gun.  Called when the weapon is first
   // mounted and there is ammo.
   stateName[1]                     = "Activate";
   stateTransitionOnTimeout[1]      = "Ready";
   stateTimeoutValue[1]             = 0.6;
   stateSequence[1]                 = "Activate";

   // Ready to fire, just waiting for the trigger
   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateTransitionOnTriggerDown[2]  = "Fire";
   stateTransitionOnSecondTriggerDown[2]  = "AltFire";

   // Fire the weapon. Calls the fire script which does 
   // the actual work.
   stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.2;
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateSound[3]                    = CrossbowFireSound;
   
   // Play the relead animation, and transition into
   stateName[4]                     = "Reload";
   stateTransitionOnNoAmmo[4]       = "NoAmmo";
   stateTransitionOnTimeout[4]      = "Ready";
   stateTimeoutValue[4]             = 0.8;
   stateAllowImageChange[4]         = false;
   stateSequence[4]                 = "Reload";
   stateEjectShell[4]               = true;
   stateSound[4]                    = CrossbowReloadSound;

   // No ammo in the weapon, just idle until something
   // shows up. Play the dry fire sound if the trigger is
   // pulled.
   stateName[5]                     = "NoAmmo";
   stateTransitionOnAmmo[5]         = "Reload";
   stateSequence[5]                 = "NoAmmo";
   stateTransitionOnTriggerDown[5]  = "DryFire";

   // No ammo dry fire
   stateName[6]                     = "DryFire";
   stateTimeoutValue[6]             = 1.0;
   stateTransitionOnTimeout[6]      = "NoAmmo";
   stateSound[6]                    = CrossbowFireEmptySound;
   
   // Alt Fire the weapon. Calls the altfire script which does 
   // the actual work.
   stateName[7]                     = "AltFire";
   stateTransitionOnTimeout[7]      = "Reload";
   stateTimeoutValue[7]             = 0.2;
   stateFire[7]                     = true;
   stateRecoil[7]                   = LightRecoil;
   stateAllowImageChange[7]         = false;
   stateSequence[7]                 = "Fire";
   stateScript[7]                   = "onAltFire";
   stateSound[7]                    = CrossbowFireSound;

};

so now State 7 is the alt fire and we defined the onAltFire function to echo that we entered the function. The problem is that we cant seem to get that function to fire. Is there a function somewhere that we are missing that links up the $mvTriggerCount1 to the state change in the crossbow?

Thanks!

#1
07/27/2006 (9:37 am)
I would really like to get this info as well. I have pretty much the same problem but a different weapon.