[Help Request] - Helldivers

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

[Help Request] - Helldivers

Postby Shaag7 » Mon Feb 08, 2016 10:50 am

-----------------------------------------------------------------------------------------
EDIT: Final version released to the GPC Library http://www.consoletuner.com/gpclib/?s=1104
Version history:
* 26-Feb-2016: 1.2 - Workaround for R1 and Cross[4] collision - No-Array variables
* 26-Feb-2016: 1.1 - Workaround for R1 and Cross[4] collision - deleted 1 profile
* 19-Feb-2016: 1.0 - Release
* 16-Feb-2016: 0.9 - Beta Release

NOTE: I'll keep posts bellow as help for others (if they seek script optimisation - how to use Data segments)
-----------------------------------------------------------------------------------------
Hi all,

I would like to ask for help with my new Helldivers script optimisation.
Main purpose of this script is Autorun and Stratagem commands (pushing DPAD keys in predefined order for item/usage)
I was going to add 4 profiles support (R3+DPAD) which would allow user to have 4 different stratagems setups for standard gameplay.
I have currently problem with full stack (code length probably as well).

Do you see some solution/advice for this?

Thanks

Code: Select all

/*
This is Helldivers Autorun and Stratagem macro script.
Stratagem combos are taken from http:
//helldivers.gamepedia.com/Stratagems
*/

// ****************************************************************************
// ******** DUE TO MAX STACK SIZE SOME COMBOS HAVE TO BE COMMENTED ************
// ******************UNCOMMENT COMBOS FOR YOUR STRATAGEM USE*******************
// ****************COMMENT COMBOS NOT IN USE TO SAVE STACK SIZE****************
// ****************************************************************************

int RunON = TRUE;
int delay = 40; // Delay between button interactions

// MAIN
main {

if (get_val(PS4_L3) && !get_val(PS4_L1)) {RunON = !RunON;}

if(RunON==TRUE) colorled(0,1,0,0);  // dim red
if(RunON==FALSE) colorled(1,0,0,0); // dim blue

// Auto-Run
    if((abs(get_val(PS4_LX)) > 70 || abs(get_val(PS4_LY)) > 70) && RunON) {
        set_val(PS4_L3,100);
        }

// Press L1 and trigger combos from bellow (change combos by your needs)
     if (get_val(PS4_L1)) {
        if (event_press(PS4_R3)) {combo_run(Reinforce);} //Special
        if (event_press(PS4_L3)) {combo_run(NUX);}       //Special
        if (event_press(PS4_R1)) {combo_run(Sniffer);}   //Special
        if (event_press(PS4_L2)) {combo_run(SOS);}       //Special

        if (event_press(PS4_CROSS)) {combo_run(EXO44);}
        if (event_press(PS4_CIRCLE)) {combo_run(AMG);}
        if (event_press(PS4_TRIANGLE)) {combo_run(SH32);}
        if (event_press(PS4_SQUARE)) {combo_run(M25);}
        }
 
} // MAIN END


// COMBOS



// Supply Stratagems
//combo AC22 {DD();DL();DU();DU();DR();}                  //AC-22 Dum-Dum *
//combo AD289 {DD();DU();DL();DL();DR();DD();}            //AD-289 Angel *
//combo AD334 {DD();DU();DL();DU();DR();DD();}            //AD-334 Guard Dog *
//combo EAT17 {DD();DL();DR();DU();DD();}                 //EAT-17     
combo EXO44 {DD();DR();DU();DL();DD();DD();}              //EXO-44 Walker Exosuit
combo EXO48 {DD();DR();DU();DL();DD();DL();}              //EXO-48 Obsidian Exosuit *
combo EXO51 {DD();DR();DU();DL();DD();DR();}              //EXO-51 Lumberer Exosuit *
combo FLAM40 {DD();DL();DD();DR();DL();}                  //FLAM-40 Incinerator
//combo LAS98 {DD();DL();DD();DU();DL();}                 //LAS-98 Laser Cannon
//combo LIFT850 {DD();DU();DU();DD();DU();}               //LIFT-850 Jump Pack
combo M25 {DD();DL();DU();DL();DL();}                     //M-25 Rumbler *
//combo M5 {DD();DR();DD();DL();DL();DR();}               //M5 APC
//combo M5HAV {DD();DR();DU();DL();DU();DD();}            //M5-32 HAV
//combo MC109 {DD();DR();DD();DL();DL();DU();}            //MC-109 Hammer Motorcycle *
//combo M94 {DD();DL();DD();DU();DR();}                   //MG-94 Machine Gun
//combo MLS4X {DD();DL();DU();DD();DR();}                 //MLS-4X Commando *
//combo Obliter {DD();DL();DU();DL();DD();}               //Obliterator Grenade Launcher
//combo REC6 {DD();DL();DR();DU();DU();}                  //REC-6 Demolisher *
//combo REP80 {DD();DD();DL();DR();DD();}                 //REP-80
combo RESSUPLY {DD();DD();DU();DR();}                     //Resupply
combo RESPACK {DD();DU();DD();DD();DR();}                 //Resupply Pack
combo RL112 {DD();DL();DR();DR();DL();}                   //RL-112 Recoilless Rifle
combo SH20 {DD();DU();DL();DR();DL();DR();}               //SH-20 Shield Generator Pack
combo SH32 {DD();DU();DL();DR();DL();DD();}               //SH-32 Directional Kinetic Shield *
//combo TD110 {DD();DR();DD();DL();DU();DR();}            //TD-110 Bastion *
//combo TOX13 {DD();DL();DD();DR();DR();}                 //TOX-13 Avenger *
                                                          //
// Defensive Stratagems                                   //
//combo AAC6 {DL();DD();DD();DU();DR();DL();}             //A/AC-6 Tesla Tower
combo AMG {DL();DD();DU();DR();DL();}                     //A/MG-II Minigun Turret
//combo ARX {DL();DD();DU();DL();DR();}                   //A/RX-34 Railcannon Turret
//combo APMINE {DL();DR();DD();DU();}                     //Airdropped Anti-Personnel Mines
//combo STUNMINE {DL();DR();DU();DD();}                   //Airdropped Stun Mines
combo APBAR {DL();DR();DD();DD();DR();}                   //Anti-Personnel Barrier *
//combo AT47 {DL();DL();DU();DU();DR();DL();}             //AT-47 Anti-Tank Emplacement *
//combo DISTRACT {DL();DD();DR();}                        //Distractor Beacon
combo UAV {DL();DU();DR();}                               //Humblebee UAV drone *
                                                          //
// Offensive Stratagems                                   //
//combo AIRSTRIKE {DR();DU();DD();DR();DL();}             //Airstrike
//combo CLOSEAIR {DR();DR();DD();DL();}                   //Close Air Support *
//combo INCEDRIARY {DR();DU();DL();DR();}                 //Incendiary Bombs
//combo BARRAGE {DR();DD();DD();DD();DL();DD();}          //Missile Barrage *
//combo ORBITAL {DR();DU();DL();DU();DR();DL();}          //Orbital Laser Strike
//combo RAILCAN {DR();DD();DU();DD();DL();}               //Railcannon Strike
//combo SHREDDER {DR();DL();DR();DL();DD();DD();DR();}    //Shredder Missile Strike
//combo SLEDGE {DR();DU();DL();DU();DD();DR();}           //Sledge Precision Artillery *
//combo STATIC {DR();DU();DL();DD();}                     //Static Field Conductors
combo STRAFING {DR();DR();DU();}                          //Strafing Run
//combo THUNDER {DR();DD();DU();DU();DL();DD();}          //Thunderer Barrage
combo VINDICATOR {DR();DR();DR();}                        //Vindicator Dive Bomb                 
                                                          //
// Special Stratagems                                     //
combo Reinforce {DU();DD();DR();DL();DU();}               //Reinforce
combo NUX {DU();DL();DR();DD();DU();DD();}                //NUX-223 Hellbomb
combo Sniffer {DD();DD();DR();DU();}                      //ME-1 Sniffer Metal Detector
combo SOS {DU();DD();DR();DU();}                          //Emergency Beacon
                                                         
// Wait time between presses for functions processing
combo WaitTime {
wait(delay);
}


// functions for DPAD - Press button, wait, release button, wait.
function DU(){set_val(PS4_UP, 100);combo_run(WaitTime);set_val(PS4_UP, 0);combo_run(WaitTime);}
function DD(){set_val(PS4_DOWN, 100);combo_run(WaitTime);set_val(PS4_DOWN, 0);combo_run(WaitTime);}
function DL(){set_val(PS4_LEFT, 100);combo_run(WaitTime);set_val(PS4_LEFT, 0);combo_run(WaitTime);}
function DR(){set_val(PS4_RIGHT, 100);combo_run(WaitTime);set_val(PS4_RIGHT, 0);combo_run(WaitTime);}

function colorled(a,b,c,d) {
      set_led(LED_1,a);
      set_led(LED_2,b);
      set_led(LED_3,c);
      set_led(LED_4,d);
}
Last edited by Shaag7 on Wed Feb 24, 2016 6:13 pm, edited 6 times in total.
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: Script Optimisation - Helldivers

Postby J2Kbr » Mon Feb 08, 2016 12:54 pm

You have too may combos. Each combo utilizes 3 control variables (total of 6 bytes). My suggestion is utilize the data segment to store the combo sequences you have and then use it to drive a single generic combo. I did something similar to that for War Gods, a old fighting game:

Code: Select all
/* -----------------------------------------------------------------------------
 *  DEFINES
**/

define LX                   =  11; // PS3_LX,       XB360_LX
define LY                   =  12; // PS3_LY,       XB360_LY
define DL                   =  15; // PS3_LEFT,     XB360_LEFT
define DR                   =  16; // PS3_RIGHT,    XB360_RIGHT

define DPAD_UP              =  13; // PS3_UP,       XB360_UP
define DPAD_DOWN            =  14; // PS3_DOWN,     XB360_DOWN
define B_LOW_PUNCH          =  19; // PS3_CROSS,    XB360_A
define B_HIGH_PUNCH         =  20; // PS3_SQUARE,   XB360_X
define B_LOW_KICK           =  18; // PS3_CIRCLE,   XB360_B
define B_HIGH_KICK          =  17; // PS3_TRIANGLE, XB360_Y
define B_BLOCK              =   3; // PS3_R1,       XB360_RB
define B_THREED             =   6; // PS3_L1,       XB360_LB

define DATA_END             = 255;

define AHAU_KIN             =   1;
define ANUBIS               =   2;
define CY_5                 =   3;
define EXOR                 =   4;
define GROX                 =   5;
define KABUKI_JO            =   6;
define MAXIMUS              =   7;
define PAGAN                =   8;
define TAK                  =   9;
define VALLAH               =  10;
define VOODOO               =  11;
define WARHEAD              =  12;
define CHARACTER_END        = 254;

define COMBO_1              =   1;
define COMBO_2              =   2;
define FATALITY_1           =   3;
define FATALITY_2           =   4;
define COMBO_END            = 253;

define DISTANCE             =   0;
define FORWARD              =   1;
define BACK                 =   2;
define UP                   =   4;
define UP_FORWARD           =   5;
define UP_BACK              =   6;
define DOWN                 =   8;
define DOWN_FORWARD         =   9;
define DOWN_BACK            =  10;
define WAIT                 =  16;
define LOW_PUNCH            = 129;
define HIGH_PUNCH           = 130;
define LOW_KICK             = 132;
define HIGH_KICK            = 136;
define BLOCK                = 144;
define THREED               = 160;
define PLUS                 = 249;
define HOLD                 = 251;
define RELEASE              = 253;

define CLOSE                =   0;
define SWEEP                =  70;
define JUMP                 = 100;

/* -----------------------------------------------------------------------------
 *  DATA SEGMENT
**/

data (
    AHAU_KIN,
        COMBO_1,
            BACK,           4,
            FORWARD,        4,
            HIGH_KICK,      4,
            LOW_KICK,       4,
            HIGH_KICK,      4,
            LOW_PUNCH,      4,
            LOW_PUNCH,      4,
            HIGH_PUNCH,     4,
            HIGH_PUNCH,     4,
            HIGH_PUNCH,     4,
            HIGH_KICK,      4,
        COMBO_END,
    CHARACTER_END,
    ANUBIS,
        COMBO_1,
            BACK,           4,
            FORWARD,        4,
            HIGH_PUNCH,     4,
            HIGH_KICK,      4,
            HIGH_PUNCH,     4,
            LOW_PUNCH,      4,
            BLOCK,          4,
            FORWARD,        4,
            FORWARD,        4,
            BACK,           4,
            FORWARD,        4,
            HIGH_KICK,   PLUS,
            LOW_KICK,       4,
        COMBO_END,
        FATALITY_1,
            DISTANCE,   SWEEP,
            BLOCK,       HOLD,
            FORWARD,     HOLD,
            DOWN,        HOLD,
            FORWARD,  RELEASE,
            DOWN,     RELEASE,
            UP,             4,
            DOWN,           4,
            BLOCK,    RELEASE,
            HIGH_PUNCH,  PLUS,
            LOW_KICK,    PLUS,
            THREED,         4,
        COMBO_END,
    CHARACTER_END,
DATA_END);

/* -----------------------------------------------------------------------------
 *  VARIABLES
**/

int DPAD_BACK = DL, DPAD_FORWARD = DR;
int step, dpad, hpad, press, hold, ms;
int character;

/* -----------------------------------------------------------------------------
 *  INITIALIZATION
**/

init {
    character = ANUBIS;
}

/* -----------------------------------------------------------------------------
 *  MAIN SCRIPT
**/

main {
    if(get_val(DR) || get_val(LX) >= 30) {
        DPAD_BACK = DL; DPAD_FORWARD = DR;
    } else if(get_val(DL) || get_val(LX) <= -30) {
        DPAD_BACK = DR; DPAD_FORWARD = DL;
    }
    if(get_val(PS3_L2)) {
        if(event_press(B_LOW_PUNCH)) {
            RunCombo(character, COMBO_1);
        } else if(event_press(B_HIGH_PUNCH)) {
            RunCombo(character, COMBO_2);
        } else if(event_press(B_LOW_KICK)) {
            RunCombo(character, FATALITY_1);
        } else if(event_press(B_HIGH_KICK)) {
            RunCombo(character, FATALITY_2);
        } else if(event_press(B_THREED)) {
            step = 0; dpad = 0; hpad = 0; press = 0; hold = 0; ms = 0;
            combo_stop(Step);
        }
    }
    if(step > 0) {
        set_val(DPAD_BACK, 0);
        set_val(DPAD_FORWARD, 0);
        set_val(DPAD_UP, 0);
        set_val(DPAD_DOWN, 0);
        set_val(B_LOW_PUNCH, 0);
        set_val(B_HIGH_PUNCH, 0);
        set_val(B_LOW_KICK, 0);
        set_val(B_HIGH_KICK, 0);
        set_val(B_BLOCK, 0);
        set_val(B_THREED, 0);
        if(!combo_running(Distance)) combo_run(Step);
    }
}

/* -----------------------------------------------------------------------------
 *  COMBOS
**/

combo Step {
    DoDPad();
    DoHPad();
    DoPress();
    DoHold();
    wait(60);
    DoHPad();
    DoHold();
    wait(ms);
    DoHPad();
    DoHold();
    GetStep();
}

combo Distance {
    set_val(DPAD_BACK, 100);
    wait(ms);
    GetStep();
}

/* -----------------------------------------------------------------------------
 *  FUNCTIONS
**/

function RunCombo(pC, pT) {
    step = 0;
    while(TRUE) {
        if(dbyte(step) == DATA_END) {
            step = -1; return;
        } else if(dbyte(step) == pC) {
            step = step + 1;
            while(TRUE) {
                if(dbyte(step) == CHARACTER_END) {
                    step = -1; return;
                } else if(dbyte(step) == pT) {
                    step = step + 1;
                    GetStep();
                    return;
                } else while(dbyte(step) != COMBO_END) step = step + 1;
                step = step + 1;
            }
        } else while(dbyte(step) != CHARACTER_END) step = step + 1;
        step = step + 1;
    }
}

function GetStep() {
    ms = PLUS;
    press = 0;
    dpad = 0;
    while(ms == PLUS) {
        if(dbyte(step) == COMBO_END) {
            dpad = 0;
            hpad = 0;
            press = 0;
            hold = 0;
            ms = 0;
            step = 0;
            return;
        } else if(dbyte(step) == DISTANCE) {
            combo_restart(Distance);
            ms = dbyte(step + 1);
        } else if(test_bit(dbyte(step), 7)) {
            if(dbyte(step + 1) == HOLD) {
                hold = SET(dbyte(step), hold);
                ms = 0;
            } else if(dbyte(step + 1) == RELEASE) {
                hold = CLEAR(dbyte(step), hold);
                ms = 0;
            } else {
                press = SET(dbyte(step), press);
                ms = dbyte(step + 1);
            }
        } else if(dbyte(step) == WAIT) {
            ms = dbyte(step + 1);
        } else {
            if(dbyte(step + 1) == HOLD) {
                hpad = SET(dbyte(step), hpad);
                ms = 0;
            } else if(dbyte(step + 1) == RELEASE) {
                hpad = CLEAR(dbyte(step), hpad);
                ms = 0;
            } else {
                dpad = SET(dbyte(step), dpad);
                ms = dbyte(step + 1);
            }
        }
        step = step + 2;
    }
    ms = ms * 10;
}

function SET(t, s) {
    if(test_bit(t, 0)) set_bit(s, 0);
    if(test_bit(t, 1)) set_bit(s, 1);
    if(test_bit(t, 2)) set_bit(s, 2);
    if(test_bit(t, 3)) set_bit(s, 3);
    if(test_bit(t, 4)) set_bit(s, 4);
    if(test_bit(t, 5)) set_bit(s, 5);
    if(test_bit(t, 6)) set_bit(s, 6);
    return(s);
}

function CLEAR(t, s) {
    if(test_bit(t, 0)) clear_bit(s, 0);
    if(test_bit(t, 1)) clear_bit(s, 1);
    if(test_bit(t, 2)) clear_bit(s, 2);
    if(test_bit(t, 3)) clear_bit(s, 3);
    if(test_bit(t, 4)) clear_bit(s, 4);
    if(test_bit(t, 5)) clear_bit(s, 5);
    if(test_bit(t, 6)) clear_bit(s, 6);
    return(s);
}

function DoDPad() {
    if(test_bit(dpad, 0))  set_val(DPAD_FORWARD, 100);
    if(test_bit(dpad, 1))  set_val(DPAD_BACK, 100);
    if(test_bit(dpad, 2))  set_val(DPAD_UP, 100);
    if(test_bit(dpad, 3))  set_val(DPAD_DOWN, 100);
}

function DoHPad() {
    if(test_bit(hpad, 0))  set_val(DPAD_FORWARD, 100);
    if(test_bit(hpad, 1))  set_val(DPAD_BACK, 100);
    if(test_bit(hpad, 2))  set_val(DPAD_UP, 100);
    if(test_bit(hpad, 3))  set_val(DPAD_DOWN, 100);
}

function DoPress() {
    if(test_bit(press, 0)) set_val(B_LOW_PUNCH, 100);
    if(test_bit(press, 1)) set_val(B_HIGH_PUNCH, 100);
    if(test_bit(press, 2)) set_val(B_LOW_KICK, 100);
    if(test_bit(press, 3)) set_val(B_HIGH_KICK, 100);
    if(test_bit(press, 4)) set_val(B_BLOCK, 100);
    if(test_bit(press, 5)) set_val(B_THREED, 100);
}

function DoHold() {
    if(test_bit(hold, 0))  set_val(B_LOW_PUNCH, 100);
    if(test_bit(hold, 1))  set_val(B_HIGH_PUNCH, 100);
    if(test_bit(hold, 2))  set_val(B_LOW_KICK, 100);
    if(test_bit(hold, 3))  set_val(B_HIGH_KICK, 100);
    if(test_bit(hold, 4))  set_val(B_BLOCK, 100);
    if(test_bit(hold, 5))  set_val(B_THREED, 100);
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 19359
Joined: Tue Mar 18, 2014 1:39 pm

Re: Script Optimisation - Helldivers

Postby Shaag7 » Mon Feb 08, 2016 1:08 pm

Thanks for advice J2...
This is exactly what I was looking for.

I'll post the script to the library when finished.

EDIT: after going through the script more deeply, this is sooo nice solution to the profiling I would like to do.
GG mate ;-)
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: Script Optimisation - Helldivers

Postby J2Kbr » Tue Feb 09, 2016 10:35 am

you are welcome! :) Having any doubts about the data segment, please let me know!!
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 19359
Joined: Tue Mar 18, 2014 1:39 pm

[Solved]Re: Script Optimisation - Helldivers

Postby Shaag7 » Tue Feb 16, 2016 5:07 pm

J2Kbr wrote:you are welcome! :) Having any doubts about the data segment, please let me know!!


It took me some time to choose correct data segment process, but it is really simple and working script now.
Instead of StackMemory>100% and BytecodeSize>4k with just ~16 combos, I have all combos there and its only 1333 bytes and 14 words.
I'll add profiling with rumble now and its just done :-).

Thanks for your advice

Code: Select all
//NAME: Helldivers (Stratagem,Autorun,Ressurect,Melee)
//VER:  0.9
/* =============================================================================
* Author: Shaag7
*
* Functions: Stratagem macros, Autorun, TurboRessurect, TurboMelee
* Stratagem combos are taken from http:
//helldivers.gamepedia.com/Stratagem
*
* Changes:
* 16-Feb-2016: 0.9 - Beta Release
* =============================================================================*/

/*
-----------------------------------------------------------------------------
DEFINES
-----------------------------------------------------------------------------
*/

 
// Supply Stratagems
define  AC22            = 1;         //AC-22 Dum-Dum *                   
define  AD289           = 2;         //AD-289 Angel *                     
define  AD334           = 3;         //AD-334 Guard Dog *                 
define  EAT17           = 4;         //EAT-17                             
define  EXO44           = 5;         //EXO-44 Walker Exosuit             
define  EXO48           = 6;         //EXO-48 Obsidian Exosuit *         
define  EXO51           = 7;         //EXO-51 Lumberer Exosuit *         
define  FLAM40          = 8;         //FLAM-40 Incinerator               
define  LAS98           = 9;         //LAS-98 Laser Cannon               
define  LIFT850         = 10;        //LIFT-850 Jump Pack                 
define  M25             = 11;        //M-25 Rumbler *                     
define  M5              = 12;        //M5 APC                             
define  M5HAV           = 13;        //M5-32 HAV                         
define  MC109           = 14;        //MC-109 Hammer Motorcycle *         
define  M94             = 15;        //MG-94 Machine Gun                 
define  MLS4X           = 16;        //MLS-4X Commando *                 
define  OBLITERATOR     = 17;        //Obliterator Grenade Launcher       
define  REC6            = 18;        //REC-6 Demolisher *                 
define  REP80           = 19;        //REP-80                             
define  RESSUPLY        = 20;        //Resupply                           
define  RESPACK         = 21;        //Resupply Pack                     
define  RL112           = 22;        //RL-112 Recoilless Rifle           
define  SH20            = 23;        //SH-20 Shield Generator Pack       
define  SH32            = 24;        //SH-32 Directional Kinetic Shield *
define  TD110           = 25;        //TD-110 Bastion *                   
define  TOX13           = 26;        //TOX-13 Avenger *                   


// Defensive Stratagems
define  AAC6            = 31;        //A/AC-6 Tesla Tower                 
define  AAMG            = 32;        //A/MG-II Minigun Turret             
define  ARX             = 33;        //A/RX-34 Railcannon Turret         
define  APMINE          = 34;        //Airdropped Anti-Personnel Mines   
define  STUNMINE        = 35;        //Airdropped Stun Mines             
define  APBAR           = 36;        //Anti-Personnel Barrier *           
define  AT47            = 37;        //AT-47 Anti-Tank Emplacement *     
define  DISTRACT        = 38;        //Distractor Beacon                 
define  UAV             = 39;        //Humblebee UAV drone *             


// Offensive Stratagems
define  AIRSTRIKE       = 41;        //Airstrike                         
define  CLOSEAIR        = 42;        //Close Air Support *               
define  INCENDRIARY     = 43;        //Incendiary Bombs                   
define  BARRAGE         = 44;        //Missile Barrage *                 
define  ORBITAL         = 45;        //Orbital Laser Strike               
define  RAILCAN         = 46;        //Railcannon Strike                 
define  SHREDDER        = 47;        //Shredder Missile Strike           
define  SLEDGE          = 48;        //Sledge Precision Artillery *       
define  STATIC          = 49;        //Static Field Conductors           
define  STRAFING        = 50;        //Strafing Run                       
define  THUNDER         = 51;        //Thunderer Barrage                 
define  VINDICATOR      = 52;        //Vindicator Dive Bomb               

// Special Stratagems
define  Reinforce       = 61;        //Reinforce                     
define  NUX             = 62;        //NUX-223 Hellbomb               
define  Sniffer         = 63;        //ME-1 Sniffer Metal Detector   
define  SOS             = 64;        //Emergency Beacon

define  L               = 201;       //DPAD LEFT
define  R               = 202;       //DPAD RIGHT
define  U               = 203;       //DPAD UP
define  D               = 204;       //DPAD DOWN

define  EOC             = 254;       //END OF COMBO
define  EOD             = 255;       //END OF DATA



/*
-----------------------------------------------------------------------------
DATA SEGMENT
-----------------------------------------------------------------------------
*/


