Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Darkling Lord's Sarkoth DH Script v1.3.5 - 6/19/2012
- ;Installation Instructions: http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/356234-gold-item-farming-shimizokis-sarkoth-dh-script-autoit.html
- ;;;;;
- ;Revision: notAres @ ownedcore
- ;Original: mackus101 @ ownedcore
- ;#include <ImageSearch.au3>
- Global $Paused
- Global $ini = "S-SarkothBot.ini"
- Global $log = "S-SarkothBot.log"
- ; -------------------- Update Variables --------------------- ;
- $VersionsInfo = "https://dl.dropbox.com/s/657jmncdq5wrqcz/version.ini?dl=1" ; Link to version.ini for updater
- $oldVersion = IniRead("updater.ini","Version","Version","Unknown") ; Read the version from updater.ini
- $newVersion = "0.0" ; Initialize new version variable
- ;Get Window Status
- Opt('MouseCoordMode', 2)
- Opt('PixelCoordMode', 2)
- $size = WinGetClientSize("[TITLE:Diablo III; CLASS:D3 Main Window Class]")
- If @error Then
- MsgBox(16, "Fatal Error", "FATAL ERROR: Diablo 3 not running or not in Fullscreen Windowed")
- Exit
- EndIf
- If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
- ;Hotkeys
- HotKeySet("=","Leave") ;script started by pressing =
- HotKeySet("-", "Pause") ;script paused by pressing -
- HotKeySet("x", "Stop") ;script stopped by pressing x
- ;Sell
- $vendorArea = True ;Vendors all the items in a area ROWSxCOLS
- $vendorRows = 4 ;Rows to vendor
- $vendorCols = 10 ;Cols to vendor
- ;Change to match your abilities (1-4 by default)
- $skillSmokeScreen = "w"
- $skillPreperation = "a"
- $skillCompanion = "s"
- $skillCaltrops = "d"
- ;Stats
- $movementSpeed = 0 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
- $pickupRadius = 0 ;Pickup globe/gold radius
- ;Custom Loot
- $pngLoc = "C:\Your Path\" ;Location of the .PNGs
- $totalItems = 1 ;Number of items in the pick array
- $currentArrayItem = 0
- Global $pick[$totalItems] ;DONT CHANGE THIS
- ;Array of items to loot
- $pick[0] = "mythic.png|40" ;png|Tolerance
- ;$pick[1] = "item2.png"
- ;$pick[2] = "item3.png"
- ;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 = False ;True if you want to pick up Tome of Secrets (Automatically picked up when LootMagic is True)
- $LootCustom = False ;True if you want to pick up Custom Items (The items in the pick array above)
- ;Manage Loot
- $mLoot = 5 ;Nuber of successful runs until Stash and Vendor
- $IdentifyLoot = False ;True if you want to identify items
- ;Stashing
- $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
- $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
- $StashTomes = False ;True if you want to store Tomes items in the stash
- ;Vendoring
- $VendorLoot = True ;True if you want to vendor Items
- $VendorRare = False ;True if you want to vendor Rares
- $VendorMagic = False ;True if you want to vendor Magic
- ;Variability
- $Timer = False ;True and the bot will add random sleep intervals
- $atk1Time = 8.5 ;Time in seconds to attack with the right mouse button
- $atk2Time = 4.5 ;Time in seconds to attack with the left mouse button
- $atk3Time = 5 ;Time in seconds to attack both sides of sarkoth
- $usingNT = False ;True if using NetherTentacles instead of Ball Lightning
- ;Options
- $CreateLog = True ;True if you want to create a log file
- $autoUpdate = True ;True if you want to automatically download new versions of this bot
- ;Constants
- $loadtime = 3200 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
- $yellow = 0xFFF000 ; yellow color code (repair icon)
- $red = 0xD90000 ; red color code (repair icon)
- $go = True
- $Leave = False
- $Logout = False
- $default_resolutionX = 1920 ;DO NOT CHANGE
- $default_resolutionY = 1080 ;DO NOT CHANGE (seriously... i'll beat you with a stick)
- $x_ratio = $size[0] / $default_resolutionX
- $y_ratio = $size[1] / $default_resolutionY
- $gX = 0
- $gY = 0
- ;States
- $ExpectedState = "MainMenu" ;Where the script thinks it should be
- $ActualState = "" ;Where the script knows it was
- ;Counts
- $LegendaryCount = 0
- $SetCount = 0
- $RareCount = 0
- $MagicCount = 0
- $GemCount = 0
- $TomeCount = 0
- $runCount = 0
- $cellarCount = 0
- $deathCount = 0
- $t = TimerInit()
- $rt = 0
- ;INI File
- If FileExists($ini) Then
- ReadINI()
- Else
- CreateINI()
- EndIf
- ;Update Bot
- If $autoUpdate == True Then
- ;#RequireAdmin
- Call("DoUpdate")
- EndIf
- ;Log File
- If $CreateLog == True Then
- $LogFile = FileOpen($log, 2)
- EndIf
- ;Calculate new values
- $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
- $movementSpeed = 1+($movementSpeed/100)
- ;Check that PNGs are in the proper location
- 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
- ;Main
- While $go
- Call("RunBot")
- WEnd
- ;Script
- Func RunBot()
- if($Leave) Then
- ;Check and Handle Network Disconnect
- If CheckFor("DisconnectError", 720*$x_ratio, 360*$y_ratio, 1200*$x_ratio, 480*$y_ratio, .5) Then
- RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 25*$x_ratio, 5*$y_ratio)
- Sleep(1500)
- EndIf
- ;Main portion of script
- Select
- Case $ExpectedState == "OldRuins"
- LogWrite("Expects - OldRuins")
- UpdateTooltip()
- ;Checks that the player is in the Old Ruins
- If CheckFor("OldRuins", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio) Then
- UpdateTooltip()
- ;Start Run
- RandClick("middle", Round(500*$x_ratio), Round(250*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;starts the run [waypoint 1]
- Moving(1125)
- Send($skillSmokeScreen)
- Moving(440)
- RandClick("middle", 1, Round(370*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;waits ~1 second then [waypoint 2]
- Moving(1875)
- RandClick("middle", Round(400*$x_ratio), Round(600*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;middle of courtyard [waypoint 3]
- Moving(50)
- Send($skillSmokeScreen)
- Moving(25)
- Send($skillPreperation)
- Moving(750)
- Send($skillCaltrops)
- Sleep(300)
- RandMove(Round(300*$x_ratio),Round(80*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
- ;Checks if Dank Cellar is Open
- LogWrite("Checking - DankCellar")
- $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
- If Not @error Then
- $ExpectedState = "DankCellar"
- LogWrite(" Moving - To DankCellar")
- RandClick("left", Round(300*$x_ratio), Round(80*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;Entrance to cellar
- Moving(750)
- Send($skillSmokeScreen)
- Moving(2500)
- Else ;ABORT RUN
- LogWrite(" Not Found - DankCellar")
- Sleep(10)
- 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(200)
- Send($skillSmokeScreen)
- Sleep(40)
- Call("TownPortal")
- EndIf
- Else
- If $ActualState == "MainMenu" OR $ActualState == "NewTristram" Then
- $ExpectedState = $ActualState
- ElseIf Not Call("CheckDead") Then
- Call("TownPortal")
- EndIf
- EndIf
- Case $ExpectedState == "DankCellar"
- LogWrite("Expects - DankCellar")
- UpdateTooltip()
- ;Checks that the player is in the Dank Cellarwa
- If CheckFor("DankCellar", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio, 5) Then
- $cellarCount += 1
- UpdateTooltip()
- RandClick("middle", Round(120*$x_ratio), Round(1020*$y_ratio), 10*$x_ratio, 10*$y_ratio) ;moves to doorway leading to rare inside cellar
- Moving(2750)
- RandMove(Round(450*$x_ratio),Round(70*$y_ratio), 5*$x_ratio, 5*$y_ratio) ;hovers over the rare Sarkoth
- Sleep(10)
- Send("{SHIFTDOWN}")
- MouseDown("right") ;ATTACK
- Send($skillCompanion)
- Sleep($atk1Time*1000)
- MouseUp("right")
- ;If using NT, Attack both sides
- If $usingNT == True Then
- ;Sleep(4000)
- RandMove(Round(300 * $x_ratio), Round(75 * $y_ratio), 1, 1) ;attack left
- MouseDown("right")
- Sleep($atk3Time*1000)
- MouseUp("right")
- RandMove(Round(530 * $x_ratio), Round(50 * $y_ratio), 1, 1) ;attack right
- MouseDown("right")
- Sleep($atk3Time*1000)
- MouseUp("right")
- EndIf
- Sleep(500)
- RandClick("right", Round(600*$x_ratio), Round(20*$y_ratio)) ;break the table & chair
- MouseDown("left")
- Sleep($atk2Time*1000)
- MouseUP("left")
- Sleep(Random(50, 150))
- Send("{SHIFTUP}")
- Sleep(Random(300, 500))
- ;Do a little dance because you have a low pickup radius
- If $pickupRadius <= 10 Then
- RandClick("middle", Round(370*$x_ratio), Round(180*$y_ratio)) ;Left
- Moving(2500)
- RandClick("middle", Round(1200*$x_ratio), Round(380*$y_ratio)) ;Right
- Moving(1500)
- Else
- RandClick("middle", Round(530*$x_ratio), Round(190*$y_ratio)) ;location of sarkoth after death
- Moving(2750)
- Endif
- Send($skillCompanion)
- Call("Loot")
- $mLootIn -= 1
- Send($skillCompanion)
- RandSleep(5, 10, 50)
- Call("TownPortal")
- Else
- If $ActualState == "MainMenu" OR $ActualState == "NewTristram" Then
- $ExpectedState = $ActualState
- ElseIf Not Call("CheckDead") Then
- Call("TownPortal")
- EndIf
- EndIf
- Case $ExpectedState == "NewTristram"
- ;Ensure successful town portal
- If Call("CheckDead") Then
- Return
- EndIf
- LogWrite("Expects - New Tristram")
- UpdateTooltip()
- ;Checks that theplayer is in New Tristram
- If CheckFor("NewTristram", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio, 5) Then
- UpdateTooltip()
- RandSleep(30, 60, 10)
- ;If its time to manage loot
- If $mLootIn == 0 Then
- If $IdentifyLoot == True Then
- ;Call("Identify")
- EndIf
- If $StashLoot == True Then
- Call("Stash")
- EndIf
- If $VendorLoot == True Then
- Call("VendorLoot")
- EndIf
- $mLootIn = $mLoot ;Reset Counter
- Else
- ;Check if player needs to repair
- Call("CheckRepair")
- EndIf
- Call("LeaveGame")
- Else
- If $ActualState == "MainMenu" Then
- $ExpectedState = $ActualState
- ElseIf Not Call("CheckDead") Then
- Call("TownPortal")
- EndIf
- EndIf
- Case Else
- LogWrite("Expects - MainMenu")
- UpdateTooltip()
- ;Checks if the player is in the Main Menu
- If CheckFor("MainMenu", 0*$x_ratio, 360*$y_ratio, 480*$x_ratio, 480*$y_ratio) Then
- $runCount += 1
- UpdateTooltip()
- RandSleep(60, 180, 2)
- ;Keep trying to enter game if Game Limit has been reahed.
- ; While True
- RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120*$x_ratio, 5*$y_ratio) ;Random Click on the resume button
- ; If CheckFor("LimitError", Round(720*$x_ratio), Round(480*$y_ratio), Round(960*$x_ratio), Round(600*$y_ratio), .5) Then
- ; Sleep(Random(1000, 2000))
- ; RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 25*$x_ratio, 5*$y_ratio)
- ; $rand = Random(40000, 80000)
- ; LogWrite("Waiting " & Round($rand/1000) & " seconds.")
- ; Sleep($rand)
- ; Else
- ; ExitLoop
- ; EndIf
- ; WEnd
- $rt = TimerInit()
- $ExpectedState = "OldRuins"
- LogWrite("Runs: " & $runCount & ", Manage In: " & $mLootIn)
- Else
- If $ActualState == "" Then
- MsgBox(16, "Fatal Error", "FATAL ERROR: " & $pngLoc & "MainMenu.png" & @CRLF & "Image is not recognizeable.")
- Exit
- ElseIf Not Call("CheckDead") Then
- Call("LeaveGame")
- EndIf
- EndIf
- EndSelect
- EndIf
- EndFunc
- ;Helper Functions
- Func CheckDead()
- LogWrite("Checking Death")
- $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
- LogWrite(" Found - Logout Cancel")
- ;Sleep(11000)
- Return True
- Else
- LogWrite(" Not Found - Logout Cancel")
- 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
- Sleep(200)
- Send("{SPACE}") ;close any open windows
- Return True
- 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
- LogWrite(" Found - Death")
- $deathCount += 1
- UpdateTooltip()
- Call("LeaveGame")
- Sleep(11000)
- Return True
- Else
- LogWrite(" Not Found - Death")
- Return False
- EndIf
- EndFunc
- Func CheckRepair()
- LogWrite("Checking - Repair")
- $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
- If Not @error Then
- LogWrite(" Found - Damaged")
- Call("DoRepair")
- Else
- LogWrite(" Not Found - Damaged")
- EndIf
- $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
- If Not @error Then
- LogWrite(" Found - Broken")
- Call("DoRepair")
- Else
- LogWrite(" Not Found - Broken")
- EndIf
- EndFunc
- Func DoRepair()
- LogWrite("Start - Repairing")
- Sleep(Random(75, 150))
- MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
- Moving(1875)
- MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
- Moving(1875)
- MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
- Moving(2000)
- ;Make sure window is open
- $VendorFound = PixelSearch(Round(0*$x_ratio), Round(0*$y_ratio), Round(420*$x_ratio), Round(120*$y_ratio), 0xC5C25A, 5) ; checks for the bright spot on bag at top of vendor
- If Not @error Then
- LogWrite("Found - Repair")
- MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
- Sleep(400)
- MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
- Sleep(200)
- Send("{Escape}")
- Sleep(500)
- Else
- Send("{SPACE}")
- LogWrite("Not Found - Repair")
- EndIf
- LogWrite("Finished - Repairing")
- EndFunc
- Func CalcTime()
- $srt = TimerDiff($rt)
- LogWrite("Runtime: " & Round($srt/1000,2) & " seconds.")
- $trt = TimerDiff($t)
- $total = Round((($trt/1000)/60)/60,4)
- ;Total runtiume 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
- LogWrite("Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes.")
- LogWrite("")
- EndFunc
- Func CheckFor($img, $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 10, $tolerance = 100)
- $c = 0
- $string = $pngLoc & $img & ".png"
- Do
- $c +=1
- Sleep(100)
- If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
- LogWrite(" Not Found - " & $img)
- Return False
- EndIf
- Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
- LogWrite(" Found - " & $img)
- $ActualState = $img
- Return True
- EndFunc
- Func Identify()
- Send("i")
- Sleep(1300)
- LogWrite("Start - Identify")
- $preArmor = PixelChecksum(1600, 170, 1865, 535)
- While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400*$x_ratio, 580*$y_ratio, 1915*$x_ratio, 890*$y_ratio, $gX, $gY, 120)
- LogWrite(" Found - Unidentified")
- MouseClick("right", $gX, $gY, 1, 4)
- Sleep(250)
- If Not $preArmor = PixelChecksum(1600, 170, 1865, 535) Then
- LogWrite(" Error - Missidentified")
- Sleep(250)
- MouseClick("right", $gX, $gY, 1, 4)
- Else
- LogWrite(" Identifying")
- MouseMove(Round(Random(0, 400)*$x_ratio), Round(Random(700, 1080)*$y_ratio), 3) ;Moves mouse out of the way
- Sleep(Random(3000, 3500))
- EndIf
- WEnd
- LogWrite("Finish - Identify")
- Send("i")
- Sleep(200)
- EndFunc
- Func LeaveGame()
- LogWrite("Leaving Game")
- $Logout = true
- Call("RandSleep")
- Sleep(Random(100, 500))
- Send("{Escape}")
- Sleep(Random(100, 500))
- RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120*$x_ratio, 5*$y_ratio) ;Random Click on the leave button
- $ExpectedState = "MainMenu"
- Call("CalcTime")
- EndFunc
- Func Loot()
- LogWrite("Start - Looting")
- MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
- If $LootSets == True Then
- LogWrite(" Searching - Set")
- $SetCount += LootGear(0x02CE01, 2)
- EndIf
- If $LootLegendaries == True Then
- LogWrite(" Searching - Legendary")
- $LegendaryCount += LootGear(0xBF642F, 0)
- EndIf
- If $LootRares == True Then
- LogWrite(" Searching - Rare")
- $RareCount += LootGear(0xBBBB00, 2)
- EndIf
- If $LootTomes == True Then
- LogWrite(" Searching - Tome")
- $TomeCount += LootItem("tome", 100)
- EndIf
- If $LootMagic == True Then
- LogWrite(" Searching - Magic")
- $MagicCount += LootGear(0x6969FF, 2)
- EndIf
- If $LootGems == True Then
- LogWrite(" Searching - Gem")
- $GemCount += LootItem("square", 115)
- EndIf
- If $LootCustom == True Then
- LogWrite(" Searching - Custom")
- for $i = 0 to ($totalItems - 1)
- $array = StringSplit($pick[$i],"|")
- $file = $array[1]
- $tolerance = $array[2]
- LootItem($file, $tolerance)
- next
- EndIf
- LogWrite("Finished - Looting")
- EndFunc
- Func LootGear($color, $tolerance = 2)
- $count = 0
- $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance) ; Magic loot (darker for compatibility)
- While Not @error
- LogWrite(" Found - " & $color)
- $count += 1
- MouseClick ('left', $Loot[0], $Loot[1])
- Moving(900)
- MouseMove(Round(Random(1400,1600)*$x_ratio),Round(Random(700,900)*$y_ratio),3) ;Moves mouse out of the way
- ;Run at max 5 times per quality
- If $count >= 5 Then
- LogWrite(" Overburdened - " & $color)
- ExitLoop
- EndIf
- $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance) ; Magic loot (darker for compatibility)
- WEnd
- Return $count
- EndFunc
- Func LootItem($item, $tolerance)
- $count = 0
- $gX = 0
- $gY = 0
- While _ImageSearchArea($pngLoc & $item & ".png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$tolerance)
- LogWrite(" Found - " & $item)
- $count += 1
- sleep(Random(75, 150))
- MouseClick("left",$gX,$gY)
- Moving(900)
- MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
- ;Run at max 5 times per quality
- $count += 1
- If $count >= 5 Then
- ExitLoop
- EndIf
- WEnd
- Return $count
- EndFunc
- Func Moving($time)
- Sleep($time/$movementSpeed)
- EndFunc
- Func RandClick($clickType, $xPos, $yPos, $xOff = 5, $yOff = 5, $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
- Func RandMove($xPos, $yPos, $xOff = 5, $yOff = 5)
- 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)))
- MouseMove($randX, $randY)
- EndFunc
- Func RandSleep($min = 30, $max = 60, $chance = 5)
- $randNum = Round(Random(1, 100))
- If $Timer == True And $randNum <= $chance Then
- $sleepTime = Random($min*1000, $max*1000)
- LogWrite("Random Sleep - " & Round($sleepTime/1000) & " sec" & @CRLF)
- For $c = 0 To 10
- Sleep($sleepTime/10)
- ConsoleWrite("|")
- Next
- ConsoleWrite(@CRLF)
- EndIf
- EndFunc
- Func Stash()
- LogWrite("Start - Stashing")
- Sleep(Random(250, 500))
- MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
- Moving(1875)
- ;Legendaries
- If $StashLegendary == True Then
- StashGear(0x4D2C0D, 0)
- EndIf
- ;Rares
- If $StashRare == True Then
- StashGear(0x4A3C0B, 1)
- EndIf
- ;Tomes
- $count = 0
- While $StashTomes == True
- LogWrite("Searching - Tome")
- If _ImageSearchArea($pngLoc & "tomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,100) Then
- LogWrite("Stashing - Tome")
- MouseClick("left",500*$x_ratio,360*$y_ratio,1,1)
- Sleep(Random(500, 750))
- MouseClick("right",$gX,$gY,1,1)
- Sleep(Random(400, 600))
- MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
- Sleep(Random(200, 500))
- ;Run at max 5 times per quality
- $count += 1
- If $count >= 5 Then
- LogWrite(" Overburdened - Tome")
- ExitLoop
- EndIf
- Else
- ExitLoop
- EndIf
- WEnd
- ;Magic
- While $StashMagic == True
- StashGear(0x182037, 2)
- WEnd
- Sleep(Random(500, 1000))
- LogWrite("Finished - Stashing")
- Send("{ESCAPE}")
- EndFunc
- Func StashGear($color, $tolerance)
- $count = 0
- While True
- LogWrite("Searching - " & $color)
- Sleep(Random(200, 300))
- $Stash = PixelSearch(1400*$x_ratio, 580*$y_ratio, 1915*$x_ratio, 890*$y_ratio, $color, $tolerance)
- If Not @error Then
- LogWrite("Stashing - " & $color)
- MouseClick("right", $Stash[0], $Stash[1])
- ;Run at max 5 times per quality
- $count += 1
- If $count >= 5 Then
- LogWrite(" Overburdened - " & $color)
- ExitLoop
- EndIf
- Else
- ExitLoop
- EndIf
- WEnd
- EndFunc
- Func TownPortal()
- LogWrite("Calling - TownPortal")
- Send("t")
- Sleep(6500)
- $ExpectedState = "NewTristram"
- EndFunc
- Func VendorLoot()
- LogWrite("Start - Vendoring")
- If Not $StashLoot Then ;Move from TP towards vendor
- LogWrite("Moving - From Portal")
- Sleep(Random(300, 500))
- MouseClick("left", 1565*$x_ratio, 50*$y_ratio)
- Else ;Move from Stash towards vendor
- LogWrite("Moving - From Stash")
- Sleep(Random(300, 500))
- MouseClick("left", 1560*$x_ratio, 120*$y_ratio)
- EndIf
- LogWrite("Moving - To Vendor")
- Moving(3000)
- MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
- Moving(2500)
- ;Make sure window is open
- $VendorFound = PixelSearch(Round(0*$x_ratio), Round(0*$y_ratio), Round(420*$x_ratio), Round(120*$y_ratio), 0xC5C25A, 5) ; checks for the bright spot on bag at top of vendor
- If Not @error Then
- LogWrite("Found - Vendor")
- ;All
- If $vendorArea == True Then
- LogWrite("Vendor All - R=" & $vendorRows & " C=" & $vendorCols)
- 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), 1, 2, 1, 3)
- Next
- Next
- EndIf
- ;Rares
- If $VendorRare == True Then
- $c = 0
- While $VendorRare
- LogWrite("Searching - Rare")
- Sleep(Random(200, 300))
- $RarePixel = PixelSearch(1400*$x_ratio, 580*$y_ratio, 1915*$x_ratio, 890*$y_ratio, 0x4A3C0B, 1)
- If Not @error Then
- LogWrite("Found - Rare")
- MouseClick("right", $RarePixel[0], $RarePixel[1])
- $c += 1
- If $c >= 20 Then
- LogWrite("Excess/Un-identified - Rare")
- ExitLoop
- EndIf
- Else
- LogWrite("Not Found - Rare")
- ExitLoop
- EndIf
- WEnd
- EndIf
- ;Magic
- If $VendorMagic == True Then
- LogWrite("Searching - Magic")
- $c = 0
- While True
- Sleep(Random(100, 300))
- $MagicPixel = PixelSearch(1400*$x_ratio, 580*$y_ratio, 1915*$x_ratio, 890*$y_ratio, 0x182037, 2)
- If Not @error Then
- LogWrite("Found - Magic")
- MouseClick("right", $MagicPixel[0], $MagicPixel[1])
- $c += 1
- If $c >= 20 Then
- LogWrite("Excess/Un-identified - Magic")
- ExitLoop
- EndIf
- Else
- LogWrite("Not Found - Magic")
- ExitLoop
- EndIf
- WEnd
- EndIf
- Sleep(Random(500, 1000))
- LogWrite("Finished - Vendoring")
- Send("{ESCAPE}")
- Else
- Send("{SPACE}")
- LogWrite("Not Found - Vendor")
- EndIf
- LogWrite("Finished - Vendoring")
- EndFunc
- ;Hotkey Functions
- Func Leave()
- $Leave = True
- EndFunc
- Func Pause()
- $Paused = Not $Paused
- If $Paused Then
- LogWrite("Script - Paused")
- Else
- LogWrite("Script - UnPaused")
- EndIf
- While $Paused
- Sleep(100)
- WEnd
- EndFunc
- Func Stop() ;to allow the script to stop
- LogWrite(@CRLF & "Legendary:" & $LegendaryCount & " Set:" & $SetCount & " Rare:" & $RareCount & " Magic:" & $MagicCount & " Gem:" & $GemCount & " Tome:" & $TomeCount & @CRLF)
- If $CreateLog == True Then
- FileClose($LogFile)
- EndIf
- Exit
- EndFunc
- ;Settings Functions
- 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 CreateINI()
- IniWrite($ini,"Options", "AutoUpdate", $autoUpdate)
- IniWrite($ini,"Options", "Physical Log", $CreateLog)
- IniWrite($ini, "Skills", "Caltrops", $skillCaltrops)
- IniWrite($ini, "Skills", "Companion", $skillCompanion)
- IniWrite($ini, "Skills", "Preperation", $skillPreperation)
- IniWrite($ini, "Skills", "SmokeScreen", $skillSmokeScreen)
- IniWrite($ini, "Looting", "Sets", $LootSets)
- IniWrite($ini, "Looting", "Legendaries", $LootLegendaries)
- IniWrite($ini, "Looting", "Rares", $LootRares)
- IniWrite($ini, "Looting", "Magic", $LootMagic)
- IniWrite($ini, "Looting", "Gems", $LootGems)
- IniWrite($ini, "Looting", "Tomes", $LootTomes)
- IniWrite($ini, "Looting", "Custom", $LootCustom)
- IniWrite($ini, "Custom Loot", "PNG Location", $pngLoc)
- ;IniWrite($ini,"Custom Loot", "Total Items", $totalItems)
- ;Array of items to loot
- ;$pick[0] = "mythic.png|40" ;png|Tolerance
- ;$pick[1] = "item2.png"
- ;$pick[2] = "item3.png"
- IniWrite($ini, "ManageLoot","How Often", $mLoot)
- ;IniWrite($ini, "ManageLoot","Identify", $IdentifyLoot)
- IniWrite($ini, "Stashing", "Loot", $StashLoot)
- IniWrite($ini, "Stashing", "Legendaries", $StashLegendary)
- IniWrite($ini, "Stashing", "Rares", $StashRare)
- IniWrite($ini, "Stashing", "Magic", $StashMagic)
- IniWrite($ini, "Stashing", "Tomes", $StashTomes)
- IniWrite($ini, "Vendoring", "Loot", $VendorLoot)
- IniWrite($ini, "Vendoring", "Rares", $VendorRare)
- IniWrite($ini, "Vendoring", "Magic", $VendorMagic)
- IniWrite($ini, "Variability", "Timer", $Timer)
- IniWrite($ini, "Variability", "Secondary Attack", $atk1Time)
- IniWrite($ini, "Variability", "Primary Attack", $atk2Time)
- IniWrite($ini, "Variability", "Adds Attack", $atk3Time)
- IniWrite($ini, "Variability", "Using NT", $usingNT)
- IniWrite($ini, "Additional", "Movement Speed", $movementSpeed)
- IniWrite($ini, "Additional", "Pickup Radius", $pickupRadius)
- IniWrite($ini, "Beta", "Area", $vendorArea)
- IniWrite($ini, "Beta", "Rows", $vendorRows)
- IniWrite($ini, "Beta", "Cols", $vendorCols)
- EndFunc
- Func DoUpdate()
- $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini") ;download version.ini
- If $Ini = 0 Then ;was the download of version.ini successful?
- MsgBox(0,"ERROR","The server seems to be offline. No update will be done.")
- Else
- $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","") ;reads the new version out of version.ini
- If $newVersion = $oldVersion Then ;compare old and new
- ;MsgBox (0,"No update","There is no update available!")
- FileDelete(@ScriptDir & "\version.ini")
- Else
- $msg = MsgBox (4,"Update","Would you like to update from version " & $oldVersion & " to " & $newVersion & "?")
- If $msg = 7 Then ;No was pressed
- FileDelete(@ScriptDir & "\version.ini")
- ElseIf $msg = 6 Then ;OK was pressed
- ;------------------------------- Begin download the zip file --------------------------------------;
- $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
- ConsoleWrite($downloadLink)
- $dlhandle = InetGet($downloadLink,@ScriptDir & "\S-SarkothBot-" & $newVersion & ".rar",1,1)
- ProgressOn("Update", "Downloading Updates", "",-1,-1,16) ;creates an progressbar
- $Size = InetGetSize($downloadLink,1) ;get the size of the update
- While Not InetGetInfo($dlhandle, 2)
- $Percent = (InetGetInfo($dlhandle,0)/$Size)*100
- ProgressSet( $Percent, $Percent & " percent") ;update progressbar
- Sleep(1)
- WEnd
- ProgressSet(100 , "Done", "Complete") ;show complete progressbar
- sleep(500)
- ProgressOff() ;close progress window
- ;------------------------------- Write the new version for future updates --------------------------------------;
- IniWrite("updater.ini","version","version",$newVersion) ;updates update.ini with the new version
- InetClose($dlhandle) ;close net connection
- MsgBox(-1,"Success","Download Complete! Please restart the bot." & @CRLF & "Check your Change Log.txt file to see the newest updates!") ;show complete message
- FileDelete(@ScriptDir & "\version.ini")
- Exit
- EndIf
- EndIf
- EndIf
- EndFunc
- Func LogWrite($text)
- ConsoleWrite($text & @CRLF)
- If $CreateLog == True Then
- FileWriteLine($LogFile, $text)
- EndIf
- EndFunc
- Func UpdateTooltip()
- ToolTip("Runs: " & $runCount & ", Cellar Spawn: " & Round(($cellarCount/$runCount)*100) & "%, Deaths: " & $deathCount & ", Manage In: " & $mLootIn, 0, $size[1]-20)
- ;ToolTip("Expected: " & $ExpectedState & ", Actual: " & $ActualState, 0, $size[1]-20)
- EndFunc
- Func ReadINI()
- $autoUpdate = IniRead($ini,"Options", "AutoUpdate", $autoUpdate)
- $CreateLog = IniRead($ini,"Options","Physical Log",$CreateLog)
- $skillCaltrops = IniRead($ini, "Skills","Caltrops",$skillCaltrops)
- $skillCompanion = IniRead($ini,"Skills","Companion",$skillCompanion)
- $skillPreperation = IniRead($ini,"Skills","Preperation",$skillPreperation)
- $skillSmokeScreen = IniRead($ini,"Skills","SmokeScreen",$skillSmokeScreen)
- $LootSets = IniRead($ini,"Looting","Sets",$LootSets)
- $LootLegendaries = IniRead($ini,"Looting","Legendaries",$LootLegendaries)
- $LootRares = IniRead($ini,"Looting","Rares",$LootRares)
- $LootMagic = IniRead($ini,"Looting","Magic",$LootMagic)
- $LootGems = IniRead($ini,"Looting","Gems",$LootGems)
- $LootTomes = IniRead($ini,"Looting","Tomes",$LootTomes)
- $LootCustom = IniRead($ini,"Looting","Custom",$LootCustom)
- $pngLoc = IniRead($ini,"Custom Loot","PNG Location",$pngLoc)
- ;$totalItems = IniRead($ini,"Custom Loot","Total Items",$totalItems)
- ;Array of items to loot
- ;$pick[0] = "mythic.png|40" ;png|Tolerance
- ;$pick[1] = "item2.png"
- ;$pick[2] = "item3.png"
- $mLoot = IniRead($ini,"ManageLoot","How Often",$mLoot)
- ;$IdentifyLoot = IniRead($ini, "ManageLoot","Identify", $IdentifyLoot)
- $StashLoot = IniRead($ini,"Stashing","Loot",$StashLoot)
- $StashLegendary = IniRead($ini,"Stashing","Legendaries",$StashLegendary)
- $StashRare = IniRead($ini,"Stashing","Rares",$StashRare)
- $StashMagic = IniRead($ini,"Stashing","Magic",$StashMagic)
- $StashTomes = IniRead($ini,"Stashing","Tomes",$StashTomes)
- $VendorLoot = IniRead($ini,"Vendoring","Loot",$VendorLoot)
- $VendorRare = IniRead($ini,"Vendoring","Rares",$VendorRare)
- $VendorMagic = IniRead($ini,"Vendoring","Magic",$VendorMagic)
- $Timer = IniRead($ini,"Variability","Timer",$Timer)
- $atk1Time = IniRead($ini,"Variability","Secondary Attack",$atk1Time)
- $atk2Time = IniRead($ini,"Variability","Primary Attack",$atk2Time)
- $atk3Time = IniRead($ini,"Variability","Adds Attack",$atk3Time)
- $usingNT = IniRead($ini,"Variability","Using NT",$usingNT)
- $movementSpeed = IniRead($ini,"Additional","Movement Speed",$movementSpeed)
- $pickupRadius = IniRead($ini,"Additional","Pickup Radius",$pickupRadius)
- $vendorArea = IniRead($ini,"Beta","Area",$vendorArea)
- $vendorRows = IniRead($ini,"Beta","Rows",$vendorRows)
- $vendorCols = IniRead($ini,"Beta","Cols",$vendorCols)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement