Guest User

Monk script: off vendorin and identifyin, second mystic ally

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