Convert Titan1 scripts to Titan2 the easy way

GPC script programming for Titan Two device. Code examples, how to, questions, requests.

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

Re: Convert Titan1 scripts to Titan2 the easy way

Postby J2Kbr » Tue Jan 08, 2019 6:27 am

Converted using the back compatibility header file:
Code: Select all
#include <titanone.gph>
 
//------------------------------------------------|
// \ \ \ \ \    ___   _ __\ \ ,_\    __   __  _   |
//  \ \ \ \ \  / __`\/\`'__\ \ \/  /'__`\/\ \/'\  |
//   \ \ \_/ \/\ \L\ \ \ \/ \ \ \_/\  __/\/>  </  |
//    \ `\___/\ \____/\ \_\  \ \__\ \____\/\_/\_\ |
//     `\/__/  \/___/  \/_/   \/__/\/____/\//\/_/ |
//------------------------------------------------|                                             
 
//DEFINITIONS
define ANTI_RECOIL = 20;       // change this value to compensate vertical recoil (0 - 100)
define ANTI_RECOIL_LEFT = 0// change this value to compensate to the left (0 - 100)
define ANTI_RECOIL_RIGHT = 0; // change this value to compensate to the right (0 - 100)
 
//INITIALIZATION
int Dead_Zone_Up         = -10 ;
int Dead_Zone_Down       =  10 ;
int Dead_Zone_Left       = -10  ;
int Dead_Zone_Right      =  10 ;
int Recoil_Down          =  28;     
int Recoil_Up            = -28;         
int Recoil_Delay          =  17;     
int Recoil_Release;       
int Vertical;               
int value                 =  33;
int value2                 = -33;
int delay                 =  11;                   
int crouch_shot_onoff      =  FALSE;
int rf                          =  FALSE;
int rf2                     =  FALSE;
int rf3                     =     FALSE;
int Aim_BTN;
int Shoot_BTN;
int RX;
int RY;
int Crouch_BTN;
int LeanLeft;
int LeanRight;
int Switch;
int LX;
int LY;
int Left;
int Up;
init { //-BUTTON LAYOUT-\\ 
if(get_console() == PIO_PS4){ Aim_BTN = PS4_L2; Shoot_BTN = PS4_R2; RX = PS4_RX; RY = PS4_RY; Crouch_BTN = PS4_CIRCLE; LeanLeft = PS4_L3; LeanRight = PS4_R3; Switch = PS4_TRIANGLE; LX = PS4_LX; LY = PS4_LY; Left = PS4_LEFT; Up = PS4_UP;
   }else{
   Aim_BTN = XB1_LT; Shoot_BTN = XB1_RT; RX = XB1_RX; RY = XB1_RY; Crouch_BTN = XB1_B; LeanLeft = XB1_LS; LeanRight = XB1_RS; Switch = XB1_Y; LX = XB1_LX; LY = XB1_LY; Left = XB1_LEFT; Up = XB1_UP;
}   
   Recoil_Release = Recoil_Down + 1;   // Anti-Recoil Release Value (For Positive Number)   // Anti-Recoil
}   
 
//MAIN SCRIPT
main {
 
//AimAssist
    if(get_val(Shoot_BTN) && get_val(Aim_BTN)) {
    combo_run(RT_C);
    }
 
    if(get_val(RX) < value2 || get_val(RX) > value || get_val(RY) < value2 || get_val(RY) > value
    || get_val(RX) < value2 || get_val(RX) > value || get_val(RY) < value2 || get_val(RY) > value) {
    combo_stop(RT_C);
    }
 
//FastLean       
    if (get_val(Aim_BTN) && event_press(LeanLeft)) combo_run(LeanLeft_Combo);
    if(combo_running(LeanLeft)) {set_val(LeanLeft, 0);}
 
 
    if (get_val(Aim_BTN) && event_press(LeanRight)) combo_run(LeanRight_Combo);
    if(combo_running(LeanRight)) set_val(LeanRight, 0);
 
 
//RapidFire
    if(event_press(Left)) {   // Rapid Fire Secondary
          rf  = FALSE;
          rf2 = TRUE;
          rf3 = FALSE;
}
     if(event_press(Up)) {   // Rapid Fire Both
          rf = TRUE;
          rf2 = FALSE;
}
 
    if (rf) {
        if (get_val(Shoot_BTN))
            combo_run(rapidfire);
}
    if (rf2) {
        if (event_press(Switch))
        rf3 = !rf3;
}   
    if (rf3) {
        if (get_val(Shoot_BTN))
            combo_run(rapidfire);
}
 
 
//CrouchShot
     if (get_val(Aim_BTN) && event_press(Left)) {
        crouch_shot_onoff = !crouch_shot_onoff;
         }
 
     if (crouch_shot_onoff) {
        if (get_val(Shoot_BTN))
            combo_run(Crouch_Shot);
        } 
//AntiRecoil
    if (get_val(Shoot_BTN))
        combo_run(Anti_Recoil1)
        combo_run(Dead_Zone);
    }
 
 
//COMBOS
 
 
combo Crouch_Shot { //CrouchShot
    set_val(Crouch_BTN, 100);
    wait(80);
    wait(60);
}
 
combo LeanRight_Combo {//FastLeanRight
    set_val(LeanLeft, 100);
    wait(40);
    set_val(LeanRight, 100);
    set_val(LeanLeft, 100);
    wait(90);
    set_val(LeanRight, 100);
    set_val(LeanLeft, 0);
    wait(10);
    set_val(LeanRight, 0);
}
 
combo LeanLeft_Combo {//FastLeanLeft
    set_val(LeanRight, 100);
    wait(40);
    set_val(LeanLeft, 100);
    set_val(LeanRight, 100);
    wait(90);
    set_val(LeanLeft, 100);
    set_val(LeanRight, 0);
    wait(10);
    set_val(LeanLeft, 0);
}
 
combo rapidfire {   // Rapid Fire
     set_val(Shoot_BTN,100);
    wait(17);
     set_val(Shoot_BTN,0);
     wait(17);
}
 
combo RT_C {
       set_val(RY, -32);             
       wait(delay);
       set_val(RX, 32);
       set_val(RY, 22);
       wait(delay) ;
       set_val(RY, 22);
       wait(delay)  ;               
       set_val(RX, -32);
       set_val(RY, 22);
       wait(delay);
}
 
combo Dead_Zone {   // Anti-Recoil
 set_val(RX,Dead_Zone_Vertical(RX,Dead_Zone_Right,Dead_Zone_Left));
 set_val(RY,Dead_Zone_Vertical(RY,Dead_Zone_Down,Dead_Zone_Up));
 set_val(LX,Dead_Zone_Vertical(LX,Dead_Zone_Right,Dead_Zone_Left));
 set_val(LY,Dead_Zone_Vertical(LY,Dead_Zone_Down,Dead_Zone_Up));
 }
 
 
combo Anti_Recoil1 { //Don't touch this combo pls
     set_val(RY,Anti_Recoil_Vertical(RY,Recoil_Down));   // Down
     wait(Recoil_Delay);
     set_val(RY,Anti_Recoil_Vertical(RY,Recoil_Up));   // Up
     wait(Recoil_Delay);
}
 
function Anti_Recoil_Vertical(f_axis,f_val) {   // Return Anti-Recoil Value Or Controller Value If Above Release   // Anti-Recoil
    Vertical = get_val(f_axis);
    if(abs(Vertical) < Recoil_Release)
     return f_val + Vertical;
     return Vertical; }
 
function Dead_Zone_Vertical(f_axis,f_pv,f_nv) {   // Return zero if between postive & negative limits   // Anti-Recoil
 if(get_val(f_axis) < f_pv && get_val(f_axis) > f_nv) 
  return 0;
  return get_val(f_axis); }
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 17946
Joined: Tue Mar 18, 2014 1:39 pm

Re: Convert Titan1 scripts to Titan2 the easy way

Postby kick238 » Tue Jan 08, 2019 11:36 pm

J2Kbr wrote:Converted using the back compatibility header file:
Code: Select all
#include <titanone.gph>
 
//------------------------------------------------|
// \ \ \ \ \    ___   _ __\ \ ,_\    __   __  _   |
//  \ \ \ \ \  / __`\/\`'__\ \ \/  /'__`\/\ \/'\  |
//   \ \ \_/ \/\ \L\ \ \ \/ \ \ \_/\  __/\/>  </  |
//    \ `\___/\ \____/\ \_\  \ \__\ \____\/\_/\_\ |
//     `\/__/  \/___/  \/_/   \/__/\/____/\//\/_/ |
//------------------------------------------------|                                             
 
//DEFINITIONS
define ANTI_RECOIL = 20;       // change this value to compensate vertical recoil (0 - 100)
define ANTI_RECOIL_LEFT = 0// change this value to compensate to the left (0 - 100)
define ANTI_RECOIL_RIGHT = 0; // change this value to compensate to the right (0 - 100)
 
//INITIALIZATION
int Dead_Zone_Up         = -10 ;
int Dead_Zone_Down       =  10 ;
int Dead_Zone_Left       = -10  ;
int Dead_Zone_Right      =  10 ;
int Recoil_Down          =  28;     
int Recoil_Up            = -28;         
int Recoil_Delay          =  17;     
int Recoil_Release;       
int Vertical;               
int value                 =  33;
int value2                 = -33;
int delay                 =  11;                   
int crouch_shot_onoff      =  FALSE;
int rf                          =  FALSE;
int rf2                     =  FALSE;
int rf3                     =     FALSE;
int Aim_BTN;
int Shoot_BTN;
int RX;
int RY;
int Crouch_BTN;
int LeanLeft;
int LeanRight;
int Switch;
int LX;
int LY;
int Left;
int Up;
init { //-BUTTON LAYOUT-\\ 
if(get_console() == PIO_PS4){ Aim_BTN = PS4_L2; Shoot_BTN = PS4_R2; RX = PS4_RX; RY = PS4_RY; Crouch_BTN = PS4_CIRCLE; LeanLeft = PS4_L3; LeanRight = PS4_R3; Switch = PS4_TRIANGLE; LX = PS4_LX; LY = PS4_LY; Left = PS4_LEFT; Up = PS4_UP;
   }else{
   Aim_BTN = XB1_LT; Shoot_BTN = XB1_RT; RX = XB1_RX; RY = XB1_RY; Crouch_BTN = XB1_B; LeanLeft = XB1_LS; LeanRight = XB1_RS; Switch = XB1_Y; LX = XB1_LX; LY = XB1_LY; Left = XB1_LEFT; Up = XB1_UP;
}   
   Recoil_Release = Recoil_Down + 1;   // Anti-Recoil Release Value (For Positive Number)   // Anti-Recoil
}   
 
//MAIN SCRIPT
main {
 
//AimAssist
    if(get_val(Shoot_BTN) && get_val(Aim_BTN)) {
    combo_run(RT_C);
    }
 
    if(get_val(RX) < value2 || get_val(RX) > value || get_val(RY) < value2 || get_val(RY) > value
    || get_val(RX) < value2 || get_val(RX) > value || get_val(RY) < value2 || get_val(RY) > value) {
    combo_stop(RT_C);
    }
 
//FastLean       
    if (get_val(Aim_BTN) && event_press(LeanLeft)) combo_run(LeanLeft_Combo);
    if(combo_running(LeanLeft)) {set_val(LeanLeft, 0);}
 
 
    if (get_val(Aim_BTN) && event_press(LeanRight)) combo_run(LeanRight_Combo);
    if(combo_running(LeanRight)) set_val(LeanRight, 0);
 
 
//RapidFire
    if(event_press(Left)) {   // Rapid Fire Secondary
          rf  = FALSE;
          rf2 = TRUE;
          rf3 = FALSE;
}
     if(event_press(Up)) {   // Rapid Fire Both
          rf = TRUE;
          rf2 = FALSE;
}
 
    if (rf) {
        if (get_val(Shoot_BTN))
            combo_run(rapidfire);
}
    if (rf2) {
        if (event_press(Switch))
        rf3 = !rf3;
}   
    if (rf3) {
        if (get_val(Shoot_BTN))
            combo_run(rapidfire);
}
 
 
//CrouchShot
     if (get_val(Aim_BTN) && event_press(Left)) {
        crouch_shot_onoff = !crouch_shot_onoff;
         }
 
     if (crouch_shot_onoff) {
        if (get_val(Shoot_BTN))
            combo_run(Crouch_Shot);
        } 
//AntiRecoil
    if (get_val(Shoot_BTN))
        combo_run(Anti_Recoil1)
        combo_run(Dead_Zone);
    }
 
 
//COMBOS
 
 
combo Crouch_Shot { //CrouchShot
    set_val(Crouch_BTN, 100);
    wait(80);
    wait(60);
}
 
combo LeanRight_Combo {//FastLeanRight
    set_val(LeanLeft, 100);
    wait(40);
    set_val(LeanRight, 100);
    set_val(LeanLeft, 100);
    wait(90);
    set_val(LeanRight, 100);
    set_val(LeanLeft, 0);
    wait(10);
    set_val(LeanRight, 0);
}
 
combo LeanLeft_Combo {//FastLeanLeft
    set_val(LeanRight, 100);
    wait(40);
    set_val(LeanLeft, 100);
    set_val(LeanRight, 100);
    wait(90);
    set_val(LeanLeft, 100);
    set_val(LeanRight, 0);
    wait(10);
    set_val(LeanLeft, 0);
}
 
combo rapidfire {   // Rapid Fire
     set_val(Shoot_BTN,100);
    wait(17);
     set_val(Shoot_BTN,0);
     wait(17);
}
 
combo RT_C {
       set_val(RY, -32);             
       wait(delay);
       set_val(RX, 32);
       set_val(RY, 22);
       wait(delay) ;
       set_val(RY, 22);
       wait(delay)  ;               
       set_val(RX, -32);
       set_val(RY, 22);
       wait(delay);
}
 
combo Dead_Zone {   // Anti-Recoil
 set_val(RX,Dead_Zone_Vertical(RX,Dead_Zone_Right,Dead_Zone_Left));
 set_val(RY,Dead_Zone_Vertical(RY,Dead_Zone_Down,Dead_Zone_Up));
 set_val(LX,Dead_Zone_Vertical(LX,Dead_Zone_Right,Dead_Zone_Left));
 set_val(LY,Dead_Zone_Vertical(LY,Dead_Zone_Down,Dead_Zone_Up));
 }
 
 
combo Anti_Recoil1 { //Don't touch this combo pls
     set_val(RY,Anti_Recoil_Vertical(RY,Recoil_Down));   // Down
     wait(Recoil_Delay);
     set_val(RY,Anti_Recoil_Vertical(RY,Recoil_Up));   // Up
     wait(Recoil_Delay);
}
 
function Anti_Recoil_Vertical(f_axis,f_val) {   // Return Anti-Recoil Value Or Controller Value If Above Release   // Anti-Recoil
    Vertical = get_val(f_axis);
    if(abs(Vertical) < Recoil_Release)
     return f_val + Vertical;
     return Vertical; }
 
function Dead_Zone_Vertical(f_axis,f_pv,f_nv) {   // Return zero if between postive & negative limits   // Anti-Recoil
 if(get_val(f_axis) < f_pv && get_val(f_axis) > f_nv) 
  return 0;
  return get_val(f_axis); }
 

Thanks for the reply. When ever I tried to convert this I kept getting errors. I added the titanone.gph thing and all the other headers that you posted in the replies that was said to be needed for cm conversions (this is a cm script) I did the find all combo and changed it to combo c but to no avail. Is there anything special that you did to covert this or did you just add the titanone.gph header?
User avatar
kick238
Staff Sergeant
Staff Sergeant
 
Posts: 10
Joined: Tue Aug 21, 2018 3:57 pm

Re: Convert Titan1 scripts to Titan2 the easy way

Postby Scachi » Wed Jan 09, 2019 9:17 am

kick238 wrote:
J2Kbr wrote:Converted using the back compatibility header file...cut...

Thanks for the reply. When ever I tried to convert this I kept getting errors. I added the titanone.gph thing and all the other headers that you posted in the replies that was said to be needed for cm conversions (this is a cm script) I did the find all combo and changed it to combo c but to no avail. Is there anything special that you did to covert this or did you just add the titanone.gph header?

I don't know what "all the other headers" are you are referring to, you only need the back compatibility header for your script.

Post containing the unmodified script -> viewtopic.php?f=26&t=7591&start=20#p77745
Steps:
  1. add the back compatibility header to the top of your script
    Code: Select all
    #include <titanone.gph>
  2. hit compile, result:
    Code: Select all
    GPC error: e.gpc(124): Invalid symbol redefinition 'LeanRight'
    GPC error: e.gpc(136): Invalid symbol redefinition 'LeanLeft'
    GPC: GPC Compile ABORTED with 0 warning(s) and 2 error(s).
  3. double click on the first "redefinition" error , it will jump to the line, change
    Code: Select all
    combo LeanRight {//FastLeanRight
    to
    Code: Select all
    combo cLeanRight {//FastLeanRight

    and hit compile again, result:
    Code: Select all
    GPC error: e.gpc(136): Invalid symbol redefinition 'LeanLeft'
    GPC: GPC Compile ABORTED with 0 warning(s) and 1 error(s).
  4. double click on the first line.... change
    Code: Select all
    combo LeanLeft {//FastLeanLeft
    to
    Code: Select all
    combo cLeanLeft {//FastLeanLeft
    and hit compile again: result
    Code: Select all
    GPC error: e.gpc(17): syntax error, unexpected INT16, expecting C or T 'int'.
    GPC: GPC Compile ABORTED with 0 warning(s) and 1 error(s).
  5. double click on the first error line again...add the missing ; to the end of the previous line or to the start of the current line, hit compile again,...repeat this process until you are getting this type of error message:
    Code: Select all
    GPC error: e.gpc(66): Identifier is not a combo 'LeanLeft'.
    GPC error: e.gpc(70): Identifier is not a combo 'LeanRight'.
    GPC error: e.gpc(92): syntax error, unexpected B_E, expecting C '}'.
    GPC: GPC Compile ABORTED with 0 warning(s) and 3 error(s).
  6. We have renamed two combos to fix the redefinition error, so we have to tell the script the correct combo name now.
    Double click on the first error message again.
    Starting from this line search for all lines with ctrl+f containing "combo_.*LeanLeft" (without the quotes).
    and change each LeanLeft in a combo_whatever(LeanLeft) command to combo_whatever(cLeanLeft)
    Press F3 to jump to the next line containing the search phrase...
    Required change for your script:
    Code: Select all
    //FastLean        
        if (get_val(Aim_BTN) && event_press(LeanLeft)) combo_run(LeanLeft);
        if(combo_running(LeanLeft)) {set_val(LeanLeft, 0);}
     
    to
    Code: Select all
    if (get_val(Aim_BTN) && event_press(LeanLeft)) combo_run(cLeanLeft);
        if(combo_running(cLeanLeft)) {set_val(LeanLeft, 0);}
  7. hit compile again, result:
    Code: Select all
    GPC error: e.gpc(70): Identifier is not a combo 'LeanRight'.
    GPC error: e.gpc(92): syntax error, unexpected B_E, expecting C '}'.
    GPC: GPC Compile ABORTED with 0 warning(s) and 2 error(s).
  8. Repeat the double click on error msg .. combo renaming, this time for cLeanReight: "combo_.*LeanRight"...
    Required change for your script:
    Code: Select all
    if (get_val(Aim_BTN) && event_press(LeanRight)) combo_run(LeanRight);
        if(combo_running(LeanRight)) set_val(LeanRight, 0);
    to
    Code: Select all
    if (get_val(Aim_BTN) && event_press(LeanRight)) combo_run(cLeanRight);
        if(combo_running(cLeanRight)) set_val(LeanRight, 0);
  9. hit compile again, result:
    Code: Select all
    GPC error: e.gpc(92): syntax error, unexpected B_E, expecting C '}'.
    GPC: GPC Compile ABORTED with 0 warning(s) and 1 error(s).
    Add the missing ; again and hit compile until you have no more errors.
  10. done
To fix the redefinition errors there are other approaches available posted by Sillyasskid -> viewtopic.php?f=26&t=7591&start=10#p71881
But I prefer doing it manually.
Last edited by Scachi on Mon Mar 04, 2019 1:41 pm, edited 2 times in total.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Convert Titan1 scripts to Titan2 the easy way

Postby J2Kbr » Wed Jan 09, 2019 9:37 am

Scachi, thank you for making this comprehensive script conversion tutorial. Truly appreciated. :)
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 17946
Joined: Tue Mar 18, 2014 1:39 pm

Re: Convert Titan1 scripts to Titan2 the easy way

Postby AhmedEgg » Tue Apr 16, 2019 5:58 pm

*bookmarks by adding a useless comment*
User avatar
AhmedEgg
Sergeant Major
Sergeant Major
 
Posts: 95
Joined: Thu Jun 30, 2016 4:13 pm

Re: Convert Titan1 scripts to Titan2 the easy way

Postby megid0105 » Fri Jul 05, 2019 9:08 am

indeed it work with putting
Code: Select all
#include <titanone.gph>
at header.
But the script no longer supports T2 codes where unfortunately that the script i'm using is a T2 based script and turns out some of my T2 code comes with GPC errorwhile compile (i've try not to add any T1 code, just adding the
Code: Select all
#include <titanone.gph>
header, GPC error against my worked T2 script comes out as well). So i actually can't add any T1 code into my script. Is that mean "convert" is either full T1 or full T2 script supported only?
User avatar
megid0105
Private First Class
Private First Class
 
Posts: 2
Joined: Mon Jun 24, 2019 4:10 pm

Re: Convert Titan1 scripts to Titan2 the easy way

Postby Scachi » Fri Jul 05, 2019 9:47 am

Don't mix T1 and T2 code..the chances are good that it will mess up your script.
The include of titanone.gph does add some button translation to functions and this will brake the T2 code.

You should translate the T1 part of your script to plain T2 gpc code or stick to using T1 code only.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Convert Titan1 scripts to Titan2 the easy way

Postby infintejock21 » Tue Aug 06, 2019 12:05 am

Can someone help me fix for Titan2. Getting GPC error: Invalid symbol redefinition 'rumble' and Invalid parameter ')'

Code: Select all
// GPC Online Library
// _battlefield_v_antirecoil_-_auto_heal_-_easy_sprint.gpc
#include <titanone.gph>
//--------------------------------------------------------------
// ANTIRECOIL - AUTO HEAL - EASY SPRINT- BATTLEFIELD V
//--------------------------------------------------------------
//--Controls
    define VIEW  =  1;
    define MENU  =  2;
    define RB    =  3;
    define RT    =  4;
    define RS    =  5;
    define LB    =  6;
    define LT    =  7;
    define LS    =  8;
    define RX    =  9;
    define RY    = 10;
    define LX    = 11;
    define LY    = 12;
    define UP    = 13;
    define DOWN  = 14;
    define LEFT  = 15;
    define RIGHT = 16;
    define Y     = 17;
    define B     = 18;
    define A     = 19;
    define X     = 20;
 
    // -- LEDs
    define GREEN    = 0;
    define BLUE     = 1;
    define PINK     = 2;
    define RED      = 3;
    define SKYBLUE  = 4;
    define YELLOW   = 5;
    define WHITE    = 6;
 
    //--DATA
    data(0,0,3,0,3,0,0,0,0,0,0,3,
    0,3,0,0,3,0,3,0,0,3,3,0,3,3,3,3);
 
 
//DECLARARATIONS - define
//--------------------------------------------------------------
define RECOIL_UP = 13;     // Press: LT + UP   for increase
define RECOIL_DOWN = 14;   // Press: LT + DOWN for decrease
define RECOIL_LEFT  = 15// Press: LT+LEFT  compensate to the left
define RECOIL_RIGHT = 16// Press: LT+RIGHT compensate to the right
define ONLY_WITH_SCOPE=TRUE; //Use Anti-recoil only when scoping
define SPRINT_BTN = 8;// default button is LS/L3 index 8
//--------------------------------------------------------------
//VARIABLES - int
//--------------------------------------------------------------
int ANTI_RECOIL=0;
int ANTI_RECOIL_LEFT = 0;
int ANTI_RECOIL_RIGHT = 0;
int fire_button;
int scope_button;
int anti_recoil;
int anti_recoil_left;
int anti_recoil_right;
int onoff,i;
int rumble,toggled;
//INITIALIZATION - init
//--------------------------------------------------------------
init {
     if(get_console() == PIO_PS3) {
     fire_button = 3;
     scope_button = 6;}
     else { // Natural Trigger & Bumper
     fire_button = 4;
     scope_button = 7;}
}
//MAIN BLOCK RUTINES
//--------------------------------------------------------------
main {  // Start of MAIN BLOCK
     //increase Antirecoil
     if(get_val(7) && event_press(RECOIL_UP)) {
     ANTI_RECOIL = ANTI_RECOIL + 1;}
     if(get_val(7) && event_press(RECOIL_UP))set_val(RECOIL_UP,0);
     // decrease Antirecoil
     if(get_val(7) && event_press(RECOIL_DOWN)) {
     ANTI_RECOIL = ANTI_RECOIL - 1;}
     if(get_val(7) && event_press(RECOIL_DOWN))set_val(RECOIL_DOWN,0);
     // compensate to the left
     if(get_val(7) && event_press(RECOIL_LEFT)) {
     ANTI_RECOIL_LEFT = ANTI_RECOIL_LEFT + 1;}
     if(get_val(7) && event_press(RECOIL_LEFT))set_val(RECOIL_LEFT,0);
     // compensate to the right
     if(get_val(7) && event_press(RECOIL_RIGHT)) {
     ANTI_RECOIL_RIGHT = ANTI_RECOIL_RIGHT + 1;}
     if(get_val(7) && event_press(RECOIL_RIGHT))set_val(RECOIL_RIGHT,0);
     // ONLY WITH SCOPE ANTIRECOIL
     if(!ONLY_WITH_SCOPE || get_val(scope_button)) {combo_run(AntiRecoil);}
     {
 
     // Move Left Stick at 80% or more will start sprint
          if(get_val(12)<-80 || get_val(12)>80 ^^ get_val(11)<-80 || get_val(11)>80 )combo_run(EASY_SPRINT);
      }
     //--RB is held 1 second
    if(get_val(RB) && get_ptime(RB) >= 1000 && !toggled) {
        //--keep from looping if rb is held more than 1 sec
        toggled = TRUE;
        //--toggle
        onoff = !onoff;
        //--rumble
        rumble(onoff);
        //--led colors
        if(onoff)
            //--pink on
            leds(PINK);
        else
            //--blue off
            leds(BLUE);
    }
    //--reset
    if(event_release(RB))
        toggled = FALSE;
 
    //--combo activators in here
    if(onoff) {
        combo_run(AUTO_HEAL);
        //--toggle off if aim or fire
        if(get_val(LT) || get_val(RT)) {
        combo_suspend(AUTO_HEAL);
        }
    }
    //--if rumble has a value run combo
    if(rumble)
        combo_run(RUMBLE);
 
}// End of MAIN BLOCK
//COMBO BLOCKS
//--------------------------------------------------------------
//Antirecoil This combo must be the last one
combo AntiRecoil {//begin
    if(get_val(fire_button)) {
    anti_recoil = get_val(10) + ANTI_RECOIL;
    if(anti_recoil > 100) anti_recoil = 100;
    set_val(10, anti_recoil);
    anti_recoil_left = get_val(9) -ANTI_RECOIL_LEFT;
    if(anti_recoil_left > 100) anti_recoil_left = 100;
    set_val(9, anti_recoil_left);
    anti_recoil_right = get_val(9) +ANTI_RECOIL_RIGHT;
    if(anti_recoil_right > 100) anti_recoil_right = 100;
    set_val(9, anti_recoil_right);}   
}
combo EASY_SPRINT {
 set_val(SPRINT_BTN,100);
 wait(100);
 
}
    combo AUTO_HEAL {
    set_val(LEFT, 100);
    wait(200);
    set_val (UP, 100);
    wait(200);
}
combo RUMBLE{
    set_rumble(RUMBLE_A,100);
    wait(250);
    reset_rumble();
    wait(150);
    rumble--;
}
function leds(f_color){
    for(i = 0;i <= 3;i++) {
        set_led(i, dbyte((f_color * 4) + i));
    }
}
//--1 for ON, 2 for OFF
function rumble(f_bln){
    rumble = f_bln;
    if(!rumble)
        rumble = 2;
}
 
User avatar
infintejock21
Corporal
Corporal
 
Posts: 4
Joined: Tue Aug 06, 2019 12:00 am

Re: Convert Titan1 scripts to Titan2 the easy way

Postby Mad » Tue Aug 06, 2019 1:15 am

Code: Select all
#pragma METAINFO("c1.gpc", 1, 0, "Buffy's GPC Converter v0.25r3")
#include <titanone.gph>
 
 
// GPC Online Library
// _battlefield_v_antirecoil_-_auto_heal_-_easy_sprint.gpc
//--------------------------------------------------------------
// ANTIRECOIL - AUTO HEAL - EASY SPRINT- BATTLEFIELD V
//--------------------------------------------------------------
//--Controls
// -- LEDs
//--DATA
//DECLARARATIONS - define
//--------------------------------------------------------------
// Press: LT + UP   for increase
// Press: LT + DOWN for decrease
// Press: LT+LEFT  compensate to the left
// Press: LT+RIGHT compensate to the right
//Use Anti-recoil only when scoping
// default button is LS/L3 index 8
//--------------------------------------------------------------
//VARIABLES - int
//--------------------------------------------------------------
//INITIALIZATION - init
//--------------------------------------------------------------
// Natural Trigger & Bumper
//MAIN BLOCK RUTINES
//--------------------------------------------------------------
// Start of MAIN BLOCK
//increase Antirecoil
// decrease Antirecoil
// compensate to the left
// compensate to the right
// ONLY WITH SCOPE ANTIRECOIL
// Move Left Stick at 80% or more will start sprint
//--RB is held 1 second
//--keep from looping if rb is held more than 1 sec
//--toggle
//--rumble
//--led colors
//--pink on
//--blue off
//--reset
//--combo activators in here
//--toggle off if aim or fire
//--if rumble has a value run combo
// End of MAIN BLOCK
//COMBO BLOCKS
//--------------------------------------------------------------
//Antirecoil This combo must be the last one
//begin
//--1 for ON, 2 for OFF
 
define VIEW = 1;
define MENU = 2;
define RB = 3;
define RT = 4;
define RS = 5;
define LB = 6;
define LT = 7;
define LS = 8;
define RX = 9;
define RY = 10;
define LX = 11;
define LY = 12;
define UP = 13;
define DOWN = 14;
define LEFT = 15;
define RIGHT = 16;
define Y = 17;
define B = 18;
define A = 19;
define X = 20;
define GREEN = 0;
define BLUE = 1;
define PINK = 2;
define RED = 3;
define SKYBLUE = 4;
define YELLOW = 5;
define WHITE = 6;
define RECOIL_UP = 13;
define RECOIL_DOWN = 14;
define RECOIL_LEFT = 15;
define RECOIL_RIGHT = 16;
define ONLY_WITH_SCOPE = TRUE;
define SPRINT_BTN = 8;
 
data(0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 3,
0, 3, 0, 0, 3, 0, 3, 0, 0, 3, 3, 0, 3, 3, 3, 3);
 
int ANTI_RECOIL = 0;
int ANTI_RECOIL_LEFT = 0;
int ANTI_RECOIL_RIGHT = 0;
int fire_button;
int scope_button;
int anti_recoil;
int anti_recoil_left;
int anti_recoil_right;
int onoff, i;
int rumble, toggled;
 
init {
    if (get_console() == PIO_PS3) {
        fire_button = 3;
        scope_button = 6;
    }
    else {
        fire_button = 4;
        scope_button = 7;
    }
}
 
 
main {
    if (get_val(7) && event_press(RECOIL_UP)) {
        ANTI_RECOIL = ANTI_RECOIL + 1;
    }
    if (get_val(7) && event_press(RECOIL_UP)) set_val(RECOIL_UP, 0);
    if (get_val(7) && event_press(RECOIL_DOWN)) {
        ANTI_RECOIL = ANTI_RECOIL - 1;
    }
    if (get_val(7) && event_press(RECOIL_DOWN)) set_val(RECOIL_DOWN, 0);
    if (get_val(7) && event_press(RECOIL_LEFT)) {
        ANTI_RECOIL_LEFT = ANTI_RECOIL_LEFT + 1;
    }
    if (get_val(7) && event_press(RECOIL_LEFT)) set_val(RECOIL_LEFT, 0);
    if (get_val(7) && event_press(RECOIL_RIGHT)) {
        ANTI_RECOIL_RIGHT = ANTI_RECOIL_RIGHT + 1;
    }
    if (get_val(7) && event_press(RECOIL_RIGHT)) set_val(RECOIL_RIGHT, 0);
    if (!ONLY_WITH_SCOPE || get_val(scope_button)) {
        combo_run(c_AntiRecoil);
    }
    if (get_val(12) <- 80 || get_val(12) > 80 ^^ get_val(11) <- 80 || get_val(11) > 80) combo_run(c_EASY_SPRINT);
    if (get_val(RB) && get_ptime(RB) >= 1000 && !toggled) {
        toggled = TRUE;
        onoff =! onoff;
        f_rumble(onoff);
        if (onoff) f_leds(PINK);
        else  f_leds(BLUE);
    }
    if (event_release(RB)) toggled = FALSE;
    if (onoff) {
        combo_run(c_AUTO_HEAL);
        if (get_val(LT) || get_val(RT)) {
            combo_stop(c_AUTO_HEAL);
        }
    }
    if (rumble) combo_run(c_RUMBLE);
}
 
 
combo c_AntiRecoil {
    if (get_val(fire_button)) {
        anti_recoil = get_val(10) + ANTI_RECOIL;
        if (anti_recoil > 100) anti_recoil = 100;
        set_val(10, anti_recoil);
        anti_recoil_left = get_val(9) - ANTI_RECOIL_LEFT;
        if (anti_recoil_left > 100) anti_recoil_left = 100;
        set_val(9, anti_recoil_left);
        anti_recoil_right = get_val(9) + ANTI_RECOIL_RIGHT;
        if (anti_recoil_right > 100) anti_recoil_right = 100;
        set_val(9, anti_recoil_right);
    }
}
 
combo c_EASY_SPRINT {
    set_val(SPRINT_BTN, 100);
    wait(100);
}
 
combo c_AUTO_HEAL {
    set_val(LEFT, 100);
    wait(200);
    set_val(UP, 100);
    wait(200);
}
 
combo c_RUMBLE {
    set_rumble(RUMBLE_A, 100);
    wait(250);
    reset_rumble();
    wait(150);
    rumble -- ;
}
 
 
function f_leds(f_color) {
    for (i == 0; i <= 3; i ++ ) {
        set_led(i, dbyte((f_color * 4) + i));
    }
}
 
function f_rumble(f_bln) {
    rumble = f_bln;
    if (!rumble) rumble = 2;
}
 
ConsoleTuner Support Team || Discord
Mad
Captain
Captain
 
Posts: 690
Joined: Wed May 22, 2019 5:39 am

Previous

Return to GPC Script Programming (Titan Two)

Who is online

Users browsing this forum: JamesCaywood, MSN [Bot] and 85 guests