SIMPLE anti recoil script for Rainbow Six

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

Re: SIMPLE anti recoil script for Rainbow Six

Postby bonefisher » Wed Aug 15, 2018 4:12 pm

TheSaint wrote:Yes, updated last month. It does not happen with other AR scripts. It only happens randomly. But the melee issue is more common in latest script.

You sure your not pushing the button and just letting the strafe do it for you?
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby Sillyasskid » Wed Aug 15, 2018 5:08 pm

@bonefisher
Code: Select all
if(get_actual(BUTTON_8) && event_release(BUTTON_8) < 140) {


:whistling: less then 140...? That if statement does not really make sense. Did you mean to to use a different function other than event_release()?
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby bonefisher » Wed Aug 15, 2018 7:34 pm

hmmmm let me look what it is doing....
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby bonefisher » Wed Aug 15, 2018 7:55 pm

Sillyasskid wrote:@bonefisher
Code: Select all
if(get_actual(BUTTON_8) && event_release(BUTTON_8) < 140) {


:whistling: less then 140...? That if statement does not really make sense. Did you mean to to use a different function other than event_release()?

This hold aiming down sight on and holds whatever lean you have locked in. Then a quick tap of ads releases everything on next line.
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby TheSaint » Wed Aug 15, 2018 8:41 pm

Will you release an updated version for testing? :)
User avatar
TheSaint
Command Sergeant Major
Command Sergeant Major
 
Posts: 148
Joined: Sun Jun 24, 2018 1:43 pm

Re: SIMPLE anti recoil script for Rainbow Six

Postby bonefisher » Fri Aug 17, 2018 3:39 am

TheSaint wrote:Will you release an updated version for testing? :)

Code: Select all
 
#pragma METAINFO("R 6 S", 1, 0, "bonefisher")
 
/* *****************************************************************************
<cfgdesc>
[R 6 S MODzPACK]
color       = #349510
shortdesc    = Switching P=primary(blue led) and S=secondary(red led) enabled. If you get on wrong side hold switch button for 300ms to correct weapon class.
control        = info
 
[ONE CLICK CONFIGURATIONS]
color       = #349510
collapsible = 2
shortdesc    = One click predefined configurations can be incorporated in the Interactive Configuration interface.
control        = config
item        = SLEDGE:000000029E0000000000000003000000A000194CCD0005000001000000000001C10000000000000002000000A00018000000000000
item        = THATCHER:010000005C0000000000000001000000A0001800000000000001000000000001C10000000000000002000000A00018000000000000
item        = ASH:020000035C0000000000000003000000A00018D99A0000000001000000000001C10000000000000002000000A00017800000000000
item        = THERMITE:02000002B20000000000000003000000A0001800000000000001000000000001C10000000000000002000000A00017800000000000
item        = TWITCH:01000001F40000000000000003000000A00018D99AFFFF4CCC01000000000001C10000000000000002000000A00017800000000000
 
[PRIMARY WEAPONS FIRING OPTIONS]
color       = #349510
collapsible = 2
shortdesc    = Enable options on fire trigger.
byteoffset    = 0
bitsize        = 8
control        = radiobox
default        = 0
item        = Disabled for automatics
item        = Enable rapid fire for semi-automatics.
item        = Enable burst firing for automatics.
item        = Enable burst firing for semi-automatics.
 
[PRIMARY WEAPON ROUNDS PER MINUTE]
group        = true
shortdesc    = Adjust rounds per minute.
byteoffset    = 1
bitsize        = 32
control        = spinbox
default        = 360
minimum        = 60
maximum        = 1200
step        = 1
 
[PRIMARY WEAPON SHOTS PER BURST]
group        = true
shortdesc    = Apply burst shots by quick tap of fire trigger or for burst firing.
byteoffset    = 9
bitsize        = 32
control        = spinbox
default        = 1
minimum        = 1
maximum        = 20
step        = 1
 
[PRIMARY WEAPON BURST FIRE]
group        = true
shortdesc    = Adjust release time for burst firing semi-automatics or automatics.
byteoffset    = 13
bitsize        = 32
control        = spinbox
default        = 160
minimum        = 1
maximum        = 1200
step        = 1
 
[PRIMARY WEAPON ANTI-RECOIL VERTICAL SETTINGS]
group        = true
shortdesc    = Vertical compensation settings for primary weapon.
byteoffset    = 17
bitsize        = 32
control        = spinboxf
default        = 0000
minimum        = -10000
maximum        = 10000
step        = 1
decimals    = 2
 
[PRIMARY WEAPON ANTI-RECOIL HORIZONTAL SETTINGS]
group        = true
shortdesc    = Horizontal compensation settings for primary weapon.
byteoffset    = 21
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 1
decimals    = 2
 
[SECONDARY WEAPONS FIRING OPTIONS]
color       = #349510
collapsible = 2
shortdesc    = Enable options on fire trigger.
byteoffset    = 25
bitsize        = 8
control        = radiobox
default        = 0
item        = Disabled for automatics
item        = Enable rapid fire for semi-automatics.
item        = Enable burst firing for automatics.
item        = Enable burst firing for semi-automatics.
 
[SECONDARY WEAPON ROUNDS PER MINUTE]
group        = true
shortdesc    = Adjust rounds per minute.
byteoffset    = 29
bitsize        = 32
control        = spinbox
default        = 450
minimum        = 60
maximum        = 1200
step        = 1
 
[SECONDARY WEAPON SHOTS PER BURST]
group        = true
shortdesc    = Apply burst shots by quick tap of fire trigger or for burst firing.
byteoffset    = 37
bitsize        = 32
control        = spinbox
default        = 1
minimum        = 1
maximum        = 20
step        = 1
 
[SECONDARY WEAPON BURST FIRE]
group        = true
shortdesc    = Adjust release time for burst firing semi-automatics or automatics.
byteoffset    = 41
bitsize        = 32
control        = spinbox
default        = 160
minimum        = 1
maximum        = 1200
step        = 1
 
[SECONDARY WEAPON ANTI-RECOIL VERTICAL SETTINGS]
group        = true
shortdesc    = Vertical compensation settings for primary weapon.
byteoffset    = 45
bitsize        = 32
control        = spinboxf
default        = 0000
minimum        = -10000
maximum        = 10000
step        = 1
decimals    = 2
 
[SECONDARY WEAPON ANTI-RECOIL HORIZONTAL SETTINGS]
group        = true
shortdesc    = Horizontal compensation settings for primary weapon.
byteoffset    = 49
bitsize        = 32
control        = spinboxf
default        = 00000
minimum        = -10000
maximum        = 10000
step        = 1
decimals    = 2
 
[RUNNING OPTIONS]
color       = #349510
collapsible = 2
shortdesc    = ads long tap locks ads on and quick tap ads shuts off ads lock. also tapping jump button shuts off ads lock. more or less the jump button controls everything from shutting off lean, reloading, right bumper hold to coming out of crouch engaging sprint but if you double tap jump button it will auto throw for rappel shut off sprint so you can climb. also hold jump pass 500ms shut down sprint to climb too. when wanting to lean works with auto ads hold by holding ads and strafing for direction and long as you hold ads you change direction of lean and if you want lean locked in just release ads and switching lean just temporary hold ads for breif time of switching. tap jump button to break out of ads lock and lean. then sprinting is engaged unless reload has been tapped or crouch has been presses and fire trigger been engaged. this has double tap reload button for planting bomb or long press of right bumper for sheild lock with release of right bumper or control release tapping jump button.
control        = info
</cfgdesc>
***************************************************************************** */

 
#include <display.gph>
#define WEAPON_0   0
#define WEAPON_1   1
bool   lean_hold;
bool   fire_hold;
bool   crouch;
bool   reload_hold;
bool   RB_hold;
bool   toggle_rappel;
bool   toggle_plant;
uint8  primary_fire;
uint8  secondary_fire;
uint8  weapon = 0;
fix32  noise;
fix32  vertical;
fix32  horizontal;
fix32  vertical2;
fix32  horizontal2;
uint32 rpm;
uint32 rpm2;
uint32 burst;
uint32 burst2;
uint32 tap_fire;
uint32 tap_fire2;
uint32 burst_adjustment;
uint32 burst_adjustment2;
uint32    IND[] = {
    _0_,                  // 0
    _1_,                  // 1
    _2_,                  // 2
    _3_,                  // 3
    _P_,                  // 4
    _S_,                  // 5
    _A_                   // 6
};
init
{
    pmem_load();
    primary_fire = pmem_read(0);
    pmem_read(1, &rpm);
    pmem_read(9, &burst);
    pmem_read(13, &burst_adjustment);
    pmem_read(17, &vertical);
    pmem_read(21, &horizontal);
    secondary_fire = pmem_read(25);
    pmem_read(29, &rpm2);
    pmem_read(37, &burst2);
    pmem_read(41, &burst_adjustment2);
    pmem_read(45, &vertical2);
    pmem_read(49, &horizontal2);
 
    printf("primary_fire: %u", primary_fire);
    printf("rpm: %d", rpm);
    printf("burst: %d", burst);
    printf("burst_adjustment: %d", burst_adjustment);
    printf("vertical: %.04f", vertical);
    printf("horizontal: %.04f", horizontal);
    printf("secondary_fire: %u", secondary_fire);
    printf("rpm2: %d", rpm2);
    printf("burst2: %d", burst2);
    printf("burst_adjustment2: %d", burst_adjustment2);
    printf("vertical2: %.04f", vertical2);
    printf("horizontal2: %.04f", horizontal2);
 
    tap_fire = burst * (1000 / (rpm / 60));
    tap_fire2 = burst2 * (1000 / (rpm2 / 60));
    noise = 5.0;
 
    clamp(vertical, -100.00, 100.00);
    clamp(horizontal, -100.00, 100.00);
    clamp(vertical2, -100.00, 100.00);
    clamp(horizontal2, -100.00, 100.00);
}
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);
//--------------------------WEAPON-SWITCHING----------------------------------//
    if(event_release(BUTTON_14) && time_active(BUTTON_14) < 250) {
        if(weapon == WEAPON_0) set_weapon(WEAPON_1);
        else if(weapon == WEAPON_1) set_weapon(WEAPON_0);
    }
//--------------------------RESET-WEAPON-TRACK--------------------------------//
    if(!is_active(BUTTON_12) && !is_active(BUTTON_13) &&
    event_active(BUTTON_11) && time_release(BUTTON_11) < 250) {
        set_weapon(WEAPON_0);
    }
 
    switch(weapon) {
        case WEAPON_0: {
    /* Automatic weapons */
    if(primary_fire == 0) {
    if(get_actual(BUTTON_5)) {
        set_val(BUTTON_5, 100.0);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire) {
        tap_fire = burst * (1000 / (rpm / 60));
        set_val(BUTTON_5, 100.0);
        combo_run(anti_recoil);
    }
    }
    /* Semi- Automatic weapons */
    if(primary_fire == 1) {
    if(get_actual(BUTTON_5)) {
        turbo(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire) {
        turbo(BUTTON_5);
        combo_run(anti_recoil);
    }
    }
     /* Burst for Automatic weapons */
    if(primary_fire == 2) {
        set_val(BUTTON_5, 0.0);
    if(is_active(BUTTON_5)) {
        combo_run(burst_auto);
        turbo(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire) {
        turbo(BUTTON_5);
        combo_run(anti_recoil);
    }
    }
    /* Burst for Semi- Automatic weapons */
    if(primary_fire == 3) {
        set_val(BUTTON_5, 0.0);
    if(is_active(BUTTON_5)) {
        combo_run(burst_rapid);
        turbo(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire) {
        turbo(BUTTON_5);
        combo_run(anti_recoil);
    }
    }
    if(get_actual(BUTTON_5))combo_run(anti_recoil);
    if(is_active(STICK_1_Y))combo_stop(anti_recoil);
    if(is_active(STICK_1_X))combo_stop(anti_recoil);
    } break;
        case WEAPON_1: {
    /* Automatic weapons */
    if(secondary_fire == 0) {
    if(get_actual(BUTTON_5)) {
        set_val(BUTTON_5, 100.0);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire2) {
        tap_fire2 = burst2 * (1000 / (rpm2 / 60));
        set_val(BUTTON_5, 100.0);
        combo_run(anti_recoil2);
    }
    }
    /* Semi- Automatic weapons */
    if(secondary_fire == 1) {
    if(get_actual(BUTTON_5)) {
        turbos(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire2) {
        turbos(BUTTON_5);
        combo_run(anti_recoil2);
    }
    }
     /* Burst for Automatic weapons */
    if(secondary_fire == 2) {
        set_val(BUTTON_5, 0.0);
    if(is_active(BUTTON_5)) {
        combo_run(burst_auto2);
        turbos(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire2) {
        turbos(BUTTON_5);
        combo_run(anti_recoil2);
    }
    }
    /* Burst for Semi- Automatic weapons */
    if(secondary_fire == 3) {
        set_val(BUTTON_5, 0.0);
    if(is_active(BUTTON_5)) {
        combo_run(burst_rapid2);
        turbos(BUTTON_5);
    }else if(is_release(BUTTON_5) &&
     time_active(BUTTON_5) <= tap_fire2) {
        turbos(BUTTON_5);
        combo_run(anti_recoil2);
    }
    }
    if(get_actual(BUTTON_5))combo_run(anti_recoil2);
    if(is_active(STICK_1_Y))combo_stop(anti_recoil2);
    if(is_active(STICK_1_X))combo_stop(anti_recoil2);
    } break;
    }
    if(get_actual(BUTTON_5)){
        fire_hold = 1;
    }
    if(get_actual(BUTTON_8) && event_release(BUTTON_8) < 140) {
        lean_hold = 1;reload_hold = 0;RB_hold = 0;toggle_plant = 0;
    }
    if(get_actual(BUTTON_8) && time_active(BUTTON_8) < 100){
        lean_hold = 0;reload_hold = 1;
    }
    if(lean_hold == 1){
        set_val(BUTTON_8, 100.0);
    }
    if(lean_hold == 0){
        if(event_active(BUTTON_16)){
            reload_hold = 1;
        }
    }
    if(check_active(BUTTON_15, 20)){
        crouch = 1;
    }
    if(crouch == 1){
        if(event_active(BUTTON_16)){
            crouch = 0; lean_hold = 0;
        }
    }
    if(check_active(BUTTON_16, 5)){
        crouch = 0;lean_hold = 0;fire_hold = 0;
    }
    if(check_active(BUTTON_16, 500)){
        reload_hold = 1; lean_hold = 0;toggle_rappel = 0;
    }
    set_val(BUTTON_6, 0.0);
    if(lean_hold == 1 && get_actual(BUTTON_8) && get_actual(STICK_2_X) >= 7.0){
        combo_run(lean_right);
    }
    if(lean_hold == 1 && get_actual(BUTTON_8) && get_actual(STICK_2_X) <= -7.0){
        combo_run(lean_left);
    }
    if(fire_hold == 0 && lean_hold == 0 && reload_hold == 0 && crouch == 0 && toggle_rappel == 0 && get_actual(STICK_2_Y) <= -90.0){
        combo_run(easysprint);
    }
    if(event_active(BUTTON_17)){
        lean_hold = 0; reload_hold = 1;
    }
    if(reload_hold == 1){
        if(event_active(BUTTON_16)){
            lean_hold = 0; reload_hold = 0;crouch = 0;fire_hold = 0;toggle_plant = 0;
        }
    }
    if(event_active(BUTTON_4)){
        combo_run(RB_use);
    }
    if(check_active(BUTTON_4, 250)){
        RB_hold = 1;lean_hold = 0;
    }
    if(RB_hold == 1){
        set_val(BUTTON_4, 100.0);
    if(event_active(BUTTON_4) || event_active(BUTTON_6) || event_active(BUTTON_16)){
        RB_hold = 0;
        }
    }
    set_val(BUTTON_6, 0.0);
    if(check_active(BUTTON_6, 130)){
        lean_hold = 0; RB_hold = 0;
        combo_run(melee);
    }
    if(event_active(BUTTON_16)&&time_release(BUTTON_16)< 200){
        toggle_rappel = 1;
        reload_hold = 1;
    }else if(time_active(BUTTON_16) > 2000){
        toggle_rappel = 0;
    }
    if(toggle_rappel == 1){ set_val(BUTTON_16, 100.0);}
 
    if(event_active(BUTTON_17)&&time_release(BUTTON_17)< 200){
        toggle_plant = 1;
        reload_hold = 1;
    }else if(time_active(BUTTON_17) > 6000){
        toggle_plant = 0;
    }
    if(toggle_plant == 1){ set_val(BUTTON_17, 100.0);}
}
 
combo burst_auto
{
    turbo(BUTTON_5);
    set_val(BUTTON_5, 100.0);
    wait(tap_fire);
    set_val(BUTTON_5, 0.0);
    wait(burst_adjustment);
}
 
combo burst_rapid
{
    turbo(BUTTON_5);
    wait(tap_fire);
    set_val(BUTTON_5, 0.0);
    wait(burst_adjustment);
}
 
combo burst_auto2
{
    turbos(BUTTON_5);
    set_val(BUTTON_5, 100.0);
    wait(tap_fire2);
    set_val(BUTTON_5, 0.0);
    wait(burst_adjustment2);
}
 
combo burst_rapid2
{
    turbos(BUTTON_5);
    wait(tap_fire2);
    set_val(BUTTON_5, 0.0);
    wait(burst_adjustment2);
}
 
combo anti_recoil
{
    set_val(STICK_1_Y, vertical);
    set_val(STICK_1_X, horizontal);
}
 
combo anti_recoil2
{
    set_val(STICK_1_Y, vertical2);
    set_val(STICK_1_X, horizontal2);
}
 
combo lean_right
{
    set_val(BUTTON_16, 0.0);
    set_val(BUTTON_6, 100.0);
    wait(200);
}
combo lean_left
{
    set_val(BUTTON_16, 0.0);
    set_val(BUTTON_9, 100.0);
    wait(200);
}
combo easysprint
{
    set_val(BUTTON_9,100.0);
    wait(60);
    set_val(BUTTON_9,0.0);
    wait(60);
    set_val(BUTTON_9,0.0);
}
combo melee
{
    set_val(BUTTON_6, 100.0);
    wait(40);
    set_val(BUTTON_6, 0.0);
    wait(40);
    set_val(BUTTON_6, 0.0);
}
combo RB_use
{
    lean_hold = 0;
    set_val(BUTTON_8, 0.0);
    set_val(BUTTON_4, 0.0);
    wait(80);
    set_val(BUTTON_4, 100.0);
    wait(200);
}
 
void turbo(uint8 button)
{
    uint32 sps = rpm/ 60;
    uint32 rate = 1000 / sps;
    uint32 hold = rate / 2;
 
    uint32 ta = time_active(button);
    set_val(button, 100.0);
 
   while(ta > rate) {
        ta -= rate;
    }
    tap_fire = burst * (1000 / (rpm / 60));
 
    if(ta > hold) {
        set_val(button, 0.0);
    }
}
 
void turbos(uint8 button)
{
    uint32 sps2 = rpm2/ 60;
    uint32 rate2 = 1000 / sps2;
    uint32 hold2 = rate2 / 2;
 
    uint32 ta2 = time_active(button);
    set_val(button, 100.0);
 
   while(ta2 > rate2) {
        ta2 -= rate2;
    }
    tap_fire2 = burst2 * (1000 / (rpm2 / 60));
 
    if(ta2 > hold2) {
        set_val(button, 0.0);
    }
}
 
void set_weapon(uint8 new_weapon)
{
    static uint8 old_weapon;
 
    if(new_weapon == old_weapon) return;
    old_weapon = new_weapon;
    weapon = new_weapon;
 
    static uint32 timestamp;
    uint32 elapsed = system_time() - timestamp;
 
    if(!elapsed || elapsed >= 10) {
    // Set LED
    switch(weapon) {
        case WEAPON_0: { // BLUE LED
            led_set(LED_1, 100.0, 0);
            led_set(LED_2, 0.0, 0);
            led_set(LED_3, 0.0, 0);
            led_set(LED_4, 0.0, 0);
            display (4);
        } break;
        case WEAPON_1: { // RED LED
            led_set(LED_1, 0.0, 0);
            led_set(LED_2, 100.0, 0);
            led_set(LED_3, 0.0, 0);
            led_set(LED_4, 0.0, 0);
            display (5);
        } break;
    }
    timestamp = system_time();
    }
    return;
}
 
 // Display Numbers
void display (uint8 indc)
{
    uint8 VIE;
    VIE = IND[indc];
    display_overlay(VIE, 2000 );
}
 
 
 

Here to see if you have problems. Now if you run out of bullets and you strafe to the right at that time for lean the gun goes into reload then that is when your open to knife. Give it a good test! This goes into slot and use interactive configurations.
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby TheSaint » Sat Aug 18, 2018 4:38 pm

Thank you bonefisaher for your quick post of updated script. I have tested a bit yesterday and when it works, it is great! The issue is getting it to work seems a challange to me. I am not sure if anyone else testing updated script with different results
Findings:
- The Melee attacjk still happens but I noticed if you crouch and ADS that fixes the melee issue.
- Leaning. I am only able to lean to the left but not right. I have tried several in different stages with same result, lean only on direction.
- Auto firing. As soon as I fire, the firing mode goes into auto fire and does not stop and reloads and continuous firing by itself. I have to change to different memory slot and switch back to get it to stop.

The Good:
- The added pre configuration for certain operators was a great touch! Certainly saved time doing it manually.
- I managed to get it to work once before running our of bullets due to auto firing, and it worked really well.

I am not sure how it is supposed to work exactly .. Who is doing the firing? The player or script?
Your ifrst script with one time straf worked beautifully without issues. Only thing it needed:
- A way to over ride it (press jump twice to pause, press jump twice to reactive it it.
- Go longer than one time (maybe 2 times and resets when firing stops (unless overridden by jump twice click. (most fire fights will not last longer than that).

I am not scripting guru but these are general ideas on maybe how to simplify script.

Thank you for the hard work!
User avatar
TheSaint
Command Sergeant Major
Command Sergeant Major
 
Posts: 148
Joined: Sun Jun 24, 2018 1:43 pm

Re: SIMPLE anti recoil script for Rainbow Six

Postby bonefisher » Sun Aug 19, 2018 12:29 am

Have you updated your titan 2 because I don't ever get this auto firing do you have a setting flipped trigger or something because right bumper does have a hold on it for the shield then a tap release for it or tap jump button. check to see in game you have it on different setting please because that would explain it auto firing and you not leaning to right if on different game setting other than default... I get everything working for me perfect...
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: SIMPLE anti recoil script for Rainbow Six

Postby lgbm » Sat Sep 01, 2018 4:30 am

J2Kbr wrote:Here is the code:
Code: Select all
#pragma METAINFO("antithesis Antirecoil", 1, 02, "antithesis")
 
fix32 RECOIL_V = 30.0;
fix32 RECOIL_H = 0.0;
fix32 RY;
fix32 RX;
 
fix32 StickNoise = 4.32;
 
main {
 
if (get_val (BUTTON_5)) // only active when firing to allow for microaim adjustments without the input being filtered
{   
// DEADZONE REMOVER
    if(abs(get_actual(STICK_1_X)) < StickNoise) { set_val(STICK_1_X, 0.0); }
    if(abs(get_actual(STICK_1_Y)) < StickNoise) { set_val(STICK_1_Y, 0.0); }
    if(abs(get_actual(STICK_2_X)) < StickNoise) { set_val(STICK_2_X, 0.0); }
    if(abs(get_actual(STICK_2_Y)) < StickNoise) { set_val(STICK_2_Y, 0.0); }
 
}
// ANTI-RECOIL
    if (get_val (BUTTON_5)) //antirecoil only active when firing
    {   
        AntiRecoil(STICK_1_Y,RECOIL_V);
        AntiRecoil(STICK_1_X,RECOIL_H);
    }
 
}
 
void AntiRecoil (uint8 axis, fix32 recoil)
{
 
     RY = get_actual(STICK_1_Y);
     RX = get_actual(STICK_1_X);
 
    if (get_val(BUTTON_5) && (sqrt(RX*RX + RY*RY)) <= abs(recoil))
    {
        if(abs(RY) <= abs(recoil))
        {
            set_val(axis,(recoil * (100.0 - abs(get_val(axis)))) / 100.0 + get_val(axis));
        }
    }
}
 

Our focus is on this line:
Code: Select all
fix32 RECOIL_V = 30.0;

First test in game, if the aim still goes up while firing increase this value, if the aim goes down, decrease. Keep making small adjustments until the value is perfect to keep the aim steady.


Hello everyone!

why do you use get_actual instead of get_val ?
does get_actual function have similar to titan one?

Thanks!
Owned Scripts:
- TheDivision
- COD WW2

XB1 - BR
User avatar
lgbm
Private First Class
Private First Class
 
Posts: 2
Joined: Thu Aug 02, 2018 10:33 pm

Re: SIMPLE anti recoil script for Rainbow Six

Postby J2Kbr » Sun Sep 02, 2018 1:15 pm

get_val() returns the value that will be send to the console, which can be from the controller or set by the script. While get_actual() always returns the value from the controller.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 207 guests

cron