Advertisement
Guest User

Untitled

a guest
Jun 13th, 2012
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.52 KB | None | 0 0
  1. #include <ImageSearch.au3>
  2. #include <File.au3>
  3. Global $Paused
  4. Global $ingamewait
  5. Global $wintitle="Diablo III"
  6. Global $winhandle=Wingethandle($wintitle)
  7. Opt('MouseCoordMode', 2)
  8. Opt('PixelCoordMode', 2)
  9.  
  10. HotKeySet("=","Leave") ;script started by pressing =
  11. HotKeySet("-", "Pause") ;script paused by pressing -
  12. HotKeySet("x", "Stop") ;script stopped by pressing x
  13. $go = True
  14. $default_resolutionX = 1920
  15. $default_resolutionY = 1080
  16. $x_ratio = @Desktopwidth / $default_resolutionX
  17. $y_ratio = @Desktopheight / $default_resolutionY
  18.  
  19. ;ImageSearch Looting Variables
  20. $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
  21. $directory = "D:\gry\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  22. $totalItems = 17 ; This needs to match the number of pngs you are loading
  23. Global $pick[$totalItems]
  24. $currentArrayItem = 0
  25. $gX = 0
  26. $gY = 0
  27. $gX0 = 0
  28. $gY0 = 0
  29.  
  30. $pick[0] = "uare.png|40"
  31. $pick[1] = "tome.png|40"
  32. $pick[2] = "legendaryA.png|20"
  33. $pick[3] = "legendaryE.png|20"
  34. $pick[4] = "legendaryI.png|10"
  35. $pick[5] = "legendaryO.png|20"
  36. $pick[6] = "legendaryU.png|20"
  37. $pick[7] = "setA.png|30"
  38. $pick[8] = "setE.png|30"
  39. $pick[9] = "setU.png|30"
  40. $pick[10] = "setO.png|30"
  41. $pick[11] = "setI.png|30"
  42. $pick[12] = "rareA.png|20" ; comment/delete these and adjust $totalItems to disable rare looting
  43. $pick[13] = "rareE.png|20"
  44. $pick[14] = "rareI.png|20"
  45. $pick[15] = "rareO.png|20"
  46. $pick[16] = "rareU.png|20" ; end comment
  47.  
  48. $LootGems = False ; Old Methods set to true if you don't want to use imagesearch
  49. $LootRares = True ; Old Methods set to true if you don't want to use imagesearch
  50.  
  51.  
  52. $Amethyst = 0xAC7FFF
  53. $Ruby = 0xB01D2D
  54. $Emerald = 0x58EE33
  55. $Topaz = 0xFFFF59
  56. $yellow = 0xFFF000 ; yellow color code (repair icon)
  57. $red = 0xD90000 ; red color code (repair icon)
  58.  
  59. $Timer = false ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  60. $walktime = 3600 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  61. $loadtime = 4500 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  62. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  63.  
  64. $Leave = False
  65. $Dead = False
  66. $Window = False
  67. $Logout = False
  68. $i = 0
  69.  
  70. $Sarkothkill=Iniread("Sarkoth.ini","Misc","Sarkothkill",0)
  71. $Sarkothnotfound=Iniread("Sarkoth.ini","Misc","Sarkothnotfound",0)
  72. $Died=Iniread("Sarkoth.ini","Misc","Died",0)
  73.  
  74.  
  75. Call("RestartRun")
  76. Func RestartRun()
  77. While $go
  78. if($Leave) Then
  79. $i = 0
  80. Call("CheckExit")
  81. Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
  82. Call("CheckDead")
  83. Call("CheckRepair")
  84. If $Window Then
  85. Call("InputReqScrn")
  86. $Window = False
  87. ExitLoop
  88. ElseIf $Dead or $Logout Then
  89. ExitLoop
  90. EndIf
  91. MouseClick("middle", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  92. Send("4")
  93. Sleep(140)
  94. Send("4")
  95. Sleep(140)
  96. Send("4")
  97. Sleep(140)
  98. Send("4")
  99. Sleep(80)
  100. Send("4")
  101. Sleep(80)
  102. Send("4")
  103. Sleep(80)
  104. Send("4")
  105. Sleep(80)
  106. Send("4")
  107. Sleep(80)
  108. Send("4")
  109. sleep(80)
  110. Send("3")
  111. Sleep(300)
  112. MouseMove(Round(290*$x_ratio),Round(270*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  113. Sleep(700)
  114. Sleep(250)
  115. Call("CheckDead")
  116. If $Window Then
  117. Call("InputReqScrn")
  118. $Window = False
  119. ExitLoop
  120. ElseIf $Dead or $Logout Then
  121. ExitLoop
  122. EndIf
  123. $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)
  124. If Not @error Then
  125. Send("2")
  126. sleep(80)
  127. MouseClick("left",Round(290*$x_ratio),Round(270*$y_ratio)) ;Entrance to cellar
  128. Cellarwait()
  129. Send(1)
  130. Sleep(200)
  131. Send(2)
  132. Sleep(200)
  133. MouseClick("middle",Round(40*$x_ratio),Round(797*$y_ratio)) ;moves to doorway leading to rare inside cellar
  134. Sleep(3100)
  135. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  136. Sleep(100)
  137. Send("{SHIFTDOWN}")
  138. MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio))
  139. Sleep(200)
  140. MouseClick("right",Round(440*$x_ratio),Round(80*$y_ratio))
  141. Sleep(150)
  142. MouseDown("right") ;attack middle
  143. Sleep(3700)
  144. MouseUP("right")
  145. Send("{SHIFTUP}")
  146. Sleep(400)
  147. MouseClick("middle",Round(564*$x_ratio),Round(222*$y_ratio)) ;location of sarkoth after death
  148. Sleep(1500)
  149. MouseClick("middle",Round(1320*$x_ratio),Round(315*$y_ratio)) ;move to right top corner for gold
  150. Sleep(700)
  151. MouseClick("middle",Round(880*$x_ratio),Round(748*$y_ratio)) ;move to middle before looting
  152. Sleep(600)
  153. Call("CheckLoot")
  154. Send("t")
  155. Sleep($tptime)
  156. Call("RandomSleep")
  157. Call("CheckDead")
  158. If Not $Logout And Not $Dead And Not $Window Then
  159. Sleep(300)
  160. Send("{ESCAPE}") ;menu
  161. Sleep(200)
  162. _FileWriteLog("Botlog.txt", "Sarkoth down")
  163. $Sarkothkill=$Sarkothkill+1
  164. IniWrite("Sarkoth.ini","Misc","Sarkothkill",$Sarkothkill)
  165. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  166. Sleep($loadtime)
  167. Call("CheckDead")
  168. If Not $Logout Then
  169. Call("InputReqScrn")
  170. EndIf
  171. Else
  172. Call("InputReqScrn")
  173. $Window = False ; reset the flag so it doesn't think a window is always up
  174. EndIf
  175. Else
  176. mousemove(962,518,1)
  177. Send("3")
  178. Sleep(620)
  179. send("2")
  180. Sleep(400)
  181. send("{SHIFTDOWN}")
  182. sleep(200)
  183. Mouseclick("left")
  184. sleep(300)
  185. send("{SHIFTUP}")
  186. sleep(400)
  187. Send("t")
  188. Sleep($tptime)
  189. Call("CheckDead")
  190. Call("RandomSleep")
  191. _FileWriteLog("Botlog.txt", "Sarkoth not found")
  192. $Sarkothnotfound=$Sarkothnotfound+1
  193. IniWrite("Sarkoth.ini","Misc","Sarkothnotfound",$Sarkothnotfound)
  194. If Not $Logout And Not $Dead And Not $Window Then
  195. Sleep(300)
  196. Send("{ESCAPE}") ;menu
  197. Sleep(200)
  198. Call("CheckDead")
  199. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  200. Sleep($loadtime)
  201. Call("CheckDead")
  202. If Not $Logout Then
  203. Call("InputReqScrn")
  204. EndIf
  205. Else
  206. Call("InputReqScrn")
  207. $Window = False ; reset the flag so it doesn't think a window is always up
  208. EndIf
  209.  
  210. EndIf
  211. EndIf
  212. WEnd
  213. Call("InputReqScrn")
  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. _FileWriteLog("Botlog.txt", "Oh my you have died")
  223. $Died=$Died+1
  224. IniWrite("Sarkoth.ini","Misc","Died",$Died)
  225. Sleep(100)
  226. Send("{Escape}")
  227. Sleep(10)
  228. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  229. Sleep(11000)
  230. Call("InputReqScrn")
  231. Else
  232. Call("InputReqScrn")
  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. Call("InputReqScrn")
  247. Else
  248. Call("InputReqScrn")
  249. $Logout = False
  250. EndIf
  251. Else
  252. $Logout = False
  253. EndIf
  254. EndFunc
  255.  
  256. Func CheckWindow()
  257. $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
  258. If Not @error Then
  259. Sleep(200)
  260. Send("{SPACE}") ;close any open windows
  261. $Window = True
  262. Else
  263. $Window = False
  264. EndIf
  265. EndFunc
  266.  
  267. Func CheckExit()
  268. $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
  269. If Not @error Then
  270. Send("{ESCAPE}")
  271. Sleep(100)
  272. Send("{SPACE}") ;close any open windows
  273. Sleep(200)
  274. MouseMove(1,1) ; reset cursor position before checking for button
  275. $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  276. If $Resume == "400900" Or $Resume == "380900" Then
  277. Sleep(200)
  278. Call("InputReqScrn")
  279. EndIf
  280. EndIf
  281. EndFunc
  282.  
  283. Func CheckRepair()
  284. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  285. If Not @error Then
  286. Call("DoRepair")
  287. EndIf
  288. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  289. If Not @error Then
  290. Call("DoRepair")
  291. EndIf
  292. EndFunc
  293.  
  294. Func DoRepair()
  295. Sleep(100)
  296. Send("t")
  297. Sleep($tptime)
  298. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  299. Sleep(1900)
  300. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  301. Sleep(1900)
  302. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  303. Sleep(1200)
  304. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  305. Sleep(400)
  306. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  307. Sleep(200)
  308. Call("CheckDead")
  309. If Not $Dead and Not $Logout Then
  310. Send("{ESCAPE}") ;closes repair tab
  311. Sleep(100)
  312. Send("{ESCAPE}") ;menu
  313. Sleep(10)
  314. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  315. Sleep($loadtime)
  316. Call("InputReqScrn")
  317. EndIf
  318. EndFunc
  319.  
  320. Func CheckLoot()
  321. Sleep(Random(500,2000))
  322. $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  323. If Not @error Then
  324. MouseClick ('left', $SetLoot[0], $SetLoot[1])
  325. Sleep(Random(800,1200))
  326. $i+= 1
  327. If $i <= 6 Then
  328. Call("CheckLoot")
  329. EndIf
  330. EndIf
  331. If $LootRares Then
  332. $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  333. If Not @error Then
  334. MouseClick ('left', $RareLoot[0], $RareLoot[1])
  335. Sleep(Random(700,900))
  336. $i+= 1
  337. If $i <= 6 Then
  338. Call("CheckLoot")
  339. EndIf
  340. EndIf
  341. Else
  342. Call("pickItems")
  343. EndIf
  344.  
  345. If $LootGems Then
  346. $AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
  347. If Not @error Then
  348. MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
  349. Sleep(Random(900,1400))
  350. $i+= 1
  351. If $i <= 10 Then
  352. Call("CheckLoot")
  353. EndIf
  354. EndIf
  355. $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
  356. If Not @error Then
  357. MouseClick("left", $RubyDrop[0], $RubyDrop[1])
  358. Sleep(Random(900,1400))
  359. $i+= 1
  360. If $i <= 10 Then
  361. Call("CheckLoot")
  362. EndIf
  363. EndIf
  364. $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
  365. If Not @error Then
  366. MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
  367. Sleep(Random(900,1400))
  368. $i+= 1
  369. If $i <= 10 Then
  370. Call("CheckLoot")
  371. EndIf
  372. EndIf
  373. $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
  374. If Not 1 = 1 Then ; change to 'If Not @error Then' if you want to search for topazes
  375. MouseClick("left", $TopazDrop[0], $TopazDrop[1])
  376. Sleep(Random(900,1400))
  377. $i+= 1
  378. If $i <= 10 Then
  379. Call("CheckLoot")
  380. EndIf
  381. EndIf
  382. EndIf
  383. EndFunc
  384.  
  385.  
  386.  
  387. Func pickItems()
  388. $currentArrayItem = 0
  389. For $gI = 0 to ($totalItems - 1)
  390. $array = StringSplit($pick[$gI],"|")
  391. $file = $array[1]
  392. $accuracy = $array[2]
  393. $urlString = $directory & $file
  394. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  395. While $i <= 12 ; max: 13 gems and pieces of gear to loot
  396. If $Target And ($gX > 15) And ($gY > 15) Then
  397. ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  398. MouseClick("left", $gX, $gY, 1, 0)
  399. Sleep(Random(1200,1400))
  400. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  401. Sleep(5)
  402. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  403. $i+= 1
  404. Else
  405. ExitLoop
  406. EndIf
  407. WEnd
  408. Next
  409. EndFunc
  410.  
  411.  
  412. Func InputReqScrn()
  413. Menuwait()
  414. MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
  415. Ingamewait()
  416. $Target = _ImageSearchArea($directory & "InputReq.png",1,0,0,@DesktopHeight,@DesktopWidth,$gX0,$gY0,0)
  417. If $Target And ($gX > 15) And ($gY > 15) Then
  418. sleep(1500)
  419. MouseClick("Left",959,632)
  420. Sleep(Random(1500000,300000))
  421. MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
  422. $gX0 = 0
  423. $gY0 = 0
  424. Ingamewait()
  425. EndIf
  426. EndFunc
  427.  
  428. Func Menuwait()
  429. $menuwait=0
  430. Do
  431. sleep(100)
  432. $menuwait=$menuwait+1
  433. PixelSearch(1630*$x_ratio ,990*$y_ratio, 1660*$x_ratio ,1030*$y_ratio, 0xAF681B, 20, 1, $winhandle) ; this function waits for that helmet button to appear on the lower right of the main menu
  434. Until (Not @Error OR $menuwait=100)
  435.  
  436. If $menuwait=100 Then
  437. send("{ESC}")
  438. sleep(2000)
  439. send("{ESC}")
  440. $menuwait=0
  441. EndIf
  442.  
  443. $menuwait=0
  444.  
  445. sleep(100)
  446. EndFunc
  447.  
  448. Func Ingamewait()
  449. Do
  450. sleep(100)
  451. $ingamewait=$ingamewait+1
  452. PixelSearch(1100*$x_ratio ,1000*$y_ratio,1140*$x_ratio ,1060*$y_ratio, 0x426AFA, 20, 1, $winhandle) ; this function waits until the blue townportalbutton appears to recognize that we are ingame
  453. Until (Not @Error OR $ingamewait=100)
  454. $ingamewait=0
  455. sleep(200)
  456. EndFunc
  457.  
  458.  
  459.  
  460. Func Cellarwait()
  461. $menuwait=0
  462. Do
  463. sleep(100)
  464. $menuwait=$menuwait+1
  465. PixelSearch(811*$x_ratio ,222*$y_ratio, 900*$x_ratio ,320*$y_ratio, 0xFDFD34, 40, 1, $winhandle) ; This function waits until the light of the lamp next to the entrance appears
  466. Until (Not @Error OR $menuwait=100)
  467.  
  468. $menuwait=0
  469. EndFunc
  470.  
  471.  
  472. Func RandomSleep()
  473. if ($timer) then
  474. Sleep(Random(2000,240000))
  475. EndIf
  476. EndFunc
  477.  
  478. Func Pause()
  479. $Leave = False
  480. EndFunc
  481.  
  482. Func Stop() ;to allow the script to stop
  483. Exit
  484. EndFunc
  485.  
  486. Func Leave()
  487. $Leave = True
  488. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement