Anti Recoil Deadzone Compensation

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

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Fri Dec 21, 2018 4:42 am

Ok fixed how it should go download again and if you give the good to go I'll start my Battlefield different anti-recoil setting for stand/prone stuff....
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Anti Recoil Deadzone Compensation

Postby AryanX » Fri Dec 21, 2018 5:00 am

Alright, going to try it out again
User avatar
AryanX
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Fri Dec 21, 2018 12:38 am

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Fri Dec 21, 2018 5:13 am

Put it on 5sps because it doesn't bullet drop as much and 26 vertical.
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Anti Recoil Deadzone Compensation

Postby AryanX » Fri Dec 21, 2018 6:03 am

I really like how it turned out regarding the tracking. Y movement while shooting also feels alright. Is it possible for you to add an option in MS to wait before the anti recoil kicks in?
User avatar
AryanX
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Fri Dec 21, 2018 12:38 am

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Fri Dec 21, 2018 5:33 pm

AryanX wrote:I really like how it turned out regarding the tracking. Y movement while shooting also feels alright. Is it possible for you to add an option in MS to wait before the anti recoil kicks in?

Yeah I can put this in!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Fri Dec 21, 2018 10:05 pm

Code: Select all
 
/*
  You can set a delay before anti-recoil kicks in or set to 0.
  Stand anti-recoil is reset by tapping jump button...
    Crouch anti-recoil is when standing quick tap crouch button.
    Prone anti-recoil is by holding crouch button pass 120ms.
    Windows or laying your gun over something is a prone setting
    but is done easy by quick tap of d-pad left.
*/

uint16 ar_delay        = 160; // delay before anti-recoil adjustment.
fix32  vertical        = 17.0;//Stand adjustment
fix32  horizontal      =  0.0;
fix32  vertical_crouch = 16.0;//Crouch adjustment
fix32  vertical_prone  = 15.0;//Prone adjustment
fix32  noise;
uint32 hold_time = 40;
uint32 rest_time = 40;
bool   fire_toggle = 0; //change to 1 if you want rapid fire.
bool   ar_toggle   = 1;
bool   crouch;
init
{
    noise = 6.0;
}
 
main {
//-------------------------Remove stick noise---------------------------------//
    if(abs(get_actual(STICK_1_X)) < noise) set_val(STICK_1_X, 0.0);
    if(abs(get_actual(STICK_1_Y)) < noise) set_val(STICK_1_Y, 0.0);
    if(abs(get_actual(STICK_2_X)) < noise) set_val(STICK_2_X, 0.0);
    if(abs(get_actual(STICK_2_Y)) < noise) set_val(STICK_2_Y, 0.0);
 
    if(ar_toggle == 1)
    {
    if(get_actual(BUTTON_5) && time_active(BUTTON_5) >= ar_delay){
    if(crouch == 0  && get_val(BUTTON_8) && get_val(BUTTON_5)){combo_run(anti_recoil);}
    if(crouch == 1  && get_val(BUTTON_8) && get_val(BUTTON_5)){combo_run(anti_recoil_crouch);}
    if(crouch == 2 && get_actual(BUTTON_8) && get_val(BUTTON_5)){combo_run(anti_recoil_prone);}
    if(is_active(STICK_1_Y)){combo_stop(anti_recoil);combo_stop(anti_recoil_crouch);combo_stop(anti_recoil_prone);}
    if(is_active(STICK_1_X)){combo_stop(anti_recoil);combo_stop(anti_recoil_crouch);combo_stop(anti_recoil_prone);}
    if(!anti_recoil|| !anti_recoil_crouch || !anti_recoil_prone){
    if(get_actual(BUTTON_5)){
        AntiRecoil(STICK_1_Y, 14.0);
    AntiRecoil(STICK_1_X, 0.0);
    }
    }
    }
    }
 
    if(is_active(STICK_2_Y) && crouch == 0) {
        combo_run(EasySprint);
    }
    if(get_actual(BUTTON_5) || get_actual(BUTTON_8) ||
       get_actual(BUTTON_4) || get_actual(BUTTON_7)) {
        combo_stop(EasySprint);
    }
    if(get_actual(BUTTON_15) && time_active(BUTTON_15) < 120){
        crouch = 1;
    }
    if(get_actual(BUTTON_15) && time_active(BUTTON_15) > 120||
    event_release(BUTTON_12) && time_release(BUTTON_12)<140){
        crouch = 2;
    }else if(event_active(BUTTON_16)){
        crouch = 0;
    }inhibit(BUTTON_12,140);
    if(fire_toggle == 1){
    if(get_actual(BUTTON_5)){
        combo_run(fire);
    }
    }
}
 
combo anti_recoil
{
    set_val(STICK_1_Y, vertical);
    set_val(STICK_1_X, horizontal);
}
combo anti_recoil_crouch
{
    set_val(STICK_1_Y, vertical_crouch);
    set_val(STICK_1_X, horizontal);
}
combo anti_recoil_prone
{
    set_val(STICK_1_Y, vertical_prone);
    set_val(STICK_1_X, horizontal);
}
combo EasySprint
{
    set_val(BUTTON_9, 100.0);
    wait(hold_time);
    set_val(BUTTON_9, 0.0);
    wait(rest_time);
    set_val(BUTTON_9, 0.0);
}
combo fire
{
    set_val(BUTTON_5, 100.0);
    wait(hold_time);
    set_val(BUTTON_5, 0.0);
    wait(rest_time);
    set_val(BUTTON_5, 0.0);
}
void AntiRecoil(uint8 axis, fix32 recoil)
{
    set_val(axis,(recoil * (100.0 - abs(get_val(axis)))) / 100.0 + get_val(axis));
}
 

Try this for Battlefield V! Read top of script.... info!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Anti Recoil Deadzone Compensation

Postby AryanX » Fri Dec 21, 2018 11:23 pm

Alright, going to try in an hour.
User avatar
AryanX
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Fri Dec 21, 2018 12:38 am

Re: Anti Recoil Deadzone Compensation

Postby AryanX » Sat Dec 22, 2018 8:28 am

I tried and i felt that it wasn't tracking crouching etc like i wanted to. Sometimes it would work, then it would apply recoil for the wrong version.

I wanted to try anti recoil which depended on both axis during movement so i created a modified equation. I ended up writing stand/prone/crouch code as well. It only handles simple rapid fire and different poses. I setup two configs which you can try.

Code: Select all
#pragma METAINFO("AC Battlefield V", 1, 00, "AryanX")
 
 
/* *****************************************************************************
<cfgdesc>
[BATTLEFIELD V AC]
color       = #008000
shortdesc    = Automatically detects crouch/stand/prone to use appropriate recoil. Runtime operations for manual overrides. Press Jump button to reset to standing. <br /><br /> <b><u>Runtime Operations</b></u>  <br /><br />Press <b>[Touch-Click|View] + [CROSS|A]</b> to quickly enable/disable the mod. <br /> Press <b>[Touch-Click|View] + DPAD UP</b> to manually set <b>Standing Anti Recoil</b>  mode<br /> Press <b>[Touch-Click|View] + DPAD Down</b> to manually set <b>Crouch Anti Recoil</b>  mode<br /> Press <b>[Touch-Click|View] + DPAD Left</b> to manually set <b>Prone Anti Recoil</b>  mode<br /> Press <b>[Touch-Click|View] + DPAD Right</b> to manually set <b>Custom Anti Recoil</b>  mode. Can only be set manually.
control        = info
 
[One Click Config]
color       = #008000
collapsible = 2
shortdesc    = One click predefined configurations. To create one, click on copy configuration after modification, go to script "One Click Config" and add to items
control    = config
item    = ASSAULT S1916 Base:80001900000019000080004B001E0000000451EC0019C00000000000001940000000000000192667000000000019000000000000
item    = ASSAULT S1916 LLLR Tree:80001900000019000080004B001E0000000451EC00160000000000000013DC29000000000011F334000000000019000000000000
item    = SUPPORT LEWIS LRRL Tree:8002BC000000320000800014001E0000000451EC0013851F000240000011B3340002451F000F26670001B3340019000000000000
 
[Rapidfire Settings]
color       = #008000
collapsible = 2
shortdesc    = Enable Rapid Fire?
byteoffset    = 0
bitsize        = 1
bitoffset    = 7
control        = checkbox
default        = 1
item        = Rapidfire ON
 
[Rapidfire Hold Time]
group        = true
shortdesc    = Rapidfire Hold Time
byteoffset    = 1
bitsize        = 16
control        = spinbox
default        = 25
minimum        = 10
maximum        = 5000
step        = 1
 
[Rapidfire Release Time]
group        = true
shortdesc    = Rapidfire Release Time
byteoffset    = 5
bitsize        = 16
control        = spinbox
default        = 25
minimum        = 10
maximum        = 5000
step        = 1
 
[Anti Recoil Settings]
color       = #008000
shortdesc    = Enable Anti Recoil?
byteoffset    = 9
bitsize        = 1
bitoffset    = 7
control        = checkbox
default        = 1
item        = Anti Recoil ON
 
[Anti Recoil Delay]
group        = true
shortdesc    = Anti Recoil Delay (In MS) after fire button is pressed.
byteoffset    = 10
bitsize        = 16
control        = slider
default        = 75
minimum        = 0
maximum        = 1000
step        = 5
 
[Min Anti Recoil Percent]
group        = true
shortdesc    = Minimum Percentage of Anti Recoil to apply during aim stick movement.
byteoffset    = 12
bitsize        = 32
control        = spinboxf
default        = 300
minimum        = 0
maximum        = 1000
step        = 100
decimals    = 1
 
[Antithesis Apex Dead Zone Remover]
group        = true
shortdesc    = Stick Noise. Set to the resting dead zone values for your right stick.
byteoffset    = 16
bitsize        = 32
control        = spinboxf
default        = 432
minimum        = 0
maximum        = 10000
step        = 100
decimals    = 2
 
[Standing Anti Recoil Settings]
collapsible = 2
shortdesc    = Standing: Anti Recoil vertical pull force compensation.
byteoffset    = 20
bitsize        = 32
control        = spinboxf
default        = 2500
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Standing Anti Recoil H Settings]
group        = true
shortdesc    = Standing: Anti Recoil horizontal pull force compensation.
byteoffset    = 24
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Crouch Anti Recoil Settings]
collapsible = 2
shortdesc    = Crouch: Anti Recoil vertical pull force compensation.
byteoffset    = 28
bitsize        = 32
control        = spinboxf
default        = 2500
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Crouch Anti Recoil H Settings]
group        = true
shortdesc    = Crouch: Anti Recoil horizontal pull force compensation.
byteoffset    = 32
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Prone Anti Recoil Settings]
collapsible = 2
shortdesc    = Prone: Anti Recoil vertical pull force compensation.
byteoffset    = 36
bitsize        = 32
control        = spinboxf
default        = 2500
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Prone Anti Recoil H Settings]
group        = true
shortdesc    = Prone: Anti Recoil horizontal pull force compensation.
byteoffset    = 40
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Custom Anti Recoil Settings]
collapsible = 2
shortdesc    = Custom: Anti Recoil vertical pull force compensation.
byteoffset    = 44
bitsize        = 32
control        = spinboxf
default        = 2500
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
[Custom Anti Recoil H Settings]
group        = true
shortdesc    = Custom: Anti Recoil horizontal pull force compensation.
byteoffset    = 48
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 30
decimals    = 2
 
</cfgdesc>
***************************************************************************** */

 
 
/////////////////////////////////////////////////////////////////////////////////
//  Button Defines
/////////////////////////////////////////////////////////////////////////////////
#define STK_MOVE_X  STICK_2_X
#define STK_MOVE_Y  STICK_2_Y
#define STK_AIM_X  STICK_1_X
#define STK_AIM_Y  STICK_1_Y
#define BTN_JUMP  BUTTON_16
#define BTN_SPRINT  BUTTON_9
#define BTN_CROUCH  BUTTON_15
#define BTN_RELOAD  BUTTON_17
#define BTN_CHANGE_WEAPON  BUTTON_14
#define BTN_COMMO_ROSE  BUTTON_4
#define BTN_GRENADE  BUTTON_7
#define BTN_ADS  BUTTON_8
#define BTN_SHOOT  BUTTON_5
#define BTN_MELEE  BUTTON_6
#define BTN_DPAD_UP  BUTTON_10
#define BTN_DPAD_DOWN  BUTTON_11
#define BTN_DPAD_LEFT  BUTTON_12
#define BTN_DPAD_RIGHT  BUTTON_13
#define BTN_MENU  BUTTON_3
#define BTN_PS  BUTTON_1
#define BTN_TOUCHPAD  BUTTON_2
#define BTN_SHARE  BUTTON_18
#define float  fix32
/////////////////////////////////////////////////////////////////////////////////
//  Character State Defines
/////////////////////////////////////////////////////////////////////////////////
#define STATE_STANDING  0 //[Touch-Click|View] + DPAD UP
#define STATE_CROUCH  1 //[Touch-Click|View] + DPAD DOWN
#define STATE_PRONE  2 //[Touch-Click|View] + DPAD LEFT
#define STATE_CUSTOM  3 //[Touch-Click|View] + DPAD RIGHT
 
/////////////////////////////////////////////////////////////////////////////////
//  Configurable Variables
/////////////////////////////////////////////////////////////////////////////////
 
//Anti Recoil
bool bUseAntiRecoil = TRUE;
float ARecoil_H_Standing = 0.0;
float ARecoil_V_Standing = 25.0;
float ARecoil_H_Crouch = 0.0;
float ARecoil_V_Crouch = 25.0;
float ARecoil_H_Prone = 0.0;
float ARecoil_V_Prone = 25.0;
float ARecoil_H_Custom = 0.0;
float ARecoil_V_Custom = 25.0;
uint16 ARecoilDelay = 75;
 
//Percent of anti ARecoil to always apply regardless of aim movement
float MinARecoilPercent = 30.0;
 
//Apex Dead zone Remover
float StickNoise = 4.32;
 
//Rapid Fire
bool bUseRapidFire = TRUE;
int RapidHold = 25;
int RapidRelease = 25;
 
/////////////////////////////////////////////////////////////////////////////////
//  Dev Variables
/////////////////////////////////////////////////////////////////////////////////
//Mod Enable
bool bModOn = TRUE;
 
//Anti Recoil
float ARecoil_H_ToUse = 0.0;
float ARecoil_V_ToUse = 0.0;
 
//Character State Related
int CharacterStateCurrent = STATE_STANDING;
int32 TimeInState = 0;
 
//Debug Related
int DebugLevel = 1;
 
//Runtime Operations Related
int RuntimeClickWindow = 700;
 
//Crouch/Prone
int ProneHoldTime = 195; //it is around 180 but fluctuates so 195 to be safe
 
/////////////////////////////////////////////////////////////////////////////////
//  Init
/////////////////////////////////////////////////////////////////////////////////
init
{
    pmem_load(); // Load permanent memory before use any pmem operation
 
    // Store the values from the permanent memory (the configuration values)
     // into variables.
    bUseRapidFire = (pmem_read(0) >> 7) & 0b1;
    pmem_read(1, &RapidHold);
    pmem_read(5, &RapidRelease);
    bUseAntiRecoil = (pmem_read(9) >> 7) & 0b1;
    pmem_read(10, &ARecoilDelay);
    pmem_read(12, &MinARecoilPercent);
    pmem_read(16, &StickNoise);
    pmem_read(20, &ARecoil_V_Standing);
    pmem_read(24, &ARecoil_H_Standing);
    pmem_read(28, &ARecoil_V_Crouch);
    pmem_read(32, &ARecoil_H_Crouch);
    pmem_read(36, &ARecoil_V_Prone);
    pmem_read(40, &ARecoil_H_Prone);
    pmem_read(44, &ARecoil_V_Custom);
    pmem_read(48, &ARecoil_H_Custom);
 
 
    printf("bUseRapidFire: %d", bUseRapidFire);
    printf("RapidHold: %d", RapidHold);
    printf("RapidRelease: %d", RapidRelease);
 
    printf("bUseAntiRecoil: %d", bUseAntiRecoil);
    printf("ARecoilDelay: %d", ARecoilDelay);
    printf("MinARecoilPercent: %.02f", MinARecoilPercent);
    printf("StickNoise: %.02f", StickNoise);
    printf("ARecoil_V_Standing: %.02f", ARecoil_V_Standing);
    printf("ARecoil_H_Standing: %.02f", ARecoil_H_Standing);
    printf("ARecoil_V_Crouch: %.02f", ARecoil_V_Crouch);
    printf("ARecoil_H_Crouch: %.02f", ARecoil_H_Crouch);
    printf("ARecoil_V_Prone: %.02f", ARecoil_V_Prone);
    printf("ARecoil_H_Prone: %.02f", ARecoil_H_Prone);
    printf("ARecoil_V_Custom: %.02f", ARecoil_V_Custom);
    printf("ARecoil_H_Custom: %.02f", ARecoil_H_Custom);
 
}
 
/////////////////////////////////////////////////////////////////////////////////
//  Main loops
/////////////////////////////////////////////////////////////////////////////////
main
{
    //////////////////////////////////////////////////////////////////////////
    //Runtime Operations
    //////////////////////////////////////////////////////////////////////////
 
    // Press [Touch-Click|View] + [CROSS|A] to quickly enable/disable the mod
    if (get_actual(BTN_TOUCHPAD))
    {
        //Disabling relevant input during runtime click window
        if (time_active(BTN_TOUCHPAD) < RuntimeClickWindow)
        {
            set_val(BTN_TOUCHPAD, 0.0);
 
            if (event_active(BTN_JUMP))
            {               
                bModOn = !bModOn;
                if(bModOn)
                    DebugString(1, "Mod On");
                else
                    DebugString(1, "Mod Off");
            }
            set_val(BTN_JUMP, 0.0);
 
            if (event_active(BTN_DPAD_UP))
            {
                SetCharacterState(STATE_STANDING);
            }
            set_val(BTN_DPAD_UP, 0.0);
 
            if (event_active(BTN_DPAD_DOWN))
            {               
                SetCharacterState(STATE_CROUCH);
            }
            set_val(BTN_DPAD_DOWN, 0.0);
 
            if (event_active(BTN_DPAD_LEFT))
            {           
                SetCharacterState(STATE_PRONE);
            }
            set_val(BTN_DPAD_LEFT, 0.0);
 
            if (event_active(BTN_DPAD_RIGHT))
            {               
                SetCharacterState(STATE_CUSTOM);
            }
            set_val(BTN_DPAD_RIGHT, 0.0);
 
        }
    }
 
 
if (bModOn)
{
    //////////////////////////////////////////////////////////////////////////
    //Character State Checking
    //////////////////////////////////////////////////////////////////////////   
    TimeInState += elapsed_time();
    clamp(TimeInState, 0, 10000000);
 
    //Regardless of any state when jump button is pressed, the character goes standing
    if (event_active(BTN_JUMP))
    {       
        SetCharacterState(STATE_STANDING);
    }
 
    //Standing State to other state checks
    if (CharacterStateCurrent == STATE_STANDING && TimeInState > 0)
    {
        if (event_release(BTN_CROUCH))
        {
            if (time_active(BTN_CROUCH) < ProneHoldTime)
            {
                SetCharacterState(STATE_CROUCH);
            }
            else
            {
                SetCharacterState(STATE_PRONE);
            }
        }
    }
 
    //Crouch State to other state checks
    if (CharacterStateCurrent == STATE_CROUCH && TimeInState > 0)
    {
        if (event_release(BTN_CROUCH))
        {
            if (time_active(BTN_CROUCH) < ProneHoldTime)
            {
                SetCharacterState(STATE_STANDING);
            }
            else
            {
                SetCharacterState(STATE_PRONE);
            }
        }
    }
 
    //Prone State to other state checks
    if (CharacterStateCurrent == STATE_PRONE && TimeInState > 0)
    {
        if (event_release(BTN_CROUCH))
        {
            if (time_active(BTN_CROUCH) < ProneHoldTime)
            {
                SetCharacterState(STATE_CROUCH);
            }
            else
            {
                SetCharacterState(STATE_STANDING);
            }
        }
 
        //If character is prone and presses sprint with movement forward and no ads, it goes to standing.
        if (get_val(BTN_SPRINT) && (time_active(BTN_SPRINT) < TimeInState) && (get_val(STK_MOVE_Y) <= -40.0) && get_val(BTN_ADS) == 0.0)
        {
            SetCharacterState(STATE_STANDING);
        }
    }
 
 
 
    //////////////////////////////////////////////////////////////////////////
    //Rapid Fire
    //////////////////////////////////////////////////////////////////////////
    if (bUseRapidFire)
    {
        if (get_actual(BTN_SHOOT))
        {
            combo_run(RapidFire);
        }
 
        if (event_release(BTN_SHOOT))
        {
            set_val(BTN_SHOOT, 0.0);
            combo_stop(RapidFire);
        }
    }
 
    //////////////////////////////////////////////////////////////////////////
    //Anti Recoil
    //////////////////////////////////////////////////////////////////////////
    if (bUseAntiRecoil)
    {
        if (CharacterStateCurrent == STATE_STANDING)
        {
            ARecoil_V_ToUse = ARecoil_V_Standing;
            ARecoil_H_ToUse = ARecoil_H_Standing;
        }
        else if (CharacterStateCurrent == STATE_CROUCH)
        {
            ARecoil_V_ToUse = ARecoil_V_Crouch;
            ARecoil_H_ToUse = ARecoil_H_Crouch;
        }
        else if (CharacterStateCurrent == STATE_PRONE)
        {
            ARecoil_V_ToUse = ARecoil_V_Prone;
            ARecoil_H_ToUse = ARecoil_H_Prone;
        }
        else if (CharacterStateCurrent == STATE_CUSTOM)
        {
            ARecoil_V_ToUse = ARecoil_V_Custom;
            ARecoil_H_ToUse = ARecoil_H_Custom;
        }
 
        if(TimeInState == 0)
        {
            DebugFloat(1, "Anti Recoil V: %.02f", ARecoil_V_ToUse);
            DebugFloat(1, "Anti Recoil H: %.02f", ARecoil_H_ToUse);
        }
 
        if (get_actual(BTN_SHOOT) && time_active(BTN_SHOOT) >= ARecoilDelay)
        {
 
            if (abs(get_actual(STK_AIM_X)) < StickNoise) set_val(STK_AIM_X, 0.0);
            if (abs(get_actual(STK_AIM_Y)) < StickNoise) set_val(STK_AIM_Y, 0.0);
            if (abs(get_actual(STK_MOVE_X)) < StickNoise) set_val(STK_MOVE_X, 0.0);
            if (abs(get_actual(STK_MOVE_Y)) < StickNoise) set_val(STK_MOVE_Y, 0.0);
 
            //We currently only want shoot to be on during the hold phase of rapid fire
            if (get_val(BTN_SHOOT))
            {
                AntiRecoil(STK_AIM_X, ARecoil_H_ToUse);
                AntiRecoil(STK_AIM_Y, ARecoil_V_ToUse);
            }
        }
    }
}
 
 
}
 
/////////////////////////////////////////////////////////////////////////////////
//  Combos
/////////////////////////////////////////////////////////////////////////////////
combo RapidFire
{
    set_val(BTN_SHOOT, 100);
wait(RapidHold);
set_val(BTN_SHOOT, 0);
wait(RapidRelease);
}
 
/////////////////////////////////////////////////////////////////////////////////
//  Functions
/////////////////////////////////////////////////////////////////////////////////
 
void DebugString(int DLevel, char* String)
{
    if (DLevel >= DebugLevel)
    {
        printf(String);
    }
}
 
void DebugInt(int DLevel, char* String, int Integer)
{
    if (DLevel >= DebugLevel)
    {
        printf(String, Integer);
    }
}
 
void DebugFloat(int DLevel, char* String, float FloatValue)
{
    if (DLevel >= DebugLevel)
    {
        printf(String, FloatValue);
    }
}
 
void SetCharacterState(int NewCharacterState)
{
    if (NewCharacterState != CharacterStateCurrent)
    {
        DebugInt(1, "Time In Old State(sec): %d", TimeInState/1000);
        TimeInState = 0;
        CharacterStateCurrent = NewCharacterState;
 
        if (NewCharacterState == STATE_STANDING)
        {
            DebugString(1, "New State: STATE_STANDING");
        }
        else if (NewCharacterState == STATE_CROUCH)
        {
            DebugString(1, "New State: STATE_CROUCH");
        }
        else if (NewCharacterState == STATE_PRONE)
        {
            DebugString(1, "New State: STATE_PRONE");
        }
        else if (NewCharacterState == STATE_CUSTOM)
        {
            DebugString(1, "New State: STATE_CUSTOM");
        }
    }
}
 
void AntiRecoil(uint8 AxisToApply, float ARecoilToApply)
{
    float CurrentX = get_val(STK_AIM_X);
    float CurrentY = get_val(STK_AIM_Y);
    float MinARecoilFactor = MinARecoilPercent / 100.0;
    float MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
 
    //This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
    float MovementARecoilToApply = (1.0 - MinARecoilFactor) * ((ARecoilToApply * (100.0 - sqrt(CurrentX*CurrentX + CurrentY*CurrentY))) / (100.0 + abs(CurrentX) + (CurrentY*CurrentY*0.5)));
 
    set_val(AxisToApply, MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply));
}
 
 
User avatar
AryanX
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Fri Dec 21, 2018 12:38 am

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Sat Dec 22, 2018 3:35 pm

Very nice for the few minutes testing....Awesome work! Yeah I found out for different stances to bring the turn number down also so I did change mine too. Anyway this looks like it! Do more testing :smile0517:
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Anti Recoil Deadzone Compensation

Postby bonefisher » Sun Dec 23, 2018 12:13 am

@AryanX this is really working well so I dropped what I was doing. lol! Do you mined if I use this in my script I will definitely give you credit if I post?
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 116 guests