Destiny RapidFire and AntiRecoil with XIM4

Destiny RapidFire & AntiRecoil for XIM4 Users. Works great with PulseRifle (and Grasp of Malok), Scout and Handcannon. Not recommended for AutoRifles. All credits and thanks for this script goes to our Forum Group Leader: J2Kbr All I added is: When switching weapon (Special or Heavy) RapidFire will stop working. Reason is, FusionRifle and HeavyMG don't work when RF is active. Switching back to Primary you need to enable it again manually using Touchpad (pull out Ghost). It has also LED support when active=ON or not=OFF.
Version1.0
AuthorCallisto
Publish DateTue, 12 Jul 2016 - 08:27
Last UpdateTue, 12 Jul 2016 - 08:27
Downloads533
RATE


0

0

Release Notes: 1.0 Tested and running on PS4 with XIM4 and Logitech G13 KB with G502 Mouse.
Code: Select all
define XIM4_MIN_VAL = 20;
 
// The force needed is different when ADS or hip firing
define ANTIRECOIL_FORCE = 11;
 
define RAPIDFIRE_BUTTON = PS4_R2;
 
define RATE_OF_FIRE = 15;   // 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;
int Enabled;
 
init {
    Enabled = TRUE;
    block_rumble();
    rsf = 10000 / (100 - XIM4_MIN_VAL);
 
    hold_time = 500 / RATE_OF_FIRE;
    rest_time = hold_time - 20;
    if(rest_time < 0) rest_time = 0;
    }
 
main {
    if (event_press(PS4_TOUCH)) { Enabled = TRUE; }
    if (event_press(PS4_TRIANGLE)) { Enabled = FALSE; }
    if (Enabled) {
        set_led(LED_1,1);
        } else set_led(LED_1,0);
 
    if(get_val(PS4_R2)) {
        // 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);
    }
 
    if ((get_val(RAPIDFIRE_BUTTON) > 0)  && (Enabled)) {
        combo_run(RapidFire);
        } else 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);
}