The Division2.gpc

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

The Division2.gpc

Postby Lucifer242 » Mon Aug 12, 2019 1:10 am

I cant seem to wrap my head around why this isnt working i am new to this so if you would please fix it but if possible can i get a short explanation as to why it doesnt work ive tried reading the tutorials but i have trouble learning things that way
Code: Select all
// GPC Online Library
// the_divison_2_.gpc
 
 
// /$$$$$$$  /$$            /$$                                      /$$$$$$
// | $$__  $$|__/           |__/                                     /$$__  $$
// | $$  \ $$ /$$ /$$    /$$ /$$  /$$$$$$$  /$$$$$$  /$$$$$$$       |__/  \ $$
// | $$  | $$| $$|  $$  /$$/| $$ /$$_____/ /$$__  $$| $$__  $$        /$$$$$$/
// | $$  | $$| $$ \  $$/$$/ | $$|  $$$$$$ | $$  \ $$| $$  \ $$       /$$____/
// | $$  | $$| $$  \  $$$/  | $$ \____  $$| $$  | $$| $$  | $$      | $$     
// | $$$$$$$/| $$   \  $/   | $$ /$$$$$$$/|  $$$$$$/| $$  | $$      | $$$$$$$$
// |_______/ |__/    \_/    |__/|_______/  \______/ |__/  |__/      |________/
 
//Divison 2 v1
 
//Script has:
// steady aim
// rapidfire
// no recoil
// aim assist
// more to be added so let me know
    define HOME  =  0;
    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;
//------------------------------------------------------------------------------------------
// Special thanks to lex,batts,Excalibur,crescens,the community
// concocted by Xbl Jedi
//-------------------------------------------------------------------------------------------
//  LED indications:                                 
//  Green:  rapidfire ON  - antirecoil ON           
//  Pink: antirecoil ON  - rapidfire OFF           
//  Yellow:  rapidfire ON  - antirecoil OFF           
//  Red: rapidfire OFF  - antirecoil OFF;         
 
//-------------------------------------------------------------------------------------------
//           INSTRUCTIONS:                       
// RAPIDFIRE (ON by default - Start value: 14 - Pink led = ON; Red led = OFF)
// Hold LT/L2 and Press X/SQUARE to Enable or Disable Rapidfire
// Hold LT/L2 And Press D-PAD DOWN to switch between Low and High Anti-Recoil
// Rumbles 1 = Low (Green) 2 = High (Pink)                                 
// For steady aim you must be standing still meaning not moving.       
// When aiming aim assist wil be active.
 
define AR_Release = 70;      // change this value to set when antirecoil stops working (min: antirecoil value + 10)
define Scope_only = TRUE; // if TRUE Antirecoil IS ON only when scoping - if FALSE, is always ON
int recoil_onoff  = TRUE; // if TRUE Antirecoil is ON by default - if FALSE, OFF by default
int rapid_onoff   = TRUE; // if TRUE Rapidfire is ON by default - if FALSE, OFF by default 
int RATE_OF_FIRE  = 14;   // Range: 1 to 25 RPS (Round/s)                                                                                                       
int Col_ind;                                                                             
int hold_time;                                                                         
int rest_time;                                                                         
int v,i,ar_y;
int ar_idx;
int rumble = -1;
int rumble_t;
int aa_p  = 24;
int aa_n = -24;
int aa_delay  = 20;
define time = 2000;
define FIRE_BTN   = 4;
define ADS_BTN    = 7;
define R_X        = 9;
define R_Y        = 10;
define D_UP       = 13;
define Blue       =  1;                                                                       
define Red        =  2;                                                                       
define Green      =  3;                                                                       
define Pink       =  4;                                                                       
define SkyBlue    =  5;                                                                       
define Yellow     =  6;                                                                       
define White      =  7;
 
data(0,0,3,0,0,0,0,3);
 
//Anti Recoil Values
const byte AR_T[][] =
{{10,50,140},
 {10,90,150}};
const byte AR_V[][] =
{{15,10},
{17,15}};
 
init{
led_color(ar_idx);
}
 
main {
//Aim Assist
if(get_val(7)  && !get_val(4)) combo_run(AA_XY);
else combo_stop(AA_XY);
//Rapidfire
if(get_val(7) && event_press(20))  {
combo_run (vibrate);                         
rapid_onoff=!rapid_onoff;                   
}                                               
if(rapid_onoff   &&  recoil_onoff) colourled(Green);
if(rapid_onoff   && !recoil_onoff) colourled(Pink);
if(recoil_onoff  && !rapid_onoff ) colourled(Yellow)
if(!recoil_onoff && !rapid_onoff ) colourled(Red)
if(rapid_onoff) {                                   
if(get_val(4)) {                                   
combo_run (RAPID_FIRE);                       
}                                               
hold_time = 500 / RATE_OF_FIRE;                 
rest_time = hold_time - 20;                       
if(rest_time < 0) rest_time = 0;                 
}   
//Toggle ANTI-RECOIL
if(get_val(7) && event_press(14)) {
        ar_idx = !ar_idx;
        rumble = ar_idx;
        led_color(ar_idx);
}
if(get_val(7) && get_val(4)) {
//Anti-Recoil Values
        if(get_ptime(FIRE_BTN) >= AR_T[ar_idx][0])   
            ar_y =  AR_V[ar_idx][0];
        if(get_ptime(FIRE_BTN) >= AR_T[ar_idx][1] * 10)
            ar_y = AR_V[ar_idx][1];
        if(get_ptime(FIRE_BTN) >= AR_T[ar_idx][2] * 10)
            ar_y = AR_V[ar_idx][2];
//CHECK RX
        if(abs(get_val(9)) < ar_y + 5)
//Set Anti-Recoil Values
        set_val(R_Y,xy_val(R_Y,ar_y));
}
//RUMBLE 2 = On, 1 = Off
    if(rumble >= 0) {
        if(!rumble_t)
            set_rumble(RUMBLE_A,100);
        rumble_t += get_rtime();
        if(rumble_t ==  250) 
            reset_rumble();
        if(rumble_t == 400) {
            rumble--;
            rumble_t = 0;   
         }
     }
}//End Of Main
combo AA_XY {
    set_val(10,xy_val(10,aa_p));
    wait(aa_delay)
    set_val(9,xy_val(9,aa_p));
    wait(aa_delay)
    set_val(10,xy_val(10,aa_n));
    wait(aa_delay)
    set_val(9,xy_val(9,aa_n));
    wait(aa_delay)
}
combo vibrate {                                     
    set_rumble(1, 100);                   
    wait(300);                                       
    reset_rumble();                                 
}                                                   
combo RAPID_FIRE {                                   
    set_val(4, 100);                         
    wait(hold_time);                                 
    set_val(4, 0);                           
    wait(rest_time);                                 
    set_val(4, 0);                           
}                                                   
function xy_val(f_axis,f_val) {
    v = get_val(f_axis);
    if(abs(v) < 10)
        v = 0;
    if(abs(v) < f_val + 5)
        return v + f_val;
    return v;
}     
function led_color(color) {
   for(i = 0; i <= 3; i++) {
     set_led(i,dbyte((color * 4) + i));
     }
  }
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));               
}
 
User avatar
Lucifer242
Private First Class
Private First Class
 
Posts: 2
Joined: Mon May 13, 2019 11:15 pm

Re: The Division2.gpc

Postby Buffy » Tue Aug 13, 2019 2:14 am

Code: Select all
 
 
// GPC Online Library
// the_divison_2_.gpc
// /$$$$$$$  /$$            /$$                                      /$$$$$$
// | $$__  $$|__/           |__/                                     /$$__  $$
// | $$  \ $$ /$$ /$$    /$$ /$$  /$$$$$$$  /$$$$$$  /$$$$$$$       |__/  \ $$
// | $$  | $$| $$|  $$  /$$/| $$ /$$_____/ /$$__  $$| $$__  $$        /$$$$$$/
// | $$  | $$| $$ \  $$/$$/ | $$|  $$$$$$ | $$  \ $$| $$  \ $$       /$$____/
// | $$  | $$| $$  \  $$$/  | $$ \____  $$| $$  | $$| $$  | $$      | $$     
// | $$$$$$$/| $$   \  $/   | $$ /$$$$$$$/|  $$$$$$/| $$  | $$      | $$$$$$$$
// |_______/ |__/    \_/    |__/|_______/  \______/ |__/  |__/      |________/
//Divison 2 v1
//Script has:
// steady aim
// rapidfire
// no recoil
// aim assist
// more to be added so let me know
//------------------------------------------------------------------------------------------
// Special thanks to lex,batts,Excalibur,crescens,the community
// concocted by Xbl Jedi
//-------------------------------------------------------------------------------------------
//  LED indications:                                 
//  Green:  rapidfire ON  - antirecoil ON           
//  Pink: antirecoil ON  - rapidfire OFF           
//  Yellow:  rapidfire ON  - antirecoil OFF           
//  Red: rapidfire OFF  - antirecoil OFF;         
//-------------------------------------------------------------------------------------------
//           INSTRUCTIONS:                       
// RAPIDFIRE (ON by default - Start value: 14 - Pink led = ON; Red led = OFF)
// Hold LT/L2 and Press X/SQUARE to Enable or Disable Rapidfire
// Hold LT/L2 And Press D-PAD DOWN to switch between Low and High Anti-Recoil
// Rumbles 1 = Low (Green) 2 = High (Pink)                                 
// For steady aim you must be standing still meaning not moving.       
// When aiming aim assist wil be active.
// change this value to set when antirecoil stops working (min: antirecoil value + 10)
// if TRUE Antirecoil IS ON only when scoping - if FALSE, is always ON
// if TRUE Antirecoil is ON by default - if FALSE, OFF by default
// if TRUE Rapidfire is ON by default - if FALSE, OFF by default 
// Range: 1 to 25 RPS (Round/s)                                                                                                       
//Anti Recoil Values
//Aim Assist
//Rapidfire
//Toggle ANTI-RECOIL
//Anti-Recoil Values
//CHECK RX
//Set Anti-Recoil Values
//RUMBLE 2 = On, 1 = Off
//End Of Main
 
 
 
 
define HOME = 0;
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 AR_Release = 70;
define Scope_only = TRUE;
define time = 2000;
define FIRE_BTN = 4;
define ADS_BTN = 7;
define R_X = 9;
define R_Y = 10;
define D_UP = 13;
define Blue = 1;
define Red = 2;
define Green = 3;
define Pink = 4;
define SkyBlue = 5;
define Yellow = 6;
define White = 7;
 
data(0, 0, 3, 0, 0, 0, 0, 3);
 
int AR_T[6];
 
int AR_V[4];
int recoil_onoff = TRUE;
int rapid_onoff = TRUE;
int RATE_OF_FIRE = 14;
int Col_ind;
int hold_time;
int rest_time;
int v, i, ar_y;
int ar_idx;
int rumble =- 1;
int rumble_t;
int aa_p = 24;
int aa_n =- 24;
int aa_delay = 20;
 
init {
    f_led_color(ar_idx);
    AR_T[0] = 10;
    AR_T[1] = 50;
    AR_T[2] = 140;
    AR_T[3] = 10;
    AR_T[4] = 90;
    AR_T[5] = 150;
 
    AR_V[0] = 15;
    AR_V[1] = 10;
    AR_V[2] = 17;
    AR_V[3] = 15;
}
 
 
main {
    if (get_val(7) && !get_val(4)) combo_run(c_AA_XY);
    else  combo_stop(c_AA_XY);
    if (get_val(7) && event_press(20)) {
        combo_run(c_vibrate);
        rapid_onoff =! rapid_onoff;
    }
    if (rapid_onoff && recoil_onoff) f_colourled(Green);
    if (rapid_onoff && !recoil_onoff) f_colourled(Pink);
    if (recoil_onoff && !rapid_onoff) f_colourled(Yellow);
    if (!recoil_onoff && !rapid_onoff) f_colourled(Red);
    if (rapid_onoff) {
        if (get_val(4)) {
            combo_run(c_RAPID_FIRE);
        }
        hold_time = 500 / RATE_OF_FIRE;
        rest_time = hold_time - 20;
        if (rest_time < 0) rest_time = 0;
    }
    if (get_val(7) && event_press(14)) {
        ar_idx = !ar_idx;
        rumble = ar_idx;
        f_led_color(ar_idx);
    }
    if (get_val(7) && get_val(4)) {
        if (get_ptime(FIRE_BTN) >= AR_T[(3 * (ar_idx)) + (0)]) ar_y = AR_V[(2 * (ar_idx)) + (0)];
        if (get_ptime(FIRE_BTN) >= AR_T[(3 * (ar_idx)) + (1)] * 10) ar_y = AR_V[(2 * (ar_idx)) + (1)];
        if (get_ptime(FIRE_BTN) >= AR_T[(3 * (ar_idx)) + (2)] * 10) ar_y = AR_V[(2 * (ar_idx)) + (2)];
        if (abs(get_val(9)) < ar_y + 5) set_val(R_Y, f_xy_val(R_Y, ar_y));
    }
    if (rumble >= 0) {
        if (!rumble_t) set_rumble(RUMBLE_A, 100);
        rumble_t = rumble_t + get_rtime();
        if (rumble_t == 250) reset_rumble();
        if (rumble_t == 400) {
            rumble -- ;
            rumble_t = 0;
        }
    }
}
 
 
combo c_AA_XY {
    set_val(10, f_xy_val(10, aa_p));
    wait(aa_delay);
    set_val(9, f_xy_val(9, aa_p));
    wait(aa_delay);
    set_val(10, f_xy_val(10, aa_n));
    wait(aa_delay);
    set_val(9, f_xy_val(9, aa_n));
    wait(aa_delay);
}
 
combo c_vibrate {
    set_rumble(1, 100);
    wait(300);
    reset_rumble();
}
 
combo c_RAPID_FIRE {
    set_val(4, 100);
    wait(hold_time);
    set_val(4, 0);
    wait(rest_time);
    set_val(4, 0);
}
 
 
function f_xy_val(f_axis, f_val) {
    v = get_val(f_axis);
    if (abs(v) < 10) v = 0;
    if (abs(v) < f_val + 5)
        return v + f_val;
    return v;
}
 
function f_led_color(color) {
    i = 0;
    while(i <= 3) {
        set_led(i, dbyte((color * 4) + i));
        i = i + 1;
    }
}
 
function f_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));
}
 
ConsoleTuner Support Team || Discord || Custom Scripts
User avatar
Buffy
Lieutenant
Lieutenant
 
Posts: 422
Joined: Wed Jul 20, 2016 5:23 am


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 65 guests