Advertisement
Guest User

Untitled

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