Resident Evil 4 (2005)

Resident Evil 4 (2005)

查看统计:
leonid87 2014 年 3 月 2 日 上午 6:55
Script for QTEs (KB&M + controllers)
Worry not about QTEs anymore.

http://youtu.be/cpa_80I7sG0

http://youtu.be/DHVbAAAeiPI

https://github.com/lbrayner/AutoHotkeyScripts/blob/master/scripts/re4_qtime.ahk

(I'm referencing the keyboard::)

Hold "P" to repeatedly press "X" and "C", i.ie, it's good for either. (Battle against the 2 gigantes.)
Hold "O" to wiggle mouse.

Press "K" for the combo "X"+"C".
Press "L" for the combo "LMB"+"RMB".
Press both "K" and "L" to ensure success! :D


Press "RAlt" to toggle Active and Inactive.
Press "End" to end script.

Script will only be active when the RE4 game is focused.
(If you want to kill it just go to system tray, righclick the green AutoHotKey icon and choose Exit.)

Get the tool here:

http://ahkscript.org/download/

Neither installation nor admin credentials required. Just set the file (*.ahk) to be opened with the program executable.

UPDATE: "L" actually works as a quickshot hotkey. It helped a lot against U3.

2019 UPDATE: Cruft and unnecessary code removed. Script is only active when the RE4 game is focused. Link to Github instead of Google Drive.

This is it:

#UseHook #MaxHotkeysPerInterval 200 ;example from Help file #IfWinActive, ahk_exe bio4.exe CoordMode, Mouse, Screen ~*RAlt:: global Chat Chat := not Chat return ~*k:: SetKeyDelay -1 global Chat if(!Chat) { Send {Blind}{x DownTemp}{c DownTemp} } return ~*k up:: SetKeyDelay -1 Send {Blind}{x up}{c up} return ~*l:: SetKeyDelay -1 global Chat if(!Chat) { Send {Blind}{Click down}{Click down right} } return ~*l up:: SetKeyDelay -1 global Chat if(!Chat) { Send {Blind}{Click up}{Click up right} } return ~*o:: SetKeyDelay -1 global Chat displacement := 30 var := true sleep_var := 1 speed := 1 if(!Chat) { while(var) { MouseMove, (A_ScreenWidth/2 + displacement), A_ScreenHeight/2, speed Sleep sleep_var MouseMove, (A_ScreenWidth/2 - displacement), A_ScreenHeight/2, speed Sleep sleep_var } } return ~*o up:: var := false return ~*p:: SetKeyDelay -1 global Chat var := true sleep_var := 1 if(!Chat) { while(var) { Send {Blind}{x DownTemp}{c DownTemp} Sleep sleep_var Send {Blind}{x up}{c up} Sleep sleep_var } } return ~*p up:: var := false return
最后由 leonid87 编辑于; 2020 年 9 月 26 日 上午 4:07
< >
正在显示第 61 - 75 条,共 87 条留言
leonid87 2016 年 8 月 27 日 上午 10:42 
Thank you SO much for this. Without you, I wouldn't have been able to get past the first boulder qte, let alone the rest of the game on pro. I really appreciate it.
Thank you also for introducing me to AutoHotkey. I'm dabbling in programming, and this new syntax makes for good practice :D
I took the liberty of modifying the code so that it would only apply while the RE4 Window was active, and gave it a toggle sprint and an auto-move function:

#UseHook
#MaxHotkeysPerInterval 200 ;example from Help file
#IfWinActive Resident Evil 4 ;This means that if you alt-tab into, say, an internet browser, you won't have to worry about +y|>ing 1i|<e +his
CoordMode, Mouse, Screen

*RAlt::
chat := not chat
return

*~RShift:: ;toggle run. Map it to any key you want, but I prefer Right Shift
if(!chat)
{
send {LShift down}
}
return

*~+RShift:: ;the plus symbol means "shift," so when the Left Shift key is registered as being pressed, this function fires instead of the one above, effectively allowing for a toggle. Left Shift also turns it off.
if(!chat)
{
send {LShift up}
}
return

MoveToggle := false

*~t:: ;this is automove.
MoveToggle := !MoveToggle
if(!chat)
{
if (!MoveToggle)
{
send {w down}
return
}
else
{
send {w up}
send {t up}
}
MoveToggle := !MoveToggle
}
return

*~w up:: ;so that moving forward manually also cancels automove
if(!chat)
MoveToggle = !MoveToggle
return

*k::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{x DownTemp}{c DownTemp}
}
else
{
Send {Blind}{k DownTemp}
}
return

*k up::
SetKeyDelay -1
Send {Blind}{x up}{c up}{k up}
return

*l::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{Click down}{Click down right}
}
else
{
Send {Blind}{l DownTemp}
}
return

*l up::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{Click up}{Click up right}
}
else
{
Send {Blind}{l up}
}

return

*o::
SetKeyDelay -1
Displacement := 30
var := true
sleep_var := 1
speed := 1
if(!chat)
{
while(var)
{
MouseMove, (A_ScreenWidth/2 + Displacement), A_ScreenHeight/2, speed
Sleep sleep_var
MouseMove, (A_ScreenWidth/2 - Displacement), A_ScreenHeight/2, speed
Sleep sleep_var
}
}
else
{
Send {Blind}{o DownTemp}
}
return

*o up::
var := false
Send {Blind}{o up}
return

*p::
SetKeyDelay -1
var := true
sleep_var := 36 ;IMPORTANT - This WILL change; 35 was good for the first boulder, but I had to go for around 39 just to get by the Salazar statue.
if(!chat)
{
while(var)
{
Send {Blind}{x DownTemp}{c DownTemp}
Sleep sleep_var
Send {Blind}{x up}{c up}
Sleep sleep_var
}
}
else
{
Send {Blind}{p DownTemp}
}

return

*p up::
var := false
Send {Blind}{p up}
return

End::ExitApp
return

Not a problem! I'm glad it helped you as much as it makes the game playable and enjoyable for me.

I'll post my full and newest RE4 script shortly (since you said you're dabbling in programming). In it, running automatically is accomplished by sending the run key (e.g. LShift) as the move forward key (e.g. w) is pressed.


The script is outdated, that is, there some patterns that were refined and rendered succincter in my more recent works (The only game I played this year was the new Tomb Raider). Ah, and it reflects my personal key mappings, not the default ones.


The following is an example of how a pattern has been refined.

This code is present in the full script (the comments are not):

;********************CODE*************************

*Numpad8::
SetKeyDelay -1
UnreadyWeapon() ; function call (see the full script)
UnreadyKnife() ; function call (see the full script)
if(!walking)
{
Send {Blind}{Numpad8 DownTemp} {Space DownTemp}
}
else
{
Send {Blind}{Numpad8 DownTemp}
}
return

;********************END-CODE*************************

Today I'd have written it as thus:

;********************CODE*************************

~*Numpad8:: ; notice the tilde
SetKeyDelay -1
UnreadyWeapon() ; function call (see the full script)
UnreadyKnife() ; function call (see the full script)
if(!walking)
{
Send {Blind}{Space DownTemp}
}
return

;********************END-CODE*************************

The tilde means 'do not intercept', which will send the key in question anyway. Space is my 'Run' mapping; and Numpad8, my 'move forward' one.
最后由 leonid87 编辑于; 2016 年 8 月 27 日 下午 12:04
leonid87 2016 年 8 月 27 日 上午 11:29 
Here it is:

https://drive.google.com/open?id=0B_NNN6sIxejFT2xGQWpWUjBteUE

My hand grip was always weak but it's got worse in the past three years, to the point where I can't hold the virtual trigger anymore (playing with a gamepad is out of the question). I had to switch hands: mouse is handled with left hand. So, there's a mapping for holding the trigger. That part, which I reuse in almost every game, has been improved -- what used to be a toggle is not anymore. See my Tomb Raider script below (there's some crud left in it, just spotted it, oops).

But both older and newer scripts contain a function that releases the trigger (UnreadyWeapon in re4.ahk), called from anywhere when convenient, such as moving forward (as seen in the snippet above), since you can't move while manoeuvring your weapon in RE4 anyway.

There are more things that the script does, such as turning left and right with the mouse (like in RE5). If you're curious, leave a comment.

The Tomb Raider script:

https://drive.google.com/open?id=0B_NNN6sIxejFcEdFcmJIcVVyU0U

PS: The Click and Click right are aliases to mouse actions for the Send function and they respect OS settings (in my case, the mouse buttons have their actions reversed, so Click right actually sends LMouse). However, LButton and RButton are rebinding aliases to the actual physical buttons, independet of OS settings (confusing at first).
WaiLFin, the Angry Golem 2016 年 8 月 27 日 下午 12:00 
引用自 leonid87
Thank you SO much for this. Without you, I wouldn't have been able to get past the first boulder qte, let alone the rest of the game on pro. I really appreciate it.
Thank you also for introducing me to AutoHotkey. I'm dabbling in programming, and this new syntax makes for good practice :D
I took the liberty of modifying the code so that it would only apply while the RE4 Window was active, and gave it a toggle sprint and an auto-move function:

#UseHook
#MaxHotkeysPerInterval 200 ;example from Help file
#IfWinActive Resident Evil 4 ;This means that if you alt-tab into, say, an internet browser, you won't have to worry about +y|>ing 1i|<e +his
CoordMode, Mouse, Screen

*RAlt::
chat := not chat
return

*~RShift:: ;toggle run. Map it to any key you want, but I prefer Right Shift
if(!chat)
{
send {LShift down}
}
return

*~+RShift:: ;the plus symbol means "shift," so when the Left Shift key is registered as being pressed, this function fires instead of the one above, effectively allowing for a toggle. Left Shift also turns it off.
if(!chat)
{
send {LShift up}
}
return

MoveToggle := false

*~t:: ;this is automove.
MoveToggle := !MoveToggle
if(!chat)
{
if (!MoveToggle)
{
send {w down}
return
}
else
{
send {w up}
send {t up}
}
MoveToggle := !MoveToggle
}
return

*~w up:: ;so that moving forward manually also cancels automove
if(!chat)
MoveToggle = !MoveToggle
return

*k::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{x DownTemp}{c DownTemp}
}
else
{
Send {Blind}{k DownTemp}
}
return

*k up::
SetKeyDelay -1
Send {Blind}{x up}{c up}{k up}
return

*l::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{Click down}{Click down right}
}
else
{
Send {Blind}{l DownTemp}
}
return

*l up::
SetKeyDelay -1
if(!chat)
{
Send {Blind}{Click up}{Click up right}
}
else
{
Send {Blind}{l up}
}

return

*o::
SetKeyDelay -1
Displacement := 30
var := true
sleep_var := 1
speed := 1
if(!chat)
{
while(var)
{
MouseMove, (A_ScreenWidth/2 + Displacement), A_ScreenHeight/2, speed
Sleep sleep_var
MouseMove, (A_ScreenWidth/2 - Displacement), A_ScreenHeight/2, speed
Sleep sleep_var
}
}
else
{
Send {Blind}{o DownTemp}
}
return

*o up::
var := false
Send {Blind}{o up}
return

*p::
SetKeyDelay -1
var := true
sleep_var := 36 ;IMPORTANT - This WILL change; 35 was good for the first boulder, but I had to go for around 39 just to get by the Salazar statue.
if(!chat)
{
while(var)
{
Send {Blind}{x DownTemp}{c DownTemp}
Sleep sleep_var
Send {Blind}{x up}{c up}
Sleep sleep_var
}
}
else
{
Send {Blind}{p DownTemp}
}

return

*p up::
var := false
Send {Blind}{p up}
return

End::ExitApp
return

Not a problem! I'm glad it helped you as much as it makes the game playable and enjoyable for me.

I'll post my full and newest RE4 script shortly. In it, running automatically is accomplished by sending the run key (e.g. LShift) as the move forward key (e.g. w) is pressed.

The script is outdated, that is, there some patterns that were refined and rendered more succint in my more recent works (The only game I played this year was the new Tomb Raider). Ah, and it reflects my personal key mappings, not the default ones.

The following is an example of how a pattern has been refined.

This code is present in the full script (the comments are not):

;********************CODE*************************

*Numpad8::
SetKeyDelay -1
UnreadyWeapon() ; function call (see the full script)
UnreadyKnife() ; function call (see the full script)
if(!walking)
{
Send {Blind}{Numpad8 DownTemp} {Space DownTemp}
}
else
{
Send {Blind}{Numpad8 DownTemp}
}
return

;********************END-CODE*************************

Today I'd have written it as thus:

;********************CODE*************************

~*Numpad8:: ; notice the tilde
SetKeyDelay -1
UnreadyWeapon() ; function call (see the full script)
UnreadyKnife() ; function call (see the full script)
if(!walking)
{
Send {Blind}{Space DownTemp}
}
return

;********************END-CODE*************************

The tilde means 'do not intercept', which will send the key in question anyway. Space is my 'Run' mapping; and Numpad8, my 'move forward' one.

Yeah, I'd learned about the tilde and a bunch of other features as well.
I've just started dabbling in code, so it's been fun messing around with a language that isn't Java. Thanks for introducing me (and likely a whole bunch of others, namely those who've posted in this discussion) to ahk!
The shift + forward key I don't feel would work for RE4, especially considering parts involving the Garrador--if you're trying to aggro him, you don't want to accidentally keep running into him/giving away your location. That's just asking for a hug. And subsequently a decapitation. ;) Another part that springs to mind is the razor-pendulum section right after the Novistadores in the sewer.

One thing I've been struggling to accomplish, if indeed it's possible at all, is to make the quickturn key ( q for me) function even while run ( {LShift down} for me) and/or auto-move ({w down}) is registered as on. I'm aware that quickturn is equivalently accomplished by hitting run while holding back (in my case, hold s, and tap/hold LShift), so I've been trying to map q so that if the keystate of LShift is registered as down (NOT just physically, though; I put in the run toggle to give my poor pinky a break T~T), it'll send LShift up, send s down and send LShift back down again before sending to release s, thus interrupting the running-state (because I think that even if you mapped q to ignore case, the problem is the game only lets you quickturn when you're not moving/when run isn't being registered as held), doing the secondary quickturn key combination and proceeding with the running-state; similarly I'd like it to stop automoving briefly if the forward (w) key is registered as being held, execute the quickturn, and resume auto-moving shortly thereafter.

I'd also like to see if I can mess with the tank-controls; I'm thinking there's got to be a way to toggle a mode wherein the horizontal movement of the camera (mouse x-axis movement) is mapped proportionally to the physical turning of your character (a and d), with, of course, a variable or two that allows for tweaking so that people running the script on different setttings can adjust the sensitivity themselves towards more of a 1-to-1 correlation, or just whatever would feel right. (Yes, I am aware I am desecrating the holy balance of RE4's magnificent tank controls, but what can I say? I'm heretical :steammocking: )

Another cool idea is a quarter-turn; basically, you'd have a hotkey that would hold down the aim button, move the mouse in one direction or the other 90 degrees, then release-maybe you could have one quarter-turn key for left and another for right, or map things so a single quickturn key in combination with left or right would determine which way you turned. The amount of mouse movement sent per keypress could again be configurable via a local variable if necessary.

Lastly, speaking of 90-degree movement, I was thinking it'd be funny to have a pseudo-"strafe modifier" key that would make use of the quarter turn by very quickly quarter-turning in one direction, moving forward in that direction just a tad, and very quickly quarter-turning back to the original direction you were facing. I'm aware this would look pretty dumb and probably wouldn't function well, but I'm just trying to see what I can do.

Again, thanks not only for the script, but for the introduction to this fun little tool! I await your full updated code eagerly, sir. :)
最后由 WaiLFin, the Angry Golem 编辑于; 2016 年 8 月 27 日 下午 12:02
leonid87 2016 年 8 月 27 日 下午 12:47 
The most recent version of re4.ahk is

http://steamcommunity.com/app/254700/discussions/0/558749191152568985/?ctp=5#c359547436753565524

and it dates from March 2014.

To accomplish the quarter-turn, you could mess with

;********************CODE*************************

DllCall("mouse_event", uint, 32769, int, 32768, int, 32768, uint, 0, int, 0) ; native function call
;take a look at the Windows C/C++ API for this function
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646260%28v=vs.85%29.aspx

;and

MouseMove, A_ScreenWidth/2, A_ScreenHeight/2, 10


;********************END-CODE*************************

I had a quirky instant 180 degree turn for Dying Light using both those functions, but that game pissed me off so much that I even forgot to upload the script (I'm not on Windows but on Debian right now and the script must be sitting there on my Windows PC's HDD -- I hope I haven't deleted it out of rage).

The parameters really depend on the game and it can give you wild, seemingly random results. It's a pain, but it's worth trying if you really want to be able to do 90 or 180 turns.

My solution to turning Leon to the left and right with the mouse is centering the mouse pointer and polling for its position relative to the center after a specified interval to see if it's to the right or left and send either 'turn left' or 'turn right'. If no movement is detected, send both up. Of course it's not perfectly smooth like RE5, but it does the job! Better than using the arrows keys in my opinion.


The thing about the quickturn is timing. I belive even if you map q to also send LShift down, it won't work because the game won't register such fast state changes. You could try sleeping and then sending q, but I don't think it'd be as responsive as you would like it to.
最后由 leonid87 编辑于; 2016 年 8 月 27 日 下午 12:50
Duke Von Rollington 2016 年 8 月 27 日 下午 3:32 
Ahh I had looked for something like this earlier and didn't find anything. Gonna have to try these out. No more bs QTE deaths prease
leonid87 2016 年 8 月 28 日 上午 3:58 
引用自 R0ll Call
Ahh I had looked for something like this earlier and didn't find anything. Gonna have to try these out. No more bs QTE deaths prease

:wesker: I approve.
最后由 leonid87 编辑于; 2016 年 8 月 28 日 上午 3:58
Duke Von Rollington 2016 年 8 月 29 日 下午 5:13 
Works great. Free bump
SirPantsington 2018 年 9 月 3 日 下午 10:09 
Can you bind these to controller buttons somehow to just hold the button and not mash it? If so, could you give me a text field for it?
leonid87 2018 年 9 月 4 日 下午 5:57 
引用自 Relax & Reload
Can you bind these to controller buttons somehow to just hold the button and not mash it? If so, could you give me a text field for it?

#UseHook #MaxHotkeysPerInterval 200 ;example from Help file #IfWinActive, ahk_exe bio4.exe Joy4:: joy4_var := true joy4_sleep_var := 50 while(joy4_var) { Send {Blind}{Joy4 DownTemp} Sleep joy4_sleep_var Send {Blind}{Joy4 up} Sleep joy4_sleep_var } return Joy4 up:: joy4_var := false return

I haven't used a controller in over 4 years -- I had a made-in-China generic one -- so this is untested. I looked the keys up here: https://www.autohotkey.com/docs/KeyList.htm#Joystick

Substitute the re4.exe on the 3rd line for the name of game executable (I don't remember exactly) so that it's only active for that game.

Edit: It's bio4.exe.

(I'm downloading the game now by the way.)

What it does is it sends multiple presses (10 per second) of Button 4 while the same is held down.

This is for Button 4 -- you'd have to customize if you wanted another button.

最后由 leonid87 编辑于; 2018 年 9 月 5 日 下午 2:38
Ser Superior0001 2019 年 4 月 21 日 下午 9:05 
i dont understand
Ser Superior0001 2019 年 4 月 21 日 下午 10:49 
can someone explain me this?, i dont know much english, thanks
Bolek 2019 年 4 月 22 日 上午 2:30 
can someone explain me this?, i dont know much english, thanks

https://drive.google.com/file/d/0B_NNN6sIxejFaEJQT0JXczU1cWs/edit?usp=sharing

Click on this link and it should download qte.ahk which is the file you need, after that you need to get ahk which he left a link in the post so download that too, and after that you should be able to just double click on the qte.ahk and it will work.


Ser Superior0001 2019 年 4 月 22 日 下午 12:58 
引用自 Punisher
can someone explain me this?, i dont know much english, thanks

https://drive.google.com/file/d/0B_NNN6sIxejFaEJQT0JXczU1cWs/edit?usp=sharing

Click on this link and it should download qte.ahk which is the file you need, after that you need to get ahk which he left a link in the post so download that too, and after that you should be able to just double click on the qte.ahk and it will work.
you mean this link?

https://autohotkey.com/download/

i must click on download autohotkey installer?, if so, then?, what i must do after?

PD: and i use joystick lol, ok tell me how this works please
最后由 Ser Superior0001 编辑于; 2019 年 4 月 22 日 下午 1:09
Bolek 2019 年 4 月 22 日 下午 1:26 
You install autohotkey and then launch the script pretty much, and I'm not sure if it will work on joystick as I use kbm
Ser Superior0001 2019 年 4 月 22 日 下午 1:29 
引用自 WeebDegenerate-kun
You install autohotkey and then launch the script pretty much, and I'm not sure if it will work on joystick as I use kbm
then wat?, i replaced it already, when i must cut and paste this qte file?
< >
正在显示第 61 - 75 条,共 87 条留言
每页显示数: 1530 50

发帖日期: 2014 年 3 月 2 日 上午 6:55
回复数: 87