define FIRE_BTN = XB1_RT;
define ADS_BTN = XB1_LT;
define SPRINT_BTN = XB1_LS;
define DPAD_UP = XB1_UP;
define DPAD_DOWN = XB1_DOWN;
define DPAD_RIGHT = XB1_RIGHT;
define LED_R = 0;
define LED_G = 1;
define LED_B = 2;
int recoil_v[4] = {26, 23, 20, 28};
int recoil_h[4] = {0, 1, -1, 0};
int current_profile = 0;
int aim_assist = TRUE;
int assist_toggle_delay = 0;
int rapid_fire = TRUE;
int fire_delay = 25;
int auto_sprint = TRUE;
int switch_delay = 0;
int rapid_fire_timer = 0;
int aim_assist_timer = 0;
int aim_assist_direction = 1;
int ry, rx;
init {
set_led(LED_B, 3); // Start with Blue for profile 0
}
function update_led() {
if(current_profile == 0) set_led(LED_B, 3);
else if(current_profile == 1) set_led(LED_G, 3);
else if(current_profile == 2) set_led(LED_R, 3);
else set_led(LED_R, 2); // Dim red for profile 3 (orange-ish)
}
main {
// Profile switch up/down
if(event_press(DPAD_UP) && switch_delay == 0) {
current_profile = (current_profile + 1) % 4;
switch_delay = 20;
update_led();
}
if(event_press(DPAD_DOWN) && switch_delay == 0) {
current_profile = (current_profile - 1 + 4) % 4;
switch_delay = 20;
update_led();
}
if(switch_delay > 0) switch_delay--;
// Toggle Aim Assist on D-Pad Right
if(event_press(DPAD_RIGHT) && assist_toggle_delay == 0) {
aim_assist = !aim_assist;
assist_toggle_delay = 20;
set_led(LED_G, 3); // Flash green to show toggle
}
if(assist_toggle_delay > 1) assist_toggle_delay--;
else if(assist_toggle_delay == 1) {
update_led();
assist_toggle_delay--;
}
// Auto sprint forward if not aiming
if(auto_sprint && get_val(XB1_LY) > 95 && !get_val(ADS_BTN)) {
set_val(SPRINT_BTN, 100);
}
// Rapid fire on right trigger
if(rapid_fire && get_val(FIRE_BTN)) {
if(rapid_fire_timer == 0) {
set_val(FIRE_BTN, 100);
rapid_fire_timer = fire_delay;
} else if(rapid_fire_timer == fire_delay / 2) {
set_val(FIRE_BTN, 0);
}
} else {
set_val(FIRE_BTN, 0);
rapid_fire_timer = 0;
}
if(rapid_fire_timer > 0) rapid_fire_timer--;
// Anti-recoil while aiming and firing
if(get_val(ADS_BTN) && get_val(FIRE_BTN)) {
ry = get_val(XB1_RY) + recoil_v[current_profile];
ry = ry > 100 ? 100 : (ry < -100 ? -100 : ry);
set_val(XB1_RY, ry);
rx = get_val(XB1_RX) + recoil_h[current_profile];
rx = rx > 100 ? 100 : (rx < -100 ? -100 : rx);
set_val(XB1_RX, rx);
}
// Aim assist side-to-side when aiming
if(aim_assist && get_val(ADS_BTN)) {
if(aim_assist_timer == 0) {
set_val(XB1_RX, 12 * aim_assist_direction);