View difference between Paste ID: v9RSvGCy and X3epCQj2
SHOW: | | - or go back to the newest paste.
1
;IF YOU PLAN TO USE IMAGESEARCH FUNCTIONS:
2-
	  ;Download: http://www.mediafire.com/?vtx9l1woj61h8r6 (1.4a new link)
2+
	  ;Download: http://www.mediafire.com/?vtx9l1woj61h8r6
3
	  ;If your Windows installation is x64, use the 64-bit native AutoIt and the x64 directory in the archive
4
	  ;Extract and copy AutoIt3 folder to Program Files directory
5
	  ;Extract and copy all dlls to C:\Windows\ directory (optionally copy the MSVCR dlls to System32 as well)
6
	  ;Extract pics directory anywhere and update the $directory var - INCLUDE TRAILING BACKSLASH: C:\pics\
7
	  ;If you are running anything but fullscreen mode, the size of letters will mismatch and not loot anything. Resize or make your own pngs.
8
;IF YOU COMPILE THE SCRIPT TO EXE AND YOU USE X64:
9
	  ;Run "Compile script to .exe (x64)"
10
	  ;Check "Lowest" under the Compression menu option
11
	  ;Leave x64 checkbox checked
12
;;;;;
13
;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
14
;Required build: http://us.battle.net/d3/en/calculator/barbarian#WTXYQg!ZVg!abcZaY
15
;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
16
;Official supported resolution: 1920x1080
17
;;;;;
18
;Original: [Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
19
;ImageSearch contributions by rvbfreak, goofinator, and asuRob
20
21
#include <ImageSearch.au3> ;comment this if you are not using the new looting system
22
Global $Paused
23
Opt('MouseCoordMode', 2)
24
Opt('PixelCoordMode', 2)
25
HotKeySet("=","Leave")  ;script started by pressing =
26
HotKeySet("-", "Pause") ;script paused by pressing -
27
HotKeySet("x", "Stop") ;script stopped by pressing x
28
29
;ImageSearch Looting Variables
30
$ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
31
$directory = "C:\Program Files (x86)\AutoIt3\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
32-
$totalItems = 19; This needs to match the number of pngs you are loading
32+
$totalItems = 17; This needs to match the number of pngs you are loading
33
Global $pick[$totalItems], $size = WinGetClientSize("[TITLE:Diablo III; CLASS:D3 Main Window Class]"), $go = True, $Leave = False, $Dead = False, $Logout = False, $Window = False, $i = 0, $currentArrayItem = 0, $gX = 0, $gY = 0
34
If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
35
$pick[0] = "legendaryA.png|30"
36
$pick[1] = "legendaryE.png|30"
37
$pick[2] = "legendaryI.png|10"
38
$pick[3] = "legendaryO.png|30"
39
$pick[4] = "legendaryU.png|30"
40
$pick[5] = "setA.png|30"
41
$pick[6] = "setE.png|30"
42
$pick[7] = "setU.png|30"
43
$pick[8] = "setO.png|30"
44
$pick[9] = "setI.png|30"
45
$pick[10] = "rareA.png|30"
46
$pick[11] = "rareE.png|30"
47
$pick[12] = "rareI.png|30"
48
$pick[13] = "rareO.png|30"
49
$pick[14] = "rareU.png|30"
50-
$pick[15] = "ros.png|30"
50+
$pick[15] = "uare.png|40"
51-
$pick[16] = "ans.png|30"
51+
$pick[16] = "tome.png|30" 
52-
$pick[17] = "uare.png|40"
52+
53-
$pick[18] = "tome.png|30" 
53+
54
$Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
55
$walktime = 2600 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
56
$loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
57
$tptime = 6900 ; time in ms the script waits for teleport before exiting the game
58
$x_ratio = $size[0] / 1920
59
$y_ratio = $size[1] / 1080
60
$yellow = 0xFFF000 ; yellow color code (repair icon)
61
$red = 0xD90000 ; red color code (repair icon)
62
63
Call("RestartRun")
64
Func RestartRun()
65
   While $go
66
	  if($Leave) Then
67
		 $i = 0
68
		 Call("CheckExit")
69
		 Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
70
		 Call("CheckDead")
71
		 Call("CheckRepair")
72
		 If $Window Then
73
			MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
74
			Sleep($loadtime)
75
			$Window = False
76
			ExitLoop
77
		 ElseIf $Dead or $Logout Then
78
			ExitLoop
79
		 EndIf
80
		 MouseClick("middle", Round(587 * $x_ratio),Round(333 * $y_ratio)) ;starts the main run
81
		 Sleep(1090)
82
		 MouseMove(Round(96*$x_ratio),Round(383*$y_ratio),1)
83
		 Sleep(10)
84
		 Send("1")
85
		 Sleep(800)
86
		 MouseClick("middle", Round(56 * $x_ratio),Round(290 * $y_ratio))
87
		 Sleep(2900)
88
		 MouseMove(Round(320*$x_ratio),Round(205*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
89
		 Sleep(600)
90
		 Call("CheckDead")
91
		 If $Window Then
92
			MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
93
			Sleep($loadtime)
94
			$Window = False
95
			ExitLoop
96
		 ElseIf $Dead or $Logout Then
97
			ExitLoop
98
		 EndIf
99
		 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
100
			If Not @error Then
101
				  MouseClick("left",Round(320*$x_ratio),Round(205*$y_ratio)) ;Entrance to cellar
102
				  Sleep(1400)
103
				  Sleep($walktime)
104
				  MouseClick("middle",Round(80*$x_ratio),Round(830*$y_ratio)) ;moves to doorway leading to rare inside cellar
105
				  Sleep(2500)
106
				  MouseMove(Round(350*$x_ratio),Round(60*$y_ratio),1) ;hovers over the rare Sarkoth
107
				  Sleep(5)
108
				  Send("1")
109
				  Sleep(10)
110
				  MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
111
				  Sleep(140)
112
				  MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
113
				  Sleep(140)
114
				  MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
115
				  Sleep(1000)
116
				  Send("2")
117
				  Sleep(120)
118
				  Send("2")
119
				  Sleep(120)
120
				  Send("2")
121
				  Sleep(120)
122
				  Send("2")
123
				  Sleep(120)
124
				  Send("3")
125
				  Sleep(120)
126
				  Send("3")
127
				  Sleep(120)
128
				  Send("3")
129
				  Sleep(120)
130
				  Send("3")
131
				  Sleep(140)
132
				  Send("4")
133
				  Sleep(140)
134
				  Send("4")
135
				  Sleep(140)
136
				  Send("4")
137
				  Sleep(1550)
138
				  MouseClick("middle",Round(750*$x_ratio),Round(555*$y_ratio)) ;move to left top corner for gold
139
				  Sleep(1000)
140
				  MouseClick("middle",Round(1175*$x_ratio),Round(350*$y_ratio)) ;move to right top corner for gold
141
				  Sleep(1000)
142
				  MouseClick("middle",Round(1020*$x_ratio),Round(773*$y_ratio)) ;move to middle before looting
143
				  Sleep(1000)
144
				  MouseClick("middle",Round(900*$x_ratio),Round(400*$y_ratio)) ;move to chest middle
145
				  Call("CheckLoot")
146
				  Send("t")
147
				  Sleep($tptime)
148
				  Call("RandomSleep")
149
				  Call("CheckDead")
150
				  If Not $Logout And Not $Dead And Not $Window Then
151
					 Sleep(300)
152
					 Send("{ESCAPE}") ;menu
153
					 Sleep(200)
154
					 MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
155
					 Sleep($loadtime)
156
					 Call("CheckDead")
157
					 If Not $Logout Then
158
						MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
159
						Sleep($loadtime)
160
					 EndIf
161
				  Else
162
					 MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
163
					 Sleep($loadtime)
164
					 $Window = False ; reset the flag so it doesn't think a window is always up
165
				  EndIf
166
			   Else
167
				  Sleep(40)
168
				  Send("t")
169
				  Sleep($tptime)
170
				  Call("RandomSleep")
171
				  Call("CheckDead")
172
				  If Not $Logout And Not $Dead And Not $Window Then
173
					 Sleep(300)
174
					 Send("{ESCAPE}") ;menu
175
					 Sleep(200)
176
					 MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
177
					 Sleep($loadtime)
178
					 Call("CheckDead")
179
					 If Not $Logout Then
180
						MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
181
						Sleep($loadtime)
182
					 EndIf
183
				  Else
184
					 MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
185
					 Sleep($loadtime)
186
					 $Window = False ; reset the flag so it doesn't think a window is always up
187
				  EndIf
188
			EndIf
189
	  EndIf
190
   WEnd
191
   Call("RestartRun")
192
EndFunc
193
194
Func CheckDead()
195
Call("CheckWindow")
196
$YouHaveDied = PixelSearch(Round(620*$x_ratio), Round(325*$y_ratio), Round(625*$x_ratio), Round(330*$y_ratio), 0xFFFFFF) ; checks for white text "YOU HAVE DIED"
197
If Not @error Then
198
   If Not $Window Then
199
	  $Dead = True
200
	  Sleep(100)
201
	  Send("{Escape}")
202
	  Sleep(10)
203
	  MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
204
	  Sleep(11000)
205
	  Sleep($loadtime)
206
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
207
	  Sleep($loadtime)
208
   Else
209
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
210
	  Sleep($loadtime)
211
	  $Dead = False
212
   EndIf
213
Else
214
   $Dead = False
215
EndIf
216
$LogoutTimerCancel = PixelSearch(Round(900*$x_ratio), Round(240*$y_ratio), Round(1010*$x_ratio), Round(290*$y_ratio), 0x993827) ; checks for cancel button on logout timer
217
If Not @error Then
218
   Sleep(11000)
219
   Sleep($loadtime)
220
   If Not $Window Then
221
	  $Dead = True
222
	  $Logout = True
223
	  Sleep($loadtime)
224
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
225
	  Sleep($loadtime)
226
   Else
227
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
228
	  Sleep($loadtime)
229
	  $Logout = False
230
   EndIf
231
Else
232
   $Logout = False
233
EndIf
234
EndFunc
235
236
Func CheckWindow()
237
$CloseButton = PixelSearch(Round(1570*$x_ratio), Round(110*$y_ratio), Round(1590*$x_ratio), Round(120*$y_ratio), 0x8C2300) ; checks for the red color of the "X" on an open window
238
If Not @error Then
239
   Sleep(200)
240
   Send("{SPACE}") ;close any open windows
241
   $Window = True
242
Else
243
   $Window = False
244
EndIf
245
EndFunc
246
247
Func CheckExit()
248
$ExitButton = PixelSearch(Round(1190*$x_ratio), Round(400*$y_ratio), Round(1200*$x_ratio), Round(440*$y_ratio), 0x14100E) ; checks for the grey border of the exit prompt
249
If Not @error Then
250
   Send("{ESCAPE}")
251
   Sleep(100)
252
   Send("{SPACE}") ;close any open windows
253
   Sleep(200)
254
   MouseMove(1,1) ; reset cursor position before checking for button
255
   $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
256
   If $Resume == "400900" Or $Resume == "380900" Then
257
	  Sleep(200)
258
	  MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
259
	  Sleep($loadtime)
260
   EndIf
261
EndIf
262
EndFunc
263
264
Func CheckRepair()
265
$RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
266
   If Not @error Then
267
	  Call("DoRepair")
268
   EndIf
269
$RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
270
   If Not @error Then
271
	  Call("DoRepair")
272
   EndIf
273
EndFunc
274
275
Func DoRepair()
276
Sleep(100)
277
Send("t")
278
Sleep($tptime)
279
MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
280
Sleep(1500)
281
MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
282
Sleep(1500)
283
MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
284
Sleep(1200)
285
MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
286
Sleep(400)
287
MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
288
Sleep(200)
289
Call("CheckDead")
290
If Not $Dead and Not $Logout Then
291
   Send("{ESCAPE}") ;closes repair tab
292
   Sleep(100)
293
   Send("{ESCAPE}") ;menu
294
   Sleep(10)
295
   MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
296
   Sleep($loadtime)
297
   MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
298
   Sleep($loadtime)
299
EndIf
300
EndFunc
301
302
Func CheckLoot()
303
MouseMove(14,14,0)
304
Sleep(Random(500,2000))
305
If Not $ImgLoot Then
306
   $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
307
   If Not @error Then
308
	  MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
309
	  Sleep(Random(1000,1200))
310
	  MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
311
	  $i+= 1
312
	  If $i <= 6 Then
313
		 Call("CheckLoot")
314
	  EndIf
315
   EndIf
316
   $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
317
   If Not @error Then
318
	  MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
319
	  Sleep(Random(1000,1200))
320
	  MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
321
	  $i+= 1
322
	  If $i <= 6 Then
323
		 Call("CheckLoot")
324
	  EndIf
325
   EndIf
326
   If $LootRares Then
327
	  $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
328
	  If Not @error Then
329
		 MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
330
		 Sleep(Random(1000,1200))
331
		 MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
332
		 $i+= 1
333
		 If $i <= 6 Then
334
			Call("CheckLoot")
335
		 EndIf
336
	  EndIf
337
   EndIf
338
Else
339
   Call("pickItems")
340
EndIf
341
EndFunc
342
343
Func pickItems()
344
$currentArrayItem = 0
345
For $gI = 0 to ($totalItems - 1)
346
   $array = StringSplit($pick[$gI],"|")
347
   $file = $array[1]
348
   $accuracy = $array[2]
349
   $urlString = $directory & $file
350
   $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
351
   While $i <= 12 ; max: 13 gems and pieces of gear to loot
352
	  If $Target And ($gX > 15) And ($gY > 15) Then
353
		 ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
354
		 MouseClick("left", $gX, $gY, 1, 0)
355
		 Sleep(Random(1200,1400))
356
		 MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
357
		 Sleep(5)
358
		 $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
359
		 $i+= 1
360
	  Else
361
		 ExitLoop
362
	  EndIf
363
   WEnd
364
Next
365
EndFunc
366
367
Func RandomSleep()
368
   If $Timer And Random(1,20) = 20 Then
369
	  Sleep(Random(30000,60000)
370
   EndIf
371
EndFunc
372
373
Func Pause()
374
   $Leave = False
375
EndFunc
376
377
Func Stop() ;to allow the script to stop
378
    Exit
379
EndFunc 
380
 
381
Func Leave()
382
   $Leave = True
383
EndFunc