Advertisement
darkjoy

notAres 1.8c Modified for Wormhole Wizard Archon *1.03*

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