Self loading anti-recoil!

GPC2 script programming for Titan Two. Code examples, questions, requests.

Re: Self loading anti-recoil!

Postby bonefisher » Sun Apr 14, 2019 1:36 pm

Really liking this also :innocent_smile_1: but the pain in the butt game is BO4 which uses both FFB_1 and 2 so its a pain so I'm still tinkering getting that one! Still could right now run most of my guns though... :smile0517:
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Self loading anti-recoil!

Postby SweatyPapi » Sun Apr 14, 2019 2:19 pm

This is next level! Trying out tonight!
User avatar
SweatyPapi
Sergeant Major
Sergeant Major
 
Posts: 91
Joined: Fri Feb 08, 2019 12:52 am

Re: Self loading anti-recoil!

Postby TrayDay » Mon Apr 15, 2019 6:19 am

This is truly amazing bonefisher, and I can definitely say, ps4 and Xbox differs in some various inputs. For example, the rapid-fire doesn't work correctly as I had to change the values as we've covered before in another topic. Secondly, FBB_1 is swapped with FBB_2, tested with Apex Legends. But once I changed both the rapid-fire and FBB, all works accordingly. Being able to not have to swap various recoils is amazing. Literally won my next game, after setting it all up. This is next level, T2 boys!
User avatar
TrayDay
First Sergeant
First Sergeant
 
Posts: 60
Joined: Wed Nov 02, 2016 11:12 pm

Re: Self loading anti-recoil!

Postby bonefisher » Mon Apr 15, 2019 6:32 am

Yes I figured PS4 and Xbox differ but I glad this is working for both even though little time setting up but worth it for sure just to pick up a weapon and it is set already.... oh yeah!!!!!!! :smile0517:
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Self loading anti-recoil!

Postby Mochi » Mon Apr 15, 2019 7:46 am

TrayDay wrote:This is truly amazing bonefisher, and I can definitely say, ps4 and Xbox differs in some various inputs. For example, the rapid-fire doesn't work correctly as I had to change the values as we've covered before in another topic. Secondly, FBB_1 is swapped with FBB_2, tested with Apex Legends. But once I changed both the rapid-fire and FBB, all works accordingly. Being able to not have to swap various recoils is amazing. Literally won my next game, after setting it all up. This is next level, T2 boys!


So as PS4 users, do we need to look at FBB_2 or 1?
User avatar
Mochi
Sergeant First Class
Sergeant First Class
 
Posts: 24
Joined: Wed Mar 20, 2019 8:02 am

Re: Self loading anti-recoil!

Postby TrayDay » Mon Apr 15, 2019 9:25 am

Mochi wrote:
TrayDay wrote:This is truly amazing bonefisher, and I can definitely say, ps4 and Xbox differs in some various inputs. For example, the rapid-fire doesn't work correctly as I had to change the values as we've covered before in another topic. Secondly, FBB_1 is swapped with FBB_2, tested with Apex Legends. But once I changed both the rapid-fire and FBB, all works accordingly. Being able to not have to swap various recoils is amazing. Literally won my next game, after setting it all up. This is next level, T2 boys!


So as PS4 users, do we need to look at FBB_2 or 1?


This is what I did for PS4

Code: Select all
#pragma METAINFO("APEX LEGENDS rumble anti recoil", 1, 0, "bonefisher")
 
#define float  fix32
#define wait(a)  wait((int)a);
//Anti Recoil
bool bUseAntiRecoil = 1;
uint16 ARecoilDelay = 0;
float MinARecoilPercent = 20.0;
float StickNoise = 13.00;
 
main {
  //////////////////////////////////////////////////////////////////////////
    //Anti Recoil
    //////////////////////////////////////////////////////////////////////////
    if (bUseAntiRecoil)
    {
        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(ffb_get(FFB_2, NULL) > 25.0 && ffb_get(FFB_2, NULL) < 35.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 60.0);
        }
        if(ffb_get(FFB_2, NULL) > 35.0 && ffb_get(FFB_2, NULL) < 45.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 45.0);
        }
        if(ffb_get(FFB_2, NULL) > 50.0 && ffb_get(FFB_2, NULL) < 70.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 55.0);
        }
        if(ffb_get(FFB_2, NULL) > 39.0 && ffb_get(FFB_2, NULL) < 40.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 32.0);
        }
        }
    }
}
 
main{
if(get_actual(BUTTON_5))combo_run(RapidFire);
}
combo RapidFire
{
wait(30);
set_val(BUTTON_5, 0);
wait(30);
}
 
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,clamp(MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply),-100.00,100.00 - MinARecoilToApply));
}
 
 
User avatar
TrayDay
First Sergeant
First Sergeant
 
Posts: 60
Joined: Wed Nov 02, 2016 11:12 pm

Re: Self loading anti-recoil!

Postby jelly44 » Mon Apr 15, 2019 9:58 am

Thank you for sharing it, TrayDay.

So just to see if I understand the beauty / logic of the script.

Each gun has a given FFB, that can be either 1 or 2 depending on the game, right? Or does the value varies per platform (PC, PS$, XB1) ? (Battlefield 5 gives values under 1 and 2, so I'm not sure what to do there.)

Is the value for STICK_1_X the vertical recoil and STICK_1_Y horizontal?
- My recommendation for learning C programming: 'C Programming Absolute Beginner's Guide'
- Create your own scripts with GPC2 Scripting
User avatar
jelly44
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 220
Joined: Tue Feb 05, 2019 3:49 pm

Re: Self loading anti-recoil!

Postby TrayDay » Mon Apr 15, 2019 10:14 am

jelly44 wrote:Thank you for sharing it, TrayDay.

So just to see if I understand the beauty / logic of the script.

Each gun has a given FFB, that can be either 1 or 2 depending on the game, right? Or does the value varies per platform (PC, PS$, XB1) ? (Battlefield 5 gives values under 1 and 2, so I'm not sure what to do there.)

Is the value for STICK_1_X the vertical recoil and STICK_1_Y horizontal?

Correct, each gun have a distinct FBB, and when you check the gtuner you'll see the value of FBB_2 change when you shoot, FBB_1 will be 100 and FBB_2 will be the gun as each will vary, but you get a general idea of what the value is by hold R2/RT. While this also may depend on the controller you're using as well. But once you see the value, basically the way bonefisher have the script is any FBB values between > ...... < will be detected, the script will then use the Stick Value as you have correctly, STICK_1_X the vertical recoil and STICK_1_Y horizontal, it will be triggered. Also, you're right, I believe that's the next script bonefisher is working on, as he understands that dearly. As there's a gun in Apex that also uses both values, so I'm also interested as well.

EDIT: Also in the script I posted, I forgot to change the first value of the function, here are the correct values for them

Code: Select all
#pragma METAINFO("APEX LEGENDS rumble anti recoil", 1, 0, "bonefisher")
 
#define float  fix32
#define wait(a)  wait((int)a);
//Anti Recoil
bool bUseAntiRecoil = 1;
uint16 ARecoilDelay = 0;
float MinARecoilPercent = 20.0;
float StickNoise = 13.00;
 
main {
  //////////////////////////////////////////////////////////////////////////
    //Anti Recoil
    //////////////////////////////////////////////////////////////////////////
    if (bUseAntiRecoil)
    {
        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(ffb_get(FFB_2, NULL) > 25.0 && ffb_get(FFB_2, NULL) < 34.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 60.0);
        }
        if(ffb_get(FFB_2, NULL) > 35.0 && ffb_get(FFB_2, NULL) < 45.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 45.0);
        }
        if(ffb_get(FFB_2, NULL) > 50.0 && ffb_get(FFB_2, NULL) < 70.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 55.0);
        }
        if(ffb_get(FFB_2, NULL) > 39.0 && ffb_get(FFB_2, NULL) < 40.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 32.0);
        }
        }
    }
}
 
