/
d2r-reset-macro.ahk
116 lines (97 loc) · 3.01 KB
/
d2r-reset-macro.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
FileAppend,, settings.ini, CP0
CoordMode, Mouse, Client
IniRead, macroHotkey, settings.ini, Hotkeys, macro
IniRead, loadHotkey, settings.ini, Hotkeys, load
Hotkey, %macroHotkey%, Reset
Hotkey, %loadHotkey%, Load
Return
Reset:
rect := WindowGetRect("Diablo II: Resurrected")
heroY := rect.height * 0.503
heroXAmazon := rect.width * 0.200
heroXAssassin := rect.width * 0.303
heroXNecromancer := rect.width * 0.402
heroXBarbarian := rect.width * 0.494
heroXPaladin := rect.width * 0.602
heroXSorceress := rect.width * 0.712
heroXDruid := rect.width * 0.809
; Settings
IniRead, name, settings.ini, Settings, name
IniRead, hero, settings.ini, Settings, hero
heroX := heroX%hero%
IniRead, delete, settings.ini, Settings, delete
IniRead, classic, settings.ini, Settings, classic
IniRead, hardcore, settings.ini, Settings, hardcore
; Delays
IniRead, saveAndExitDelay, settings.ini, Delays, saveAndExitDelay
IniRead, loadingDelay, settings.ini, Delays, loadingDelay
hardcoreDelay := 100
deleteDelay := 5025
; Hotkeys
IniRead, liveSplitResetHotkey, settings.ini, LiveSplit, reset
IniRead, liveSplitStartHotkey, settings.ini, LiveSplit, start
; Reset
Send {%liveSplitResetHotkey%}
BlockInput, On
Send {Esc}
MouseClick, left, rect.width * 0.5, rect.height * 0.438
Sleep, %saveAndExitDelay%
; Delete
if delete {
MouseClick, left, rect.width * 0.866, rect.height * 0.937
MouseMove, rect.width * 0.427, rect.height * 0.538
Send {LButton Down}
Sleep, %deleteDelay%
Send {LButton Up}
}
; Create New
MouseClick, left, rect.width * 0.891, rect.height * 0.868
Sleep, %loadingDelay%
; Select Hero Class
MouseClick, left, %heroX%, %heroY%
; Character Name
If !delete
{
Loop, 5 {
letters := "bcdfghjklmnpqrstvwxz"
random, rand, 1, % strlen(letters)
randomLetter := strsplit(letters)
Send, % randomLetter[rand]
}
Send _%name%
} Else
{
Send %Name%
}
; Pre-Expansion (Classic)
If classic
{
MouseClick, left, rect.width * 0.519, rect.height * 0.885
}
; Create
If hardcore {
MouseClick, left, rect.width * 0.483, rect.height * 0.881
MouseClick, left, rect.width * 0.914, rect.height * 0.920
Sleep, %hardcoreDelay%
MouseClick, left, rect.width * 0.428, rect.height * 0.536
} Else {
MouseClick, left, rect.width * 0.914, rect.height * 0.920
}
; Move mouse to center
MouseMove, (rect.width/2), (rect.height/2)
BlockInput Off
Send {%liveSplitStartHotkey%}
return
; Load settings on hotkey
load:
ToolTip Loading...
Sleep, 500
Reload
Return
WindowGetRect(windowTitle*) {
if hwnd := WinExist(windowTitle*) {
VarSetCapacity(rect, 16, 0)
DllCall("GetClientRect", "Ptr", hwnd, "Ptr", &rect)
return {width: NumGet(rect, 8, "Int"), height: NumGet(rect, 12, "Int")}
}
}