Game Development Community

Alt Fire? [Solved]

by Jesse Allen · in Torque 3D Beginner · 07/04/2014 (12:11 pm) · 2 replies

Hi guys, I've been setting up some weapons and I've found that the altFire isn't working. I believe I've gone through all of the standard motions and was hoping someone could clue me in as to what I'm overlooking.

In the weapon's datablock I've got this state for the altFire:

stateName[14]                     = "AltFire";
stateTransitionGeneric0In[14]     = "SprintEnter";
stateTransitionOnTimeout[14]      = "Reload";
stateTimeoutValue[14]             = 0.1;
stateAlternateFire[14]            = true;
stateEnergyDrain[14]				= 30.0;
stateRecoil[14]                   = "";
stateAllowImageChange[14]         = false;
stateSequence[14]                 = "fire_alt";
stateScaleAnimation[14]           = true;
stateSequenceNeverTransition[14]  = true;
stateSequenceRandomFlash[14]      = true;        // use muzzle flash sequence
stateScript[14]                   = "onAltFire";
stateSound[14]                    = LaserFireSoundList;

In the same datablock I've added an altProjectile as well as the energy use fields:

usesEnergy = true;
minEnergy = 20;

altProjectile = blueLaserProjectile;
altProjectileSpread = "0.005";

Finally, I've updated the default.bind.cs so that the altTrigger function isn't commented out:

function altTrigger(%val)
{
   $mvTriggerCount1++;
}

moveMap.bind( mouse,button1, altTrigger );

Does anyone have any ideas? I'd just use another weapon datablock as reference, but alas I haven't seen any of the stock T3D 3.5 MIT weapons using altFire...The Lurker I believe supported it at one time but doesn't seem to anymore?

What Does Work:

The onAltFire() callback does work if I simply call it in the weapons's 'Fire' state, although that defeats the purpose of an altFire :) Just replacing the onFire() with onAltFire().

Also the energy drain etc. is working as intended. Really just seems like a problem with the right click communicating that it's being pressed and calling for the AltFire state, but using all of the available documentation and thread resources I could find I can't pinpoint the problem.

As usual, thanks for any help!



#1
07/06/2014 (9:24 am)
Beginning to become a common theme, but I solved this myself...a bit surprised no one answered though on such a basic question...

In case anyone else runs into this trying to setup alt-fire for the first time:

In default.bind.cs, when you un-comment the altTrigger() function you also need to understand the $mvTrigger1 variable. These trigger variables are declared in the engine script (C++) and designate specific 'movement' type tasks. By default, the $mvTrigger1 is set to 'jump-jet' and a toggle between altFire and mountSlot1...I'm not entirely sure what's up with this supposed toggle since I have yet to have $mvTrigger1 ever work for altFire.

What it does do though is it triggers a weapon in slot 1, so in my case this works fine for what I'm doing. I'm just setting the $mvTrigger1 to fire a different weapon mounted on slot1 (if the correct ammo is equipped to enable alt-fire). The 2 weapons are identical other than the projectile and ammo, so the end result is the same. Still not entirely sure why it's so difficult to just re-use the same 'fire' sequence on another 'altFire' state within the same weapon datablock, but whatever.
#2
08/18/2015 (11:40 am)
add in weapon datablock nearby with stateTransitionOnTriggerDown[...] = "Fire";
:

stateTransitionOnAltTriggerDown[2] = "AltFire";
.
.
.
stateTransitionOnAltTriggerDown[3] = "AltFire";
.
.
.
stateTransitionOnAltTriggerDown[4] = "AltFire";
.
.
.