//M4 Anti Recoil Script
/* *
* ANTI-RECOIL GPC SCRIPT
* *********************************************************** */
// Use Anti-recoil only when scoping
define ONLY_WITH_SCOPE = TRUE;
define SPOT_BUTTON = XB1_RB;int autospot = FALSE;
define SENS_INCREASE_BY = 20;
define RATE_OF_FIRE = 9.9;
define SELECT = XB1_A;
// Anti-recoil strongness
// Value range from 0 to 100
// Each weapon may need a specific value
define ANTI_RECOIL = 25;
define RAPIDFIRE_BUTTON = XB1_RT;
define START = XB1_LT;
//
// No need to make changes in the code below.
//
//
// VARIABLES
// ---------------------------------------------------------
int fire_button, scope_button;
int anti_recoil;
int rpgcount =FALSE;
int rapidfire = TRUE;
int rapid_onoff = TRUE;
int hold_time, rest_time;
//
// INITIALIZATION
// ---------------------------------------------------------
init {
if( event_press(CEMU_EXTRA1)){ // PS3 Trigger & Bumper
fire_button = 3;
scope_button = 6;
hold_time = 500 / RATE_OF_FIRE;
rest_time = hold_time - 20;
if(rest_time < 0) rest_time = 0;
} else { // Natural Trigger & Bumper
fire_button = 4;
scope_button = 7;
hold_time = 500 / RATE_OF_FIRE;
rest_time = hold_time - 20;
if(rest_time < 0) rest_time = 0;
}
}
//
// MAIN PROCEDURE
// ---------------------------------------------------------
main {
if(!ONLY_WITH_SCOPE || get_val(scope_button)) {
combo_run(AntiRecoil);
}
if(get_val(SELECT) && event_press(START)) rapid_onoff = !rapid_onoff; //sets variable to TRUE or FALSE when both buttons are pressed.
if(get_val(RAPIDFIRE_BUTTON) && rapid_onoff) { //Now Looks for a "TRUE" value of rapid_onoff
combo_run(RapidFire);
} else if(combo_running(RapidFire)) {
combo_stop(RapidFire);
}
if(event_release(SPOT_BUTTON) && get_ptime(SPOT_BUTTON) < 140)
autospot = !autospot;
if(autospot && !get_val(SPOT_BUTTON))
combo_run(AutoSpot);block(SPOT_BUTTON, 200);}
combo AutoSpot {
set_val(SPOT_BUTTON, 100);
wait(40);
set_val(SPOT_BUTTON, 0);
wait(200);
if(get_val(XB1_LT))
combo_run(HoldBreath);
if(get_val(XB1_LEFT))
rpgcount = TRUE;
if( rpgcount == TRUE && get_val(XB1_RT))
combo_run(RPG);
}
combo HoldBreath{
wait(50);
set_val(XB1_LS, 100);
wait(3000);
set_val(XB1_LS, 0);
}
//
// COMBOS
// ---------------------------------------------------------
combo RapidFire {
set_val(RAPIDFIRE_BUTTON, 100);
wait(hold_time);
set_val(RAPIDFIRE_BUTTON, 0);
wait(rest_time);
set_val(RAPIDFIRE_BUTTON, 0);
}
combo RPG {
wait(3250);
set_val(XB1_RIGHT, 100);
wait(120);
set_val(XB1_RIGHT, 0);
wait(110);
set_val(XB1_LEFT, 100);
wait(110);
set_val(XB1_LEFT, 0);
rpgcount = FALSE;
}
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);
}
//Rapidfire
}