Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

anti-recoil script question (script included)


  • Please log in to reply
19 replies to this topic
HockeyZ
  • Guests
  • Last active:
  • Joined: --
In the following script I am just trying to figure out what is ACTUALLY being done to reduce the recoil. As in what tasks are being preformed to create the reduced recoil effect.

I have been trying to read all of the how-to's and tutorials to decipher the code myself but alot of the syntax is giving me a headache, esp the DllCall stuff. :)

TIA!



#NoEnv
SendMode Input

_auto := true

~LButton::autofire()
+LButton::_auto := ! _auto
F1::ExitApp

autofire()
{
global _auto
if _auto
{
Loop
{
if GetKeyState("LButton", "P")
{
Sleep 85
mouseXY(0, 6)
Sleep 45
}
else
break
} ;; loop
} ;; if
} ;; autofire()

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


Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
It moves the mouse down 6 pixels every 50ms while the left mouse button is held. I have absolutly no idea why mouse_move is used. If it doesn't work you can replace the mouseXY(0, 6) line with MouseMove, 0, 6, 0, R. And even that might not work in your game.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

HockeyZ
  • Guests
  • Last active:
  • Joined: --

It moves the mouse down 6 pixels every 50ms while the left mouse button is held. I have absolutly no idea why mouse_move is used. If it doesn't work you can replace the mouseXY(0, 6) line with MouseMove, 0, 6, 0, R. And even that might not work in your game.


Thank you very much for the info. If possible could you look another script ill put below and tell me the method it uses for anti-recoil? it seems to use a different method at least to my novice eyes.

It is autofire and anti-recoil, I under stand how the auto fire is working, just wondering how the anti-recoil part is functioning in this script. sorry for all the newbie questions. :)

#NoEnv
SendMode Input
SetMouseDelay, -1
SetKeyDelay, -1

~CapsLock::             ;Use the caplocks key to quickly toggle the script on & off
         Hotkey, ~LButton, toggle
If toggle != 1
          {
           toggle := 1    ; Will beep if it is set to on
           SoundPlay *84            ;Good because it plays over primary speakers. Others tend to play on motherboard speakers. It's 2008 many computers no longer have motherboard speakers!
           }
else
          {
           toggle := 0        ; Will beep if it is set to off
           SoundPlay *64            ;Good because it plays over primary speakers. Others tend to play on motherboard speakers. It's 2008 many computers no longer have motherboard speakers!
           }

_auto := true

~LButton::autofire()
~^LButton::autofire()
Code:


\::suspend             ;\ key completely suspends the script
autofire()
{
global _auto
if _auto
{
{
Loop
{
if GetKeyState("LButton", "P")
{
Test1 := A_Index            ;Test1 = A variable that carries outside of the loop, A_Index = how many times this specific loop has run.
SendInput {LButton Down}
Random, rand, 25.48019, 35
Sleep, rand      ;Time to wait in MS
SendInput {LButton Up}
Sleep, 100.8019               ;Time to wait in MS
}
else
break
}
} ;; loop
} ;; if
} ;; autofire()

mouseXY(x,y)
{
DllCall("mouse_event",uint,1,int,x,int,y,uint,0,int,0)
}
return
;;;;;;
;;; End script


Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
It doesn't appear to do anything other than click. I wouldn't use this script. It has problems with not using %'s where it should.

I'm in a good mood...if you want I'll write you a autofire script with antirecoil if needed. Just let me know any specifications required.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

HockeyZ
  • Guests
  • Last active:
  • Joined: --

It doesn't appear to do anything other than click. I wouldn't use this script. It has problems with not using %'s where it should.

I'm in a good mood...if you want I'll write you a autofire script with antirecoil if needed. Just let me know any specifications required.


ah makes sense bc I was noticing very little difference when comparing the script ones just for auto fire. I would like the anti-recoil to be stand alone script so I can use it with full auto weapons. also just an FYI I am probably about to give you way more info than you wanted. :)

I am looking to use this script for black ops on the xbox. I run the XIM controller so my mouse/keyboard/xbox all interface with my computer which is running software that is emulating all the xbox controls to the game system. just letting you know this in case certain commands are required.

the recoil system in black ops is somewhat randomized with horizontal and vertical kick. I am just concerned about the vertical. Below are the recoil specs for the weapon I am interested in using the script with.

AK47: (I am not really sure what the unit of measure for these statistics are)
fire rate/time per round: 0.08
recoil speed: 1500
Vert Kick max: 60
Vert Kick min: -30
Horiz Kick max: 60
Horiz Kick min: -60
average recoil per round: 24
percent that 2nd round will recover (not recoil): 21%
percent that 3nd round will recover (not recoil): 19%
percent that 4nd round will recover (not recoil): 17%

info obtained from:
http://denkirson.pro... ... hread=2699

now since im not concerned with horizontal kick I would guess the average recoil per round not including recovery chance is around 15 up. So including recovery chance I would think 10 per round is a decent place to start (that is based on no math and just a guess).

so 10 up per round at .08 rounds per second would be 125 up per second for what ever unit of measure is in place. Now I could be going about this all wrong so just let me know if I am going off in the way wrong direction. :)

thanks again for the help.

HockeyZ
  • Guests
  • Last active:
  • Joined: --
sorry for not spell/grammar checking before hitting submit :)

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Try this. It uses accurate timing and counts your shots. Just play with the settings at the top. The Reload_Key probably needs to be changed to your current hotkey for reloading, it can be any AHK hotkey name. You can make the reload times shorter or longer if they give you problems, but they should be close enough. Last is the down movement, which controls how much to move the mouse.

SetBatchLines, -1

; AK47 Stats/Settings
Mag_Size := 30 ; Set 45 for extended mags
Time_Per_Round := 0.08 ; Time to fire one round in seconds
Reload_Key := "r" ; Put your reload key here, this is the key you use already to reload
Reload_Time_UL := 3.25 ; Unloaded reload time
Reload_Time_L := 2.5 ; Loaded reload time
Down_Movement := 10 ; Move down this many pixels per shot, negative go up
Right_Movement := 0 ; Same for right and left movement

; ----------------------------------------
; No need to change anything bellow here
; ----------------------------------------
Hotkey, %Reload_Key%, On_Reload
Ammo := Mag_Size
return





~LButton::
While ( GetKeyState("LButton", "P") && Ammo > 0 )
{
	Delay(Time_Per_Round)
	MouseMove, %Right_Movement%, %Down_Movement%, 0, R
	Ammo--
}
If Ammo = 0
	GoSub, On_Reload
return


On_Reload:
Sleep_Time := (Ammo = 0 ? Reload_Time_UL : Reload_Time_L) ; Set the sleep time depending on if we have any ammo or not
Ammo := Mag_Size ; Reset ammo to max
AccuSleep(Sleep_Time)
return

^Esc::ExitApp


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 )
}

AccuSleep( Seconds=0.001 ) { ;  High-Resolution Sleep,  accurate upto a millisecond
 Static Freq,pQPC ; By SKAN, www.autohotkey.com/forum/viewtopic.php?p=388198#388198
 _BatchLines := A_Batchlines ; Created : 05-Oct-2010
 Critical
 If !Freq
   DllCall( "QueryPerformanceFrequency", Int64P,Freq ),
  ,hMod := DllCall( "GetModuleHandle", Str,"kernel32.dll" )
  ,pQPC := DllCall( "GetProcAddress", UInt,hMod, Str,"QueryPerformanceCounter" )
 DllCall( pQPC,Int64P,T1 )
 If ( Seconds > 0.032 ) {
   Sleep %  ( Seconds - 0.016 ) * 1000
   DllCall( pQPC,Int64P,T2 ), Seconds := Seconds - ((T2-T1)/Freq)
 }
 SetBatchlines, -1
 DllCall( pQPC, Int64P,pTick ), cTick := pTick
 While( ( (Tick:=(pTick-cTick)/Freq)) < Seconds ) {
   DllCall( pQPC, Int64P,pTick )
   Sleep -1
 }
 DllCall( pQPC,Int64P,T3 )
 SetBatchlines, %_BatchLines%
Return Round( (T3-T1)/Freq,3 )
}
The two functions at the bottom are made by SKAN, another visitor of this forum. They control precise sleep times and this is a time sensitive script. I just used AccuSleep because sleep allows other threads (ie. the left click hotkey) to take over.

Press Ctrl-Esc to quit.


Quick question: How much does it cost to set up XIM? I'm interested in it.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010
I apologize if this is a pathetically naive question but, wouldn't something like this work about as well:
setbatchlines, -1
process, priority, ,high

~lbutton::
 {
   mousegetpos, x, y
   while getkeystate("lbutton", "p")
    {
      mousemove, %x%, %y%
    }
 }
return

"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
It would depend on the game/UI. If when the gun was fired the mouse is actually moved up or down, then it would be the best solution. In most FPS games (I don't know about the UI of XIM), the game does its best to keep the mouse centered. So when the physical or simulated mouse is moved, the game checks how much movement occurred and in which direction then quickly resets the mouse position. This can happen up to 60 times per second. Most games don't move the mouse in response to recoil.

Also my script includes features like exact timing to only move the mouse when it is called for. And ammo counting to only move the mouse when you could possibly be shooting. The fall back for these is to not interfere with the game if something goes wrong in the script.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

HockeyZ
  • Guests
  • Last active:
  • Joined: --
Thank you very much for the script I will give it a shot when I get home tonight.

In regards tot he XIM the XIM3 is out now so I picked up a XIM2 that was listed incorrectly on eBay for a steal (25 bucks!!!) from what I have seen you can grab a XIM2 for around 75-100 normally.

The setup and tweaking is a pain and very time consuming (i used some posted settings but none fit perfect for me). after getting it setup tho its all worth it!

Well worth the time/money IMO as all my friends play on xbox.

HockeyZ
  • Guests
  • Last active:
  • Joined: --
Also if you want to bypass a large portion of the setup you can go with the brand new XIM3 which is stand alone and has no need for a computer to interface with the xbox (but also means no scripts).

quick question on the script, what is the load/unloaded reload time? is that to factor in the slight of hand (faster reload) perk?

thanks again.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
In BlackOps guns take different amounts of time depending on if the clip is partialy full (loaded) or completely empty (unloaded).

Thanks for the info on XIM.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

HockeyZ
  • Guests
  • Last active:
  • Joined: --

In BlackOps guns take different amounts of time depending on if the clip is partialy full (loaded) or completely empty (unloaded).

Thanks for the info on XIM.


Is it sad that I'm prestiged and didnt even notice that? any idea what the times would be with slight of hand perk? I use that perk on almost all my setups.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
It would be exactly half the time.
Source: <!-- m -->http://callofduty.wi... ... _Black_Ops<!-- m -->
AK47 Info (Including reload times): <!-- m -->http://callofduty.wi... ... _Black_Ops<!-- m -->
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

  • Guests
  • Last active:
  • Joined: --
Hi all, sorry to bring up an old thread, its just i own a Xim3 and im trying to get my head around BF3 recoil.

Frankie, sorry to ask.

Here are the details:

<!-- m -->http://symthic.com/?s=bf3&sb=dmgchart<!-- m -->

I wondered if you would be so kind as to make a no recoil for the G3A3?

The script above works well, but the mousemove makes the mouse go slightly crazy!
If poss could it be made with

DllCall("mouse_event", uint, 1, int, 0, int, 6, uint, 0, int, 0)

type mouse movement? This seems to not effect the use of the mouse.

Many thanks, sorry again to drag up an old thread.