Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Don DooBee's v1.3b
- ; + rep @ ownedcore if you enjoy the script
- ; you will need tesseract from https://tesseract-ocr.googlecode.com/files/tesseract-ocr-setup-3.01-1.exe
- ; and you will need tesserect library to in your auto it include folder from https://dl.dropbox.com/u/22203901/Tesseract.au3
- ; you will also need image files and search dlls from https://dl.dropbox.com/u/9955791/BotFiles.zip
- ; and http://www45.zippyshare.com/v/15622375/file.html
- ;notAres' Gold Script for Monk - 6/30/2012
- ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
- ;;;;;
- ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
- ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
- ;Official supported resolution: 1920x1080
- ;;;;;
- ;Original by mackus101 @ ownedcore
- ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
- ;Refactoring and additional functions by Shimizoki
- ;=========== DO NOT TOUCH ===========;
- #RequireAdmin
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- ;=========== mypart ===========;
- #include <Tesseract.au3>
- Global $numitem, $numgem, $numtomb, $numgold, $numpot, $lblGold, $numsold, $numstashed, $monold = 0, $mon = 0, $monstart = 0, $SprintStart
- Opt('MouseCoordMode', 2)
- Opt('PixelCoordMode', 2)
- Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $ver = "Don DooBee's ", $hFont = 0, $title, $Paused, $Go = False, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $deathCount = 0, $cellarCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000, $lblRun, $lblLocation, $lblStatus, $lblLast, $lblRuntime, $lblGear, $lblItems
- Global $str_Stash, $str_StashGems, $str_StashMisc, $str_Vendor, $str_Salvage, $int_TownPosition
- For $i = 0 To Random(0, 3, 1)
- $title &= Chr(Random(97, 122, 1))
- Next
- For $i = 0 To Random(2, 5, 1)
- $title &= Chr(Random(65, 90, 1))
- Next
- $title &= " "
- Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
- If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
- If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
- If $size = 0 Then
- MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
- Exit
- EndIf
- ;====================================;
- ;============= SETTINGS =============;
- HotKeySet("=", "Begin") ;script toggled on/off by pressing =
- HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
- HotKeySet("x", "Stop") ;script stopped by pressing x
- HotKeySet("0", "GoTown") ;script stopped by pressing x
- $movementSpeed = 0 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
- ;Custom Loot
- $pngLoc = "C:\Program Files (x86)\AutoIt3\pics\" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
- $totalItems = 2 ;Number of items in the pick array
- Global $pick[$totalItems] ;DONT CHANGE THIS
- ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
- $pick[0] = "mythic.png|50" ;png|Tolerance
- $pick[1] = "gold.png|50"
- ;$pick[2] = "item3.png"
- ;General
- $ExtraSafeExit = True ;use ancients when you port back to prevent death if you have low HP
- $RunsUntilMenuWait = 0 ;wait for 1 hour at menu after x successful runs, set to 0 to disable
- $TakeMissShots = False ;take screenshots into \shots folder on every cellar miss for finding positions
- $SarkothKillTime = 800 ;additional time delay to wait for sarkoth to die use 2800 for 10K dps 800 for 15kdps etc
- $DetectTPFail = False ;set true to immediatly exit game if TP is inturrupted (requires TP.png)
- $TPProtectTime = 2.5 ;number of seconds to check for TP inturrupt if TPfail detection is enabled if your pc is slow reduce this number
- $BlankLamps = True ;enable/disable putting boxes over the lamps before looting legendaries to reduce false positives
- $ReduceLegendSearch = False ; limit legendary searching to lower part of screen to reduce false finds
- ;define your own cellar co-ords here, list the most likely ones first for efficiency
- ;change the [4] to how many co-ords you listed
- Dim $celx[4] = [300, 210, 190, 250]
- Dim $cely[4] = [179, 179, 224, 160]
- ;Buttons
- $skillCaltrops = "1"
- $skillSmokeScreen = "2"
- $skillPreparation = "3"
- $skillCompanion = "4"
- $TownPortalButton = "t"
- $Inventory = "i"
- ;Looting
- $LootSets = True ;True if you want to pick up Sets
- $LootLegendaries = True;True if you want to pick up Legendaries
- $LootRares = True ;True if you want to pick up Rares
- $LootMagic = True ;True if you want to pick up Magic
- $LootGems = True ;True if you want to pick up Gems
- $LootTomes = True ;True if you want to pick up Tome of Secrets
- $LootCustom = false ;True if you want to pick up Custom Items (The items in the $pick array above)
- ;Manage Loot
- $Identify = True ;True to enable identifying items before stashing/vendoring
- $mLoot = 8 ;Nuber of successful runs until Stash and Vendor
- $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
- ;Variability ==NEW SETTINGS==
- $Timer = False ;True and the bot will add random sleep intervals
- $walktime = 2400 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
- $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
- $tptime = 6900 ;Time (in ms) the script waits for teleport before exiting the game
- ;Stashing/vendoring COMMON
- $StashRare = True ;True if you want to store Rare items in the stash
- $StashMagic = False ;True if you want to store Magic items in the stash
- $VendorRare = False ;True if you want to vendor Rares
- $VendorMagic = True ;True if you want to vendor Magic
- $GemTab = 1;Tab to put gems and tombs in
- $ItemTab = 2 ;Tab to put any items in
- $NextItemTab = 3 ;Next Tab to put any items in when first one is full
- ;--------------------------------------------TRADITIONAL----------------------------------------------------
- ;Stashing/vendoring TRADITIONAL METHOD to enable set line 155 to FALSE
- $StashLoot = True ;True if you want to store Items in the stash
- $StashLegendary = True;True if you want to store Legendary items in the stash
- $StashTomes = True ;True if you want to store Tomes items in the stash
- $StashGems = True ;True if you want to store Gems items in the stash
- ;SALVAGE - setting this will OVERRIDE traditional vendoring options - it will be skipped
- ; make sure you have a stack of each material in your bottom row( which is not scanned )for it to add To
- ; otherwise it will start tying to salvage your craft items and do nothing!
- $SalvageLoot = False
- ;Vendoring ==NEW SETTINGS==
- $VendorLoot = True ;True if you want to vendor anything
- $vendorAll = False ;True if you want to right click all items when talking to vendor
- $vendorRows = 6 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
- $vendorCols = 10 ;# of columns to vendor, starting from left
- ;--------------------------------------------TRADITIONAL----------------------------------------------------
- ;--------------------------------------------iLVL----------------------------------------------------
- $UseiLVL = True ;set true or false to enable the iLVL system THIS OVERRIDES ALL "TRADITIONAL" SETTINGS
- ;====================================;
- ;New Analyze Loot Settings Options are "salvage", "stash", and "vend"
- $i59Rare = "vend"
- $i60Rare = "stash"
- $i61Rare = "stash"
- $i62Rare = "stash"
- $i63Rare = "stash"
- $i59Magic = "vend"
- $i60Magic = "vend"
- $i61Magic = "vend"
- $i62Magic = "vend"
- $i63Magic = "stash"
- ;====================================;
- ;--------------------------------------------iLVL----------------------------------------------------
- $x_ratio = $size[0] / 1920
- $y_ratio = $size[1] / 1080
- $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
- $RunsUntilMenuWaitCnt = $RunsUntilMenuWait
- If $totalItems < 1 Then $LootCustom = False
- $movementSpeed = 1 + ($movementSpeed / 100)
- If $TakeMissShots Then
- DirCreate("shots")
- EndIf
- If Not FileExists($pngLoc & "MainMenu.png") Then
- $pngLoc = "C:\pics\"
- If Not FileExists($pngLoc & "MainMenu.png") Then
- MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
- Exit
- EndIf
- EndIf
- Call("SetupGUI")
- While 1
- Call("RestartRun")
- WEnd
- Func RestartRun()
- If ($Go) Then
- $i = 0
- Send("{SPACE}")
- WinSetTitle($title, "", $title & $ver & " - Running")
- MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
- ;Checks if the player is Dead/Logout/Window, then if in Main Menu, etc.
- If CheckDead() Then
- Return
- ElseIf CheckFor("ExitGame", "", Round(860 * $x_ratio), Round(400 * $y_ratio), Round(1040 * $x_ratio), Round(450 * $y_ratio), 0.5, 140) Then
- GUICtrlSetData($lblStatus, "Status: Exit window up")
- MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
- Sleep(100)
- Send("{SPACE}")
- Return
- ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio)) Then
- GUICtrlSetData($lblRun, "Runs till vendor: " & $mLootIn & ", Run Number: " & $run)
- GUICtrlSetData($lblLocation, "Location: Main Menu")
- GUICtrlSetData($lblStatus, "Status: Starting Game")
- RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
- CheckFor("OldRuins", "Area", 0, 0, 0, 0, $loadtime / 1000)
- ;Sleep($loadtime)
- $rt = TimerInit()
- $run += 1
- ElseIf CheckFor("OldRuins", "Area") Or CheckFor("NewTristram", "Area") Or CheckFor("DankCellar", "Area") Then
- Call("TownPortal")
- Call("LeaveGame")
- Return
- ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
- MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
- $rand = Random(40000, 80000)
- GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
- Sleep($rand)
- Send("{SPACE}")
- Return
- ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
- GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
- MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
- Sleep(100)
- Send("{SPACE}")
- Return
- Else
- GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
- Return
- EndIf
- $CellarWasFound = 0
- If CheckFor("OldRuins", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
- GUICtrlSetData($lblLocation, "Location: Old Ruins")
- ;Check if player needs to repair
- Call("CheckRepair")
- ;Start Run
- MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
- Send("{4 DOWN}")
- Sleep(3500)
- Send("{4 UP}")
- Sleep(100)
- MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
- Sleep(790)
- If Call("CheckDead") Then
- Return
- EndIf
- ;Checks if Dank Cellar is Open
- $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
- If Not @error Then
- GUICtrlSetData($lblStatus, "Status: Cellar - Found")
- $run += 1
- MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
- Moving(550)
- Send($skillSmokeScreen)
- Moving($walktime)
- Else ;ABORT RUN
- GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
- Sleep(10)
- Send($skillPreparation)
- sleep(40)
- RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
- Moving(250)
- Send($skillCaltrops)
- Sleep(620)
- Send($skillSmokeScreen)
- Sleep(40)
- Call("TownPortal")
- sleep(600)
- If Not Call("CheckDead") Then
- Call("LeaveGame")
- EndIf
- Return
- EndIf
- Else
- Call("TownPortal")
- If Not Call("CheckDead") Then
- Call("LeaveGame")
- EndIf
- Return
- EndIf
- ;Checks that the player is in the Dank Cellar
- If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
- GUICtrlSetData($lblLocation, "Location: Dank Cellar")
- MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
- Sleep(Random(2200, 2800))
- Send(3)
- Sleep(30)
- MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
- Sleep(2100)
- Send("{SHIFTDOWN}")
- Sleep(10)
- GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
- MouseClick("left")
- Sleep(10)
- Send(2)
- Sleep(10)
- MouseDown("right") ;attack middle
- Sleep(3500)
- MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
- Sleep(100)
- Send("{SHIFTUP}")
- Sleep(10)
- Send(3)
- Sleep(10)
- GUICtrlSetData($lblStatus, "Status: Looting")
- MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
- Sleep(1100)
- MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
- Sleep(1100)
- MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
- Sleep(1500)
- $numitem =0
- $numgem=0
- $numtomb=0
- $numgold=0
- $numpot=0
- GUICtrlSetData($lblStatus, "Status: Looting")
- Call("Loot")
- RandSleep(1, 6, 50)
- Send("i")
- Sleep(140)
- $mon = _TesseractScreenCapture( 0, "", 1, 2,1454,508,1920-1571,1080-525, 0)
- $mon = StringReplace($mon , ",", "")
- $mon = StringReplace($mon , @CRLF, "")
- $mon = StringReplace($mon , " ", "")
- $mondelt = Number($mon) - Number($monold)
- Call("AddLog",'Gold: ' & $mon & ', Gold Delt: ' & $mondelt & ', Items: ' & $numitem & ', Gems: ' & $numgem & ', Books: ' & $numtomb & ', Potions: ' & $numpot & ', GoldPick: ' & $numgold)
- Send("i")
- GUICtrlSetData($lblGold, "Gold: " & $mon & ", This Run: " & $mondelt)
- $monold=$mon
- Call("TownPortal")
- Else
- Sleep(620)
- Sleep(40)
- Call("TownPortal")
- If Not Call("CheckDead") Then
- Call("LeaveGame")
- EndIf
- EndIf
- ;After successful run
- If Not CheckDead() Then
- 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
- If $UseiLVL Then
- Call("AnalyseLoots") ;ilvl discriminatory stashing
- Else
- If $Identify Then Call("Identify")
- If $StashLoot Then Call("StashLoot")
- If $SalvageLoot Then
- Call("SalvageLoot")
- Else
- If $VendorLoot Then Call("VendorLoot")
- EndIf
- EndIf
- $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
- ElseIf Not CheckFor("NewTristram", "Area", 1500*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 80*$y_ratio, 6, 180) Then
- GUICtrlSetData($lblStatus, "Status: Skipping vendor")
- Sleep(1000)
- Else
- $mLootIn -= 1
- EndIf
- If Not Call("CheckDead") Then
- Call("LeaveGame")
- EndIf
- Return
- Else
- Return
- EndIf
- EndIf
- EndFunc
- ;Helper Functions
- Func SetupGUI()
- $frmBot = GUICreate($title & $ver & "Waiting...", 290, 140, Round(1580 * $x_ratio), Round(900 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
- GUISetBkColor(0xC0C0C0)
- $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
- GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
- GUICtrlSetColor(-1, 0xFF0000)
- $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
- $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
- $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
- $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
- $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
- $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
- $lblGold = GUICtrlCreateLabel("Gold: 0", 12, 110, 240, 17)
- GUISetState(@SW_SHOW)
- EndFunc ;==>SetupGUI
- Func CheckDead()
- $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
- If Not @error Then
- Call("AddLog", "Logged out")
- GUICtrlSetData($lblStatus, "Status: Logging out")
- CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), $loadtime / 1000)
- Return 1
- EndIf
- $CloseButton = PixelSearch(Round(1570 * $x_ratio), Round(110 * $y_ratio), Round(1590 * $x_ratio), Round(120 * $y_ratio), 0x8C2300) ; checks for the red color of the "X" on an open window
- If Not @error Then
- GUICtrlSetData($lblStatus, "Status: Open Window")
- Call("AddLog", "Open Window")
- Sleep(200)
- Send("{SPACE}") ;close any open windows
- Return 1
- EndIf
- $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"
- If Not @error Then
- GUICtrlSetData($lblStatus, "Status: Dead")
- Call("AddLog", "You have died")
- $deathCount += 1
- Call("LeaveGame")
- For $c = 1 To 110 + $loadtime / 100
- Sleep(100)
- If CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), 0.1) Then ExitLoop
- Next
- Return 1
- Else
- Return 0
- EndIf
- EndFunc ;==>CheckDead
- Func CheckRepair()
- $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
- If Not @error Then
- Call("DoRepair")
- EndIf
- $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
- If Not @error Then
- Call("DoRepair")
- EndIf
- EndFunc ;==>CheckRepair
- Func DoRepair()
- Sleep(Random(75, 150))
- Call("TownPortal")
- If CheckDead() Then
- Return
- EndIf
- If CheckFor("NewTristram", "Area") Then
- RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
- Moving(1875)
- RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
- Moving(1875)
- RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
- Sleep(1200)
- RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
- Sleep(400)
- RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
- Sleep(200)
- Send("{Escape}")
- Call("AddLog", "Repair")
- If Not CheckDead() Then
- Call("LeaveGame")
- EndIf
- EndIf
- EndFunc ;==>DoRepair
- Func CalcTime()
- $srt = TimerDiff($rt)
- GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
- $trt = TimerDiff($t)
- $total = Round((($trt / 1000) / 60) / 60, 4)
- Call("AddLog", "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
- ;Total runtime calculation.
- $hours = Floor((($trt / 1000) / 60) / 60)
- $minutes = (($trt / 1000) / 60)
- ;trim minutes if runtime is more then 1 hour.
- If $minutes > 60 Then
- While $minutes > 60
- $minutes -= 60
- WEnd
- EndIf
- GUICtrlSetData($lblRuntime, "Runtime: " & $hours & ":" & Ceiling($minutes) & ", GPH: " & Ceiling((Number($mon) - $monstart) / ($trt / 3600000)))
- EndFunc ;==>CalcTime
- Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 6, $tolerance = 140)
- If $type = "Area" Then
- $startX = 1500 * $x_ratio
- $startY = 0 * $y_ratio
- $endX = 1920 * $x_ratio
- $endY = 90 * $y_ratio
- If $seconds = 6 Then $seconds = 2.5
- EndIf
- If $seconds > 20 Then
- MsgBox(1, "uhoh", "we got a problem " & $seconds)
- EndIf
- $c = 0
- $string = $pngLoc & $img & ".png"
- Do
- $c += 1
- Sleep(200)
- If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
- If $type = "Area" Then
- GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
- EndIf
- Return False
- EndIf
- Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
- GUICtrlSetData($lblStatus, "Status: Area found! " & $img)
- Return True
- EndFunc ;==>CheckFor
- Func DoSprint()
- RandClick("right", Round(15 * $x_ratio), Round(1055 * $y_ratio)) ;sprint
- $SprintStart = TimerInit()
- EndFunc ;==>DoSprint
- Func WalkTime($lootx, $looty, $extra = 0)
- $PPmSsprint = (960 / 2200) * $movementSpeed
- $PPmSwalk = (960 / 3100) * $movementSpeed
- Dim $BarbFeet[2] = [960 * $x_ratio, 505 * $y_ratio]
- $dist = Sqrt(($BarbFeet[0] - $lootx) ^ 2 + ($BarbFeet[1] - $looty) ^ 2)
- $sprintremain = 3000 - TimerDiff($SprintStart)
- ;determine if sprint is still active to choose run speed
- If $sprintremain > 0 Then ;duration of sprint - 100 for safty
- ;calculate milliseconds per pixel for this run, return delay
- ;calculate composite sleep time
- If $dist < $PPmSsprint * $sprintremain Then
- Sleep($dist / $PPmSsprint + $extra)
- Else
- Sleep(($sprintremain + ($dist - $sprintremain * $PPmSsprint) / $PPmSwalk) + $extra)
- EndIf
- Else
- Sleep($dist / $PPmSwalk + $extra)
- EndIf
- EndFunc ;==>WalkTime
- Func Loot()
- $numgem = 0
- $numtomb = 0
- $numgold = 0
- $numpot = 0
- Send("{ALTDOWN}")
- MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
- If $LootLegendaries Then
- If $BlankLamps Then
- $frmBlock = GUICreate("block", 250 * $x_ratio, (250 - 20) * $y_ratio, Round(150 * $x_ratio), Round(225 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
- GUISetState(@SW_SHOW)
- $frmBlock2 = GUICreate("block", 200 * $x_ratio, (100 - 20) * $y_ratio, Round(700 * $x_ratio), Round(0 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
- GUISetState(@SW_SHOW)
- WinActivate("Diablo III")
- WinWaitActive("Diablo III", "", 1)
- EndIf
- If $ReduceLegendSearch Then
- $LegendaryCount += LootGear(0xBF642F, 1, 365, 442, 380)
- $LegendaryCount += LootGear(0xBF642F, 1, 442, 1690, 115)
- Else
- $LegendaryCount += LootGear(0xBF642F, 1)
- EndIf
- If $BlankLamps Then
- GUIDelete($frmBlock)
- GUIDelete($frmBlock2)
- EndIf
- EndIf
- If $LootSets Then
- $SetCount += LootGear(0x02CE01, 2)
- EndIf
- If $LootRares Then
- $RareCount += LootGear(0xBBBB00, 1)
- EndIf
- If $LootMagic Then
- $mac = LootGear(0x6969FF, 0)
- $MagicCount += $mac
- $numitem -= $mac
- EndIf
- If $LootGems Then
- Call("LootGems")
- LootImage("square.png", 90, 10)
- EndIf
- If $LootTomes Then
- Call("LootTomes")
- LootImage("tome.png", 90, 10)
- EndIf
- If $LootCustom Then
- Call("LootCustom")
- EndIf
- Send("{ALTUP}")
- Call("ShowLoot")
- EndFunc ;==>Loot
- Func LootGear($color, $tolerance = 2, $x1 = 400, $x2 = 1690, $y1 = 20, $y2 = 900)
- $count = 0
- $Loot = PixelSearch(Round($x1 * $x_ratio), Round($y1 * $y_ratio), Round($x2 * $x_ratio), Round($y2 * $y_ratio), $color, $tolerance)
- If Not @error Then
- While Not @error
- $count += 1
- MouseClick('left', $Loot[0], $Loot[1], 1, 1)
- Sleep(20)
- MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
- WalkTime($Loot[0], $Loot[1])
- ;Sleep(Random(700, 800))
- ;Run at max 10 times per quality
- If $count >= 10 Then
- ExitLoop
- EndIf
- $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
- WEnd
- EndIf
- $numitem += $count;
- Return $count
- EndFunc ;==>LootGear
- Func LootImage($img, $tol, $max = 10)
- $count = 0
- $gX = 0
- $gY = 0
- GUICtrlSetData($lblStatus, "Status: Looting - " & $img)
- While _ImageSearchArea($pngLoc & $img, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $tol)
- $count += 1
- MouseClick("left", $gX, $gY - 3, 1, 1)
- Sleep(50)
- MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
- If $img == "square.png" Then
- $GemCount += 1
- $numgem += 1
- ElseIf $img == "tome.png" Then
- $TomeCount += 1
- $numtomb += 1
- ElseIf $img == "gold.png" Then
- $numgold += 1
- ElseIf $img == "mythic.png" Then
- $numpot += 1
- EndIf
- WalkTime($gX, $gY)
- If $count >= $max Then
- ExitLoop
- EndIf
- WEnd
- EndFunc ;==>LootImage
- Func LootCustom()
- For $i = 0 To ($totalItems - 1)
- $array = StringSplit($pick[$i], "|")
- LootImage($array[1], $array[2], 5)
- Next
- EndFunc ;==>LootCustom
- Func Identify()
- Send($Inventory)
- Sleep(1300)
- $count = 0
- While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
- $count += 1
- GUICtrlSetData($lblStatus, "Status: Identifying")
- MouseClick("right", $gX, $gY, 1, 4)
- MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
- Sleep(Random(3000, 3500))
- If $count >= 30 Then
- ExitLoop
- EndIf
- WEnd
- Send($Inventory)
- Sleep(200)
- EndFunc ;==>Identify
- Func CleanOCR($text)
- $out = ""
- For $i = 1 To StringLen($text)
- $chr = Asc(StringMid($text, $i, 1))
- If $chr >= 48 And $chr <= 57 Then $out = $out & Chr($chr)
- If $chr = 79 Then $out = $out & '0'
- Next
- Return $out
- EndFunc ;==>CleanOCR
- Func ClickTab($Tabno)
- If $Tabno = 1 Then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
- If $Tabno = 2 Then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
- If $Tabno = 3 Then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
- Sleep(Random(100, 200))
- EndFunc ;==>ClickTab
- Func UseNextTab()
- If $ItemTab = $NextItemTab Then
- Call("AddLog", "Stash full Both tabs full, disabling stashing")
- $StashLegendary = False
- $StashRare = False
- $StashMagic = False
- Else
- Call("AddLog", "Stash full Using next tab")
- $ItemTab = $NextItemTab
- EndIf
- EndFunc ;==>UseNextTab
- Func AddLog($logtxt)
- Local $file = FileOpen("log.txt", 1)
- $msg = @MDAY & '/' & @MON & '/' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & ': ' & $logtxt & @CRLF
- FileWrite($file, $msg)
- FileClose($file)
- ConsoleWrite($msg)
- EndFunc ;==>AddLog
- Func StashLoot()
- GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
- MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
- Sleep(Random(800, 1000))
- ClickTab($GemTab)
- ;Tomes
- If $StashTomes Then
- GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
- ClickImage("TomeIcon.png", 140, 1)
- EndIf
- ;Gems (DOESN'T STASH BOTTOM ROW!)
- If $StashGems Then
- GUICtrlSetData($lblStatus, "Status: Stashing Gems")
- For $i = 0 To 7
- ClickImage($gems[$i], 150, 1)
- Next
- EndIf
- $numstashed = 0;
- ClickTab($ItemTab)
- If $StashLegendary Then
- ClickItems(0xFF7F00, 2, True, 5)
- ClickItems(0x8F5C25, 2, True, 5)
- EndIf
- If $StashRare Then
- ClickItems(0x4A3C0B, 1, True, 20)
- EndIf
- If $StashMagic Then
- ClickItems(0x182037, 1, True, 30)
- EndIf
- Call("AddLog", "Stashed Items: " & $numstashed)
- Sleep(Random(500, 600))
- Send("{SPACE}")
- EndFunc ;==>StashLoot
- Func VendorLoot()
- GUICtrlSetData($lblStatus, "Status: Vendoring Items")
- DoSprint()
- If Not $StashLoot Then ;Move from TP towards vendor
- Sleep(Random(100, 300))
- MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
- walktime(1565 * $x_ratio, 50 * $y_ratio)
- Else ;Move from Stash towards vendor
- Sleep(Random(100, 300))
- MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
- walktime(1560 * $x_ratio, 120 * $y_ratio)
- EndIf
- MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
- walktime(1030 * $x_ratio, 210 * $y_ratio, 200)
- $numsold = 0;
- ;All
- If $vendorAll Then
- For $c = 1 To $vendorCols
- For $r = 1 To $vendorRows
- RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
- Next
- Next
- EndIf
- ;Rares
- If $VendorRare Then
- ClickItems(0x4A3C0B, 2)
- EndIf
- ;Magic
- If $VendorMagic Then
- ClickItems(0x182037, 2)
- EndIf
- $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
- $mon = CleanOCR($mon)
- $mondelt = Number($mon) - Number($monold)
- GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
- $monold = $mon
- Call("AddLog", "Sold Items: " & $numsold & ", Sold value: " & $mondelt)
- Sleep(200)
- RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
- Sleep(300)
- RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
- Sleep(400)
- $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
- $mon = CleanOCR($mon)
- $mondelt = Number($mon) - Number($monold)
- GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
- $monold = $mon
- Call("AddLog", "Repair Cost: " & - $mondelt)
- GUICtrlSetData($lblStatus, "Status: Done With Vendor")
- Send("{ESCAPE}")
- EndFunc ;==>VendorLoot
- Func ClickItems($color, $tolerance, $checkfull = False, $max = 30)
- $c = 0
- While $c < $max
- RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
- Sleep(Random(60, 120))
- $StashPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $color, $tolerance)
- If Not @error Then
- MouseClick("right", $StashPixel[0], $StashPixel[1], 1, 4)
- $c += 1
- If $checkfull Then
- $numstashed += 1
- Else
- $numsold += 1
- EndIf
- Else
- ExitLoop
- EndIf
- WEnd
- Sleep(Random(60, 120))
- If $checkfull Then
- If $c = $max Then Call("UseNextTab")
- ClickTab($ItemTab)
- EndIf
- EndFunc ;==>ClickItems
- Func ClickImage($image, $tolerance, $max = 20)
- For $c = 1 To $max
- RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
- Sleep(Random(100, 300))
- If _ImageSearchArea($pngLoc & $image, 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, $tolerance) Then
- MouseClick("right", $gX, $gY, 1, 4)
- Sleep(120)
- Else
- ExitLoop
- EndIf
- Next
- EndFunc ;==>ClickImage
- Func SalvageLoot()
- DoSprint()
- GUICtrlSetData($lblStatus, "Status: Salvaging Items")
- Sleep(Random(300, 500))
- MouseClick("middle", 1786 * $x_ratio, 535 * $y_ratio)
- walktime(1786 * $x_ratio, 535 * $y_ratio, 100)
- ;Sleep(2000)
- MouseClick("left", 1430 * $x_ratio, 390 * $y_ratio) ;Talk to anvil
- ;Sleep(3000)
- walktime(1430 * $x_ratio, 390 * $y_ratio, 100)
- $c = 0
- While $c <= 20
- Sleep(Random(200, 300))
- $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 830 * $y_ratio, 0x182037, 1)
- If Not @error Then
- MouseClick("left", 265 * $x_ratio, 291 * $y_ratio, 1, 4)
- Sleep(Random(200, 300))
- MouseClick("left", $MagicPixel[0], $MagicPixel[1], 1, 4)
- Sleep(Random(200, 300))
- MouseClick("left", 1072 * $x_ratio, 375 * $y_ratio, 1, 4)
- RandMove(1200 * $x_ratio, 600 * $y_ratio, 5, 5, 2)
- Sleep(40)
- $c += 1
- Else
- ExitLoop
- EndIf
- WEnd
- Call("AddLog", "Salvaged Items: " & $c)
- Send("{SPACE}")
- Sleep(Random(300, 500))
- EndFunc ;==>SalvageLoot
- Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
- If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
- $findImage = "*TRANSBLACK " & $findImage
- If @AutoItX64 Then
- $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
- Else
- $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
- EndIf
- If $result = "0" Then
- Return 0
- EndIf
- ; Otherwise get the x,y location of the match and the size of the image to
- ; compute the centre of search
- $array = StringSplit($result[0], "|")
- If (UBound($array) >= 4) Then
- $x = Int(Number($array[2]))
- $y = Int(Number($array[3]))
- If $resultPosition = 1 Then
- $x = $x + Int(Number($array[4]) / 2)
- $y = $y + Int(Number($array[5]) / 2)
- EndIf
- Return 1
- EndIf
- EndFunc ;==>_ImageSearchArea
- Func LeaveGame()
- Call("RandSleep")
- GUICtrlSetData($lblStatus, "Status: Leaving Game")
- Send("{Escape}")
- Sleep(200)
- RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
- Call("CalcTime")
- Sleep($loadtime)
- EndFunc ;==>LeaveGame
- Func TownPortalShort()
- $gX = 0
- $gY = 0
- $c = 0
- GUICtrlSetData($lblStatus, "Status: Waiting for TP bar")
- Do
- $c += 1
- Sleep(200)
- If $c > 4 Then Return
- Until _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
- $seconds = $TPProtectTime
- $c = 0
- Do
- $c += 1
- GUICtrlSetData($lblStatus, "Status: Prepared for inturrupt, " & $seconds * 5 - $c)
- Sleep(200)
- If $c > ($seconds * 5) Then ;Make sure we never get stuck here for infinity.
- GUICtrlSetData($lblStatus, "Status: safe, doing long wait for town")
- Sleep($tptime - $seconds * 1000 - 1200)
- GUICtrlSetData($lblStatus, "Status: detecting town")
- CheckFor("NewTristram", "Area")
- Sleep(300)
- Return
- EndIf
- Until Not _ImageSearchArea($pngLoc & "TP.png", 1, 600, 200, 1000, 500, $gX, $gY, 50)
- EndFunc ;==>TownPortalShort
- Func TownPortal()
- GUICtrlSetData($lblStatus, "Status: Returning to Town")
- Send($TownPortalButton)
- If $DetectTPFail Then
- Call("TownPortalShort")
- Else
- Sleep(Random($tptime, $tptime + 500))
- EndIf
- EndFunc ;==>TownPortal
- #region OtherStuff
- Func Moving($time)
- Sleep($time / $movementSpeed)
- EndFunc ;==>Moving
- Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
- If $xOff < 1 Then $xOff = 1
- If $yOff < 1 Then $yOff = 1
- $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
- $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
- MouseClick($clickType, $randX, $randY, $clicks, $speed)
- EndFunc ;==>RandClick
- Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
- $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
- $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
- MouseMove($randX, $randY, $speed)
- EndFunc ;==>RandMove
- Func RandSleep($min = 5, $max = 45, $chance = 3)
- $randNum = Round(Random(1, 100))
- If $Timer And $randNum <= $chance Then
- $sleepTime = Random($min * 1000, $max * 1000)
- GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
- For $c = 0 To 10
- Sleep($sleepTime / 10)
- Next
- EndIf
- EndFunc ;==>RandSleep
- ;Hotkey Functions
- Func Begin()
- $Go = Not $Go
- If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
- EndFunc ;==>Begin
- Func TogglePause()
- $Paused = Not $Paused
- While $Paused
- Sleep(100)
- WinSetTitle($title, "", $title & $ver & " - Paused")
- ToolTip('[PAUSED] - Deaths: ' & $deathCount & ' | Cellars: ' & $cellarCount, 0, 0)
- WEnd
- WinSetTitle($title, "", $title & $ver & " - Running")
- ToolTip("")
- EndFunc ;==>TogglePause
- Func ShowLoot()
- GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
- GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
- EndFunc ;==>ShowLoot
- Func Stop() ;to allow the script to stop
- Exit
- EndFunc ;==>Stop
- Func GoTown()
- $mLootIn = 1
- EndFunc ;==>GoTown
- Func AnalyseLoots() ; Grid search + ilvl detection, a little bit slower than old method but computes db for fast stashing/vendoring/new salvaging
- ;ConsoleWrite("---- NEW ANALYSIS ----" & @crlf)
- $str_Stash = ""
- $str_StashGems = ""
- $str_StashMisc = ""
- $str_Vendor = ""
- $str_Salvage = ""
- $int_TownPosition = 0
- $int_emptygrid = 0
- $str_Ignore = ""
- $nX = 0
- $nY = 0
- GUICtrlSetData($lblStatus, "Status: Analysing loots")
- Send("c")
- Sleep(500)
- For $y = 0 To 5
- $int_emptygrid = 0
- MouseMove(1435, Round(609 + (45 * $y)), 1)
- Sleep(500)
- For $x = 0 To 9
- If StringInStr($str_Ignore, 1435 + (48 * $x) & "," & 609 + (45 * $y)) Then ContinueLoop
- MouseMove(1435 + (48 * $x), 609 + (45 * $y), 1)
- Sleep(300)
- If _ImageSearchArea($pngLoc & "tt_check.png", 0, Round((1435 + (48 * $x) - 455) * $x_ratio), Round((609 + (45 * $y) - 500) * $y_ratio), Round((1435 + (48 * $x) - 35) * $x_ratio), Round(1080 * $y_ratio), $gX, $gY, 10) Then ; If tooltip exists
- $int_emptygrid = 0
- If _ImageSearchArea($pngLoc & "tt_unidentified.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) And $Identify Then ; Identify items.
- MouseClick("secondary")
- Sleep(Random(3000, 3500, 1))
- EndIf
- If _ImageSearchArea($pngLoc & "tt_square.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Gem, automatic stashing.
- $str_StashGems = $str_StashGems & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_tome.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Tome, automatic stashing.
- $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_exquisite.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
- $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_iridescent.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing.
- $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_fiery.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 40) Then ; Crafting, automatic stashing (faster than the pixel detection below).
- $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_plan.png", 0, $gX, $gY, $gX + 425, $gY + 70, $gX, $gY, 60) Then ; Plans, automatic stashing.
- $str_StashMisc = $str_StashMisc & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "tt_neck.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_waist.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_finger.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 And _ImageSearchArea($pngLoc & "tt_follower.png", 0, $gX + 320, $gY + 60, $gX + 425, $gY + 150, $nX, $nY, 60) == 0 Then
- $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * ($y + 1))
- EndIf
- $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x00FF00, 1) ; Set, no ilvl check since they drop rarely. Goes to stash.
- If Not @error Then
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xBF642F, 1) ; Legendary, no ilvl check since they drop rarely. Goes to stash.
- If Not @error Then
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ContinueLoop
- EndIf
- $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0xFFFF00, 1) ; Rare
- If Not @error Then
- If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 59
- If (getOption("i59r") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- ElseIf (getOption("i59r") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 60, goes to salvage
- If (getOption("i60r") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- ElseIf (getOption("i60r") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 61, goes to salvage
- If (getOption("i61r") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- ElseIf (getOption("i61r") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 62, goes to salvage
- If (getOption("i62r") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- ElseIf (getOption("i62r") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y) & ",r"
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Rare ilvl 63, goes to stash
- If (getOption("i63r") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i63r") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- ; Below ilvl 59
- If $StashRare Then
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf $VendorRare Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- $tt_title = PixelSearch($gX, $gY, $gX + 425, $gY + 70, 0x6969FF, 1) ; Magic
- If Not @error Then
- If _ImageSearchArea($pngLoc & "ilvl59.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 59
- If (getOption("i59m") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i59m") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl60.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 60, goes to salvage
- If (getOption("i60m") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i60m") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl61.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 61, goes to salvage
- If (getOption("i61m") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i61m") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl62.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 62, goes to salvage
- If (getOption("i62m") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i62m") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- If _ImageSearchArea($pngLoc & "ilvl63.png", 0, $gX, $gY, $gX + 125, Round(1080 * $y_ratio), $gX, $gY, 20) Then ; Magic ilvl 63, goes to stash
- If (getOption("i63m") == 1) Then
- $str_Salvage = $str_Salvage & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf (getOption("i63m") == 2) Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- ; Below ilvl 59
- If $StashMagic Then
- $str_Stash = $str_Stash & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- ElseIf $VendorMagic Then
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $str_Ignore = $str_Ignore & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- EndIf
- ContinueLoop
- EndIf
- ; Probably white/gray trash bugged pick, add to vendor string
- $str_Vendor = $str_Vendor & "|" & 1435 + (48 * $x) & "," & 609 + (45 * $y)
- Else
- $int_emptygrid += 1
- If $int_emptygrid == 2 Then ; If there's nothing 2 times in a row in a row (see wut i did thar?), it probably ends here, skip to the next row.
- $int_emptygrid = 0
- ExitLoop
- Else
- ContinueLoop
- EndIf
- EndIf
- Next
- Next
- Send("c")
- Sleep(500)
- ;Call("AddLog", "Stash gear : " & $str_Stash )
- ;Call("AddLog", "Stash misc : " & $str_StashMisc )
- ;Call("AddLog", "Stash gems : " & $str_StashGems )
- ;Call("AddLog", "Salvage : " & $str_Salvage )
- ;Call("AddLog", "Vendor : " & $str_Vendor )
- ;Call("AddLog", "Ignored Square : " & $str_Ignore )
- Call("AddLog", "Stashed Items: " & UBound(StringSplit($str_Stash, "|")))
- If $str_Stash <> "" Or $str_StashGems <> "" Or $str_StashMisc <> "" Then Call("StashLoot_new")
- If $str_Salvage <> "" Then Call("SalvageLoot_new")
- If $str_Vendor <> "" Then Call("VendorLoot_new")
- EndFunc ;==>AnalyseLoots
- Func StashLoot_new()
- $arr_split = ""
- $pos_split = ""
- GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
- MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
- Moving(1600)
- $int_TownPosition = 1
- ;Gems Page 1
- If $str_StashGems <> "" Then
- ClickTab($GemTab)
- $str_StashGems = StringMid($str_StashGems, 2)
- $arr_split = StringSplit($str_StashGems, "|")
- For $i = 1 To $arr_split[0]
- Sleep(Random(300, 350))
- $pos_split = StringSplit($arr_split[$i], ",", 2)
- MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
- Next
- EndIf
- ;Tomes/Crafting Materials/Plans/Etc Page 2
- If $str_StashMisc <> "" Then
- ClickTab($GemTab)
- $str_StashMisc = StringMid($str_StashMisc, 2)
- $arr_split = StringSplit($str_StashMisc, "|")
- For $i = 1 To $arr_split[0]
- Sleep(Random(300, 350))
- $pos_split = StringSplit($arr_split[$i], ",", 2)
- MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
- Next
- EndIf
- ;Gears Page 2
- If $str_Stash <> "" Then
- $str_Stash = StringMid($str_Stash, 2)
- $arr_split = StringSplit($str_Stash, "|")
- For $i = 1 To $arr_split[0]
- Sleep(Random(80, 100))
- If Random() < 0.5 Then
- ClickTab($ItemTab)
- Else
- ClickTab($NextItemTab)
- EndIf
- Sleep(Random(300, 350))
- $pos_split = StringSplit($arr_split[$i], ",", 2)
- MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
- Next
- EndIf
- Sleep(Random(100, 150))
- Send("{SPACE}")
- EndFunc ;==>StashLoot_new
- Func SalvageLoot_new()
- $arr_split = ""
- $pos_split = ""
- GUICtrlSetData($lblStatus, "Status: Salvaging loots")
- If $int_TownPosition = 0 Then ; Starting from TP
- MouseClick("middle", 1582 * $x_ratio, 527 * $y_ratio)
- Moving(2000)
- MouseClick("left", 1661 * $x_ratio, 409 * $y_ratio)
- Moving(2500)
- Else ; Starting from Stash
- MouseClick("middle", 1484 * $x_ratio, 583 * $y_ratio)
- Moving(2000)
- MouseClick("left", 1773 * $x_ratio, 484 * $y_ratio)
- Moving(2500)
- EndIf
- $int_TownPosition = 2
- MouseClick("left", 263 * $x_ratio, 287 * $y_ratio)
- $str_Salvage = StringMid($str_Salvage, 2)
- $arr_split = StringSplit($str_Salvage, "|")
- For $i = 1 To $arr_split[0]
- Sleep(Random(300, 400))
- $pos_split = StringSplit($arr_split[$i], ",")
- MouseClick("left", $pos_split[1], $pos_split[2], 1, 3)
- If $pos_split[0] == 3 Then
- Send("{ENTER}")
- Sleep(1000)
- EndIf
- Next
- Sleep(Random(300, 400))
- Send("{SPACE}")
- EndFunc ;==>SalvageLoot_new
- Func VendorLoot_new()
- $arr_split = ""
- $pos_split = ""
- GUICtrlSetData($lblStatus, "Status: Vendoring Items")
- If $int_TownPosition = 0 Then ; Starting from TP
- MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
- ElseIf $int_TownPosition = 1 Then ; Starting from Stash
- MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
- Else ; Starting from Blacksmith
- MouseClick("middle", 738 * $x_ratio, 64 * $y_ratio)
- EndIf
- Moving(3000)
- MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
- Moving(3000)
- $str_Vendor = StringMid($str_Vendor, 2)
- $arr_split = StringSplit($str_Vendor, "|")
- For $i = 1 To $arr_split[0]
- Sleep(Random(100, 300))
- $pos_split = StringSplit($arr_split[$i], ",", 2)
- MouseClick("right", $pos_split[0], $pos_split[1], 1, 3)
- If PixelGetColor(819 * $x_ratio, 375 * $y_ratio) == 0x370C00 Then Send("{ENTER}")
- Next
- Sleep(Random(100, 200))
- $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
- $mon = CleanOCR($mon)
- $mondelt = Number($mon) - Number($monold)
- GUICtrlSetData($lblGold, "Gold: " & $mon & ", Sold value: " & $mondelt)
- $monold = $mon
- Call("AddLog", "Sold Items: " & $arr_split[0] & ", Sold value: " & $mondelt)
- Sleep(Random(200, 300))
- RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
- Sleep(200)
- RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
- Sleep(400)
- $mon = _TesseractScreenCapture(0, "", 1, 2, 1454 * $x_ratio, 508 * $y_ratio, (1920 - 1571) * $x_ratio, (1080 - 525) * $y_ratio, 0)
- $mon = CleanOCR($mon)
- $mondelt = Number($mon) - Number($monold)
- GUICtrlSetData($lblGold, "Gold: " & $mon & ", Repair cost: " & $mondelt)
- $monold = $mon
- Call("AddLog", "Repair Cost: " & - $mondelt)
- GUICtrlSetData($lblStatus, "Status: Done With Vendor")
- Send("{SPACE}")
- EndFunc ;==>VendorLoot_new
- Func getOption($option) ;Gets the correct INI settings corrisponding to the vend/stash/salvage of items.
- If ($option == "i59r") Then
- If ($i59Rare = "salvage") Then
- Return 1
- ElseIf ($i59Rare = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i60r") Then
- If ($i60Rare = "salvage") Then
- Return 1
- ElseIf ($i60Rare = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i61r") Then
- If ($i61Rare = "salvage") Then
- Return 1
- ElseIf ($i61Rare = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i62r") Then
- If ($i62Rare = "salvage") Then
- Return 1
- ElseIf ($i62Rare = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i63r") Then
- If ($i63Rare = "salvage") Then
- Return 1
- ElseIf ($i63Rare = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i59m") Then
- If ($i59Magic = "salvage") Then
- Return 1
- ElseIf ($i59Magic = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i60m") Then
- If ($i60Magic = "salvage") Then
- Return 1
- ElseIf ($i60Magic = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i61m") Then
- If ($i61Magic = "salvage") Then
- Return 1
- ElseIf ($i61Magic = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i62m") Then
- If ($i62Magic = "salvage") Then
- Return 1
- ElseIf ($i62Magic = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- ElseIf ($option == "i63m") Then
- If ($i63Magic = "salvage") Then
- Return 1
- ElseIf ($i63Magic = "vend") Then
- Return 2
- Else
- Return 0
- EndIf
- Else
- Return 0
- EndIf
- EndFunc ;==>getOption
- #endregion OtherStuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement