Advertisement
Guest User

source

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