Guest User

Monk gold

a guest
Jun 22nd, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.27 KB | None | 0 0
  1. ;notAres' DH DH Gold Script 1.7d - 6/15/2012 - MOVED TO DROPBOX. UPDATES WILL DOWNLOAD THE WHOLE ZIP NOW!
  2. ;NEW BINDS: Right Control starts the bot. Pause key pauses it. YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  3. ;Thread: http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/d3-gold-profiles/357024-goldfarming-spycs-sarkoth-monk-gold-script-autoit-script-1920x1080-notares.html
  4. ;;;;;
  5. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  6. ;Required build: http://us.battle.net/d3/en/calculator/monk#TbRYjc!abg!cbbaZZ
  7. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  8. ;Official supported resolution: 1920x1080
  9. ;;;;;
  10. ;Original by mackus101 @ ownedcore
  11. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  12. ;Refactoring and additional functions by Shimizoki
  13.  
  14. ;=========== DO NOT TOUCH ===========;
  15. #RequireAdmin
  16. ;#include <ImageSearch.au3> ;NO LONGER INCLUDED! Function added to script. Duh. :)
  17. #include <GUIConstantsEx.au3>
  18. #include <StaticConstants.au3>
  19. #include <WindowsConstants.au3>
  20. Opt('MouseCoordMode', 2)
  21. Opt('PixelCoordMode', 2)
  22. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "1.7dFIX", $Paused, $Go = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000
  23. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  24. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16,"ERROR","Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  25. If $size = 0 Then
  26. MsgBox(16,"Error","Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  27. Exit
  28. EndIf
  29. ;====================================;
  30.  
  31.  
  32. ;============= SETTINGS =============;
  33. HotKeySet("{F1}", "Begin") ;script toggled on/off by pressing F1
  34. HotKeySet("{F2}", "TogglePause") ;script toggle pause by pressing F2
  35. HotKeySet("{F3}", "Stop") ;script stopped by pressing F3
  36.  
  37. ;Change to match your abilities (1-4 by default)z
  38. $skillCaltrops = "1"
  39. $skillSmokeScreen = "2"
  40. $skillPreparation = "3"
  41. $skillCompanion = "4"
  42.  
  43. $movementSpeed = 10 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  44.  
  45. ;Custom Loot
  46. $pngLoc = "C:\pics\" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  47. $totalItems = 1 ;Number of items in the pick array
  48. Global $pick[$totalItems] ;DONT CHANGE THIS
  49.  
  50. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  51. $pick[0] = "mythic.png|40" ;png|Tolerance
  52. ;$pick[1] = "item2.png"
  53. ;$pick[2] = "item3.png"
  54.  
  55. ;Looting
  56. $LootSets = True ;True if you want to pick up Sets
  57. $LootLegendaries = True ;True if you want to pick up Legendaries
  58. $LootRares = True ;True if you want to pick up Rares
  59. $LootMagic = False ;True if you want to pick up Magic
  60. $LootGems = False ;True if you want to pick up Gems
  61. $LootTomes = False ;True if you want to pick up Tome of Secrets
  62. $LootCustom = True ;True if you want to pick up Custom Items (The items in the pick array above)
  63.  
  64. ;Manage Loot
  65. $mLoot = 6 ;Nuber of successful runs until Stash and Vendor
  66. $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  67.  
  68. ;Stashing
  69. $StashLoot = True ;True if you want to store Items in the stash
  70. $StashLegendary = True ;True if you want to store Legendary items in the stash
  71. $StashRare = True ;True if you want to store Rare items in the stash
  72. $StashMagic = False ;True if you want to store Magic items in the stash
  73. $StashTomes = True ;True if you want to store Tomes items in the stash
  74. $StashGems = True ;True if you want to store Gems items in the stash
  75.  
  76. ;Vendoring
  77. $VendorLoot = True ;True if you want to vendor Items
  78. $VendorRare = False ;True if you want to vendor Rares
  79. $VendorMagic = True ;True if you want to vendor Magic
  80.  
  81. ;Variability
  82. $Timer = False ;True and the bot will add random sleep intervals
  83. $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
  84. $loadtime = 3400 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  85. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  86. ;====================================;
  87.  
  88. $x_ratio = $size[0] / 1920
  89. $y_ratio = $size[1] / 1080
  90. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  91. $movementSpeed = 1+($movementSpeed/100)
  92.  
  93. $VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
  94. $oldVersion = IniRead("updater.ini","Version","Version",$ver)
  95. $newVersion = "0.0"
  96.  
  97. #Region ### START Koda GUI section ###
  98. $frmBot = GUICreate("notAres' DH Extension v" & $ver & " - Updating", 280, 121, Round(1540*$x_ratio), Round(920*$y_ratio), -1, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
  99. GUISetBkColor(0xC0C0C0)
  100. $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  101. GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  102. GUICtrlSetColor(-1, 0xFF0000)
  103. $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  104. $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  105. $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  106. $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  107. $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  108. $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  109. GUISetState(@SW_SHOW)
  110. #EndRegion ### END Koda GUI section ###
  111.  
  112. While 1
  113. Call("RestartRun")
  114. WEnd
  115.  
  116. Func RestartRun()
  117. If($Go) Then
  118. $i = 0
  119. ;Checks if the player is in the Main Menu
  120. If Not FileExists($pngLoc & "MainMenu.png") Then
  121. MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  122. Exit
  123. EndIf
  124. WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  125. If CheckFor("MainMenu", "", Round(40*$x_ratio), Round(300*$y_ratio), Round(400*$x_ratio), Round(600*$y_ratio), 8, 100) Then
  126. $run += 1
  127. GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  128. GUICtrlSetData($lblLocation, "Location: Main Menu")
  129. GUICtrlSetData($lblStatus, "Status: Starting Game")
  130. While True
  131. RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120, 20) ;Random Click on the resume button
  132. If CheckFor("LimitError", "", Round(720*$x_ratio), Round(480*$y_ratio), Round(960*$x_ratio), Round(600*$y_ratio), 3, 60) Then
  133. Sleep(Random(1000, 2000))
  134. RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
  135. $rand = Random(40000, 80000)
  136. GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand/1000) & " seconds.")
  137. Sleep($rand)
  138. Else
  139. ExitLoop
  140. EndIf
  141. WEnd
  142. $rt = TimerInit()
  143. ElseIf Call("CheckDead") Then
  144. GUICtrlSetData($lblStatus, "Status: Dead")
  145. Return
  146. ElseIf CheckFor("ExitGame", "", Round(700*$x_ratio), Round(340*$y_ratio), Round(1200*$x_ratio), Round(500*$y_ratio), 3, 60) Then
  147. GUICtrlSetData($lblStatus, "Status: Exit window up")
  148. MouseClick("left", Round(1064*$x_ratio), Round(632*$y_ratio))
  149. Sleep(100)
  150. Send("{SPACE}")
  151. Return
  152. Else
  153. GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  154. Return
  155. EndIf
  156. If CheckFor("OldRuins", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  157. GUICtrlSetData($lblLocation, "Location: Old Ruins")
  158. ;Check if player needs to repair
  159. Call("CheckRepair")
  160. ;Start Run
  161. MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  162. Send("{4 DOWN}")
  163. Sleep(3500)
  164. Send("{4 UP}")
  165. Sleep(100)
  166. MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  167. Sleep(790)
  168. If Call("CheckDead") Then
  169. Return
  170. EndIf
  171.  
  172. ;Checks if Dank Cellar is Open
  173. $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  174. If Not @error Then
  175. GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  176. MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
  177. Moving(650)
  178. Send(3)
  179. Moving($walktime)
  180. Else ;ABORT RUN
  181. GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  182. Sleep(10)
  183. RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  184. Moving(250)
  185. Send($skillCaltrops)
  186. Sleep(620)
  187. Send($skillSmokeScreen)
  188. Sleep(40)
  189. Call("TownPortal")
  190. If Not Call("CheckDead") Then
  191. Call("LeaveGame")
  192. EndIf
  193. Return
  194. EndIf
  195. Else
  196. Call("TownPortal")
  197. If Not Call("CheckDead") Then
  198. Call("LeaveGame")
  199. EndIf
  200. Return
  201. EndIf
  202.  
  203. ;Checks that the player is in the Dank Cellar
  204. If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  205. GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  206. MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  207. Sleep(Random(2200, 2800))
  208. Send(3)
  209. Sleep(30)
  210. MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
  211. Sleep(2100)
  212. Send("{SHIFTDOWN}")
  213. Sleep(10)
  214. GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  215. MouseClick("left")
  216. Sleep(10)
  217. Send(2)
  218. Sleep(10)
  219. MouseDown("right") ;attack middle
  220. Sleep(8000)
  221. MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  222. Sleep(100)
  223. Send("{SHIFTUP}")
  224. Sleep(10)
  225. GUICtrlSetData($lblStatus, "Status: Looting")
  226. MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  227. Sleep(1100)
  228. MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  229. Sleep(1100)
  230. MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
  231. Call("Loot")
  232. RandSleep(1, 6)
  233. Call("TownPortal")
  234. Call("CheckDead")
  235. Else
  236. Send($skillCaltrops)
  237. Sleep(620)
  238. Send($skillSmokeScreen)
  239. Sleep(40)
  240. Call("TownPortal")
  241. If Not Call("CheckDead") Then
  242. Call("LeaveGame")
  243. EndIf
  244. EndIf
  245.  
  246. ;After successful run
  247. If Not Call("CheckDead") Then
  248. Sleep(600)
  249. If $mLootIn == 1 And CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then ;If its time to manage loot and we are in town
  250. If $StashLoot or $VendorLoot Then
  251. Call("Identify")
  252. EndIf
  253. If $StashLoot Then
  254. Call("StashLoot")
  255. EndIf
  256. If $VendorLoot Then
  257. Call("VendorLoot")
  258. EndIf
  259. $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  260. ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  261. GUICtrlSetData($lblStatus, "Status: Skipping vendor")
  262. Sleep(1000)
  263. Else
  264. $mLootIn -= 1
  265. EndIf
  266. If Not Call("CheckDead") Then
  267. Call("LeaveGame")
  268. EndIf
  269. Return
  270. Else
  271. Return
  272. EndIf
  273. EndIf
  274. EndFunc
  275.  
  276. ;Helper Functions
  277. Func CheckDead()
  278. $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
  279. If Not @error Then
  280. GUICtrlSetData($lblStatus, "Status: Logging out")
  281. Sleep(11000)
  282. Sleep($loadtime)
  283. Return 1
  284. EndIf
  285.  
  286. $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"
  287. If Not @error Then
  288. GUICtrlSetData($lblStatus, "Status: Dead")
  289. Call("LeaveGame")
  290. Sleep(11000)
  291. Return 1
  292. Else
  293. Return 0
  294. EndIf
  295. EndFunc
  296.  
  297. Func CheckRepair()
  298. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  299. If Not @error Then
  300. Call("DoRepair")
  301. EndIf
  302. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  303. If Not @error Then
  304. Call("DoRepair")
  305. EndIf
  306. EndFunc
  307.  
  308. Func DoRepair()
  309. Sleep(Random(75, 150))
  310. Call("TownPortal")
  311. If Call("CheckDead") Then
  312. Return
  313. EndIf
  314. If CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  315. RandClick("left", Round(1480*$x_ratio),Round(281*$y_ratio),1,1) ;begin movement towards merchant
  316. Moving(1875)
  317. RandClick("left", Round(1316*$x_ratio),Round(206*$y_ratio),1,1) ;moves to get merchant in screen
  318. Moving(1875)
  319. RandClick("left", Round(845*$x_ratio),Round(225*$y_ratio),1,1) ;NPC Merchant to the right of cain's home
  320. Sleep(1200)
  321. RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  322. Sleep(400)
  323. RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  324. Sleep(200)
  325. Send("{Escape}")
  326. If Not Call("CheckDead") Then
  327. Call("LeaveGame")
  328. EndIf
  329. EndIf
  330. EndFunc
  331.  
  332. Func CalcTime()
  333. $srt = TimerDiff($rt)
  334. GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt/1000,2) & " seconds.")
  335. $trt = TimerDiff($t)
  336. $total = Round((($trt/1000)/60)/60,4)
  337.  
  338. ;Total runtiume calculation.
  339. $hours = Floor((($trt/1000)/60)/60)
  340. $minutes = (($trt/1000)/60)
  341. ;trim minutes if runtime is more then 1 hour.
  342. If $minutes > 60 Then
  343. While $minutes > 60
  344. $minutes -=60
  345. WEnd
  346. EndIf
  347. GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes")
  348. EndFunc
  349.  
  350. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5 ,$tolerance = 130)
  351. $c = 0
  352. $string = $pngLoc & $img & ".png"
  353. Do
  354. $c +=1
  355. Sleep(100)
  356. If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
  357. If $type = "Area" Then
  358. GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  359. EndIf
  360. Return False
  361. EndIf
  362. Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  363. Return True
  364. EndFunc
  365.  
  366. Func LeaveGame()
  367. Call("RandSleep")
  368. GUICtrlSetData($lblStatus, "Status: Leaving Game")
  369. Sleep(Random(100, 500))
  370. Send("{Escape}")
  371. Sleep(Random(100, 500))
  372. RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120, 20) ;Random Click on the leave button
  373. Call("CalcTime")
  374. EndFunc
  375.  
  376. Func Loot()
  377. Sleep(Random(500,700))
  378. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  379. If $LootSets Then
  380. $SetCount += LootGear(0x02CE01, 2)
  381. EndIf
  382. If $LootLegendaries Then
  383. $LegendaryCount += LootGear(0xBF642F, 0)
  384. EndIf
  385. If $LootRares Then
  386. $RareCount += LootGear(0xBBBB00, 2)
  387. EndIf
  388. If $LootGems Then
  389. Call("LootGems")
  390. EndIf
  391. If $LootTomes Then
  392. Call("LootTomes")
  393. EndIf
  394. If $LootCustom Then
  395. Call("LootCustom")
  396. EndIf
  397. If $LootMagic Then
  398. $MagicCount += LootGear(0x6969FF, 2)
  399. EndIf
  400. Call("ShowLoot")
  401. EndFunc
  402.  
  403. Func LootGear($color, $tolerance = 2)
  404. $count = 0
  405. $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  406. If Not @error Then
  407. While Not @error
  408. $count += 1
  409. MouseClick ('left', $Loot[0], $Loot[1])
  410. Sleep(Random(800,1200))
  411. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  412. ;Run at max 10 times per quality
  413. If $count >= 10 Then
  414. ExitLoop
  415. EndIf
  416. $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance)
  417. WEnd
  418. EndIf
  419. Return $count
  420. EndFunc
  421.  
  422. Func LootCustom()
  423. $count = 0
  424. $gX = 0
  425. $gY = 0
  426. for $i = 0 to ($totalItems - 1)
  427. $array = StringSplit($pick[$i],"|")
  428. $file = $array[1]
  429. $accuracy = $array[2]
  430. $urlString = $pngLoc & $file
  431. While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
  432. $count += 1
  433. Sleep(Random(75, 150))
  434. MouseClick("left",$gX,$gY,1,1)
  435. Sleep(Random(800, 1200))
  436. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  437.  
  438. If $count >= 10 Then
  439. ExitLoop
  440. EndIf
  441. WEnd
  442. next
  443. EndFunc
  444.  
  445. Func LootGems()
  446. $gX = 0
  447. $gY = 0
  448. For $i = 0 to 15
  449. If _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90) Then
  450. Sleep(Random(75, 150))
  451. MouseClick("left",$gX,$gY)
  452. $GemCount += 1
  453. Sleep(Random(800, 1200))
  454. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  455. EndIf
  456. Sleep(200)
  457. Next
  458. EndFunc
  459.  
  460. Func LootTomes()
  461. $gX = 0
  462. $gY = 0
  463. For $i = 0 to 15
  464. If _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90) Then
  465. Sleep(Random(75, 150))
  466. MouseClick("left",$gX,$gY)
  467. $TomeCount += 1
  468. Sleep(Random(800, 1200))
  469. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  470. EndIf
  471. Sleep(200)
  472. Next
  473. EndFunc
  474.  
  475. Func Moving($time)
  476. Sleep($time/$movementSpeed)
  477. EndFunc
  478.  
  479. Func RandClick($clickType, $xPos, $yPos, $xOff = 20, $yOff = 20)
  480. $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  481. $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  482. MouseClick($clickType, $randX, $randY)
  483. EndFunc
  484.  
  485. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 20)
  486. $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  487. $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  488. MouseMove($randX, $randY)
  489. EndFunc
  490.  
  491. Func RandSleep($min = 5, $max = 15, $chance = 2)
  492. $randNum = Round(Random(1, 100))
  493. If $Timer And $randNum <= $chance Then
  494. $sleepTime = Random($min*1000, $max*1000)
  495. GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime/1000) & " secs")
  496.  
  497. For $c = 0 To 10
  498. Sleep($sleepTime/10)
  499. Next
  500. EndIf
  501. EndFunc
  502.  
  503. Func TownPortal()
  504. GUICtrlSetData($lblStatus, "Status: Returning to Town")
  505. Sleep(5)
  506. Send(3)
  507. Sleep(5)
  508. Send(2)
  509. Sleep(3)
  510. Send("t")
  511. Sleep(Random($tptime, $tptime+500))
  512. EndFunc
  513.  
  514. Func Identify()
  515. Send("c")
  516. Sleep(1300)
  517. While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, $gX, $gY, 180)
  518. GUICtrlSetData($lblStatus, "Status: Identifying")
  519. Sleep(Random(200, 300))
  520. MouseClick("right",$gX,$gY, 1)
  521. MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  522. Sleep(Random(3000, 3500))
  523. WEnd
  524. Send("c")
  525. Sleep(600)
  526. EndFunc
  527.  
  528. Func StashLoot()
  529. GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  530. Sleep(Random(1000, 1500))
  531. MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
  532. Sleep(Random(1500, 2000))
  533.  
  534. ;Legendaries
  535. While $StashLegendary
  536. Sleep(Random(200, 300))
  537. $LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
  538. If Not @error Then
  539. GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  540. MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  541. Else
  542. ExitLoop
  543. EndIf
  544. WEnd
  545.  
  546. ;Rares
  547. While $StashRare
  548. Sleep(Random(200, 300))
  549. $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  550. If Not @error Then
  551. GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  552. MouseClick("right", $RarePixel[0], $RarePixel[1])
  553. Else
  554. ExitLoop
  555. EndIf
  556. WEnd
  557.  
  558. ;Tomes
  559. If _ImageSearchArea($pngLoc & "TomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  560. GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  561. MouseClick("left",500*$x_ratio,360*$y_ratio,1,1)
  562. Sleep(Random(500, 750))
  563. MouseClick("right",$gX,$gY,1,1)
  564. Sleep(Random(400, 600))
  565. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  566. Sleep(Random(200, 500))
  567. EndIf
  568.  
  569. ;Magic
  570. While $StashMagic
  571. Sleep(Random(100, 300))
  572. $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  573. If Not @error Then
  574. GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  575. MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  576. Else
  577. ExitLoop
  578. EndIf
  579. WEnd
  580.  
  581. ;Gems
  582. If $StashGems Then
  583. If _ImageSearchArea($pngLoc & "Ru1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  584. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  585. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  586. Sleep(Random(200, 500))
  587. MouseClick("right",$gX,$gY,1,1)
  588. Sleep(Random(400, 600))
  589. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  590. Sleep(Random(200, 500))
  591. EndIf
  592. If _ImageSearchArea($pngLoc & "Ru2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  593. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  594. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  595. Sleep(Random(200, 500))
  596. MouseClick("right",$gX,$gY,1,1)
  597. Sleep(Random(400, 600))
  598. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  599. Sleep(Random(200, 500))
  600. EndIf
  601. If _ImageSearchArea($pngLoc & "Em1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  602. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  603. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  604. Sleep(Random(200, 500))
  605. MouseClick("right",$gX,$gY,1,1)
  606. Sleep(Random(400, 600))
  607. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  608. Sleep(Random(200, 500))
  609. EndIf
  610. If _ImageSearchArea($pngLoc & "Em2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  611. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  612. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  613. Sleep(Random(200, 500))
  614. MouseClick("right",$gX,$gY,1,1)
  615. Sleep(Random(400, 600))
  616. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  617. Sleep(Random(200, 500))
  618. EndIf
  619. If _ImageSearchArea($pngLoc & "To1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  620. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  621. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  622. Sleep(Random(200, 500))
  623. MouseClick("right",$gX,$gY,1,1)
  624. Sleep(Random(400, 600))
  625. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  626. Sleep(Random(200, 500))
  627. EndIf
  628. If _ImageSearchArea($pngLoc & "To2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  629. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  630. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  631. Sleep(Random(200, 500))
  632. MouseClick("right",$gX,$gY,1,1)
  633. Sleep(Random(400, 600))
  634. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  635. Sleep(Random(200, 500))
  636. EndIf
  637. If _ImageSearchArea($pngLoc & "Am1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  638. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  639. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  640. Sleep(Random(200, 500))
  641. MouseClick("right",$gX,$gY,1,1)
  642. Sleep(Random(400, 600))
  643. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  644. Sleep(Random(200, 500))
  645. EndIf
  646. If _ImageSearchArea($pngLoc & "Am2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  647. GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  648. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  649. Sleep(Random(200, 500))
  650. MouseClick("right",$gX,$gY,1,1)
  651. Sleep(Random(400, 600))
  652. MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  653. Sleep(Random(200, 500))
  654. EndIf
  655. EndIf
  656. Sleep(Random(1000, 3000))
  657. Send("{SPACE}")
  658. EndFunc
  659.  
  660. Func VendorLoot()
  661. GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  662. If Not $StashLoot Then ;Move from TP towards vendor
  663. Sleep(Random(300, 500))
  664. MouseClick("middle", 1565*$x_ratio, 50*$y_ratio)
  665. Else ;Move from Stash towards vendor
  666. Sleep(Random(300, 500))
  667. MouseClick("middle", 1560*$x_ratio, 120*$y_ratio)
  668. EndIf
  669. Sleep(3000)
  670. MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  671. Sleep(3000)
  672.  
  673. ;Rares
  674. If $VendorRare Then
  675. $c = 0
  676. While $c <= 10
  677. Sleep(Random(200, 300))
  678. $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  679. If Not @error Then
  680. MouseClick("right", $RarePixel[0], $RarePixel[1])
  681. $c += 1
  682. Else
  683. ExitLoop
  684. EndIf
  685. WEnd
  686. EndIf
  687.  
  688. ;Magic
  689. If $VendorMagic Then
  690. $c = 0
  691. While $c <= 25
  692. Sleep(Random(200, 300))
  693. $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 0)
  694. If Not @error Then
  695. MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  696. $c += 1
  697. Else
  698. ExitLoop
  699. EndIf
  700. WEnd
  701. EndIf
  702.  
  703. Sleep(200)
  704. RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  705. Sleep(300)
  706. RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  707. Sleep(200)
  708. Sleep(Random(1000, 3000))
  709. GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  710. Send("{ESCAPE}")
  711. EndFunc
  712.  
  713.  
  714. Func DoUpdate()
  715. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini") ;download version.ini
  716. If $Ini = 0 Then ;was the download of version.ini successful?
  717. MsgBox(16,"Fatal Error","The server seems to be offline. No update will be done.")
  718. Else
  719. $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","") ;reads the new version out of version.ini
  720. If $NewVersion = $oldVersion Then ;compare old and new
  721. ;MsgBox (0,"No update","There is no update available!")
  722. FileDelete(@ScriptDir & "\version.ini")
  723. Else
  724. $msg = MsgBox (68,"Update","A new version is available: " & $newVersion & "! Current version: " & $oldVersion & @CRLF & "Do you want to download the new version?")
  725. If $msg = 7 Then ;No was pressed
  726. FileDelete(@ScriptDir & "\version.ini")
  727. ElseIf $msg = 6 Then ;OK was pressed
  728. $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  729. $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update_" & $newVersion & ".zip",1,1)
  730. ProgressOn("Update", "Downloading Updates", "",-1,-1,16) ;creates a progressbar
  731.  
  732. $Size = InetGetSize($downloadLink,1) ;get the size of the update
  733. While Not InetGetInfo($dlhandle, 2)
  734. $Percent = Round((InetGetInfo($dlhandle,0)/$Size)*100)
  735. ProgressSet( $Percent, $Percent & "%") ;update progressbar
  736. Sleep(1)
  737. WEnd
  738. ProgressSet(100 , "Done", "Complete") ;show complete progressbar
  739. sleep(500)
  740. ProgressOff() ;close progress window
  741. IniWrite("updater.ini","version","version",$NewVersion)
  742. InetClose($dlhandle)
  743. $iniMsg = IniRead(@ScriptDir & "\version.ini","Version","message","Exiting...")
  744. MsgBox(64,"Success","Download Complete!" & @CRLF & "Please restart the bot by extracting the Au3 from Update_" & $newVersion & ".zip" & @CRLF & $iniMsg)
  745. FileDelete(@ScriptDir & "\version.ini")
  746. Exit
  747. EndIf
  748. EndIf
  749. EndIf
  750. WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Waiting")
  751. EndFunc
  752.  
  753. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  754. If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  755. $findImage = "*TRANSBLACK " & $findImage
  756. If @AutoItX64 Then
  757. $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  758. Else
  759. $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  760. EndIf
  761. If $result = "0" Then
  762. Return 0
  763. EndIf
  764.  
  765. ; Otherwise get the x,y location of the match and the size of the image to
  766. ; compute the centre of search
  767. $array = StringSplit($result[0],"|")
  768. If(UBound($array) >= 4) Then
  769. $x=Int(Number($array[2]))
  770. $y=Int(Number($array[3]))
  771. If $resultPosition = 1 Then
  772. $x=$x + Int(Number($array[4])/2)
  773. $y=$y + Int(Number($array[5])/2)
  774. EndIf
  775. Return 1
  776. EndIf
  777. EndFunc
  778.  
  779. ;Hotkey Functions
  780.  
  781. Func Begin()
  782. $Go = Not $Go
  783. If Not $Go Then WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Halted")
  784. EndFunc
  785.  
  786. Func TogglePause()
  787. $Paused = Not $Paused
  788. While $Paused
  789. Sleep(100)
  790. WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Paused")
  791. ToolTip('Script is "Paused"', 0, 0)
  792. WEnd
  793. WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  794. ToolTip("")
  795. EndFunc
  796.  
  797. Func ShowLoot()
  798. GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  799. GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  800. EndFunc
  801.  
  802. Func Stop() ;to allow the script to stop
  803. Exit
  804. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment