Guest User

Adjusted

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