Advertisement
Guest User

trav123

a guest
Jun 12th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.46 KB | None | 0 0
  1. ; Script Start - Add your code below here
  2.  
  3. ;notAres' Sarkoth DH Gold Script 1.3a - 6/9/2012 - Holy shit look how beautiful this code is. Utilized ExitLoop to perfect the efficiency when dead/logging out/in need of repair
  4. ;Thread: http://ownedcore.com/forums/diablo-3/diablo-3-bots-programs/354464-goldfarming-notares-sarkarth-dh-gold-script-autoit-script-1920x1080.html
  5. ;Please notice I changed some variable names around and added a variable for teleport time. $waittime is now appropriately named $loadtime.
  6. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  7. ;Required build: http://us.battle.net/d3/en/calculator/demon-hunter#aRYXVT!aTW!YcaZbY
  8. ;Required movement speed: 25% (10% boots + 15% passive 'Hot Pursuit')
  9. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  10. ;Official supported resolution: 1920x1080
  11. ;;;;;
  12. ;Features:
  13. ;Loot scanning. Will only pick up rare/legendary/set pieces [IMPROVED]
  14. ;Randomized aiming coordinates (but still static path)
  15. ;Randomized pickup timers for variation in runs
  16. ;Automatic repair on yellow status icon
  17. ;Automatic resolution adjustment (16:9 only) [BUGGY - need someone to tweak coords]
  18. ;Death check
  19. ;Open window check (in rare case it gets stuck in menu)
  20. ;;;;;
  21. ;Original:
  22. ;[Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  23.  
  24. Global $Paused
  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. $walktime = 3000 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  30. $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  31. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  32. $yellow = 0xFFF000 ; yellow color code (repair icon)
  33. $red = 0xD90000 ; red color code (repair icon)
  34.  
  35. $LootRares = True ; Change this to false if you don't want the bot to pick up rares (good for legendary/set only, recommend setting LootGems to False)
  36. $LootGems = False ; Change this to true if you want to pick up gems (messy, can fill up bag with whites/blues)
  37. $Amethyst = 0xAC7FFF
  38. $Ruby = 0xB01D2D
  39. $Emerald = 0x58EE33
  40. $Topaz = 0xFFFF59
  41.  
  42. $go = True
  43. $Leave = False
  44. $Dead = False
  45. $Logout = False
  46. $Window = False
  47. $default_resolutionX = 1920
  48. $default_resolutionY = 1080
  49. $x_ratio = @Desktopwidth / $default_resolutionX
  50. $y_ratio = @Desktopheight / $default_resolutionY
  51. $i = 0
  52.  
  53. Call("RestartRun")
  54.  
  55. Func RestartRun()
  56. While $go
  57. if($Leave) Then
  58. $i = 0
  59. Sleep(1000) ;had to add this since the icon doesn't show up RIGHT away in game
  60. Call("CheckDead")
  61. Call("CheckRepair")
  62. If $Window Then
  63. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  64. Sleep($loadtime)
  65. $Window = False
  66. ExitLoop
  67. ElseIf $Dead or $Logout Then
  68. ExitLoop
  69. EndIf
  70. MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  71. Send("4")
  72. Sleep(140)
  73. Send("4")
  74. Sleep(140)
  75. Send("4")
  76. Sleep(140)
  77. Send("4")
  78. Sleep(80)
  79. Send("4")
  80. Sleep(80)
  81. Send("4")
  82. Sleep(80)
  83. Send("4")
  84. Sleep(80)
  85. Send("4")
  86. Sleep(80)
  87. Send("1")
  88. Send("3")
  89. Sleep(800)
  90. MouseMove(Round(290*$x_ratio),Round(270*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  91. Sleep(700)
  92. Call("CheckDead")
  93. If $Window Then
  94. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  95. Sleep($loadtime)
  96. $Window = False
  97. ExitLoop
  98. ElseIf $Dead or $Logout Then
  99. ExitLoop
  100. EndIf
  101. $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)
  102. If Not @error Then
  103. MouseClick("left",Round(290*$x_ratio),Round(270*$y_ratio)) ;Entrance to cellar
  104. Sleep(400)
  105.  
  106. Sleep($walktime)
  107. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  108. Sleep(2500)
  109. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  110. Sleep(10)
  111. Send("{SHIFTDOWN}")
  112. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  113. MouseDown("right") ;attack middle
  114. Sleep(7800)
  115. MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  116. Sleep(10)
  117. Send("{SHIFTUP}")
  118. Sleep(400)
  119. MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  120. Sleep(2100)
  121.  
  122. Call("CheckLoot")
  123. Send("t")
  124. Sleep($tptime)
  125. Call("CheckDead")
  126. If Not $Logout And Not $Dead And Not $Window Then
  127. Sleep(300)
  128. Send("{ESCAPE}") ;menu
  129. Sleep(200)
  130. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  131. Sleep($loadtime)
  132. Call("CheckDead")
  133. If Not $Logout Then
  134. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  135. Sleep($loadtime)
  136. EndIf
  137. Else
  138. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  139. Sleep($loadtime)
  140. $Window = False ; reset the flag so it doesn't think a window is always up
  141. EndIf
  142. Else
  143. Send("2")
  144. Sleep(700)
  145. Send("t")
  146. Sleep($tptime)
  147. Call("CheckDead")
  148. If Not $Logout And Not $Dead And Not $Window Then
  149. Sleep(300)
  150. Send("{ESCAPE}") ;menu
  151. Sleep(200)
  152. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  153. Sleep($loadtime)
  154. Call("CheckDead")
  155. If Not $Logout Then
  156. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  157. Sleep($loadtime)
  158. EndIf
  159. Else
  160. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  161. Sleep($loadtime)
  162. $Window = False ; reset the flag so it doesn't think a window is always up
  163. EndIf
  164. EndIf
  165. EndIf
  166. WEnd
  167. Call("RestartRun")
  168. EndFunc
  169.  
  170. Func CheckDead()
  171. Call("CheckWindow")
  172. $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"
  173. If Not @error Then
  174. If Not $Window Then
  175. $Dead = True
  176. Sleep(100)
  177. Send("{Escape}")
  178. Sleep(10)
  179. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  180. Sleep(11000)
  181. Sleep($loadtime)
  182. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  183. Sleep($loadtime)
  184. Else
  185. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  186. Sleep($loadtime)
  187. $Dead = False
  188. EndIf
  189. Else
  190. $Dead = False
  191. EndIf
  192. $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
  193. If Not @error Then
  194. Sleep(11000)
  195. Sleep($loadtime)
  196. If Not $Window Then
  197. $Dead = True
  198. $Logout = True
  199. Sleep($loadtime)
  200. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  201. Sleep($loadtime)
  202. Else
  203. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  204. Sleep($loadtime)
  205. $Logout = False
  206. EndIf
  207. Else
  208. $Logout = False
  209. EndIf
  210. EndFunc
  211.  
  212. Func CheckWindow()
  213. $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
  214. If Not @error Then
  215. Sleep(200)
  216. Send("{SPACE}") ;close any open windows
  217. $Window = True
  218. Else
  219. $Window = False
  220. EndIf
  221. EndFunc
  222.  
  223. Func CheckRepair()
  224. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  225. If Not @error Then
  226. Call("DoRepair")
  227. EndIf
  228. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  229. If Not @error Then
  230. Call("DoRepair")
  231. EndIf
  232. EndFunc
  233.  
  234. Func DoRepair()
  235. Sleep(100)
  236. Send("t")
  237. Sleep($tptime)
  238. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  239. Sleep(1500)
  240. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  241. Sleep(1500)
  242. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  243. Sleep(1200)
  244. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  245. Sleep(400)
  246. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  247. Sleep(200)
  248. Call("CheckDead")
  249. If Not $Dead and Not $Logout Then
  250. Send("{ESCAPE}") ;closes repair tab
  251. Sleep(100)
  252. Send("{ESCAPE}") ;menu
  253. Sleep(10)
  254. MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  255. Sleep($loadtime)
  256. MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  257. Sleep($loadtime)
  258. EndIf
  259.  
  260. EndFunc
  261. Func MainMenu() ;verifies the screen is at the main menu before attempting to start the next game to avoid getting trapped in menus.
  262. Local $Menu = False
  263. While $Menu = False
  264. $Pixeltestmm = PixelGetColor(Round(251*$x_ratio), Round(284*$y_ratio)) ;tests for main menu
  265. If Hex($Pixeltestmm, 6) == "683C02" Then
  266. $Menu = True
  267. Else
  268. $Pixeltestgm = PixelGetColor(Round(937*$x_ratio), Round(246*$y_ratio)) ;checks if game menu is open
  269. If Hex($Pixeltestgm, 6) == "621610" Then
  270. Send("{Escape}") ;return to main menu
  271. $Menu = True
  272. Else
  273. $Pixeltestgmexit = PixelGetColor(Round(975*$x_ratio), Round(428*$y_ratio)) ;checks if exit game menu is open
  274. If Hex($Pixeltestgmexit, 6) == "FFA300" Then
  275. Send("{Escape}")
  276. Send("{Escape}")
  277. $Menu = True
  278. Else
  279. $Pixeltestbm = PixelGetColor(Round(958*$x_ratio), Round(150*$y_ratio)) ;checks if banner customization window is open
  280. If Hex($Pixeltestbm, 6) == "933618" Then
  281. Send("{Escape}")
  282. $Menu = True
  283. Else
  284. $Pixeltestpm = PixelGetColor(Round(1506*$x_ratio), Round(138*$y_ratio)) ;checks if player window is open
  285. If Hex($Pixeltestpm, 6) == "320c08" Then
  286. Send("{Escape}")
  287. $Menu = True
  288. EndIf
  289. EndIf
  290. EndIf
  291. EndIf
  292. EndIf
  293. WEnd
  294. EndFunc
  295.  
  296.  
  297.  
  298. Func CheckLoot()
  299. Sleep(Random(500,2000))
  300. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  301. If Not @error Then
  302. MouseClick ('left', $SetLoot[0], $SetLoot[1])
  303. Sleep(Random(800,1200))
  304. $i+= 1
  305. If $i <= 6 Then
  306. Call("CheckLoot")
  307. EndIf
  308. EndIf
  309. $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  310. If Not @error Then
  311. MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1])
  312. Sleep(Random(800,1200))
  313. $i+= 1
  314. If $i <= 6 Then
  315. Call("CheckLoot")
  316. EndIf
  317. EndIf
  318. If $LootRares Then
  319. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  320. If Not @error Then
  321. MouseClick ('left', $RareLoot[0], $RareLoot[1])
  322. Sleep(Random(700,900))
  323. $i+= 1
  324. If $i <= 6 Then
  325. Call("CheckLoot")
  326. EndIf
  327. EndIf
  328. EndIf
  329. If $LootGems Then
  330. $AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
  331. If Not @error Then
  332. MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
  333. Sleep(Random(900,1400))
  334. $i+= 1
  335. If $i <= 10 Then
  336. Call("CheckLoot")
  337. EndIf
  338. EndIf
  339. $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
  340. If Not @error Then
  341. MouseClick("left", $RubyDrop[0], $RubyDrop[1])
  342. Sleep(Random(900,1400))
  343. $i+= 1
  344. If $i <= 10 Then
  345. Call("CheckLoot")
  346. EndIf
  347. EndIf
  348. $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
  349. If Not @error Then
  350. MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
  351. Sleep(Random(900,1400))
  352. $i+= 1
  353. If $i <= 10 Then
  354. Call("CheckLoot")
  355. EndIf
  356. EndIf
  357. $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
  358. If Not 1 = 1 Then ; change to 'If Not @error Then' if you want to search for topazes
  359. MouseClick("left", $TopazDrop[0], $TopazDrop[1])
  360. Sleep(Random(900,1400))
  361. $i+= 1
  362. If $i <= 10 Then
  363. Call("CheckLoot")
  364. EndIf
  365. EndIf
  366. EndIf
  367. EndFunc
  368.  
  369. Func Pause()
  370. $Leave = False
  371. EndFunc
  372.  
  373. Func Stop() ;to allow the script to stop
  374. Exit
  375. EndFunc
  376.  
  377. Func Leave()
  378. $Leave = True
  379. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement