Will script size affect performance?

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

Will script size affect performance?

Postby Nstarnoe » Sat Jun 08, 2019 8:59 pm

I have a pretty big scrip, around 85% usage. I am having some issues where my keyboard and sometimes mouse freezes. I could be fortnite lagging, but I can’t get it to make sense. Everything freezes, if I release key presses on keyboard it’s running again - but, even it is game lag why wouldn’t it “pick up” movements once the lag is over?

So I thinking I might be pushing performance of the t2 too hard.

I have amble room to optimize the script in size, but will it have an effect? (I not I to lazy to do it :) )
User avatar
Nstarnoe
Master Sergeant
Master Sergeant
 
Posts: 40
Joined: Sun Jan 13, 2019 2:19 pm

Re: Will script size affect performance?

Postby Mad » Sat Jun 08, 2019 9:10 pm

It wouldn't be the size of the script but the code itself.

You can monitor CPU load under device monitor on Gtuner.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Will script size affect performance?

Postby Scachi » Sat Jun 08, 2019 9:14 pm

Can you post or pm me the complete script so I can check what may cause the issues ?
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Will script size affect performance?

Postby Nstarnoe » Sat Jun 08, 2019 9:24 pm

Hi Mad and Sachi

Thanks for your reply :)

I think the script is good, it's working flawless for long periods, weeks. But, sometimes there are periods where i get a lot of freezes, its kinda wierd. Most of the time i get input back if release key presses, although every now and then i have to unplug and replug the t2.

It is correlated with periods of poor performance in fortnite and lagging, but i can't get my head why the inputs don't pick up again once the lag is over.

Sachi, thank for looking a the script, but fair warning is is quite long, not well documented and done by a novice :unsure:

Code: Select all
 
 
    #pragma METAINFO("Fortnite T2 on PS4", 7,71, "Nikolaj")
 
    #include "keyboard.gph"
    #include "mouse.gph"
    #include "xkeys_v3.gph"   
 
    #define KEYS_TO_MONITOR_MAX     31
    uint8 Weapon_1_KEY, Weapon_2_KEY, Weapon_3_KEY, Weapon_4_KEY, Secondary_Weapon_4_KEY, Weapon_5_KEY, Pickaxe_KEY, CHANGE_TRAP_KEY, Secondary_CHANGE_TRAP_KEY, PLACE_TRAP_KEY, CHANGE_MATS_KEY, Secondary_CHANGE_MATS_KEY, ROOF_KEY, Secondary_ROOF_KEY, FLOOR_KEY, RAMP_KEY, WALL_KEY, SHIFT_KEY, FORWARD_KEY, BACK_KEY, LEFT_KEY, RIGHT_KEY, PAGEUP_KEY, PAGEDOWN_KEY, Emote_1_KEY, Emote_2_KEY, Emote_3_KEY, Emote_4_KEY, Emote_5_KEY, Emote_6_KEY, Drop_item_KEY;
 
    init
    {
    // use xkeys_add to add each key to monitor, it returns an uint8 number that has to be used with the functions
        Weapon_1_KEY                =xkeys_add(KEY_1);
        Weapon_2_KEY                =xkeys_add(KEY_2);       
        Weapon_3_KEY                =xkeys_add(KEY_3);
        Weapon_4_KEY                =xkeys_add(KEY_4);    
        Secondary_Weapon_4_KEY        =xkeys_add(KEY_O);
        Weapon_5_KEY                =xkeys_add(KEY_5);
        Pickaxe_KEY                    =xkeys_add(KEY_Y);
 
        CHANGE_TRAP_KEY                =xkeys_add(KEY_X);
        Secondary_CHANGE_TRAP_KEY    =xkeys_add(KEY_I);   
        PLACE_TRAP_KEY                =xkeys_add(KEY_Q);
        CHANGE_MATS_KEY                =xkeys_add(KEY_C);
        Secondary_CHANGE_MATS_KEY    =xkeys_add(KEY_P);
 
        RAMP_KEY                    =xkeys_add(KEY_J);
        WALL_KEY                    =xkeys_add(KEY_U);
        FLOOR_KEY                    =xkeys_add(KEY_E);
        ROOF_KEY                    =xkeys_add(KEY_R);
        Secondary_ROOF_KEY            =xkeys_add(KEY_B);
        SHIFT_KEY                    =xkeys_add(KEY_LEFTSHIFT);   
        FORWARD_KEY                    =xkeys_add(KEY_W);
        BACK_KEY                    =xkeys_add(KEY_S);
        LEFT_KEY                    =xkeys_add(KEY_A);
        RIGHT_KEY                    =xkeys_add(KEY_D);
 
        PAGEUP_KEY                    =xkeys_add(KEY_PAGEUP);
        PAGEDOWN_KEY                =xkeys_add(KEY_PAGEDOWN);
 
        Emote_1_KEY                 =xkeys_add(KEY_F1);
        Emote_2_KEY                 =xkeys_add(KEY_F2);
        Emote_3_KEY                 =xkeys_add(KEY_F3);
        Emote_4_KEY                 =xkeys_add(KEY_F4);
        Emote_5_KEY                 =xkeys_add(KEY_F5);
        Emote_6_KEY                 =xkeys_add(KEY_F6);
 
        Drop_item_KEY                =xkeys_add(KEY_L);
    }
 
 
    fix32 a;//
    fix32 b;//1.07
    fix32 d;   
    fix32 x1;                                        // x1 coordinate, input magnitude
    fix32 y1;                                    // y1 coordinate, output magnitude
    fix32 x2;                // x2 coordinate, input magnitude     90.0
    fix32 y2;                                        // y2 coordinate, output magnitude
    fix32 m;                        // slope
    fix32 c;                            // constant
    fix32 p;                      // original magnitude
    fix32 y0;                             // new magnitude
    fix32 s;                                    // scaling factor
    fix32 x;
    fix32 y;
    fix32 sensitivity_x;
    fix32 sensitivity_y;
 
    #define MAP                    BUTTON_2
    #define RIGHT_BUMP            BUTTON_4         //PS4_R1;
    #define FIRE_BTN            BUTTON_8         //PS4_R2;
    #define R3                    BUTTON_6          //PS4_R3;
    #define L3                    BUTTON_9          //PS4_R3;
    #define LEFT_BUMP            BUTTON_7         //PS4_L1;
    #define ADS_BTN                BUTTON_5         //PS4_L2;
 
    #define UP_BTN                BUTTON_10         //PS4_RIGHT;
    #define DOWN_BTN            BUTTON_11         //PS4_DOWN;
    #define LEFT_BTN            BUTTON_12         //PS4_LEFT;
    #define RIGHT_BTN            BUTTON_13         //PS4_RIGHT;
    #define PICKAXE_BTN            BUTTON_14         //PS4_TRIANGLE;
    #define CIRCLE_BTN            BUTTON_15         //PS4_RIGHT;
    #define CROSS_BTN            BUTTON_16         //PS4_CROSS;   
    #define SQUARE_BTN            BUTTON_17         //PS4_SQUARE;
 
    #define RX                      STICK_1_X          //PS4_RX;
    #define RY                      STICK_1_Y          //PS4_RY;
    #define LX                     STICK_2_X          //PS4_LX;
     #define LY                     STICK_2_Y         //PS4_LY;
 
    bool aimabuse_hold_value;                     // fra 230
    bool aimabuse_rest_value;                      // fra 30       
//    int delay                      = 17;
    fix32 aim_start                = 15.0;
    bool weapon_choice             = 0;
 
    bool building_on             = FALSE;
    bool inventory_on             = FALSE;
    bool edit_on                 = FALSE;
//    bool edit_reset_on             = FALSE;
    bool trap_on                 = FALSE;   
    bool rapid_fire_1_on         = TRUE;   
    bool rapid_fire_5_on         = FALSE;   
 
//    bool aim_abuse_on             = TRUE;
    bool wait_short                = 20;
    bool wait_weapon            = 25;
    bool wait_weapon_swap        = 25;
    bool wait_long                = 30;
 
//    bool led_wait                = 300;
 
 
    bool emote_x;
    bool emote_y;
 
    #define ScrollForward         1
    #define ScrollBackward         -1
 
//    int ScrollDirection         = 0;
//    int ScrollDirectionPrev     = 0;
//    int ScrollCount             = 0;
//    int ScrollTimeout             = 0;
//    bool swap_no                 = 1;
//    bool n                         = 0;
 
//    bool w_delay                = 125; //85
    bool aim_on                    = TRUE;
//    fix32 movement_x;
//    fix32 movement_y;
 
//    int DeadZone_Weapon         = 13; // 5
//    int DeadZone_Sniper         = 13; // 5
//    int DeadZone_Other            = 13; // 5
//    int DeadZone_map            = 13;
    int DeadZone                = 13;
 
 
 
    #define SENSITIVITY_AR           0.72 //0.75
    #define SENSITIVITY_SNIPER          0.76 // 0.35
    #define SENSITIVITY_PUMP_SMG    0.75 // 0.35
    #define SENSITIVITY_BUILD        1.00  //0.70
    #define SENSITIVITY_OTHER        1.00  //1.07
    #define SENSITIVITY_RUNNING        1.00  //1.07
 
 
    #define SENSITIVITY_BUILDING    1.15  //1.07
 
 
    uint32 time_counter;
//    uint32 time_counter_weapon        = 0;   
//    uint32 p_wait                    = 0;
    uint32 time_counter_aim;
 
//    uint32 time_to_dblclick          = 300;// time for second click to occur
    int b_dblclick                    = FALSE;
    uint32 dblclick_msecs;
//    int scroll_temp_fw = 0;
//    int scroll_temp_bw = 0;
 
    #define TLIMIT    200              // idle time after a scroll in the same direction will be accepted as a new scroll
    uint32 scrollTstamp;             // last time a scroll was used
    int8     scrollDir;                // last direction of scroll
    int8 wheel;
    uint32 tstamp;
 
 
main
{
    time_counter += elapsed_time();
 
    if(xkeys_event_active(Drop_item_KEY)) // (key_status(KEY_L) && time_counter >= 250)
    {
//        time_counter = 0;
        combo_run(PRESS_Y);
    }
 
//    if(key_status(KEY_K) && time_counter >= 250)
//    {
//       time_counter = 0;
//        combo_run(PRESS_CIRCLE);
//    }
 
// rapid fire ar on/off
 
    if(xkeys_event_active(PAGEUP_KEY)) //key_status(KEY_PAGEUP) && time_counter >= 250) //xkeys_event_active(PAGEUP_KEY) 
    {
 //       time_counter = 0;
        rapid_fire_5_on = !rapid_fire_5_on;
    }
 
// rapid fire pump on/off   
    if(xkeys_event_active(PAGEDOWN_KEY)) // key_status(KEY_PAGEDOWN) && time_counter >= 250) //xkeys_event_active(PAGEDOWN_KEY)
    {
//        time_counter = 0;
        rapid_fire_1_on = !rapid_fire_1_on;
    }
 
 
//set led's
    if (!rapid_fire_1_on && !rapid_fire_5_on)
    {       
        led_reset();
        normal_led();
    }
    else if (rapid_fire_1_on && !rapid_fire_5_on)
    {
        led_reset();
        pump_led();   
    }
    else if (!rapid_fire_1_on && rapid_fire_5_on)
    {
        led_reset();
        ar_led();   
    }       
    else if (rapid_fire_1_on && rapid_fire_5_on)
    {
        led_reset();
        combo_run (blinking_led_rapid_fire_on);   
    }
 
    sensitivity();
 
 
//    set_val(LX, clamp(get_val(LX),-98.0,98.0));
//    set_val(LY, clamp(get_val(LY),-98.0,98.0));
 
 
 
 
 
 
 
 
 
// mouse wheel   
if (mouse_status(MREPORT_UPDATED))
{
    if (wheel=mouse_status(MOUSE_WHEEL))
    {
            tstamp=mouse_status(MREPORT_TIMESTAMP);
 
            if (wheel!=scrollDir || tstamp > scrollTstamp + TLIMIT)
            { // on direction change or current_time > lasttime+TLMIT a scroll will be accepted as a new scroll
                printf("tstamp: %ld, scolltstamp: %ld , diff: %ld",tstamp,scrollTstamp,tstamp-scrollTstamp);
                scrollDir=wheel;
 
                if (wheel==1)
                {
                    printf("Mouse Wheel Forward");                     
                    stop_combos();   
                    weapon_1_void();                   
                }   
                if (wheel==-1)
                {
                    printf("Mouse Wheel Backward");
                    stop_combos();
                    weapon_2_void();           
                }
            }
            scrollTstamp=tstamp;
    }
}
 
 
if (first_ramp || first_wall || first_floor || first_roof) {time_counter_aim += elapsed_time();}
 
if (time_counter_aim < 150) {wait_weapon = 150 - time_counter_aim;}
else {wait_weapon = 1;}
 
//build on + ramp       
 
    if(xkeys_event_active(RAMP_KEY)) //xkeys_event_active(RAMP_KEY)
    {             
        stop_combos();
        set_val(FIRE_BTN, 0);
 
        if(!building_on)
        {       
        combo_run (first_ramp);                                                       
        }   
    }
 
//build on + wall            
    if(xkeys_event_active(WALL_KEY)) //xkeys_event_active(WALL_KEY)
    {             
        stop_combos();
 
        if(!building_on)
        {
        combo_run (first_wall);                                                               
        }
        building_on = TRUE;       
    }
 
 
//build on + floor            
    if(xkeys_event_active(FLOOR_KEY))
    {             
        stop_combos();
 
        if(!building_on)
        {
        combo_run (first_floor);               
 
        }
        building_on = TRUE;       
    }
 
//build on + roof   
    if(xkeys_event_active(ROOF_KEY) || xkeys_event_active(Secondary_ROOF_KEY))
    {             
        stop_combos();
 
        if(!building_on)
        {
        combo_run (first_roof);
 
        }
        building_on = TRUE;            
    }
 
 
    if (!edit_on)
    {           
 
//place ramp   
 
            if (key_status(KEY_J) && building_on)
            {           
                combo_run(spam_ramp);
            }   
 
 
//place wall   
            if (key_status(KEY_U) && building_on && !first_wall) //  !combo_running()   xkeys_time_active(WALL_KEY) > 80
            {
                //set_val(FIRE_BTN, 0);
                combo_run(spam_fire);           
            }   
 
// Spam floor   
            if (key_status(KEY_E) && building_on)
            {
                set_val(LEFT_BUMP,100);
                combo_run(spam_floor);
            }           
 
// Spam roof   
            if (key_status(KEY_R) && building_on)
            {
                set_val(RIGHT_BUMP,100);
                combo_run(spam_roof);
            }
 
            if (key_status(KEY_B) && building_on)
            {
                set_val(RIGHT_BUMP,100);
                combo_run(spam_roof);
            }
 
 
// build off with weapon select (ads)
            if (building_on)
            {
                if (mouse_status(MBUTTON_1) || mouse_status(MBUTTON_2))
                {   
                    building_on = FALSE;
                    combo_run(build_on_off);                   
                }   
            }
        }   
 
 
//change trap   
        if (xkeys_event_active(CHANGE_TRAP_KEY) )      //&& xkeys_time_active(CHANGE_TRAP_KEY) < 280
        {       
            if        (!building_on)     {combo_run (change_trap_from_not_build);}
            else if    (building_on)    {combo_run (change_trap);}   
        }   
 
//place trap   
        if (key_status(KEY_Q))       //xkeys_event_active(PLACE_TRAP_KEY)    && !trap_on
        {                       
            if (!building_on){combo_run (place_trap_from_not_build);}   
            else if (building_on){combo_run (place_trap);}
        }
 
        if (xkeys_event_release(PLACE_TRAP_KEY) ) //&& trap_on
        {
                set_val(L3, 0);
 
            combo_run (trap_off);
            trap_on = FALSE;
            building_on = FALSE;   
        }
 
 
//change mats   
        if (xkeys_event_active(CHANGE_MATS_KEY))
        {         
            if (!building_on){combo_run (change_mats_building_off);}
            else{combo_run (change_mats_building_on);}
        }
 
// PICKAXE
            if(xkeys_event_active(Pickaxe_KEY))
            {         
                stop_combos();
                combo_run (reset_weapons);               
                weapon_choice = 6;
                reset_weapon_variables();
                building_on = FALSE;
            }   
 
// WEAPON 1
            if (xkeys_event_active(Weapon_1_KEY)) {weapon_1_void();}
 
            if (key_status(KEY_1) && xkeys_time_active(Weapon_1_KEY) > 250 && xkeys_time_active(Weapon_1_KEY) < 280)
            {
                stop_combos();   
                combo_run (weapon_1);
                weapon_choice = 1;
                building_on = FALSE;               
            }
 
// WEAPON 2
            if (xkeys_event_active(Weapon_2_KEY)){weapon_2_void();}
 
            if (key_status(KEY_2) && xkeys_time_active(Weapon_2_KEY) > 250 && xkeys_time_active(Weapon_2_KEY) < 280)
            {
                stop_combos();   
 
                combo_run (weapon_2);
                weapon_choice = 2;
                building_on = FALSE;
            }
 
//WEAPON 3
            if(xkeys_event_active(Weapon_3_KEY) ) {weapon_3_void();}           
 
            if (key_status(KEY_3) && xkeys_time_active(Weapon_3_KEY) > 250 && xkeys_time_active(Weapon_3_KEY) < 280)
            {
                stop_combos();   
                combo_run (weapon_3);
                weapon_choice = 3;
                building_on = FALSE;
            }
 
//WEAPON 4
            if(xkeys_event_active(Weapon_4_KEY)){weapon_4_void();}           
 
            if (key_status(KEY_4) && xkeys_time_active(Weapon_4_KEY) > 250 && xkeys_time_active(Weapon_4_KEY) < 280)
            {
                stop_combos();   
 
                combo_run (weapon_4);
                weapon_choice = 4;
                building_on = FALSE;
            }           
 
//double click weapon 4
        if (xkeys_event_active(Secondary_Weapon_4_KEY) && !b_dblclick)     
            {
                dblclick_msecs = 0;
                b_dblclick = TRUE;
            }
 
        dblclick_msecs += elapsed_time();
 
        if (dblclick_msecs > 500) {b_dblclick = FALSE;}
 
        if (xkeys_event_active(Secondary_Weapon_4_KEY) && b_dblclick && dblclick_msecs > 75 && dblclick_msecs < 900 ){weapon_4_void();}    //&& tstamp > scrollTstamp + TLIMIT
 
 
// WEAPON 5
            if (xkeys_event_active(Weapon_5_KEY)){weapon_5_void();}       
 
            if (key_status(KEY_5) && xkeys_time_active(Weapon_5_KEY) > 250 && xkeys_time_active(Weapon_5_KEY) < 280)
            {
                stop_combos();   
 
                combo_run (weapon_5);
                weapon_choice = 5;
                building_on = FALSE;               
            }               
 
//AIMING
 
 
//AIM ABUSE & AIM ASSIST    
 
 
 
            if (weapon_choice == 1  || weapon_choice == 2 || weapon_choice == 5) //
            {
 
                if (weapon_choice == 5 ) //
                {           
                    aimabuse_hold_value     =      250; // fra 300   eller 500
                    aimabuse_rest_value     =     20;      // fra 30 eller 50
                    aim_start                 = 15.0;
                }
                else //|| weapon_choice == 2 || weapon_choice == 5
                {
                    aimabuse_hold_value     =      250; // fra 84
                    aimabuse_rest_value     =     20;      // fra 15
                    aim_start                 =     5.0;
                }
 
                if (abs(get_val(RX)) < aim_start || abs(get_val(RY)) < aim_start) {aim_on = TRUE;}
                else
                {
                    if (abs(get_val(RX))  > abs(get_prev(RX)) || abs(get_val(RY))  > abs(get_prev(RY))) {aim_on = FALSE;}
                }
 
                if (mouse_status(MBUTTON_2) && !building_on)
                {           
                    if (weapon_choice == 1 || weapon_choice == 2)
                    {
                            if (!aim_on && mouse_status(MBUTTON_1)) {aimabuse_rest_value     =     50;}
                    }           
 
                    combo_run(AimAbuse);
                }
 
            }
 
 
//Rapid fire       
        if (mouse_status(MBUTTON_1) && mouse_status(MBUTTON_2) && !building_on && !edit_on)
        {               
            if (rapid_fire_1_on && weapon_choice == 1) {combo_run(spam_fire);}
            if (rapid_fire_5_on && weapon_choice == 5) {combo_run(spam_fire);}
        }   
 
//wall replace
        if (weapon_choice == 6 && mouse_status(MBUTTON_1) && mouse_status(MBUTTON_2) && !building_on && !edit_on) //
        {   
            set_val(FIRE_BTN, 0);
            combo_run(wall_replace);
        }   
 
// Going in & out of inventory
 
    if(event_active(UP_BTN)) {inventory_on=TRUE;}   
    if(event_release(CIRCLE_BTN) && inventory_on) {edit_on = FALSE;}
 
// insta edit confirm   
 
    if(event_active(CIRCLE_BTN)) {edit_on = TRUE;}
 
    if (event_release(FIRE_BTN) && edit_on)
    {
        combo_run (confirm_edit_from_select);
        edit_on = FALSE;
    }
 
    if (event_release(ADS_BTN) && edit_on)
    {
        combo_run (confirm_edit_from_reset);
        edit_on = FALSE;
    }
 
 
//emotes
 
    if(xkeys_event_active(Emote_1_KEY))
        {
            emote_x = 0;
            emote_y = 0; //-100
            combo_run (emote);
        }
    if(xkeys_event_active(Emote_2_KEY))
        {
            emote_x = 100;
            emote_y = -100;
            combo_run (emote);
        }
    if(xkeys_event_active(Emote_3_KEY))
        {
            emote_x = 100;
            emote_y = 100;
            combo_run (emote);
        }
    if(xkeys_event_active(Emote_4_KEY))
        {
            emote_x = 0;
            emote_y = 100;
            combo_run (emote);
        }
    if(xkeys_event_active(Emote_5_KEY))
        {
            emote_x = -100;
            emote_y = 75;
            combo_run (emote);
        }
    if(xkeys_event_active(Emote_6_KEY))        
        {
            emote_x = -100;
            emote_y = -100;
            combo_run (emote);
        }
 
} // MAIN END
 
 
 
combo build_on_off
{
    set_val(LEFT_BTN, 100);
    wait(2 * wait_short);
//    set_val(LEFT_BTN, 0);
//    wait(wait_short);
}
 
 
combo AimAbuse
{
    set_val(ADS_BTN, 100);
    wait(aimabuse_hold_value);
    set_val(ADS_BTN, 0);
    wait(aimabuse_rest_value);
}
 
 
combo reset_weapons
{                                                                          
    wait(wait_weapon);
 
    call(PRESS_Y);    
    wait(20);     //?
    call(build_on_off);       
    wait(20);   //?
    call(PRESS_Y);    
}
 
 
combo weapon_1
{   
    reset_weapon_variables();
    wait(wait_weapon);
    call (reset_weapons);           
    call (one_right);                       
}
 
//combo weapon_1_from_pickaxe
//{   
//    reset_weapon_variables();
//    wait(wait_weapon);
//    call (one_right);
//    call (reset_weapons);           
//    call (one_right);                       
//}
 
 
combo weapon_2
{                               
    reset_weapon_variables();
    call (weapon_1);
    call (one_right);   
}
 
//combo weapon_2_from_pickaxe
//{   
//    call (weapon_1_from_pickaxe);
//    call (one_right);   
//}
 
combo weapon_3
{   
    call (weapon_1);   
    call (one_right);       
    call (one_right);   
}
 
//combo weapon_3_from_pickaxe
//{   
//    call (weapon_2_from_pickaxe);       
//    call (one_right);   
//}
 
combo weapon_4
{   
    reset_weapon_variables();        
    call (weapon_5);       
    call (one_left);   
}
 
//combo weapon_4_from_pickaxe
//{   
//    call (weapon_5_from_pickaxe);           
//    call (one_left);       
//}
 
combo weapon_5
{   
    reset_weapon_variables();    
    wait(wait_weapon);
    call (reset_weapons);           
    call (one_left);   
}
 
//combo weapon_5_from_pickaxe
//{   
//    reset_weapon_variables();    
//    wait(wait_weapon);
//    call (one_left);
//    call (reset_weapons);           
//    call (one_left);   
//}
 
combo first_wall
{
    call(build_on_off);   
    building_on = TRUE;           
    call(fire_btn);   
    call(fire_btn);
    call(fire_btn);   
//    call(fire_btn);   
}
 
combo first_ramp
{
    call(build_on_off);   
    building_on = TRUE;   
    call (ads_btn);
    call (ads_btn);   
    call (ads_btn);   
//    call (ads_btn);
}
 
 
combo first_floor
{
    call(build_on_off);   
    building_on = TRUE;   
    call (one_left);    
    call (one_left);   
    call (one_left);   
//    call (one_left);
}
 
combo first_roof
{
    call(build_on_off);   
    building_on = TRUE;   
    call (one_right);    
    call (one_right);    
    call (one_right);    
//    call (one_right);
}
 
//combo roof_floor
//{
//    call (one_left);    
//    call (one_left);   
//    call (one_right);    
//    call (one_right);
//}
 
 
combo change_trap_from_not_build
{
    call(build_on_off);
    call (change_trap);       
    call(build_on_off);   
 
}
 
combo change_trap
{
    set_val(RIGHT_BTN, 100);
    wait(wait_long);
    wait(2*wait_long);
 
    set_val(DOWN_BTN, 100);
    wait(2*wait_long);
}
 
combo place_trap_from_not_build
{
    call(build_on_off);   
    call (place_trap);
    building_on = TRUE;   
    trap_on = TRUE;
}
 
combo place_trap
{       
    set_val(SQUARE_BTN, 100);
    wait(wait_long);
    wait(wait_long);
 
    set_val(L3, 100);
    wait(wait_long);
    wait(wait_long);
}
 
combo trap_off
{       
    wait(200);
    call(build_on_off);   
    building_on = FALSE;
}
 
combo change_mats_building_on
{
    set_val(DOWN_BTN, 100);
    wait(wait_long);
    set_val(DOWN_BTN, 0);
    wait(wait_long);
}
 
combo change_mats_building_off
{
    call(build_on_off);   
 
    wait(wait_long);   
    call (change_mats_building_on);   
    call(build_on_off);
 
}
 
combo confirm_edit_from_select
{
    wait(wait_short);
    set_val(CIRCLE_BTN, 100);
    wait(wait_short);
    wait(wait_short);
}   
 
combo confirm_edit_from_reset
{
    wait(wait_short);   
    call (square_btn);
 
    set_val(CIRCLE_BTN, 100);
    wait(wait_short);
    wait(wait_short);
}
 
combo spam_fire
{
    set_val(FIRE_BTN, 100);
    wait(5);
    set_val(FIRE_BTN, 0);
    wait(5);
}
 
//combo spam_ads
//{
//    set_val(ADS_BTN, 100);
//    wait(5);
//    set_val(ADS_BTN, 0);
//    wait(5);
//}
 
combo fire_btn
{
    set_val(FIRE_BTN, 100);
    wait(wait_short);
    set_val(FIRE_BTN, 0);   
    wait(wait_short);   
}
 
combo ads_btn
{
    set_val(ADS_BTN, 100);
    wait(wait_short);   
    set_val(ADS_BTN, 0);
    wait(wait_short);   
}
 
combo square_btn
{
    set_val(SQUARE_BTN, 100);
    wait(wait_short);
    set_val(SQUARE_BTN, 0);
    wait(wait_short);
}
combo one_right
{
    set_val(RIGHT_BUMP, 100);
    wait(wait_weapon_swap);
    set_val(RIGHT_BUMP, 0);   
    wait(wait_weapon_swap);   
}
 
combo one_right_from_build
{
    wait(wait_long);
    call (build_on_off);
    building_on = FALSE;
    wait(wait_long);   
    call (one_right);   
}
 
combo two_right
{
    call (one_right);   
    call (one_right);   
}
 
combo two_right_from_build
{
    call (one_right_from_build);
    call (one_right);       
}
 
combo three_right
{
    call (one_right);
    call (two_right);   
 
}
 
combo three_right_from_build
{
    call (one_right_from_build);
    call (two_right);   
}
 
combo one_left
{
    set_val(LEFT_BUMP, 100);
    wait(wait_weapon_swap);   
    set_val(LEFT_BUMP, 0);
    wait(wait_weapon_swap);   
}
 
combo one_left_from_build
{
    wait(wait_long);
    call (build_on_off);
    building_on = FALSE;
    wait(wait_long);
 
    call (one_left);
}
 
combo two_left
{
    call (one_left);   
    call (one_left);
}
 
combo two_left_from_build
{
    call (one_left_from_build);
    call (one_left);   
}
 
combo PRESS_Y
{
           set_val(PICKAXE_BTN,100);
        wait(wait_weapon_swap);
}
 
//combo PRESS_CIRCLE
//{
//           set_val(CIRCLE_BTN,100);
//        wait(1000);
//        wait(wait_short);
//}
 
 
 
void reset_weapon_variables()
{
     building_on         = FALSE;
     edit_on             = FALSE;
     inventory_on         = FALSE;
}
 
void normal_led()
{
           led_set(LED_1,2.0,0);
        led_set(LED_2,0.0,0);
        led_set(LED_3,0.0,0);
        led_set(LED_4,0.0,0);
}
 
void pump_led()
{
           led_set(LED_1,0.0,0);
        led_set(LED_2,3.0,0);
        led_set(LED_3,0.0,0);
        led_set(LED_4,0.0,0);
}
 
void ar_led()
{
           led_set(LED_1,0.0,0);
        led_set(LED_2,0.0,0);
        led_set(LED_3,3.0,0);
        led_set(LED_4,0.0,0);
}
 
combo blinking_led_rapid_fire_on
{
    ar_led();
    wait(500);
    pump_led();
    wait(500);
}
 
void stop_combos()
{
    combo_stop (reset_weapons);
    combo_stop (weapon_1);
    combo_stop (weapon_3);
    combo_stop (weapon_5);
 
    combo_stop (change_trap);
    combo_stop (place_trap);
    combo_stop (change_mats_building_on);
    combo_stop (change_mats_building_off);
    combo_stop (confirm_edit_from_select);
    combo_stop (confirm_edit_from_reset);
 
    combo_stop (spam_fire);
    combo_stop (ads_btn);
    combo_stop (fire_btn);
 
    combo_stop (first_ramp);
    combo_stop (first_wall);
    combo_stop (first_floor);
    combo_stop (first_roof);
 
    combo_stop (one_right);
    combo_stop (one_right_from_build);
    combo_stop (two_right);
    combo_stop (two_right_from_build);
    combo_stop (three_right);
    combo_stop (three_right_from_build);
    combo_stop (one_left);
    combo_stop (two_left);
    combo_stop (two_left_from_build);
}
 
void weapon_1_void()
{
    stop_combos();   
 
    if (building_on)
    {                                                                                       
        if      (weapon_choice == 1){combo_run (build_on_off);}
        else if (weapon_choice == 2){combo_run (one_left_from_build);}
        else if (weapon_choice == 3){combo_run (two_left_from_build);}
        else if (weapon_choice == 4){combo_run (two_right_from_build);}   
        else if (weapon_choice == 5){combo_run (one_right_from_build);}                   
        else if (weapon_choice == 6){combo_run (weapon_1);}        
    }   
    else
    {
        if      (weapon_choice == 1){combo_run (weapon_1);}
        else if (weapon_choice == 2){combo_run (one_left);}
        else if (weapon_choice == 3){combo_run (two_left);}
        else if (weapon_choice == 4){combo_run (two_right);}   
        else if (weapon_choice == 5){combo_run (one_right);}                   
        else if (weapon_choice == 6){combo_run (one_right);}        //weapon_1_from_pickaxe
    }
 
    reset_weapon_variables();           
    weapon_choice = 1;
}
 
void weapon_2_void()
{
        stop_combos();       
 
        if (building_on)
        {                                                                                       
            if      (weapon_choice == 1){combo_run (one_right_from_build);}
            else if (weapon_choice == 2){combo_run (build_on_off);}
            else if (weapon_choice == 3){combo_run (one_left_from_build);}
            else if (weapon_choice == 4){combo_run (two_left_from_build);}   
            else if (weapon_choice == 5){combo_run (two_right_from_build);}                   
            else if (weapon_choice == 6){combo_run (weapon_2);} //weapon_2_from_pickaxe
        }   
        else
        {
            if      (weapon_choice == 1){combo_run (one_right);}
            else if (weapon_choice == 2){combo_run (weapon_2);}
            else if (weapon_choice == 3){combo_run (one_left);}
            else if (weapon_choice == 4){combo_run (two_left);}   
            else if (weapon_choice == 5){combo_run (two_right);}                   
            else if (weapon_choice == 6){combo_run (two_right);}        //weapon_2_from_pickaxe
        }
 
        weapon_choice = 2;       
        reset_weapon_variables();           
 
}
 
void weapon_3_void()
{
    stop_combos();   
 
        if (building_on)
        {                                                                                       
            if      (weapon_choice == 1){combo_run (two_right_from_build);}
            else if (weapon_choice == 2){combo_run (one_right_from_build);}
            else if (weapon_choice == 3){combo_run (build_on_off);}
            else if (weapon_choice == 4){combo_run (one_left_from_build);}   
            else if (weapon_choice == 5){combo_run (two_left_from_build);}                   
            else if (weapon_choice == 6){combo_run (weapon_3);} //weapon_3_from_pickaxe
        }   
        else
        {
            if      (weapon_choice == 1){combo_run (two_right);}
            else if (weapon_choice == 2){combo_run (one_right);}
            else if (weapon_choice == 3){combo_run (weapon_3);}
            else if (weapon_choice == 4){combo_run (one_left);}   
            else if (weapon_choice == 5){combo_run (two_left);}                   
            else if (weapon_choice == 6){combo_run (three_right);}        //weapon_3_from_pickaxe
        }
 
        weapon_choice = 3;       
        reset_weapon_variables();
        building_on = FALSE;   
}
 
void weapon_4_void()
{
    stop_combos();   
 
        if (building_on)
        {                                                                                       
            if      (weapon_choice == 1){combo_run (two_left_from_build);}
            else if (weapon_choice == 2){combo_run (two_right_from_build);}
            else if (weapon_choice == 3){combo_run (one_right_from_build);}
            else if (weapon_choice == 4){combo_run (build_on_off);}   
            else if (weapon_choice == 5){combo_run (one_left_from_build);}                   
            else if (weapon_choice == 6){combo_run (weapon_4);} //weapon_4_from_pickaxe
        }   
        else
        {
            if      (weapon_choice == 1){combo_run (two_left);}
            else if (weapon_choice == 2){combo_run (two_right);}
            else if (weapon_choice == 3){combo_run (one_right);}
            else if (weapon_choice == 4){combo_run (weapon_4);}   
            else if (weapon_choice == 5){combo_run (one_left);}                   
            else if (weapon_choice == 6){combo_run (two_left);}        //weapon_4_from_pickaxe
        }
 
        weapon_choice = 4;       
        reset_weapon_variables();               
}
 
void weapon_5_void()
{
    stop_combos();   
 
    if (building_on)
    {
        if      (weapon_choice == 1) {combo_run (one_left_from_build);}
        else if (weapon_choice == 2) {combo_run (two_left_from_build);}
        else if (weapon_choice == 3) {combo_run (two_right_from_build);}
        else if (weapon_choice == 4) {combo_run (one_right_from_build);}   
        else if (weapon_choice == 5) {combo_run (build_on_off);}       
        else if (weapon_choice == 6) {combo_run (weapon_5);}    
    }
 
    else
    {
        if      (weapon_choice == 1) {combo_run (one_left);}
        else if (weapon_choice == 2) {combo_run (two_left);}
        else if (weapon_choice == 3) {combo_run (two_right);}
        else if (weapon_choice == 4) {combo_run (one_right);}   
        else if (weapon_choice == 5) {combo_run (weapon_5);}       
        else if (weapon_choice == 6) {combo_run (one_left);}    //weapon_5_from_pickaxe
 
 
    }
 
    reset_weapon_variables();
    weapon_choice = 5;       
}
 
 
combo spam_ramp
{
    set_val(ADS_BTN, 100);
    wait(5);
    set_val(ADS_BTN, 0);
    wait(5);   
}
 
combo spam_floor
{
    set_val(LEFT_BUMP, 100);
    wait(5);
    set_val(LEFT_BUMP, 0);
    wait(5);   
}
 
combo spam_roof
{
    set_val(RIGHT_BUMP, 100);
    wait(5);
    set_val(RIGHT_BUMP, 0);
    wait(5);
}
 
combo wall_replace
{
 
 
    set_val(FIRE_BTN, 100);
    wait(200);
 
    set_val(LEFT_BTN, 100);
    wait(30);
    set_val(FIRE_BTN, 100);
    wait(20);
    wait(20);
 
    set_val(FIRE_BTN, 100);
    wait(20);
    wait(20);
 
    set_val(LEFT_BTN, 100);
    wait(30);
    wait(30);
 
    wait(375);
}
 
combo emote
{
        set_val(DOWN_BTN, 100);
        wait(wait_long);   
        call (emote_reset);
        set_val(RX,emote_x); //
        set_val(RY,emote_y);    //   
        wait(100);
        set_val(CROSS_BTN,100);
        wait(wait_short);
}
 
combo emote_reset
{
        set_val(RX,100);    //   
        wait(50);       
        set_val(RX,-100);    //   
        wait(50);
        set_val(RY,100);    //   
        wait(50);       
        set_val(RY,-100);    //   
        wait(50);
 
}
 
void sensitivity()
{   
    x = abs(get_val(RX)/100.0);           
    y = abs(get_val(RY)/100.0);   
 
 
            if (mouse_status(MBUTTON_2))
            {                           
                if(!building_on)
                {   
                    // AR Sens
                    if (weapon_choice == 5 )
                    {                                                   
                        sensitivity_x = SENSITIVITY_AR ;
                        sensitivity_y = 1.1 * SENSITIVITY_AR ;
 
//                        DeadZone = DeadZone_Weapon;
                    }
                    else if (weapon_choice == 4 )
                    {                                                   
                        sensitivity_x = SENSITIVITY_SNIPER ;   
                        sensitivity_y = 1.1 * SENSITIVITY_SNIPER  ;
 
//                        DeadZone = DeadZone_Weapon;
                    }
                    else if (weapon_choice == 1 ||  weapon_choice == 2 ||  weapon_choice == 3 ||  weapon_choice == 6)
                    {                           
                        sensitivity_x = SENSITIVITY_PUMP_SMG  ;
                        sensitivity_y = 1.1 * SENSITIVITY_PUMP_SMG ;
 
//                        DeadZone = DeadZone_Weapon;
                    }
                }
                else if(building_on)
                {
                        sensitivity_x = SENSITIVITY_BUILD  ;
                        sensitivity_y = 1.5 * SENSITIVITY_BUILD ;
                }
            }
            else if (!mouse_status(MBUTTON_2)) // normal
            {                       
                sensitivity_x = SENSITIVITY_RUNNING  ;
                sensitivity_y = SENSITIVITY_RUNNING ;   
 
//                DeadZone = DeadZone_Other;           
            }
 
 
 
     a = clamp(get_val(RX) * sensitivity_x,-100.0,100.0) ;//
     b = clamp(get_val(RY) * 1.10 * sensitivity_y,-100.0,100.0) ;//1.07
     d  = (fix32) DeadZone;   
     x1 = 1.0;                                        // x1 coordinate, input magnitude
     y1 = d + x1;                                    // y1 coordinate, output magnitude
     x2 = sqrt(sq(100.0) + sq(100.0));                // x2 coordinate, input magnitude     90.0
     y2 = x2;                                        // y2 coordinate, output magnitude
     m = (y2 - y1)/(x2 - x1);                        // slope
     c = y1 - (m * x1);                            // constant
     p = sqrt(sq(a) + sq(b));                      // original magnitude
     y0 = (m * p) + c;                             // new magnitude
     s = y0 / p ;                                    // scaling factor
 
    set_val(RX, clamp(a * s ,-100.0,100.0));
    set_val(RY, clamp(b * s,-100.0,100.0));   
 
    if (mouse_status(MBUTTON_2) && !building_on)
    {
        if(weapon_choice == 1 || weapon_choice == 2 )
        {
            set_val(RX, clamp(get_val(RX),-90.0,90.0));
            set_val(RY, clamp(get_val(RY),-90.0,90.0));
        }
    }
}   
 
 
User avatar
Nstarnoe
Master Sergeant
Master Sergeant
 
Posts: 40
Joined: Sun Jan 13, 2019 2:19 pm

Re: Will script size affect performance?

Postby Scachi » Sat Jun 08, 2019 10:08 pm

You are monitoring a lot of keys. The xekys header file can handle around 20 if I remember correctly, after that it will reach the 100% cpu usage or more.
Start the script, open the Device Monitor, and hold down a key..the CPU will go over 100% ..that will cause problems sooner or later.

I'll test some ideas and reply later or tomorrow.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Will script size affect performance?

Postby Nstarnoe » Sat Jun 08, 2019 10:31 pm

that could actually explain a lot, i have expanded the use of keys lately - it's just such a brilliant feature.

and again, so much appreciate you help :)

could i ask one more favor, i think it's a no brainier for you, but i am struggling with it.

instead of having a combo for wall, ramp, floor and roof (the same combo, only different button presses), i could have one combo running a variable button press). But I cant figure out how to define is... something like (only it dosen't work);

#define structure;

main ...
{

if (xkeys_event_active(RAMP_KEY) || xkeys_event_active(WALL_KEY) || xkeys_event_active(FLOOR_KEY) || xkeys_event_active(ROOF_KEY))
{
if (xkeys_event_active(RAMP_KEY)) {structure ADS_BTN} //how do i do this bit?
else if (xkeys_event_active(WALL_KEY)) {structure FIRE_BTN)
else if (xkeys_event_active(FLOOR_KEY) {structure LEFT_BUMP)
else if (xkeys_event_active(ROOF_KEY)) {structure RIGHT_BUMP)

if(!building_on) {combo_run(first_build);}

}

}

combo first_build
{
call(build_on_off);
building_on = TRUE;
call(structure);
call(structure);
call(structure);

}
User avatar
Nstarnoe
Master Sergeant
Master Sergeant
 
Posts: 40
Joined: Sun Jan 13, 2019 2:19 pm

Re: Will script size affect performance?

Postby Nstarnoe » Sat Jun 08, 2019 10:37 pm

ups sorry, like this ....

Code: Select all
 
 
    #define RIGHT_BUMP            BUTTON_4         //PS4_R1;
    #define FIRE_BTN            BUTTON_8         //PS4_R2;
    #define LEFT_BUMP            BUTTON_7         //PS4_L1;
    #define ADS_BTN            BUTTON_5         //PS4_L2;        
    #define structure;   
 
main
{
    if (xkeys_event_active(RAMP_KEY) || xkeys_event_active(WALL_KEY) || xkeys_event_active(FLOOR_KEY) || xkeys_event_active(ROOF_KEY))
    {
        stop_combos();
 
        if        (xkeys_event_active(RAMP_KEY))     {structure = ADS_BTN;}
        else if    (xkeys_event_active(WALL_KEY))     {structure = FIRE_BTN;)
        else if    (xkeys_event_active(FLOOR_KEY)     {structure = LEFT_BUMP;)
        else if    (xkeys_event_active(ROOF_KEY))     {structure = RIGHT_BUMP;)   
 
        if(!building_on){combo_run(first_build);}   
 
    }
 
 
combo first_build
{
    call(build_on_off);   
    building_on = TRUE;           
    call(place_build);   
    call(place_build);
    call(place_build);   
 
}
 
combo place_build
{
    set_val(structure, 100);
    wait(wait_short);
    set_val(structure, 0);
    wait(wait_short);
}
 
}
 
 
 
 
 
User avatar
Nstarnoe
Master Sergeant
Master Sergeant
 
Posts: 40
Joined: Sun Jan 13, 2019 2:19 pm

Re: Will script size affect performance?

Postby Scachi » Sat Jun 08, 2019 10:47 pm

Buttons are of datatype uint8 and don't use "#define" when you want to change the set value for that during your script.
Nstarnoe wrote:ups sorry, like this ....

Code: Select all
 
 
    #define RIGHT_BUMP            BUTTON_4         //PS4_R1;
    #define FIRE_BTN            BUTTON_8         //PS4_R2;
    #define LEFT_BUMP            BUTTON_7         //PS4_L1;
    #define ADS_BTN            BUTTON_5         //PS4_L2;        
    uint8 structure; // buttons are of datatype uint8
 
main
{
    if (xkeys_event_active(RAMP_KEY) || xkeys_event_active(WALL_KEY) || xkeys_event_active(FLOOR_KEY) || xkeys_event_active(ROOF_KEY))
    {
        stop_combos();
 
        if        (xkeys_event_active(RAMP_KEY))     {structure = ADS_BTN;}
        else if    (xkeys_event_active(WALL_KEY))     {structure = FIRE_BTN;)
        else if    (xkeys_event_active(FLOOR_KEY)     {structure = LEFT_BUMP;)
        else if    (xkeys_event_active(ROOF_KEY))     {structure = RIGHT_BUMP;)   
 
        if(!building_on){combo_run(first_build);}   
 
    }
 
 
combo first_build
{
    call(build_on_off);   
    building_on = TRUE;           
    call(place_build);   
    call(place_build);
    call(place_build);   
 
}
 
combo place_build
{
    set_val(structure, 100);
    wait(wait_short);
    set_val(structure, 0);
    wait(wait_short);
}
 
}
 
 
 
 
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Will script size affect performance?

Postby Nstarnoe » Sat Jun 08, 2019 10:48 pm

Thank you so much :)
User avatar
Nstarnoe
Master Sergeant
Master Sergeant
 
Posts: 40
Joined: Sun Jan 13, 2019 2:19 pm

Re: Will script size affect performance?

Postby Scachi » Sun Jun 09, 2019 8:27 am

Ok..something for you to try...

create a file xin.gph in the directory of your script file and copy all the code into it:
Code: Select all
// XIN by scachi, version alpha.0000001
//
#define XIN_NOMOUSE
 
#ifndef KEYBOARD_GPH_
#include <keyboard.gph> // titan two keyboard stuff
#endif
 
#ifndef XIN_NOMOUSE
    #ifndef MOUSE_GPH_
    #include <mouse.gph>         // titan two mouse stuff
    #endif
#endif
 
// xkeys compatibility
#ifdef KEYS_TO_MONITOR_MAX
    #define XIN_MONITOR_MAX KEYS_TO_MONITOR_MAX
#endif
#define xkeys_add(_x)                     (xin_add_k(_x))
#define xkeys_event_active(_x)     (xin_track(_x)==XIN_EV_ACTIVE)
#define xkeys_time_active(_x)     (xin_time_active(_x))
#define xkeys_event_release(_x) (xin_track(_x)==XIN_EV_RELEASE)
 
 
#ifndef XIN_MONITOR_MAX
    #define XIN_MONITOR_MAX 9 // copy this line to your main script to change the maximum number of keys to check
#endif
 
#ifndef xin_GPH_
#define xin_GPH_
 
uint16  xin_monitor[XIN_MONITOR_MAX]; // the inputs to monitor (like KEY_A or MBUTTON_1)
uint8   xin_state[XIN_MONITOR_MAX];   // tracking state: on/off/is_/event_
uint8   xin=0;        // keep track of the number of inputs to monitor
 
#define XIN_IS_RELEASE    0
#define XIN_EV_ACTIVE        1
#define XIN_IS_ACTIVE        2
#define XIN_EV_RELEASE    3
 
 
#define xin_add_k(_x) xin_add(_x)
#define xin_add_m(_x) xin_add(_x+0x0100)
#define xin_syst    system_time()
 
 
#define xin_is_active(_x_i)            (xin_track(_x_i)==XIN_IS_ACTIVE)
#define xin_is_release(_x_i)        (xin_track(_x_i)==XIN_IS_RELEASE)
#define xin_event_active(_x_i)    (xin_track(_x_i)==XIN_EV_ACTIVE)
#define xin_event_release(_x_i)    (xin_track(_x_i)==XIN_EV_RELEASE)
 
 
#ifndef XIN_NOTIME  // time_active time_release tracking
    uint32  xin_state_time_active[XIN_MONITOR_MAX];
    uint32  xin_state_time_release[XIN_MONITOR_MAX];
#endif
 
//bool        xin_k;                                    // result of: key_check
 
#ifndef XIN_NOMOUSE    // disable mouse event functions
    bool        xin_m;                                    // result of: mouse_status(MREPORT_UPDATED)
    int8        xin_mwheel;                            // mouse wheel
    #ifndef XIN_MWHEEL_TLIMIT                // time limit until same direction is recognized as new input
        #define XIN_MWHEEL_TLIMIT 200
    #endif
#endif
 
// own main loop, nothing to add to your script for monitoring the inputs, just use the events to add functionality
main {
 
#ifndef XIN_NOMOUSE
    if (xin_m=mouse_status(MREPORT_UPDATED)) {
        xin_mwheel=mouse_status(MOUSE_WHEEL);
    }
#endif
}
 
uint8 xin_track(uint8 idx) {
 
#ifndef XIN_NOMOUSE
    if (xin_monitor[idx] & 0x0100) {    // MOUSE
        curStat=xin_mouse_status(idx);
    } else {                                                    // KEYBOARD
        if (xin_k) curStat=key_status(xin_monitor[idx]);
    }
#endif
 
    if (key_status(xin_monitor[idx])) {                                                // ---------- not active
        if (xin_state[idx]!=XIN_IS_ACTIVE) xin_track_active(idx);
    } else {                                                            // ---------- active
        if (xin_state[idx]!=XIN_IS_RELEASE) xin_track_release(idx);
    }
 
 
    return xin_state[idx];
}
 
#ifndef XIN_NOMOUSE
bool xin_mouse_status(uint8 idx) {
    uint8 mouseID= xin_monitor[idx]-0x0100;   
    if (mouseID==2) {
        if (xin_mwheel== 1) return TRUE;
        return FALSE;
    }
    if (mouseID==3) {
        if (xin_mwheel==-1) return TRUE;
        return FALSE;
    }
    return mouse_status(mouseID);
}
 
combo xin_cmwheel {
    wait(XIN_MWHEEL_TLIMIT);
}
#endif
 
void xin_track_release(uint8 idx) {
    if (xin_state[idx]==XIN_EV_RELEASE) {
        xin_state[idx]=XIN_IS_RELEASE;        // is_release
    }
 
    if (xin_state[idx]==XIN_IS_ACTIVE) {
        xin_state[idx]=XIN_EV_RELEASE;            // event_release
        #ifndef XIN_NOTIME
            xin_state_time_release[idx] = xin_syst;
        #endif
    }
}
 
void xin_track_active(uint8 idx) {       
    if (xin_state[idx]==XIN_EV_ACTIVE) {
        xin_state[idx]=XIN_IS_ACTIVE;            // is_active
    }
 
    if (xin_state[idx]==XIN_IS_RELEASE) {
        xin_state[idx]=XIN_EV_ACTIVE;            // event_active
        #ifndef XIN_NOTIME
        xin_state_time_active[idx] = xin_syst;
        #endif               
    }
}
 
 
// add an input to monitoring
uint8 xin_add(uint16 new_idx) {
  if (xin >= XIN_MONITOR_MAX) return 254;
#ifdef XIN_DEBUG
    if (new_idx & 0x0100) {
        printf("mouse! %d",new_idx-0x0100);
    } else {
        printf("key! %d",new_idx);
        xin_monitor[xin]=new_idx;
    }
#endif   
    xin_monitor[xin]=new_idx;
  xin++;
  return  xin-1;
}
 
 
#ifndef XIN_NOTIME   // time_active and time_release functions
uint32 xin_time_active(uint8 keyidx) {
    return(xin_syst - xin_state_time_active[keyidx]);
}
 
uint32 xin_time_release(uint8 keyidx) {
  if (xin_state_time_release[keyidx] == 0) return 0;
  return(xin_syst - xin_state_time_release[keyidx]);
}
 
bool xin_check_active(uint8 keyidx, uint32 ms) {
    return(xin_state[keyidx] && xin_syst - xin_state_time_active[keyidx] >= ms);
}
 
bool xin_check_release(uint8 keyidx, uint32 ms) {
    if (xin_state_time_release[keyidx] == 0) return 0;
    return(!xin_state[keyidx] && xin_syst - xin_state_time_release[keyidx] >= ms);
}
#endif
 
#endif
 



Modify your own script file now so that the first lines read this (no "xkeys" anymore in the first lines, replaced by "xin"):
Code: Select all
 
#pragma METAINFO("Fortnite T2 on PS4", 7,71, "Nikolaj")
 
#include "keyboard.gph"
#include "mouse.gph"
#define XIN_MONITOR_MAX 31 // new: replaces KEYS_TO_MONITOR_MAX !! the order matters, #define first, then the include
#include "xin.gph"  // new : replaces xkeys.gph
 


If I didn't miss something and you named + save the xin.gph file into your scripts directory your script should still compile and work.
It still reaches 100% cpu and a bit more but should run less cpu intensive than before.

If everything is working you should take a look at your code and check your "//set led's" section.
You should run led_reset or led_set lines only once when the led really changes.
As an example it looks like you run this all the time when rapid 1&2 is off , ignoring that the led is already set to normal_led.
This can cause your issues with T2 locking up too.
Code: Select all
//set led's
    if (!rapid_fire_1_on && !rapid_fire_5_on)
    {       
        led_reset();
        normal_led();
    }


Another problem is your combo "blinking_led_rapid_fire_on".
When you call a led_set or led_reset commands from inside a combo like you are doing here you have to add a wait(0); right after you led section so this section gets only run once.
Without that additional wait your combo will run for 500ms the led_set command over and over again.


Not sure if this will really work but it should give you an idea how to fix it, replace your current led code section with this:
Code: Select all
//set led's
static uint8 LedState=0; // keep track of last set led mode
    if (!rapid_fire_1_on && !rapid_fire_5_on)
    {       
                if (LedState!=1) {
                    LedState=1;
                    led_reset();
                    normal_led();
                }
    }
    else if (rapid_fire_1_on && !rapid_fire_5_on)
    {
                if (LedState!=2) {
                    LedState=2;
                    led_reset();
                    pump_led();   
                }
    }
    else if (!rapid_fire_1_on && rapid_fire_5_on)
    {
                if (LedState!=3) {
                    LedState=3;
                    led_reset();
                    ar_led();   
                }
    }       
    else if (rapid_fire_1_on && rapid_fire_5_on)
    {
                LedState=4;
        combo_run (blinking_led_rapid_fire_on);   
    }


and the combo:
Code: Select all
combo blinking_led_rapid_fire_on
{
    led_reset(); ar_led(); wait(0);
    wait(500);
    led_reset(); pump_led(); wait(0);
    wait(500);
}
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Next

Return to GPC2 Script Programming

Who is online

Users browsing this forum: fox5, midg3t2 and 65 guests