Would someone take a look and see what I did wrong?

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

Would someone take a look and see what I did wrong?

Postby Justin420time » Mon Apr 24, 2023 6:11 am

I have two scripts and one is working fine, but the other doesn't want to "combo_stop".

Please let me know why its not working for Diablo when they are almost the same scripts, just different buttons.

To clarify about Diablo, it has nothing to do with the game because it works without script turned on. It shouldn't attack more then once, unless I am holding the hotkey down, but with the code down below it will not "combo_stop"..

First script is working fine in COD:
Code: Select all
#pragma METAINFO("Sprint More for DMZ", 1, 0, "Justin420time")
// CLICK IN AND HOLD BUTTON_9/LEFT JOYSTICK CLICK FOR COMBO!
#include "titanone.gph"
#include "ColorLED.gph"
#define DTAP_BUTTON    BUTTON_9
int WaitWE4 = 40;
int WaitWE65 = 65;
int SC_SPEED = 175;
int WaitWEtime = 145;
int WaitWE500 = 500;
int WaitWE750 = 750;
int Sprint_MoreCOD2 = TRUE; //BUTTON_9(LEFTJOYIN) && BUTTON_2(VIEW) to turn on/off
int b_reload = FALSE;
int rld_time = 1400;
bool playerMoving50 = FALSE;
main {
 
    // This should allow for 100% control over the stick if at 50% in any direction.
    playerMoving50 = (
        get_actual(STICK_2_Y) >= 50.00 ||
        get_actual(STICK_2_Y) <= -50.00 ||
        get_actual(STICK_2_X) >= 50.00 ||
        get_actual(STICK_2_X) <= -50.00
    );
    // If Reload is pressed stop running combo
    if (event_release(PS4_SQUARE)) {
        b_reload = TRUE;
    }
    if (b_reload) {
        b_reload = b_reload + get_rtime();
    }
    if (b_reload >= rld_time) {
        b_reload = 0;
        b_reload = FALSE;
    }
    // Sprint More for CODMW2/DMZ
    if (get_val(BUTTON_9) && event_press(BUTTON_3)) {
        combo_run(c_vibrate);
        Sprint_MoreCOD2=! Sprint_MoreCOD2;
        if (c_Sprint_MoreCOD2) ColorLED(CR,100,100,2,CG);
        else ColorLED(CR,100,100,2);
    }
    if (Sprint_MoreCOD2) {
        if(!b_reload && playerMoving50 && event_active(DTAP_BUTTON) && time_release(DTAP_BUTTON) <= 200) {
            combo_restart(X_JSprint_X);
        }
        if(X_JSprint_X) X_JSprint_X = is_active(DTAP_BUTTON);{
        }
        if(event_release(DTAP_BUTTON)) combo_stop(c_Sprint_MoreCOD2); // <-- This works great in this script
    }
}
 
combo RumbleOnce {
    ffb_set(FFB_2,100.0,200); // command motor FFB_1 to run at 100% for 200ms
    wait(0);          // !Important! only run the previous lines once
    wait(500);        // repeat the lines between this wait and the previous
                    //  (none=just waiting) for 500ms
    ffb_reset();      // this command allows the console to control the rumbles again
}
combo c_vibrate {
    call(RumbleOnce);
}
combo X_JSprint_X {
    set_val(BUTTON_9,0);
    wait(WaitWE4); wait(WaitWE4);
    combo_run(c_Sprint_CancelCOD2);
    combo_restart(X_JSprint_X);
    wait(0);
}
combo c_Sprint_MoreCOD2{
    set_val(XB1_B,100);
    wait(WaitWE65);
    set_val(XB1_B,0);
    wait(WaitWEtime);
    set_val(XB1_LT,100);
    wait(SC_SPEED);
    set_val(XB1_LT,0);
    wait(WaitWE4);
    set_val(XB1_LT,100);
    wait(SC_SPEED);
    set_val(XB1_LT,0);
    wait(WaitWE4);
    wait(WaitWE500);
    wait(WaitWE500);
    set_val(XB1_B,100);
    wait(1100);
    set_val(XB1_B,0);
    wait(WaitWE4);
    wait(WaitWE750);
    wait(WaitWE750);
}


This is script two, for Diablo Inferno.
Code: Select all
#pragma METAINFO("Diablo Immortal v1", 1, 0, "Justin420time")
 
#define BTAP_BUTTON BUTTON_15
 
#include "titanone.gph"
#include "ColorLED.gph"
 
 
int WaitWE0 = 0;
int WaitWE25 = 25;
int WaitWE65 = 65;
int WaitWE200 = 200;
int WaitWE300 = 300;
int Wait1Sec = 1000;
 
