-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEldenRing.ahk
371 lines (327 loc) · 9.18 KB
/
EldenRing.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
;EldenRing.ahk by DarKcyde
;Features: Keys for Run, instant Roll, backstep (while moving), 2hand, use pockets
;Macros for Exit to Main Menu, Pause, teleport to RoundTable
;QoL bindings for menus (PgUp, PgDn, Enter)
; Depends on modified fork at https://github.com/DarKcyde0/TapHoldManager for keydown
#include <TapHoldManager>
#SingleInstance Force
#Warn
#MenuMaskKey vkFF ; solves extraneous CTRL presses
#NoEnv
#MaxHotkeysPerInterval 200 ;managed to get warning at default 70
; If hotkey response time is crucial (such as in games) and the script contains any timers whose subroutines take longer
; than about 5 ms to execute, use the following command to avoid any chance of a 15 ms delay.
Thread, interrupt, 0 ; Make all threads always-interruptible
if not A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"
Process Priority,,AboveNormal ;probably not needed?
Sendmode Input
global RollDashKey := "p"
global UseKey := "o"
global DisableWASD := 0
global tick := ""
;thm := new TapHoldManager([ <tapTime := -1>, holdTime := -1, <maxTaps := -1>, <prefix := "$">, <window := ""> ])
TapMgr := new TapHoldManager(-1,-1,2,"*","ahk_exe eldenring.exe")
TapMgr.Add("MButton",Func("MbuttonMgr"),,1)
TapMgr.Add("z",Func("z_func"),,1)
TapMgr.Add("c",Func("c_func"),,1)
TapMgr.Add("f",Func("f_func")150,,1)
TapMgr.Add("CapsLock",Func("Caps_func"),100,150,1) ;try to reduce lag on tap, defaults noticably slow
; TapMgr.Add("lshift",Func("run_func"),200,500,2,"~*")
TapMgr.Add("w",Func("DoubleTapMoves_Run").Bind("w"),-1,-1,2,"~*")
; TapMgr.Add("a",Func("DoubleTapMoves_Run").Bind("a"),-1,-1,2,"~*")
; TapMgr.Add("s",Func("DoubleTapMoves_Run").Bind("s"),-1,-1,2,"~*")
; TapMgr.Add("d",Func("DoubleTapMoves_Run").Bind("d"),-1,-1,2,"~*")
#IfWinActive ahk_exe eldenring.exe
F9::Reload ;for AHK tweaking
F12::Suspend ;Toggle on/off
; Mouse remap, best accomplished with mouse driver software
; *WheelLeft::left
; *WheelRight::right
; *Xbutton1::u ;remapped below to Q
; *Xbutton2::r
; REMAPS
;===============
`::ToggleMap()
LWIN::send {shift down}{space down} ;alternate jump
LWIN up::send {shift up}{space up}
; *CapsLock:: Send {Ctrl down} ;crouch for easy press in combat
; *CapsLock up:: Send {Ctrl up} ;separate down/up more reliable
tab::esc ;menu
<!tab::alttab ;overrides ESC when doing alt-tab
<!F4::send {LAlt down}{F4 down}{LAlt up}{F4 up}
;QoL for the menus
enter::e
PgUp::c
PgDn::v
Delete::r
End::q
Home::f
Insert::g
; Attempt at replacing Run with TapHoldManager, untested, not currently using.
run_func(isHold, taps, keydown){
if (taps==1 && isHold==0 && keydown==1) ;on key down
{
if (!tick)
tick:=A_tickCount
if IsMoving() ; Will backstep if not moving
send {%RollDashKey% down}
SetTimer, RunMgr, 17 ; 60fps is 16.7ms
}
if (isHold && !keydown) ; held for 500ms and keyup
SetTimer RunMgr, Off
StopRunning()
if (taps && !isHold && state==-1) ; released before 500ms, prevent backstep
{
SetTimer RunMgr, Off
SetTimer StopRunning, % - (500 - (A_TickCount-tick)) ; calculate how much time to keep key down for 500ms
tick := ""
}
}
; Dedicated Run key
~*Lshift::
if (!tick)
tick:=A_tickCount
if IsMoving() ; Will backstep if not moving
send {%RollDashKey% down}
SetTimer, RunMgr, 17 ; 60fps is 16.7ms
Keywait Lshift ; prevent autorepeat
return
~*Lshift Up::
SetTimer RunMgr, Off
SetTimer StopRunning, % (tock:=A_TickCount-tick)<500 ? - (500-tock) : -0 ; calculate how much time to keep key down for 500ms
return
StopRunning() {
if (!GetKeyState("Lshift","P")){ ;In case Run pressed during timer
send {%RollDashKey% Up}
tick := ""
}
}
RunMgr() {
if ( !GetKeyState(RollDashKey) AND IsMoving() ) ;started moving or run interrupted
send {%RollDashKey% down}
}
; Dedicated Roll key, no input lag
; Default happens on key Up, this fires on key Down.
~*space::
TapKey(RollDashKey)
return
;Switch weapon, spell, item keys.
;Backup in case needed, mapped to scroll wheel.
*F1::left
*F2::right
*F3::up
*F4::down
;Quick Pockets keys
*q::QuickUse("up") ;Pocket 1 (red flask)
*e::QuickUse("right") ;Pocket 2 (blue flask)
*1::QuickUse("left") ;Pocket 3 (Horse pocket)
*2::QuickUse("down") ;Pocket 4 (Physick flask)
*3::MenuClick(1750,470) ;Pocket 5 (Lantern)
*4::MenuClick(1840,470) ;Pocket 6 (power ups, varies)
; REMAP Q & E
u::q ;mouse back
i::e ;mouse side btn
;Exit to Main Menu
NumpadSub::
TapKey("ESC")
TapKey("up")
TapKey("e")
Sleep 25
TapKey("z")
TapKey("e")
Sleep 25
TapKey("left")
TapKey("e")
return
Pause::
TapKey("ESC")
TapKey("e")
sleep 25
TapKey("g")
TapKey("up")
TapKey("e")
return
;Teleport to Roundtable Hold.
F5::
TapKey("g")
sleep 50
TapKey("f")
TapKey("r")
; if ( GetKeyState("space", "p") OR GetKeyState("LAlt", "p")) { ;hold space/alt to bypass confirmation
sleep 25
TapKey("e")
; }
return
;Gestures
Numpad7::MenuClick(1750,620)
Numpad8::MenuClick(1840,620)
Numpad4::MenuClick(1750,710)
Numpad5::MenuClick(1840,710)
Numpad1::MenuClick(1750,800)
Numpad2::MenuClick(1840,800)
#IfWinActive ;END HOTKEYS
;=============
;FUNCTIONS
;=============
IsMoving() {
if GetKeyState("w","P") OR GetKeyState("a","P") OR GetKeyState("s","P") OR GetKeyState("d","P")
return 1
else
return 0
}
; TapKey() Function
; key = press this
; delay = sleep in ms
; stopAutoRepeat = key to wait for keyup, usually A_ThisHotkey
TapKey(key, delay := 25, stopAutoRepeat := "") {
send {%key% down}
Sleep %delay%
send {%key% up}
if (stopAutoRepeat)
KeyWait %stopAutoRepeat%, T5
return
}
; QuickUse() Function
; Holds Interact and presses Key
; Lbutton and Q for 2hand left/right
; Pocket keys up/dn/left/right
QuickUse(key) {
send {e down}
send {%key% down}
sleep 25
send {e up}
send {%key% up}
return
}
Toggle(key) {
send % GetKeyState(key) ? "{" key " up}" : "{" key " down}"
}
; Function that releases all the letters in the str variable
ReleaseKeys(str){
Loop, Parse, % str ; Loop through each character of the variable str
Send {%A_LoopField% Up}
Return
}
; Directive disables WASD when true
#if (DisableWASD)
*w::
*a::
*s::
*d::
return
#if
; Pockets 5,6 and Gestures
MenuClick(x,y) {
local
ThisKey := % LTrim(A_ThisHotkey, "*~^!+#<>$")
SetMouseDelay 25
BlockInput On
TapKey("ESC")
SendEvent {click %x% %y%}
TapKey("ESC")
BlockInput Off
Keywait %ThisKey%, T5
}
; Original idea by KowboyBebop of EMU Light
; QoL: Makes map key also close map
ToggleMap(){
local ThisKey := % LTrim(A_ThisHotkey, "*~^!+#<>$")
Send {Escape Down}
Send {G down}
sleep 50
Send {Escape Up}
Send {G up}
KeyWait %ThisKey%, T10
}
; Interesting, saved for later
createTimer(fn, period, args*) {
if (args.MaxIndex() != "")
fn := Func(fn).Bind(args*)
SetTimer % fn, % period
}
; Middle click - tap to use, hold to go back to first item.
MButtonMgr(isHold, taps, keydown){
global UseKey
if (taps && !isHold && keydown==-1) ;tap
TapKey(UseKey,25)
if (isHold && keydown)
TapKey("down",550)
}
z_func(isHold, taps, keydown){
if (taps && !isHold && keydown==-1)
TapKey("z")
if (isHold && keydown)
QuickUse("q") ;2hand-Left
}
c_func(isHold, taps, keydown){
if (taps && !isHold && keydown==-1)
TapKey("c")
if (isHold && keydown)
QuickUse("LButton") ;2hand-Right
}
f_func(isHold, taps, keydown){
if (taps && !isHold && keydown==1) ;On keydown
BackStep()
if (isHold && keydown) ;Hold, still fires backstep, but no effect in menus
TapKey("f")
return
}
;BackStep - usable while moving
BackStep() {
Critical ;running timer could interrupt
if (IsMoving()){
ReleaseKeys("wasd")
DisableWASD := true
if (GetKeyState(RollDashKey)) {
send {%RollDashKey% up}
sleep 25
}
}
TapKey(RollDashKey)
sleep 25
if (DisableWASD){
DisableWASD := false
MoveKeys := "wasd"
Loop, Parse, MoveKeys
{
if ( GetKeyState(A_LoopField, "p"))
Send {%A_LoopField% down}
}
}
}
; Tap=Crouch, Hold=walk
; Never needed both at same time, same finger as run, good place for walk.
Caps_Func(isHold, taps, keydown){
if (taps && !isHold && keydown==-1) ;tap
TapKey("LCtrl")
if (isHold && keydown)
send {LAlt down}
if (isHold && !keydown)
send {LAlt up}
}
; WASD gets DoubleTap ability
; While this is cool, it might kill you near cliffs, be careful
; Send WASD is bad, better to pass thru with ~
DoubleTapMoves_Roll(key, isHold, taps, keydown) {
if (taps && !isHold && keydown==1) ;On keydown
send {%key% down}
if (taps==2 && !isHold && keydown==1) { ; Double Tap keydown
Thread NoTimers, true ;running timer could interrupt
if GetKeyState(RollDashKey) {
send {%RollDashKey% up}
sleep 25
}
TapKey(RollDashKey)
Thread NoTimers, false
}
if (keydown < 1) ;keyup
send {%key% up}
}
; Run on double tap hold
DoubleTapMoves_Run(key, isHold, taps, keydown) {
if (taps==2 && !isHold && keydown==1) ; Double tap keydown
send {%RollDashKey% down}
if (taps==2 && keydown < 1)
send {%RollDashKey% up}
}