Guest User

LATM's 1.6E Barbarian

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