Akimbo Rapid Fire w/ Anti-recoil

This is a toggle-able Akimbo rapid fire (Y), which then switches to regular rapid fire. It has anti-recoil, so when firing the guns it won't go up. This will need to be adjusted.
Versionv1
AuthorValant
Publish DateMon, 4 May 2015 - 23:10
Last UpdateMon, 4 May 2015 - 23:10
Downloads301
RATE


1

0

Release Notes: J2Kbr helped me make this.
Code: Select all
define RAPIDFIRE_BUTTON1 = XB360_RT;
define RAPIDFIRE_BUTTON2 = XB360_LT;
 
define RATE_OF_FIRE1 = 20// Range: 1 to 25 RPS (Round/s)
define RATE_OF_FIRE2 = 20// Values higher than 25 would be so
int akimbo_onoff = FALSE;
                            // fast that the game probably will
                            // not detect 100% of the events.
 
define ONLY_WITH_SCOPE = TRUE;// Use Anti-recoil only when scoping
define ANTI_RECOIL = 0;       //change "0" to compensate vertical recoil (0 - 100)
define ANTI_RECOIL_LEFT = 0//change this value to compensate to the left (0 - 100)
define ANTI_RECOIL_RIGHT = 0; //change this value to compensate to the right (0 - 100)
 
//
// No need to make changes in the code below.
//
 
int hold_time1, rest_time1;
int hold_time2, rest_time2;
 
int fire_button, scope_button;
int anti_recoil;
int anti_recoil_left;
int anti_recoil_right;
 
init {
    hold_time1 = 500 / RATE_OF_FIRE1;
    rest_time1 = hold_time1 - 20;
    if(rest_time1 < 0) rest_time1 = 0;
 
    hold_time2 = 500 / RATE_OF_FIRE2;
    rest_time2 = hold_time2 - 20;
    if(rest_time2 < 0) rest_time2 = 0;
 
    if(get_console() == PIO_XB360) { // XB360 Trigger & Bumper
        fire_button = 3;
        scope_button = 6;
    } else {                       // Natural Trigger & Bumper
        fire_button = 4;
        scope_button = 7;
    }
}
 
main {
    if(get_val(RAPIDFIRE_BUTTON1)) {
        combo_run(RapidFire1);
    } else if(combo_running(RapidFire1)) {
        combo_stop(RapidFire1);
    }
 
    if(event_press(XB360_Y)){
        akimbo_onoff = !akimbo_onoff;
        if(akimbo_onoff){
            set_val(TRACE_1, 1); //1  = akimbo_onoff is TRUE, 0 = rap[id_onoff is FALSE
        }else if(!akimbo_onoff){
            set_val(TRACE_1, 0); //akimbo_onoff = FALSE
        }
    }
 
    if(get_val(RAPIDFIRE_BUTTON2) && akimbo_onoff) { //Now Looks for a "TRUE" value of rapid_onoff and turns on rapid fire on the left trigger accordingly
        combo_run(RapidFire2);
    } else if(combo_running(RapidFire2)) {
        combo_stop(RapidFire2);
    }
 
    if(!ONLY_WITH_SCOPE || get_val(scope_button)) {
        combo_run(AntiRecoil);
    }
}
combo RapidFire1 {
    set_val(RAPIDFIRE_BUTTON1, 100);
    wait(hold_time1);
    set_val(RAPIDFIRE_BUTTON1, 0);
    wait(rest_time1);
    set_val(RAPIDFIRE_BUTTON1, 0);
}
 
combo RapidFire2 {
    set_val(RAPIDFIRE_BUTTON2, 100);
    wait(hold_time2);
    set_val(RAPIDFIRE_BUTTON2, 0);
    wait(rest_time2);
    set_val(RAPIDFIRE_BUTTON2, 0);
} 
 
combo AntiRecoil { // This combo must be the last one
    if(get_val(fire_button)) {
    anti_recoil = get_val(10) + ANTI_RECOIL;
    if(anti_recoil > 100) anti_recoil = 100;
    set_val(10, anti_recoil);
    anti_recoil_left = get_val(9) -ANTI_RECOIL_LEFT;
    if(anti_recoil_left > 100) anti_recoil_left = 100;
    set_val(9, anti_recoil_left);
    anti_recoil_right = get_val(9) +ANTI_RECOIL_RIGHT;
    if(anti_recoil_right > 100) anti_recoil_right = 100;
    set_val(9, anti_recoil_right);
    }
}