Stimulating analog behaviour on KB

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

Stimulating analog behaviour on KB

Postby bt1740 » Mon Dec 09, 2019 1:24 am

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
User avatar
bt1740
Staff Sergeant
Staff Sergeant
 
Posts: 13
Joined: Thu Jun 13, 2019 11:13 pm

Re: Stimulating analog behaviour on KB

Postby Buffy » Mon Dec 09, 2019 2:16 am

I have some old code made for Fortnite:

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);
 
}
 
ConsoleTuner Support Team || Discord || Custom Scripts
User avatar
Buffy
Lieutenant
Lieutenant
 
Posts: 422
Joined: Wed Jul 20, 2016 5:23 am

Re: Stimulating analog behaviour on KB

Postby DontAtMe » Mon Dec 09, 2019 4:01 am

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, :a1chill_angry1:
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);
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am

Re: Stimulating analog behaviour on KB

Postby antithesis » Mon Dec 09, 2019 6:32 am

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 :whistling:
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Stimulating analog behaviour on KB

Postby bt1740 » Mon Dec 09, 2019 1:46 pm

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.



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 :whistling:


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?
User avatar
bt1740
Staff Sergeant
Staff Sergeant
 
Posts: 13
Joined: Thu Jun 13, 2019 11:13 pm

Re: Stimulating analog behaviour on KB

Postby antithesis » Mon Dec 09, 2019 10:00 pm

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.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Mr-redjoni and 93 guests