Double forward push L-stick condition help please

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

Double forward push L-stick condition help please

Postby Sparky101 » Wed Apr 07, 2021 11:33 am

Double forward-push L-stick condition help please

I'm trying to write an autowalk function when the Left Stick is pushed forwards twice in a row a short time apart, but I'm having trouble with writing the condition.

tia :)
User avatar
Sparky101
Sergeant Major
Sergeant Major
 
Posts: 94
Joined: Sun Sep 24, 2017 11:54 am

Re: Double forward push L-stick condition help please

Postby Mad » Wed Apr 07, 2021 9:35 pm

ConsoleTuner Support Team || Discord || YouTube || Twitter
Mad
Major General
Major General
 
Posts: 3293
Joined: Wed May 22, 2019 5:39 am

Re: Double forward push L-stick condition help please

Postby Sparky101 » Thu Apr 08, 2021 9:20 am

Thanks, but although this 'kinda' works it will create issues that make it unusable, perhaps because it was written mainly for buttons and not sticks. Please let me explain...

The problem:

I used this code to do some testing (for full code goto end of post):

Code: Select all
    if(event_active(PS4_LY) && time_release(PS4_LY) < 400)  {
        auto_walk = 1;
    }
 


The main problem with this is that a double-push of the Left Stick in *any* direction with *any* distance (i.e. how far one pushes the stick from centre to the edge) will trigger the autowalk.

List of example issues:
    Push left stick Forwards and then Backwards: this triggers the autowalk.
    Push left stick Left and then Right: this triggers the autowalk.
    Push left stick Left and then Forwards: this triggers the autowalk.
    Do *any* of the above with distance (from centre of the stick) of as little as say 20%: this triggers the autowalk.

And in a combat game like Ghost of Tsushima, heavily using left stick in combat will trigger the auto-walk regularly and so just won't work.


The solution?

Thinking more on the requirements, a good solution would work with the following definition:

"Pushing the Left Stick forwards" means:
    a) Pushing the Left Stick forwards give or take, say, 40 degress from 0 degress (i.e. the top of the stick, or 'due North').
    b) Pushing the Left Stick forwards at least, say, 80% distance from centre of Stick resting place, to the outer edge of the stick range.
    c) Optionally, it would be nice to be able to tweak the following:
    ------- "40 degress from 0 degress"
    ------- "80% distance from centre of Stick resting place"

Also, the left stick should return to within, say, <= 5% of the centre point between pushing the left stick forwards twice to enable the condition to trigger.


I'm not sure if this is possible, but I would find it useful.



This is the full code I have currently:


Code: Select all
// ================================================================
// Ghost of Tsushima - autowalk v1.2
// ================================================================
//
// Autorun
// ========
// To start: press L3 whist running (whilst Left Stick is forwards)
// To stop: press Circle OR Left Stick down
//
// Auto-walk
// ========
// To start: Push L Stick forwards twice
// To stop: press Circle OR Left Stick down
//
 
#pragma METAINFO("", 1, 0, "Tsushima_Autowalk")
#include <ps4.gph>
bool auto_run;   
bool auto_walk;
main {
 
    ///////////////////////////////////////////////////////////////
    // detect ON input
    ///////////////////////////////////////////////////////////////
    if(is_active(PS4_LY) && is_active(PS4_L3)) {
        auto_run = 1;
    }
 
 
    if(event_active(PS4_LY) && time_release(PS4_LY) < 400)  {
        // INTENTION: if double push L3 forwards >=80% then autowalk
        auto_walk = 1;
    }
 
    if(is_active(PS4_L3)) {
        // If L3 pressed, disable Cross button
        set_val(PS4_CROSS ,0);
 
        // and iff Cross pressed, enable autowalk
        if(is_active(PS4_CROSS)) {auto_walk = 1;}
    }
 
    if(is_active(PS4_RIGHT)) {
        auto_walk = 1;
    }
 
    ///////////////////////////////////////////////////////////////
    // set output
    ///////////////////////////////////////////////////////////////
    if(auto_run) set_val(PS4_LY, -100);
 
    if(auto_walk) set_val(PS4_LY, -100);   
 
 
    ///////////////////////////////////////////////////////////////
    // detect OFF input
    ///////////////////////////////////////////////////////////////
    if(is_active(PS4_CIRCLE)) {
        auto_run = 0;
        auto_walk = 0;
    }
 
    if(get_actual(PS4_LY) >= 85f) {
        auto_run = 0;
        auto_walk = 0;
    }
 
 
}




tia for any help :)
User avatar
Sparky101
Sergeant Major
Sergeant Major
 
Posts: 94
Joined: Sun Sep 24, 2017 11:54 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 18 guests