set_polar() - Script Documentation

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

Re: set_polar() - Script Documentation

Postby Mad » Sun Jan 12, 2020 7:57 pm

Gjin Yuko wrote:Any future plans on Xim Support?

You can use this with XIM :smile0517:
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: set_polar() - Script Documentation

Postby Gjin Yuko » Mon Jan 13, 2020 5:20 pm

UK_Wildcats_Fans wrote:What are some applications for using this?


Mainly for Anti Recoil on Battlefield and Call of Duty series
YouTube /Gjin Yuko
Facebook /Gjin Yuko
Twitter /Gjin Yuko
Discord /Gjin Yuko
Xbox /Gjin Yuko
Playstation Dont have one, Xbox is the better Console :P
User avatar
Gjin Yuko
Sergeant Major
Sergeant Major
 
Posts: 95
Joined: Mon Aug 05, 2019 10:00 pm
Location: Germany

Re: set_polar() - Script Documentation

Postby Gjin Yuko » Mon Jan 13, 2020 5:22 pm

Mad wrote:
Gjin Yuko wrote:Any future plans on Xim Support?

You can use this with XIM :smile0517:


Yeah i tried it out with the Xim, but when you ADS youre Mouse movements gets really really stiff
YouTube /Gjin Yuko
Facebook /Gjin Yuko
Twitter /Gjin Yuko
Discord /Gjin Yuko
Xbox /Gjin Yuko
Playstation Dont have one, Xbox is the better Console :P
User avatar
Gjin Yuko
Sergeant Major
Sergeant Major
 
Posts: 95
Joined: Mon Aug 05, 2019 10:00 pm
Location: Germany

Re: set_polar() - Script Documentation

Postby cb57 » Tue Jan 21, 2020 5:06 pm

How would this be used for Anti-Recoil?
User avatar
cb57
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Wed Mar 13, 2019 1:14 pm

Re: set_polar() - Script Documentation

Postby UK_Wildcats » Thu Mar 05, 2020 7:56 pm

cb57 wrote:How would this be used for Anti-Recoil?


My understanding may be wrong, but here it is. I am assuming that set_polar is another alternative to set_val for the stick (x & Y).

For example, let's assume that a gun kicks up and to the right fairly consistent. Based upon the recoil pattern, you could plot an angle and use set_polar for the plotted angles.

Please let me know if my understanding is not correct or how else it would be used.
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: set_polar() - Script Documentation

Postby bonefisher » Sun Mar 08, 2020 9:40 pm

Code: Select all
 
#pragma METAINFO("polar anti recoil", 1, 0, "bonefisher")
 
#define POLAR_RS STICK_1_X, STICK_1_Y
#define POLAR_LS STICK_2_X, STICK_2_Y
 
fix32 anti_recoil = 40.0//--Anti_Recoil strength
fix32 polar_angle = 90.0//--direction of anti_recoil
 
fix32 StickNoise = 8.0;
main {
    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(get_val(BUTTON_5)) {
        set_polar(POLAR_RS, polar_angle, anti_recoil + .01);
    }
}
 
void set_polar(uint8 X, uint8 Y, fix32 ANGLE, fix32 RADIUS){
 
  fix32 angle = rad2deg(mod(deg2rad(ANGLE) + PI * 2f, PI * 2f));
 
  fix32 x_Out, y_Out;
 
  if(angle > 45.10 && angle < 225.90) {
    x_Out = -sin(deg2rad(angle) - deg2rad(90.02));
    y_Out = -cos(deg2rad(angle) - deg2rad(270.00));
  }
  else {
    x_Out = cos(deg2rad(angle));
    y_Out = sin(deg2rad(angle));
  }
 
  set_val_offset(X, clamp(x_Out * RADIUS, -100.00, 100.00));
  set_val_offset(Y, clamp(y_Out * RADIUS, -100.00, 100.00));
}
void set_val_offset(uint8 axis, fix32 offset_val)
{
    set_val(axis, clamp(offset_val * (100.0 - abs(get_val(axis))) / 100.0 + get_val(axis), -100.0, 100.0));
    return;
}
 

Here!! :smile0517:
90 is straight down 95 is down left 85 is down right example.....
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: set_polar() - Script Documentation

Postby bonefisher » Mon Mar 09, 2020 4:08 am

Code: Select all
 
#pragma METAINFO("polar anti recoil", 1, 0, "bonefisher")
 
#define POLAR_RS STICK_1_X, STICK_1_Y
#define POLAR_LS STICK_2_X, STICK_2_Y
 
fix32 anti_recoil = 44.0//--Anti_Recoil strength
fix32 polar_angle = 95.0//--direction of anti_recoil
fix32 recoil_drop = anti_recoil - 12.0;
fix32 recoil = anti_recoil;
fix32 StickNoise = 8.0;
main {
    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(get_val(BUTTON_5)) {
        set_polar(POLAR_RS, polar_angle, anti_recoil + .01);
    }
        if(get_actual(BUTTON_5)) {
        anti_recoil = anti_recoil - 0.01;
        if(anti_recoil < recoil_drop)anti_recoil = recoil_drop;
        }else if(event_release(BUTTON_5))anti_recoil = recoil;
}
 
void set_polar(uint8 X, uint8 Y, fix32 ANGLE, fix32 RADIUS){
 
  fix32 angle = rad2deg(mod(deg2rad(ANGLE) + PI * 2f, PI * 2f));
 
  fix32 x_Out, y_Out;
 
  if(angle > 45.10 && angle < 225.90) {
    x_Out = -sin(deg2rad(angle) - deg2rad(90.02));
    y_Out = -cos(deg2rad(angle) - deg2rad(270.00));
  }
  else {
    x_Out = cos(deg2rad(angle));
    y_Out = sin(deg2rad(angle));
  }
 
  set_val_offset(X, clamp(x_Out * RADIUS, -100.00, 100.00));
  set_val_offset(Y, clamp(y_Out * RADIUS, -100.00, 100.00));
}
void set_val_offset(uint8 axis, fix32 offset_val)
{
    set_val(axis, clamp(offset_val * (100.0 - abs(get_val(axis))) / 100.0 + get_val(axis), -100.0, 100.0));
    return;
}
 

This is best for MW2019 :smile0517:
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: set_polar() - Script Documentation

Postby Pianist » Mon Mar 09, 2020 2:02 pm

Hi,

just asking myself:

The recoil angles/values of the Battlefield weapons are known. (you can look them up at sym.gg, see below picture yellow marked)

Is there anyway to translate these values in a script like this here? That would be very interesting! (I know that sometimes random recoil comes up, thats excluded from my question)

Image
User avatar
Pianist
Sergeant First Class
Sergeant First Class
 
Posts: 20
Joined: Sun Jan 12, 2020 11:28 am

Re: set_polar() - Script Documentation

Postby bonefisher » Mon Mar 09, 2020 3:44 pm

Use the second one I posted!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: set_polar() - Script Documentation

Postby Pianist » Mon Mar 09, 2020 6:15 pm

Thanks for your reply.

But which value of my screenshot do I have to insert where?

Or do you mean just copy your second code and play with it in BFV?

Sorry when its a dumb question, I am not a pro when it comes to scripts.

BR
User avatar
Pianist
Sergeant First Class
Sergeant First Class
 
Posts: 20
Joined: Sun Jan 12, 2020 11:28 am

PreviousNext

Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 80 guests