Force combo to complete before interruption/pause

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

Force combo to complete before interruption/pause

Postby TheBruhhh » Mon Jun 05, 2023 10:20 pm

So I have this Snaking script, the combo currently is set to be interrupted if L2 or R2 are held. Is there anything I can do to this script, so that if L2 or R2 are pressed while the combo is active, that those inputs won't be actually active/sent to the console, until the combo has completed? I'd like to do this to avoid accidentally interrupting the combo by pressing too early and then I shoot while prone behind the cover because I've pressed before I've had a chance to start standing :P

Code: Select all
 #include <keyboard.gph>
 #define irand(a, b) (((int)(rand() * (fix32)(b+1 - a))) + a)
 
main {
    if (key_status(KEY_R)) {
            if(time_active(KEY_R) > 10) set_val(8, 0);
            if(time_active(KEY_R) > 10) set_val(STICK_2_Y, 0);
        if (!get_val(4) && !get_val(7)) combo_run(Snake);
    }
}
combo Snake {     
    set_val(24, 100.0);
    wait(irand(20, 40));
    set_val(24, 100.0);
    set_val(14, 100.0);
    wait(irand(325, 375)); wait(irand(30, 50));
    set_val(14, 0.0);
    set_val(24, -100.0);
    set_val(8, 100.0);
    wait(irand(150, 250));
    }
User avatar
TheBruhhh
First Sergeant
First Sergeant
 
Posts: 65
Joined: Sun Nov 24, 2019 1:28 pm

Re: Force combo to complete before interruption/pause

Postby Mad » Mon Jun 05, 2023 11:27 pm

time_active only works for buttons, need to make your own timers for keys.
you can check if a combo is running with if(combo_name)
Code: Select all
#include <keyboard.gph>
#define irand(a, b) (((int)(rand() * (fix32)(b+1 - a))) + a)
uint32 timer;
main {
    if(key_status(KEY_R)) {
        if(elapsed_time() && ++timer >= 10) {
            set_val(8, 0);
            set_val(24, 0);
        }
        if(Snake) {
            set_val(4, 0);
            set_val(7, 0);
        }
        combo_run(Snake);
    } else {
        timer = 0;
    }
}
combo Snake {
    set_val(24, 100.0);
    wait(irand(20, 40));
    set_val(24, 100.0);
    set_val(14, 100.0);
    wait(irand(325, 375)); wait(irand(30, 50));
    set_val(14, 0.0);
    set_val(24, -100.0);
    set_val(8, 100.0);
    wait(irand(150, 250));
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Force combo to complete before interruption/pause

Postby TheBruhhh » Mon Jun 05, 2023 11:48 pm

Mad wrote:time_active only works for buttons, need to make your own timers for keys.
you can check if a combo is running with if(combo_name)
Code: Select all
#include <keyboard.gph>
#define irand(a, b) (((int)(rand() * (fix32)(b+1 - a))) + a)
uint32 timer;
main {
    if(key_status(KEY_R)) {
        if(elapsed_time() && ++timer >= 10) {
            set_val(8, 0);
            set_val(24, 0);
        }
        if(Snake) {
            set_val(4, 0);
            set_val(7, 0);
        }
        combo_run(Snake);
    } else {
        timer = 0;
    }
}
combo Snake {
    set_val(24, 100.0);
    wait(irand(20, 40));
    set_val(24, 100.0);
    set_val(14, 100.0);
    wait(irand(325, 375)); wait(irand(30, 50));
    set_val(14, 0.0);
    set_val(24, -100.0);
    set_val(8, 100.0);
    wait(irand(150, 250));
}


Ah okay, thanks for correcting that! I've used this script but now L2 and R2 aren't functioning at all while the script is running. I was looking for it to interrupt the script from looping as before, but not interrupt the script before the combo is complete, if that makes sense.
User avatar
TheBruhhh
First Sergeant
First Sergeant
 
Posts: 65
Joined: Sun Nov 24, 2019 1:28 pm

Re: Force combo to complete before interruption/pause

Postby TheBruhhh » Wed Jun 07, 2023 12:34 pm

Any ideas folks :innocent_smile_1:
User avatar
TheBruhhh
First Sergeant
First Sergeant
 
Posts: 65
Joined: Sun Nov 24, 2019 1:28 pm

Re: Force combo to complete before interruption/pause

Postby Mad » Wed Jun 07, 2023 11:49 pm

Code: Select all
#include <keyboard.gph>
#define irand(a, b) (((int)(rand() * (fix32)(b+1 - a))) + a)
uint32 timer;
 
main {
    if(key_status(KEY_R)) {
        if(elapsed_time() && ++timer >= 10) {
            set_val(8, 0);
            set_val(24, 0);
        }
        if(is_release(4) && is_release(7)) {
            combo_run(Snake);
        } else {
            if(Snake) {
                set_val(4, 0);
                set_val(7, 0);
            }
        }
    } else {
        timer = 0;
    }
}
combo Snake {
    set_val(24, 100.0);
    wait(irand(20, 40));
    set_val(24, 100.0);
    set_val(14, 100.0);
    wait(irand(325, 375)); wait(irand(30, 50));
    set_val(14, 0.0);
    set_val(24, -100.0);
    set_val(8, 100.0);
    wait(irand(150, 250));
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Force combo to complete before interruption/pause

Postby TheBruhhh » Sun Jun 11, 2023 4:16 pm

Thanks Mad, not been around all week, perfect, thanks very much :joia:
User avatar
TheBruhhh
First Sergeant
First Sergeant
 
Posts: 65
Joined: Sun Nov 24, 2019 1:28 pm

Re: Force combo to complete before interruption/pause

Postby GPCNoob » Fri Mar 08, 2024 10:48 am

Mad wrote:
Code: Select all
#include <keyboard.gph>
#define irand(a, b) (((int)(rand() * (fix32)(b+1 - a))) + a)
uint32 timer;
 
main {
    if(key_status(KEY_R)) {
        if(elapsed_time() && ++timer >= 10) {
            set_val(8, 0);
            set_val(24, 0);
        }
        if(is_release(4) && is_release(7)) {
            combo_run(Snake);
        } else {
            if(Snake) {
                set_val(4, 0);
                set_val(7, 0);
            }
        }
    } else {
        timer = 0;
    }
}
combo Snake {
    set_val(24, 100.0);
    wait(irand(20, 40));
    set_val(24, 100.0);
    set_val(14, 100.0);
    wait(irand(325, 375)); wait(irand(30, 50));
    set_val(14, 0.0);
    set_val(24, -100.0);
    set_val(8, 100.0);
    wait(irand(150, 250));
}

How would I convert this for PS4.gph?? Which numbers represent the buttons? please help!
User avatar
GPCNoob
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Wed Nov 25, 2020 2:24 am

Re: Force combo to complete before interruption/pause

Postby Scachi » Fri Mar 08, 2024 12:22 pm

no need to adjust the button numbers.
hit F1 in gtuner to see the list of button names and their numbers and you will see that the same number applied to different consoles/controllers and should just work the same as long as the game has the same button layout on both.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Force combo to complete before interruption/pause

Postby GPCNoob » Sat Mar 09, 2024 12:30 am

Scachi wrote:no need to adjust the button numbers.
hit F1 in gtuner to see the list of button names and their numbers and you will see that the same number applied to different consoles/controllers and should just work the same as long as the game has the same button layout on both.

Thank you for the reply! much appreciated. the F1 does nothing in my gtunerIV for some reason
User avatar
GPCNoob
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Wed Nov 25, 2020 2:24 am



Return to GPC2 Script Programming

Who is online

Users browsing this forum: Google [Bot] and 78 guests