data (

// Supply Stratagems
AC22            ,D,L,U,U,R,EOC,           //AC-22 Dum-Dum *                   
AD289           ,D,U,L,L,R,D,EOC,         //AD-289 Angel *                   
AD334           ,D,U,L,U,R,D,EOC,         //AD-334 Guard Dog *               
EAT17           ,D,L,R,U,D,EOC,           //EAT-17                           
EXO44           ,D,R,U,L,D,D,EOC,         //EXO-44 Walker Exosuit             
EXO48           ,D,R,U,L,D,L,EOC,         //EXO-48 Obsidian Exosuit *         
EXO51           ,D,R,U,L,D,R,EOC,         //EXO-51 Lumberer Exosuit *         
FLAM40          ,D,L,D,R,L,EOC,           //FLAM-40 Incinerator               
LAS98           ,D,L,D,U,L,EOC,           //LAS-98 Laser Cannon               
LIFT850         ,D,U,U,D,U,EOC,           //LIFT-850 Jump Pack               
M25             ,D,L,U,L,L,EOC,           //M-25 Rumbler *                   
M5              ,D,R,D,L,L,R,EOC,         //M5 APC                           
M5HAV           ,D,R,U,L,U,D,EOC,         //M5-32 HAV                         
MC109           ,D,R,D,L,L,U,EOC,         //MC-109 Hammer Motorcycle *       
M94             ,D,L,D,U,R,EOC,           //MG-94 Machine Gun                 
MLS4X           ,D,L,U,D,R,EOC,           //MLS-4X Commando *                 
OBLITERATOR     ,D,L,U,L,D,EOC,           //Obliterator Grenade Launcher     
REC6            ,D,L,R,U,U,EOC,           //REC-6 Demolisher *               
REP80           ,D,D,L,R,D,EOC,           //REP-80                           
RESSUPLY        ,D,D,U,R,EOC,             //Resupply                         
RESPACK         ,D,U,D,D,R,EOC,           //Resupply Pack                     
RL112           ,D,L,R,R,L,EOC,           //RL-112 Recoilless Rifle           
SH20            ,D,U,L,R,L,R,EOC,         //SH-20 Shield Generator Pack       
SH32            ,D,U,L,R,L,D,EOC,         //SH-32 Directional Kinetic Shield *
TD110           ,D,R,D,L,U,R,EOC,         //TD-110 Bastion *                 
TOX13           ,D,L,D,R,R,EOC,           //TOX-13 Avenger *                 


// Defensive Stratagems
AAC6            ,L,D,D,U,R,L,EOC,         //A/AC-6 Tesla Tower                 
AAMG            ,L,D,U,R,L,EOC,           //A/MG-II Minigun Turret             
ARX             ,L,D,U,L,R,EOC,           //A/RX-34 Railcannon Turret         
APMINE          ,L,R,D,U,EOC,             //Airdropped Anti-Personnel Mines   
STUNMINE        ,L,R,U,D,EOC,             //Airdropped Stun Mines             
APBAR           ,L,R,D,D,R,EOC,           //Anti-Personnel Barrier *           
AT47            ,L,L,U,U,R,L,EOC,         //AT-47 Anti-Tank Emplacement *     
DISTRACT        ,L,D,R,EOC,               //Distractor Beacon                 
UAV             ,L,U,R,EOC,               //Humblebee UAV drone *             


// Offensive Stratagems
AIRSTRIKE       ,R,U,D,R,L,EOC,           //Airstrike                     
CLOSEAIR        ,R,R,D,L,EOC,             //Close Air Support *           
INCENDRIARY     ,R,U,L,R,EOC,             //Incendiary Bombs               
BARRAGE         ,R,D,D,D,L,D,EOC,         //Missile Barrage *             
ORBITAL         ,R,U,L,U,R,L,EOC,         //Orbital Laser Strike           
RAILCAN         ,R,D,U,D,L,EOC,           //Railcannon Strike             
SHREDDER        ,R,L,R,L,D,D,R,EOC,       //Shredder Missile Strike       
SLEDGE          ,R,U,L,U,D,R,EOC,         //Sledge Precision Artillery *   
STATIC          ,R,U,L,D,EOC,             //Static Field Conductors       
STRAFING        ,R,R,U,EOC,               //Strafing Run                   
THUNDER         ,R,D,U,U,L,D,EOC,         //Thunderer Barrage             
VINDICATOR      ,R,R,R,EOC,               //Vindicator Dive Bomb           

// Special Stratagems
Reinforce       ,U,D,R,L,U,EOC,           //Reinforce                     
NUX             ,U,L,R,D,U,D,EOC,         //NUX-223 Hellbomb               
Sniffer         ,D,D,R,U,EOC,             //ME-1 Sniffer Metal Detector   
SOS             ,U,D,R,U,EOC,             //Emergency Beacon           

EOD
);

/*
-----------------------------------------------------------------------------
VARIABLES
-----------------------------------------------------------------------------
*/

    int step, press;
    int ms = 40;
    int rt = 10;   
    int RunON = TRUE;
/*
-----------------------------------------------------------------------------
INITIALIZATION
-----------------------------------------------------------------------------
*/


/*
-----------------------------------------------------------------------------
MAIN SCRIPT
-----------------------------------------------------------------------------
*/

main {
   
// AutoRun Switch
    if(get_val(PS4_L3)&& event_release(PS4_R3))  {RunON = !RunON;}

    if(RunON==TRUE) set_led(LED_3,1); 
    if(RunON==FALSE) set_led(LED_3,0); 

// (0,0,0,0) Off / No LED light
// (0,1,0,0) Dim Red
// (0,0,1,0) Dim Lime/Green
// (0,1,1,0) Dim Yellow
           

// Auto-Run
    if((abs(get_val(PS4_LX)) > 60 || abs(get_val(PS4_LY)) > 60) && RunON) {set_val(PS4_L3,100);}

// Turbo Ressurection
    if (get_val(PS4_CROSS) && get_ptime(PS4_CROSS) >= 200 && !get_val(PS4_L1)) {combo_run(Ressurect);}
// Turbo Melee   
    if (get_val(PS4_CIRCLE) && get_ptime(PS4_CIRCLE) >= 200 && !get_val(PS4_L1)) {combo_run(Melee);}
       
// Press L1 and trigger combos from bellow (change combos by your needs)
    if (get_val(PS4_L1)) {
        if (event_press(PS4_R1)) {RunCombo(Reinforce);} //Special
        if (event_press(PS4_L3)) {RunCombo(NUX);}       //Special
        if (event_press(PS4_R2)) {RunCombo(Sniffer);}   //Special
        if (event_press(PS4_L2)) {RunCombo(SOS);}       //Special

        if (event_press(PS4_TRIANGLE))  {RunCombo(AIRSTRIKE);}
        if (event_press(PS4_SQUARE))    {RunCombo(SH20);}
        if (event_press(PS4_CIRCLE))    {RunCombo(STATIC);}       
        if (event_press(PS4_CROSS))     {RunCombo(UAV);}             
    }
// Supply Stratagems
// AC22 AD289 AD334 EAT17 EXO44 EXO48 EXO51 FLAM40 LAS98 LIFT850 M25 M5 M5HAV MC109 M94 MLS4X OBLITERATOR REC6 REP80 RESSUPLY RESPACK RL112 SH20 SH32 TOX13                 

// Defensive Stratagems
// AAC6 AAMG ARX APMINE STUNMINE APBAR AT47 DISTRACT UAV             

// Offensive Stratagems
// AIRSTRIKE CLOSEAIR INCENDRIARY BARRAGE ORBITAL RAILCAN SHREDDER SLEDGE STATIC STRAFING THUNDER VINDICATOR           

    if(step > 0) {
            ReleaseAll();
            combo_run(Step);
    }

}

/*
-----------------------------------------------------------------------------
COMBOS
-----------------------------------------------------------------------------
*/

    combo Step {
        DoPress();
        wait(ms);
        ReleaseAll();
        wait(rt);
        GetStep();
    }

    combo Ressurect {set_val(PS4_CROSS,100);wait(ms);set_val(PS4_CROSS,0);wait(rt);set_val(PS4_CROSS,0);}
    combo Melee {set_val(PS4_CIRCLE,100);wait(ms);set_val(PS4_CIRCLE,0);wait(rt);set_val(PS4_CIRCLE,0);}

