Advertisement
Guest User

Turro Monk Gold/Item v1.02

a guest
Jul 10th, 2012
1,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 38.41 KB | None | 0 0
  1. ;Turro Monk Gold/Item Script 1.01d - 7/4/2012
  2. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  3. ;;;;;
  4. ;Item Display must be set to Push To Toggle and turned on
  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#TURVjc!abX!cabbZZ
  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.02", $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. $skillInnerSanctuary = "1"
  39. $skillExplodingPalm = "2"
  40. $skillMysticAlly = "3"
  41. $skillTempestRush = "4"
  42.  
  43. $movementSpeed = 10             ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  44. $lowdps = False               ; This will remove extra time for looting and killing
  45.  
  46. ;Custom Loot
  47. $pngLoc = "C:\pics\"   ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  48. $totalItems = 1                         ;Number of items in the pick array
  49. Global $pick[$totalItems]       ;DONT CHANGE THIS
  50.  
  51. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  52. $pick[0] = "mythic.png|40"      ;png|Tolerance
  53. ;$pick[1] = "item2.png"
  54. ;$pick[2] = "item3.png"
  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 = 8                             ;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.  ;Constants
  78. $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  79. $yellow =   0xFFF000 ; yellow color code (repair icon)
  80. $red =      0xD90000 ; red color code (repair icon)
  81. $go = True
  82. $Leave = False
  83. $Logout = False
  84. $default_resolutionX = 1920     ;DO NOT CHANGE
  85. $default_resolutionY = 1080     ;DO NOT CHANGE (seriously... i'll beat you with a stick)
  86. $x_ratio = $size[0] / $default_resolutionX
  87. $y_ratio = $size[1] / $default_resolutionY
  88. $gX = 0
  89. $gY = 0
  90.  
  91.  
  92.  ;Options
  93. $CreateLog = False      ;True if you want to create a log file
  94. $autoUpdate = True      ;True if you want to automatically download new versions of this bot
  95.  
  96. ;Vendoring
  97. $VendorLoot = True              ;True if you want to vendor Items
  98. $VendorRare = False      ;True if you want to vendor Rares
  99. $VendorMagic = True     ;True if you want to vendor Magic
  100.  
  101. ;Variability
  102. $Timer = False                   ;True and the bot will add random sleep intervals
  103. $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
  104. $loadtime = 3400 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  105. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  106. ;====================================;
  107.  
  108. $x_ratio = $size[0] / 1920
  109. $y_ratio = $size[1] / 1080
  110. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  111. $movementSpeed = 1+($movementSpeed/100)
  112.  
  113. $VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
  114. $oldVersion = IniRead("updater.ini","Version","Version",$ver)
  115. $newVersion = "0.0"
  116.  
  117. #Region ### START Koda GUI section ###
  118. $frmBot = GUICreate("Turro's Monk Extension v" & $ver & " - Updating", 280, 121, Round(1540*$x_ratio), Round(920*$y_ratio), -1, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
  119. GUISetBkColor(0xC0C0C0)
  120. $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  121. GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  122. GUICtrlSetColor(-1, 0xFF0000)
  123. $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  124. $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  125. $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  126. $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  127. $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  128. $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  129. GUISetState(@SW_SHOW)
  130. #EndRegion ### END Koda GUI section ###
  131.  
  132. While 1
  133.         Call("RestartRun")
  134. WEnd
  135.  
  136. Func RestartRun()
  137.         If($Go) Then
  138.                 $i = 0
  139.                 ;Checks if the player is in the Main Menu
  140.                 If Not FileExists($pngLoc & "MainMenu.png") Then
  141.                         MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  142.                         Exit
  143.                 EndIf
  144.                 WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  145.                 If CheckFor("MainMenu", "", Round(40*$x_ratio), Round(300*$y_ratio), Round(400*$x_ratio), Round(600*$y_ratio), 8, 100) Then
  146.                         $run += 1
  147.                         GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  148.                         GUICtrlSetData($lblLocation, "Location: Main Menu")
  149.                         GUICtrlSetData($lblStatus, "Status: Starting Game")
  150.                         While True
  151.                                 RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120, 20) ;Random Click on the resume button
  152.                                 If CheckFor("LimitError", "", Round(720*$x_ratio), Round(480*$y_ratio), Round(960*$x_ratio), Round(600*$y_ratio), 3, 60) Then
  153.                                         Sleep(Random(1000, 2000))
  154.                                         RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
  155.                                         $rand = Random(40000, 80000)
  156.                                         GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand/1000) & " seconds.")
  157.                                         Sleep($rand)
  158.                                 Else
  159.                                         ExitLoop
  160.                                 EndIf
  161.                         WEnd
  162.                         $rt = TimerInit()
  163.                 ElseIf Call("CheckDead") Then
  164.                         GUICtrlSetData($lblStatus, "Status: Dead")
  165.                         Return
  166.                 ElseIf CheckFor("ExitGame", "", Round(700*$x_ratio), Round(340*$y_ratio), Round(1200*$x_ratio), Round(500*$y_ratio), 3, 60) 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(3500)
  184.                 Send("{4 UP}")         
  185.                 Sleep(100)
  186.                 MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  187.                 Sleep(790)
  188.                 If Call("CheckDead") Then
  189.                         Return
  190.                 EndIf
  191.  
  192.                 ;Checks if Dank Cellar is Open
  193.                 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  194.                 If Not @error Then
  195.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  196.                         MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
  197.                         Moving(550)
  198.                         Moving($walktime)
  199.                 Else ;ABORT RUN
  200.                         GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  201.                             send(3)
  202.                         Sleep(10)                      
  203.                         RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  204.                         Moving(250)  
  205.                         Send($skillInnerSanctuary)
  206.                         Sleep(620)                    
  207.                        Call("TownPortal")
  208.                         If Not Call("CheckDead") Then
  209.                                 Call("LeaveGame")
  210.                         EndIf
  211.                         Return
  212.                 EndIf
  213.         Else
  214.                 Call("TownPortal")
  215.                 If Not Call("CheckDead") Then
  216.                         Call("LeaveGame")
  217.                 EndIf
  218.                 Return
  219.         EndIf
  220.  
  221.         ;Checks that the player is in the Dank Cellar
  222.         If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  223.                 GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  224.                 MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  225.                 Sleep(Random(2200, 2800))
  226.                 Send(3)
  227.                 Sleep(30)
  228.                 MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
  229.                 Sleep(2100)
  230.                 Send("{SHIFTDOWN}")
  231.                 Sleep(10)
  232.                 GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  233.                 MouseClick("left")
  234.                 Sleep(10)
  235.                 Send(2)
  236.                 Sleep(10)
  237.                     Send(2)
  238.                 MouseDown("right") ;attack middle
  239.                 Sleep(6500)
  240.                  Send(3)
  241.                 MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  242.                 Sleep(2500)        
  243.                 Send("{SHIFTUP}")
  244.                 Sleep(1000)
  245.                  Send(3)
  246.                  Sleep(2500)
  247.                  If $lowdps = true then
  248.                     sleep(random (2500,5000))
  249.                 GUICtrlSetData($lblStatus, "Status: Looting")
  250.                 MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  251.                 Sleep(1100)
  252.                 MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  253.                 Sleep(1100)
  254.                 Send("{SHIFTDOWN}")
  255.                 MouseClick("right",Round(889*$x_ratio),Round(386*$y_ratio)) ;Breaks table
  256.                 Send("{SHIFTUP}")
  257.                 Sleep(1100)
  258.                 MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
  259.                 Sleep(1100)    
  260.                 Call("Loot")
  261.                 Sleep(2000)
  262.                 MouseClick("middle",Round(675*$x_ratio),Round(887*$y_ratio)) ;moves to bottom left to check for loot
  263.                 sleep(1100)
  264.                 Call("Loot")
  265.              Else
  266.                 GUICtrlSetData($lblStatus, "Status: Looting")
  267.                 MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  268.                 Sleep(1100)
  269.                 MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  270.                 Sleep(1100)
  271.                 Send("{SHIFTDOWN}")
  272.                 MouseClick("right",Round(889*$x_ratio),Round(386*$y_ratio)) ;Breaks table
  273.                 Send("{SHIFTUP}")
  274.                 Sleep(1100)
  275.                 MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
  276.                 Sleep(1100)    
  277.                 Call("Loot")
  278.                 endif
  279.                 RandSleep(1, 6)
  280.                 sleep(random(1500,3500))               
  281.                 Call("TownPortal")                
  282.         Else
  283.                 Send($skillInnerSanctuary)
  284.                 Sleep(620)
  285.                 Send($skillExplodingPalm)
  286.                 Sleep(40)
  287.                 Call("TownPortal")
  288.                 Sleep(500)
  289.                 If Not Call("CheckDead") Then
  290.                         Call("LeaveGame")
  291.                 EndIf
  292.         EndIf
  293.  
  294.         ;After successful run
  295.         If Not Call("CheckDead") Then
  296.                 Sleep(600)
  297.                 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
  298.                         If $StashLoot Then
  299.                                 Call("StashLoot")
  300.                         EndIf
  301.                         If $VendorLoot Then
  302.                                 Call("VendorLoot")
  303.                         EndIf
  304.                         $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  305.                 ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
  306.                         GUICtrlSetData($lblStatus, "Status: Skipping vendor")
  307.                         Sleep(1000)
  308.                 Else
  309.                         $mLootIn -= 1
  310.                 EndIf
  311.                 If Not Call("CheckDead") Then
  312.                    Sleep(500)
  313.                         Call("LeaveGame")
  314.                 EndIf
  315.                 Return
  316.         Else
  317.                 Return
  318.         EndIf
  319. EndIf
  320. EndFunc
  321.  
  322. ;Helper Functions
  323. Func CheckDead()
  324.         $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
  325.         If Not @error Then
  326.                 GUICtrlSetData($lblStatus, "Status: Logging out")
  327.                 Sleep(1000)
  328.                 Sleep($loadtime)
  329.                 Return 1
  330.         EndIf
  331.  
  332.         $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"
  333.         If Not @error Then
  334.                 GUICtrlSetData($lblStatus, "Status: Dead")
  335.                 Call("LeaveGame")
  336.                 Sleep(1000)
  337.                 Return 1
  338.         Else
  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.                 If Not Call("CheckDead") Then
  373.                         Call("LeaveGame")
  374.                 EndIf
  375.         EndIf
  376. EndFunc
  377.  
  378. Func CalcTime()
  379.         $srt = TimerDiff($rt)
  380.         GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt/1000,2) & " seconds.")
  381.         $trt = TimerDiff($t)
  382.         $total = Round((($trt/1000)/60)/60,4)
  383.  
  384.         ;Total runtiume calculation.
  385.         $hours = Floor((($trt/1000)/60)/60)
  386.         $minutes = (($trt/1000)/60)
  387.         ;trim minutes if runtime is more then 1 hour.
  388.         If $minutes > 60 Then
  389.                 While $minutes > 60
  390.                         $minutes -=60
  391.                 WEnd
  392.         EndIf
  393.         GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes")
  394.  EndFunc
  395.  
  396. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5 ,$tolerance = 130)
  397.         $c = 0
  398.         $string = $pngLoc & $img & ".png"
  399.         Do
  400.                 $c +=1
  401.                 Sleep(100)
  402.                 If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
  403.                         If $type = "Area" Then
  404.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  405.                         EndIf
  406.                         Return False
  407.                 EndIf
  408.         Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  409.         Return True
  410. EndFunc
  411.  
  412. Func LeaveGame()
  413.         Call("RandSleep")
  414.         GUICtrlSetData($lblStatus, "Status: Leaving Game")
  415.         Sleep(Random(100, 500))
  416.         Send("{Escape}")
  417.         Sleep(Random(100, 500))
  418.         RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120, 20) ;Random Click on the leave button
  419.         Call("CalcTime")
  420. EndFunc
  421.  
  422. Func Loot()
  423.     MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  424.     If $LootSets == True Then
  425.         $SetCount += LootGear(0x02CE01, 2)
  426.     EndIf
  427.     If $LootLegendaries == True Then   
  428.         $LegendaryCount += LootGear(0xBF642F, 0)
  429.     EndIf
  430.     If $LootRares == True Then 
  431.         $RareCount += LootGear(0xBBBB00, 2)
  432.     EndIf  
  433.     If $LootMagic == True Then 
  434.         $MagicCount += LootGear(0x6969FF, 2)
  435.     EndIf
  436.     If $LootGems Then
  437.           Call("LootGems")
  438.         EndIf
  439.         If $LootTomes Then
  440.           Call("LootTomes")
  441.         EndIf
  442.     If $LootCustom == True Then
  443.         for $i = 0 to ($totalItems - 1)
  444.             $array = StringSplit($pick[$i],"|")
  445.             $file = $array[1]
  446.             $tolerance = $array[2]
  447.             LootItem($file, $tolerance)
  448.         next
  449.     EndIf
  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) ; Magic loot (darker for compatibility)
  455.     While Not @error   
  456.         $count += 1
  457.         MouseClick ('left', $Loot[0], $Loot[1])
  458.         Moving(900)
  459.         MouseMove(Round(Random(1400,1600)*$x_ratio),Round(Random(700,900)*$y_ratio),3) ;Moves mouse out of the way
  460.         $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance) ; Magic loot (darker for compatibility)
  461.     WEnd
  462.     Return $count
  463. EndFunc
  464.  
  465. Func LootCustom()
  466.         $count = 0
  467.         $gX = 0
  468.         $gY = 0
  469.         for $i = 0 to ($totalItems - 1)
  470.                 $array = StringSplit($pick[$i],"|")
  471.                 $file = $array[1]
  472.                 $accuracy = $array[2]
  473.                 $urlString = $pngLoc & $file
  474.                 While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
  475.                         $count += 1
  476.                         Sleep(Random(75, 150))
  477.                         MouseClick("left",$gX,$gY,1,1)
  478.                         Sleep(100))
  479.                         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  480.  
  481.                         If $count >= 10 Then
  482.                                 ExitLoop
  483.                         EndIf
  484.                 WEnd
  485.         next
  486. EndFunc
  487.  
  488. Func LootGems()
  489.         $gX = 0
  490.         $gY = 0
  491.         For $i = 0 to 15
  492.                 If _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90) Then
  493.                         Sleep(Random(75, 150))
  494.                         MouseClick("left",$gX,$gY)
  495.                         $GemCount += 1
  496.                         Sleep(200)
  497.                         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  498.                 EndIf
  499.                 Sleep(100)
  500.         Next
  501. EndFunc
  502.  
  503. Func LootTomes()
  504.         $gX = 0
  505.         $gY = 0
  506.         For $i = 0 to 15
  507.                 If _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90) Then
  508.                         Sleep(Random(75, 150))
  509.                         MouseClick("left",$gX,$gY)
  510.                         $TomeCount += 1
  511.                         Sleep(200)
  512.                         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  513.                 EndIf
  514.                 Sleep(100)
  515.         Next
  516. EndFunc
  517.  
  518. Func Moving($time)
  519.         Sleep($time/$movementSpeed)
  520. EndFunc
  521.  
  522. Func RandClick($clickType, $xPos, $yPos, $xOff = 20, $yOff = 20)
  523.         $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  524.         $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  525.         MouseClick($clickType, $randX, $randY)
  526. EndFunc
  527.  
  528. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 20)
  529.         $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  530.         $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  531.         MouseMove($randX, $randY)
  532. EndFunc
  533.  
  534. Func RandSleep($min = 5, $max = 15, $chance = 2)
  535.         $randNum = Round(Random(1, 100))
  536.         If $Timer And $randNum <= $chance Then
  537.                 $sleepTime = Random($min*1000, $max*1000)
  538.                 GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime/1000) & " secs")
  539.  
  540.                 For $c = 0 To 10
  541.                         Sleep($sleepTime/10)
  542.                 Next
  543.         EndIf
  544. EndFunc
  545.  
  546. Func TownPortal()
  547.         GUICtrlSetData($lblStatus, "Status: Returning to Town")
  548.         Send("t")
  549.         Sleep(Random($tptime, $tptime+500))
  550. EndFunc
  551.  
  552. Func Identify()
  553.         Send("c")
  554.         Sleep(1300)
  555.         While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, $gX, $gY, 180)
  556.                 GUICtrlSetData($lblStatus, "Status: Identifying")
  557.                 Sleep(Random(200, 300))
  558.                 MouseClick("right",$gX,$gY, 1)
  559.                 MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  560.                 Sleep(Random(3000, 3500))
  561.         WEnd
  562.         Send("c")
  563.         Sleep(600)
  564. EndFunc
  565.  
  566. Func StashLoot()
  567.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  568.         Sleep(Random(1000, 1500))
  569.         MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
  570.         Sleep(Random(1500, 2000))
  571.  
  572.         ;Legendaries
  573.         While $StashLegendary
  574.                 Sleep(Random(200, 300))
  575.                 $LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
  576.                 If Not @error Then
  577.                         GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  578.                         MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  579.                 Else
  580.                         ExitLoop
  581.                 EndIf
  582.         WEnd
  583.  
  584.         ;Rares
  585.         While $StashRare
  586.                 Sleep(Random(200, 300))
  587.                 $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  588.                 If Not @error Then
  589.                         GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  590.                         MouseClick("right", $RarePixel[0], $RarePixel[1])
  591.                 Else
  592.                         ExitLoop
  593.                 EndIf
  594.         WEnd
  595.  
  596.         ;Tomes
  597.         If _ImageSearchArea($pngLoc & "TomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  598.                 GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  599.                 MouseClick("left",500*$x_ratio,360*$y_ratio,1,1)
  600.                 Sleep(Random(500, 750))
  601.                 MouseClick("right",$gX,$gY,1,1)
  602.                 Sleep(Random(400, 600))
  603.                 MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  604.                 Sleep(Random(200, 500))
  605.         EndIf
  606.  
  607.         ;Magic
  608.         While $StashMagic
  609.                 Sleep(Random(100, 300))
  610.                 $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  611.                 If Not @error Then
  612.                         GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  613.                         MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  614.                 Else
  615.                         ExitLoop
  616.                 EndIf
  617.         WEnd
  618.  
  619.         ;Gems
  620.         If $StashGems Then
  621.                 If _ImageSearchArea($pngLoc & "Ru1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  622.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  623.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  624.                         Sleep(Random(200, 500))
  625.                         MouseClick("right",$gX,$gY,1,1)
  626.                         Sleep(Random(400, 600))
  627.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  628.                         Sleep(Random(200, 500))
  629.                 EndIf
  630.                 If _ImageSearchArea($pngLoc & "Ru2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  631.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  632.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  633.                         Sleep(Random(200, 500))
  634.                         MouseClick("right",$gX,$gY,1,1)
  635.                         Sleep(Random(400, 600))
  636.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  637.                         Sleep(Random(200, 500))
  638.                 EndIf
  639.                 If _ImageSearchArea($pngLoc & "Em1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  640.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  641.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  642.                         Sleep(Random(200, 500))
  643.                         MouseClick("right",$gX,$gY,1,1)
  644.                         Sleep(Random(400, 600))
  645.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  646.                         Sleep(Random(200, 500))
  647.                 EndIf
  648.                 If _ImageSearchArea($pngLoc & "Em2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  649.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  650.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  651.                         Sleep(Random(200, 500))
  652.                         MouseClick("right",$gX,$gY,1,1)
  653.                         Sleep(Random(400, 600))
  654.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  655.                         Sleep(Random(200, 500))
  656.                 EndIf
  657.                 If _ImageSearchArea($pngLoc & "To1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  658.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  659.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  660.                         Sleep(Random(200, 500))
  661.                         MouseClick("right",$gX,$gY,1,1)
  662.                         Sleep(Random(400, 600))
  663.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  664.                         Sleep(Random(200, 500))
  665.                 EndIf
  666.                 If _ImageSearchArea($pngLoc & "To2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  667.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  668.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  669.                         Sleep(Random(200, 500))
  670.                         MouseClick("right",$gX,$gY,1,1)
  671.                         Sleep(Random(400, 600))
  672.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  673.                         Sleep(Random(200, 500))
  674.                 EndIf
  675.                 If _ImageSearchArea($pngLoc & "Am1.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  676.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  677.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  678.                         Sleep(Random(200, 500))
  679.                         MouseClick("right",$gX,$gY,1,1)
  680.                         Sleep(Random(400, 600))
  681.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  682.                         Sleep(Random(200, 500))
  683.                 EndIf
  684.                 If _ImageSearchArea($pngLoc & "Am2.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  685.                         GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  686.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  687.                         Sleep(Random(200, 500))
  688.                         MouseClick("right",$gX,$gY,1,1)
  689.                         Sleep(Random(400, 600))
  690.                         MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  691.                         Sleep(Random(200, 500))
  692.                 EndIf
  693.         EndIf
  694.         Sleep(Random(1000, 3000))
  695.         Send("{SPACE}")
  696. EndFunc
  697.  
  698. Func VendorLoot()
  699.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  700.         If Not $StashLoot == "True" Then ;Move from TP towards vendor
  701.                 Sleep(Random(300, 500))
  702.                 MouseClick("middle", 1565*$x_ratio, 50*$y_ratio)
  703.         Else ;Move from Stash towards vendor
  704.                 Sleep(Random(300, 500))
  705.                 MouseClick("middle", 1560*$x_ratio, 120*$y_ratio)
  706.         EndIf
  707.         Sleep(3000)
  708.         MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  709.         Sleep(3000)
  710.  
  711.         ;Rares
  712.         If $VendorRare Then
  713.                 $c = 0
  714.                 While $c <= 10
  715.                         Sleep(Random(200, 300))
  716.                         $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x544A11, 1)
  717.                         If Not @error Then
  718.                                 MouseClick("right", $RarePixel[0], $RarePixel[1])
  719.                                 $c += 1
  720.                         Else
  721.                                 ExitLoop
  722.                         EndIf
  723.                 WEnd
  724.         EndIf
  725.  
  726.         ;Magic
  727.         If $VendorMagic Then
  728.                 $c = 0
  729.                 While $c <= 25
  730.                         Sleep(Random(100, 300))
  731.                         $MagicPixel = PixelSearch(1408*$x_ratio, 580*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 1)
  732.                         If Not @error Then
  733.                                 MouseClick("right", $MagicPixel[0], $MagicPixel[1], 1, 4)
  734.                                 Sleep(Random(200, 300))
  735.                                 $c += 1
  736.                         Else
  737.                                 ExitLoop
  738.                         EndIf
  739.                 WEnd
  740.         EndIf
  741.  
  742.         Sleep(200)
  743.         RandClick("left", Round(521*$x_ratio),Round(506*$y_ratio),1,1) ;button to open up repair menu
  744.         Sleep(300)
  745.         RandClick("left", Round(260*$x_ratio),Round(595*$y_ratio),1,1) ;button to pay for repairs
  746.         Sleep(200)
  747.         Sleep(Random(1000, 3000))
  748.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  749.         Send("{ESCAPE}")
  750.      EndFunc
  751.      
  752.  
  753.  
  754. Func DoUpdate()
  755. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini")                                                                                       ;download version.ini
  756. If $Ini = 0 Then                                                                                                                                                                        ;was the download of version.ini successful?
  757.         MsgBox(16,"Fatal Error","The server seems to be offline. No update will be done.")
  758. Else
  759.     $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","")                                          ;reads the new version out of version.ini
  760.     If $NewVersion = $oldVersion Then                                                                                                                           ;compare old and new
  761.         ;MsgBox (0,"No update","There is no update available!")
  762.                 FileDelete(@ScriptDir & "\version.ini")
  763.     Else
  764.         $msg = MsgBox (68,"Update","A new version is available: " & $newVersion & "! Current version: " & $oldVersion & @CRLF & "Do you want to download the new version?")
  765.                 If $msg = 7 Then                                                                                                                                                        ;No was pressed
  766.             FileDelete(@ScriptDir & "\version.ini")
  767.                 ElseIf $msg = 6 Then                                                                                                                                            ;OK was pressed
  768.                         $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  769.             $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update_" & $newVersion & ".zip",1,1)
  770.             ProgressOn("Update", "Downloading Updates", "",-1,-1,16)                                                            ;creates a progressbar
  771.  
  772.                         $Size = InetGetSize($downloadLink,1)                                                                                                    ;get the size of the update
  773.             While Not InetGetInfo($dlhandle, 2)
  774.                 $Percent = Round((InetGetInfo($dlhandle,0)/$Size)*100)
  775.                 ProgressSet( $Percent, $Percent & "%")                                                                          ;update progressbar
  776.                 Sleep(1)
  777.             WEnd
  778.             ProgressSet(100 , "Done", "Complete")                                                                                                       ;show complete progressbar
  779.                          sleep(500)
  780.             ProgressOff()                                                                                                                                                       ;close progress window
  781.             IniWrite("updater.ini","version","version",$NewVersion)
  782.             InetClose($dlhandle)
  783.                         $iniMsg = IniRead(@ScriptDir & "\version.ini","Version","message","Exiting...")
  784.             MsgBox(64,"Success","Download Complete!" & @CRLF & "Please restart the bot by extracting the Au3 from Update_" & $newVersion & ".zip" & @CRLF & $iniMsg)
  785.                         FileDelete(@ScriptDir & "\version.ini")
  786.                         Exit
  787.                 EndIf
  788.     EndIf
  789. EndIf
  790. WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Waiting")
  791. EndFunc
  792.  
  793. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  794.         If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  795.         $findImage = "*TRANSBLACK " & $findImage
  796.         If @AutoItX64 Then
  797.                 $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  798.         Else
  799.                 $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  800.         EndIf
  801.         If $result = "0" Then
  802.                 Return 0
  803.         EndIf
  804.  
  805.         ; Otherwise get the x,y location of the match and the size of the image to
  806.         ; compute the centre of search
  807.         $array = StringSplit($result[0],"|")
  808.         If(UBound($array) >= 4) Then
  809.                 $x=Int(Number($array[2]))
  810.                 $y=Int(Number($array[3]))
  811.                 If $resultPosition = 1 Then
  812.                         $x=$x + Int(Number($array[4])/2)
  813.                         $y=$y + Int(Number($array[5])/2)
  814.                 EndIf
  815.         Return 1
  816.         EndIf
  817. EndFunc
  818.  
  819. ;Hotkey Functions
  820.  
  821. Func Begin()
  822.         $Go = Not $Go
  823.         If Not $Go Then WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Halted")
  824. EndFunc
  825.  
  826. Func TogglePause()
  827.     $Paused = Not $Paused
  828.     While $Paused
  829.         Sleep(100)
  830.                 WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Paused")
  831.         ToolTip('Script is "Paused"', 0, 0)
  832.     WEnd
  833.         WinSetTitle("notAres", "", "notAres' DH Extension v" & $ver & " - Running")
  834.     ToolTip("")
  835. EndFunc
  836.  
  837. Func ShowLoot()
  838.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  839.         GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  840. EndFunc
  841.  
  842. Func Stop() ;to allow the script to stop
  843.     Exit
  844. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement