I need help with creating a cross-shaped deadzone
14 posts
• Page 2 of 2 • 1, 2
Re: I need help with creating a cross-shaped deadzone
Thanks so much = D
Oh and to answer your question... yes, the game lets you set the real deadzone to almost nothing (I barely move the stick and see a tiny input happen in the game).
Oh and to answer your question... yes, the game lets you set the real deadzone to almost nothing (I barely move the stick and see a tiny input happen in the game).
-
durpthesecond - Master Sergeant
- Posts: 29
- Joined: Sun Nov 25, 2018 1:53 pm
Re: I need help with creating a cross-shaped deadzone
would this help with anti recoil?
-
teckx - Sergeant Major of the Army
- Posts: 194
- Joined: Tue Mar 27, 2018 1:53 pm
Re: I need help with creating a cross-shaped deadzone
Can anyone add an anti recoil script to this? Game im playing is pubg
J2Kbr wrote:this will require some math, please test:
- Code: Select all
#define DEADZONE_X 20.0
#define DEADZONE_Y 20.0
#define DEADZONE_D 4.0 // Cross Shape Deadzone
void deadzone() {
static fix32 ax, ay;
static fix32 vx, vy;
if(ax != get_actual(STICK_1_X) || ay != get_actual(STICK_1_Y)) {
vx = ax = get_actual(STICK_1_X);
vy = ay = get_actual(STICK_1_Y);
fix32 sx = (vx < 0.0) ? (vx = inv(vx), -1.0) : (vx > 0.0) ? 1.0 : 0.0;
fix32 sy = (vy < 0.0) ? (vy = inv(vy), -1.0) : (vy > 0.0) ? 1.0 : 0.0;
fix32 a = atan2(vy, vx);
fix32 dx = DEADZONE_X * pow(cos(a), DEADZONE_D);
fix32 dy = DEADZONE_Y * pow(sin(a), DEADZONE_D);
if(vx <= dx) vx = 0.0;
if(vy <= dy) vy = 0.0;
vx *= sx;
vy *= sy;
}
set_val(STICK_1_X, clamp(vx, -100.0, 100.0));
set_val(STICK_1_Y, clamp(vy, -100.0, 100.0));
return;
}
main {
deadzone();
}
-
Beryl - Sergeant Major of the Army
- Posts: 198
- Joined: Fri Nov 27, 2020 7:47 pm
Re: I need help with creating a cross-shaped deadzone
Not My Anti_Recoil
- Code: Select all
#define DEADZONE_X 20.0
#define DEADZONE_Y 20.0
#define DEADZONE_D 4.0 // Cross Shape Deadzone
// Anti_Recoil----------------------------------
fix32 RECOIL_V = -40.0;
fix32 RECOIL_H = 0.0;
fix32 RY;
fix32 RX;
main {
deadzone();
if (get_val (BUTTON_5))
{
AntiRecoil(STICK_1_Y,RECOIL_V);
AntiRecoil(STICK_1_X,RECOIL_H);
}
}
void AntiRecoil (uint8 axis, fix32 recoil)
{
RY = get_actual(STICK_1_Y);
RX = get_actual(STICK_1_X);
if (get_val(BUTTON_5) && (sqrt(RX*RX + RY*RY)) <= abs(recoil))
{
if(abs(RY) <= abs(recoil))
{
set_val(axis,(recoil * (100.0 - abs(get_val(axis)))) / 100.0 + get_val(axis));
}
}
}
void deadzone() {
static fix32 ax, ay;
static fix32 vx, vy;
if(ax != get_actual(STICK_1_X) || ay != get_actual(STICK_1_Y)) {
vx = ax = get_actual(STICK_1_X);
vy = ay = get_actual(STICK_1_Y);
fix32 sx = (vx < 0.0) ? (vx = inv(vx), -1.0) : (vx > 0.0) ? 1.0 : 0.0;
fix32 sy = (vy < 0.0) ? (vy = inv(vy), -1.0) : (vy > 0.0) ? 1.0 : 0.0;
fix32 a = atan2(vy, vx);
fix32 dx = DEADZONE_X * pow(cos(a), DEADZONE_D);
fix32 dy = DEADZONE_Y * pow(sin(a), DEADZONE_D);
if(vx <= dx) vx = 0.0;
if(vy <= dy) vy = 0.0;
vx *= sx;
vy *= sy;
}
set_val(STICK_1_X, clamp(vx, -100.0, 100.0));
set_val(STICK_1_Y, clamp(vy, -100.0, 100.0));
return;
}
-
MrBrgv - Sergeant First Class
- Posts: 16
- Joined: Sun Dec 27, 2020 9:32 pm
14 posts
• Page 2 of 2 • 1, 2
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 43 guests