TitanFall Toggle ADS

Toggles ADS on/off with Left Trigger. Turns off ADS when reloading, switching weapons, throwing a grenade, or sprinting.
Version1.20
Authorjim007
Publish DateWed, 19 Feb 2014 - 11:32
Last UpdateSat, 15 Mar 2014 - 05:52
Downloads946
RATE


4

1

Release Notes: Added Rapid Fire
Code: Select all
// GPC Online Library
// titanfall_toggle_ads.gpc
 
/*
    Update 3/14/2014: Added Rapid Fire stuff
    Update 2/24/2014: Added ADS sensitivity adjustment.
 
    Toggles ADS on and off by pressing LT.
    Turns off ADS when reloading, switching weapons, throwing a grenade, and sprinting.
    Simply press and release LT again to be back in ADS mode.
 
    Assign a Key (e.g: F1) to CEMU_EXTRA1 to use that for toggling Rapid Fire on/off
    Long pressing it for over 1 second will turn Rapid Fire on.
    Tap pressing it will turn Rapid Fire off.
*/

 
define BUTTON_ADS = XB1_LT;
define BUTTON_FIRE = XB1_RT;
define BUTTON_RELOAD = XB1_X;
define BUTTON_SWITCH = XB1_Y;
define BUTTON_LAUNCHER = XB1_LEFT;
define BUTTON_GRENADE = XB1_RB;
define BUTTON_SPRINT = XB1_LS;
define STICK_RIGHT_Y = XB1_RY;
define STICK_RIGHT_X = XB1_RX;
define STICK_LEFT_Y = XB1_LY;
 
/*
    If you want to increase your ADS sensitivity set this to a number over 100.
    If you want to decrease your ADS sensitivity set this to a number below 100.
*/

define SENS_ADS = 100;
 
 
// Key that will be pressed to turn Rapid Fire On/Off
define KEY_RF = CEMU_EXTRA1;
 
// How long (in miliseconds) to hold the fire button
define RF_HOLD = 40;
// How long (in miliseconds) to wait between bursts
define RF_WAIT = 40;
 
// Used for toggle ADS logic
int ads = FALSE;
 
// You can set this to TRUE if you want Rapid Fire to be On by default
int rapid_fire = FALSE;
 
main {
 
    // Toggle ADS on and off by pressing and releasing the ADS Button
    if ( event_press(BUTTON_ADS) )
    {
        ads = !ads;
    }
    // Turn off ADS when reloading, switching to sidearm, switching to anti-titan weapon, or throwing a grenade
    else if ( event_press(BUTTON_RELOAD) || event_press(BUTTON_SWITCH) || event_press(BUTTON_LAUNCHER) || event_press(BUTTON_GRENADE) )
    {
        ads = FALSE;
    }
    // Turn off ADS by sprinting
    else if ( event_press(BUTTON_SPRINT) &&  get_val(STICK_LEFT_Y) < 0 )
    {
        ads = FALSE;
    }
 
    // Hold ADS Button until ads variable is toggled off
    // Will also adjust ADS sensitivity
    if (ads)
    {
        set_val(BUTTON_ADS, 100);
        sensitivity(STICK_RIGHT_X, NOT_USE, SENS_ADS);
        sensitivity(STICK_RIGHT_Y, NOT_USE, SENS_ADS);
    }
 
    // Use Rapid Fire if it is on
    if ( rapid_fire && get_val(BUTTON_FIRE) )
    {
        combo_run(rapidFire);
    }
    // Kill Rapid Fire as soon as you let go of the Fire Button
    else if ( combo_running(rapidFire) )
    {
        combo_stop(rapidFire);
    }
 
    // Rapid Fire On with a long (over 1 second) key press
    // Rapid Fire Off with a tap key press
    if ( event_release(KEY_RF) )
    {
        if ( get_ptime(KEY_RF) > 1000 )
            rapid_fire = TRUE;
        else
            rapid_fire = FALSE;
    }
 
}//==> main
 
combo rapidFire {
    set_val(BUTTON_FIRE,100);
    wait(RF_HOLD);
    set_val(BUTTON_FIRE,0);
    wait(RF_WAIT);
    set_val(BUTTON_FIRE,0);
}