Need some help converting script. Coded for device

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

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

Need some help converting script. Coded for device

Postby bt1740 » Thu Jun 13, 2019 11:17 pm

Need help converting this script, would appreciate any help I can get, thanks. Getting a couple errors. Originally coded for the device.

Code: Select all
 
 
 
 
 
    #define    Starting_Anti_Recoil_Value  = 20;
    #define    Ending_Anti_Recoil_Value    = 19;
    #define    Total_Anti_Recoil_Time      = 1500;  //-- 10ms increments
     int aa_p  = 17;
    int aa_n = -17;
    int aa_delay  = 20;
    int release = 19;
    int i_val;
    int i_pnt;
    int i_num;
    int i_cnt;
 
    int v,ar_y;
 
init {
    //--adding or subtracting
    if(Starting_Anti_Recoil_Value < Ending_Anti_Recoil_Value)
        i_val = 1;
    else
        i_val = -1;
    //--iteration point for progression
    i_pnt = (Total_Anti_Recoil_Time / 10) / (abs(Starting_Anti_Recoil_Value - Ending_Anti_Recoil_Value));
}
 
 
main {
 
 
 
 
    if(get_val(PS4_CIRCLE) > 0 ) {
 
        if(get_val(PS4_L2) < 100 || get_val(PS4_R2) < 100) {
 
            set_val(PS4_L3, 100);
 
            set_val(PS4_LY, -100);
 
 
            //set_val(PS4_CIRCLE, 100);
        }
 
 
    }
 
    if(get_val(PS4_R3) > 0)
    {
        set_val(PS4_R3, 0);   
    combo_run(test);
    }
 if(get_val(7)  && !get_val(4)) combo_run(AA_XY);
        else combo_stop(AA_XY);
 
    //--reset counters/pointers
    if(!get_lval(4)) {
       ar_y = Starting_Anti_Recoil_Value;
       i_cnt = 0;
       i_num = 0;
    }
 
    //--RT
    if(get_val(4)) {
        if(!p_complete()) 
            ar_y = p_val();
        else
            ar_y = Ending_Anti_Recoil_Value;
        //--set RY to anti recoil value
        set_val(10,y_val());
    }   
}
combo test {
    set_val(PS4_R2, 0);
    set_val(PS4_R3, 100);
 
 
 
}
combo AA_XY {
    set_val(10,xy_val(10,aa_p));
    wait(aa_delay)
    set_val(9,xy_val(9,aa_p));
    set_val(11,xy_val(11,aa_p));
    wait(aa_delay)
    set_val(10,xy_val(10,aa_n));
    wait(aa_delay)
    set_val(9,xy_val(9,aa_n));
    set_val(11,xy_val(11,aa_n));
    wait(aa_delay)
}
function xy_val(f_axis,f_val) {
    if(abs(get_val(f_axis)) < release)
        return f_val;
    return get_val(f_axis);
}
function p_complete() {
    i_cnt++;
    if (i_cnt > Total_Anti_Recoil_Time / 10) {
        //--avoid stack overflow
        i_cnt = Total_Anti_Recoil_Time / 10;
        //--progression complete
        return 1;
    }
    //--progression not complete
    return 0;
}       
function p_val() {
    i_num++;
    if(i_num == i_pnt) {
        //--reset counter
        i_num = 0;
        //--adjust ar_y
        ar_y += i_val;
    }
    return ar_y;
}
function y_val() {
    v = get_val(10);
    if(abs(v) < 10)
        v = 0;
    if(abs(v) > ar_y + 5)
        return v;
    return v + ar_y;         
}




The errors i got are
GPC error: melee-antirecoily-aimassist-reloadcancel.gpc(27): syntax error, unexpected ASSIGN '='.
GPC error: melee-antirecoily-aimassist-reloadcancel.gpc(11): syntax error, unexpected IDENTIFIER 'define'.
User avatar
bt1740
Private First Class
Private First Class
 
Posts: 3
Joined: Thu Jun 13, 2019 11:13 pm

Re: Need some help converting script. Coded for device

Postby Buffy » Fri Jun 14, 2019 12:05 am

Code: Select all
 
#pragma METAINFO("this.gpc", 1, 0, "Buffy's GPC Converter v0.25")
#include <titanone.gph>
 
 
//-- 10ms increments
//--adding or subtracting
//--iteration point for progression
//set_val(PS4_CIRCLE, 100);
//--reset counters/pointers
//--RT
//--set RY to anti recoil value
//--avoid stack overflow
//--progression complete
//--progression not complete
//--reset counter
//--adjust ar_y
 
 
 
 
define Starting_Anti_Recoil_Value = 20;
define Ending_Anti_Recoil_Value = 19;
define Total_Anti_Recoil_Time = 1500;
 
int aa_p = 17;
int aa_n =- 17;
int aa_delay = 20;
int release = 19;
int i_val;
int i_pnt;
int i_num;
int i_cnt;
int v, ar_y;
 
init {
    if (Starting_Anti_Recoil_Value < Ending_Anti_Recoil_Value) i_val = 1;
    else  i_val =- 1;
    i_pnt = (Total_Anti_Recoil_Time / 10) / (abs(Starting_Anti_Recoil_Value - Ending_Anti_Recoil_Value));
}
 
 
main {
    if (get_val(PS4_CIRCLE) > 0) {
        if (get_val(PS4_L2) < 100 || get_val(PS4_R2) < 100) {
            set_val(PS4_L3, 100);
            set_val(PS4_LY, - 100);
        }
    }
    if (get_val(PS4_R3) > 0) {
        set_val(PS4_R3, 0);
        combo_run(c_test);
    }
    if (get_val(7) && !get_val(4)) combo_run(c_AA_XY);
    else  combo_stop(c_AA_XY);
    if (!get_lval(4)) {
        ar_y = Starting_Anti_Recoil_Value;
        i_cnt = 0;
        i_num = 0;
    }
    if (get_val(4)) {
        if (!f_p_complete()) ar_y = f_p_val();
        else  ar_y = Ending_Anti_Recoil_Value;
        set_val(10, f_y_val());
    }
}
 
 
combo c_test {
    set_val(PS4_R2, 0);
    set_val(PS4_R3, 100);
}
 
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));
    set_val(11, f_xy_val(11, 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));
    set_val(11, f_xy_val(11, aa_n));
    wait(aa_delay);
}
 
 
function f_xy_val(f_axis, f_val) {
    if (abs(get_val(f_axis)) < release)
        return f_val;
    return get_val(f_axis);
}
 
function f_p_complete() {
    i_cnt ++ ;
    if (i_cnt > Total_Anti_Recoil_Time / 10) {
        i_cnt = Total_Anti_Recoil_Time / 10;
        return 1;
    }
    return 0;
}
 
function f_p_val() {
    i_num ++ ;
    if (i_num == i_pnt) {
        i_num = 0;
        ar_y += i_val;
    }
    return ar_y;
}
 
function f_y_val() {
    v = get_val(10);
    if (abs(v) < 10) v = 0;
    if (abs(v) > ar_y + 5)
        return v;
    return v + ar_y;
}
 


Please check this thread out: viewtopic.php?f=26&t=12027
User avatar
Buffy
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 259
Joined: Wed Jul 20, 2016 5:23 am


Return to GPC Script Programming (Titan Two)

Who is online

Users browsing this forum: LyndonLauder and 7 guests