XIM Community

XIM 4 => XIM 4 Discussions => Commander => Topic started by: Frash brang on 12:59 PM - 12/03/15

Title: no recoil not working
Post by: Frash brang on 12:59 PM - 12/03/15
thanks for the script havoc


#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

GetKeyState, state, Delete
if state = D
{
XIM:=false
}
GetKeyState, state, Insert
if state = D
{
XIM:=true
}
; XIM1
XIM4 := 1
; XIM
~LButton::
while GetKeyState("LButton") & XIM4
{
DllCall("mouse_event", uint, 1, int, 0, int, 3, uint, 0, int, 0)
Sleep, 30
DllCall("mouse_event", uint, 1, int, 0, int, 4, uint, 0, int, 0)
Sleep, 5
}
return

It seems to work on pc but when I try to get it working on xbox one through sanhawC it doesn't work for me? any ideas guys?
Title: Re: no recoil not working
Post by: Zacharybinx34 on 01:29 PM - 12/03/15
thanks for the script havoc


#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

GetKeyState, state, Delete
if state = D
{
XIM:=false
}
GetKeyState, state, Insert
if state = D
{
XIM:=true
}
; XIM1
XIM4 := 1
; XIM
~LButton::
while GetKeyState("LButton") & XIM4
{
DllCall("mouse_event", uint, 1, int, 0, int, 3, uint, 0, int, 0)
Sleep, 30
DllCall("mouse_event", uint, 1, int, 0, int, 4, uint, 0, int, 0)
Sleep, 5
}
return

It seems to work on pc but when I try to get it working on xbox one through sanhawC it doesn't work for me? any ideas guys?

What are you actually trying to do?
Title: Re: no recoil not working
Post by: Frash brang on 01:39 PM - 12/03/15
This is an anti recoil script...  I think. When you press left mouse button it moves your mouse down to combat upward gun recoil.

Title: Re: no recoil not working
Post by: Zacharybinx34 on 01:54 PM - 12/03/15
This is an anti recoil script...  I think. When you press left mouse button it moves your mouse down to combat upward gun recoil.



Interesting, if you get it fixed, let us know.
Title: Re: no recoil not working
Post by: Od1n on 05:49 PM - 12/03/15
add the usehook command

also scripts need to be written in a "smooth" way, means an ahk script that sort of spams the command as fast as the PC can will not work as well as a script that takes the update rate of XIM and SandhawC into account
the challenging part is to optimize a script for SandhawC for scripts that require a smooth movement
Title: Re: no recoil not working
Post by: Frash brang on 05:48 AM - 12/04/15
Thanks od1n, so I have added the usehook command and it works sporadically. How do I make this code "smooth"? and how do I take account of the update rate of xim and sandhawC?

Do you have some sample code that demonstrates the above that you could share?


#NoEnv
#Usehook
SendMode Input
SetWorkingDir %A_ScriptDir%

GetKeyState, state, Delete
if state = D
{
XIM:=false
}
GetKeyState, state, Insert
if state = D
{
XIM:=true
}
; XIM1
XIM4 := 1
; XIM
~LButton::
while GetKeyState("LButton") & XIM4
{
DllCall("mouse_event", uint, 1, int, 0, int, 3, uint, 0, int, 0)
Sleep, 30
DllCall("mouse_event", uint, 1, int, 0, int, 4, uint, 0, int, 0)
Sleep, 5
}
return
Title: Re: no recoil not working
Post by: Frash brang on 08:08 AM - 12/14/15

xim4 polling rate to xbone is 125hz (8ms)
I set my sandhawC to run at 125hz

I am trying to get this anti recoil script working, it works but in a very inconsistent way... sometimes I left click and it moves the mouse down to compensate for upwards recoil, sometimes it does nothing.

I found something called setbatchlines, 8ms that allows you to set the speed at which the autohotkey runs.

Am I on the right lines od1n?

do I need to consider any other polling rates? of the mouse maybe?

I'm trying to get this "smooth" as you suggested.

Thanks

Title: Re: no recoil not working
Post by: Od1n on 05:02 PM - 12/14/15
havent tested that yet but it sounds like a good idea

i havent looked into the issue for a few month now so i cannot tell you which mouse grab method you need to use in order to get a smooth script
though it would be nice incase you find one to let us all know :)
Title: Re: no recoil not working
Post by: Rouss3l on 12:18 AM - 12/22/15
Could not get this working even with usehook command. I have a few ideas to try and smooth it but cannot get anything working on ps4. Am I missing something with this? Put it into the script folder and launched sand which has the script working on desktop but not in game when I press pause.

Code: [Select]
#NoEnv
#Usehook
SendMode Input
SetWorkingDir %A_ScriptDir%

GetKeyState, state, Delete
if state = D
{
XIM:=false
}
GetKeyState, state, Insert
if state = D
{
XIM:=true
}
; XIM1
XIM4 := 1
; XIM
~LButton::
while GetKeyState("LButton") & XIM4
{
DllCall("mouse_event", uint, 1, int, 0, int, 3, uint, 0, int, 0)
Sleep, 30
DllCall("mouse_event", uint, 1, int, 0, int, 4, uint, 0, int, 0)
Sleep, 5
}
return
Title: Re: no recoil not working
Post by: Frash brang on 06:54 AM - 12/22/15
To be honest, I've given up on anti recoil...  Tried setbatchlines to reduce the speed at which it runs the script...  No joy.

Best bet is to buy a titan one... Still a massive ball ache
Title: Re: no recoil not working
Post by: Rouss3l on 09:54 AM - 12/23/15
Nah titanOne anti recoil does not work with XIM4. It creates weird movement skipping when trying to track enemies. I have been trying to figure that out as well for the longest time but unfortunately it has not worked.
Title: Re: no recoil not working
Post by: Frash brang on 06:52 PM - 12/26/15
I bought a bloody mouse which has on board macro storage and anti recoil calibration. It did not work either and created similar movements that you describe above.

Can't work out why rapid fire (continuously looping fire and stop firing) works but anti recoil (continuously moving mouse down) doesn't.

Can someone with a massive brain figure this out for me. Thanks in advance.
Title: Re: no recoil not working
Post by: W11cE on 04:11 PM - 12/28/15
Rapid fire works because SC queues all the button presses and makes sure all button presses get through on a speed that works on consoles.

There is also limited speed where console can react when it comes to rapid joystick moves. Rapid first shot recoil compensation is impossible. Only slow drags work on anti recoil scripts.
Title: Re: no recoil not working
Post by: abc123 on 10:14 PM - 12/31/15
Rapid fire works because SC queues all the button presses and makes sure all button presses get through on a speed that works on consoles.

There is also limited speed where console can react when it comes to rapid joystick moves. Rapid first shot recoil compensation is impossible. Only slow drags work on anti recoil scripts.

this is interesting, the next issue is that auto-hotkey doesn't support "slow" drags while SendMode is set to Input, only instantaneous mouse movements. these don't seem to work
Title: Re: no recoil not working
Post by: Od1n on 10:39 AM - 01/01/16
if you need such a script abc that is working with sandhawc (slow mouse drags downwards that you can customize) i can sent you one, maybe it helps you to unterstand what this script does different compared to all the others
(i havent had the time to go through the several hundred code lines yet)
Title: Re: no recoil not working
Post by: abc123 on 12:07 PM - 01/01/16
if you need such a script abc that is working with sandhawc (slow mouse drags downwards that you can customize) i can sent you one, maybe it helps you to unterstand what this script does different compared to all the others
(i havent had the time to go through the several hundred code lines yet)

please do, I have one that is ~150 lines of code and works on PC and when doing the PC->Xbox "streaming".

send away please
Title: Re: no recoil not working
Post by: Od1n on 01:45 PM - 01/01/16
if you need such a script abc that is working with sandhawc (slow mouse drags downwards that you can customize) i can sent you one, maybe it helps you to unterstand what this script does different compared to all the others
(i havent had the time to go through the several hundred code lines yet)

please do, I have one that is ~150 lines of code and works on PC and when doing the PC->Xbox "streaming".

send away please

pm sent :)
Title: Re: no recoil not working
Post by: Frash brang on 08:47 PM - 01/01/16
What is it that your code does od1n? Can you share this with me too?
Title: Re: no recoil not working
Post by: abc123 on 07:18 PM - 01/04/16
What is it that your code does od1n? Can you share this with me too?

for anyone else interested it seems you just need to move using "mouse_event" in dll then simply move 1 pixel multiple times over whatever period is required for the run you are using.

for example if you are firing a gun that shoots 600 rounds per minute then you have 60000 milliseconds in a minute so you have 100ms per bullet (simple math)

this means if the gun kicks 20 pixels up per round then over 100ms you need to move down 20 pixels
100/20 = 5ms every 5ms move 1 pixel down...

i hope this helps and makes sense to everyone.  it is really important to look up accurate delay and timing since it doesn't work to simply use the default "Sleep" function
Title: Re: no recoil not working
Post by: Dale on 02:54 PM - 01/05/16
I was gonna say, if your trying to automate slow movement.. just make it move small amounts very quickly.

movedown 1 pixel , .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms

..
and then if you want to add an ease to the movement to either end you just need to fuss with increasing the duration in incremental amounts.

movedown 1 pixel, .010ms
movedown 1 pixel, .008ms
movedown 1 pixel, .006ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .006ms
movedown 1 pixel, .008ms
movedown 1 pixel, .010ms

^example of something that would have ease to the front and back.
Title: Re: no recoil not working
Post by: abc123 on 11:04 AM - 01/08/16
I was gonna say, if your trying to automate slow movement.. just make it move small amounts very quickly.

movedown 1 pixel , .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms

..
and then if you want to add an ease to the movement to either end you just need to fuss with increasing the duration in incremental amounts.

movedown 1 pixel, .010ms
movedown 1 pixel, .008ms
movedown 1 pixel, .006ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .005ms
movedown 1 pixel, .006ms
movedown 1 pixel, .008ms
movedown 1 pixel, .010ms

^example of something that would have ease to the front and back.

this is correct, then it is just a requirement to do the math...

Number of Pixels to Move / Time between shots

So if a gun shoots 450 bullets a minute

450 / 60 = 7.5 bullets a second

1 / 7.5 = 0.133333333 time per bullet fire

This means you want to compensate for the number of pixels to move in 134ms
I'd pad 10ms at the beginning and end so that you start moving after you shot and end before the next shot
so 134ms becomes 114ms

So then 114 / number_of_pixels

this gives you the REQUIRED delay after each movement then do what dale posted to move those pixels
Title: Re: no recoil not working
Post by: Rouss3l on 11:44 PM - 01/13/16
So you managed to get it working abc?
Title: Re: no recoil not working
Post by: abc123 on 02:21 PM - 01/14/16
So you managed to get it working abc?

yeah, mine works for me. basically you need to use rapid small motion rather than doing massive motion
Title: Re: no recoil not working
Post by: Zacharybinx34 on 11:02 PM - 01/17/16
So you managed to get it working abc?

yeah, mine works for me. basically you need to use rapid small motion rather than doing massive motion

Could you share the entire macro?

Thanks ABC
Title: Re: no recoil not working
Post by: abc123 on 09:59 AM - 03/10/16
So you managed to get it working abc?

yeah, mine works for me. basically you need to use rapid small motion rather than doing massive motion

Could you share the entire macro?

Thanks ABC

this code will move the mouse 3 pixels left and 86 pixels down, the recoil of 1 gunshot from touch of malice.  the Delay(0.01) could be made smaller...and a ui could be built for this.


Code: [Select]
l:=time()
i:=0

While (i < 86) {
    If (i < 3) {
    l:=time(),move(-1, 0)
    Delay(0.01)
    }
    ; 0.1s + 0.03s = 0.13s

l:=time(),move(0, 1)

Delay(0.01)
i++
}

time() {
varsetcapacity(Count1, 8, 0)
DllCall("QueryPerformanceCounter", Uint, &Count1)
Count1:=Numget(Count1, 0)
return % Floor(count1 / 3.385)
}

move(x, y) {
DllCall("mouse_event", uint, 1, int, x, int, y, uint, 0, int, 0)
}

Delay( D=0.001 ) {  ; High Resolution Delay ( High CPU Usage )  by SKAN  | CD: 13/Jun/2009
 Static F           ; www.autohotkey.com/forum/viewtopic.php?t=52083     | LM: 13/Jun/2009
 Critical
 F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
 DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
 While( ( (Tick:=(pTick-cTick)/F)) <D ) {
   DllCall( "QueryPerformanceCounter", Int64P,pTick )
   Sleep -1
 }
Return Round( Tick,3 )
}
Title: Re: no recoil not working
Post by: R3MiX on 01:57 PM - 03/14/16
So you managed to get it working abc?

yeah, mine works for me. basically you need to use rapid small motion rather than doing massive motion

Could you share the entire macro?

Thanks ABC

this code will move the mouse 3 pixels left and 86 pixels down, the recoil of 1 gunshot from touch of malice.  the Delay(0.01) could be made smaller...and a ui could be built for this.


Code: [Select]
l:=time()
i:=0

While (i < 86) {
    If (i < 3) {
    l:=time(),move(-1, 0)
    Delay(0.01)
    }
    ; 0.1s + 0.03s = 0.13s

l:=time(),move(0, 1)

Delay(0.01)
i++
}

time() {
varsetcapacity(Count1, 8, 0)
DllCall("QueryPerformanceCounter", Uint, &Count1)
Count1:=Numget(Count1, 0)
return % Floor(count1 / 3.385)
}

move(x, y) {
DllCall("mouse_event", uint, 1, int, x, int, y, uint, 0, int, 0)
}

Delay( D=0.001 ) {  ; High Resolution Delay ( High CPU Usage )  by SKAN  | CD: 13/Jun/2009
 Static F           ; www.autohotkey.com/forum/viewtopic.php?t=52083     | LM: 13/Jun/2009
 Critical
 F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
 DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
 While( ( (Tick:=(pTick-cTick)/F)) <D ) {
   DllCall( "QueryPerformanceCounter", Int64P,pTick )
   Sleep -1
 }
Return Round( Tick,3 )
}

abc is this just weapon specific to TOM? Or can it be used also with AR, MG?
Title: Re: no recoil not working
Post by: BananaJuice on 12:38 PM - 03/16/16
So you managed to get it working abc?

yeah, mine works for me. basically you need to use rapid small motion rather than doing massive motion

Could you share the entire macro?

Thanks ABC

this code will move the mouse 3 pixels left and 86 pixels down, the recoil of 1 gunshot from touch of malice.  the Delay(0.01) could be made smaller...and a ui could be built for this.


Code: [Select]
l:=time()
i:=0

While (i < 86) {
    If (i < 3) {
    l:=time(),move(-1, 0)
    Delay(0.01)
    }
    ; 0.1s + 0.03s = 0.13s

l:=time(),move(0, 1)

Delay(0.01)
i++
}

time() {
varsetcapacity(Count1, 8, 0)
DllCall("QueryPerformanceCounter", Uint, &Count1)
Count1:=Numget(Count1, 0)
return % Floor(count1 / 3.385)
}

move(x, y) {
DllCall("mouse_event", uint, 1, int, x, int, y, uint, 0, int, 0)
}

Delay( D=0.001 ) {  ; High Resolution Delay ( High CPU Usage )  by SKAN  | CD: 13/Jun/2009
 Static F           ; www.autohotkey.com/forum/viewtopic.php?t=52083     | LM: 13/Jun/2009
 Critical
 F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
 DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
 While( ( (Tick:=(pTick-cTick)/F)) <D ) {
   DllCall( "QueryPerformanceCounter", Int64P,pTick )
   Sleep -1
 }
Return Round( Tick,3 )
}

is this a AHk script ? or how to get it work ?

Copy and paste the script  to a .txt file  and save it  into   C:\Users\.....\Documents\SandhawC\Scripts    is that correct ?   i dont know it not working for me
Title: Re: no recoil not working
Post by: abc123 on 01:22 PM - 03/21/16
hey guys, I am going to answer some questions

Is this Specific to ToM: Yes, but just change the movement to make it for anything else
just edit:
Code: [Select]
While (i < 86) {
    If (i < 3) {
    l:=time(),move(-1, 0)
    Delay(0.01)
    }
    ; 0.1s + 0.03s = 0.13s

l:=time(),move(0, 1)

Delay(0.01)
i++
}
yes, this is AHK...
you would need ahk installed and then save the above script as .ahk...you would also need to add the top of the file that all these scripts need...i didn't include it because everyone needs to learn how this works.
Title: Re: no recoil not working
Post by: name294 on 05:16 PM - 05/16/16
Abc, I tried out the script you posted, but it is inconsistent. It moves the mouse down a different amount of pixels every time.  :(

I did some testing with DllCall and it is extremely inconsistent and unreliable. Especially with higher number of pixels moved. For instance, I tested this by running a single DllCall to move the mouse down 40 pixels everytime I clicked the left mouse button. I pointed my crosshair dot on the same starting location on a wall and checked how far down it moved. Different results almost every time.

This is problematic, as guns with heavy recoil that require a lot of mouse movement down (such as AEK with heavy barrel in Battlefield 4) require a large of amount pixels down. Using DllCall with small amount of pixels moved each time is not enough.

I guess sandhawC has some limitations when it comes to mouse movement. Are there other methods or functions? Also, why doesn't MouseMove function work at all on sandhawC?
Title: Re: no recoil not working
Post by: cw1985 on 12:17 PM - 05/17/16
Here is the script I use for bf4. It's not as simple as some of the others, but I love the fact it incorporates a first shot multiplier, a GUI, and tweakable guns that are assigned to hotkeys. I have it up and running through sandhawc

Code: [Select]
#UseHook
#SingleInstance force
#MaxThreadsPerHotkey 2
#NoEnv
SetBatchLines -1
CoordMode, Mouse, Screen
 
global voice := ComObjCreate("SAPI.SpVoice"), weap, HWND_GUI, HWND_GUNS
voice.rate := -1
 
OnMessage(0x03, "GuiMove")
 
weap := gunarray()
 
Menu, Tray, NoStandard
Menu, Tray, Add, Show Window, ShowWindow
Menu, Tray, Add
Menu, Tray, Add, Exit, Exit
Menu, Tray, Click, 1
Menu, Tray, Default, Show window
 
SetWorkingDir % A_Appdata "\BF4Tools"
 
global Settings := new Settings("settings.ini")
Settings.Read()
 
SetTimer, gamecheck, 500
 
Gui, Add, Button, x118 y4 h70 gSettings hwndHWND_SETTINGSBUTTON, >>
 
Gui, Add, Text, x10 y10, Game:
Gui, Add, Text, x45 y10 w70 vRunningText, Checking..
 
Gui, Add, Text, x10 y30 gToggleNoRecoil, NoRecoil:
Gui, Add, Text, % "x60 y30 w50 gToggleNoRecoil vNoRecoilText c" (Settings.NoRecoil ? "Green" : "Red"), % (Settings.NoRecoil ? "Enabled" : "Disabled")
 
Gui, Add, Button, % "x10 y50 vWeapon gDropDownList w100 gChooseWeapon", % Settings.Weapon
GuiControl, ChooseString, Weapon, % Settings.Weapon
Gui, Show, w150, BF4Tools
Gui, % "-0x20000 +hwnd" RandomString(10) " +Owner"
HWND_GUI := WinExist("BF4Tools")
 
GuiControl, focus, NoRecoil ; have "nothing" in focus
 
Hotkey, % "~*" Settings.NoRecoilHotkey, ToggleNoRecoil
Hotkey, ~*LButton, Fire
 
ShowWindow:
if !WinActive("ahk_id" HWND_GUI)
        WinActivate % "ahk_id" HWND_GUI
return
 
ToggleNoRecoil:
Settings["NoRecoil"] := !Settings["NoRecoil"]
Settings.Write("NoRecoil", Settings["NoRecoil"])
if (!Settings["NoRecoil"]) {
        SoundPlay, *16
        Gui, Font, cRed
        GuiControl, Font, NoRecoilText
        GuiControl,, NoRecoilText, Disabled
} else {
        SoundPlay, *48
        Gui, Font, cGreen
        GuiControl, Font, NoRecoilText
        GuiControl,, NoRecoilText, Enabled
} Gui, Font
return
 
~F9::
~F10::
~F11::
~F12::
a := Settings["Gun" (RegExReplace(A_ThisHotkey, "[~F]", "") - 8)]
if !a
        return
Settings.Write("Weapon", a)
GuiControl 1:, Weapon, % a
saygun(Settings.Weapon)
return
 
#IfWinActive SandhawC
~Right::
~Left::
Gui Submit, NoHide
RecoilMultiplier := (A_ThisHotkey = "~Right" ? (RecoilMultiplier + 1) : (RecoilMultiplier - 1))
GuiControl,, RecoilMultiplier, % RecoilMultiplier
GuiControl,, MultiplierText, % "x" Round(RecoilMultiplier / 100, 2)
Settings.Write("RecoilMultiplier", RecoilMultiplier)
voice.speak("", 2)
voice.speak((StrLen(RecoilMultiplier) > 2 ? (SubStr(RecoilMultiplier, 1, 1) "." SubStr(RecoilMultiplier, 2, 2)) : ("0." RecoilMultiplier)), 1)
return
 
CheckBox:
Gui Submit, NoHide
Settings.Write("HeavyBarrel", HeavyBarrel)
return
 
DropDownList:
Gui Submit, NoHide
Settings.Write("Weapon", Weapon)
return
 
Fire:
Critical
if !WinActive("SandhawC")
        return
for x, b in weap
        for a, y in b
                if (a = Settings.Weapon)
                        typ := x, break
mult := weap[typ, Settings.Weapon, "FSM"]
rec_up := weap[typ, Settings.Weapon, "RU"]
rec_hor := weap[typ, Settings.Weapon, "RHA"]
rec_dir := (rec_hor = 0 ? 0 : (rec_hor > 0 ? -1 : 1))
rpm_ps := weap[typ, Settings.Weapon, "RPM"] / 60
sleep % Settings.Delay
s:=l:=time()
 
While (GetKeyState("LButton", "P"))&&(GetKeyState("NumPad8", "P") || Settings.Force)&&(Settings.NoRecoil)&&(running) {
        if (rpm_ps*rec_up*(Settings.RecoilMultiplier/3)*((time()-l)/1000000)*((time()-s)/10000<rpm_ps?((Settings.HeavyBarrel?2:1)*mult):1) >= 1) {
                i++
                l:=time(),move(((Abs(i*rec_hor)>rec_up)?(rec_dir*(i:=1)):0),(Settings.Invert?-1:1))
        }
}
 
return
 
gamecheck:
Process, exist, SandhawC.exe
if (Errorlevel > 0) {
        running := true
        Gui, Font, cGreen
        GuiControl, Font, RunningText
        GuiControl,, RunningText, Running!
        Gui, Font
} else {
        running := false
        Gui, Font, cRed
        GuiControl, Font, RunningText
        GuiControl,, RunningText, Not running..
        Gui, Font
} Gui, Submit, NoHide
return
 
GuiMove() {
        global
        WinGetPos, x, y, w,, % "ahk_id" HWND_GUI
        if WinExist("ahk_id" HWND_SETTINGS)
                Gui 2: Show, % "x" x+(w+10) " y" y " NoActivate"
        if WinExist("ahk_id" HWND_GUNS)
                Gui 3: Show, % "x" x-150 " y" y
}
 
Settings:
if WinExist("ahk_id" HWND_SETTINGS) {
        gosub SettingsSave
        return
} GuiControl,, >>, X
Hotkey, % "~*" Settings.NoRecoilHotkey, Off
Gui 2: Margin, 8, 6
Gui 2: Add, Text, x10, NoRecoil toggle:
Gui 2: Add, Hotkey, vNoRecoilHotkey hwndHWND_HOTKEY, % Settings.NoRecoilHotkey
AddToolTip(HWND_HOTKEY, "Button to toggle NoRecoil")
Gui 2: Add, Text, x10 y55, F9:
Gui 2: Add, Button, vGun1 gChooseGun1 yp-4 x35 w95, % Settings.Gun1
Gui 2: Add, Text, x10, F10:
Gui 2: Add, Button, vGun2 gChooseGun2 yp-4 x35 w95, % Settings.Gun2
Gui 2: Add, Text, x10, F11:
Gui 2: Add, Button, vGun3 gChooseGun3 yp-4 x35 w95, % Settings.Gun3
Gui 2: Add, Text, x10, F12:
Gui 2: Add, Button, vGun4 gChooseGun4 yp-4 x35 w95, % Settings.Gun4
Loop 4
        GuiControl 2: ChooseString, Gun%A_Index%, % Settings["Gun" A_Index]
Gui 2: Add, CheckBox, % "vHeavyBarrel hwndHWND_BARREL x8 Checked" Settings.HeavyBarrel, Heavy barrel?
Gui 2: Add, CheckBox, % "vForce hwndHWND_FORCE x8 Checked" Settings.Force, Force NoRecoil
Gui 2: Add, CheckBox, % "vInvert hwndHWND_INVERT x8 Checked" Settings.Invert, Inverted look
AddToolTip(HWND_FORCE, "Enable if you use toggle aim, as opposed to hold to aim")
AddToolTip(HWND_INVERT, "Enable if you use inverted look ingame")
AddToolTip(HWND_BARREL, "Enable if your gun uses Heavy Barrel attachment")
Gui 2: Add, Text, x10, Recoil strength:
Gui 2: Add, Slider, x10 vRecoilMultiplier hwndHWND_SLIDER gSlider NoTicks Range10-800 AltSubmit Center w90, % Settings.RecoilMultiplier
Gui 2: Add, Text, vMultiplierText yp+5 x110, % "x" Round(Settings.RecoilMultiplier / 100, 2)
AddToolTip(HWND_SLIDER, "The sensitivity of the algorithm. Change until it matches your ingame sensitivity,")
Gui 2: Add, Text, x10, Initial delay:
Gui 2: Add, Slider, vDelay hwndHWND_DELAY Range10-150 ToolTip, % Settings.Delay
Gui 2: Font, s7, Arial
Gui 2: Add, Text,, Enjoy the Tool, Cubed2 <3
AddToolTip(HWND_DELAY, "The amount to wait until countering recoil after firing (default: 40)")
Gui 2: -0x20000 +Owner -Caption +Border +hwndHWND_SETTINGS
WinGetPos, x, y, w,, % "ahk_id" HWND_GUI
Gui 2: Show, % "x" x+(w+10) " y" y " hide", Settings
DllCall("AnimateWindow", "UInt", HWND_SETTINGS, "Int", 100, "UInt", "0x40001")
Gui 2: Show
GuiControl 2: focus, NoRecoilHotkey
GuiControl 2: focus, NoRecoil toggle:
return
 
SettingsSave:
Gui 2: Submit, NoHide
if !NoRecoilHotkey {
        TrayTip,, All Hotkeys have to be filled/unique.
        return
} Hotkey("~*" NoRecoilHotkey, "ToggleNoRecoil")
Hotkey("~*" NoRecoilHotkey, "On")
Settings.Write("HeavyBarrel", HeavyBarrel)
Settings.Write("NoRecoilHotkey", NoRecoilHotkey)
Settings.Write("Delay", Delay)
Settings.Write("Invert", Invert)
Settings.Write("Force", Force)
GuiControl,, X, >>
DllCall("AnimateWindow", "UInt", HWND_SETTINGS, "Int", 100, "UInt", "0x90000")
Gui 2: Destroy
WinActivate ahk_id%HWND_GUI%
TrayTip,, Settings saved.
return
 
Slider:
Gui Submit, NoHide
GuiControl 2:, MultiplierText, % "x" Round(RecoilMultiplier / 100, 2)
Settings.Write("RecoilMultiplier", RecoilMultiplier)
return
 
ChooseWeapon:
ChooseGun1:
ChooseGun2:
ChooseGun3:
ChooseGun4:
ChooseWeap(Settings[SubStr(A_ThisLabel, 7)], SubStr(A_ThisLabel, 7))
return
 
ChooseWeap(pre, butto) {
        static
        if WinExist("ahk_id" HWND_GUNS)
                Gui 3: Destroy
        Gui 3: Add, DropDownList, vGunType gTypeChange, % arraytoguilist(weap)
        for x, b in weap
                for a, y in b
                        if (a = pre)
                                typ := x, break
        GuiControl 3: ChooseString, GunType, % typ
        Gui 3: Add, ListBox, vGunWeap h200
        GuiControl 3:, GunWeap, % arraytoguilist(weap[typ])
        GuiControl 3: ChooseString, GunWeap, % pre
        Gui 3: Add, Button, gSave w120, Save
        Gui 3: Add, Edit,vbutton x0 y0 h0 w0 Hidden, % butto
        Gui 3: -0x20000 +hwndHWND_GUNS -Caption +ToolWindow
        WinGetPos x, y,,, % "ahk_id" HWND_GUI
        Gui 3: Show, % "x" x-150 " y" y, Guns
        return
       
        Save:
        Gui 3: Submit, NoHide
        if !GunWeap
                return
        if (button = "Weapon") {
                GuiControl 1:, Weapon, % GunWeap
                Settings.Write("Weapon", GunWeap)
        } else {
                GuiControl 2:, % button, % GunWeap
                Settings.Write("Gun" SubStr(button, 0), GunWeap)
        } Gui 3: Destroy
        return
       
        TypeChange:
        Gui 3: Submit, NoHide
        GuiControl 3:, ListBox1, % "|" arraytoguilist(weap[GunType])
        return
       
        3GuiClose:
        Gui 3: Destroy
        return
}
 
arraytoguilist(arr) {
        for a, b in arr
                out .= a "|"
        return out
}
 
saygun(string) {
        a := RegExReplace(string, "-", "")
        Loop, parse, a
                if (RegExMatch(a, "[0-9][0-9]") = A_Index) && !RegExMatch(a, "[0-9][0-9][0-9]")
                        d .= A_LoopField
        else
                d .= A_LoopField . " "
        voice.speak("", 2)
        voice.speak(d, 1)
}
 
time() {
        varsetcapacity(Count1, 8, 0)
        DllCall("QueryPerformanceCounter", Uint, &Count1)
        Count1:=Numget(Count1, 0)
        return % Floor(count1 / 3.385)
}
 
GuiEscape:
GuiClose:
Gui Submit
ExitApp
return
 
Class Settings {
        __New(file) {
                this.file := file
                this.defaults := {"NoRecoilHotkey": "F6"
                , "RecoilMultiplier": 100
                , "Weapon": "AK-12"
                , "HeavyBarrel": false
                , "NoRecoil": true
                , "HoldRight": true
                , "Delay": 40
                , "Invert": false
                , "Force": false
                , "Gun1": "AK-12"
                , "Gun2": "AEK-971"
                , "Gun3": "FAMAS"
                , "Gun4": "AUG A3"}
        }
       
        Defaults() {
                for a, b in this.defaults
                        this.Write(a, b)
        }
       
        Read() {
                for a, b in this.defaults
                        if ((this[a] := IniRead(this.file, "Settings", a)) = "")
                                this.Write(a, b)
        }
       
        Write(key, value) {
                IniWrite(value, this.file, "Settings", key)
                this[key] := value
        }
}
 
IniRead(file, section, key) {
        IniRead, tempf, % A_WorkingDir "\" file, % section, % key, % A_Space
        return tempf
}
 
IniWrite(value, file, section, key) {
        IniWrite, % value, % A_WorkingDir "\" file, % section, % key
}
 
move(x, y) {
        DllCall("mouse_event", uint, 1, int, x, int, y, uint, 0, int, 0)
}
 
Equals(needle, haystack) {
        Loop, parse, haystack, % "|"
                if (A_LoopField = needle)
                        return true
        return false
}
 
Hotkey(key, label := "", hwnd := "") {
        if (hwnd)
                Hotkey, IfWinActive, % "ahk_id" hwnd
        else
                Hotkey, IfWinActive
        Hotkey, % key, % label, UseErrorLevel
}
 
Random(min, max) {
        Random, out, % min, % max
        return out
}
 
RandomString(length, special := false) {
        Loop % length
                str .= (r := Random(1, special ? 4 : 3)) = 1
        ? Random(0, 9) : r = 2
        ? Chr(Random(65, 90)) : r = 3
        ? Chr(Random(97, 122)) : SubStr("-_?!&:", r := Random(1, 6), 1)
        return % str
}
 
Exit:
ExitApp
return
 
#if true
 
AddToolTip(CtrlHwnd,text,Modify=0) {
        static TThwnd, GuiHwnd, Ptr
        if (!TThwnd) {
                Gui,+LastFound
                GuiHwnd:=WinExist()
                TThwnd:=DllCall("CreateWindowEx","Uint",0,"Str","TOOLTIPS_CLASS32","Uint",0,"Uint",2147483648 | 3,"Uint",-2147483648
                ,"Uint",-2147483648,"Uint",-2147483648,"Uint",-2147483648,"Uint",GuiHwnd,"Uint",0,"Uint",0,"Uint",0)
                Ptr:=(A_PtrSize ? "Ptr" : "UInt"), DllCall("uxtheme\SetWindowTheme","Uint",TThwnd,Ptr,0,"UintP",0)
        } Varsetcapacity(TInfo,44,0), Numput(44,TInfo), Numput(1|16,TInfo,4), Numput(GuiHwnd,TInfo,8), Numput(CtrlHwnd,TInfo,12), Numput(&text,TInfo,36)
        !Modify   ? (DllCall("SendMessage",Ptr,TThwnd,"Uint",1028,Ptr,0,Ptr,&TInfo,Ptr))
        . (DllCall("SendMessage",Ptr,TThwnd,"Uint",1048,Ptr,0,Ptr,A_ScreenWidth))
        DllCall("SendMessage",Ptr,TThwnd,"UInt",(A_IsUnicode ? 0x439 : 0x40c),Ptr,0,Ptr,&TInfo,Ptr)
}
 
gunarray() {
        w1 := {   "ACE 23":             {"RPM": 770, "FSM": 2.25, "RU": 0.36, "RHA": 0.05} ; ASSAULT
        , "AEK-971":            {"RPM": 900, "FSM": 2.6, "RU": 0.42, "RHA": 0.1}
        , "AK-12":                      {"RPM": 650, "FSM": 2.1, "RU": 0.3, "RHA": -0.025}
        , "AR 160":             {"RPM": 700, "FSM": 1.6, "RU": 0.23, "RHA": 0.0}
        , "AUG A3":             {"RPM": 700, "FSM": 1.95, "RU": 0.26, "RHA": -0.025}
        , "AN-94":            {"RPM": 600, "FSM": 265.0, "RU": 0.01, "RHA": 0.0}
        , "CZ-805":             {"RPM": 700, "FSM": 2.1, "RU": 0.29, "RHA": 0.055}
        , "F2000":                      {"RPM": 850, "FSM": 2.4, "RU": 0.35, "RHA": -0.05}
        , "FAMAS":                      {"RPM": 1000, "FSM": 2.5, "RU": 0.4, "RHA": 0.1}
        , "L85A2X":                      {"RPM": 750, "FSM": 4.4, "RU": 0.35, "RHA": 0.0}
        , "M16A4":                      {"RPM": 800, "FSM": 4.9, "RU": 0.28, "RHA": 0.055}
        , "M416X":                       {"RPM": 750, "FSM": 3.25, "RU": 0.42, "RHA": 0.08}
        , "QBZ-95-1":           {"RPM": 650, "FSM": 2.0, "RU": 0.24, "RHA": -0.05}
        , "SAR-21":             {"RPM": 600, "FSM": 1.8, "RU": 0.14, "RHA": 0.0}
        , "SCAR-HX":             {"RPM": 620, "FSM": 4.0, "RU": 0.58, "RHA": 0.0}}
        w2 := {   "A-91":                       {"RPM": 800, "FSM": 2.0, "RU": 0.3, "RHA": 0.0} ; CARBINES
        , "ACE 21 CQB":         {"RPM": 770, "FSM": 2.25, "RU": 0.36, "RHA": 0.05}
        , "ACE 52 CQB":         {"RPM": 650, "FSM": 1.95, "RU": 0.56, "RHA": 0.0}
        , "ACW-R":                      {"RPM": 880, "FSM": 2.5, "RU": 0.41, "RHA": -0.075}
        , "AK 5CXH":                      {"RPM": 700, "FSM": 2.25, "RU": 0.49, "RHA": 0.0}
        , "AKU-12":             {"RPM": 680, "FSM": 2.1, "RU": 0.3, "RHA": -0.025}
        , "G36C":                       {"RPM": 650, "FSM": 1.85, "RU": 0.3, "RHA": 0.0}
        , "M4":                         {"RPM": 800, "FSM": 2.4, "RU": 0.28, "RHA": 0.055}
        , "MTAR-21":            {"RPM": 900, "FSM": 2.6, "RU": 0.34, "RHA": 0.0}
        , "SG553":                      {"RPM": 830, "FSM": 2.3, "RU": 0.37, "RHA": 0.1}
        , "TYPE-95B-1":         {"RPM": 650, "FSM": 2.0, "RU": 0.24, "RHA": -0.05}}
        w3 := {   "ACE 53 SV":          {"RPM": 260, "FSM": 1.1, "RU": 1.0, "RHA": 0.2} ; DMR
        , "M39 EMR":            {"RPM": 300, "FSM": 1.0, "RU": 1.2, "RHA": 0.0}
        , "MK11 MOD 0":         {"RPM": 260, "FSM": 1.0, "RU": 1.0, "RHA": 0.075}
        , "QBU-88":             {"RPM": 310, "FSM": 1.0, "RU": 0.8, "RHA": 0.2}
        , "RFB":                        {"RPM": 260, "FSM": 1.0, "RU": 0.9, "RHA": 0.15}
        , "SCAR-H SV":          {"RPM": 260, "FSM": 1.0, "RU": 1.0, "RHA": 0.0}
        , "SKS":                        {"RPM": 333, "FSM": 1.0, "RU": 0.7, "RHA": 0.05}
        , "SVD-12":             {"RPM": 260, "FSM": 1.0, "RU": 0.95, "RHA": -0.065}}
        w4 := {   "AS VAL":             {"RPM": 900, "FSM": 2.55, "RU": 0.33, "RHA": 0.05} ; ENGINEER
        , "CBJ-MSX":             {"RPM": 700, "FSM": 3.0, "RU": 0.28, "RHA": 0.0}
        , "CZ-3A1":             {"RPM": 1000, "FSM": 3.0, "RU": 0.4, "RHA": 0.15}
        , "JS2":                        {"RPM": 900, "FSM": 2.55, "RU": 0.38, "RHA": 0.1}
        , "MP7":                        {"RPM": 950, "FSM": 2.15, "RU": 0.35, "RHA": 0.1}
        , "MPX":                        {"RPM": 850, "FSM": 2.4, "RU": 0.36, "RHA": 0.0}
        , "MX4":                        {"RPM": 830, "FSM": 2.3, "RU": 0.36, "RHA": -0.06}
        , "P90":                        {"RPM": 900, "FSM": 2.0, "RU": 0.32, "RHA": 0.0}
        , "PDW-R":                      {"RPM": 750, "FSM": 2.0, "RU": 0.26, "RHA": 0.07}
        , "PP-2000":            {"RPM": 650, "FSM": 1.65, "RU": 0.24, "RHA": -0.05}
        , "SR-2":                       {"RPM": 900, "FSM": 2.3, "RU": 0.33, "RHA": 0.0}
        , "UMP-45":             {"RPM": 600, "FSM": 1.65, "RU": 0.38, "RHA": 0.0}
        , "UMP-9":                      {"RPM": 700, "FSM": 1.8, "RU": 0.26, "RHA": 0.0}}
        /*
                w5 := {   "44 MAGNUM":          {"RPM": 150, "FSM": 1.0, "RU": 2.0, "RHA": 0.0} ; SECONDARY
                , "93R":                        {"RPM": 900, "FSM": 2.0, "RU": 0.5, "RHA": 0.0}
                , "COMPACT 45":         {"RPM": 320, "FSM": 1.0, "RU": 0.7, "RHA": 0.0}
                , "CZ-75":                      {"RPM": 360, "FSM": 1.0, "RU": 0.6, "RHA": 0.0}
                , "DEAGLE 44":          {"RPM": 220, "FSM": 1.0, "RU": 2.0, "RHA": 0.0}
                , "FN57":                       {"RPM": 455, "FSM": 1.0, "RU": 0.7, "RHA": 0.0}
                , "G18":                        {"RPM": 900, "FSM": 2.0, "RU": 0.56, "RHA": 0.0}
                , "M1911":                      {"RPM": 310, "FSM": 1.0, "RU": 0.6, "RHA": 0.0}
                , "M9":                         {"RPM": 400, "FSM": 1.0, "RU": 0.45, "RHA": 0.0}
                , "MP412 REX":          {"RPM": 180, "FSM": 1.0, "RU": 2.0, "RHA": 0.0}
                , "MP443":                      {"RPM": 380, "FSM": 1.0, "RU": 0.7, "RHA": 0.0}
                , "P226":                       {"RPM": 400, "FSM": 1.0, "RU": 0.4, "RHA": -0.1}
                , "QSZ-92":                     {"RPM": 455, "FSM": 1.0, "RU": 0.4, "RHA": 0.0}}
        */
        w6 := {   "AWS":                        {"RPM": 780, "FSM": 2.2, "RU": 0.35, "RHA": 0.065} ; SUPPORT
        , "LSAT":                       {"RPM": 650, "FSM": 1.75, "RU": 0.28, "RHA": 0.0}
        , "M240B":                      {"RPM": 650, "FSM": 2.2, "RU": 0.48, "RHA": 0.0}
        , "M249":                       {"RPM": 800, "FSM": 2.5, "RU": 0.325, "RHA": -0.05}
        , "M60E4":                      {"RPM": 570, "FSM": 1.0, "RU": 0.4, "RHA": -0.05}
        , "MG4":                        {"RPM": 800, "FSM": 3.55, "RU": 0.37, "RHA": 0.1}
        , "PKP PECHENEG":       {"RPM": 600, "FSM": 1.75, "RU": 0.43, "RHA": 0.0}
        , "QBB-95-1":           {"RPM": 650, "FSM": 3.55, "RU": 0.24, "RHA": -0.05}
        , "RPK-12":             {"RPM": 600, "FSM": 2.05, "RU": 0.27, "RHA": -0.03}
        , "RPK-74M":            {"RPM": 600, "FSM": 1.75, "RU": 0.36, "RHA": -0.05}
        , "TYPE-88 LMG":        {"RPM": 700, "FSM": 2.05, "RU": 0.28, "RHA": 0.0}
        , "U-100 MK5":          {"RPM": 590, "FSM": 2.5, "RU": 0.2, "RHA": 0.0}}
        return {"ASSAULT": w1, "CARBINES": w2, "DMR": w3, "ENGINEER": w4, "SUPPORT": w6}
} ; download complete
Title: Re: no recoil not working
Post by: cw1985 on 12:21 PM - 05/17/16
Some things to note:

-The script should be placed in your sandhawc script folder. Once run, it will generate a settings file, which should also be placed in your scripts folder

-When you click the launch scripts button, it will launch the AA script, but for whatever reason the script won't pull up any saved settings information. To fix this you have to close out the script and settings file, then manually open it through the scripts folder. This will load up all your saved gun settings

-The script is set up to only run when sandhawc is the active window. Just make sure you click over to sandhawc before you pause break over to console

-I have my ADS button set to Numpad8 in this script. Just edit it to whatever button you use. I think Rbutton is for right mouse?

-As far as the GUI goes, there is a recoil strength slider that can be adjusted from .10 to 8. I have mine set at 4.5. Adjust it so that the antirecoil feels close to correct, and then don't adjust it again. The exact fine tuning should be done for each individual gun

-Force recoil button is for toggle ADS. Inverted is obviously for inverted aiming. I never use the heavy barrell button. Instead I edit a gun that I don't use to have 1.3x the spread of the base version. I leave initial delay set at 40

-Finally, you are probably going to want to tweak each individual gun. The defaults on this script were based around the gun stats on symthic, but since everyone has different XIM sensitivities, the exact numbers will have to be reached through testing. The #s that I posted are mostly the default ones, except for a few like the L85 that I adjusted. Adjust FSM for first shot multiplier, RU for upward recoil and RHA for horizontal. Positive RHA adjusts for guns that kick right, negative to the left. Never adjust the RPM imo. When adjusting for heavy barrel, only multiply your RU by 1.3

-Also, when testing, don't aim at the dummies on test range. It screws with the recoil for some reason. Aim at a wall instead

I think that's it! I just posted a question in another thread about routing a sony nav through Sandhawc. If anyone has any helpful info on that I'd appreciate a response. Thanks
Title: Re: no recoil not working
Post by: kenn9797 on 12:45 AM - 04/01/17
How do u make the script work, i can get rapid fire macros to work, but when i open this script with lunch scripts
it opens the gui, but the recoil thing doesnt go down its study
Title: Re: no recoil not working
Post by: DragonHunter516 on 08:11 PM - 02/06/19
Some things to note:

-The script should be placed in your sandhawc script folder. Once run, it will generate a settings file, which should also be placed in your scripts folder

-When you click the launch scripts button, it will launch the AA script, but for whatever reason the script won't pull up any saved settings information. To fix this you have to close out the script and settings file, then manually open it through the scripts folder. This will load up all your saved gun settings

-The script is set up to only run when sandhawc is the active window. Just make sure you click over to sandhawc before you pause break over to console

-I have my ADS button set to Numpad8 in this script. Just edit it to whatever button you use. I think Rbutton is for right mouse?

-As far as the GUI goes, there is a recoil strength slider that can be adjusted from .10 to 8. I have mine set at 4.5. Adjust it so that the antirecoil feels close to correct, and then don't adjust it again. The exact fine tuning should be done for each individual gun

-Force recoil button is for toggle ADS. Inverted is obviously for inverted aiming. I never use the heavy barrell button. Instead I edit a gun that I don't use to have 1.3x the spread of the base version. I leave initial delay set at 40

-Finally, you are probably going to want to tweak each individual gun. The defaults on this script were based around the gun stats on symthic, but since everyone has different XIM sensitivities, the exact numbers will have to be reached through testing. The #s that I posted are mostly the default ones, except for a few like the L85 that I adjusted. Adjust FSM for first shot multiplier, RU for upward recoil and RHA for horizontal. Positive RHA adjusts for guns that kick right, negative to the left. Never adjust the RPM imo. When adjusting for heavy barrel, only multiply your RU by 1.3

-Also, when testing, don't aim at the dummies on test range. It screws with the recoil for some reason. Aim at a wall instead

I think that's it! I just posted a question in another thread about routing a sony nav through Sandhawc. If anyone has any helpful info on that I'd appreciate a response. Thanks
thank you tons for this little addendum you've added about your script I had no idea how much work you put into it. Major props on ya bud I was wondering if there was any possibility if you've made a (AR) script for BF1? if so would you mind pming it to me? I'm still in the learning process of how to make scripts and it helps to see what people have made already and see what works compared to what doesn't anyway awesome job on the script bud works wonders and love it hope to hear from ya -Good Luck and Keep Gaming!