Page 1 of 1

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

PostPosted: Wed Feb 13, 2019 8:41 pm
by USER101
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);   
}

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

PostPosted: Wed Feb 13, 2019 8:50 pm
by USER101
Anyone have examples of adjustable recoil with deadzone compensation? Thanks.

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

PostPosted: Wed Feb 13, 2019 10:44 pm
by Sillyasskid
quick question why is the Y axis negative in the combo? It should be positive to counteract the recoil :unsure:

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

PostPosted: Thu Feb 14, 2019 12:14 am
by bonefisher
Might be a inverted player :smile0208:

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

PostPosted: Thu Feb 14, 2019 12:30 am
by bonefisher
Code: Select all
 
/* Special credits goes out to AryanX for a awesome anti-recoil script!*/
#define float  fix32
//Anti Recoil
float ARecoil_H  =  0.0;// Change horizontal force add negative if needed.
float ARecoil_V  = 20.0;//Change vertical pull force
uint16 ARecoilDelay = 0;//Change delay after trigger is pulled to engage anti-recoil.
 
//Percent of anti ARecoil to always apply regardless of aim movement
float 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));
}