Guest User

notAres1.7c_moded

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