AzEKnightz

Untitled

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