What anti recoil is used in Alan Mcgregors script

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

Re: What anti recoil is used in Alan Mcgregors script

Postby Beryl » Sat Jan 09, 2021 5:38 am

Thats fantastic thankyou, now iv got a base anti recoil script i feel i can add to, is there any good tutorials of how to make scripts? Iv got a few ideas of stuff. Thanks again!
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: What anti recoil is used in Alan Mcgregors script

Postby Mad » Sat Jan 09, 2021 6:52 am

Beryl wrote:Thats fantastic thankyou, now iv got a base anti recoil script i feel i can add to, is there any good tutorials of how to make scripts? Iv got a few ideas of stuff. Thanks again!

No problem. https://www.consoletuner.com/wiki/index ... _scripting
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: What anti recoil is used in Alan Mcgregors script

Postby Beryl » Sat Jan 09, 2021 12:16 pm

Thanks very much you've been more than helpful!
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: What anti recoil is used in Alan Mcgregors script

Postby Beryl » Fri Feb 05, 2021 8:16 am

Mad wrote:
Beryl wrote:Just had a play around with it, certainly works but only issue i can see is theres no way to add a delay before recoil kicks in? Guns in Pubg iv found require this. Maybe iv overlooked it in the code but is there 1 in there i cant see anything?

Code: Select all
#define RECOIL_V  17.0  // Vertical compensation   
#define RECOIL_H  0.0   // Horizontal compensation
#define sn        13.00       // COD/BF = 13 R6 = 19 (SN + COMP = ACTUAL RECOIL VALUE)
#define delay     250 // delay before anti recoil kicks in
main {
    if(is_active(BUTTON_8)) if(check_active(BUTTON_5, delay)) {
        AntiRecoil(STICK_1_Y,STICK_1_X, RECOIL_V,RECOIL_H);
    }
}
 
void AntiRecoil (uint8 axis1,uint8 axis2,fix32 recoil_Y,fix32 recoil_X)
{
    if ((recoil_Y != 0.0) || (recoil_X != 0.0))
    {
        fix32 RY;
        fix32 RX;
 
        fix32 true_RY;
        fix32 true_RX;
 
        fix32 altrecoil_Y;
        fix32 altrecoil_X;
 
        fix32 modified_RY;
        fix32 modified_RX;
 
        fix32 final_RY;
        fix32 final_RX;
 
        fix32 true_radius;
        fix32 modi_radius;
 
        fix32 modi_recoil;
 
        RY = clamp(get_actual(axis1), -100.0, 100.0);
        RX = clamp(get_actual(axis2), -100.0, 100.0);
 
        if ( RX*RX+RY*RY <= sn*sn )
        {
            modi_recoil = sqrt(recoil_Y*recoil_Y+recoil_X*recoil_X);
            set_val(axis1,recoil_Y /modi_recoil*(modi_recoil+sn));
            set_val(axis2,recoil_X /modi_recoil*(modi_recoil+sn));
        }   
 
        if (RX*RX+RY*RY > sn*sn)
        {
 
            true_radius = clamp(sqrt(RY*RY+RX*RX),0.0,100.0);
 
            true_RY = (true_radius-sn)/true_radius*RY;
            true_RX = (true_radius-sn)/true_radius*RX;
 
            altrecoil_Y = recoil_Y - recoil_Y*0.80/(100.0-sn)*true_radius;
            altrecoil_X = recoil_X - recoil_X*0.80/(100.0-sn)*true_radius;
 
            modified_RY = true_RY + altrecoil_Y - altrecoil_Y/(100.0-sn)*abs(true_RY);
            modified_RX = true_RX + altrecoil_X - altrecoil_X/(100.0-sn)*abs(true_RX);
 
            modi_radius = sqrt(modified_RY*modified_RY + modified_RX*modified_RX);
 
            final_RY = modified_RY / modi_radius * (modi_radius+sn);
            final_RX = modified_RX / modi_radius * (modi_radius+sn);
 
            set_val(axis1,clamp(final_RY, -100f, 100f));
            set_val(axis2,clamp(final_RX, -100f, 100f));
        }
    }
}



Hi this anti recoil is great btw, but my question is as most guns in pubg seem to pull left how can i compensate for this with the horizontal figures? How does it work?
If i added say 1.0 to the horizontal figurea does that pull it to the left,right? Im confused sorry i hope this makes sense
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: What anti recoil is used in Alan Mcgregors script

Postby Mad » Fri Feb 05, 2021 8:47 am

Beryl wrote:Hi this anti recoil is great btw, but my question is as most guns in pubg seem to pull left how can i compensate for this with the horizontal figures? How does it work?
If i added say 1.0 to the horizontal figurea does that pull it to the left,right? Im confused sorry i hope this makes sense

Negative value for left, positive for right.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: What anti recoil is used in Alan Mcgregors script

Postby Convivium » Sun Feb 21, 2021 7:39 pm

Will this work the same if I have vibration disabled on the controller and in-game?

How about if I remove the 'if'' conditional containing the ffb and the ffb definitions, will it work as intended.

I know it will compile, I guess what I am asking is, is there any advantage to using the ffb over disabling it?
User avatar
Convivium
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Wed Mar 27, 2019 2:45 am
Location: Clemson, SC

Re: What anti recoil is used in Alan Mcgregors script

Postby Beryl » Tue Apr 13, 2021 1:05 pm

So if i change this bit thats the left and right recoil control?

if ((recoil_Y != 0.0) || (recoil_X != 0.0))
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: What anti recoil is used in Alan Mcgregors script

Postby Mad » Tue Apr 13, 2021 9:03 pm

No, you can adjust the values at the very top:
Code: Select all
#define RECOIL_V  17.0  // Vertical compensation   
#define RECOIL_H  0.0   // Horizontal compensation
#define sn        13.00       // COD/BF = 13 R6 = 19 (SN + COMP = ACTUAL RECOIL VALUE)
#define delay     250 // delay before anti recoil kicks in
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: What anti recoil is used in Alan Mcgregors script

Postby Beryl » Thu Apr 15, 2021 1:16 am

Gotcha! So positive figure in H will pull it one way negative the other?
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Previous

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 128 guests