Is possible to make switch between 2 Anti-recoil with time

Gtuner IV general support. Operation, questions, updates, feature request.

Is possible to make switch between 2 Anti-recoil with time

Postby TKill » Sat Feb 09, 2019 5:48 am

hi

Is possible to make switch between 2 Anti-recoil with time

i mean i want 1st [30 recoil] in 5-10 shot (0.4sec) then switch to 2nd [15 recoil] until i stop shooting



Code: Select all
#pragma METAINFO("antithesis ADS Antirecoil", 1, 01, "antithesis")
 
fix32 RECOIL_V = 30.0; // Change this value to adjust the strength of Vertical antirecoil
fix32 RECOIL_H = 0.0; // Change this value to adjust the strength of Horizontal antirecoil
fix32 RY;
fix32 RX;
 
fix32 StickNoise = 4.32// Change this value to adjust the size of the Deadzone to ignore when using a Xim Apex.
// Go to Device Monitor in Gtuner IV, flick the right stick and take note of the largest value.
 
main {
 
 
if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
{   
// DEADZONE REMOVER
    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); }
 
}   
 
// ANTI-RECOIL
if (get_val (BUTTON_8)) // while holding ADS
    {
        if (get_val (BUTTON_5)) // while holding SHOOT
        {   
            AntiRecoil(STICK_1_Y,RECOIL_V); // apply Vertical antirecoil
            AntiRecoil(STICK_1_X,RECOIL_H); // apply Horizontal antirecoil
        }
 
    }
}
 
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));
        }
    }
}
User avatar
TKill
Sergeant
Sergeant
 
Posts: 8
Joined: Fri Sep 07, 2018 7:59 pm

Re: Is possible to make switch between 2 Anti-recoil with ti

Postby Scachi » Sat Feb 09, 2019 6:06 am

Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
 
init {
  // some error checking, number of values have to match the number of times
  if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
  if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main {
 
  if (get_val(BUTTON_5)) AROverTime(); // when fire button is active use anti recoil
}
 
void AROverTime() {
  int8 i;
  uint32 ta = time_active(BUTTON_5);
 
  static int last=0; // for information in the output panel
 
  for (i=sizeof(T)/4;i>=0;i--) {
    if (ta >= T[i]) {
 
      if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
      AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
      AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
      return;
    }
  }
}
 
 
// antithesis antirecoil
void AntiRecoil (uint8 axis, fix32 recoil)
{
  fix32 RY = get_actual(STICK_1_Y);
  fix32 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));
      }
  }
}
 
User avatar
Scachi
Colonel
Colonel
 
Posts: 1543
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Is possible to make switch between 2 Anti-recoil with ti

Postby TKill » Sat Feb 09, 2019 7:03 am

can u plz add only active when i holding ADS and SHOOT the same time like the script above
User avatar
TKill
Sergeant
Sergeant
 
Posts: 8
Joined: Fri Sep 07, 2018 7:59 pm

Re: Is possible to make switch between 2 Anti-recoil with ti

Postby Scachi » Sat Feb 09, 2019 8:28 am

TKill wrote:can u plz add only active when i holding ADS and SHOOT the same time like the script above

here it is..but it is monitoring the fire button for using its time active to use the anti recoil value.
When you hip fire and without releasing the shoot button press the ADS button later on it will jump to the second AR value as the Shoot button is already hold down that long. Not sure if this is what you are looking for.
Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
 
fix32 StickNoise = 4.32// Change this value to adjust the size of the Deadzone to ignore when using a Xim Apex.
// Go to Device Monitor in Gtuner IV, flick the right stick and take note of the largest value.
 
 
init {
  // some error checking, number of values have to match the number of times
  if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
  if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main {
    if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
    {   
      // DEADZONE REMOVER
      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 (get_val(BUTTON_5) && get_val(BUTTON_8)) AROverTime(); // when fire button is active use anti recoil
}
 
void AROverTime() {
  int8 i;
  uint32 ta = time_active(BUTTON_5);
 
  static int last=0; // for information in the output panel
 
  for (i=sizeof(T)/4;i>=0;i--) {
    if (ta >= T[i]) {
 
      if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
      AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
      AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
      return;
    }
  }
}
 
 
// antithesis antirecoil
void AntiRecoil (uint8 axis, fix32 recoil)
{
  fix32 RY = get_actual(STICK_1_Y);
  fix32 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));
      }
  }
}
 



This one will start with the first AR value even when you hold Shoot and press ADS later on:
Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
 
fix32 StickNoise = 4.32// Change this value to adjust the size of the Deadzone to ignore when using a Xim Apex.
// Go to Device Monitor in Gtuner IV, flick the right stick and take note of the largest value.
 
 
init {
  // some error checking, number of values have to match the number of times
  if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
  if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main {
    if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
    {   
      // DEADZONE REMOVER
      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 (get_val(BUTTON_5) && get_val(BUTTON_8)) AROverTime(); // when fire button is active use anti recoil
}
 
void AROverTime() {
  int8 i;
  uint32 ta = time_active(BUTTON_5);
  uint32 taADS = time_active(BUTTON_8);
 
  static int last=0; // for information in the output panel
 
  for (i=sizeof(T)/4;i>=0;i--) {
    if (ta > taADS) ta = taADS;
    if (ta >= T[i]) {
 
      if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
      AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
      AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
      return;
    }
  }
}
 
 
// antithesis antirecoil
void AntiRecoil (uint8 axis, fix32 recoil)
{
  fix32 RY = get_actual(STICK_1_Y);
  fix32 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));
      }
  }
}
 
User avatar
Scachi
Colonel
Colonel
 
Posts: 1543
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Is possible to make switch between 2 Anti-recoil with ti

Postby TKill » Mon Feb 11, 2019 6:21 am

Scachi wrote:
TKill wrote:can u plz add only active when i holding ADS and SHOOT the same time like the script above

here it is..but it is monitoring the fire button for using its time active to use the anti recoil value.
When you hip fire and without releasing the shoot button press the ADS button later on it will jump to the second AR value as the Shoot button is already hold down that long. Not sure if this is what you are looking for.
Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
 
fix32 StickNoise = 4.32// Change this value to adjust the size of the Deadzone to ignore when using a Xim Apex.
// Go to Device Monitor in Gtuner IV, flick the right stick and take note of the largest value.
 
 
init {
  // some error checking, number of values have to match the number of times
  if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
  if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main {
    if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
    {   
      // DEADZONE REMOVER
      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 (get_val(BUTTON_5) && get_val(BUTTON_8)) AROverTime(); // when fire button is active use anti recoil
}
 
void AROverTime() {
  int8 i;
  uint32 ta = time_active(BUTTON_5);
 
  static int last=0; // for information in the output panel
 
  for (i=sizeof(T)/4;i>=0;i--) {
    if (ta >= T[i]) {
 
      if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
      AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
      AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
      return;
    }
  }
}
 
 
// antithesis antirecoil
void AntiRecoil (uint8 axis, fix32 recoil)
{
  fix32 RY = get_actual(STICK_1_Y);
  fix32 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));
      }
  }
}
 



This one will start with the first AR value even when you hold Shoot and press ADS later on:
Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
 
fix32 StickNoise = 4.32// Change this value to adjust the size of the Deadzone to ignore when using a Xim Apex.
// Go to Device Monitor in Gtuner IV, flick the right stick and take note of the largest value.
 
 
init {
  // some error checking, number of values have to match the number of times
  if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
  if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main {
    if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
    {   
      // DEADZONE REMOVER
      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 (get_val(BUTTON_5) && get_val(BUTTON_8)) AROverTime(); // when fire button is active use anti recoil
}
 
void AROverTime() {
  int8 i;
  uint32 ta = time_active(BUTTON_5);
  uint32 taADS = time_active(BUTTON_8);
 
  static int last=0; // for information in the output panel
 
  for (i=sizeof(T)/4;i>=0;i--) {
    if (ta > taADS) ta = taADS;
    if (ta >= T[i]) {
 
      if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
      AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
      AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
      return;
    }
  }
}
 
 
// antithesis antirecoil
void AntiRecoil (uint8 axis, fix32 recoil)
{
  fix32 RY = get_actual(STICK_1_Y);
  fix32 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));
      }
  }
}
 



Thank you soo much :)

this work will > make weapon OP
User avatar
TKill
Sergeant
Sergeant
 
Posts: 8
Joined: Fri Sep 07, 2018 7:59 pm

Re: Is possible to make switch between 2 Anti-recoil with ti

Postby bonefisher » Mon Feb 11, 2019 9:47 am

Code: Select all
 
uint32 T[]= {0,400}; // time in ms the button has to be pressed down for the values to be used
int8  AX[]= {0 ,0  }// x anti recoil when time reached
int8  AY[]= {30,15}// y anti recoil when time reached
fix32 StickNoise = 6.50;
init
{
  // some error checking, number of values have to match the number of times
    if (sizeof(T)/4 != sizeof(AX)) printf("number of times (%d) and x values (%d) have to match",sizeof(T)/4,sizeof(AX));
    if (sizeof(T)/4 != sizeof(AY)) printf("number of times (%d) and y values (%d) have to match",sizeof(T)/4,sizeof(AY));
}
 
main
{
    if(get_actual(BUTTON_8))
    {
        if (get_val(BUTTON_5))
        {
            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);
            AROverTime(); // when fire button is active use anti recoil
        }
    }
}
 
void AROverTime()
{
    int8 i;
    uint32 ta = time_active(BUTTON_5);
 
    static int last=0; // for information in the output panel
 
    for (i=sizeof(T)/4;i>=0;i--)
    {
        if (ta >= T[i])
        {
            if (i != last) { last=i; printf("active entry %d, time %ld, applying x: %d, y: %d",i,T[i],AX[i],AY[i]); }// for information in the output panel
 
            AntiRecoil(STICK_1_X,(fix32)AX[i]); // apply the X anti recoil value
            AntiRecoil(STICK_1_Y,(fix32)AY[i]); // apply the y anti recoil value
            return;
        }
    }
}
 
void AntiRecoil (uint8 axis, fix32 recoil)
{
    fix32 RY = get_actual(STICK_1_Y);
    fix32 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));
        }
    }
}
 

Here is just with being when ADS and Fire!
bonefisher
Major General
Major General
 
Posts: 4812
Joined: Thu Jan 29, 2015 10:49 am


Return to Gtuner IV Support (Titan Two)

Who is online

Users browsing this forum: No registered users and 4 guests