/*
-----------------------------------------------------------------------------
FUNCTIONS
-----------------------------------------------------------------------------
*/

    function RunCombo(CM) {
        step = 0;
        press = 0;
        while(TRUE) {
            if(dbyte(step) == EOD) {
                step = -1; return;
            }
            else if(dbyte(step) == CM) {
                    step = step + 1;
                    GetStep();
                    return;
            }
            step = step + 1;
        }
    }


    function GetStep() {
        if(dbyte(step) == EOC) {
                step = 0;
                return;
        } 
        press = dbyte(step);
        step = step + 1;
    }

    function DoPress() {
        if(press == L) set_val(PS4_LEFT, 100);
        if(press == R) set_val(PS4_RIGHT, 100);
        if(press == U) set_val(PS4_UP, 100);
        if(press == D) set_val(PS4_DOWN, 100);
    }
   
    function ReleaseAll() {
            set_val(PS4_LEFT, 0);
            set_val(PS4_RIGHT, 0);
            set_val(PS4_UP, 0);
            set_val(PS4_DOWN, 0);
            set_val(PS4_L1, 100);
    }

PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: [Solved] Script Optimisation (Data Segment)- Helldivers

Postby J2Kbr » Wed Feb 17, 2016 11:20 am

wow!! Very nice script!! I am impressed.. Awesome work!! Thanks for posting here.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 19359
Joined: Tue Mar 18, 2014 1:39 pm

Re: [Solved] Script Optimisation (Data Segment)- Helldivers

Postby Shaag7 » Fri Feb 19, 2016 1:21 pm

I have just finished work on the script (added 4 fast switch profiles, led colors, rumbles, comments and fixed some typos).

Code: Select all
//NAME: Helldivers (Stratagem,Autorun,Ressurect,Melee)
//VER:  1.0
/* =============================================================================
* Author: Shaag7
*
* Functions: Stratagem macros(4 profiles), Autorun, TurboRessurect, TurboMelee
*
* Notes:
* You can manually change your preferred stratagems for each profile (1-4)
* You can switch between profiles using R3 + DPAD
* Each profile lights different led colors
* Special Stratagems are in common for all profiles
*
* TurboMelee & TurboRess will press Circle/Cross button fast when you hold them
*
* AutoRun can be switched On/Off by pressing L3 and R3 together
*
* Stratagem combos are taken from http:
//helldivers.gamepedia.com/Stratagem
* Script was done for PS4 and Titan1 (http://www.consoletuner.com)
*
* Changes:
* 19-Feb-2016: 1.0 - Release
* 16-Feb-2016: 0.9 - Beta Release
* =============================================================================*/

/*
-----------------------------------------------------------------------------
DEFINES
-----------------------------------------------------------------------------
*/

 
// Supply Stratagems
define  AC22            = 1;         //AC-22 Dum-Dum *                   
define  AD289           = 2;         //AD-289 Angel *                     
define  AD334           = 3;         //AD-334 Guard Dog *                 
define  EAT17           = 4;         //EAT-17                             
define  EXO44           = 5;         //EXO-44 Walker Exosuit             
define  EXO48           = 6;         //EXO-48 Obsidian Exosuit *         
define  EXO51           = 7;         //EXO-51 Lumberer Exosuit *         
define  FLAM40          = 8;         //FLAM-40 Incinerator               
define  LAS98           = 9;         //LAS-98 Laser Cannon               
define  LIFT850         = 10;        //LIFT-850 Jump Pack                 
define  M25             = 11;        //M-25 Rumbler *                     
define  M5              = 12;        //M5 APC                             
define  M5HAV           = 13;        //M5-32 HAV                         
define  MC109           = 14;        //MC-109 Hammer Motorcycle *         
define  M94             = 15;        //MG-94 Machine Gun                 
define  MLS4X           = 16;        //MLS-4X Commando *                 
define  OBLITERATOR     = 17;        //Obliterator Grenade Launcher       
define  REC6            = 18;        //REC-6 Demolisher *                 
define  REP80           = 19;        //REP-80                             
define  RESSUPLY        = 20;        //Resupply                           
define  RESPACK         = 21;        //Resupply Pack                     
define  RL112           = 22;        //RL-112 Recoilless Rifle           
define  SH20            = 23;        //SH-20 Shield Generator Pack       
define  SH32            = 24;        //SH-32 Directional Kinetic Shield *
define  TD110           = 25;        //TD-110 Bastion *                   
define  TOX13           = 26;        //TOX-13 Avenger *                   


// Defensive Stratagems
define  AAC6            = 31;        //A/AC-6 Tesla Tower                 
define  AAMG            = 32;        //A/MG-II Minigun Turret             
define  ARX             = 33;        //A/RX-34 Railcannon Turret         
define  APMINE          = 34;        //Airdropped Anti-Personnel Mines   
define  STUNMINE        = 35;        //Airdropped Stun Mines             
define  APBAR           = 36;        //Anti-Personnel Barrier *           
define  AT47            = 37;        //AT-47 Anti-Tank Emplacement *     
define  DISTRACT        = 38;        //Distractor Beacon                 
define  UAV             = 39;        //Humblebee UAV drone *             


// Offensive Stratagems
define  AIRSTRIKE       = 41;        //Airstrike                         
define  CLOSEAIR        = 42;        //Close Air Support *               
define  INCENDIARY      = 43;        //Incendiary Bombs                   
define  BARRAGE         = 44;        //Missile Barrage *                 
define  ORBITAL         = 45;        //Orbital Laser Strike               
define  RAILCAN         = 46;        //Railcannon Strike                 
define  SHREDDER        = 47;        //Shredder Missile Strike           
define  SLEDGE          = 48;        //Sledge Precision Artillery *       
define  STATIC          = 49;        //Static Field Conductors           
define  STRAFING        = 50;        //Strafing Run                       
define  THUNDER         = 51;        //Thunderer Barrage                 
define  VINDICATOR      = 52;        //Vindicator Dive Bomb               

// Special Stratagems
define  Reinforce       = 61;        //Reinforce                     
define  NUX             = 62;        //NUX-223 Hellbomb               
define  Sniffer         = 63;        //ME-1 Sniffer Metal Detector   
define  SOS             = 64;        //Emergency Beacon

define  L               = 201;       //DPAD LEFT
define  R               = 202;       //DPAD RIGHT
define  U               = 203;       //DPAD UP
define  D               = 204;       //DPAD DOWN

define  EOC             = 254;       //END OF COMBO
define  EOD             = 255;       //END OF DATA



/*
-----------------------------------------------------------------------------
DATA SEGMENT
-----------------------------------------------------------------------------
*/


data (

// Supply Stratagems
AC22            ,D,L,U,U,R,EOC,           //AC-22 Dum-Dum *                   
AD289           ,D,U,L,L,R,D,EOC,         //AD-289 Angel *                   
AD334           ,D,U,L,U,R,D,EOC,         //AD-334 Guard Dog *               
EAT17           ,D,L,R,U,D,EOC,           //EAT-17                           
EXO44           ,D,R,U,L,D,D,EOC,         //EXO-44 Walker Exosuit             
EXO48           ,D,R,U,L,D,L,EOC,         //EXO-48 Obsidian Exosuit *         
EXO51           ,D,R,U,L,D,R,EOC,         //EXO-51 Lumberer Exosuit *         
FLAM40          ,D,L,D,R,L,EOC,           //FLAM-40 Incinerator               
LAS98           ,D,L,D,U,L,EOC,           //LAS-98 Laser Cannon               
LIFT850         ,D,U,U,D,U,EOC,           //LIFT-850 Jump Pack               
M25             ,D,L,U,L,L,EOC,           //M-25 Rumbler *                   
M5              ,D,R,D,L,L,R,EOC,         //M5 APC                           
M5HAV           ,D,R,U,L,U,D,EOC,         //M5-32 HAV                         
MC109           ,D,R,D,L,L,U,EOC,         //MC-109 Hammer Motorcycle *       
M94             ,D,L,D,U,R,EOC,           //MG-94 Machine Gun                 
MLS4X           ,D,L,U,D,R,EOC,           //MLS-4X Commando *                 
OBLITERATOR     ,D,L,U,L,D,EOC,           //Obliterator Grenade Launcher     
REC6            ,D,L,R,U,U,EOC,           //REC-6 Demolisher *               
REP80           ,D,D,L,R,D,EOC,           //REP-80                           
RESSUPLY        ,D,D,U,R,EOC,             //Resupply                         
RESPACK         ,D,U,D,D,R,EOC,           //Resupply Pack                     
RL112           ,D,L,R,R,L,EOC,           //RL-112 Recoilless Rifle           
SH20            ,D,U,L,R,L,R,EOC,         //SH-20 Shield Generator Pack       
SH32            ,D,U,L,R,L,D,EOC,         //SH-32 Directional Kinetic Shield *
TD110           ,D,R,D,L,U,R,EOC,         //TD-110 Bastion *                 
TOX13           ,D,L,D,R,R,EOC,           //TOX-13 Avenger *                 


// Defensive Stratagems
AAC6            ,L,D,D,U,R,L,EOC,         //A/AC-6 Tesla Tower                 
AAMG            ,L,D,U,R,L,EOC,           //A/MG-II Minigun Turret             
ARX             ,L,D,U,L,R,EOC,           //A/RX-34 Railcannon Turret         
APMINE          ,L,R,D,U,EOC,             //Airdropped Anti-Personnel Mines   
STUNMINE        ,L,R,U,D,EOC,             //Airdropped Stun Mines             
APBAR           ,L,R,D,D,R,EOC,           //Anti-Personnel Barrier *           
AT47            ,L,L,U,U,R,L,EOC,         //AT-47 Anti-Tank Emplacement *     
DISTRACT        ,L,D,R,EOC,               //Distractor Beacon                 
UAV             ,L,U,R,EOC,               //Humblebee UAV drone *             


// Offensive Stratagems
AIRSTRIKE       ,R,U,D,R,L,EOC,           //Airstrike                     
CLOSEAIR        ,R,R,D,L,EOC,             //Close Air Support *           
INCENDIARY      ,R,U,L,R,EOC,             //Incendiary Bombs               
BARRAGE         ,R,D,D,D,L,D,EOC,         //Missile Barrage *             
ORBITAL         ,R,U,L,U,R,L,EOC,         //Orbital Laser Strike           
RAILCAN         ,R,D,U,D,L,EOC,           //Railcannon Strike             
SHREDDER        ,R,L,R,L,D,D,R,EOC,       //Shredder Missile Strike       
SLEDGE          ,R,U,L,U,D,R,EOC,         //Sledge Precision Artillery *   
STATIC          ,R,U,L,D,EOC,             //Static Field Conductors       
STRAFING        ,R,R,U,EOC,               //Strafing Run                   
THUNDER         ,R,D,U,U,L,D,EOC,         //Thunderer Barrage             
VINDICATOR      ,R,R,R,EOC,               //Vindicator Dive Bomb           

// Special Stratagems
Reinforce       ,U,D,R,L,U,EOC,           //Reinforce                     
NUX             ,U,L,R,D,U,D,EOC,         //NUX-223 Hellbomb               
Sniffer         ,D,D,R,U,EOC,             //ME-1 Sniffer Metal Detector   
SOS             ,U,D,R,U,EOC,             //Emergency Beacon           

EOD
);

/*
-----------------------------------------------------------------------------
VARIABLES
-----------------------------------------------------------------------------
*/

    int step, press;
    int ms = 40;        // Button press time
    int rt = 10;        // Rest time
    int RunON = TRUE;   // Default value for AutoRunSwitch
    int RunSens = 55;   // Sensitivity to trigger AutoRun
    int N;
    int Triangle[4];
    int Square[4];
    int Circle[4];
    int Cross[4];
    int R1;
    int L3;
    int R2;
    int L2;
/*
-----------------------------------------------------------------------------
INITIALIZATION
-----------------------------------------------------------------------------
*/


init {
N=1; // Default Stratagem Profile (1-4)

// Pressing L1 and button below will trigger special combo
R1 = Reinforce; //Special
L3 = NUX;       //Special
R2 = Sniffer;   //Special
L2 = SOS;       //Special
// Pressing L1 and button bellow will trigger combo based on current Profile [1-4] -- (change combos by your needs)
// To activate press R3 + PS4_UP ---- Blue LED
Triangle[1] = AAMG;
Square[1]   = RESSUPLY;
Circle[1]   = LIFT850;
Cross[1]    = UAV;
// To activate press R3 + PS4_LEFT ---- Red LED
Triangle[2] = RL112;
Square[2]   = RESSUPLY;
Circle[2]   = VINDICATOR;
Cross[2]    = UAV;
// To activate press R3 + PS4_RIGHT ---- Green LED
Triangle[3] = TOX13;
Square[3]   = RESSUPLY;
Circle[3]   = SH20;
Cross[3]    = UAV;
// To activate press R3 + PS4_DOWN ---- Pink LED
Triangle[4] = OBLITERATOR;
Square[4]   = RESSUPLY;
Circle[4]   = SH20;
Cross[4]    = UAV;
       
// Supply Stratagems
// AC22 AD289 AD334 EAT17 EXO44 EXO48 EXO51 FLAM40 LAS98 LIFT850 M25 M5 M5HAV MC109 M94 MLS4X OBLITERATOR REC6 REP80 RESSUPLY RESPACK RL112 SH20 SH32 TOX13                 
// Defensive Stratagems
// AAC6 AAMG ARX APMINE STUNMINE APBAR AT47 DISTRACT UAV             
// Offensive Stratagems
// AIRSTRIKE CLOSEAIR INCENDIARY BARRAGE ORBITAL RAILCAN SHREDDER SLEDGE STATIC STRAFING THUNDER VINDICATOR           

}

