Progressive antirecoil

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

Progressive antirecoil

Postby Alfagamer » Mon Apr 05, 2021 12:26 am

Convertion for titan one please.

Code: Select all
//Posted by Batts, a member of the device Community - https://device.com/forums
 
//Posted : Monday 5th of April, 2021 0:15 UTC 
 
 
//--Anti-Recoil Progression Adjustable Transition Point
 
 
//--Anti-Recoil values go from Starting_Anti_Recoil_Value to Mid_Point_Anti_Recoil_Value over Progression_Point_Percent of Total_Anti_Recoil_Time
//--Anti-Recoil values then go from Mid_Point_Anti_Recoil_Value to Ending_Anti_Recoil_Value for the remaining Total_Anti_Recoil_Time percent
//--Ending_Anti_Recoil_Value is then applied until trigger release.
 
 
 
 
//--Adjust These Values
 
 
    define    Starting_Anti_Recoil_Value  = 20;    //--postive values only
    define    Mid_Point_Anti_Recoil_Value = 28;
    define    Ending_Anti_Recoil_Value    = 10;
    define    Total_Anti_Recoil_Time      = 2500//-- 10ms increments (min - 2000)
    define    Progression_Point_Percent   = 30;    //--percentage of total time to transition to mid to end values 10% increments
 
 
//--Do not alter sequence of the variables below.  Script uses in-direct reference to access the values (ex... inc[0] = inc , inc[1] = inc_2)
 
    int p,inc,inc_2,pr,pr_2,vm,vm_2;
    int loops,loops_2,vm_count,p_count,v,ar_y;
 
init {
    loops = (Total_Anti_Recoil_Time / 100) * (Progression_Point_Percent / 10);
    loops_2 = (Total_Anti_Recoil_Time / 10) - loops;
    if(Starting_Anti_Recoil_Value < Mid_Point_Anti_Recoil_Value)
        inc = 1;
    else
        inc = -1;
    if(Mid_Point_Anti_Recoil_Value < Ending_Anti_Recoil_Value)
        inc_2 = 1;
    else
        inc_2 = -1;
    pr = abs(Starting_Anti_Recoil_Value - Mid_Point_Anti_Recoil_Value);
    pr_2 = abs(Mid_Point_Anti_Recoil_Value - Ending_Anti_Recoil_Value);
    vm = loops / pr;
    vm_2 = loops_2 / pr_2;
}
 
main {
 
    //--device monitor
    set_val(30,vm_count);
    set_val(31,p);
    set_val(32,ar_y);
 
    if(!get_lval(4)) {
        p = 0;
        vm_count = 0;
        p_count = 0;
        ar_y = Starting_Anti_Recoil_Value;
    }
 
 
    //--RT
    if(get_val(4)) {
        p = p_cycle();
        if(p != -1)
            ar_y = p_val();
        else
            ar_y = Ending_Anti_Recoil_Value;
         set_val(10,y_val());
    }   
}
function p_val() {
    p_count++;
    if(p_count == vm[p]) {
        p_count = 0;
        ar_y += inc[p];
    }
    return ar_y;
}
function p_cycle() {
    vm_count++;
    if (vm_count > loops[p]) {
        if(!p) {
            vm_count = 0;
            return 1;
        }
        else{
            vm_count = loops_2;
            return -1;
         }
     }
     return p;
}       
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;           
}
User avatar
Alfagamer
First Sergeant
First Sergeant
 
Posts: 60
Joined: Fri Sep 04, 2020 7:58 am

Re: Progressive antirecoil

Postby Mad » Mon Apr 05, 2021 7:38 am

Code: Select all
    define    Starting_Anti_Recoil_Value  = 20;    //--postive values only
    define    Mid_Point_Anti_Recoil_Value = 28;
    define    Ending_Anti_Recoil_Value    = 10;
    define    Total_Anti_Recoil_Time      = 2500//-- 10ms increments (min - 2000)
    define    Progression_Point_Percent   = 30;    //--percentage of total time to transition to mid to end values 10% increments
 
 
//--Do not alter sequence of the variables below.  Script uses in-direct reference to access the values (ex... inc[0] = inc , inc[1] = inc_2)
 
    int p,inc,inc_2,pr,pr_2,vm,vm_2;
    int loops,loops_2,vm_count,p_count,v,ar_y;
 
init {
    loops = (Total_Anti_Recoil_Time / 100) * (Progression_Point_Percent / 10);
    loops_2 = (Total_Anti_Recoil_Time / 10) - loops;
    if(Starting_Anti_Recoil_Value < Mid_Point_Anti_Recoil_Value)
        inc = 1;
    else
        inc = -1;
    if(Mid_Point_Anti_Recoil_Value < Ending_Anti_Recoil_Value)
        inc_2 = 1;
    else
        inc_2 = -1;
    pr = abs(Starting_Anti_Recoil_Value - Mid_Point_Anti_Recoil_Value);
    pr_2 = abs(Mid_Point_Anti_Recoil_Value - Ending_Anti_Recoil_Value);
    vm = loops / pr;
    vm_2 = loops_2 / pr_2;
}
 
main {
 
    //--device monitor
    set_val(30,vm_count);
    set_val(31,p);
    set_val(32,ar_y);
 
    if(!get_lval(4)) {
        p = 0;
        vm_count = 0;
        p_count = 0;
        ar_y = Starting_Anti_Recoil_Value;
    }
 
 
    //--RT
    if(get_val(4)) {
        p = p_cycle();
        if(p != -1)
            ar_y = p_val();
        else
            ar_y = Ending_Anti_Recoil_Value;
         set_val(10,y_val());
    }   
}
function p_val() {
    p_count = p_count + 1;
    if(p_count == vm[p]) {
        p_count = 0;
        ar_y = ar_y + inc[p];
    }
    return ar_y;
}
function p_cycle() {
    vm_count = vm_count + 1;
    if (vm_count > loops[p]) {
        if(!p) {
            vm_count = 0;
            return 1;
        }
        else{
            vm_count = loops_2;
            return -1;
         }
     }
     return p;
}       
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;           
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Progressive antirecoil

Postby Alfagamer » Mon Apr 05, 2021 2:21 pm

Thank you very much
User avatar
Alfagamer
First Sergeant
First Sergeant
 
Posts: 60
Joined: Fri Sep 04, 2020 7:58 am


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 86 guests