PUBG - PlayerUnknown's Battlegrounds - Script v2

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby TheSaint » Fri Feb 05, 2021 8:59 am

N53IDO wrote:People need to understand some core principles about PUBG and anti recoil mods. I'll do my best to explain them, and its based on my 3 years of playing this game.


1. Firstly, when setting up the script, your grip matters. For example if you set an M4 using a vertical grip, if ingame you use a thumbgrip you're going to have alot more recoil then when you zeroed the script using a vertical grip. Same goes the other way around - if you zero the script using an angled grip and you have a vertical grip ingame, your recoil will shoot down.

2. Your muzzle attatchments also matter. If you have a compensator/vert grip to zero the script but ingame you have a vert grip/suppressor, you'll notice the recoil shoots up.

3. Don't change your settings ingame if you zero the script. Even if you raise your ingame deadzones by 1, you need to then redo the anti recoil on the script completely. Same goes for sensitivities.

4. I can't stress how useless red dots are in this game with Anti Recoil Scripts. Bear with me. On pubg your character sway when aiming is HUGE compared to other games. So, lets take a half grip for example. If you zero a ANY script with a half grip/red dot and get it into lazer mode while pressing lb to zoom it in, when not pressing LB and zooming you'll see how inconsistent the anti recoil is. Sometimes your gun will shoot up, sometimes it will shoot down, sometimes it lazers. This isnt the script, its PUBG's aiming mechanics. Sometimes your characters breathing will be on the downstroke, so when you shoot and the Anti recoil kicks in it'll go down alot more than other times. Sometimes he'll be on the upbreathe, causing your anti recoil to shoot up. If you use red dots and use AR scripts, use a thumb grip as its the grip that negates character sway the most.

5. The Minimum Percentage Anti Recoil mechanic that scachi has built into this script is the most useful thing i have ever encountered in a script across ALL devices i have owned. Zero your script, and set the minimum percent to 13. Notice how when you move your aim your AR no longer works? Now set it to 100, notice how everything is just far too senstive? Its about finding a good balance for your thumbs. I recommend setting it to 45% and go from there; personally i use 55.


Excellent tips! Thank you!

Can you share details on how you Zero your script? I got it fairly close but nowhere near Zero.
User avatar
TheSaint
Command Sergeant Major
Command Sergeant Major
 
Posts: 148
Joined: Sun Jun 24, 2018 1:43 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby luccamelo » Sat Feb 06, 2021 3:05 am

Buenas noches, acabo de llegar al foro y primero agradecer este script por me parece una maravilla, llevo un día investigado para hacerlo funcionar a la perfección y casi lo domino. Me gustaría preguntar si alguno usa xim apex con el titan y si usa alguna configuración predeterminada para que vaya mucho mejor su funcionamiento, yo uso la mía que venía usando y estoy muy contento ,pero aún así quisiera saber más y ver que puedo mejorar.
Esta pregunta va para el genio creador del script, hecho en falta para las armas secundarias perfiles de DMR ( SKS, SLR) con un buen anti recoil, se puede utilizar tan y como esta el script pero seguro que ustedes es capaz de hacer magia con esos DMR. Gracias y enhorabuena por su trabajo.
User avatar
luccamelo
Sergeant
Sergeant
 
Posts: 6
Joined: Fri Jan 29, 2021 5:16 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby luccamelo » Sat Feb 06, 2021 5:39 pm

por algún motivo algunas armas , sobre todo he visto que me pasa con el Ak , pierdo cadencia de disparo alguien sabe cual es el motivo?
User avatar
luccamelo
Sergeant
Sergeant
 
Posts: 6
Joined: Fri Jan 29, 2021 5:16 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby Scachi » Sat Feb 06, 2021 8:04 pm

Please try in English.. I had to use google translator to get an idea what you are asking.
Automatic weapon may slow down when you have rapid fire active.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby luccamelo » Sat Feb 06, 2021 9:51 pm

Hi,good evening,im a new in The fórum and with titán.First i want to say thanks for The script,is my first day and it’s amazing!!! I want to know if someone use titán with XIM APEX and if there is Antea script to make it work perfectly!!i,ve got a cuestión for the scripts creator ,i need a script for secundary weapons like slr or sks,with a good anti-recoi!, and one more question !why the point score pull exaggeratedly down the objective, is that right? Is it possible to correct the problem or am I doing something wrong?thanks for everything
User avatar
luccamelo
Sergeant
Sergeant
 
Posts: 6
Joined: Fri Jan 29, 2021 5:16 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby Beryl » Mon May 31, 2021 12:48 pm

Im having trouble slowing the rof of fire down and timing the recoil on the dmrs has anyone come across a happy medium to fire 4 to 5 times per second whilst having the recoil hold the recoil on target? thanks in advance
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby N53IDO » Tue Jun 29, 2021 1:08 pm

Scachi, i was wondering if you could help/offer any advice on a problem i've been having.

I've recently purchased a scuf controller and when i use anti recoil with the Scuf, theres a sweet spot where the controller recognises that LT and RT are being held down, however on PUBG there must be some sort of hidden deadzone as the gun doesn't shoot nor aim. This results in my gun going down as it should with the anti recoil without shooting - this only happens for a few milliseconds however its really off putting and sometimes i end up aiming at peoples legs before my gun has shot a bullet. I've looked in device monitoring and it happens when my LT and RT are below 20% pressure - and for some context this DOESNT happen on my elite controller - with the trigger stops on my elite controller the values go to 100% when the triggers are pressed.

I know its nothing to do with your script, however i only play PUBG thats why im asking ahaha. I don't know if the solution is if i manually add a hair trigger line like:
main {
if (get_val(BUTTON_5)) set_val(BUTTON_5,100);
}

would that solve the issue?

EDIT:
It solved the issue manually adding hair triggers, can finally actually have a go with my scuf now.
User avatar
N53IDO
Corporal
Corporal
 
Posts: 5
Joined: Tue May 12, 2020 2:28 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby Tahsin » Tue Aug 03, 2021 8:44 am

How to add 5 more slots to the scripte ?
The rapidefire does not work
Thank you

Edit:
I did some fixes to this script
1- Weapon slot do not change anymore when looting or when in inventory or map .
2- Speech disabled when in inventory (I 'm using same headset on PC and PS5 ) so to make sure i have selected the exact weapon.
3- Weapon slot do not change anymore when selecting grenade .
4- added Speech weapons name on selected slot.
5- OTS slot works great when using 3x scoop you need to holdbreath when shooting
:joia:
User avatar
Tahsin
Sergeant Major
Sergeant Major
 
Posts: 100
Joined: Wed May 15, 2019 7:57 am

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby PUBG_Player » Tue Aug 24, 2021 1:19 pm

Are you trying to add 5 more slots to the script or an additional 5 slots to your Titan2 to give you 10 total?

Also, is your script available anywhere? I would love to not worry about weapon slot swapping while in the inventory screen!
User avatar
PUBG_Player
Corporal
Corporal
 
Posts: 5
Joined: Tue Sep 01, 2020 3:39 pm

Re: PUBG - PlayerUnknown's Battlegrounds - Script v2

Postby Tahsin » Tue Aug 24, 2021 6:40 pm

PUBG_Player wrote:Are you trying to add 5 more slots to the script or an additional 5 slots to your Titan2 to give you 10 total?

Also, is your script available anywhere? I would love to not worry about weapon slot swapping while in the inventory screen!

Hi PUBG_Player
more slots needs more Byteoffsets so unfortunatly that's not possible
but you can add a copy to T2 solts
1 -i've added keypad two button slot change to change between T2 slots so you can add 5 more weapon slots or so to
T2 memory and switch between easily. Press Keypad HYPHEN - PLUS to change slots
2 - added dobble tap Square button to fix weapon slot if it is out of sync it while happen rarly .
3 - Added L1+R2 recoil for Hip
4 - Modified (MinARecoilPercent) to work more presise for red dote X2 scoops you can change values in scripe file to fit your
settings.
5- Removed (Sticknoise remove ) it cause drifting when using mouse .
6- to change slots is no longer L2 button i've replaced by Square button so if you want to change to slot number
hold Square+[Touch-Click|View]+DPAD-Up, DPAD-Right, DPAD-Down, DPAD-Left, Triangle|Y
but if you have keypad it while be easyer to do that
so the minimum recoil percent in CFg do nothing if you change it only change it in the file script
This script was modified to TybeB player
6- keypad slash for change stance mode
Here you go
Code: Select all
 
#pragma METAINFO("PUBG_V2_Modified", 1, 02, "Owner scachi, Modified by Tahsin")
#include "PUBG_v2_or.gph"
#include "PUBG_v2_ic.gph"
bool bUseLEDWeapon;
bool bModOn;
#include "ColorLED.gph"
#define DWRITE_DI
#define DWRITE_DF
#include "DWrite.gph"
#include <keyboard.gph>
#include <display.gph>
 
/** ToDo:
*/

/* Changes:
    v.102: rapid fire enabled/disabled state is now handled by weapon configuration only
    v.101: added more weapon presets for full sensitivity, for each #configuration nr
    v.100: weapon slot fix doesn't switch weapon anymore, only switches color/configuration
           script reload button combination L3+PS / LS+XBOX
    v.096: throw mode and anti recoil toggle fix
    v.095: interactive configuration description additions/fixes only
    v.094: autoholdbreath optimization, OTS mode fix
    v0.93: change weapon slot switch to L2+Touchclick+Dpad to not block in-game toggles anymore
    v0.92: lowered cpu usage again
    v0.91: rapid fire is now working
    v0.90: lowered cpu usage when using keyboard/mouse/keypad for toggles
    v0.05: directKM.gph: added mousemapping for softaim
    v0.04: tracking of inventory added
    v0.03: added anti recoil button combination, weapon tracking modes, stacne tracking/inventory tracking with circle button override with L2/LT
    v0.02: directKM support
    //Modification made on this script by tahsin
    1 -i've added keypad two button slot change to change between T2 slots so you can add  5 more weapon slots  or so to
     T2 memory and switch between easily.
    2 - added dobble tap Square button to fix weapon slot if it is out of sync it while happen rarly .
    3 - Added L1+R2 recoil for Hip
    4 - Modified (MinARecoilPercent) to work more presise for red dote X2 scoops you can change values in scripe file to fit your
    settings.
    5- Removed (Sticknoise remove ) it cause drifting when using mouse .
    6- to change slots is no longer L2 button i've replaced by Square button so if you want to change to slot number
    hold Square+[Touch-Click|View]+DPAD-Up, DPAD-Right, DPAD-Down, DPAD-Left, Triangle|Y
    but if you have keypad it while be easyer to do that
    so the minimum recoil percent in CFg do nothing if you change it only change it in the file script
*/

 
/*^* Presets notes:
#1 AKM ADS & HIP Standing & CROUCH & PRONE  , MISSING: OTS
GIVICFG:0301000258780D000500000104010400000000000000000000000000000000000096012C01F427000000012C05140000012C05140000012C05140000012C05140000012C05142A2A2E10101010101010101010101000A300EB00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC00CC000104
*/

 
/********************************************************************************
 ** CUSTOMIZEABLE SECTION START
 *******************************************************************************
 **/

 
// autohold breath delay (delay after movement was detected) when ADS was already active
#define AUTOHOLDBREATH_STICK_DELAY    50
 
/////////////////////////////////////////////////////////////////////////////////
//  Supporting multiple input translators via directKM.gph file
/////////////////////////////////////////////////////////////////////////////////
//#include "directKM.gph" /* remove leading "//" of this line to use */
/*    
    this will only work WITHOUT an input translator in the scripts slot !
    as the input translator stuff is handled completely by code then
*/

 
/////////////////////////////////////////////////////////////////////////////////
// switch weapon configuration by button combination
/////////////////////////////////////////////////////////////////////////////////
uint8 btnHold1 = BUTTON_17; // <-- set to FALSE to disable
uint8 btnHold2 = BUTTON_2; // <--/
uint8 btnSlot[5] = {BUTTON_10, BUTTON_13, BUTTON_11, BUTTON_12, BUTTON_14};
 
/////////////////////////////////////////////////////////////////////////////////
// switch active weapon slot (weapon tracking) by controller
/////////////////////////////////////////////////////////////////////////////////
uint8 btnWeaponSlotHold = BUTTON_9; // <- set to FALSE to disable
uint8 btnWeaponSlotTap = BUTTON_14;
 
/////////////////////////////////////////////////////////////////////////////////
// script reload
/////////////////////////////////////////////////////////////////////////////////
uint8 btnScriptHold = BUTTON_9; // <- set to FALSE to disable
uint8 btnScriptTap = BUTTON_1;
 
 
/////////////////////////////////////////////////////////////////////////////////
// switch weapon configuration by keyboard
/////////////////////////////////////////////////////////////////////////////////
uint8 keyScript[] = { KEY_PAD0, KEY_PADPERIOD, KEY_PADENTER};
uint8 keySlot[] = {KEY_PAD1, KEY_PAD2, KEY_PAD3, KEY_PAD4, KEY_PAD5};
uint8 keySlotStat[sizeof(keySlot)];
uint8 keyScriptStat[5];
 
/////////////////////////////////////////////////////////////////////////////////
// switch active weapon slot (weapon tracking) by keyboard
/////////////////////////////////////////////////////////////////////////////////
uint8 keyWeaponSlot[] = { KEY_PAD7, KEY_PAD8, KEY_PAD9 };
 
/////////////////////////////////////////////////////////////////////////////////
// switch stance by keyboard
/////////////////////////////////////////////////////////////////////////////////
//uint8 keyStance = KEY_PADHYPHEN;
uint8 keyStance = KEY_PADSLASH;
uint8 keyPlus = KEY_PADPLUS;
uint8 keyMinus = KEY_PADHYPHEN;
uint32 keyStanceTime;
 
/////////////////////////////////////////////////////////////////////////////////
//  Controller/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
 
 
/**
 *******************************************************************************
 ** CUSTOMIZEABLE SECTION END
 *******************************************************************************/

 
bool key_ready;
uint8 check_slot;
 
bool bUseAutoSprint;
bool bUseDuckJump;
bool bUseT2SegStance;
bool bUseT2SegWeapon;
uint8 T2SegStateStance;
uint8 T2SegStateWeapon;
uint32 T2SegTimer;
bool bUseSpeech;
bool bUseSpeechActiveWeapon;
char *speech[] = {
    "SPEECH:Script ON Red dote ", // change red dote to X2 if you want make second slot for X2 in T2
    "SPEECH:Script OFF",
    "SPEECH:Rapid ON",
    "SPEECH:Rapid OFF",
    "SPEECH:Recoil ON",
    "SPEECH:Recoil OFF",
    };
char *speechWeapon[] = {
    "SPEECH:Prime",
    "SPEECH:Second",
    "SPEECH:Side", // this while be for grenade and sid arme
};
 
uint8 WeaponActive = 0;
uint8 WeaponLast = 0;
uint8 WeaponHolstered = 0;
uint8 WeaponSlotCfg[2]; // primary, secondary, sidearm : assigned configurations
uint8 WeaponSlotRapid[3];
uint8 WeaponSlotRecoil[3];
uint8 WeaponSlotColor[] = {CG,CR,CP};
uint8 WeaponTracking;
 
 // Anti Recoil
bool  ARSlotLoadRFActivate[5];
uint8 ARSlotColor[5] = {CG,CR,CP,CB,CA};
uint8 *ARSlotText[5] = {"a","b","c","d","e"};
uint8 ARSlotActive = 0;
int16 ARecoilDelay[15];
int8 ARecoil_V[15];
fix32 ARecoilMod[20]; // HIP,DUCK,PRONE,OTS (a,b,c,d,e)
fix32 MinARecoilPercent = 13.0;
// Anti Recoil Autostop
uint8  AutoStopRumbleID = FFB_2; // which rumble motor to monitor
uint16 AutoStopRumbleTLimit;     // autostop antirecoil rumble timeout
uint16 AutoStopFireTMin;          // autostop antirecoil fire button minimum press test before checking for rumble
uint32 AutoStopLastRumble=0;
 
//Rapid Fire
// Anti Recoil Rapid Fire modes:
uint8 ARecoilRF_Mode[5];
#define ARRF_DISABLED     0 // no anti recoil
#define ARRF_BTN_FIRE    1 // on fire button fire time, applied during fire only
#define ARRF_BTN_WAIT    2 // on fire button wait time, applied during wait only
//
uint32 tRapidFiring; // track the time the rapid fire is currently shooting
uint32 tRapidHolding; // track the time the rapid fire is currently on wait
bool RFTapNHold;
uint8 RapidFireMode;
uint16 RapidHold[5];
uint16 RapidRelease[5];
uint8 RapidHold8; // for loading values
uint8 RapidRelease8; // for loading values
/////////////////////////////////////////////////////////////////////////////////
//  Rapid Fire modes:
/////////////////////////////////////////////////////////////////////////////////
#define RF_CHECKBOX         0
#define RF_TAP_TAPHOLD      1
 
// Dead Zone
fix32 StickNoise;
 
// 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_OTS  3 //[Touch-Click|View] + DPAD RIGHT OTS    (Over The Shoulder)
//Stance Tracking
bool bTrackCrouch=TRUE;
bool bTrackProne=TRUE;
bool bTrackOTS=TRUE;
 
int16 ProneHoldTime = 195; //it is around 180 but fluctuates so 195 to be safe
int CharacterStateCurrent = STATE_STANDING;
int CharacterStatePrevious = STATE_STANDING;
//Grenade/Throwing stuff
bool bThrow;
bool bOTS;
bool bHIP;
bool bInventory;
 
// controller layout type
uint8 cType;
bool  cType_A_ADS = FALSE; // TRUE when ADS is active with controller layout A
#define CTYPE_A 0
#define CTYPE_B 1
#define CTYPE_A_ADS_TAPTIME 170
 
//Auto Hold Breath, works with controller layout Type-B only
uint8 autoholdbreathDelay;
uint8 AutoHoldBreathType;
#define AHB_OFF        0
#define AHB_FULL    1
#define AHB_NOTFULL    2
#define AHB_LEVEL    3
bool bUseAutoHoldBreath=FALSE;
 
// Duck Jump
uint8 DuckJumpTapLimit;
uint16 DuckJumpWaitDuck;
uint16 DuckJumpWaitLoop;
 
// holster and run on long BTN_CHANGE_WEAPON hold
uint8 HolsterNRunMode;
uint16 HolsterNRunHoldTime = 600;
uint8 HolsterNRunTapTime = 150;
bool bHolsterNRun; // internal usage flag
bool bHolsterTapNHold; // internal usage flag
 
// multi tap monitoring
uint8 tap_time = 150;
uint8 taps;
 
uint8 i;
 
bool bScriptReload = TRUE;
 
// extract specific bits from a byte
// k: byte
// m: start offset from the right (inclusive)
// n: stop offset from the right (exclusive)
//  example to extrat bits2+3: MID(byte,2,4)
#define LAST(k,n) ((k) & ((1<<(n))-1))
#define MID(k,m,n) LAST((k)>>(m),((n)-(m)))
 
init
{
    pmem_load();
    bModOn             = (pmem_read(0) >> 0) & 0b1;
    bUseSpeech        = (pmem_read(0) >> 1) & 0b1;
    bUseAutoSprint     = (pmem_read(0) >> 2) & 0b1;
    bUseDuckJump     = (pmem_read(0) >> 3) & 0b1;
    bUseT2SegStance = (pmem_read(0) >> 4) & 0b1;
    bUseT2SegWeapon = (pmem_read(0) >> 5) & 0b1;
    bUseLEDWeapon    = (pmem_read(0) >> 6) & 0b1;
    bUseSpeechActiveWeapon = (pmem_read(0) >> 7) & 0b1;
 
    // controller layout type
    pmem_read(1,  &cType);
 
    WeaponSlotRecoil[0] = (pmem_read(38) >> 0) & 0b1;
    WeaponSlotRecoil[1] = (pmem_read(38) >> 1) & 0b1;
    WeaponSlotRecoil[2] = (pmem_read(38) >> 2) & 0b1;
 
    WeaponTracking = (pmem_read(39) >> 6);
    //printf("weapontracking: %d",WeaponTracking);
 
    // flag for rapid fire to enabled for weapon slot that manualy loads this config
    ARSlotLoadRFActivate[0] = (pmem_read(39) >> 0) & 0b1;
    ARSlotLoadRFActivate[1] = (pmem_read(39) >> 1) & 0b1;
    ARSlotLoadRFActivate[2] = (pmem_read(39) >> 2) & 0b1;
    ARSlotLoadRFActivate[3] = (pmem_read(39) >> 3) & 0b1;
    ARSlotLoadRFActivate[4] = (pmem_read(39) >> 4) & 0b1;
    //printf("rapid: %d %d %d %d %d",ARSlotLoadRFActivate[0],ARSlotLoadRFActivate[1],ARSlotLoadRFActivate[2],ARSlotLoadRFActivate[3],ARSlotLoadRFActivate[4]);
 
    MinARecoilPercent = pmem_read_int16tofix32(6);
    StickNoise = pmem_read_int16tofix32(8);
 
    pmem_read(15,&RapidFireMode);
    pmem_read(16,&tap_time); // tap time limit for multi tap function (rapid fire tap, tap&hold)
 
    // autostop anti recoil & rapid fire
    pmem_read(10,&AutoStopRumbleID);
    pmem_read(11,&AutoStopRumbleTLimit);
    pmem_read(13,&AutoStopFireTMin);
    //
    pmem_read(125,&WeaponSlotCfg[0]);
    pmem_read(126,&WeaponSlotCfg[1]);
    pmem_read(127,&WeaponSlotCfg[2]);
    WeaponSlotRapid[0] = ARSlotLoadRFActivate[WeaponSlotCfg[0]];
    WeaponSlotRapid[1] = ARSlotLoadRFActivate[WeaponSlotCfg[1]];
    WeaponSlotRapid[2] = ARSlotLoadRFActivate[WeaponSlotCfg[2]];
 
    // byteoffset is shared: holsternrun and autoholdbreath
    uint8 byte;
    pmem_read(2,&byte); //printf("byte:%d", byte);
    HolsterNRunMode=MID(byte,0,2);
    //printf("holsternrun    off0: %d", HolsterNRunMode);
    AutoHoldBreathType=MID(byte,2,4);
    //printf("autoholdbreath off2: %d", AutoHoldBreathType);
 
    // hold breath delay
    pmem_read(32,&autoholdbreathDelay);
 
    // duck jump   
    pmem_read(33,&DuckJumpTapLimit);
    pmem_read(34,&DuckJumpWaitDuck);
    pmem_read(36,&DuckJumpWaitLoop);
 
    // holster n run
    HolsterNRunMode = (HolsterNRunMode);
    //printf("HolsterNRunMode: %d",HolsterNRunMode);
    pmem_read(3,&HolsterNRunHoldTime);
    pmem_read(5,&HolsterNRunTapTime);
 
    //Weapon slot configurations
    //printf("size: %d",sizeof(ARecoilDelay)/2);
    uint8 offValue;
    for (i=0;i<sizeof(ARecoilDelay)/2;i++) {
        // 40,42,..,68
        uint8 offDelay = 40+i*2;
        offValue = 70+i;
        pmem_read(offDelay,&ARecoilDelay[i]);
        //printf("(offset %d) ARecoilDelay: %d", offDelay, ARecoilDelay[i]);
        pmem_read(offValue,&ARecoil_V[i]);
        //printf("(offset %d) ARecoil_V: %d", offValue, ARecoil_V[i]);       
    }
    //printf("size: %d",sizeof(ARecoilMod)/4);
    for (i=0;i<sizeof(ARecoilMod)/4;i++) {
        // mod: 70,71,..,
        offValue = 85+i*2;
        ARecoilMod[i] = pmem_read_int16tofix32(offValue);
        //printf("(offset %d) %d ARecoilMod: %.02f", offValue, i, ARecoilMod[i]);
    }
    for (i=0;i<sizeof(RapidHold)/2;i++) {
        // rapid fire timings
        pmem_read(22+i*2,&RapidHold8);
        pmem_read(23+i*2,&RapidRelease8);
        RapidHold[i]=RapidHold8*10;
        RapidRelease[i]=RapidRelease8*10;
        //printf("load: %d : %d, val: %d/%d",i,22+i*2,RapidHold[i],RapidRelease[i]);
 
        // rapid fire anti recoil mode
        pmem_read(17+i,&ARecoilRF_Mode[i]);
    }
    blink(bModOn,0);
}
uint32 GNDTimer;
//bool    bLoop=FALSE;
main
{
      //Change T2 slots
      if(key_status(KEY_PADPLUS)) {
        if(key_ready) {
            check_slot = mslot_get() + 1;
            for(;;) {
                if(check_slot > 9) check_slot = 1;
                if(check_slot == mslot_get()) break;
                if(mslot_check(check_slot)) mslot_load(check_slot);
                ++check_slot;
            }
        }
    } else if(key_status(KEY_PADHYPHEN)) {
        if(key_ready) {
            check_slot = mslot_get() - 1;
            for(;;) {
                if(check_slot < 1) check_slot = 9;
                if(check_slot == mslot_get()) break;
                if(mslot_check(check_slot)) mslot_load(check_slot);
                --check_slot;
            }
        }
    } else key_ready = 1;
 
    /*///auto strafe
     if (get_actual(BUTTON_8)){
       if ( event_active(BUTTON_7) && time_release(BUTTON_7) <250 ) {
       combo_run(AutoStrafe);
     }
     }else {
           combo_stop(AutoStrafe);
     }
 
    ///*/

    combo_run(ckeyToggles);
    T2SegTimer += elapsed_time();
    // hold L2 +
    // Press Touch-Click + CROSS to quickly enable/disable the script
    //////////original
    if (get_actual(BUTTON_17)) {
        if (get_actual(BUTTON_2)) { set_val(BUTTON_2, 0.0); set_val(BUTTON_15, 0.0); set_val(BUTTON_16, 0.0); set_val(BUTTON_5, 0.0); set_val(BUTTON_6, 0.0);}
        if (get_actual(BUTTON_2) && event_active(BUTTON_16)) bToggle(&bModOn,0); // script on/off
        if (get_actual(BUTTON_2) && event_active(BUTTON_5)) bToggle(&WeaponSlotRapid[WeaponActive],2); // rapid fire of current slot
        if (get_actual(BUTTON_2) && event_active(BUTTON_6)) bToggle(&WeaponSlotRecoil[WeaponActive],4); // anti recoil of current slot
    }
    /////////original end
    ///////
 
 
    ///////
    if (bScriptReload) {
        if (!get_actual(btnScriptHold)) bScriptReload=FALSE;
    } else {
        if (get_actual(btnScriptHold)) {
            set_val(btnScriptTap,0);
            if (event_release(btnScriptTap)) mslot_load(mslot_get());
        }
    }
 
    if (bModOn)
    {
        // Button slot change
        if (btnHold1 && btnHold2) {
            if (get_actual(btnHold1)) {
                set_val(btnHold2,0);
                if (get_actual(btnHold2)) {
                    for (i=0;i<5;i++) {
                        if (btnSlot[i]) {
                            set_val(btnSlot[i], 0);
                            if (event_active(btnSlot[i])) ARSlotChange(i);
                        }
                    }
                }
            }
        }
 
        // Active Weapon Slot fix
        if (WeaponTracking==1) {
            if (btnWeaponSlotHold) {
                if (get_actual(btnWeaponSlotHold)) {
                   // if (btnWeaponSlotTap) {
                    if (btnWeaponSlotTap && !bInventory) {
                        set_val(btnWeaponSlotTap,0);
                        //if (event_active(btnWeaponSlotTap)) {
                        if (event_active(btnWeaponSlotTap) && !bInventory) {
                            WeaponActive=(WeaponActive+1)%2;
                            WeaponNotify();
                        }
                    }
                }
            }
            ///Weapon fix doble tap Square
             if (event_active(BUTTON_17) && time_release(BUTTON_17) < 250){
                 WeaponActive=(WeaponActive+1)%2;
                 WeaponNotify();
         }
           ///
        }
 
        /*//Grenade mode
       if (WeaponTracking) {
            if (event_active(BUTTON_13) && !get_actual(BTN_ADS) && !bInventory) {
                bThrow = TRUE;
                if (bUseSpeechActiveWeapon) printf("SPEECH: Throw");
            }
            if (event_active(BUTTON_10) || event_active(BUTTON_11) || event_active(BUTTON_14)) bThrow = FALSE;
 
        }
            */
   
        TypeA(); // controller layout cType specific
        TypeB(); // controller layout cType specific
 
        StanceTrack();
        //if (WeaponTracking==1) WeaponTrack(); 
        if (WeaponTracking==1 && !bInventory) WeaponTrack()
        T2SegFeedback();
        AutoSprint();
        DuckJump();
        HolsterNRun();
 
        // rapid fire
        taps=fTaps(BTN_SHOOT, tap_time);    // tap + tap&hold tracking
        if (taps >= 2) RFTapNHold=TRUE;       
        if(WeaponSlotRapid[WeaponActive] && !bThrow)
        {
            if (get_actual(BTN_SHOOT))
            {
                if (RapidFireMode==RF_CHECKBOX) fRapidFire(); // as checkbox state
                else if (RapidFireMode==RF_TAP_TAPHOLD && RFTapNHold) fRapidFire(); // tap + tap&hold
            }
 
            if (event_release(BTN_SHOOT))
            {
                RFTapNHold=FALSE;
                set_val(BTN_SHOOT, 0.0);
                combo_stop(RapidFire);
            }
        }
 
        // anti recoil
        if (get_actual(BTN_SHOOT) && !bThrow) {
            if (!WeaponSlotRapid[WeaponActive]) AntiRecoil(); // rapid fire off
            else if (WeaponSlotRapid[WeaponActive] && RapidFireMode==RF_TAP_TAPHOLD && !RFTapNHold) AntiRecoil(); // rapid fire enabled but with NO tap+tap&hold detected
        }
    }
}
 
void AutoSprint() {
    if(bUseAutoSprint)
    {
        static bool stick_forward;
        if(get_actual(STICK_2_Y) < -90.0 && time_release(STICK_2_Y) < 240)
        {
            if(stick_forward == 0)
            {
                stick_forward = 1;
            }
        }
        if(stick_forward == 1)
        {
            combo_run(cAutoSprint);
        }
        if(is_active(STICK_2_X) || get_actual(STICK_2_Y) > 10.0 || get_actual(STICK_2_Y) > -90.0)
        {
            stick_forward = 0;
        }
        /*
        if(get_actual(BUTTON_17) || get_actual(BUTTON_5) || get_actual(BUTTON_4)
        || get_actual(BUTTON_7) || get_actual(BUTTON_6))
        {
            stick_forward;
        }
        */

    }
}
/////////Auto Strafe
combo AutoStrafe
{
    set_val(STICK_2_X, 100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
    set_val(STICK_2_X, -100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
    set_val(STICK_2_X, 100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
    set_val(STICK_2_X, -100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
    set_val(STICK_2_X, 100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
    set_val(STICK_2_X, -100.0);
    wait(600);
    set_val(STICK_2_X, 0.0);
    wait(60);
 
   }
 
    combo AutoK
{
    wait(2500);
    set_val(BUTTON_7, 100.0);
    wait(60);
    set_val(BUTTON_7, 0.0);
    wait(60);
}
 
    ///////////////
combo cAutoSprint
{
    set_val(BTN_SPRINT, 100.0);
    wait(300);
    set_val(BTN_SPRINT, 0.0);
    wait(60);
}
 
void DuckJump() {
    if(bUseDuckJump)
    {
        static bool bDuckJumped = FALSE;
        if (check_active(BTN_JUMP,DuckJumpTapLimit)) {
            if (get_val(STK_MOVE_Y) < -85.0 && !bDuckJumped) {
                bDuckJumped = TRUE;
                combo_run(cDuckJump);
            }
        }
        if (event_release(BTN_JUMP)) bDuckJumped=FALSE;
    }
}
 
combo cDuckJump
{
    set_val(BTN_JUMP, 100.0);
    wait(DuckJumpWaitDuck);
    set_val(BTN_JUMP, 0.0); // new try: release jump before doing duck
    wait(20);
    set_val(BTN_CROUCH, 100.0);
    wait(100);
    wait(DuckJumpWaitLoop);
}
 
void HolsterNRun() {
    if(HolsterNRunMode==1)
    {
        if (check_active(BTN_CHANGE_WEAPON,HolsterNRunHoldTime) && !bHolsterNRun) {
            bHolsterNRun = TRUE;
            combo_run(cHolsterNRun);
        }
        if (event_release(BTN_CHANGE_WEAPON)) bHolsterNRun = FALSE;
    }
    if(HolsterNRunMode==2)
    {
        taps=fTaps(BTN_CHANGE_WEAPON,HolsterNRunTapTime);
        if (taps >= 2) bHolsterTapNHold=TRUE;       
        if (check_active(BTN_CHANGE_WEAPON,HolsterNRunHoldTime) && !bHolsterNRun && bHolsterTapNHold  ) {
            bHolsterNRun = TRUE;
            combo_run(cHolsterNRun);
        }
        if (event_release(BTN_CHANGE_WEAPON)) { bHolsterNRun = bHolsterTapNHold = FALSE; }
    }
}
 
combo cHolsterNRun
{
    set_val(BTN_SPRINT, 100.0);
    wait(40);
    set_val(BTN_SPRINT, 0.0);
    wait(40);
    set_val(BTN_SPRINT, 100.0);
    wait(40);
    wait(300);
}
 
// controller layout cType specific !
void TypeA() {
    if (cType == CTYPE_A) {
        bOTS = FALSE;
        bHIP = FALSE;
        if (!cType_A_ADS) {
            if (event_release(BTN_ADS) && time_active(BTN_ADS) <= CTYPE_A_ADS_TAPTIME) {
                //printf("ADS now ON");
                cType_A_ADS = TRUE;
                bUseAutoHoldBreath = TRUE;
            }
            if (check_active(BTN_ADS, CTYPE_A_ADS_TAPTIME+1) && bTrackOTS) SetCharacterState(STATE_OTS);
        }
        else if (cType_A_ADS && event_release(BTN_ADS)) {
            //printf("ADS now OFF");
            cType_A_ADS = FALSE;
            bUseAutoHoldBreath = FALSE;
        }
        if (CharacterStateCurrent == STATE_OTS && !cType_A_ADS && event_release(BTN_ADS)) {
            //printf("OTS off -> %d",CharacterStatePrevious);
            SetCharacterState(CharacterStatePrevious);
        }
        if (AutoHoldBreathType && bUseAutoHoldBreath) AutoHoldBreathUse();
    }
}
 
// controller layout cType specific !
void TypeB() {
    if (cType == CTYPE_B) { // LT hold: ADS, LB hold: OTS
        bOTS = FALSE;
        //////////////////////////////////////////////////////////////////////////
        //Hold Breath (L1) , ADS is controller type specific
        //////////////////////////////////////////////////////////////////////////
        bUseAutoHoldBreath=FALSE;
        if (AutoHoldBreathType && check_active(BTN_ADS,autoholdbreathDelay)) {
            if (AutoHoldBreathType==AHB_FULL && get_actual(BTN_ADS) >= 99f) bUseAutoHoldBreath=TRUE;
            if (AutoHoldBreathType==AHB_NOTFULL && get_actual(BTN_ADS) < 99f) bUseAutoHoldBreath=TRUE;
            if (AutoHoldBreathType==AHB_LEVEL && get_actual(BTN_ADS) >= 60f && get_actual(BTN_ADS) <= 90f) bUseAutoHoldBreath=TRUE;
            if (bUseAutoHoldBreath) AutoHoldBreathUse();
        }
        if (get_actual(BTN_GRENADE))
        {
            if (!get_actual(BTN_ADS) && bTrackOTS) SetCharacterState(STATE_OTS);
               if ( get_actual(BUTTON_5)) SetCharacterState(STATE_OTS);
 
        }else{
            if (event_release(BTN_GRENADE) && CharacterStateCurrent == STATE_OTS)
            {
 
                SetCharacterState(CharacterStatePrevious);
            }
        }
 
    }
}
 
// allow overriding of autohold breath flag, like on movement or manual press of holdbreath
void AutoHoldBreathUse() {
    bool bActiveHoldBreath = FALSE;
    // only activates ahb when not moving
    if (!is_active(STICK_2_X) && !is_active(STICK_2_Y))
        if (time_release(STICK_2_X) > AUTOHOLDBREATH_STICK_DELAY && time_release(STICK_2_Y) > AUTOHOLDBREATH_STICK_DELAY) bActiveHoldBreath = TRUE;
    // on manual button press disable ahb for a short time
    if (get_actual(BUTTON_7)) {
        set_val(BUTTON_7,0);
        bActiveHoldBreath = FALSE;
    }
    if (bActiveHoldBreath) {
        printf("autobreath USED");
        set_val(BUTTON_7, 100.0);
    }
}
 
void StanceTrack() {
 
    //Inventory
    //if (bInventory && (event_release(BUTTON_15) || event_active(BUTTON_3))) {
    if (bInventory) {
        if ((event_release(BUTTON_15) && !get_actual(BUTTON_8)) || event_active(BUTTON_3) || event_active(BUTTON_2)) {
            bInventory = FALSE;
            printf("Inventory Off");
        }
        return;
    } else if (event_active(BUTTON_3) || event_active(BUTTON_2)) {
        bInventory = TRUE;
        printf("Inventory On");
    }
 
 
    if (event_active(BTN_JUMP))
    {
        cType_A_ADS = FALSE; // reset type-A ads flag on jump, jumping exits ads mode
        CharacterStatePrevious=STATE_STANDING;
        SetCharacterState(STATE_STANDING);
        return;
    }
 
    if (event_release(BTN_CROUCH)) {
        switch(CharacterStateCurrent) {
        case STATE_STANDING:
            CharacterStateChange(STATE_CROUCH,STATE_PRONE);
            break;
        case STATE_CROUCH:
            CharacterStateChange(STATE_STANDING,STATE_PRONE);
            break;
        case STATE_PRONE:
            CharacterStateChange(STATE_CROUCH,STATE_STANDING);
            break;
        }
    } else if (CharacterStateCurrent == STATE_PRONE) {
        if (get_val(BTN_SPRINT) && (get_val(STK_MOVE_Y) <= -40.0) &&
            get_val(BTN_ADS) == 0.0) {
            SetCharacterState(STATE_STANDING);
        }
    }
}
 
void CharacterStateChange(uint8 shortState, uint8 longState) {
    if (time_active(BTN_CROUCH) < ProneHoldTime) {
        if (bTrackCrouch) SetCharacterState(shortState);
    } else {
        if (bTrackProne) SetCharacterState(longState);
    }
}
 
void SetCharacterState(int NewCharacterState)
{
    if (!bTrackCrouch && !bTrackOTS && !bTrackProne) return;
 
    if (NewCharacterState != CharacterStateCurrent) {
        if (NewCharacterState == STATE_OTS) {
            //display_overlay(BOTTOM_DOT,2000);
            //printf("OTS");
            bOTS = TRUE;
            return;
        }
 
        CharacterStatePrevious = CharacterStateCurrent;
        CharacterStateCurrent = NewCharacterState;
 
        if (NewCharacterState == STATE_STANDING) {
            printf("New State: STATE_STANDING");
            //display_overlay(SEG_A|SEG_D|SEG_G,2000);
        }
        else if (NewCharacterState == STATE_CROUCH) {
            printf("New State: STATE_CROUCH");
            //display_overlay(SEG_D|SEG_G,2000);
        }
        else if (NewCharacterState == STATE_PRONE) {
            printf("New State: STATE_PRONE");
            //display_overlay(SEG_D,2000);
        }
    }
}
 
void T2SegFeedback() {
    static uint8 oldT2SegStance;
    static uint8 oldT2SegWeapon;
    //                            STAND       ,  DUCK      , PRONE
    uint8 T2SegStance[] = {SEG_A|SEG_D|SEG_G, SEG_D|SEG_G, SEG_D};
    //                        PRI,  SEC,   SIDE,        GRENADE
    uint8 T2SegWeapon[] = {SEG_F, SEG_B, SEG_F|SEG_B, SEG_C};
 
    if (bUseT2SegStance) {
        T2SegStateStance = T2SegStance[CharacterStateCurrent];
        if (bOTS) T2SegStateStance = T2SegStateStance | BOTTOM_DOT;
    }
    if (bUseT2SegWeapon) {
        T2SegStateWeapon = T2SegWeapon[WeaponActive];
        if (bThrow) T2SegStateWeapon = T2SegWeapon[3];
    }
    if (T2SegTimer > 4000 && (T2SegStateStance || T2SegStateWeapon)) {
        if (oldT2SegStance != T2SegStateStance || oldT2SegWeapon != T2SegStateWeapon) {
            oldT2SegStance = T2SegStateStance;
            oldT2SegWeapon = T2SegStateWeapon;
            combo_restart(cT2SegFeedback);
        }
        combo_run(cT2SegFeedback);
    }
    /* else if (cT2SegFeedback) {
        combo_stop(cT2SegFeedback);
    }
    */

}
 
combo cT2SegFeedback {
    display_overlay(T2SegStateStance|T2SegStateWeapon,10000);
    wait(0);
    wait(10000);
}
 
#define DTAPLIMIT 190
combo cDTapLimit {
    wait(DTAPLIMIT);
    //if (WeaponActive==2) {
    if (WeaponActive==2 && !bInventory) {
        WeaponActive = WeaponLast%2;
    }
 
    else {
    //if (!WeaponHolstered && !bThrow) {
    //if (!WeaponHolstered && !bThrow && !bInventory ) {
    if (!WeaponHolstered && !bThrow && !bInventory ) {
 
            WeaponActive = (WeaponActive+1)%2;
        }
        bThrow = FALSE;
    }
    WeaponHolstered = 0;
    printf("short tap -> holstered: %d, weapon active: %d", WeaponHolstered, WeaponActive);
    WeaponNotify();
}
 
void WeaponTrack() {
    if (btnHold1 && get_actual(btnHold1) && btnHold2 && get_actual(btnHold2) && !bInventory) return;
    if (btnWeaponSlotHold && get_actual(btnWeaponSlotHold)) return;
    //if (event_active(BUTTON_10)) {
    if (event_active(BUTTON_10) || event_active(BUTTON_13) || bInventory ) {
        //if (WeaponActive != 2) WeaponLast = WeaponActive;
        //if (WeaponActive != 2 && !bInventory) WeaponLast = WeaponActive;
        if (WeaponActive != 2 ) WeaponLast = WeaponActive;
        WeaponActive = 2;
        WeaponNotify();
 
 
    }
    if (event_active(BUTTON_14) && cDTapLimit  && !bInventory) {
        combo_stop(cDTapLimit);
        if (WeaponHolstered && !bInventory) {
            WeaponHolstered = FALSE;
            WeaponActive = (WeaponActive+1)%2;
            WeaponNotify();
        } else {
            WeaponHolstered = TRUE;
        }
        printf("double tap -> holstered: %d, WeaponActive: %d", WeaponHolstered, WeaponActive);
        return;
    }
    if (check_active(BUTTON_14,DTAPLIMIT-1) && !bInventory) combo_stop(cDTapLimit);
    if (!cDTapLimit) {
        if (event_active(BUTTON_14) && !bInventory) combo_restart(cDTapLimit);
        if (event_release(BUTTON_14) && !bInventory) {
                printf("time active: %d",time_active(BUTTON_14));
                if (time_active(BUTTON_14) > 500 && !bInventory) {
                    WeaponHolstered = !WeaponHolstered;
                    printf("long hold -> holstered: %d", WeaponHolstered);
                }
        }
    }
}
 
 
// read fix16 from pmem position ( read int16 and return it as fix32 )
fix32 pmem_read_int16tofix32 (uint8 pmem_location) {
    int16 valInt16;
    pmem_read(pmem_location, &valInt16);
    return (fix32)valInt16 / 256.0;
}
 
combo RapidFire
{
    tRapidHolding=0; tRapidFiring=0; wait(0);
    set_val(BTN_SHOOT, 100);
    if (elapsed_time()) tRapidFiring++;
    if (ARecoilRF_Mode[ARSlotActive]==ARRF_BTN_FIRE) AntiRecoil(tRapidFiring);
 
    wait(RapidHold[ARSlotActive]);
 
    set_val(BTN_SHOOT, 0);
    tRapidFiring=0;
    if (elapsed_time()) tRapidHolding++;
    if (ARecoilRF_Mode[ARSlotActive]==ARRF_BTN_WAIT) AntiRecoil(tRapidHolding); // on fire button hold time, applied during hold only
    wait(RapidRelease[ARSlotActive]);
}
 
void fRapidFire() {
    // auto stop
    if (AutoStopRumbleID) {
            combo_run(AntiRecoilAutoStop);
            if ( (system_time() - AutoStopLastRumble) > AutoStopRumbleTLimit && time_active(BTN_SHOOT) > AutoStopFireTMin) {
                printf("rapid fire auto stopped!");
                return;
            }
    }   
    combo_run(RapidFire);
}
 
 
void AntiRecoil(uint32 tFiring) {
    #define ARTMax 3
    if (!WeaponSlotRecoil[WeaponActive]) return; // anti recoil is off
    // Sticknoise remove
    /*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); }*/

 
    int8 i;
    // 0&1&2 , 3&4&5, 6&7&8, 9&10&11, ...
    uint8 arS = WeaponSlotCfg[WeaponActive] * ARTMax + ARTMax-1;    //    start index of backward search
    uint8 arE = WeaponSlotCfg[WeaponActive] * ARTMax;                //    end index of backward search
    //if (event_active(BTN_SHOOT)) printf("arS: %d, arE: %d, t/v0: %d/%.02f, t/v1: %d/%.02f, t/v2: %d/%.02f", arS,arE,ARecoilDelay[arE+0],ARecoil_V[arE+0],ARecoilDelay[arE+1],ARecoil_V[arE+1],ARecoilDelay[arE+2],ARecoil_V[arE+2]);
 
    if (get_val(BUTTON_5)) {
        if (!is_active(BUTTON_8) && !is_active(BUTTON_7) && ARecoilMod[WeaponSlotCfg[WeaponActive]] > 0.01)  return// no hip anti recoil allowed as factor is 0.0
 
 
 
        // auto anti recoil stop
        if (AutoStopRumbleID) {
            combo_run(AntiRecoilAutoStop);
            if ( (system_time() - AutoStopLastRumble) > AutoStopRumbleTLimit && time_active(BTN_SHOOT) > AutoStopFireTMin) {
                //if (elapsed_time()) printf("Anti Recoil auto stopped!");
                if (elapsed_time())
                return;
            }
        }
 
        uint32 ta = time_active(BUTTON_5);             // fire active time
        if (is_active(BUTTON_8) && time_active(BUTTON_8) < ta ) ta = time_active(BUTTON_8);
        if (tFiring > 0 ) ta = tFiring; // anti recoil started from within rapid fire combo
        for (i=arS;i>=arE;i--) { // find time matching anti recoil entry
            if ((int16)ta >= ARecoilDelay[i]) {
 
                             fix32 modHip = 1.0, modStance = 1.0, modOts = 1.0;
 
                // hip fire
             if ( !get_actual(BTN_ADS) && CharacterStateCurrent!=3 && !cType_A_ADS) {
 
                 modHip = ARecoilMod[WeaponSlotCfg[WeaponActive]*4];
            }
                //
                if (CharacterStateCurrent) modStance = ARecoilMod[WeaponSlotCfg[WeaponActive]*4+CharacterStateCurrent];
                if (bOTS) modOts = ARecoilMod[WeaponSlotCfg[WeaponActive]*4+STATE_OTS];
 
 
                // debug output
                static uint8 lasti = 99;
                if (lasti != i || event_active(BTN_SHOOT)) {
                    lasti = i;
                    //printf("stance: %d, using idx %d, ta: %d, delay: %d, value: %d",CharacterStateCurrent,i,ta,ARecoilDelay[i],ARecoil_V[i]);
                    //printf("modHip: %f, modStance: %f, modOts: %f", modHip, modStance, modOts);
                }
 
                fAntiRecoil(STICK_1_Y,(fix32)ARecoil_V[i] * modHip * modStance * modOts);
                return;
            }
        }
    }
}
 
combo AntiRecoilAutoStop {
    // auto anti recoil stop
    if (AutoStopRumbleID==1) if (ffb_get(FFB_1,NULL) > 1f) AutoStopLastRumble = system_time();       
    else if (AutoStopRumbleID==2) if (ffb_get(FFB_2,NULL) > 1f) AutoStopLastRumble = system_time();
    else if (AutoStopRumbleID==3) if (ffb_get(FFB_3,NULL) > 1f) AutoStopLastRumble = system_time();
    else if (AutoStopRumbleID==4) if (ffb_get(FFB_4,NULL) > 1f) AutoStopLastRumble = system_time();
    wait(0); wait(10);
}
 
void fAntiRecoil (uint8 AxisToApply, fix32 ARecoilToApply)
{               
    fix32 CurrentX = get_val(STICK_1_X);
    fix32 CurrentY = get_val(STICK_1_Y);
    /////minmum recoil persent to apply on L2 L1 scoop X3 and red dote  X2
    fix32 Current7 = get_val(BUTTON_7);
    fix32 Current8 = get_val(BUTTON_8);
    if (Current7 && Current8 && CurrentX) {
              MinARecoilPercent = 66.6;// red dote
            //MinARecoilPercent = 77.6;// x2 for X2 scoops you need to remove 2 slashes and put it on red dote before MinARecoilPercent = 66.6
        }else if(Current7 && Current8 && CurrentY){
            MinARecoilPercent = 40.6;//red dote
            //MinARecoilPercent = 55.6;//X2 for X2 scoops you need to remove 2 slashes and put it on red dote before MinARecoilPercent = 40.6
        }else if(CurrentX && !Current7 ){
             MinARecoilPercent = 40.6;// red dote
             //MinARecoilPercent = 50.6;// X2 for X2 scoops you need to remove 2 slashes and put it on red dote before  MinARecoilPercent = 40.6;
        }else if(CurrentY && !Current7 ) { MinARecoilPercent = 20.00;}//red dote
        //}else if(CurrentY && !Current7 ) { MinARecoilPercent = 30.00;}// X2 for X2 scoops you need to remove 2 slashes and put it on red dote before  }else
    ////
    fix32 MinARecoilFactor = MinARecoilPercent / 100.0;
    fix32 MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
    //This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
    fix32 MovementARecoilToApply = (1.0 - MinARecoilFactor) * ((ARecoilToApply * (100.0 - sqrt(sq(CurrentX) + sq(CurrentY)))) / (100.0 + abs(CurrentX) + (sq(CurrentY)*0.5)));
    set_val(AxisToApply, clamp(MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply),-100f,100f));
 
}
 
void bToggle(bool *state, uint8 id) {   
    if (*state) *state = FALSE;
    else *state = TRUE;
    blink(*state, id);
}
 
void blink(bool state, uint8 id) {
    if (state){
        DWriteTxt("On");
        ColorLED(CW,120,70,4,WeaponSlotColor[WeaponActive]);
        if (bUseSpeech) printf(speech[id]);
    }else{
        DWriteTxt("Off");
        ColorLED(CW,400,200,2);
        if (bUseSpeech) printf(speech[id+1]);
    }
}
 
void WeaponNotify() {
    //if (bUseSpeechActiveWeapon) printf(speechWeapon[WeaponActive]);
    if (bUseSpeechActiveWeapon && !bInventory)  printf(speechWeapon[WeaponActive]);
    if (bUseLEDWeapon) ColorLED(WeaponSlotColor[WeaponActive]);
}
 
 
combo ckeyToggles {
    keyToggles();
    wait(0);wait(5);
}
 
void keyToggles() {
    if (key_check()) {
        for (i=0;i<sizeof(keyScriptStat);i++) {
            if (keyScript[i] && key_status(keyScript[i])) { // toggle on/off
                if (i==0) if (!keyScriptStat[i]) bToggle(&bModOn,i*2);
                if (i==1) if (!keyScriptStat[i]) bToggle(&WeaponSlotRapid[WeaponActive],i*2);
                if (i==2) if (!keyScriptStat[i]) bToggle(&WeaponSlotRecoil[WeaponActive],i*2);
                keyScriptStat[i]=TRUE;
            } else keyScriptStat[i]=FALSE;
        }
        for (i=0;i<sizeof(keySlotStat);i++) { // configuration slot change
            if (keySlot[i] && key_status(keySlot[i]) && ARSlotActive != i ) {
                ARSlotChange(i);
            }
        }
        for (i=0;i<sizeof(keyWeaponSlot);i++) { // active weapon tracking fix
            if (keyWeaponSlot[i] && key_status(keyWeaponSlot[i]) && WeaponActive != i ) {
                WeaponActive=i;
                WeaponNotify();
            }
        }
        if (keyStance) {
            if (key_status(keyStance) && !keyStanceTime) {
                keyStanceTime=system_time();
            } else if (!key_status(keyStance)){
                if (keyStanceTime) {
                    if (system_time() - keyStanceTime < ProneHoldTime) SetCharacterState((CharacterStateCurrent+1)%2);
                    else SetCharacterState(STATE_PRONE);
                    keyStanceTime=0;
                }
            }
        }
    } else {
        for (i=0;i<sizeof(keySlotStat);i++) {
            keySlotStat[i]=FALSE;
            keyScriptStat[i]=FALSE;
        }
        if (keyStanceTime) {
            if (system_time() - keyStanceTime < ProneHoldTime) SetCharacterState((CharacterStateCurrent+1)%2);
            else SetCharacterState(STATE_PRONE);
            keyStanceTime=FALSE;
        }
    }
}
 
void ARSlotChange(int8 action) {
    if (action > -1) ARSlotActive = action;
    WeaponSlotCfg[WeaponActive] = ARSlotActive;
    // printf("Slot: %d",ARSlotActive+1);
    // DWriteInt(ARSlotActive+1);
    DWriteTxt(ARSlotText[ARSlotActive]);
    if (bModOn) ColorLED(ARSlotColor[ARSlotActive],200,100,3,WeaponSlotColor[WeaponActive]);
    WeaponSlotRapid[WeaponActive] = ARSlotLoadRFActivate[ARSlotActive];
    if (bUseSpeech) {
        if (WeaponSlotRapid[WeaponActive]) printf("SPEECH:Set %d, Rapid ON",ARSlotActive+1);
        /*else printf("SPEECH:Set %d, Rapid Off",ARSlotActive+1);*/
        else if (ARSlotActive == 0)printf("SPEECH:AKM ScarL Groza QbZ G36c ");
        else if (ARSlotActive == 1)printf("SPEECH:youMP AUG  ");
        else if (ARSlotActive == 2)printf("SPEECH:M4 K2 Vector ");
        else if (ARSlotActive == 3)printf("SPEECH:Baryl ");
        else if (ARSlotActive == 4)printf("SPEECH:Sniper ");
    }
}
 
uint8 fTaps(uint8 btn, uint8 taptime) {
    static uint8 tapped[21];
    if (btn>20) return FALSE;
 
    if (event_active(btn)) {
        tapped[btn]+=1;
    }
 
    if ( (!is_active(btn) && time_release(btn) > taptime)
        || (is_active(btn) && time_active(btn) > taptime) )
    {
        uint8 taps=tapped[btn];
        tapped[btn]=0;
        return taps;
    }
    return tapped[btn];
}
 
 
 
 


and this is my configs for red dote L1+R2 for overshoulder and L2+ L1 for scoop x3
Code: Select all
 
GIVICFG:F301010258782D990A0001010401040196010101010101020402040204020400C896012C01F407400000012C0514000000640AF0000001F405DC000001F405DC000001F403E8181B1C151B1F1B1D1E1B1E1F000000008F00EE00D4018C008F00F000E3018C011400EE00CC00CC009400EB00E6018C0000000000000000020401
 

Slot 1 = AKM ScarL Groza QbZ G36c.
Slot 2 = UMP AUG.
Slot 3 = M4 K2
Slot 4 = Baryl
Slot 5 = I set it to Snipers there is no anti recoil but you can set it to any weapon you want
My game settings
The Type B layout is required to keep Hip and ADS settings in sync with the game and script.

Right Stick Deadzone: 10
Left Stick Deadzone: 10
Movement Sensitivity: 10
Vertical Sensitivity Multiplier: 100%
General Sensitivity: 20
Aim Acceleration: Off
Vibration :On i want the recoil to stop when there is no FFB when i drive vehicles so i have set set rumble to monitor on FFB1.
Over the Shoulder Aim Sensitivity: 20
ADS Sight Sensitivity Options: 20
1X 20
2X 19
3X 18
4x 16
6X 13
8X 13

I use Xim Apex
My mouse is logitech GPro wireless 3200 Dpi 1000 hz Polling rate
Xim apex 500 hz
T2 1000 Hz
Xim Settings
Default
Hip 50
ADs 27.50
OTS 52.50
All credits goes to Scachi for his nice script :joia:
-----------------------------
User avatar
Tahsin
Sergeant Major
Sergeant Major
 
Posts: 100
Joined: Wed May 15, 2019 7:57 am

PreviousNext

Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 43 guests