Antirecoil Script
9 posts
• Page 1 of 1
Antirecoil Script
Anybody know if it’s possible to create a script where you have different anti recoil values one for zooming and one for hip fire?
-
Gorphius - Master Sergeant
- Posts: 26
- Joined: Tue Nov 13, 2018 7:54 pm
Re: Antirecoil Script
The Antirecoil Utility has it.
- Attachments
-
- Untitled-2.jpg (77.55 KiB) Viewed 843 times
-
alanmcgregor - Major
- Posts: 995
- Joined: Tue Mar 27, 2018 8:38 am
Re: Antirecoil Script
Would I be able to use this in the same slot with other code?
-
Gorphius - Master Sergeant
- Posts: 26
- Joined: Tue Nov 13, 2018 7:54 pm
Re: Antirecoil Script
No, is a stand alone script.
If you want a code that can give you two difference antirecoils for HIP and ADS.
Try this:
If you want a code that can give you two difference antirecoils for HIP and ADS.
Try this:
- Code: Select all
#pragma METAINFO("AntiRecoil", 1, 0, "AryanXbonefisher")
/* Special credits goes out to AryanX and Bonefisher*/
// AntiRecoil Float values 0.0
#define StickNoise 6.32
#define MinARecoilPercent 20.0
#define ARecoil_H 0.0
#define ARecoil_V_ADS 20.0
#define ARecoil_V_HIP 10.0
// AntiRecoil Delay
#define ARecoilDelay 50
//Anti Recoil toggle
bool tAntiRecoil = TRUE;
main {
if(get_actual(BUTTON_8)){ // ANTIRECOIL ON/OFF: HOLD L2/LT, PRESS Ps/XB1, RELEASE L2/LT
set_val(BUTTON_1, 0.0);
if(event_active(BUTTON_1)) tAntiRecoil = !tAntiRecoil;
}
if (tAntiRecoil){
if (check_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 (is_active(BUTTON_5) && (is_active(BUTTON_8))){ // ADS AntiRecoil
AntiRecoil(STICK_1_X, ARecoil_H);
AntiRecoil(STICK_1_Y, ARecoil_V_ADS);
}
else
if (is_active(BUTTON_5) && (!is_active(BUTTON_8))){ // HIP AntiRecoil
AntiRecoil(STICK_1_X, ARecoil_H);
AntiRecoil(STICK_1_Y, ARecoil_V_HIP);
}
}
}
}
void AntiRecoil(uint8 AxisToApply, fix32 ARecoilToApply){
fix32 CurrentX = get_val(STICK_1_X);
fix32 CurrentY = get_val(STICK_1_Y);
fix32 MinARecoilFactor = MinARecoilPercent / 100.0;
fix32 MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
//This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
fix32 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)));
}
-
alanmcgregor - Major
- Posts: 995
- Joined: Tue Mar 27, 2018 8:38 am
Re: Antirecoil Script
Awesome! Man seriously thanks for all your help lately!
-
Gorphius - Master Sergeant
- Posts: 26
- Joined: Tue Nov 13, 2018 7:54 pm
Re: Antirecoil Script
No problem
This is the same but also allows to set different antirecoil horizontal for both HIP and ADS fire.
This is the same but also allows to set different antirecoil horizontal for both HIP and ADS fire.
- Code: Select all
#pragma METAINFO("AntiRecoil", 1, 0, "AryanXbonefisher")
/* Special credits goes out to AryanX and Bonefisher*/
// AntiRecoil Float values 0.0
#define StickNoise 6.32 //<--- Stick max rest value
#define MinARecoilPercent 20.0 //<--- Percent of AntiRecoil apply while aiming
// Horizontal AntiRecoil
#define ARecoil_H_ADS 0.0 //<----Change this value for horizontal ADS antirecoil
#define ARecoil_H_HIP 0.0 //<----Change this value for horizontal HIP antirecoil
// Vertical AntiRecoil
#define ARecoil_V_ADS 10.0 //<--- Change this Value for vertical ADS antirecoil
#define ARecoil_V_HIP 20.0 //<--- Change this Value for vertical HIP antirecoil
// AntiRecoil Delay
#define ARecoilDelay 50
//Anti Recoil toggle
bool tAntiRecoil = TRUE;
main {
if(get_actual(BUTTON_8)){ // ANTIRECOIL ON/OFF: HOLD L2/LT, PRESS Ps/XB1, RELEASE L2/LT
set_val(BUTTON_1, 0.0);
if(event_active(BUTTON_1)) tAntiRecoil = !tAntiRecoil;
}
if (tAntiRecoil){
if (check_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 (is_active(BUTTON_5) && (is_active(BUTTON_8))){ // ADS AntiRecoil
AntiRecoil(STICK_1_X, ARecoil_H_ADS);
AntiRecoil(STICK_1_Y, ARecoil_V_ADS);
}
else
if (is_active(BUTTON_5) && (!is_active(BUTTON_8))){ // HIP AntiRecoil
AntiRecoil(STICK_1_X, ARecoil_H_HIP);
AntiRecoil(STICK_1_Y, ARecoil_V_HIP);
}
}
}
}
void AntiRecoil(uint8 AxisToApply, fix32 ARecoilToApply){
fix32 CurrentX = get_val(STICK_1_X);
fix32 CurrentY = get_val(STICK_1_Y);
fix32 MinARecoilFactor = MinARecoilPercent / 100.0;
fix32 MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
//This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
fix32 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)));
}
-
alanmcgregor - Major
- Posts: 995
- Joined: Tue Mar 27, 2018 8:38 am
Nice this will come in handy thanks! So the vertical script is initially active but the rapid fire script I use is initially off so when I activate it it turns off the anti recoil. Is there any easy tweaking to make it so the vertical recoil script is off starting out?
-
Gorphius - Master Sergeant
- Posts: 26
- Joined: Tue Nov 13, 2018 7:54 pm
Re: Antirecoil Script
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
Re: Antirecoil Script
Thanks Mad!
-
Gorphius - Master Sergeant
- Posts: 26
- Joined: Tue Nov 13, 2018 7:54 pm
9 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 171 guests