Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define sn 7.0 // Change deadzone value
- #define ar 16.0 // Change anti-recoil value
- #define RecoilDelay 20 // delay in ms
- #define float fix32
- // Rapidfire values
- #define RF_HOLD 40
- #define RF_RELEASE 90
- #define RY get_actual(22)
- #define RX get_actual(21)
- bool rapidfire;
- init {
- led(255,0,0);
- }
- main {
- if (get_actual(4) && is_active(7) && time_active(4) >= RecoilDelay) AntiRecoil(ar);
- }
- void AntiRecoil (fix32 recoil) {
- if (abs(get_actual(STICK_1_X)) < sn) set_val(STICK_1_X, 0.0);
- if (abs(get_actual(STICK_1_Y)) < sn) set_val(STICK_1_Y, 0.0);
- fix32 modifiedRY;
- fix32 trueRY = (sqrt(RY*RY+RX*RX)-sn)/sqrt(RY*RY+RX*RX)*RY;
- fix32 trueRX = (sqrt(RY*RY+RX*RX)-sn)/sqrt(RY*RY+RX*RX)*RX;
- if (RY > 0.0) modifiedRY = (100.0-sn-recoil)/(100.0-sn)*trueRY + recoil;
- if (RY < 0.0) modifiedRY = (100.0-sn+recoil)/(100.0-sn)*trueRY + recoil;
- fix32 altradius = sqrt(trueRX*trueRX + modifiedRY*modifiedRY);
- fix32 finalRX = trueRX * (altradius + sn)/altradius;
- fix32 finalRY = modifiedRY * (altradius + sn)/altradius;
- if (RX*RX+RY*RY <= sn*sn) set_val(22,(sn+recoil));
- if (RX*RX+RY*RY > sn*sn) {
- set_val(22,clamp(finalRY, -100f, 100f));
- set_val(21,clamp(finalRX, -100f, 100f));
- }
- }
- bool run_flag;
- main
- {
- }
- combo run
- {
- set_val(BUTTON_9, 0.0);
- wait(200);
- set_val(BUTTON_9, 100.0);
- wait(400);
- set_val(BUTTON_9, 0.0);
- }
- bool toggle;
- main {
- // ADS + DPAD UP to toggle rapidfire
- if (is_active(7) && event_active(9)) {
- rapidfire = !rapidfire;
- if(rapidfire) led(0,255,0);
- else led(255,0,0);
- }
- if(get_actual(4) && rapidfire) combo_run(RapidFire);
- }
- combo RapidFire {
- set_val(4, 100);
- wait(RF_HOLD);
- set_val(4, 0);
- wait(RF_RELEASE);
- }
- void led(int8 r, int8 g, int8 b) {
- led_set(LED_1, (fix32)b, 0);
- led_set(LED_2, (fix32)r, 0);
- led_set(LED_3, (fix32)g, 0);
- return;
- }
Add Comment
Please, Sign In to add comment