Advertisement
Guest User

Don DooBee Monk 1.1.a

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