Rapid Fire/Anti-Recoil (ON/OFF) for XIM

Created by J2Kbr work with all fps game to edit recoil change the # in the line below ANTIRECOIL_FORCE =4 for rapid fire change the # in the line below RATE_OF_FIRE = 25
Version1.00
Authory2k
Publish DateTue, 3 May 2016 - 19:26
Last UpdateTue, 3 May 2016 - 19:26
Downloads675
RATE


7

0

Code: Select all
 
define RAPIDFIRE_ENABLE  = TRUE;    // TRUE or FALSE
define ANTIRECOIL_ENABLE = TRUE;    // TRUE or FALSE
 
// --
 
define XIM4_MIN_VAL = 20;
// The force needed is different when ADS or hip firing
define ANTIRECOIL_FORCE = 4;
define RAPIDFIRE_BUTTON = PS4_R2;
define RATE_OF_FIRE = 25;   // Range: 1 to 25 RPS (Round/s)
                            // Values higher than 25 would be so fast that the
                            // game probably will not detect 100% of the events.
int tmp, rsf, xcmp;
int hold_time, rest_time;
 
init {
    block_rumble();
    rsf = 10000 / (100 - XIM4_MIN_VAL);
 
    hold_time = 500 / RATE_OF_FIRE;
    rest_time = hold_time - 10;
    if(rest_time < 0) rest_time = 0;
}
 
main {
    if(ANTIRECOIL_ENABLE) {
        // AIM down side + aiming and shooting but not moving - enable antirecoil
        // AIM down side + aiming and shooting AND moving left or right (i mean aiming) - not walking left or right - disable the antirecoil?
        if(get_val(PS4_L2) && get_val(PS4_R2) && isqrt(pow(get_val(PS4_RX), 2) + pow(get_val(PS4_RY), 2)) <= 30) {
      //if(get_val(PS4_R2) && (get_ptime(PS4_R2) <= 50 || get_ptime(PS4_R2) >= 100)) {
            if(abs(PS4_RX) < 25) {
                // Rescale XIM4 aim Y axis
                if(get_val(PS4_RY) >= XIM4_MIN_VAL) {
                    set_val(PS4_RY, get_val(PS4_RY)-XIM4_MIN_VAL);
                    sensitivity(PS4_RY, NOT_USE, rsf);
                } else if(get_val(PS4_RY) <= -XIM4_MIN_VAL) {
                    set_val(PS4_RY, get_val(PS4_RY)+XIM4_MIN_VAL);
                    sensitivity(PS4_RY, NOT_USE, rsf);
                } else set_val(PS4_RY, 0);
 
                // Rescale XIM4 aim X axis
                if(get_val(PS4_RX) >= XIM4_MIN_VAL) {
                    set_val(PS4_RX, get_val(PS4_RX)-XIM4_MIN_VAL);
                    sensitivity(PS4_RX, NOT_USE, rsf);
                } else if(get_val(PS4_RX) <= -XIM4_MIN_VAL) {
                    set_val(PS4_RX, get_val(PS4_RX)+XIM4_MIN_VAL);
                    sensitivity(PS4_RX, NOT_USE, rsf);
                } else set_val(PS4_RX, 0);
 
                // X movements compensation
                tmp = ANTIRECOIL_FORCE - 3 * abs(get_val(PS4_RX));
 
                // Apply the anti-recoil
                if(tmp <= 0) tmp = 1;
                tmp = get_val(PS4_RY) + tmp;
                if(tmp > 100) tmp = 100;
                else if(tmp < -100) tmp = -100;
                set_val(PS4_RY, tmp);
 
                // Re-apply deadzone;
                deadzone(PS4_RX, PS4_RY, XIM4_MIN_VAL, XIM4_MIN_VAL);
            }
        }
    }
 
    // RAPIDFIRE
    if(RAPIDFIRE_ENABLE) {
        if(get_val(RAPIDFIRE_BUTTON)) {
            combo_run(RapidFire);
        } else if(combo_running(RapidFire)) {
            combo_stop(RapidFire);
        }
    }
}
 
combo RapidFire {
    set_val(RAPIDFIRE_BUTTON, 100);
    wait(hold_time);
    set_val(RAPIDFIRE_BUTTON, 0);
    wait(rest_time);
    set_val(RAPIDFIRE_BUTTON, 0);
}