Need help with an Auto Sprint script

GPC1 script programming for Titan One. Code examples, questions, requests.

Need help with an Auto Sprint script

Postby Greedoshotlate » Mon Jan 28, 2019 2:32 pm

Hello,
I am trying to get this line in my script to work for Red Dead Redemption working as an auto run option, this line was taken from an existing GTA script. the difference in RDR2 is that it requires a double tap of PS4_L3 to get into full run rather than a single tap as in GTA. One tap goes into a jog and two taps goes into full run/sprint.

Code: Select all
if (AutoSprintOnOff == 2) {                                                //1  
    if (get_val(12) <= 100){       //360 degrees Auto Sprint.                  //1 
        set_val(8, 100);              //This Line needs to do a double tap of L3 then set the value to 100 on the second tap  //1                         
    } else {                                                                   //1                                       
        set_val(8, 0);                                                         //1         
    }                              // *|| get_val(18)"(reload) option below.   //1         
    if (get_val(7) || get_val(4) || get_val(18)) {                             //1 
        set_val(8, 0);                                                         //1 
    }


This line " set_val(8, 100);" is where I would like (if possible) to set up a double tap (holding on the last or second tap of L3).
I have tried inserting "(DoubleTap(8, 100);" and this caused a few unexpected results i.e. it brings up the PS quick menu and takes a screenshot lol. Is what I am trying to do even possible? RDR2's run feature isn't very reliable in my practice but this feature would help with that if I could get it to do a double tap after it cancels the L3 hold when Aiming or shooting.
the value on the second tap still needs to stay at a persistent "100" so as to keep the run feature working as RDR2 tends to take you out of a run often in my experience.


Values:

5 = PS4_R3
8 = PS4_L3
7 = PS4_L2
12 = PS4_LY
18 = PS4_CIRCLE





Here is the full code for the auto sprint that I am using as the base (I left out the rumble notifier combos though):
Code: Select all
    if (DoubleTap(5) == TRUE) {                                                    //1                                                                             
    if (AutoSprintOnOff == 2) {                                                //1 
        AutoSprintOnOff = 1;                                                   //1 
        set_pvar(SPVAR_1, AutoSprintOnOff);                                    //1 
        combo_run(RumbleNotifier_2);                                           //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (AutoSprintOnOff == 1) {                                         //1 
        AutoSprintOnOff = 2;                                                   //1
        set_pvar(SPVAR_1, AutoSprintOnOff);                                    //1
        combo_run(RumbleNotifier_1);                                           //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (AutoSprintOnOff == 2) {                                                //1 
    if (get_val(12) <= 100){       //360 degrees Auto Sprint.                  //1 
        set_val(8, 100);                                                       //1               
    } else {                                                                   //1                                       
        set_val(8, 0);                                                         //1         
    }                              // *|| get_val(18)"(reload) option below.   //1         
    if (get_val(7) || get_val(4) || get_val(18)) {                             //1 
        set_val(8, 0);                                                         //1 
    }


Any help would be greatly appreciated.
Thank You
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby J2Kbr » Wed Jan 30, 2019 1:47 pm

What you need to do is add this combo to your script:
Code: Select all
combo Sprint {
    set_val(PS4_L3, 100);
    wait(50);
    set_val(PS4_L3, 0);
    wait(40);
}

And change the code to auto sprint to something like this:
Code: Select all
    if(AutoSprintOnOff == 2) {
        if(get_val(PS4_LY) <= -75) {
            combo_run(Sprint);
        }
    }
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Need help with an Auto Sprint script

Postby Greedoshotlate » Thu Jan 31, 2019 2:38 am

Thank You for the reply J2Kbr ,

I did try running a combo like this (though yours did run more smoothly), same problem exists though. The combo just cycles the character through a Jogging to Run repeatedly over and over. I use the Standard FPS control settings which requires L3 to activate Jog with the first tap, then Full Run with a second tap (with "Toggle to Run" option) which is unreliable in practice as it drops you out of run more time than not. Which is why you need to Hold L3 on the second Tap in order for it to stay in the Full Run animation consistently.
Game options are:
Toggle to Run (great when it works)
Hold to Run (Who wants to hold L3 down all the time?) (Standard FPS controls)

Other options would be "Standard" controls where PS4_CROSS is used to run by repeatedly tapping PS4_CROSS to get to full run (Just as in GTAV). I switched the script to utilize the "Standard" control settings and it works much better with the requirement of a repeated combo.

Code: Select all
// GPC Online Library
// RDR2_AutoSprint.gpc
 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES DESCRIPTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//-----------------------------[ SPRINT FEATURES ]---------------------------------
 
//Included are HAIR TRIGGERS.                                                       1
//These "features" are only running when Auto Sprint is activated and done so       1
//purposely.                                                                        1
//______________                                                                    1
//-[AUTO SPRINT]                              [AUTO SPRINT'S Activate/Deactivate]   1
//**************                                                                    1
//Activated/deactivated by Double-click R3/RS(5). Once activated, you sprint in any 1   
//direction you want by pushing the left analog stick in the direction you want to  1   
//go. Works for fast Swimming/Boating/Horseback as well as Carriages. In this       1
//"feature", I've included rumble notifiers and LED's to distinguish when you       1
//activate & when you deactivate the "feature". Within this "feature" are two       1
//other "features" that work best along with Auto Sprint and have very little use   1
//otherwise.If having trouble traversing stairs or don't want to Sprint on horseback 1
//You can either deactivate Auto Sprint (Dbl Tap R3/RS(5) or just aim your weapon   1
//and point in the direction you want to go in these cases and advance with no      1
//problem. Below I have 2 aternative ways listed along with the currently used line,1
//which is the first one listed. Should you want to lessen the sensitivity of       1
//the 360 degrees always on (when activated) Auto Sprint, you can try either of     1
//these. You'll want to keep the + numbers + and - numbers -. You can only make the 1                                                                     
//numbers (1-100). Try them out and see what works best for you. Having higher      1
//numbers will allow you to tilt the left analog stick off center more before Auto  1   
//Sprint engages. Be aware that having higher numbers will likely affect swimming   1
//in a negative way.                                                                1                         
//                                                                                  1
//if (get_val(12) <= -75)  //<- CURRENTLY USED LINE.                                1
//*if (get_val(12) < -5 || abs(get_val(11)) > 5 ^^ abs(get_val(11)) < -5 ) {        1                                     
//*if (abs(get_val(12)) > 5 || abs(get_val(11)) > 5) {                              1
//                                                                                  1
//To reload while sprinting, you need to double-tap CIRCLE/B/(18). If standing      1
//still, you only need to press once to reload. I would suggest you to take the     1
//reload option out of the Auto Sprint "feature", if you can do without it.         1
//Leaving it in will allow you to double-tap CIRCLE/B/(18) to reload while          1 
//sprinting. However, it comes at the expense of slowing you down while sprinting   1     
//Reload is slow anyways. I'd suggest you just switch weapons, which is faster than 1
//reloading. The line below, which is in the script, is the one you would remove.   1
//Located in 1st section of AUTO SPRINT.                                            1
//                                                                                  1                                                                                  1
// if (get_val(7) || get_val(4) || get_val(18)) {  // *|| get_val(18)"(reload).     1
//_____________                                                                     
 
//-[HAIR TRIGGERS]                            [AUTO SPRINT'S Activate/Deactivate]   3
//****************                                                                  3
//This "feature" allows the fastest response times on aiming & firing your weapon.  3 
//                                                                                  3
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ DEFINES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//DEFINE (0) | PS4_PS | PS3_PS | XB1_XBOX | XB360_XBOX                 
//DEFINE (1) | PS4_SHARE | PS3_SELECT | XB1_VIEW | XB360_BACK                     
//DEFINE (2) | PS4_OPTIONS | PS3_START | XB1_MENU | XB360_STAR                     
//DEFINE (3) | PS4_R1 | PS3_R1 | XB1_RB | XB360_RB                           
//DEFINE (4) | PS4_R2 | PS3_R2 | XB1_RT | XB360_RT                             
//DEFINE (5) | PS4_R3 | PS3_R3 | XB1_RS | XB360_RS                     Dbl Tap to Activate/Deactivate AutoSprint.                         
//DEFINE (6) | PS4_L1 | PS3_L1 | XB1_LB | XB360_LB                           
//DEFINE (7) | PS4_L2 | PS3_L2 | XB1_LT | XB360_LT                             
//DEFINE (8) | PS4_L3 | PS3_L3 | XB1_LS | XB360_LS                               
//DEFINE (9) | PS4_RX | PS3_RX | XB1_RX | XB360_RX                                 
//DEFINE (10)| PS4_RY | PS3_RY | XB1_RY | XB360_RY                             
//DEFINE (11)| PS4_LX | PS3_LX | XB1_LX | XB360_LX               
//DEFINE (12)| PS4_LY | PS3_LY | XB1_LY | XB360_LY                   
//DEFINE (13)| PS4_UP | PS3_UP | XB1_UP | XB360_UP                               
//DEFINE (14)| PS4_DOWN | PS3_DOWN | XB1_DOWN | XB360_DOWN                     
//DEFINE (15)| PS4_LEFT | PS3_LEFT | XB1_LEFT | XB360_LEFT                               
//DEFINE (16)| PS4_RIGHT | PS3_RIGHT | XB1_RIGHT | XB360_RIGHT                         
//DEFINE (17)| PS4_TRIANGLE | PS3_TRIANGLE | XB1_Y | XB360_Y                     
//DEFINE (18)| PS4_CIRCLE | PS3_CIRCLE | XB1_B | XB360_B                       
//DEFINE (19)| PS4_CROSS | PS3_CROSS | XB1_A | XB360_A               
//DEFINE (20)| PS4_SQUARE | PS3_SQUARE | XB1_X | XB360_X                                             
//DEFINE (27)| PS4_TOUCH | XB1_P4                                                                                       
 
   //Defines must go at the top of the page.                     
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Int's must go below the defines, but above the init's.   
    int AutoSprintOnOff;                                                       //1 
    int Button_Timing;                                                         //2
    int Button_State             = 0;                                          //2
    int Double_Tap_Gap           = 200;     //Gap in between taps. Changeable. //2 
    int SWITCHoNoFF;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INIT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 
   //Init's must go below the int's, but before the main{               
    init {
    AutoSprintOnOff = get_pvar(SPVAR_1, 1, 2, 1);                              //1         
    SWITCHoNoFF     = get_pvar(SPVAR_2, 1, 2, 1);
    }                                                                          //1 
//---------------------------------------------------------------------------------
main{  //Main Start (Goes below init's and before the "features").
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //AUTO SPRINT / RUMBLE NOTIFIERS / LED                                   ////1  Fully Disables/Enables (1 Rumble On, No Rumble Off) AutoSprint and the Quick On/Off feature of Dbl Tap R3/RS(5)                 
    if (get_val(16) && event_press(18)) {                                    ///1  PS4_Right & Ps4_Circle  to fully disable or enable the autosprint feature
        if (SWITCHoNoFF == 2) {                                              ///1  This is in here in anticipation for added features in the future.
            SWITCHoNoFF = 1;
            set_pvar(SPVAR_2, SWITCHoNoFF);
        } else if (SWITCHoNoFF == 1) {
            SWITCHoNoFF = 2;
            set_pvar(SPVAR_2, SWITCHoNoFF);
            combo_run(RumbleNotifier);
        }
    }
 
 
    if (SWITCHoNoFF == 2 && event_release(5)) {                                                    //1    Double-Tap R3/RS(5) to Enable/Disable AutoSprint on the fly.                                                                         
    if (AutoSprintOnOff == 2) {                                                //1    One Rumble = Off, Two Rumbles = On or Active
        AutoSprintOnOff = 1;                                                   //1 
        set_pvar(SPVAR_1, AutoSprintOnOff);                                    //1 
        combo_run(RumbleNotifier_2);                                           //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (AutoSprintOnOff == 1) {                                         //1 
        AutoSprintOnOff = 2;                                                   //1
        set_pvar(SPVAR_1, AutoSprintOnOff);                                    //1
        combo_run(RumbleNotifier_1);                                           //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (AutoSprintOnOff == 2) {                                                //1 
    if (get_val(12) <= -75){       //360 degrees Auto Sprint.                  //1 
        combo_run(AutoSprint);                                                 //1               
    } else {                                                                   //1      No LS input pauses AutoSprint Combo                                   
        combo_stop(AutoSprint);                                                //1         
    }                              // *|| get_val(18)"(reload) option below.   //1         
    if (get_val(7) || get_val(4) || get_val(18)) {                             //1      Using ADS, Shoot, or Reload pauses AutoSprint Combo
        combo_stop(AutoSprint);                                                //1 
    }                                                                          //1 
 
   //HAIR TRIGGERS-----------------------------------------------------------------      Hair Triggers are only active with AutoSprint Feature Active
    if (get_val(7)) {                                                          //3 
        set_val(7, 100);                                                       //3
    }                                                                          //3   
    if (get_val(4)) {                                                          //3             
        set_val(4, 100);                                                       //3
    }                                                                          //3   
//---------------------------------------------------------------------------------     
}
}  //Main End (Goes after the featured scripts & before the combo's).
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ COMBO'S ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Combo's go after the Main End and before FUNCTIONS.
combo    RumbleNotifier      {
    set_rumble(RUMBLE_A, 100);
    wait                (300);
    reset_rumble();
}
 
combo RumbleNotifier_1 {     //Notifies you when the "feature" is turned on.   //1/4         
    set_rumble(RUMBLE_B, 51);                                                  //1/4
    wait(300);                                                                 //1/4
    set_rumble(RUMBLE_B, 0);                                                   //1/4   
    wait(300);                                                                 //1/4   
    set_rumble(RUMBLE_B, 51);                                                  //1/4 
    wait(400);                                                                 //1/4   
    reset_rumble();                                                            //1/4
}                                                                              //1/4
combo RumbleNotifier_2 {     //Notifies you when the "feature" is shut off.    //1/4 
    set_rumble(RUMBLE_A, 51);                                                  //1/4 
    wait(300);                                                                 //1/4
    reset_rumble();                                                            //1/4
}                                                                              //1/4 
//---------------------------------------------------------------------------------
 
//---------------------------------------------------------------------------------   
//---------------------------------------------------------------------------------
combo AutoSprint {
    set_val(19, 100);
    wait(50);
    set_val(19, 0);
    wait(40);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FUNCTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Functions must be at the bottom of the script.                                           
   //SINGLE & DOUBLE TAP R1/RB/(3)
function DoubleTap(Button) {                                                   //2
    if(Button_State == 0) {                                                    //2
           if(get_val(Button)) Button_State = 1;                               //2 
    } else if(Button_State == 1) {                                             //2 
           if(!get_val(Button)) { Button_Timing = 0; Button_State = 2; }       //2 
    } else if(Button_State == 2) {                                             //2
           if(get_val(Button)) { Button_State = 1; return TRUE; }              //2 
              Button_Timing = Button_Timing + get_rtime();                     //2
           if(Button_Timing > Double_Tap_Gap) Button_State = 0;                //2
    }                                                                          //2
}                                                                              //2
 
 



This is the full script as I am using it currently. I would prefer to use the Standard FPS settings (L3 activates Run) but have switched to the "Standard" setting (Cross activates Run) as it seems to be the only way to run it currently.



Thank you for the help, If you come up with any way to get the L3 double tap and hold on the second tap let me know :innocent_smile_1:

I included the full script in case anyone else would like to use the auto sprint in RDR2, it works great under "Standard" control settings, the AutoSprint stops when you use R2, L2, or Circle as well as when there is no Left stick input. Turns On/Off with a Double Tap of R3. Under the Standard control settings the AutoSprint works on Horseback, on Foot and in vehicles (boats, carriages etc)
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby J2Kbr » Fri Feb 01, 2019 6:19 pm

Greedoshotlate wrote:The combo just cycles the character through a Jogging to Run repeatedly over and over.

I was kind anticipating this, we need run the combo only once when the stick is pushed forward, please try this:
Code: Select all
int AutoSprintOnce;
 
main {
 
    if(AutoSprintOnOff == 2) {
        if(get_val(PS4_LY) <= -75) {
            if(!AutoSprintOnce) {
                combo_run(Sprint);
                AutoSprintOnce = TRUE;
            }
        } else {
            AutoSprintOnce = FALSE;
        }
    }
 
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Need help with an Auto Sprint script

Postby Greedoshotlate » Sat Feb 02, 2019 7:41 pm

Thank you for the reply, that new bit of code will be useful. Though in the RDR2 implementation of L3 initiating run it still doesn't help. I prefer to have Run started with L3 (StandardFPS controls), but with RDR2 it requires 1 tap(jog) followed by a second tap and hold to initiate a full run.
Lets see if I can represent this more clearly;

1tap L3 followed by a second tap/hold of L3
(L3, 100) (starts the character to jog)
wait(40)
(L3, 0) (release waiting to initiate the final tap and hold of L3)
wait(40)
(L3, 100) (final tap & needs to keep L3 at a full press in order to stay in a full run) at this point we cannot release L3 from the full hold (100) otherwise we stop the run from being initiated or staying active. In RDR2 the "toggle to run" option in settings is unreliable at best. In order to reliably initiate a run, you must use a "Hold" on the second tap of L3.

So far the most reliable way I have found for the "AutoSprint" to work has been under "Standard" controls which require tapping Cross repeatedly to initiate the full run. Which even though I hate that control scheme, I am currently stuck using it as it is more reliable at the moment.


I really dislike the way Rockstar implemented the run system in this game tbh, they should have just kept it the same as they had it in GTAV.
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby Greedoshotlate » Sat Feb 02, 2019 7:52 pm

Here is the script I am currently using with the "Standard" control scheme
Code: Select all
// GPC Online Library
// RDR2_AutoSprintTouchTest.gpc
//  ****** This Version is for Standard Control Layouts **********
//   ********* DO NOT USE FOR "FPS" Controller Lyouts   *************
// Use My Other Script That Has Been Adjusted For "FPS" Controller Layouts Instead
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES DESCRIPTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//----------------------------[ TouchPad Features ]--------------------------------
//Touchpad Swipes require the swipe to be done on the left side of the touchpad     3
//to be registered reliably and consistantly. May take a little to get used to in   3
//practice. I am currently playing around with the possibilities of using the       3
//TouchPad on the DS4. Still not sure why Rockstar didn't utilize the TouchPad more 3
//as they did in GTAV. 
//-----------------------------[ SPRINT FEATURES ]---------------------------------
 
//Included are HAIR TRIGGERS.  Hair Triggers are always activated now with this     0
//version update.                                                                   0
//These "features" are only running when Auto Sprint is activated and done so       1
//purposely.                                                                        1
//______________                                                                    1
//-[AUTO SPRINT]                              [AUTO SPRINT'S Activate/Deactivate]   1
//**************                                                                    1
//Activated/deactivated by Double-click R3/RS(5). Once activated, you sprint in any 1   
//direction you want by pushing the left analog stick in the direction you want to  1   
//go. Works for fast Swimming/Boating/Horseback as well as Carriages. In this       1
//"feature", I've included rumble notifiers and LED's to distinguish when you       1
//activate & when you deactivate the "feature". Within this "feature" are two       1
//other "features" that work best along with Auto Sprint and have very little use   1
//otherwise.If having trouble traversing stairs or don't want to Sprint on horseback 1
//You can either deactivate Auto Sprint (Hold (19) and tap (18)) or just aim your   1
//weapon and point in the direction you want to go in these cases and advance with  1
//no problem. Below I have 2 aternative ways listed along with the currently used   1
//line, which is the first one listed. Should you want to lessen the sensitivity of 1
//the 360 degrees always on (when activated) Auto Sprint, you can try either of     1
//these. You'll want to keep the + numbers + and - numbers -. You can only make the 1                                                                     
//numbers (1-100). Try them out and see what works best for you. Having higher      1
//numbers will allow you to tilt the left analog stick off center more before Auto  1   
//Sprint engages. Be aware that having higher numbers will likely affect swimming   1
//in a negative way.                                                                1                         
//                                                                                  1
//if (get_val(12) <= -75)  //<- CURRENTLY USED LINE.                                1
//*if (get_val(12) < -5 || abs(get_val(11)) > 5 ^^ abs(get_val(11)) < -5 ) {        1                                     
//*if (abs(get_val(12)) > 5 || abs(get_val(11)) > 5) {                              1
//                                                                                  1
//To reload while sprinting, you need to double-tap CIRCLE/B/(18). If standing      1
//still, you only need to press once to reload. I would suggest you to take the     1
//reload option out of the Auto Sprint "feature", if you can do without it.         1
//Leaving it in will allow you to double-tap CIRCLE/B/(18) to reload while          1 
//sprinting. However, it comes at the expense of slowing you down while sprinting   1     
//Reload is slow anyways. I'd suggest you just switch weapons, which is faster than 1
//reloading. The line below, which is in the script, is the one you would remove.   1
//Located in 1st section of AUTO SPRINT.                                            1
//                                                                                  1                                                                                  1
// if (get_val(7) || get_val(4) || get_val(18)) {  // *|| get_val(18)"(reload).     1
//_____________                                                                     
 
//-[HAIR TRIGGERS] (Always Active)                                                  0
//****************                                                                  0
//This "feature" allows the fastest response times on aiming & firing your weapon.  0 
//                                                                                  0
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ DEFINES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//DEFINE (0) | PS4_PS | PS3_PS | XB1_XBOX | XB360_XBOX                 
//DEFINE (1) | PS4_SHARE | PS3_SELECT | XB1_VIEW | XB360_BACK                     
//DEFINE (2) | PS4_OPTIONS | PS3_START | XB1_MENU | XB360_STAR                     
//DEFINE (3) | PS4_R1 | PS3_R1 | XB1_RB | XB360_RB                           
//DEFINE (4) | PS4_R2 | PS3_R2 | XB1_RT | XB360_RT                             
//DEFINE (5) | PS4_R3 | PS3_R3 | XB1_RS | XB360_RS                     Dbl Tap to Activate/Deactivate AutoSprint.                         
//DEFINE (6) | PS4_L1 | PS3_L1 | XB1_LB | XB360_LB                           
//DEFINE (7) | PS4_L2 | PS3_L2 | XB1_LT | XB360_LT                             
//DEFINE (8) | PS4_L3 | PS3_L3 | XB1_LS | XB360_LS                               
//DEFINE (9) | PS4_RX | PS3_RX | XB1_RX | XB360_RX                                 
//DEFINE (10)| PS4_RY | PS3_RY | XB1_RY | XB360_RY                             
//DEFINE (11)| PS4_LX | PS3_LX | XB1_LX | XB360_LX               
//DEFINE (12)| PS4_LY | PS3_LY | XB1_LY | XB360_LY                   
//DEFINE (13)| PS4_UP | PS3_UP | XB1_UP | XB360_UP                               
//DEFINE (14)| PS4_DOWN | PS3_DOWN | XB1_DOWN | XB360_DOWN                     
//DEFINE (15)| PS4_LEFT | PS3_LEFT | XB1_LEFT | XB360_LEFT                               
//DEFINE (16)| PS4_RIGHT | PS3_RIGHT | XB1_RIGHT | XB360_RIGHT                         
//DEFINE (17)| PS4_TRIANGLE | PS3_TRIANGLE | XB1_Y | XB360_Y                     
//DEFINE (18)| PS4_CIRCLE | PS3_CIRCLE | XB1_B | XB360_B                       
//DEFINE (19)| PS4_CROSS | PS3_CROSS | XB1_A | XB360_A               
//DEFINE (20)| PS4_SQUARE | PS3_SQUARE | XB1_X | XB360_X                                             
//DEFINE (27)| PS4_TOUCH | XB1_P4                                                                                       
define SWIPE_NONE   = 0;
define SWIPE_UP     = 1;
define SWIPE_DOWN   = 2;
define SWIPE_RIGHT  = 3;
define SWIPE_LEFT   = 4;   
   //Defines must go at the top of the page.                     
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Int's must go below the defines, but above the init's.   
    int ASOnOff;                                                               //1 
    int Button_Timing;                                                         //2
    int Button_State             = 0;                                          //2
    int Double_Tap_Gap           = 200;     //Gap in between taps. Changeable. //2 
    int SWOnOff;                                                               //1
    int finger_touching;                                                       //3
    int initial_x, initial_y;                                                  //3
    int final_x, final_y;                                                      //3
    int swipe;                                                                 //3
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INIT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 
   //Init's must go below the int's, but before the main{               
    init {                                                                     //1
    SWOnOff         = get_pvar(SPVAR_1, 1, 2, 1);                              //1         
    ASOnOff         = get_pvar(SPVAR_2, 1, 2, 1);                              //1
    }                                                                          //1 
//---------------------------------------------------------------------------------
main{  //Main Start (Goes below init's and before the "features").
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   if(finger_touching) {                                                       //3
        if(!ps4_touchpad(PS4T_P1)) {                                           //3
            finger_touching = 0;                                               //3
            final_y = ps4_touchpad(PS4T_P1X);                                  //3
            final_x = ps4_touchpad(PS4T_P1Y);                                  //3
            swipe = swipe_detect(0);                                           //3
            if(swipe == SWIPE_UP) {                                            //3
               combo_run(DE);                                                  //3 Swipe Up on TouchPad activates DeadEye
            } else if(swipe == SWIPE_DOWN) {                                   //3
                                                                               //3 TODO: Action based on swipe down
            } else if(swipe == SWIPE_LEFT) {                                   //3
                                                                               //3 TODO: Action based on swipe left
            } else if(swipe == SWIPE_RIGHT) {                                  //3
                combo_run(HT);                                                 //3 Swipe Right on TouchPad uses (currently equipped) Health Tonic
            }                                                                  //3
        }                                                                      //3
    } else if(ps4_touchpad(PS4T_P1)) {                                         //3
        finger_touching = 1;                                                   //3
        initial_x = ps4_touchpad(PS4T_P1X);                                    //3
        initial_y = ps4_touchpad(PS4T_P1Y);                                    //3
    }                                                                          //3
   //HAIR TRIGGERS-----------------------------------------------------------------     
    if (get_val(7)) {                                                          //0 
        set_val(7, 100);                                                       //0
    }                                                                          //0   
    if (get_val(16) && event_press(20)) {                                      //0             
        set_val(4, 100);                                                       //0
    }                                                                          //0   
//---------------------------------------------------------------------------------     
   //AUTO SPRINT / RUMBLE NOTIFIERS / LED
   //||  D-pad Right(16)  ||  Circle(18)                                      ///1  Fully Disables/Enables (1 Rumble On, No Rumble Off) The AutoSprint and the Quick On/Off feature of Hold Cross(19) and tap Circle(18)                 
    if (get_val(16) && event_press(18)) {                                     ///1  PS4_Right(hold) & Ps4_Circle(tap) to fully disable or enable the autosprint feature
        if (SWOnOff == 2) {                                                   ///1  This is in here in anticipation for added features in the future.
            SWOnOff = 1;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
        } else if (SWOnOff == 1) {                                             //1
            SWOnOff = 2;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
            combo_run(Rumble);                                                 //1
        }                                                                      //1
    }               //   Cross(19)   ||   Circle(18)                           //1
    if (SWOnOff == 2 && get_val(19) && event_press(18)) {                      //1    PS4_Cross(hold) & PS4_Circle(tap) to Enable/Disable AutoSprint on the fly.                                                                         
    if (ASOnOff == 2) {                                                        //1    One Rumble = Off, Two Rumbles = On or Active
        ASOnOff = 1;                                                           //1 
        set_pvar(SPVAR_2, ASOnOff);                                            //1 
        combo_run(Rumble_2);                                                   //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (ASOnOff == 1) {                                                 //1 
        ASOnOff = 2;                                                           //1
        set_pvar(SPVAR_2, ASOnOff);                                            //1
        combo_run(Rumble_1);                                                   //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (ASOnOff == 2) {                                                        //1 
    if (get_val(12) <= 100){       //360 degrees Auto Sprint.                  //1 
        combo_run(AS);                                                         //1               
    } else {                                                                   //1      No LS input pauses AutoSprint Combo                                   
        combo_stop(AS);                                                        //1         
    }  // || L2(7) ||   R2(4)    ||  Circle(18)                                //1         
    if (get_val(7) || get_val(4) || get_val(18)) {                             //1      Using ADS, Shoot, or Reload pauses AutoSprint Combo
        combo_stop(AS);                                                        //1 
    }                                                                          //1 
}
}  //Main End (Goes after the featured scripts & before the combo's).
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ COMBO'S ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Combo's go after the Main End and before FUNCTIONS.
combo    Rumble      {
    set_rumble(RUMBLE_A, 100);
    wait                (300);
    reset_rumble();
}
 
combo Rumble_1 {     //Notifies you when the "feature" is turned on.           //1/4         
    set_rumble(RUMBLE_B, 51);                                                  //1/4
    wait(300);                                                                 //1/4
    set_rumble(RUMBLE_B, 0);                                                   //1/4   
    wait(300);                                                                 //1/4   
    set_rumble(RUMBLE_B, 51);                                                  //1/4 
    wait(400);                                                                 //1/4   
    reset_rumble();                                                            //1/4
}                                                                              //1/4
combo Rumble_2 {     //Notifies you when the "feature" is shut off.            //1/4 
    set_rumble(RUMBLE_A, 51);                                                  //1/4 
    wait(300);                                                                 //1/4
    reset_rumble();                                                            //1/4
}                                                                              //1/4 
//---------------------------------------------------------------------------------
 
//---------------------------------------------------------------------------------   
//---------------------------------------------------------------------------------
combo AS {                                                                     //1       / AutoSprint Combo for Standard Control Layouts only (Not for "FPS" Variants)
    set_val(19, 100);                                                          //1
    wait(50);                                                                  //1
    set_val(19, 0);                                                            //1
    wait(40);                                                                  //1
}                                                                              //1
combo DE {                                                                     //3    /// DeadEye Combo (Line that is commented out is to make it work even in SinglePlayer mode)
    set_val(7, 100);                                                           //3         Activates with an Up Swipe on the touchpad from the left side of touchpad
    wait(40)                                                                   //3
    set_val(5, 100);                                                           //3
    set_val(7, 100);                                                           //3
    wait(50);                                                                  //3
    set_val(5, 0);                                                             //3
    //set_val(PS4_L2, 0);                                                      //3
    wait(40);                                                                  //3
}                                                                              //3
combo HT {                                                                     //3    ///Health Tonic Combo, You can try to adjust the "wait" timers to try to shave off a few ms in timing, but this is what I found to be optimal
    set_val(6, 100);                                                           //3        in order for the combo to fire off consistently.
    wait(400);                                                                 //3       Activates with a Right swipe starting from the left side of the Touchpad
    set_val(3, 100);                                                           //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(3, 0);                                                             //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(6, 100);                                                           //3
    set_val(9, -34);                                                           //3
    wait(10);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -42);                                                           //3
    set_val(10, -34);                                                          //3
    wait(20);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -65);                                                           //3
    set_val(10, -55);                                                          //3
    wait(200);                                                                 //3
    set_val(6, 0);                                                             //3
    set_val(9, -74);                                                           //3
    set_val(10, -74);                                                          //3
    wait(110);                                                                 //3
    set_val(9, -40);                                                           //3
    set_val(10, -36);                                                          //3
    wait(10);                                                                  //3
    set_val(9, 0);                                                             //3
    set_val(10, 0);                                                            //3
}                                                                              //3
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FUNCTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Functions must be at the bottom of the script.                                           
 function swipe_detect(tmp) {                                                  //3
    tmp = final_y - initial_y;                                                 //3
    if(tmp <= -75) return(SWIPE_UP);                                           //3
    if(tmp >=  75) return(SWIPE_DOWN);                                         //3
    tmp = final_x - initial_x;                                                 //3
    if(tmp <= -75) return(SWIPE_LEFT);                                         //3
    if(tmp >=  75) return(SWIPE_RIGHT);                                        //3
    return(SWIPE_NONE);                                                        //3
}                                                                              //3
function DoubleTap(Button) {                                                   //2
    if(Button_State == 0) {                                                    //2
           if(get_val(Button)) Button_State = 1;                               //2 
    } else if(Button_State == 1) {                                             //2 
           if(!get_val(Button)) { Button_Timing = 0; Button_State = 2; }       //2 
    } else if(Button_State == 2) {                                             //2
           if(get_val(Button)) { Button_State = 1; return TRUE; }              //2 
              Button_Timing = Button_Timing + get_rtime();                     //2
           if(Button_Timing > Double_Tap_Gap) Button_State = 0;                //2
    }                                                                          //2
}                                                                              //2
 



It works well enough, I guess it's biggest plus is that it also works while on horseback or in a vehicle.
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby Greedoshotlate » Sat Feb 02, 2019 7:57 pm

And here is the script I was using for the "StandardFPS" controller layout (which I would prefer to use). I just can't get the "AutoSprint" feature to work properly with a tap, tap/hold of L3. I would pull my hair out if I didn't keep it shaved lol
I even tried commenting out "//" lines 221,222,223 to see if with the new code you shared with me I could get it to work. It did not work sadly.

Code: Select all
// GPC Online Library
// RDR2_AutoSprintTouchFPSTest.gpc
// ****** For Use With The "Standard FPS" Control Layout ********
///   ****   Use my Other Script For All Other Controller Layout Settings **********
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES DESCRIPTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//----------------------------[ TouchPad Features ]--------------------------------
//Touchpad Swipes require the swipe to be done on the left side of the touchpad     3
//to be registered reliably and consistantly. May take a little to get used to in   3
//practice. I am currently playing around with the possibilities of using the       3
//TouchPad on the DS4. Still not sure why Rockstar didn't utilize the TouchPad more 3
//as they did in GTAV. 
//-----------------------------[ SPRINT FEATURES ]---------------------------------
 
//Included are HAIR TRIGGERS.  Hair Triggers are always activated now with this     0
//version update.                                                                   0
//These "features" are only running when Auto Sprint is activated and done so       1
//purposely.                                                                        1
//______________                                                                    1
//-[AUTO SPRINT]                              [AUTO SPRINT'S Activate/Deactivate]   1
//**************                                                                    1
//Activated/deactivated by Double-click R3/RS(5). Once activated, you sprint in any 1   
//direction you want by pushing the left analog stick in the direction you want to  1   
//go. Works for fast Swimming/Boating/Horseback as well as Carriages. In this       1
//"feature", I've included rumble notifiers and LED's to distinguish when you       1
//activate & when you deactivate the "feature". Within this "feature" are two       1
//other "features" that work best along with Auto Sprint and have very little use   1
//otherwise.If having trouble traversing stairs or don't want to Sprint on horseback 1
//You can either deactivate Auto Sprint (Hold (19) and tap (18)) or just aim your   1
//weapon and point in the direction you want to go in these cases and advance with  1
//no problem. Below I have 2 aternative ways listed along with the currently used   1
//line, which is the first one listed. Should you want to lessen the sensitivity of 1
//the 360 degrees always on (when activated) Auto Sprint, you can try either of     1
//these. You'll want to keep the + numbers + and - numbers -. You can only make the 1                                                                     
//numbers (1-100). Try them out and see what works best for you. Having higher      1
//numbers will allow you to tilt the left analog stick off center more before Auto  1   
//Sprint engages. Be aware that having higher numbers will likely affect swimming   1
//in a negative way.                                                                1                         
//                                                                                  1
//if (get_val(12) <= -75)  //<- CURRENTLY USED LINE.                                1
//*if (get_val(12) < -5 || abs(get_val(11)) > 5 ^^ abs(get_val(11)) < -5 ) {        1                                     
//*if (abs(get_val(12)) > 5 || abs(get_val(11)) > 5) {                              1
//                                                                                  1
//To reload while sprinting, you need to double-tap CIRCLE/B/(18). If standing      1
//still, you only need to press once to reload. I would suggest you to take the     1
//reload option out of the Auto Sprint "feature", if you can do without it.         1
//Leaving it in will allow you to double-tap CIRCLE/B/(18) to reload while          1 
//sprinting. However, it comes at the expense of slowing you down while sprinting   1     
//Reload is slow anyways. I'd suggest you just switch weapons, which is faster than 1
//reloading. The line below, which is in the script, is the one you would remove.   1
//Located in 1st section of AUTO SPRINT.                                            1
//                                                                                  1                                                                                  1
// if (get_val(7) || get_val(4) || get_val(18)) {  // *|| get_val(18)"(reload).     1
//_____________                                                                     
 
//-[HAIR TRIGGERS] (Always Active)                                                  0
//****************                                                                  0
//This "feature" allows the fastest response times on aiming & firing your weapon.  0 
//                                                                                  0
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ DEFINES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//DEFINE (0) | PS4_PS | PS3_PS | XB1_XBOX | XB360_XBOX                 
//DEFINE (1) | PS4_SHARE | PS3_SELECT | XB1_VIEW | XB360_BACK                     
//DEFINE (2) | PS4_OPTIONS | PS3_START | XB1_MENU | XB360_STAR                     
//DEFINE (3) | PS4_R1 | PS3_R1 | XB1_RB | XB360_RB                           
//DEFINE (4) | PS4_R2 | PS3_R2 | XB1_RT | XB360_RT                             
//DEFINE (5) | PS4_R3 | PS3_R3 | XB1_RS | XB360_RS                     Dbl Tap to Activate/Deactivate AutoSprint.                         
//DEFINE (6) | PS4_L1 | PS3_L1 | XB1_LB | XB360_LB                           
//DEFINE (7) | PS4_L2 | PS3_L2 | XB1_LT | XB360_LT                             
//DEFINE (8) | PS4_L3 | PS3_L3 | XB1_LS | XB360_LS                               
//DEFINE (9) | PS4_RX | PS3_RX | XB1_RX | XB360_RX                                 
//DEFINE (10)| PS4_RY | PS3_RY | XB1_RY | XB360_RY                             
//DEFINE (11)| PS4_LX | PS3_LX | XB1_LX | XB360_LX               
//DEFINE (12)| PS4_LY | PS3_LY | XB1_LY | XB360_LY                   
//DEFINE (13)| PS4_UP | PS3_UP | XB1_UP | XB360_UP                               
//DEFINE (14)| PS4_DOWN | PS3_DOWN | XB1_DOWN | XB360_DOWN                     
//DEFINE (15)| PS4_LEFT | PS3_LEFT | XB1_LEFT | XB360_LEFT                               
//DEFINE (16)| PS4_RIGHT | PS3_RIGHT | XB1_RIGHT | XB360_RIGHT                         
//DEFINE (17)| PS4_TRIANGLE | PS3_TRIANGLE | XB1_Y | XB360_Y                     
//DEFINE (18)| PS4_CIRCLE | PS3_CIRCLE | XB1_B | XB360_B                       
//DEFINE (19)| PS4_CROSS | PS3_CROSS | XB1_A | XB360_A               
//DEFINE (20)| PS4_SQUARE | PS3_SQUARE | XB1_X | XB360_X                                             
//DEFINE (27)| PS4_TOUCH | XB1_P4                                                                                       
define SWIPE_NONE   = 0;
define SWIPE_UP     = 1;
define SWIPE_DOWN   = 2;
define SWIPE_RIGHT  = 3;
define SWIPE_LEFT   = 4;   
   //Defines must go at the top of the page.                     
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Int's must go below the defines, but above the init's.   
    int ASOnOff;                                                               //1 
    int Button_Timing;                                                         //2
    int Button_State             = 0;                                          //2
    int Double_Tap_Gap           = 200;     //Gap in between taps. Changeable. //2 
    int SWOnOff;                                                               //1
    int finger_touching;                                                       //3
    int initial_x, initial_y;                                                  //3
    int final_x, final_y;                                                      //3
    int swipe;                                                                 //3
    int ASOnce;                                                                //1           ASOnce = AutoSprintOnce
    int TCOnOff;                                                               //4
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INIT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 
   //Init's must go below the int's, but before the main{               
    init {                                                                     //1/4
    SWOnOff         = get_pvar(SPVAR_1, 1, 2, 1);                              //1            SWOnOff = SwitchOnOff   
    ASOnOff         = get_pvar(SPVAR_2, 1, 2, 1);                              //1            ASOnOff = AutoSprintOnOff
    TCOnOff         = get_pvar(SPVAR_3, 1, 2, 1);                              //4            TCOnOff = TurboCrossOnOff
    }                                                                          //1 
//---------------------------------------------------------------------------------
main{  //Main Start (Goes below init's and before the "features").
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   if(finger_touching) {                                                       //3
        if(!ps4_touchpad(PS4T_P1)) {                                           //3
            finger_touching = 0;                                               //3
            final_y = ps4_touchpad(PS4T_P1X);                                  //3
            final_x = ps4_touchpad(PS4T_P1Y);                                  //3
            swipe = swipe_detect(0);                                           //3
            if(swipe == SWIPE_UP) {                                            //3
               combo_run(DE);                                                  //3 Swipe Up on TouchPad activates DeadEye
            } else if(swipe == SWIPE_DOWN) {                                   //3
                                                                               //3 TODO: Action based on swipe down
            } else if(swipe == SWIPE_LEFT) {                                   //3
                                                                               //3 TODO: Action based on swipe left
            } else if(swipe == SWIPE_RIGHT) {                                  //3
                combo_run(HT);                                                 //3 Swipe Right on TouchPad uses (currently equipped) Health Tonic
            }                                                                  //3
        }                                                                      //3
    } else if(ps4_touchpad(PS4T_P1)) {                                         //3
        finger_touching = 1;                                                   //3
        initial_x = ps4_touchpad(PS4T_P1X);                                    //3
        initial_y = ps4_touchpad(PS4T_P1Y);                                    //3
    }                                                                          //3
   //HAIR TRIGGERS-----------------------------------------------------------------     
    if (get_val(7)) {                                                          //0 
        set_val(7, 100);                                                       //0
    }                                                                          //0   
    if (get_val(16) && event_press(20)) {                                      //0             
        set_val(4, 100);                                                       //0
    }                                                                          //0   
//---------------------------------------------------------------------------------     
   //AUTO SPRINT / RUMBLE NOTIFIERS / LED
   //||  D-pad Right(16)  ||  Circle(18)                                      ///1  Fully Disables/Enables (1 Rumble On, No Rumble Off) The AutoSprint and the Quick On/Off feature of Hold Cross(19) and tap Circle(18)                 
    if (get_val(16) && event_press(18)) {                                     ///1  PS4_Right(hold) & Ps4_Circle(tap) to fully disable or enable the autosprint feature
        if (SWOnOff == 2) {                                                   ///1  This is in here in anticipation for added features in the future.
            SWOnOff = 1;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
        } else if (SWOnOff == 1) {                                             //1
            SWOnOff = 2;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
            combo_run(Rumble);                                                 //1
        }                                                                      //1
    }               //   Cross(19)   ||   Circle(18)                           //1
    if (SWOnOff == 2 && get_val(19) && event_press(18)) {                      //1    PS4_Cross(hold) & PS4_Circle(tap) to Enable/Disable AutoSprint on the fly.                                                                         
    if (ASOnOff == 2) {                                                        //1    One Rumble = Off, Two Rumbles = On or Active
        ASOnOff = 1;                                                           //1 
        set_pvar(SPVAR_2, ASOnOff);                                            //1 
        combo_run(Rumble_2);                                                   //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (ASOnOff == 1) {                                                 //1 
        ASOnOff = 2;                                                           //1
        set_pvar(SPVAR_2, ASOnOff);                                            //1
        combo_run(Rumble_1);                                                   //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (ASOnOff == 2) {                                                        //1 
    if (get_val(12) <= -85){       //360 degrees Auto Sprint.                  //1 
        if(!ASOnce) {                                                          //1
        combo_run(AS);                                                         //1
        ASOnce = TRUE;                                                         //1               
    }                                                                          //1
   } else {                                                                    //1      No LS input pauses AutoSprint Combo                                   
        ASOnce = FALSE;                                                        //1         
    }  // || L2(7) ||   R2(4)    ||  Circle(18)                                //1         
    if (get_val(7) || get_val(4) || get_val(18)) {                             //1      Using ADS, Shoot, or Reload pauses AutoSprint Combo
        ASOnce = FALSE;                                                        //1 
    }                                                                          //1 
}
}  //Main End (Goes after the featured scripts & before the combo's).
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ COMBO'S ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Combo's go after the Main End and before FUNCTIONS.
combo    Rumble      {
    set_rumble(RUMBLE_A, 100);
    wait                (300);
    reset_rumble();
}
 
combo Rumble_1 {     //Notifies you when the "feature" is turned on.           //1/4         
    set_rumble(RUMBLE_B, 51);                                                  //1/4
    wait(300);                                                                 //1/4
    set_rumble(RUMBLE_B, 0);                                                   //1/4   
    wait(300);                                                                 //1/4   
    set_rumble(RUMBLE_B, 51);                                                  //1/4 
    wait(400);                                                                 //1/4   
    reset_rumble();                                                            //1/4
}                                                                              //1/4
combo Rumble_2 {     //Notifies you when the "feature" is shut off.            //1/4 
    set_rumble(RUMBLE_A, 51);                                                  //1/4 
    wait(300);                                                                 //1/4
    reset_rumble();                                                            //1/4
}                                                                              //1/4 
//---------------------------------------------------------------------------------
 
//---------------------------------------------------------------------------------   
//---------------------------------------------------------------------------------
combo AS {                                                                     //1     /// AutoSprint Combo configured for Standard FPS control Layout
    set_val(8, 100);                                                           //1
    wait(50);                                                                  //1
    set_val(8, 0);                                                             //1
    wait(40);                                                                  //1
    set_val(8, 100);                                                           //1
    wait(50);                                                                  //1
    set_val(8, 0);                                                             //1
    wait(40);                                                                  //1                                                                             
}                                                                              //1
combo DE {                                                                     //3    /// DeadEye Combo (Line that is commented out is to make it work even in SinglePlayer mode)
    set_val(7, 100);                                                           //3         Activates with an Up Swipe on the touchpad from the left side of touchpad
    wait(40)                                                                   //3
    set_val(5, 100);                                                           //3
    set_val(7, 100);                                                           //3
    wait(50);                                                                  //3
    set_val(5, 0);                                                             //3
    //set_val(PS4_L2, 0);                                                      //3
    wait(40);                                                                  //3
}                                                                              //3
combo HT {                                                                     //3    ///Health Tonic Combo, You can try to adjust the "wait" timers to try to shave off a few ms in timing, but this is what I found to be optimal
    set_val(6, 100);                                                           //3        in order for the combo to fire off consistently.
    wait(400);                                                                 //3       Activates with a Right swipe starting from the left side of the Touchpad
    set_val(3, 100);                                                           //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(3, 0);                                                             //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(6, 100);                                                           //3
    set_val(9, -34);                                                           //3
    wait(10);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -42);                                                           //3
    set_val(10, -34);                                                          //3
    wait(20);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -65);                                                           //3
    set_val(10, -55);                                                          //3
    wait(200);                                                                 //3
    set_val(6, 0);                                                             //3
    set_val(9, -74);                                                           //3
    set_val(10, -74);                                                          //3
    wait(110);                                                                 //3
    set_val(9, -40);                                                           //3
    set_val(10, -36);                                                          //3
    wait(10);                                                                  //3
    set_val(9, 0);                                                             //3
    set_val(10, 0);                                                            //3
}                                                                              //3
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FUNCTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Functions must be at the bottom of the script.                                           
 function swipe_detect(tmp) {                                                  //3
    tmp = final_y - initial_y;                                                 //3
    if(tmp <= -75) return(SWIPE_UP);                                           //3
    if(tmp >=  75) return(SWIPE_DOWN);                                         //3
    tmp = final_x - initial_x;                                                 //3
    if(tmp <= -75) return(SWIPE_LEFT);                                         //3
    if(tmp >=  75) return(SWIPE_RIGHT);                                        //3
    return(SWIPE_NONE);                                                        //3
}                                                                              //3
function DoubleTap(Button) {                                                   //2
    if(Button_State == 0) {                                                    //2
           if(get_val(Button)) Button_State = 1;                               //2 
    } else if(Button_State == 1) {                                             //2 
           if(!get_val(Button)) { Button_Timing = 0; Button_State = 2; }       //2 
    } else if(Button_State == 2) {                                             //2
           if(get_val(Button)) { Button_State = 1; return TRUE; }              //2 
              Button_Timing = Button_Timing + get_rtime();                     //2
           if(Button_Timing > Double_Tap_Gap) Button_State = 0;                //2
    }                                                                          //2
}                                                                              //2
 



I was planning on adding a "TurboCross" feature in for sprinting on horseback etc after I got the autosprint functioning properly, but alas, I am not finished with this script yet.
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby J2Kbr » Mon Feb 04, 2019 12:26 pm

Please try with the changes below (push the left stick forward and press L3 to automatically double tap L3, the ASOnOff variable must have value 2):
Code: Select all
// GPC Online Library
// RDR2_AutoSprintTouchFPSTest.gpc
// ****** For Use With The "Standard FPS" Control Layout ********
///   ****   Use my Other Script For All Other Controller Layout Settings **********
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES DESCRIPTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//----------------------------[ TouchPad Features ]--------------------------------
//Touchpad Swipes require the swipe to be done on the left side of the touchpad     3
//to be registered reliably and consistantly. May take a little to get used to in   3
//practice. I am currently playing around with the possibilities of using the       3
//TouchPad on the DS4. Still not sure why Rockstar didn't utilize the TouchPad more 3
//as they did in GTAV. 
//-----------------------------[ SPRINT FEATURES ]---------------------------------
 
//Included are HAIR TRIGGERS.  Hair Triggers are always activated now with this     0
//version update.                                                                   0
//These "features" are only running when Auto Sprint is activated and done so       1
//purposely.                                                                        1
//______________                                                                    1
//-[AUTO SPRINT]                              [AUTO SPRINT'S Activate/Deactivate]   1
//**************                                                                    1
//Activated/deactivated by Double-click R3/RS(5). Once activated, you sprint in any 1   
//direction you want by pushing the left analog stick in the direction you want to  1   
//go. Works for fast Swimming/Boating/Horseback as well as Carriages. In this       1
//"feature", I've included rumble notifiers and LED's to distinguish when you       1
//activate & when you deactivate the "feature". Within this "feature" are two       1
//other "features" that work best along with Auto Sprint and have very little use   1
//otherwise.If having trouble traversing stairs or don't want to Sprint on horseback 1
//You can either deactivate Auto Sprint (Hold (19) and tap (18)) or just aim your   1
//weapon and point in the direction you want to go in these cases and advance with  1
//no problem. Below I have 2 aternative ways listed along with the currently used   1
//line, which is the first one listed. Should you want to lessen the sensitivity of 1
//the 360 degrees always on (when activated) Auto Sprint, you can try either of     1
//these. You'll want to keep the + numbers + and - numbers -. You can only make the 1                                                                     
//numbers (1-100). Try them out and see what works best for you. Having higher      1
//numbers will allow you to tilt the left analog stick off center more before Auto  1   
//Sprint engages. Be aware that having higher numbers will likely affect swimming   1
//in a negative way.                                                                1                         
//                                                                                  1
//if (get_val(12) <= -75)  //<- CURRENTLY USED LINE.                                1
//*if (get_val(12) < -5 || abs(get_val(11)) > 5 ^^ abs(get_val(11)) < -5 ) {        1                                     
//*if (abs(get_val(12)) > 5 || abs(get_val(11)) > 5) {                              1
//                                                                                  1
//To reload while sprinting, you need to double-tap CIRCLE/B/(18). If standing      1
//still, you only need to press once to reload. I would suggest you to take the     1
//reload option out of the Auto Sprint "feature", if you can do without it.         1
//Leaving it in will allow you to double-tap CIRCLE/B/(18) to reload while          1 
//sprinting. However, it comes at the expense of slowing you down while sprinting   1     
//Reload is slow anyways. I'd suggest you just switch weapons, which is faster than 1
//reloading. The line below, which is in the script, is the one you would remove.   1
//Located in 1st section of AUTO SPRINT.                                            1
//                                                                                  1                                                                                  1
// if (get_val(7) || get_val(4) || get_val(18)) {  // *|| get_val(18)"(reload).     1
//_____________                                                                     
 
//-[HAIR TRIGGERS] (Always Active)                                                  0
//****************                                                                  0
//This "feature" allows the fastest response times on aiming & firing your weapon.  0 
//                                                                                  0
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ DEFINES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//DEFINE (0) | PS4_PS | PS3_PS | XB1_XBOX | XB360_XBOX                 
//DEFINE (1) | PS4_SHARE | PS3_SELECT | XB1_VIEW | XB360_BACK                     
//DEFINE (2) | PS4_OPTIONS | PS3_START | XB1_MENU | XB360_STAR                     
//DEFINE (3) | PS4_R1 | PS3_R1 | XB1_RB | XB360_RB                           
//DEFINE (4) | PS4_R2 | PS3_R2 | XB1_RT | XB360_RT                             
//DEFINE (5) | PS4_R3 | PS3_R3 | XB1_RS | XB360_RS                     Dbl Tap to Activate/Deactivate AutoSprint.                         
//DEFINE (6) | PS4_L1 | PS3_L1 | XB1_LB | XB360_LB                           
//DEFINE (7) | PS4_L2 | PS3_L2 | XB1_LT | XB360_LT                             
//DEFINE (8) | PS4_L3 | PS3_L3 | XB1_LS | XB360_LS                               
//DEFINE (9) | PS4_RX | PS3_RX | XB1_RX | XB360_RX                                 
//DEFINE (10)| PS4_RY | PS3_RY | XB1_RY | XB360_RY                             
//DEFINE (11)| PS4_LX | PS3_LX | XB1_LX | XB360_LX               
//DEFINE (12)| PS4_LY | PS3_LY | XB1_LY | XB360_LY                   
//DEFINE (13)| PS4_UP | PS3_UP | XB1_UP | XB360_UP                               
//DEFINE (14)| PS4_DOWN | PS3_DOWN | XB1_DOWN | XB360_DOWN                     
//DEFINE (15)| PS4_LEFT | PS3_LEFT | XB1_LEFT | XB360_LEFT                               
//DEFINE (16)| PS4_RIGHT | PS3_RIGHT | XB1_RIGHT | XB360_RIGHT                         
//DEFINE (17)| PS4_TRIANGLE | PS3_TRIANGLE | XB1_Y | XB360_Y                     
//DEFINE (18)| PS4_CIRCLE | PS3_CIRCLE | XB1_B | XB360_B                       
//DEFINE (19)| PS4_CROSS | PS3_CROSS | XB1_A | XB360_A               
//DEFINE (20)| PS4_SQUARE | PS3_SQUARE | XB1_X | XB360_X                                             
//DEFINE (27)| PS4_TOUCH | XB1_P4                                                                                       
define SWIPE_NONE   = 0;
define SWIPE_UP     = 1;
define SWIPE_DOWN   = 2;
define SWIPE_RIGHT  = 3;
define SWIPE_LEFT   = 4;   
   //Defines must go at the top of the page.                     
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Int's must go below the defines, but above the init's.   
    int ASOnOff;                                                               //1 
    int Button_Timing;                                                         //2
    int Button_State             = 0;                                          //2
    int Double_Tap_Gap           = 200;     //Gap in between taps. Changeable. //2 
    int SWOnOff;                                                               //1
    int finger_touching;                                                       //3
    int initial_x, initial_y;                                                  //3
    int final_x, final_y;                                                      //3
    int swipe;                                                                 //3
    int ASOnce;                                                                //1           ASOnce = AutoSprintOnce
    int TCOnOff;                                                               //4
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INIT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 
   //Init's must go below the int's, but before the main{               
    init {                                                                     //1/4
    SWOnOff         = get_pvar(SPVAR_1, 1, 2, 1);                              //1            SWOnOff = SwitchOnOff   
    ASOnOff         = get_pvar(SPVAR_2, 1, 2, 1);                              //1            ASOnOff = AutoSprintOnOff
    TCOnOff         = get_pvar(SPVAR_3, 1, 2, 1);                              //4            TCOnOff = TurboCrossOnOff
    }                                                                          //1 
//---------------------------------------------------------------------------------
main{  //Main Start (Goes below init's and before the "features").
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   if(finger_touching) {                                                       //3
        if(!ps4_touchpad(PS4T_P1)) {                                           //3
            finger_touching = 0;                                               //3
            final_y = ps4_touchpad(PS4T_P1X);                                  //3
            final_x = ps4_touchpad(PS4T_P1Y);                                  //3
            swipe = swipe_detect(0);                                           //3
            if(swipe == SWIPE_UP) {                                            //3
               combo_run(DE);                                                  //3 Swipe Up on TouchPad activates DeadEye
            } else if(swipe == SWIPE_DOWN) {                                   //3
                                                                               //3 TODO: Action based on swipe down
            } else if(swipe == SWIPE_LEFT) {                                   //3
                                                                               //3 TODO: Action based on swipe left
            } else if(swipe == SWIPE_RIGHT) {                                  //3
                combo_run(HT);                                                 //3 Swipe Right on TouchPad uses (currently equipped) Health Tonic
            }                                                                  //3
        }                                                                      //3
    } else if(ps4_touchpad(PS4T_P1)) {                                         //3
        finger_touching = 1;                                                   //3
        initial_x = ps4_touchpad(PS4T_P1X);                                    //3
        initial_y = ps4_touchpad(PS4T_P1Y);                                    //3
    }                                                                          //3
   //HAIR TRIGGERS-----------------------------------------------------------------     
    if (get_val(7)) {                                                          //0 
        set_val(7, 100);                                                       //0
    }                                                                          //0   
    if (get_val(16) && event_press(20)) {                                      //0             
        set_val(4, 100);                                                       //0
    }                                                                          //0   
//---------------------------------------------------------------------------------     
   //AUTO SPRINT / RUMBLE NOTIFIERS / LED
   //||  D-pad Right(16)  ||  Circle(18)                                      ///1  Fully Disables/Enables (1 Rumble On, No Rumble Off) The AutoSprint and the Quick On/Off feature of Hold Cross(19) and tap Circle(18)                 
    if (get_val(16) && event_press(18)) {                                     ///1  PS4_Right(hold) & Ps4_Circle(tap) to fully disable or enable the autosprint feature
        if (SWOnOff == 2) {                                                   ///1  This is in here in anticipation for added features in the future.
            SWOnOff = 1;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
        } else if (SWOnOff == 1) {                                             //1
            SWOnOff = 2;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
            combo_run(Rumble);                                                 //1
        }                                                                      //1
    }               //   Cross(19)   ||   Circle(18)                           //1
    if (SWOnOff == 2 && get_val(19) && event_press(18)) {                      //1    PS4_Cross(hold) & PS4_Circle(tap) to Enable/Disable AutoSprint on the fly.                                                                         
    if (ASOnOff == 2) {                                                        //1    One Rumble = Off, Two Rumbles = On or Active
        ASOnOff = 1;                                                           //1 
        set_pvar(SPVAR_2, ASOnOff);                                            //1 
        combo_run(Rumble_2);                                                   //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (ASOnOff == 1) {                                                 //1 
        ASOnOff = 2;                                                           //1
        set_pvar(SPVAR_2, ASOnOff);                                            //1
        combo_run(Rumble_1);                                                   //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (ASOnOff == 2) {                                                        //1 
        if (get_val(12) <= -35){       //360 degrees Auto Sprint.              //1 
            if(event_press(PS4_L3)) {                                          //1
                combo_run(AS);                                                 //1
                ASOnce = TRUE;                                                 //1               
            }                                                                  //1
        } else {                                                               //1      No LS input pauses AutoSprint Combo                                   
            ASOnce = FALSE;                                                    //1         
        }  // || L2(7) ||   R2(4)    ||  Circle(18)                            //1         
        if (get_val(7) || get_val(4) || get_val(18)) {                         //1      Using ADS, Shoot, or Reload pauses AutoSprint Combo
            ASOnce = FALSE;                                                    //1 
        }                                                                      //1 
    }
}  //Main End (Goes after the featured scripts & before the combo's).
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ COMBO'S ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Combo's go after the Main End and before FUNCTIONS.
combo    Rumble      {
    set_rumble(RUMBLE_A, 100);
    wait                (300);
    reset_rumble();
}
 
combo Rumble_1 {     //Notifies you when the "feature" is turned on.           //1/4         
    set_rumble(RUMBLE_B, 51);                                                  //1/4
    wait(300);                                                                 //1/4
    set_rumble(RUMBLE_B, 0);                                                   //1/4   
    wait(300);                                                                 //1/4   
    set_rumble(RUMBLE_B, 51);                                                  //1/4 
    wait(400);                                                                 //1/4   
    reset_rumble();                                                            //1/4
}                                                                              //1/4
combo Rumble_2 {     //Notifies you when the "feature" is shut off.            //1/4 
    set_rumble(RUMBLE_A, 51);                                                  //1/4 
    wait(300);                                                                 //1/4
    reset_rumble();                                                            //1/4
}                                                                              //1/4 
//---------------------------------------------------------------------------------
 
//---------------------------------------------------------------------------------   
//---------------------------------------------------------------------------------
combo AS {                                                                     //1     /// AutoSprint Combo configured for Standard FPS control Layout
    set_val(8, 100);                                                           //1
    wait(50);                                                                  //1
    set_val(8, 0);                                                             //1
    wait(40);                                                                  //1
    set_val(8, 100);                                                           //1
    wait(50);                                                                  //1
    set_val(8, 0);                                                             //1
    wait(40);                                                                  //1                                                                             
}                                                                              //1
combo DE {                                                                     //3    /// DeadEye Combo (Line that is commented out is to make it work even in SinglePlayer mode)
    set_val(7, 100);                                                           //3         Activates with an Up Swipe on the touchpad from the left side of touchpad
    wait(40)                                                                   //3
    set_val(5, 100);                                                           //3
    set_val(7, 100);                                                           //3
    wait(50);                                                                  //3
    set_val(5, 0);                                                             //3
    //set_val(PS4_L2, 0);                                                      //3
    wait(40);                                                                  //3
}                                                                              //3
combo HT {                                                                     //3    ///Health Tonic Combo, You can try to adjust the "wait" timers to try to shave off a few ms in timing, but this is what I found to be optimal
    set_val(6, 100);                                                           //3        in order for the combo to fire off consistently.
    wait(400);                                                                 //3       Activates with a Right swipe starting from the left side of the Touchpad
    set_val(3, 100);                                                           //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(3, 0);                                                             //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(6, 100);                                                           //3
    set_val(9, -34);                                                           //3
    wait(10);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -42);                                                           //3
    set_val(10, -34);                                                          //3
    wait(20);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -65);                                                           //3
    set_val(10, -55);                                                          //3
    wait(200);                                                                 //3
    set_val(6, 0);                                                             //3
    set_val(9, -74);                                                           //3
    set_val(10, -74);                                                          //3
    wait(110);                                                                 //3
    set_val(9, -40);                                                           //3
    set_val(10, -36);                                                          //3
    wait(10);                                                                  //3
    set_val(9, 0);                                                             //3
    set_val(10, 0);                                                            //3
}                                                                              //3
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FUNCTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Functions must be at the bottom of the script.                                           
 function swipe_detect(tmp) {                                                  //3
    tmp = final_y - initial_y;                                                 //3
    if(tmp <= -75) return(SWIPE_UP);                                           //3
    if(tmp >=  75) return(SWIPE_DOWN);                                         //3
    tmp = final_x - initial_x;                                                 //3
    if(tmp <= -75) return(SWIPE_LEFT);                                         //3
    if(tmp >=  75) return(SWIPE_RIGHT);                                        //3
    return(SWIPE_NONE);                                                        //3
}                                                                              //3
function DoubleTap(Button) {                                                   //2
    if(Button_State == 0) {                                                    //2
           if(get_val(Button)) Button_State = 1;                               //2 
    } else if(Button_State == 1) {                                             //2 
           if(!get_val(Button)) { Button_Timing = 0; Button_State = 2; }       //2 
    } else if(Button_State == 2) {                                             //2
           if(get_val(Button)) { Button_State = 1; return TRUE; }              //2 
              Button_Timing = Button_Timing + get_rtime();                     //2
           if(Button_Timing > Double_Tap_Gap) Button_State = 0;                //2
    }                                                                          //2
}                                                                              //2
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Need help with an Auto Sprint script

Postby Greedoshotlate » Mon Feb 04, 2019 6:35 pm

Please try with the changes below (push the left stick forward and press L3 to automatically double tap L3, the ASOnOff variable must have value 2):


That didn't work either sadly. Same issue as before. It puts the character into jog (single tap of L3) and most the time he falls right out of jog into a normal walk. I really think it is a flaw in the way Rockstar implemented the running feature tbh. With Standard FPS controls the only reliable way to run is Tap L3, Hold L3. Or at least in my experience.


Thank you for the help in any case, it is greatly appreciated :joia:
User avatar
Greedoshotlate
First Sergeant
First Sergeant
 
Posts: 49
Joined: Tue Jun 21, 2016 2:34 pm

Re: Need help with an Auto Sprint script

Postby J2Kbr » Wed Feb 06, 2019 9:01 am

After the first press, the second should be L3 hold right? The script was just tapping the second L3, I changed the script to hold:
Code: Select all
// GPC Online Library
// RDR2_AutoSprintTouchFPSTest.gpc
// ****** For Use With The "Standard FPS" Control Layout ********
///   ****   Use my Other Script For All Other Controller Layout Settings **********
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES DESCRIPTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//----------------------------[ TouchPad Features ]--------------------------------
//Touchpad Swipes require the swipe to be done on the left side of the touchpad     3
//to be registered reliably and consistantly. May take a little to get used to in   3
//practice. I am currently playing around with the possibilities of using the       3
//TouchPad on the DS4. Still not sure why Rockstar didn't utilize the TouchPad more 3
//as they did in GTAV. 
//-----------------------------[ SPRINT FEATURES ]---------------------------------
 
//Included are HAIR TRIGGERS.  Hair Triggers are always activated now with this     0
//version update.                                                                   0
//These "features" are only running when Auto Sprint is activated and done so       1
//purposely.                                                                        1
//______________                                                                    1
//-[AUTO SPRINT]                              [AUTO SPRINT'S Activate/Deactivate]   1
//**************                                                                    1
//Activated/deactivated by Double-click R3/RS(5). Once activated, you sprint in any 1   
//direction you want by pushing the left analog stick in the direction you want to  1   
//go. Works for fast Swimming/Boating/Horseback as well as Carriages. In this       1
//"feature", I've included rumble notifiers and LED's to distinguish when you       1
//activate & when you deactivate the "feature". Within this "feature" are two       1
//other "features" that work best along with Auto Sprint and have very little use   1
//otherwise.If having trouble traversing stairs or don't want to Sprint on horseback 1
//You can either deactivate Auto Sprint (Hold (19) and tap (18)) or just aim your   1
//weapon and point in the direction you want to go in these cases and advance with  1
//no problem. Below I have 2 aternative ways listed along with the currently used   1
//line, which is the first one listed. Should you want to lessen the sensitivity of 1
//the 360 degrees always on (when activated) Auto Sprint, you can try either of     1
//these. You'll want to keep the + numbers + and - numbers -. You can only make the 1                                                                     
//numbers (1-100). Try them out and see what works best for you. Having higher      1
//numbers will allow you to tilt the left analog stick off center more before Auto  1   
//Sprint engages. Be aware that having higher numbers will likely affect swimming   1
//in a negative way.                                                                1                         
//                                                                                  1
//if (get_val(12) <= -75)  //<- CURRENTLY USED LINE.                                1
//*if (get_val(12) < -5 || abs(get_val(11)) > 5 ^^ abs(get_val(11)) < -5 ) {        1                                     
//*if (abs(get_val(12)) > 5 || abs(get_val(11)) > 5) {                              1
//                                                                                  1
//To reload while sprinting, you need to double-tap CIRCLE/B/(18). If standing      1
//still, you only need to press once to reload. I would suggest you to take the     1
//reload option out of the Auto Sprint "feature", if you can do without it.         1
//Leaving it in will allow you to double-tap CIRCLE/B/(18) to reload while          1 
//sprinting. However, it comes at the expense of slowing you down while sprinting   1     
//Reload is slow anyways. I'd suggest you just switch weapons, which is faster than 1
//reloading. The line below, which is in the script, is the one you would remove.   1
//Located in 1st section of AUTO SPRINT.                                            1
//                                                                                  1                                                                                  1
// if (get_val(7) || get_val(4) || get_val(18)) {  // *|| get_val(18)"(reload).     1
//_____________                                                                     
 
//-[HAIR TRIGGERS] (Always Active)                                                  0
//****************                                                                  0
//This "feature" allows the fastest response times on aiming & firing your weapon.  0 
//                                                                                  0
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ DEFINES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
//DEFINE (0) | PS4_PS | PS3_PS | XB1_XBOX | XB360_XBOX                 
//DEFINE (1) | PS4_SHARE | PS3_SELECT | XB1_VIEW | XB360_BACK                     
//DEFINE (2) | PS4_OPTIONS | PS3_START | XB1_MENU | XB360_STAR                     
//DEFINE (3) | PS4_R1 | PS3_R1 | XB1_RB | XB360_RB                           
//DEFINE (4) | PS4_R2 | PS3_R2 | XB1_RT | XB360_RT                             
//DEFINE (5) | PS4_R3 | PS3_R3 | XB1_RS | XB360_RS                     Dbl Tap to Activate/Deactivate AutoSprint.                         
//DEFINE (6) | PS4_L1 | PS3_L1 | XB1_LB | XB360_LB                           
//DEFINE (7) | PS4_L2 | PS3_L2 | XB1_LT | XB360_LT                             
//DEFINE (8) | PS4_L3 | PS3_L3 | XB1_LS | XB360_LS                               
//DEFINE (9) | PS4_RX | PS3_RX | XB1_RX | XB360_RX                                 
//DEFINE (10)| PS4_RY | PS3_RY | XB1_RY | XB360_RY                             
//DEFINE (11)| PS4_LX | PS3_LX | XB1_LX | XB360_LX               
//DEFINE (12)| PS4_LY | PS3_LY | XB1_LY | XB360_LY                   
//DEFINE (13)| PS4_UP | PS3_UP | XB1_UP | XB360_UP                               
//DEFINE (14)| PS4_DOWN | PS3_DOWN | XB1_DOWN | XB360_DOWN                     
//DEFINE (15)| PS4_LEFT | PS3_LEFT | XB1_LEFT | XB360_LEFT                               
//DEFINE (16)| PS4_RIGHT | PS3_RIGHT | XB1_RIGHT | XB360_RIGHT                         
//DEFINE (17)| PS4_TRIANGLE | PS3_TRIANGLE | XB1_Y | XB360_Y                     
//DEFINE (18)| PS4_CIRCLE | PS3_CIRCLE | XB1_B | XB360_B                       
//DEFINE (19)| PS4_CROSS | PS3_CROSS | XB1_A | XB360_A               
//DEFINE (20)| PS4_SQUARE | PS3_SQUARE | XB1_X | XB360_X                                             
//DEFINE (27)| PS4_TOUCH | XB1_P4                                                                                       
define SWIPE_NONE   = 0;
define SWIPE_UP     = 1;
define SWIPE_DOWN   = 2;
define SWIPE_RIGHT  = 3;
define SWIPE_LEFT   = 4;   
   //Defines must go at the top of the page.                     
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Int's must go below the defines, but above the init's.   
    int ASOnOff;                                                               //1 
    int Button_Timing;                                                         //2
    int Button_State             = 0;                                          //2
    int Double_Tap_Gap           = 200;     //Gap in between taps. Changeable. //2 
    int SWOnOff;                                                               //1
    int finger_touching;                                                       //3
    int initial_x, initial_y;                                                  //3
    int final_x, final_y;                                                      //3
    int swipe;                                                                 //3
    int ASOnce;                                                                //1           ASOnce = AutoSprintOnce
    int TCOnOff;                                                               //4
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ INIT's ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 
   //Init's must go below the int's, but before the main{               
    init {                                                                     //1/4
    SWOnOff         = get_pvar(SPVAR_1, 1, 2, 1);                              //1            SWOnOff = SwitchOnOff   
    ASOnOff         = get_pvar(SPVAR_2, 1, 2, 1);                              //1            ASOnOff = AutoSprintOnOff
    TCOnOff         = get_pvar(SPVAR_3, 1, 2, 1);                              //4            TCOnOff = TurboCrossOnOff
    }                                                                          //1 
//---------------------------------------------------------------------------------
main{  //Main Start (Goes below init's and before the "features").
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FEATURES ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   if(finger_touching) {                                                       //3
        if(!ps4_touchpad(PS4T_P1)) {                                           //3
            finger_touching = 0;                                               //3
            final_y = ps4_touchpad(PS4T_P1X);                                  //3
            final_x = ps4_touchpad(PS4T_P1Y);                                  //3
            swipe = swipe_detect(0);                                           //3
            if(swipe == SWIPE_UP) {                                            //3
               combo_run(DE);                                                  //3 Swipe Up on TouchPad activates DeadEye
            } else if(swipe == SWIPE_DOWN) {                                   //3
                                                                               //3 TODO: Action based on swipe down
            } else if(swipe == SWIPE_LEFT) {                                   //3
                                                                               //3 TODO: Action based on swipe left
            } else if(swipe == SWIPE_RIGHT) {                                  //3
                combo_run(HT);                                                 //3 Swipe Right on TouchPad uses (currently equipped) Health Tonic
            }                                                                  //3
        }                                                                      //3
    } else if(ps4_touchpad(PS4T_P1)) {                                         //3
        finger_touching = 1;                                                   //3
        initial_x = ps4_touchpad(PS4T_P1X);                                    //3
        initial_y = ps4_touchpad(PS4T_P1Y);                                    //3
    }                                                                          //3
   //HAIR TRIGGERS-----------------------------------------------------------------     
    if (get_val(7)) {                                                          //0 
        set_val(7, 100);                                                       //0
    }                                                                          //0   
    if (get_val(16) && event_press(20)) {                                      //0             
        set_val(4, 100);                                                       //0
    }                                                                          //0   
//---------------------------------------------------------------------------------     
   //AUTO SPRINT / RUMBLE NOTIFIERS / LED
   //||  D-pad Right(16)  ||  Circle(18)                                      ///1  Fully Disables/Enables (1 Rumble On, No Rumble Off) The AutoSprint and the Quick On/Off feature of Hold Cross(19) and tap Circle(18)                 
    if (get_val(16) && event_press(18)) {                                     ///1  PS4_Right(hold) & Ps4_Circle(tap) to fully disable or enable the autosprint feature
        if (SWOnOff == 2) {                                                   ///1  This is in here in anticipation for added features in the future.
            SWOnOff = 1;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
        } else if (SWOnOff == 1) {                                             //1
            SWOnOff = 2;                                                       //1
            set_pvar(SPVAR_1, SWOnOff);                                        //1
            combo_run(Rumble);                                                 //1
        }                                                                      //1
    }               //   Cross(19)   ||   Circle(18)                           //1
    if (SWOnOff == 2 && get_val(19) && event_press(18)) {                      //1    PS4_Cross(hold) & PS4_Circle(tap) to Enable/Disable AutoSprint on the fly.                                                                         
    if (ASOnOff == 2) {                                                        //1    One Rumble = Off, Two Rumbles = On or Active
        ASOnOff = 1;                                                           //1 
        set_pvar(SPVAR_2, ASOnOff);                                            //1 
        combo_run(Rumble_2);                                                   //1 
        set_led(LED_3, 0);                                                     //1 
    } else if (ASOnOff == 1) {                                                 //1 
        ASOnOff = 2;                                                           //1
        set_pvar(SPVAR_2, ASOnOff);                                            //1
        combo_run(Rumble_1);                                                   //1 
        set_led(LED_3, 1);                                                     //1 
        }                                                                      //1 
    }                                                                          //1 
    if (ASOnOff == 2) {                                                        //1 
        if (get_val(12) <= -35){       //360 degrees Auto Sprint.              //1 
            if(event_press(PS4_L3)) {                                          //1
                combo_run(AS);                                                 //1
                ASOnce = TRUE;                                                 //1               
            }                                                                  //1
            if(ASOnce) {
                set_val(8, 100);
            }
        } else {                                                               //1      No LS input pauses AutoSprint Combo                                   
            ASOnce = FALSE;                                                    //1         
        }  // || L2(7) ||   R2(4)    ||  Circle(18)                            //1         
        if (get_val(7) || get_val(4) || get_val(18)) {                         //1      Using ADS, Shoot, or Reload pauses AutoSprint Combo
            ASOnce = FALSE;                                                    //1 
        }                                                                      //1 
    }
}  //Main End (Goes after the featured scripts & before the combo's).
 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ COMBO'S ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Combo's go after the Main End and before FUNCTIONS.
combo    Rumble      {
    set_rumble(RUMBLE_A, 100);
    wait                (300);
    reset_rumble();
}
 
combo Rumble_1 {     //Notifies you when the "feature" is turned on.           //1/4         
    set_rumble(RUMBLE_B, 51);                                                  //1/4
    wait(300);                                                                 //1/4
    set_rumble(RUMBLE_B, 0);                                                   //1/4   
    wait(300);                                                                 //1/4   
    set_rumble(RUMBLE_B, 51);                                                  //1/4 
    wait(400);                                                                 //1/4   
    reset_rumble();                                                            //1/4
}                                                                              //1/4
combo Rumble_2 {     //Notifies you when the "feature" is shut off.            //1/4 
    set_rumble(RUMBLE_A, 51);                                                  //1/4 
    wait(300);                                                                 //1/4
    reset_rumble();                                                            //1/4
}                                                                              //1/4 
//---------------------------------------------------------------------------------
 
//---------------------------------------------------------------------------------   
//---------------------------------------------------------------------------------
combo AS {                                                                     //1     /// AutoSprint Combo configured for Standard FPS control Layout
    set_val(8, 100);                                                           //1
    wait(50);                                                                  //1
    set_val(8, 0);                                                             //1
    wait(40);                                                                  //1
    set_val(8, 0);
}                                                                              //1
combo DE {                                                                     //3    /// DeadEye Combo (Line that is commented out is to make it work even in SinglePlayer mode)
    set_val(7, 100);                                                           //3         Activates with an Up Swipe on the touchpad from the left side of touchpad
    wait(40)                                                                   //3
    set_val(5, 100);                                                           //3
    set_val(7, 100);                                                           //3
    wait(50);                                                                  //3
    set_val(5, 0);                                                             //3
    //set_val(PS4_L2, 0);                                                      //3
    wait(40);                                                                  //3
}                                                                              //3
combo HT {                                                                     //3    ///Health Tonic Combo, You can try to adjust the "wait" timers to try to shave off a few ms in timing, but this is what I found to be optimal
    set_val(6, 100);                                                           //3        in order for the combo to fire off consistently.
    wait(400);                                                                 //3       Activates with a Right swipe starting from the left side of the Touchpad
    set_val(3, 100);                                                           //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(3, 0);                                                             //3
    set_val(6, 100);                                                           //3
    wait(100);                                                                 //3
    set_val(6, 100);                                                           //3
    set_val(9, -34);                                                           //3
    wait(10);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -42);                                                           //3
    set_val(10, -34);                                                          //3
    wait(20);                                                                  //3
    set_val(6, 100);                                                           //3
    set_val(9, -65);                                                           //3
    set_val(10, -55);                                                          //3
    wait(200);                                                                 //3
    set_val(6, 0);                                                             //3
    set_val(9, -74);                                                           //3
    set_val(10, -74);                                                          //3
    wait(110);                                                                 //3
    set_val(9, -40);                                                           //3
    set_val(10, -36);                                                          //3
    wait(10);                                                                  //3
    set_val(9, 0);                                                             //3
    set_val(10, 0);                                                            //3
}                                                                              //3
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ FUNCTIONS ]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
   //Functions must be at the bottom of the script.                                           
 function swipe_detect(tmp) {                                                  //3
    tmp = final_y - initial_y;                                                 //3
    if(tmp <= -75) return(SWIPE_UP);                                           //3
    if(tmp >=  75) return(SWIPE_DOWN);                                         //3
    tmp = final_x - initial_x;                                                 //3
    if(tmp <= -75) return(SWIPE_LEFT);                                         //3
    if(tmp >=  75) return(SWIPE_RIGHT);                                        //3
    return(SWIPE_NONE);                                                        //3
}                                                                              //3
function DoubleTap(Button) {                                                   //2
    if(Button_State == 0) {                                                    //2
           if(get_val(Button)) Button_State = 1;                               //2 
    } else if(Button_State == 1) {                                             //2 
           if(!get_val(Button)) { Button_Timing = 0; Button_State = 2; }       //2 
    } else if(Button_State == 2) {                                             //2
           if(get_val(Button)) { Button_State = 1; return TRUE; }              //2 
              Button_Timing = Button_Timing + get_rtime();                     //2
           if(Button_Timing > Double_Tap_Gap) Button_State = 0;                //2
    }                                                                          //2
}                                                                              //2
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Next

Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 92 guests