DrNefario's antirecoil demo
23 posts
• Page 2 of 3 • 1, 2, 3
Hi Nefario, good to see your active again!
This anti recoil is really good with Xim. works perfectly in Rainbow Six Siegie! really well done! Is it possible to see the source code so I could implement it in my R6 Script (https://www.consoletuner.com/greslib/?w1163). Last thing, Are you active in the Consoletuner Discord?
Thanks man!
Edit: for people that want to try this in Rainbow Six, make sure you put the deadzone on 19.0 (PS4).
Fun fact, I am using your older open source anti recoil code with only vertical in my siege script!
This anti recoil is really good with Xim. works perfectly in Rainbow Six Siegie! really well done! Is it possible to see the source code so I could implement it in my R6 Script (https://www.consoletuner.com/greslib/?w1163). Last thing, Are you active in the Consoletuner Discord?
Thanks man!
Edit: for people that want to try this in Rainbow Six, make sure you put the deadzone on 19.0 (PS4).
Fun fact, I am using your older open source anti recoil code with only vertical in my siege script!
-
Intervirus - Sergeant
- Posts: 9
- Joined: Fri Aug 07, 2020 10:36 am
Re: DrNefario's antirecoil demo
Sure, why not. I understand it might look a bit scary, but the math behind this is actually very simple.
To anyone who wants to use this code, you are free to do so, if you could give me some credit I will be really appreciated.
Based on my testing, the algorithm is good enough, but still not in perfect condition. I am still trying to make some improvements but I have been really busy lately. Thank you for your support, glad you like my code.
For your last question, yes i joined discord, but i am not currently really active.
My goal is to find the perfect anti recoil solution, if anyone interested about it, feel free to message me and discuss with me about it, i am looking forward to it. XD
- Code: Select all
fix32 RECOIL_V = 0.0;
fix32 RECOIL_H = 0.0;
fix32 sn = 13.0;
main {
if (get_val (BUTTON_5) && get_val (BUTTON_8) )
{
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));
}
}
}
To anyone who wants to use this code, you are free to do so, if you could give me some credit I will be really appreciated.
Based on my testing, the algorithm is good enough, but still not in perfect condition. I am still trying to make some improvements but I have been really busy lately. Thank you for your support, glad you like my code.
For your last question, yes i joined discord, but i am not currently really active.
My goal is to find the perfect anti recoil solution, if anyone interested about it, feel free to message me and discuss with me about it, i am looking forward to it. XD
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
Re: DrNefario's antirecoil demo
Nice work, Thank you for sharing with us DrNefario.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
- Mad
- Major General
- Posts: 4532
- Joined: Wed May 22, 2019 5:39 am
Re: DrNefario's antirecoil demo
Great script Dr. Nefario - I was using your prior script before switching to the mxyconverter functions and your scrips worked smoothly!
- My recommendation for learning C programming: 'C Programming Absolute Beginner's Guide'
- Create your own scripts with GPC2 Scripting
- Create your own scripts with GPC2 Scripting
-
jelly44 - Sergeant Major of the Army
- Posts: 220
- Joined: Tue Feb 05, 2019 3:49 pm
Re: DrNefario's antirecoil demo
DrNefario wrote:Sure, why not. I understand it might look a bit scary, but the math behind this is actually very simple.
- Code: Select all
fix32 RECOIL_V = 0.0;
fix32 RECOIL_H = 0.0;
fix32 sn = 13.0;
main {
if (get_val (BUTTON_5) && get_val (BUTTON_8) )
{
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));
}
}
}
To anyone who wants to use this code, you are free to do so, if you could give me some credit I will be really appreciated.
Based on my testing, the algorithm is good enough, but still not in perfect condition. I am still trying to make some improvements but I have been really busy lately. Thank you for your support, glad you like my code.
For your last question, yes i joined discord, but i am not currently really active.
My goal is to find the perfect anti recoil solution, if anyone interested about it, feel free to message me and discuss with me about it, i am looking forward to it. XD
No doubt I will credit you for your amazing work. I have been asking around for months in the T2 discord for you... lol. Your anti recoil is really good and so smooth. You have discord? Always happy to talk about this stuff and you should be in the T2 discord nonetheless! Can't thank you enough for this amazing anti recoil. Keep it up this god work and if you need me to test anything you can always hit me up!
Edit: i was so blown away by your AR code I did not read the full message.. I wanna talk about this stuff with you if possible. My discord id: InterVirus#2561. Or do you wanna move this coversation somewhere else?
-
Intervirus - Sergeant
- Posts: 9
- Joined: Fri Aug 07, 2020 10:36 am
Re: DrNefario's antirecoil demo
Great work thanks for sharing
I took some time to clean up your code.
I took some time to clean up your code.
- Code: Select all
const fix32 RECOIL_V = 0.0;
const fix32 RECOIL_H = 0.0;
const fix32 sn = 13.0;
main {
if (is_active(BUTTON_5) && is_active(BUTTON_8))
{
AntiRecoil(STICK_1_Y, STICK_1_X, RECOIL_V, RECOIL_H);
}
}
void AntiRecoil(uint8 axisY, uint8 axisX, fix32 recoil_Y, fix32 recoil_X)
{
if (recoil_Y + recoil_X)
{
fix32 RY = get_actual(axisY);
fix32 RX = get_actual(axisX);
fix32 RXRY = sq(RY) + sq(RX);
fix32 temp;
if (RXRY <= sq(sn))
{
temp = sqrt(sq(recoil_Y) + sq(recoil_X));
set_val(axisY, (recoil_Y / temp) * (temp + sn));
set_val(axisX, (recoil_X / temp) * (temp + sn));
}
else
{
fix32 true_radius = min(sqrt(RXRY), 100.0);
temp = 100.0 - sn;
RY *= ((true_radius - sn) / true_radius);
RX *= ((true_radius - sn) / true_radius);
recoil_Y -= ((recoil_Y * 0.80) / temp) * true_radius;
recoil_X -= ((recoil_X * 0.80) / temp) * true_radius;
RY += recoil_Y - ((recoil_Y / temp) * abs(RY));
RX += recoil_X - ((recoil_X / temp) * abs(RX));
temp = sqrt(sq(RY) + sq(RX));
RY = (RY / temp) * (temp + sn);
RX = (RX / temp) * (temp + sn);
set_val(axisY, clamp(RY, -100f, 100f));
set_val(axisX, clamp(RX, -100f, 100f));
}
}
return;
}
-
DontAtMe - Captain
- Posts: 502
- Joined: Tue Oct 02, 2018 4:49 am
Re: DrNefario's antirecoil demo
Nice work DrNefario. Thank you for sharing with us as well as for publish on Gtuner's Online Resources.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: DrNefario's antirecoil demo
How would this be modified if using Look Inversion?
-
UK_Wildcats - Brigadier General
- Posts: 2243
- Joined: Thu Jan 08, 2015 6:53 pm
Re: DrNefario's antirecoil demo
UK_Wildcats_Fans wrote:How would this be modified if using Look Inversion?
use a negative recoil value
-
DontAtMe - Captain
- Posts: 502
- Joined: Tue Oct 02, 2018 4:49 am
Re: DrNefario's antirecoil demo
UK_Wildcats_Fans wrote:How would this be modified if using Look Inversion?
Yes,just like DontAtMe said, a negative value will be good, as i said in the script, it is a very universal algorithm, the recoil compensation value can be set between -100.0 and 100.
the deadzone setting however, should always be positive.
-
DrNefario - Master Sergeant
- Posts: 35
- Joined: Sun Dec 30, 2018 12:04 pm
23 posts
• Page 2 of 3 • 1, 2, 3
Return to User's Script Documentation
Who is online
Users browsing this forum: No registered users and 116 guests