Secondary Trigger
Created By: CheapAlert
eMail: cheapalert@yahoo.com
Difficulty Scale: Easy


Modern First-person shooters today are utilizing the Secondary Trigger, or Alternate Fire, or Special Fire. In Quake, it's pretty HARD to do this, unless you do it my way around here ;)

Most mod's "secondary trigger" isn't really a trigger, it's more like a oneway button. Once held down that trigger, it only fires once. Because that's bound to an IMPULSE, and it ain't deep enough

Now you can have a secondary trigger without modifying the Quake engine. And at the same time, you can have a "toggle trigger" and a "pick trigger" impulse for people who prefer it that way, which makes this tutorial very neat and unique. Let's get started shall we?

First, we open DEFS.QC. Get to the end of the file and paste this:

// CheapAlert - Secondary Trigger Tut
.float finger; // your fastest finger that picks in order A B C or D

That's the floating finger, that is really the value of which trigger to use. Now go to WEAPONS.QC. This is where we make most of the changes. Copy the entire W_Attack function and paste to make a new one. Call this function "W_Attack2". All righty! 2 ways to fire! But how do we fire the 2nd way? Go to the old W_Attack function and add this at the top:


if (self.finger == 1)
{
    W_Attack2(); // use the other trigger
    return;
}

This will make sure that the right finger is in the right trigger. Now we're getting somewhere, aren't we?

Let's make this thing be toggled. It'll require a new function to do this. But this is for people that TOGGLE firing modes (i.e. System Shock 2 players).

Paste this above W_Attack2:

void() W_MoveFinger =
{
       if (self.finger == 0)
       {
            self.finger = 1; // now put it on the other trigger
            centerprint(self,"Secondary Mode\n"); // let him know without clogging the console with unsubliminal messages
            return;
       }
       if (self.finger == 1)
       {
            self.finger = 0; // ditto
            centerprint(self,"Primary Mode\n");
            return;
       }
};
Now it's getting obvious about what we're doing here. Now let's add the impulses. Paste this under "CheatCommand();":

        if (self.impulse == 210)
                self.finger = 0; // primary trigger
        if (self.impulse == 211)
                self.finger = 1; // secondary trigger
        if (self.impulse == 212)
                W_MoveFinger(); // toggle switch
Ahh....

Now you're thinking "Where's the firing impulse?" Well today we're gonna do some aliasing. I suggest that you copy the following into a new document:


// QUAKE RC begins
// load the base configuration
exec default.cfg

// load the last saved configuration
exec config.cfg

// run a user script file if present
exec autoexec.cfg

//
// stuff command line statements
//
stuffcmds

// start demos if not allready running a server
startdemos demo1 demo2 demo3

// CheapAlert - putting in the triggers
alias +primary "impulse 210;+attack"
alias -primary "-attack"
alias +secondary "impulse 211;+attack"
alias -secondary "-attack"

Save as "QUAKE.RC" into your mod's root folder. (not your source code folder)

Compile your mod and run. If you get "Unknown value "W_Attack2"" message, make a prototype at the top of Weapons.QC saying:

void() W_Attack2;

then compile.

If you like the new keys I aliased, go ahead and bind +primary as your main shoot button and +secondary as your other shoot button. Or if you're the toggle kind of guy, bind a key to impulse 212. Or if you like to use 2 keys to pick what you want, bind a key to impulse 210 and another (preferably close) to impulse 211. There. Many ways to fire a second trigger. Two times the ways to die with a weapon.

Have fun and go trigger happy. - CheapAlert