Big Destiny 2 Script, please help finish

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

Big Destiny 2 Script, please help finish

Postby Longfellow78 » Tue Oct 22, 2019 6:58 pm

Hi,

I have made a quite large script for Destiny 2 (in Titan One script mainly) for a hunter build which is working pretty well for my needs but is not quite perfect.

I wrote all of this myself through trial and error, except the parts pertaining to the anti-recoil and rapid-fire (with the associated led colours and rumbles) and some of the ADS sens script, which I copied from an old Titan One script I found.

Hence it is a bit of a mongrel due to my noobish skills, but seems to work perfectly for what I need.

What would be great if someone could please look it over and point out any errors, and offer advice on the anti recoil and Rapid fire elements which don't fully work, namely:

- When the LED script is activated, the xbox guide button flashes, which is really annoying, disabling them stops this. I don't know if this is because it is in Titan One language and not Titan two. I would like this to work.

- The rumbles are weird, I don't understand how these work tbh, and there is a different rumble for activating RF and AR, and these are inconsistent. I would like this to just be small rumble for off, and big rumble for on for both. No idea how to do this.

I would really love to be able to switch anti recoil and rapid fire on independently for primary and secondary weapons. I know the logic to this (weapon switch changes the mode to on or off depending on the previous on or off toggles, with a reset if it gets out of order - I don't know how to do this, or if it is worth it, only that it is complex). Any advice?

Finally, I would like to make a new toggle (e.g. with LT and Right on dpad) to toggle a quick shot followed up by melee attack, but I'm not sure how to set this up.

Any advice would be wonderful, thanks.

FYI the script includes the following functions, and is posted below, cheers:

Quick crouch/slide when not ads by tapping right trigger and walking forward.
Swapped jump and sprint buttons for better jump control.
Remapped xbox elite paddles for crouch and weapon swap.
Super activation on double tap left trigger (for mobieus quiver multishot).
Hair triggers.
Wombo combo on right stick hold (fast smoke and grenade throw).
Lower ADS sensitivity when ADS or hipfire
Instant dodge on single b button press
Switchable recoil (adjustable with save) and rapidfire with lights and rumble.
Code: Select all
#include <titanone.gph>
 
//-------------------------------------------------------------------------------------------
//  ANTIRECOIL and RAPIDFIRE  ( with ON/OFF ) +   Auto crouch/shot ; Jump & Run swap on Jumper ; Hair triggers ; Wombo Combo ;  ADS sensitivity; LT rapid Super
//-------------------------------------------------------------------------------------------
 
//------------------------------------------------------------------------------------------
 
//  LED indications:                                 
 
//  Green:  rapidfire ON  - antirecoil ON           
//  Red: antirecoil ON  - rapidfire OFF           
//  SkyBlue:  rapidfire ON  - antirecoil OFF           
//  White: rapidfire OFF  - antirecoil OFF;         
 
//-------------------------------------------------------------------------------------------
 
//           INSTRUCTIONS:   
// Use Jumper button settings!
 
// RAPIDFIRE (OFF by default)
// Hold XB1_LT and Press XB1_UP to Enable or Disable Rapidfire (with rumble notify)                 
 
// ANTIRECOIL (OFF by default)                 
// Hold XB1_LT and Press XB1_DOWN to Enable or Disable Antirecoil (with rumble notify)               
// Hold XB1_LT, XB1_X and tap XB1_DOWN to increase Antirecoil (+1 each tap)       
// Hold XB1_LT, XB1_X and tap XB1_UP to decrease Antirecoil (-1 each tap)       
// Hold XB1_LT, XB1_X and tap XB1_RIGHT to compensate to the right (+1 each tap)
// Hold XB1_LT, XB1_X and tap XB1_LEFT to compensate to the left (+1 each tap)     
 
// SAVE new values: Hold LT and press START
 
//Remap LS and RB for better jump control.
remap XB1_LS -> XB360_LB;
remap XB1_LB -> XB360_LS;
 
// ADS or HIPFIRE SENS
 
define SENS = 85;
define RIGHT_STICK_X = XB1_RX;
define RIGHT_STICK_Y = XB1_RY;
define FIRE_BTN  = XB1_RT;                                                                           
define ADS_BTN   = XB1_LT;                                                                           
define RF_switch  = XB1_UP;   //                           
define AR_switch  = XB1_DOWN;   //                                             
//-------------------------------------------------------------------------------------------
define save       =  2;   // XB1_MENU - PS4_OPTIONS                                         
//-------------------------------------------------------------------------------------------
define AR_Release = 19;      // change this value to set when antirecoil stops working on Y AXIS (min: antirecoil value + 10) 15 to 25 is ideal.
//------------------------------------------------------------------------------------------- 
define UP         = 13;                                                           
define DOWN       = 14;                                                           
define LEFT       = 15;                                                           
define RIGHT      = 16;                                                         
//-------------------------------------------------------------------------------------------
define Blue       =  1;                                                                       
define Red        =  2;                                                                       
define Green      =  3;                                                                       
define Pink       =  4;                                                                       
define SkyBlue    =  5;                                                                       
define Yellow     =  6;                                                                       
define White      =  7;                                                                       
//-------------------------------------------------------------------------------------------
data(1,                                                                                   
  2,0,0,0, //1. Blue                                                                     
  0,2,0,0, //2. Red                                                                     
  0,0,2,0, //3. Lime/Green                                                               
  0,0,0,2, //4. Fuchsia/Pink                                                             
  2,0,2,0, //5. SkyBlue                                                                 
  0,2,2,0, //6. Yellow                                                                 
  2,2,2,2  //7. White                                                                   
);                                                                                     
//-------------------------------------------------------------------------------------------
 
//VARIABLES - int                                                                       
 
int recoil_onoff  = FALSE; // if TRUE Antirecoil is ON by default - if FALSE, OFF by default
int rapid_onoff   = FALSE; // if TRUE Rapidfire is ON by default - if FALSE, OFF by default
int RATE_OF_FIRE  = 10;   // Range: 1 to 25 RPS (Round/s)                               
int ANTI_RECOIL   = 35;   // increase to increase initial antirecoil value - this is a good optimum most most weapons. SMGs and TLW need more.                                                 
int ANTI_RECOIL_H =  0;                                                                 
int anti_recoil;                                                                         
int anti_recoil_H;                                                                       
int Col_ind;                                                                             
int hold_time;                                                                         
int rest_time;                                                                         
int rumble_tipe;                                                                         
 
 
//MAIN BLOCK ROUTINES
//-------------------------------------------------------------------------------------------
 
//Crouch Shot. Tap RT when moving forward and not ADS (i.e. running) to crouch/slide.
main {
    if((get_val(XB1_LY)) < -95) {
        if((event_press(XB1_RT)) && !(get_val(XB1_LT))) {
            combo_run(Tap_1);
        }
    }
 
 
//Dodge press b gives double tap b to crouch
 
if(get_val(XB1_B)) {
        combo_run(Tap_100);
        combo_run(Tap_101);
    }
// Paddles setup for xbox elite
if((get_val(XB1_P1)) > 01) { 
        set_val(XB360_B, 100);
    }
 
if((get_val(XB1_P3)) > 01) { 
        set_val(XB360_Y, 100);
    }
 
// Rapid LT press for mobieus quiver multishot
    if((event_release(XB1_LT)) && (get_ptime(XB1_LT)) <= 200) {
        combo_run(Tap_902);
           }
 
//|-------------------------------|
// Thu Mar 07 2019 19:50:36
// Hair Triggers
//|-------------------------------|
 
 
    if((get_val(XB1_LT)) > 01) { 
        set_val(XB360_LT, 100);
    }
 
 
    if((get_val(XB1_RT)) > 01) {
        set_val(XB360_RT, 100);
    }
 
 
//|-------------------------------|
// Wombo Combo grenade and smoke instant for Hunter - hold right stick
//|-------------------------------|
 
 
    if(is_active(XB1_RS) && time_active (XB1_RS) >200) {
        combo_run(Tap_998);
        combo_run(Tap_999);
           }
 
 
// Lower sensitivity when the ADS/Fire Button is held down   
    if((get_val(ADS_BTN)) || (get_val(FIRE_BTN)))   
    {       
        sensitivity(RIGHT_STICK_X, NOT_USE, SENS);       
        sensitivity(RIGHT_STICK_Y, NOT_USE, SENS);   
    }
 
 
 
//Anti recoil and Rapid fire switches
 
 
    if(get_val(XB1_LT) && event_press(AR_switch))  {
        recoil_onoff=!recoil_onoff;                 
        set_rumble_tipe(recoil_onoff);               
    }                                               
 
    if(get_val(XB1_LT) && event_press(RF_switch))  {
        combo_run (vibrate);                         
        rapid_onoff=!rapid_onoff;                   
    }                                               
         //currently bugged - lights work but makes xbox guide button flash when on                                           
    // if(rapid_onoff   &&  recoil_onoff) colourled(1);
    //if(rapid_onoff   && !recoil_onoff) colourled(2);
    //if(recoil_onoff  && !rapid_onoff ) colourled(3); 
    //if(!recoil_onoff && !rapid_onoff ) colourled(5); 
 
 
    if(rapid_onoff) {                                   
        if(get_val(FIRE_BTN)) {                                   
                combo_run (RAPID_FIRE);                       
        }                                               
    }                                                     
        hold_time = 500 / RATE_OF_FIRE;                 
        rest_time = hold_time - 20;                       
        if(rest_time < 0) rest_time = 0;                 
 
    if(get_val(ADS_BTN) && event_press(save)){                   
        combo_run(vibrate);                                     
        set_pvar(SPVAR_1, RATE_OF_FIRE);                         
        set_pvar(SPVAR_2, ANTI_RECOIL);                         
        set_pvar(SPVAR_3, ANTI_RECOIL_H);                       
        set_val(save, 0);                                       
    }                                                           
    if(get_val(XB1_X)){                                             
        if(event_press(XB1_DOWN)){                                   
            ANTI_RECOIL = ANTI_RECOIL+ 1;                       
        }                                                       
        if(event_press(XB1_UP)) {                                   
            ANTI_RECOIL = ANTI_RECOIL- 1;                         
        }                                                         
        set_val(XB1_DOWN,0); set_val(XB1_UP,0);                         
 
        if(event_press(XB1_RIGHT)){                                   
            ANTI_RECOIL_H = ANTI_RECOIL_H+ 1;                   
        }                                                       
        if(event_press(XB1_LEFT)) {                               
            ANTI_RECOIL_H = ANTI_RECOIL_H- 1;                   
        }                                                       
        set_val(XB1_RIGHT,0); set_val(XB1_LEFT,0);                     
 
    }                                                             
    if(get_val(FIRE_BTN )) {   
        combo_run(AntiRecoil);                                     
    }                                                               
 
    if( abs(get_val(XB1_RY)) > AR_Release) {
        combo_stop (AntiRecoil);                                       
    }                                                                   
 
 
}                                                                       
//-------------------------------------------------------------------------------------------
//COMBO BLOCKS                                                                                           
 
// crouch slide
combo Tap_1 {
    set_val(XB360_B, 0);
    wait(01);
    set_val(XB360_B, 100);
    wait(50);
    set_val(XB360_B, 100);
}
 
 
//super combo for
combo Tap_902 {
    set_val(XB360_A, 0);
    wait(10);
    set_val(XB360_A, 100);
    wait(20);
    set_val(XB360_A, 100);
}
 
combo vibrate {                                     
    set_rumble(rumble_tipe, 100);                   
    wait(300);                                       
    reset_rumble();                                 
}                                                   
// hunter dodge combo 1
combo Tap_100 {
    set_val(XB360_B, 0);
    wait(10);
    set_val(XB360_B, 100);
    wait(50);
    set_val(XB360_B, 100);
}
// hunter dodge combo 2
combo Tap_101 {
    set_val(XB360_B, 0);
    wait(10);
    set_val(XB360_B, 100);
    wait(50);
    set_val(XB360_B, 100);
}
 
 
combo RAPID_FIRE {                                   
    set_val(FIRE_BTN, 100);                         
    wait(hold_time);                                 
    set_val(FIRE_BTN, 0);                           
    wait(rest_time);                                 
    set_val(FIRE_BTN, 0);                           
}                                                   
// wombo combo 1
 
combo Tap_998 {
    set_val(XB360_RS, 0);
    wait(10);
    set_val(XB360_RS, 100);
    wait(10);
    set_val(XB360_RS, 100);
 
}
// wombo combo 2
combo Tap_999 {
    set_val(XB360_RB, 0);
    wait(50);
    set_val(XB360_RB, 100);
    wait(100);
    set_val(XB360_RB, 100);
 
}
 
combo AntiRecoil {                                   
    if(recoil_onoff) {                               
        anti_recoil = get_val(10) + ANTI_RECOIL;       
        if(anti_recoil > 100) anti_recoil = 100;       
        set_val(10, anti_recoil);                       
        anti_recoil_H = get_val(9) + ANTI_RECOIL_H;     
        if(anti_recoil_H > 100) anti_recoil_H = 100;   
        set_val(9, anti_recoil_H);                     
    }                                               
}                                                   
 
//--------------------------------------------------------------
function set_rumble_tipe ( val) {                   
    if( val) rumble_tipe = RUMBLE_A ;               
    else   rumble_tipe = RUMBLE_B ;                 
    combo_run(vibrate);                             
} 
 
function colourled(Colour) {                         
    Col_ind=(Colour*4)- 3;                           
    set_led(LED_1,dbyte(Col_ind  ));                 
    set_led(LED_2,dbyte(Col_ind+ 1));               
    set_led(LED_3,dbyte(Col_ind+ 2));               
    set_led(LED_4,dbyte(Col_ind+ 3));               
}// End
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm

Re: Big Destiny 2 Script, please help finish

Postby Scachi » Tue Oct 22, 2019 7:06 pm

For the rumble try if this fixes it:
Code: Select all
 
combo vibrate {
set_rumble(rumble_tipe, 100);
wait(0); // <--- new ! this will run the set_rumble command only once
wait(300);
reset_rumble();
}
 

Or use the native T2 rumble code I posted in your other thread.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Big Destiny 2 Script, please help finish

Postby Buffy » Tue Oct 22, 2019 10:29 pm

Just a heads up, remaps won't work properly when coming from the T1 to T2. Remaps on the T1 are calculated post execution, whereas T2 remaps are calculated pre execution.

Also there is a bug with set_led I've found and reported, but it has not been fixed yet. I have a workaround though, if you go into the titanone.h file and go to set_led, and change all the 0.0 values to 0.001, the XB1 led will no longer flash.
ConsoleTuner Support Team || Discord || Custom Scripts
User avatar
Buffy
Lieutenant
Lieutenant
 
Posts: 422
Joined: Wed Jul 20, 2016 5:23 am

Re: Big Destiny 2 Script, please help finish

Postby Longfellow78 » Wed Oct 23, 2019 9:48 am

Hi.

Thanks that's awesome, I will try fixing the flashing tnt as was driving me mad.

I understand what you're saying about the remaps, but it seems to work fine... when using those remapped buttons on other combos, I had to use the remapped button code rather than the original to make it work. Is this what you mean?

Thanks a lot.
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm

Re: Big Destiny 2 Script, please help finish

Postby Longfellow78 » Wed Oct 23, 2019 9:50 am

Scachi wrote:For the rumble try if this fixes it:
Code: Select all
 
combo vibrate {
set_rumble(rumble_tipe, 100);
wait(0); // <--- new ! this will run the set_rumble command only once
wait(300);
reset_rumble();
}
 

Or use the native T2 rumble code I posted in your other thread.


Thanks a lot I will try that out.
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm

Re: Big Destiny 2 Script, please help finish

Postby Longfellow78 » Wed Oct 23, 2019 9:46 pm

Buffy wrote:Just a heads up, remaps won't work properly when coming from the T1 to T2. Remaps on the T1 are calculated post execution, whereas T2 remaps are calculated pre execution.

Also there is a bug with set_led I've found and reported, but it has not been fixed yet. I have a workaround though, if you go into the titanone.h file and go to set_led, and change all the 0.0 values to 0.001, the XB1 led will no longer flash.


Hi,

I tried this but it didn't seem to work. Do you mean it should look like this:

led_set(LED_1, 0.001, 0);
led_set(LED_2, 0.001, 0);
led_set(LED_3, 0.001, 0);
led_set(LED_4, 0.001, 0);

Thanks.
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm

Re: Big Destiny 2 Script, please help finish

Postby Longfellow78 » Thu Oct 24, 2019 9:53 am

Longfellow78 wrote:
Scachi wrote:For the rumble try if this fixes it:
Code: Select all
 
combo vibrate {
set_rumble(rumble_tipe, 100);
wait(0); // <--- new ! this will run the set_rumble command only once
wait(300);
reset_rumble();
}
 

Or use the native T2 rumble code I posted in your other thread.


Thanks a lot I will try that out.


Thanks for this tip, it seemed to work. My script is nearing completion, as I've added a shotgun melee toggle now as well.

The only thing left is to fix the flashing xbox controller led, and to have independent recoil and rapid fire weapons for slot 1 and slot 2! :D
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm

Re: Big Destiny 2 Script, please help finish

Postby Scachi » Thu Oct 24, 2019 10:43 am

I guess you want to use different recoil values per weapon slot too.
In this case you should try to get rid of your T1 code first and convert it manually to plain gpc2 code.
set_pvar and T1 pmem stuff isn't supporting enough space to save & load all requires values from permanent storage.
You have to use plain gpc2 code functions "pmem_load() , pmem_read() , pmem_write() and pmem_save()" instead.

When you have converted your current code to plain gpc2 code you can work on extend its functionality..

All the following information may not be complete, it is not ready for copy & paste. You need to do the changes yourself and make sure that you don't miss changing a value to use the array instead or you will be wondering why the script isn't working consistently.

Doing weapon slot specific toggles requires you to track the current weapon slot in use.
For being able to toggle it per weapon slots you need as many flags as weapon slots and stuff you will toggle. (I use array for this kind of stuff.)
Then use your toggle combination to only toggle it for the current weapon slot you are using.

Tracking weapon slots is usually done by tracking the actions on the weapon change button (number of presses and/or time of how long the button is pressed). It is game specific.

relevant parts from my script "Destiny 2 - Scachi" script version 1, 29, modified to match your script:
WeaponActive has the index of the currently used weapon slot
Code: Select all
uint8 WeaponActive     = 0;      // 0 = Primary, 1 = Secondary, 2 = Power 

The weapon change tracking code is a mess in my script and can be found around line 491 .. 505
You have to look up its used variables and combos.

The anti recoil and rapid fire values per weapon slots as an array:
Code: Select all
 
int recoil_onoff[] = {0,0,0};
int rapid_onoff[] = {0,0,0};
int  ANTI_RECOIL[] = {35,35,0}; // vertical
int  ANTI_RECOIL_H[] = {0,0,0}; // horizontal
int RATE_OF_FIRE[] = {10,10,10};
 

You have to change every line containing "recoil_onoff","rapid_onoff","RATE_OF_FIRE","ANTI_RECOIL","ANTI_RECOIL_H" and whatever got changed to an array to support weapon slot specific values/toggles to use the arrays instead.

Example to toggle the flags of the active weapon slot only.
Code: Select all
 
if(get_val(XB1_LT) && event_press(AR_switch))  {
        recoil_onoff[WeaponActive]=!recoil_onoff[WeaponActive];
        set_rumble_tipe(recoil_onoff[WeaponActive]);
    }
 
if(get_val(XB1_LT) && event_press(RF_switch))  {
        combo_run (vibrate);                         
        rapid_onoff[WeaponActive]=!rapid_onoff[WeaponActive];
    }   
 


For active usage:
Code: Select all
if(rapid_onoff[WeaponActive]) {                                    
        if(get_val(FIRE_BTN)) {                                   
                combo_run (RAPID_FIRE);                       
        }                                               
    }   


To edit in-game anti recoil value of your current weapon slot:
Code: Select all
if(get_val(XB1_X)){                                              
        if(event_press(XB1_DOWN)){                                   
            ANTI_RECOIL[WeaponActive] = ANTI_RECOIL[WeaponActive]+ 1;                       
        }                                                       
        if(event_press(XB1_UP)) {                                   
            ANTI_RECOIL[WeaponActive] = ANTI_RECOIL[WeaponActive]- 1;                         
        }                                                         
        set_val(XB1_DOWN,0); set_val(XB1_UP,0);                         
 
        if(event_press(XB1_RIGHT)){                                   
            ANTI_RECOIL_H[WeaponActive] = ANTI_RECOIL_H[WeaponActive]+ 1;                   
        }                                                       
        if(event_press(XB1_LEFT)) {                               
            ANTI_RECOIL_H[WeaponActive] = ANTI_RECOIL_H[WeaponActive]- 1;                   
        }                                                       
        set_val(XB1_RIGHT,0); set_val(XB1_LEFT,0);                     
 
    }       
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Big Destiny 2 Script, please help finish

Postby Longfellow78 » Thu Oct 24, 2019 11:33 am

Hi,

Thanks a lot for taking the time/effort to post a reply. I think I understand your points. I definately want to learn how to do this and try not rely on others to do my dirty work. I will have a play around, it's all practice isn't it!

Thanks again.
User avatar
Longfellow78
Master Sergeant
Master Sergeant
 
Posts: 41
Joined: Fri Mar 15, 2019 2:24 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Baidu [Spider] and 94 guests