/*
-----------------------------------------------------------------------------
MAIN SCRIPT
-----------------------------------------------------------------------------
*/

main {
   
// AutoRun Switch - any change will rumble strongly
    if(get_val(PS4_L3)&& event_release(PS4_R3))  {RunON = !RunON; combo_run(ARumble)}

// Changing current Stratagem profile will rumble twice
if (get_val(PS4_R3) && (!get_val(PS4_L1) || !get_val(PS4_L3))) {
    if (event_press(PS4_UP))    {N=1;combo_run(BRumble);}
    if (event_press(PS4_LEFT))  {N=2;combo_run(BRumble);}
    if (event_press(PS4_RIGHT)) {N=3;combo_run(BRumble);}
    if (event_press(PS4_DOWN))  {N=4;combo_run(BRumble);}
}           
// LED colors based on current profile
if (N==1) {colorled(1,0,0,0);} //Blue LED
if (N==2) {colorled(0,1,0,0);} //Red LED
if (N==3) {colorled(0,0,1,0);} //Green LED
if (N==4) {colorled(0,0,0,1);} //Pink LED


// Auto-Run
    if((abs(get_val(PS4_LX)) > RunSens || abs(get_val(PS4_LY)) > RunSens) && RunON) {set_val(PS4_L3,100);}
// Turbo Ressurection
    if (get_val(PS4_CROSS) && get_ptime(PS4_CROSS) >= 200 && !get_val(PS4_L1)) {combo_run(Ressurect);}
// Turbo Melee   
    if (get_val(PS4_CIRCLE) && get_ptime(PS4_CIRCLE) >= 200 && !get_val(PS4_L1)) {combo_run(Melee);}
       
// Press L1 and trigger combos
    if (get_val(PS4_L1)) {
        if (event_press(PS4_R1)) {RunCombo(R1);} //Special
        if (event_press(PS4_L3)) {RunCombo(L3);} //Special
        if (event_press(PS4_R2)) {RunCombo(R2);} //Special
        if (event_press(PS4_L2)) {RunCombo(L2);} //Special

        if (event_press(PS4_TRIANGLE))  {RunCombo(Triangle[N]);}
        if (event_press(PS4_SQUARE))    {RunCombo(Square[N]);}
        if (event_press(PS4_CIRCLE))    {RunCombo(Circle[N]);}       
        if (event_press(PS4_CROSS))     {RunCombo(Cross[N]);}             
    }
 /*     
 
// This will stop Stratagem combo from execution if you release L1

    if(event_release(PS4_L1)) {
                step = 0;
                combo_stop(Step);
    }       
*/
    if(step > 0) {
            ReleaseAll();
            combo_run(Step);
    }

}

/*
-----------------------------------------------------------------------------
COMBOS
-----------------------------------------------------------------------------
*/

    combo Step {
        DoPress();
        wait(ms);
        ReleaseAll();
        wait(rt);
        GetStep();
    }

    combo Ressurect {set_val(PS4_CROSS,100);wait(ms);set_val(PS4_CROSS,0);wait(rt);set_val(PS4_CROSS,0);}
    combo Melee {set_val(PS4_CIRCLE,100);wait(ms);set_val(PS4_CIRCLE,0);wait(rt);set_val(PS4_CIRCLE,0);}
 
 combo BRumble{set_rumble(RUMBLE_B, 100);wait(200);set_rumble(RUMBLE_B, 0);wait(100);set_rumble(RUMBLE_B, 100);wait(200);set_rumble(RUMBLE_B, 0);}
 combo ARumble{set_rumble(RUMBLE_A, 100);wait(400);set_rumble(RUMBLE_A, 0);}
 
/*
-----------------------------------------------------------------------------
FUNCTIONS
-----------------------------------------------------------------------------
*/

    function RunCombo(CM) {
        step = 0;
        press = 0;
        while(TRUE) {
            if(dbyte(step) == EOD) {
                step = -1; return;
            }
            else if(dbyte(step) == CM) {
                    step = step + 1;
                    GetStep();
                    return;
            }
            step = step + 1;
        }
    }


    function GetStep() {
        if(dbyte(step) == EOC) {
                step = 0;
                return;
        } 
        press = dbyte(step);
        step = step + 1;
    }

    function DoPress() {
        if(press == L) set_val(PS4_LEFT, 100);
        if(press == R) set_val(PS4_RIGHT, 100);
        if(press == U) set_val(PS4_UP, 100);
        if(press == D) set_val(PS4_DOWN, 100);
    }
   
    function ReleaseAll() {
            set_val(PS4_LEFT, 0);
            set_val(PS4_RIGHT, 0);
            set_val(PS4_UP, 0);
            set_val(PS4_DOWN, 0);
            set_val(PS4_L1, 100);
    }

    function colorled(a,b,c,d) {
            set_led(LED_1,a);
            set_led(LED_2,b);
            set_led(LED_3,c);
            set_led(LED_4,d);
    }
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: [Solved] Script Optimisation (Data Segment)- Helldivers

Postby Shaag7 » Fri Feb 19, 2016 4:17 pm

J2Kbr wrote:wow!! Very nice script!! I am impressed.. Awesome work!! Thanks for posting here.


Hi J2,
may I ask you for help?

I have found bug within the script but I can't find cause of it.
Value for R1 (=Reinforce;) is not captured properly and it is sending combo for UAV instead of Reinforce.
When I move R1=Reinforce (and all other Specials) under Cross[4]=UAV; it is working correctly, but Cross[4] is not processing UAV anymore.
When R1=Reinforce (and all other Specials) is under Cross[3] and all profile[4] is commented, Cross[4] is still being processed (as Reinforce), but no ither buttons like Triangle[4] are.
When I move whole init{} to the main{} it is just same.

I really can't find cause of this issue. Can you help me with this?

Thx
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: [Help Request] - Helldivers

Postby J2Kbr » Mon Feb 22, 2016 12:18 pm

ok, i took a quick look and haven't spotted anything obviously that could be causing the bug. I will need follow the script logic to find a way to fix. As your script is quite complex, please allow me some time before go into that. Right now I have some urgent stuff to finish. Thanks for your understanding ...
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 19359
Joined: Tue Mar 18, 2014 1:39 pm

Re: [Help Request] - Helldivers

Postby Shaag7 » Mon Feb 22, 2016 2:46 pm

J2Kbr wrote:ok, i took a quick look and haven't spotted anything obviously that could be causing the bug. I will need follow the script logic to find a way to fix. As your script is quite complex, please allow me some time before go into that. Right now I have some urgent stuff to finish. Thanks for your understanding ...


Yeah no problem mate ;-). I'll update the script with no-array workaround.

I was going through it few time and based on behaviour it looks that somehow variables R1 and Cross(4) are overwriting each other based on position in the code and sometimes even presence of second variable.
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Next

Return to GPC1 Script Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests