Guest User

baba123

a guest
Jun 13th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.76 KB | None | 0 0
  1. ;IF YOU PLAN TO USE IMAGESEARCH FUNCTIONS:
  2. ;Download: http://www.mediafire.com/?vtx9l1woj61h8r6 (1.4a new link)
  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.  
  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 = False ; 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 = 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|50"
  36. $pick[1] = "legendaryE.png|50"
  37. $pick[2] = "legendaryI.png|10"
  38. $pick[3] = "legendaryO.png|50"
  39. $pick[4] = "legendaryU.png|50"
  40. $pick[5] = "setA.png|50"
  41. $pick[6] = "setE.png|50"
  42. $pick[7] = "setU.png|50"
  43. $pick[8] = "setO.png|50"
  44. $pick[9] = "setI.png|50"
  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] = "uare.png|50"
  51. $pick[16] = "tome.png|50"
  52.  
  53. $LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
  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 = 3600 ; 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(1390)
  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(3300)
  88. MouseMove(Round(360*$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(360*$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(1000)
  112. Send("2")
  113. Sleep(120)
  114. Send("3")
  115. Sleep(140)
  116. Send("4")
  117. Sleep(140)
  118. Send("4")
  119. Sleep(140)
  120. Send("4")
  121. Sleep(1400)
  122. MouseClick("middle",Round(750*$x_ratio),Round(555*$y_ratio)) ;move to left top corner for gold
  123. Sleep(900)
  124. MouseClick("middle",Round(1175*$x_ratio),Round(350*$y_ratio)) ;move to right top corner for gold
  125. Sleep(900)
  126. MouseClick("middle",Round(1020*$x_ratio),Round(773*$y_ratio)) ;move to middle before looting
  127. Sleep(900)
  128. MouseClick("middle",Round(1020*$x_ratio),Round(773*$y_ratio)) ;move to middle before looting
  129. Sleep(900)
  130. MouseClick("middle",Round(1175*$x_ratio),Round(350*$y_ratio)) ;move to right top corner for gold
  131. Sleep(900)
  132. Call("CheckLoot")
  133. Send("t")
  134. Sleep($tptime)
  135. Call("RandomSleep")
  136. Call("CheckDead")
  137. If Not $Logout And Not $Dead And Not $Window Then
  138. Sleep(300)
  139. Send("{ESCAPE}") ;menu
  140. Sleep(200)
  141. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  142. Sleep($loadtime)
  143. Call("CheckDead")
  144. If Not $Logout Then
  145. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  146. Sleep($loadtime)
  147. EndIf
  148. Else
  149. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  150. Sleep($loadtime)
  151. $Window = False ; reset the flag so it doesn't think a window is always up
  152. EndIf
  153. Else
  154. MouseClick("right",Round(0*$x_ratio),Round(0*$y_ratio))
  155. Sleep(400)
  156. Send("3")
  157. Sleep(120)
  158. Send("3")
  159. Sleep(120)
  160. Send("3")
  161. Sleep(620)
  162. Send("t")
  163. Sleep($tptime)
  164. Call("CheckDead")
  165. Call("RandomSleep")
  166. Call("CheckDead")
  167. If Not $Logout And Not $Dead And Not $Window Then
  168. Sleep(300)
  169. Send("{ESCAPE}") ;menu
  170. Sleep(200)
  171. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  172. Sleep($loadtime)
  173. Call("CheckDead")
  174. If Not $Logout Then
  175. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  176. Sleep($loadtime)
  177. EndIf
  178. Else
  179. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  180. Sleep($loadtime)
  181. $Window = False ; reset the flag so it doesn't think a window is always up
  182. EndIf
  183. EndIf
  184. EndIf
  185. WEnd
  186. Call("RestartRun")
  187. EndFunc
  188.  
  189. Func CheckDead()
  190. Call("CheckWindow")
  191. $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"
  192. If Not @error Then
  193. If Not $Window Then
  194. $Dead = True
  195. Sleep(100)
  196. Send("{Escape}")
  197. Sleep(10)
  198. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  199. Sleep(11000)
  200. Sleep($loadtime)
  201. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  202. Sleep($loadtime)
  203. Else
  204. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  205. Sleep($loadtime)
  206. $Dead = False
  207. EndIf
  208. Else
  209. $Dead = False
  210. EndIf
  211. $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
  212. If Not @error Then
  213. Sleep(11000)
  214. Sleep($loadtime)
  215. If Not $Window Then
  216. $Dead = True
  217. $Logout = True
  218. Sleep($loadtime)
  219. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  220. Sleep($loadtime)
  221. Else
  222. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  223. Sleep($loadtime)
  224. $Logout = False
  225. EndIf
  226. Else
  227. $Logout = False
  228. EndIf
  229. EndFunc
  230.  
  231. Func CheckWindow()
  232. $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
  233. If Not @error Then
  234. Sleep(200)
  235. Send("{SPACE}") ;close any open windows
  236. $Window = True
  237. Else
  238. $Window = False
  239. EndIf
  240. EndFunc
  241.  
  242. Func CheckExit()
  243. $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
  244. If Not @error Then
  245. Send("{ESCAPE}")
  246. Sleep(100)
  247. Send("{SPACE}") ;close any open windows
  248. Sleep(200)
  249. MouseMove(1,1) ; reset cursor position before checking for button
  250. $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  251. If $Resume == "400900" Or $Resume == "380900" Then
  252. Sleep(200)
  253. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  254. Sleep($loadtime)
  255. EndIf
  256. EndIf
  257. EndFunc
  258.  
  259. Func CheckRepair()
  260. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  261. If Not @error Then
  262. Call("DoRepair")
  263. EndIf
  264. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  265. If Not @error Then
  266. Call("DoRepair")
  267. EndIf
  268. EndFunc
  269.  
  270. Func DoRepair()
  271. Sleep(100)
  272. Send("t")
  273. Sleep($tptime)
  274. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  275. Sleep(1500)
  276. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  277. Sleep(1500)
  278. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  279. Sleep(1200)
  280. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  281. Sleep(400)
  282. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  283. Sleep(200)
  284. Call("CheckDead")
  285. If Not $Dead and Not $Logout Then
  286. Send("{ESCAPE}") ;closes repair tab
  287. Sleep(100)
  288. Send("{ESCAPE}") ;menu
  289. Sleep(10)
  290. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  291. Sleep($loadtime)
  292. MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  293. Sleep($loadtime)
  294. EndIf
  295. EndFunc
  296.  
  297. Func CheckLoot()
  298. MouseMove(14,14,0)
  299. Sleep(Random(500,2000))
  300. If Not $ImgLoot Then
  301. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  302. If Not @error Then
  303. MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
  304. Sleep(Random(1000,1200))
  305. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  306. $i+= 1
  307. If $i <= 6 Then
  308. Call("CheckLoot")
  309. EndIf
  310. EndIf
  311. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  312. If Not @error Then
  313. MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
  314. Sleep(Random(1000,1200))
  315. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  316. $i+= 1
  317. If $i <= 6 Then
  318. Call("CheckLoot")
  319. EndIf
  320. EndIf
  321. If $LootRares Then
  322. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  323. If Not @error Then
  324. MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
  325. Sleep(Random(1000,1200))
  326. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  327. $i+= 1
  328. If $i <= 6 Then
  329. Call("CheckLoot")
  330. EndIf
  331. EndIf
  332. EndIf
  333. Else
  334. Call("pickItems")
  335. EndIf
  336. EndFunc
  337.  
  338. Func pickItems()
  339. $currentArrayItem = 0
  340. For $gI = 0 to ($totalItems - 1)
  341. $array = StringSplit($pick[$gI],"|")
  342. $file = $array[1]
  343. $accuracy = $array[2]
  344. $urlString = $directory & $file
  345. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  346. While $i <= 12 ; max: 13 gems and pieces of gear to loot
  347. If $Target And ($gX > 15) And ($gY > 15) Then
  348. ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  349. MouseClick("left", $gX, $gY, 1, 0)
  350. Sleep(Random(1200,1400))
  351. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  352. Sleep(5)
  353. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  354. $i+= 1
  355. Else
  356. ExitLoop
  357. EndIf
  358. WEnd
  359. Next
  360. EndFunc
  361.  
  362. Func RandomSleep()
  363. If $Timer And Random(1,20) <= 2 Then
  364. Sleep(Random(15000,30000))
  365. EndIf
  366. EndFunc
  367.  
  368. Func Pause()
  369. $Leave = False
  370. EndFunc
  371.  
  372. Func Stop() ;to allow the script to stop
  373. Exit
  374. EndFunc
  375.  
  376. Func Leave()
  377. $Leave = True
  378. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment