## This Is NOT How Anti-Recoil Works?!?!

GPC script programming for Titan Two device. Code examples, how to, questions, requests.

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

### This Is NOT How Anti-Recoil Works?!?!

So...
I must have grossly misjudged the complexities of anti-recoil. Here I was able to counter almost every recoil movement of a weapon in BO4 and when I am aiming down the sights and shooting at a wall far off there is almost no movement for a weapon that normally jumps around like crazy. However, when I actually tried to play /lul .. I can not aim manually in any direction while firing. I saw the anti recoil example but must not completely understand it or how I could accomplish this the right way. I made this by recording the shot pattern at 60fps to get the timing then created a counter move every time the weapon decided to shift its shot group. I planned on doing this for each class until I ran out of bytecode space but... I am starting to see why simple adjustable counter movement might be better.

Code: Select all
`#define StickNoise 3.49  main {    if (get_val(BUTTON_5) && get_val(BUTTON_8)) {    if(get_actual(STICK_1_X) < StickNoise) { combo_run(Stick_X);}    if(get_actual(STICK_1_Y) < StickNoise) { combo_run(Stick_Y);}}combo Stick_X{    wait(30);    set_val(STICK_1_X, -3);    wait(100);    set_val(STICK_1_X, -10);    wait(100);    set_val(STICK_1_X, 0);        wait(180);    set_val(STICK_1_X, -18);    wait(100);    set_val(STICK_1_X, 0);    wait(640);    set_val(STICK_1_X, -15);    wait(80);    set_val(STICK_1_X, 8);        wait(290);    set_val(STICK_1_X, 0);    wait(130);    set_val(STICK_1_X, -8);        wait(620);    set_val(STICK_1_X, 0);}combo Stick_Y{    wait(130);    set_val(STICK_1_Y, -38);    wait(100);    set_val(STICK_1_Y, 0);    wait(130);    set_val(STICK_1_Y, -38);    wait(100);    set_val(STICK_1_Y, 0);            wait(800);    set_val(STICK_1_Y, -28);    wait(1000);    set_val(STICK_1_Y, -38);    wait(130);    set_val(STICK_1_Y, 0);    }`

USER101
Sergeant Major

Posts: 96
Joined: Mon Dec 03, 2018 5:45 pm

### Re: This Is NOT How Anti-Recoil Works?!?!

USER101
Sergeant Major

Posts: 96
Joined: Mon Dec 03, 2018 5:45 pm

### Re: This Is NOT How Anti-Recoil Works?!?!

quick question why is the Y axis negative in the combo? It should be positive to counteract the recoil

Sillyasskid
Captain

Posts: 575
Joined: Sat May 14, 2016 3:07 am

### Re: This Is NOT How Anti-Recoil Works?!?!

Might be a inverted player
bonefisher
Major General

Posts: 5056
Joined: Thu Jan 29, 2015 10:49 am

### Re: This Is NOT How Anti-Recoil Works?!?!

Code: Select all
` /* Special credits goes out to AryanX for a awesome anti-recoil script!*/#define float  fix32//Anti Recoilfloat ARecoil_H  =  0.0;// Change horizontal force add negative if needed.float ARecoil_V  = 20.0;//Change vertical pull forceuint16 ARecoilDelay = 0;//Change delay after trigger is pulled to engage anti-recoil. //Percent of anti ARecoil to always apply regardless of aim movementfloat MinARecoilPercent = 18.0; float StickNoise = 6.32; main {  //////////////////////////////////////////////////////////////////////////    //Anti Recoil    //////////////////////////////////////////////////////////////////////////     if (get_actual(BUTTON_5) && time_active(BUTTON_5) >= ARecoilDelay)    {         if (abs(get_actual(STICK_1_X)) < StickNoise) set_val(STICK_1_X, 0.0);        if (abs(get_actual(STICK_1_Y)) < StickNoise) set_val(STICK_1_Y, 0.0);        if (abs(get_actual(STICK_2_X)) < StickNoise) set_val(STICK_2_X, 0.0);        if (abs(get_actual(STICK_2_Y)) < StickNoise) set_val(STICK_2_Y, 0.0);     if (get_val(BUTTON_5))    {        AntiRecoil(STICK_1_X, ARecoil_H);        AntiRecoil(STICK_1_Y, ARecoil_V);    }    }} void AntiRecoil(uint8 AxisToApply, float ARecoilToApply){    float CurrentX = get_val(STICK_1_X);    float CurrentY = get_val(STICK_1_Y);    float MinARecoilFactor = MinARecoilPercent / 100.0;    float MinARecoilToApply = MinARecoilFactor * ARecoilToApply;    //This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y     float MovementARecoilToApply = (1.0 - MinARecoilFactor) * ((ARecoilToApply * (100.0 - sqrt(CurrentX*CurrentX + CurrentY*CurrentY))) / (100.0 + abs(CurrentX) + (CurrentY*CurrentY*0.5)));    set_val(AxisToApply, MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply));} `
bonefisher
Major General

Posts: 5056
Joined: Thu Jan 29, 2015 10:49 am