-
Notifications
You must be signed in to change notification settings - Fork 1
/
Diablo II.ahk
201 lines (148 loc) · 2.67 KB
/
Diablo II.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
CoordMode, Pixel, Screen
ScreenWidth := 800
ScreenHeight := 585
halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2
Images1 := "perfect.png"
Images2 := "flawless.png"
Images3 := "unique.png"
Images8 := "gold.bmp"
Images7 := "setitem.png"
Images6 := "elmag.png"
Images5 := "elixir.png"
Images4 := "crafted.png"
ImagesCount = 8
Failed := 500
Success := 1337
Searching := 1
Hotkey, !z,TheMover,On
Hotkey, !x,TheMovymover,On
Hotkey, 5,ToCube,On
Hotkey, +5,Transmute,On
HotKey, Space, TransferSide, On
Pause::Suspend
return
TransferSide:
MouseGetPos, xpos, ypos
Click, xpos, ypos, Left
Sleep, 100
if (xpos > halfWidth) ;from invo
{
if (FindAndClick( xpos2, ypos2, 50, 60, halfWidth, 560, "emptystash.png") = 1)
{
MouseMove %xpos%, %ypos%, 0
}
else
{
Click, xpos, ypos, Left
}
}
else ;;;;;;;;;;;;;from stash/cube/merchant
{
if (FindAndClick( xpos2, ypos2, halfWidth, 60, 800, 560, "emptyinvo.png") = 1)
{
MouseMove %xpos%, %ypos%, 0
}
else
{
Click, xpos, ypos, Left
}
}
return
Transmute:
if (FindAndClick( xpos2, ypos2, 50,200, 400, 560, "transmute.png") = 1)
{
Sleep, 100
Click, 370 290 Left
}
else
{
MouseGetPos, xpos, ypos
if (FindAndClickDir(xpos2, ypos2, 0, 0, 800, 560, "cube.png", "Right") = 1)
{
Sleep, 200
if (FindAndClick( xpos2, ypos2, 50,200, 400, 560, "transmute.png") = 1)
{
Sleep, 100
Click, 370 290 Left
Click, 370 460 Left
MouseMove %xpos%, %ypos%, 0
}
}
}
return
ToCube:
MouseGetPos, xpos, ypos
Click, %xpos% %ypos% Left 1
Sleep, 100
if (FindAndClick( xpos2, ypos2, 0, 0, 800, 560, "cube.png") = 1)
{
MouseMove %xpos%, %ypos%, 0
}
return
TheMover:
Gosub, FindAllImages
return
TheMovymover:
Loop
{
LastPx := 0
LastPy := 0
found := 0
Gosub, FindAllImages
if (found = 1)
{
LastPx := abs(abs(LastPx - halfWidth) - 50)
LastPy := abs(abs(LastPy - halfHeight) - 50)
Together := Ceil(Sqrt(LastPx * LastPx + LastPy * LastPy)) * 1000 / 500
Sleep, % Together
}
else
{
return
}
}
return
FindAllImages:
found := 0
Loop %ImagesCount%
{
if (FindAndClick( Px, Py, 340, 200, 460, 330, Images%A_Index%) = 1)
{
LastPx := Px
LastPy := Py
found := 1
return
}
}
Loop %ImagesCount%
{
if (FindAndClick( Px, Py, 10, 90, 800, 553, Images%A_Index%) = 1)
{
LastPx := Px
LastPy := Py
found := 1
return
}
}
return
FindAndClick(ByRef Px, ByRef Py, x1, y1, x2, y2, image)
{
return FindAndClickDir(Px, Py, x1, y1, x2, y2, image, "Left")
}
FindAndClickDir(ByRef Px, ByRef Py, x1, y1, x2, y2, image, LeftRight)
{
ImageSearch, Px, Py, x1, y1, x2, y2, *1 *TransBlack %image%
if ErrorLevel
{
return 0
}
else
{
Click, %Px% %Py% %LeftRight% 1
return 1
}
}
LWin::
send {Alt}
return