Stimulating analog behaviour on KB
6 posts
• Page 1 of 1
Stimulating analog behaviour on KB
I was wondering if anyone has ever experimented with this before? I know that because a KB can only do 100, 0, -100 values, therefore there isnt much aim assist when non ADS'd in games like cod. Has anyone experimented with setting the value going up in increments with random numbers when -100 or 100 on either axis is detected? It wouldnt give the control that a sony nav does in terms of movement, but it would cause more aim assist
-
bt1740 - Staff Sergeant
- Posts: 13
- Joined: Thu Jun 13, 2019 11:13 pm
Re: Stimulating analog behaviour on KB
I have some old code made for Fortnite:
Here was another test version I had:
- Code: Select all
#pragma METAINFO("FORTNiTE KBM Test", 1, 0, "")
#include <keyboard.gph>
#include <xb1.gph>
fix32 stick2_x = 0.0, stick2_y = 0.0, stick2_x_dest = 0.0, stick2_y_dest = 0.0;
#define STICK_SPEED 3.0
main {
if((abs(get_actual(XB1_LX) - stick2_x_dest) > 40.0 || abs(get_actual(XB1_LY) - stick2_y_dest) > 40.0)) {
stick2_x_dest = abs(get_actual(XB1_LX)) < 10.0 ? (rand() * 9.8) : get_actual(XB1_LX);
stick2_y_dest = abs(get_actual(XB1_LY)) < 10.0 ? (rand() * 9.8) : get_actual(XB1_LY);
if((sqrt(sq(abs(stick2_x_dest)) + sq(abs(stick2_y_dest))) > 115.0)) {
set_val(XB1_LX, stick2_x_dest); //sets temp value
stick2_x_dest = ((93.0 + (rand() * 6.0)) * ((stick2_x_dest) / sqrt(sq(abs(stick2_x_dest)) + sq(abs(stick2_y_dest)))));
stick2_y_dest = ((93.0 + (rand() * 6.0)) * ((stick2_y_dest) / sqrt(sq(abs(get_val(XB1_LX))) + sq(abs(stick2_y_dest)))));
}
}
if(abs(stick2_x - stick2_x_dest) > 3.5 || abs(stick2_y - stick2_y_dest) > 3.5) {
stick2_x = clamp(stick2_x + ((fix32)elapsed_time() * (stick2_x_dest > stick2_x ? STICK_SPEED : -STICK_SPEED)), -100.0, 100.0);
stick2_y = clamp(stick2_y + ((fix32)elapsed_time() * (stick2_y_dest > stick2_y ? STICK_SPEED : -STICK_SPEED)), -100.0, 100.0);
}
set_val(XB1_LX, stick2_x);
set_val(XB1_LY, stick2_y);
}
Here was another test version I had:
- Code: Select all
#include <keyboard.gph>
#include <xb1.gph>
fix32 stick2_x, stick2_y, stick2_x_dest, stick2_y_dest;
#define STICK_SPEED 2.75
main {
if(abs(get_prev(XB1_LX) - get_actual(XB1_LX)) > 15.0 || abs(get_prev(XB1_LY) - get_actual(XB1_LY)) > 15.0) {
stick2_x_dest = is_release(XB1_LX) ? (-7.5 + 15.0 * rand()) : is_active(XB1_LY) ? ((0.75 - (rand() * 0.10)) * get_actual(XB1_LX)) : get_actual(XB1_LX);
stick2_y_dest = is_release(XB1_LY) ? (-7.5 + 15.0 * rand()) : is_active(XB1_LX) ? ((0.75 - (rand() * 0.10)) * get_actual(XB1_LY)) : get_actual(XB1_LY);
}
if(elapsed_time() && (abs(stick2_x_dest-stick2_x) > 3.0 || abs(stick2_y_dest-stick2_y) > 3.0)) {
stick2_x = clamp(stick2_x + (stick2_x_dest > stick2_x ? 1.0 : -1.0) * (STICK_SPEED + rand()*0.25), -100.0, 100.0);
stick2_y = clamp(stick2_y + (stick2_y_dest > stick2_y ? 1.0 : -1.0) * (STICK_SPEED + rand()*0.25), -100.0, 100.0);
}
set_val(XB1_LX, stick2_x);
set_val(XB1_LY, stick2_y);
}
-
Buffy - Lieutenant
- Posts: 422
- Joined: Wed Jul 20, 2016 5:23 am
Re: Stimulating analog behaviour on KB
bt1740 wrote:Has anyone experimented with setting the value going up in increments with random numbers when -100 or 100 on either axis is detected? It wouldnt give the control that a sony nav does in terms of movement, but it would cause more aim assist
I also made a script like this a while ago,
- Code: Select all
#pragma METAINFO("Simulate Analog Behaviour", 1, 0, "DontAtMe")
#include <keyboard.gph>
/* 0 <- -> 200 */
#define SAB_VALUE 50
main {
bool W = key_status(KEY_W);
bool A = key_status(KEY_A) * 2;
bool S = key_status(KEY_S) * 4;
bool D = key_status(KEY_D) * 8;
bool dir = (W|A|S|D);
fix32 SX, SY;
fix32 X, Y;
fix32 RA, modifer;
fix32 strength = clamp(
(dir) ?
strength + (rand() * 2.0) :
strength + inv(rand() * 2.0) ,
0.00, 120.00);
memset(&modifer, 0, 24);
#define X_RADIUS ((fix32)SAB_VALUE) * (0.392934)
if (abs(get_actual(STICK_1_X)) >= 10.00)
modifer = clamp(
get_actual(STICK_1_X),
-(X_RADIUS), X_RADIUS)
* 0.01;;
#define Q 0.785385
RA = Q + modifer;
switch(dir){
case 15:
case 11:
case 1: // UP
RA = (Q + Q) + modifer;
SX = strength;
SY = -strength;
break;
case 7:
case 2: // LEFT
RA = modifer;
SX = -strength;
SY = strength;
break;
case 14:
case 4: // DOWN
RA = (Q + Q) + modifer;
SX = strength;
SY = strength;
break;
case 13:
case 8: // RIGHT
RA = modifer;
SX = strength;
SY = -strength;
break;
case 3: // UP_LEFT
RA = Q - modifer;
SX = -strength;
SY = -strength;
break;
case 6: // DOWN_LEFT
SX = -strength;
SY = strength;
break;
case 9: // UP_RIGHT
SX = strength;
SY = -strength;
break;
case 12: // DOWN_RIGHT
SX = strength;
SY = strength;
default:;
}
/* 1 <- -> 10 */
#define LERP_SPEED 5.50
fix32 ra, sx,sy;
if (sx != SX) sx = lerp(sx, SX, (LERP_SPEED/100f));
if (sy != SY) sy = lerp(sy, SY, (LERP_SPEED/100f));
if (ra != RA) ra = lerp(ra, RA, (LERP_SPEED/100f));
X = sx * cos(ra);
Y = sy * sin(ra);
set_val(STICK_2_X, clamp(X, -100.00, 100.00));
set_val(STICK_2_Y, clamp(Y, -100.00, 100.00));
if ((int8)abs(get_val(STICK_2_X)) <= 10 && (int8)abs(get_val(STICK_2_Y)) >= 100)
set_val(STICK_2_X, 0);
}
-
DontAtMe - Captain
- Posts: 502
- Joined: Tue Oct 02, 2018 4:49 am
Re: Stimulating analog behaviour on KB
I asked about this a couple of years ago. bonefisher and J2Kbr posted code in the first two pages - viewtopic.php?f=26&t=6762
I'm one of the alpha testers for XIM APEX and when Fortnite digital detection hit the scene, I passed J2K's code on to OBsIV and it contributed to the development of SAB. He was headed down that path anyway, but the T2 code sped the process.
SAB code is significantly more complex (more randomised for obfuscation, so kb is indistinguishable from analog input), but the core concept is the same (interpolated WASD input). And it did end up enhancing Aim Assist when using a kb
I'm one of the alpha testers for XIM APEX and when Fortnite digital detection hit the scene, I passed J2K's code on to OBsIV and it contributed to the development of SAB. He was headed down that path anyway, but the T2 code sped the process.
SAB code is significantly more complex (more randomised for obfuscation, so kb is indistinguishable from analog input), but the core concept is the same (interpolated WASD input). And it did end up enhancing Aim Assist when using a kb
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Stimulating analog behaviour on KB
Thanks for everyone that posted their code, i'll give it a try tonight. I also made something, so I'll test everyones out and see how it feels.
Thanks, thats very interesting. I'll give their code a try. Are you aware of any "requirments" for the aim assist to kick in? Currently what I coded last night before i made this thread, I simply made a script where it starts off at 10 (or -10 depending on axis). Then from 10 to 50 it finds a random number and adds anywhere from 5-10 to do the value repeatedly every x amount of ms. This 5-10 number is also randomized. Then after the 50 (or -50 depending on axis) mark, instead of adding 5-10 it adds from 1-5 (randomized each time) every x amount of ms. I did this to slow down the jump from 50 to 95+ so it actually feels like a thumb moving a joystick to each end instead of a straight snap from 10 to 95+ really quckily. I made sure to stop it before it hits 100, so the # is usually between 95-99 and each time but different because of the randomizing number that adds in increments each time.
I did this process differently for each direction, so all directions have their own randomized numbers.
I didn't get any time to properly test it but I did notice an increase in aim assist just moving around in MW briefly. Although I am wondering if you are aware of any requirments that the game looks for when having the aim assist kick in? Maybe a certain time limit has to be crossed before it reaches 90 (or -90) to 95-100?
antithesis wrote:I asked about this a couple of years ago. bonefisher and J2Kbr posted code in the first two pages - viewtopic.php?f=26&t=6762
I'm one of the alpha testers for XIM APEX and when Fortnite digital detection hit the scene, I passed J2K's code on to OBsIV and it contributed to the development of SAB. He was headed down that path anyway, but the T2 code sped the process.
SAB code is significantly more complex (more randomised for obfuscation, so kb is indistinguishable from analog input), but the core concept is the same (interpolated WASD input). And it did end up enhancing Aim Assist when using a kb
Thanks, thats very interesting. I'll give their code a try. Are you aware of any "requirments" for the aim assist to kick in? Currently what I coded last night before i made this thread, I simply made a script where it starts off at 10 (or -10 depending on axis). Then from 10 to 50 it finds a random number and adds anywhere from 5-10 to do the value repeatedly every x amount of ms. This 5-10 number is also randomized. Then after the 50 (or -50 depending on axis) mark, instead of adding 5-10 it adds from 1-5 (randomized each time) every x amount of ms. I did this to slow down the jump from 50 to 95+ so it actually feels like a thumb moving a joystick to each end instead of a straight snap from 10 to 95+ really quckily. I made sure to stop it before it hits 100, so the # is usually between 95-99 and each time but different because of the randomizing number that adds in increments each time.
I did this process differently for each direction, so all directions have their own randomized numbers.
I didn't get any time to properly test it but I did notice an increase in aim assist just moving around in MW briefly. Although I am wondering if you are aware of any requirments that the game looks for when having the aim assist kick in? Maybe a certain time limit has to be crossed before it reaches 90 (or -90) to 95-100?
-
bt1740 - Staff Sergeant
- Posts: 13
- Joined: Thu Jun 13, 2019 11:13 pm
Re: Stimulating analog behaviour on KB
Don't overthink it. As long as the script doesn't jump straight from 0 to 100, but instead ramps from 0 to 100 over XX ms, you'll have left-stick (rotational) AA in games that support it, like CoD, Battlefield, Destiny etc.
I use an Azeron Compact these days for analog input as it's the bomb for console gaming.
I use an Azeron Compact these days for analog input as it's the bomb for console gaming.
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
6 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 115 guests