// RAPID B if playing on PC with Xbox Controller
int Rapid_B = TRUE; // BUTTON_6(RIGHTJOYIN) && XB1_B (Pressing B twice(with in 200mm) and hold) Press B ever so often
int Rapid_B2 = FALSE; // BUTTON_6(RIGHTJOYIN) && XB1_A (Pressing B twice(with in 200mm) and hold) Rapidly press B
 
 
main {
 
    if (get_val(XB1_RS) && event_press(XB1_B)){
        combo_run(c_vibrate);
        Rapid_B =! Rapid_B;
        if (Rapid_B) ColorLED(CR,100,100,2,CG);
        else ColorLED(CR,100,100,2);
    }
    // Spam button B - Press B twice and hold it
    if (Rapid_B) {
        if (event_active(BTAP_BUTTON) && time_release(BTAP_BUTTON) <= 200){
            combo_restart(X_RAPID_B);
        }
        if(X_RAPID_B) X_RAPID_B = is_active(BTAP_BUTTON);{
        }
        if (event_release(BTAP_BUTTON)) combo_stop(c_Rapid_B); // <-- This will not stop combo.. Please help..
    }
 
    if (get_val(XB1_RS) && event_press(XB1_A)){
        combo_run(c_vibrate);
        Rapid_B2 =! Rapid_B2;
        if (Rapid_B2) ColorLED(CR,100,100,2,CG);
        else ColorLED(CR,100,100,2);
    }
    // Spam button B - Press B twice and hold it
    if (Rapid_B2) {
        if (event_active(BTAP_BUTTON) && time_release(BTAP_BUTTON) <= 200){
            combo_restart(X_RAPID_B2);
        }
        if(X_RAPID_B2) X_RAPID_B2 = is_active(BTAP_BUTTON);{
        }
        if(event_release(BTAP_BUTTON)) combo_stop(c_Rapid_B2);
    }
}
combo RumbleOnce {
    ffb_set(FFB_2,100.0,200); // command motor FFB_1 to run at 100% for 200ms
    wait(WaitWE0);          // !Important! only run the previous lines once
    wait(500);        // repeat the lines between this wait and the previous
                    //  (none=just waiting) for 500ms
    ffb_reset();      // this command allows the console to control the rumbles again
}
combo c_vibrate {
    call(RumbleOnce);
}
combo X_RAPID_B {
    set_val(BUTTON_15,0);
    wait(WaitWE25); wait(WaitWE25);
    combo_run(c_Rapid_B);
    combo_restart(X_RAPID_B);
    wait(WaitWE0);
}
combo c_Rapid_B {
    set_val(XB1_B,100);
    wait(WaitWE200);
    set_val(XB1_B,0);
    wait(WaitWE65);
    wait(WaitWE300);
    set_val(XB1_B,100);
    wait(WaitWE200);
    set_val(XB1_B,0);
    wait(WaitWE65);
    wait(WaitWE300);
    set_val(XB1_B,100);
    wait(WaitWE200);
    set_val(XB1_B,0);
    wait(Wait1Sec);
    wait(WaitWE300);
}
combo X_RAPID_B2 {
    set_val(BUTTON_15,0);
    wait(WaitWE25); wait(WaitWE25);
    combo_run(c_Rapid_B2);
    combo_restart(X_RAPID_B2);
    wait(WaitWE0);
}
combo c_Rapid_B2 {
    set_val(XB1_B,0);
    wait(WaitWE65);
    set_val(XB1_B,100);
    wait(WaitWE65);
}


Thank you for taking a look! Take care.

-Justin
paypal.me/xkjtx
UserBenchmarks:Game 96%,Desk 95%,Work 90%
CPU:AMD Ryzen 5 3600XT-87.5%
GPU:Nvidia RTX 3060-104.1%
RAM:Unknown 8G 135-K 4x8GB-94.7%
MBD:Gigabyte GA-B550 AORUS PRO AC
User avatar
Justin420time
First Sergeant
First Sergeant
 
Posts: 44
Joined: Fri Nov 02, 2018 6:48 pm

Re: Would someone take a look and see what I did wrong?

Postby Scachi » Mon Apr 24, 2023 7:32 am

Do NOT mix T1 and T2 code or you will end up with issues like that
Do NOT use #include <titanone.gph> mixed with any T2 function.
The t1 header file should only be used you want to get a t1 script working on the T2 (while not adding any T2 code, only add T1 code when required)

When writing T2 script just stick to T2 functions/code/examples.
Did I mention to not include the t1 header already ?

When you want to use button names just include the proper T2 button file.
Example #include <xb1.gph>
Take a look in your gtuner include directory to see the available .gph files to include.

The Titan One has other button numbers than the T2 for the circle button.
On T1 it is number 18, on T2 it is number 14.

Your combo stop never gets executed on release of your circle button as your code doesn't listen to the circle button at all as it doesn't listen for "18".
Try this instead as a dirty fix:
Code: Select all
if (event_release(18)) combo_stop(c_Rapid_B);
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Would someone take a look and see what I did wrong?

Postby Justin420time » Tue Apr 25, 2023 10:20 pm

Okay, I will take a look at that. Thank you so much for taking a look.

I didn't understand that I have titan one code in my titan two scripts..

I only have ever had the Titan Two device.

I use the Titan Two everyday and have never used the Titan one.

I'm going to try and redo the scripts so they don't have T1 included.

-Justin

P.S. Found my problem... event_active not event_press
All I needed to do was remove the included and add event_active and
change the keys.

Code: Select all
#pragma METAINFO("Diablo Immortal v1", 1, 0, "Justin420time")
 
#define BTAP_BUTTON BUTTON_15
#define ATAP_BUTTON BUTTON_16
 
#include "xb1.gph"
#include "ColorLED.gph"
 
int WaitWE0 = 0;
int WaitWE25 = 25;
int WaitWE65 = 65;
int WaitWE200 = 200;
int WaitWE300 = 300;
int Wait1Sec = 1000;
 
// RAPID B if playing on PC with Xbox Controller
int Rapid_B = TRUE; // BUTTON_6(RIGHTJOYIN) && XB1_B (Pressing B twice(with in 200mm) and hold)
int Rapid_B2 = FALSE; // BUTTON_6(RIGHTJOYIN) && XB1_A (Pressing B twice(with in 200mm) and hold)
 
 
main {
 
    if (get_val(XB1_RS) && event_release(BTAP_BUTTON)){
        combo_run(c_vibrate);
        Rapid_B =! Rapid_B;
        if (Rapid_B) ColorLED(CR,100,100,2,CG);
        else ColorLED(CR,100,100,2);
    }
    // Spam button B - Press B twice and hold it
    if (Rapid_B) {
        if (event_active(BTAP_BUTTON) && time_release(BTAP_BUTTON) <= 200){
            combo_restart(X_RAPID_B);
        }
        if(X_RAPID_B) X_RAPID_B = is_active(BTAP_BUTTON);{
        }
        if (event_release(BTAP_BUTTON)) combo_stop(c_Rapid_B);
    }
 
    if (get_val(XB1_RS) && event_release(ATAP_BUTTON)){
        combo_run(c_vibrate);
        Rapid_B2 =! Rapid_B2;
        if (Rapid_B2) ColorLED(CR,100,100,2,CG);
        else ColorLED(CR,100,100,2);
    }
    // Spam button B - Press B twice and hold it
    if (Rapid_B2) {
        if (event_active(BTAP_BUTTON) && time_release(BTAP_BUTTON) <= 160){
            combo_restart(X_RAPID_B2);
        }
        if(X_RAPID_B2) X_RAPID_B2 = is_active(BTAP_BUTTON);{
        }
        if(event_release(BTAP_BUTTON)) combo_stop(c_Rapid_B2);
    }
}
combo RumbleOnce {
    ffb_set(FFB_2,100.0,200); // command motor FFB_1 to run at 100% for 200ms
    wait(WaitWE0);          // !Important! only run the previous lines once
    wait(500);        // repeat the lines between this wait and the previous
                    //  (none=just waiting) for 500ms
    ffb_reset();      // this command allows the console to control the rumbles again
}
combo c_vibrate {
    call(RumbleOnce);
}
combo X_RAPID_B {
    set_val(BTAP_BUTTON,0);
    wait(WaitWE25); wait(WaitWE25);
    combo_run(c_Rapid_B);
    combo_restart(X_RAPID_B);
    wait(WaitWE0);
}
combo c_Rapid_B {
    set_val(BTAP_BUTTON,100);
    wait(WaitWE200);
    set_val(BTAP_BUTTON,0);
    wait(WaitWE65);
    wait(WaitWE200);
    set_val(BTAP_BUTTON,100);
    wait(WaitWE200);
    set_val(BTAP_BUTTON,0);
    wait(WaitWE65);
    wait(WaitWE200);
    set_val(BTAP_BUTTON,100);
    wait(WaitWE200);
    set_val(BTAP_BUTTON,0);
    wait(Wait1Sec);
    wait(WaitWE300);
}
combo X_RAPID_B2 {
    set_val(BTAP_BUTTON,0);
    wait(WaitWE25); wait(WaitWE25);
    combo_run(c_Rapid_B2);
    combo_restart(X_RAPID_B2);
    wait(WaitWE0);
}
combo c_Rapid_B2 {
    set_val(BTAP_BUTTON,0);
    wait(WaitWE65);
    set_val(BTAP_BUTTON,100);
    wait(WaitWE65);
}
paypal.me/xkjtx
UserBenchmarks:Game 96%,Desk 95%,Work 90%
CPU:AMD Ryzen 5 3600XT-87.5%
GPU:Nvidia RTX 3060-104.1%
RAM:Unknown 8G 135-K 4x8GB-94.7%
MBD:Gigabyte GA-B550 AORUS PRO AC
User avatar
Justin420time
First Sergeant
First Sergeant
 
Posts: 44
Joined: Fri Nov 02, 2018 6:48 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 210 guests