simonak

notAres1.8c_mod

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