main{
if(get_actual(BUTTON_5))combo_run(RapidFire);
}
combo RapidFire
{
wait(30);
set_val(BUTTON_5, 0);
wait(30);
}
 
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,clamp(MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply),-100.00,100.00 - MinARecoilToApply));
}
 
 
User avatar
TrayDay
First Sergeant
First Sergeant
 
Posts: 60
Joined: Wed Nov 02, 2016 11:12 pm

Re: Self loading anti-recoil!

Postby jelly44 » Mon Apr 15, 2019 10:58 am

TrayDay wrote:
jelly44 wrote:Thank you for sharing it, TrayDay.

So just to see if I understand the beauty / logic of the script.

Each gun has a given FFB, that can be either 1 or 2 depending on the game, right? Or does the value varies per platform (PC, PS$, XB1) ? (Battlefield 5 gives values under 1 and 2, so I'm not sure what to do there.)

Is the value for STICK_1_X the vertical recoil and STICK_1_Y horizontal?

Correct, each gun have a distinct FBB, and when you check the gtuner you'll see the value of FBB_2 change when you shoot, FBB_1 will be 100 and FBB_2 will be the gun as each will vary, but you get a general idea of what the value is by hold R2/RT. While this also may depend on the controller you're using as well. But once you see the value, basically the way bonefisher have the script is any FBB values between > ...... < will be detected, the script will then use the Stick Value as you have correctly, STICK_1_X the vertical recoil and STICK_1_Y horizontal, it will be triggered. Also, you're right, I believe that's the next script bonefisher is working on, as he understands that dearly. As there's a gun in Apex that also uses both values, so I'm also interested as well.

EDIT: Also in the script I posted, I forgot to change the first value of the function, here are the correct values for them

Code: Select all
#pragma METAINFO("APEX LEGENDS rumble anti recoil", 1, 0, "bonefisher")
 
#define float  fix32
#define wait(a)  wait((int)a);
//Anti Recoil
bool bUseAntiRecoil = 1;
uint16 ARecoilDelay = 0;
float MinARecoilPercent = 20.0;
float StickNoise = 13.00;
 
main {
  //////////////////////////////////////////////////////////////////////////
    //Anti Recoil
    //////////////////////////////////////////////////////////////////////////
    if (bUseAntiRecoil)
    {
        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(ffb_get(FFB_2, NULL) > 25.0 && ffb_get(FFB_2, NULL) < 34.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 60.0);
        }
        if(ffb_get(FFB_2, NULL) > 35.0 && ffb_get(FFB_2, NULL) < 45.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 45.0);
        }
        if(ffb_get(FFB_2, NULL) > 50.0 && ffb_get(FFB_2, NULL) < 70.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 55.0);
        }
        if(ffb_get(FFB_2, NULL) > 39.0 && ffb_get(FFB_2, NULL) < 40.0)
        {
            if(get_actual(BUTTON_5))combo_run(RapidFire);
            AntiRecoil(STICK_1_X, 0.0);
            AntiRecoil(STICK_1_Y, 32.0);
        }
        }
    }
}
 
main{
if(get_actual(BUTTON_5))combo_run(RapidFire);
}
combo RapidFire
{
wait(30);
set_val(BUTTON_5, 0);
wait(30);
}
 
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,clamp(MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply),-100.00,100.00 - MinARecoilToApply));
}
 
 


:smile0517: amazing - thank you!
- My recommendation for learning C programming: 'C Programming Absolute Beginner's Guide'
- Create your own scripts with GPC2 Scripting
User avatar
jelly44
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 220
Joined: Tue Feb 05, 2019 3:49 pm

Re: Self loading anti-recoil!

Postby undazpoon » Mon Apr 15, 2019 12:00 pm

Does anyone know why My Gtuner just crash when I compile this script?
User avatar
undazpoon
Sergeant First Class
Sergeant First Class
 
Posts: 19
Joined: Fri Nov 18, 2016 2:52 am

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 98 guests

cron