Skip to content

Instantly share code, notes, and snippets.

@ocirne23
Last active April 19, 2022 09:29
Show Gist options
  • Save ocirne23/11335307 to your computer and use it in GitHub Desktop.
Save ocirne23/11335307 to your computer and use it in GitHub Desktop.
Dark Souls 2 Input fix Autohotkey
#SingleInstance Force
#MaxHotkeysPerInterval 99999
#IfWinActive ahk_class DarkSouls2
; AutoHotkey script to remove input lag from DarkSouls2 PC, and adds
; hotkeys for Guard break / Jump Attack
;
; Current settings (some can be easily changed)
; LMB / RMB = normal attacks
; Shift + LMB / RMB = strong attacks
; Alt + LMB / RMB = swap weapon
; Wheel down/up = swap item / spell
; MMB = lock target
; Alt + Wheel down/up = cycle targets
; Q = guard break
; C = jump attack
; All current keybindings are set to match the Dark Souls 2 default keybindings
; All that needs to be done is unbinding all the mouse bindings in game while
; keeping the rest default. Note: Change the 'Walk' keybinding from Alt to something else.
; These can be modified, must be valid Autohotkey buttons
STRONG_MODIFIER = LShift
SWAP_MODIFIER = LAlt
LEFT_BUTTON = LBUTTON
RIGHT_BUTTON = RBUTTON
CYCLE_TARGET_MODIFIER = LAlt ; Cycling targets is done while holding this and scrolling up/down
; Link to action of choice in game, lowercase
SCROLL_UP = Up
SCROLL_DOWN = Down
; Default is Target Lock
MMB_CLICK = o
; These must match the bindings in the options menu, lowercase.
RIGHT = h
RIGHT_STRONG = g
LEFT = u
LEFT_STRONG = y
RIGHT_SWAP = Right
LEFT_SWAP = Left
NEXT_TARGET_LEFT = j
NEXT_TARGET_RIGHT = l
attackedLeft := false
attackedRight := false
; Guard Break. Can change Q to whatever
Q::
{
wasWalking := GetKeyState("w", "P")
if wasWalking
{
Send {w up}
Sleep 150
}
Send {w down}
Sleep 20
Send {%RIGHT% down}
Sleep 20
Send {%RIGHT% up}
if not wasWalking
{
Sleep 20
Send {w up}
}
return
}
; Jump Attack. Can change C to whatever
C::
{
wasWalking := GetKeyState("w", "P")
if wasWalking
{
Send {w up}
Sleep 150
}
Send {w down}
Sleep 20
Send {%RIGHT_STRONG% down}
Sleep 20
Send {%RIGHT_STRONG% up}
if not wasWalking
{
Sleep 20
Send {w up}
}
return
}
hasStrongModifierPressed()
{
global STRONG_MODIFIER
return GetKeyState(STRONG_MODIFIER, "P")
}
doLeftAttackButton()
{
global LEFT
global LEFT_STRONG
global attackedLeft
if not attackedLeft
{
attackedLeft := true
if hasStrongModifierPressed()
{
Send {%LEFT_STRONG% down}
}
else
{
Send {%LEFT% down}
}
}
return
}
doRightAttackButton()
{
global RIGHT
global RIGHT_STRONG
global attackedRight
if not attackedRight
{
attackedRight := true
if hasStrongModifierPressed()
{
Send {%RIGHT_STRONG% down}
}
else
{
Send {%RIGHT% down}
}
}
return
}
*~LButton::
{
global LEFT
global LEFT_STRONG
global LEFT_SWAP
global RIGHT
global RIGHT_STRONG
global LEFT_BUTTON
global RIGHT_BUTTON
global attackedLeft
global attackedRight
swap := GetKeyState(SWAP_MODIFIER, "P")
while GetKeyState(LEFT_BUTTON, "P")
{
if swap
{
Send {%LEFT_SWAP% down}
Sleep 50
Send {%LEFT_SWAP% up}
swap := false
break
}
doLeftAttackButton()
if GetKeyState(RIGHT_BUTTON, "P")
{
doRightAttackButton()
}
else
{
Send {%RIGHT% up}
Send {%RIGHT_STRONG% up}
attackedRight := false
}
}
Send {%LEFT% up}
Send {%LEFT_STRONG% up}
attackedLeft := false
if not GetKeyState(RIGHT_BUTTON, "P")
{
attackedRight := false
}
return
}
*~RButton::
{
global LEFT
global LEFT_STRONG
global RIGHT
global RIGHT_STRONG
global RIGHT_SWAP
global LEFT_BUTTON
global RIGHT_BUTTON
global attackedRight
global attackedLeft
swap := GetKeyState(SWAP_MODIFIER, "P")
while GetKeyState(RIGHT_BUTTON, "P")
{
if swap
{
Send {%RIGHT_SWAP% down}
Sleep 50
Send {%RIGHT_SWAP% up}
swap := false
break
}
doRightAttackButton()
if GetKeyState(LEFT_BUTTON, "P")
{
doLeftAttackButton()
}
else
{
Send {%LEFT% up}
Send {%LEFT_STRONG% up}
attackedLeft := false
}
}
Send {%RIGHT% up}
Send {%RIGHT_STRONG% up}
attackedRight := false
if not GetKeyState(LEFT_BUTTON, "P")
{
attackedLeft := false
}
return
}
MButton::
{
global MMB_CLICK
Send {%MMB_CLICK% down}
Sleep 20
Send {%MMB_CLICK% up}
return
}
~WheelUp::
{
global SCROLL_UP
global CYCLE_TARGET_MODIFIER
global NEXT_TARGET_LEFT
if GetKeyState(CYCLE_TARGET_MODIFIER, "P")
{
Send {%NEXT_TARGET_LEFT% down}
Sleep 20
Send {%NEXT_TARGET_LEFT% up}
}
else
{
Send {%SCROLL_UP% down}
Sleep 20
Send {%SCROLL_UP% up}
}
return
}
~WheelDown::
{
global SCROLL_DOWN
global CYCLE_TARGET_MODIFIER
global NEXT_TARGET_RIGHT
if GetKeyState(CYCLE_TARGET_MODIFIER, "P")
{
Send {%NEXT_TARGET_RIGHT% down}
Sleep 20
Send {%NEXT_TARGET_RIGHT% up}
}
else
{
Send {%SCROLL_DOWN% down}
Sleep 20
Send {%SCROLL_DOWN% up}
}
return
}
; We want to block native alt input or windows will make a beep every
; time you press any button + alt
*LAlt::
{
return
}
; Alt tab and alt escape gets enabled here
Tab::
{
if GetKeyState("LAlt", "P")
{
; Still not very pretty, but makes sure alt gets released properly
Send {LAlt down}{TAB}{TAB}{LAlt up}
}
}
~Escape::
{
if GetKeyState("LAlt", "P")
{
Send, {LAlt up}{ESCAPE}
}
}
@brunami
Copy link

brunami commented Jun 6, 2014

EDIT: For anyone getting Error for the script - download latest version here

http://ahkscript.org/download/

hours of headache for a rookie mistake..

@thereddevil123
Copy link

can u config this script into a new one that strong attack is alt and swap is shift? pls becuz i can't do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment