Advertisement
spyC

Sarkoth - Monk

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