Code:
;Darkling Lord's Sarkoth DH Script v1.3.2 - 6/16/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 ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
HotKeySet("=","Leave") ;script started by pressing =
HotKeySet("-", "Pause") ;script paused by pressing -
HotKeySet("x", "Stop") ;script stopped by pressing x
$loadtime = 3200 ; 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
$yellow = 0xFFF000 ; yellow color code (repair icon)
$red = 0xD90000 ; red color code (repair icon)
$currentArrayItem = 0
;Sell
$vendorAll = True
$vendorRows = 4
$vendorCols = 10
;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
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
;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
;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
$go = True
$Leave = False
$Dead = False
$Logout = False
$Window = 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
$i = 0
;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)
;Main
While $go
Call("RunBot")
WEnd
;Script
Func RunBot()
if($Leave) Then
$i = 0
If CheckFor("DisconnectError", "", 720*$x_ratio, 360*$y_ratio, 1200*$x_ratio, 480*$y_ratio, .5) Then
LogWrite("Disconnected" & @CRLF)
RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
Sleep(Random(1000, 2000))
EndIf
;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
LogWrite(@CRLF & "Run Number: " & $runCount & " - Runs till management: " & $mLootIn & @CRLF & "Main Menu" & @CRLF)
RandSleep(180, 300, 2)
While True
RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120*$x_ratio, 10*$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), 1) Then
Sleep(Random(1000, 2000))
RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
$rand = Random(40000, 80000)
LogWrite("Input Limit Reached - Waiting " & Round($rand/1000) & " seconds." & @CRLF)
Sleep($rand)
Else
ExitLoop
EndIf
WEnd
UpdateTooltip()
$rt = TimerInit()
$Window = False
$Logout = False
Else
LogWrite($pngLoc & "MainMenu.png not found or not on main menu")
RandMove($size[0],$size[1])
Return
EndIf
;Checks that the player is in the Old Ruins
If CheckFor("OldRuins", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio) Then
LogWrite("Old Ruins" & @CRLF)
;Start Run
RandClick("middle", Round(500*$x_ratio), Round(250*$y_ratio), 5, 5) ;starts the run [waypoint 1]
Moving(1125)
Send($skillSmokeScreen)
Moving(440)
RandClick("middle", 1, Round(370*$y_ratio), 5, 5) ;waits ~1 second then [waypoint 2]
Moving(1875)
RandClick("middle", Round(400*$x_ratio), Round(600*$y_ratio), 5, 5) ;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, 5) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
;Sleep(790)
Call("CheckDead")
If $Dead Then
Return
EndIf
;Checks if Dank Cellar is Open
LogWrite("Cellar Check ")
$Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
If Not @error Then
LogWrite("- Found" & @CRLF)
RandClick("left", Round(300*$x_ratio), Round(80*$y_ratio), 5, 5) ;Entrance to cellar
Moving(750)
Send($skillSmokeScreen)
Moving(2500)
Else ;ABORT RUN
LogWrite("- Not Found" & @CRLF)
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(40)
Send($skillSmokeScreen)
Sleep(40)
Call("TownPortal")
If Not $Logout And Not $Dead And Not $Window Then
;Check if player needs to repair
Call("CheckRepair")
Call("LeaveGame")
Return
Else
$Window = False ; reset the flag so it doesn't think a window is always up
Return
EndIf
EndIf
Call("CheckDead")
If $Dead or $Logout Then
Return
EndIf
Else
LogWrite("- Old Ruins" & @CRLF)
Call("TownPortal")
If $Dead Then
Return
EndIf
Call("LeaveGame")
Return
EndIf
;Checks that the player is in the Dank Cellarwa
If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio) Then
Call("CheckDead")
If $Dead or $Logout Then
Return
EndIf
LogWrite("Dank Cellar" & @CRLF)
$cellarCount += 1
UpdateTooltip()
RandClick("middle", Round(90*$x_ratio), Round(900*$y_ratio), 10, 10) ;moves to doorway leading to rare inside cellar
Moving(2750)
RandMove(Round(490*$x_ratio),Round(120*$y_ratio), 5, 5) ;hovers over the rare Sarkoth
Sleep(10)
Send("{SHIFTDOWN}")
LogWrite("Attacking Sarkoth" & @CRLF)
MouseDown("right") ;ATTACK
Send($skillCompanion)
Sleep($atk1Time*1000)
MouseUp("right")
MouseDown("left")
Sleep($atk2Time*1000)
MouseUP("left")
Sleep(Random(50, 150))
RandClick("right", Round(600*$x_ratio), Round(20*$y_ratio)) ;break the table & chair
Sleep(Random(50, 150))
Send("{SHIFTUP}")
Sleep(Random(300, 500))
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(2500)
Endif
Send($skillCompanion)
Call("Loot")
Send($skillCompanion)
RandSleep(5, 10, 50)
Call("TownPortal")
If $Dead or $Logout Then
Return
EndIf
Else
LogWrite("- Dank Cellar" & @CRLF)
Send($skillCaltrops)
Sleep(620)
Send($skillSmokeScreen)
Sleep(40)
Call("TownPortal")
If $Dead Then
Return
EndIf
Call("LeaveGame")
EndIf
;After successful run
If Not $Logout And Not $Dead And Not $Window Then
If $mLootIn <= 1 Then ;If its time to manage loot
If $StashLoot == True Then
Call("StashLoot")
EndIf
If $VendorLoot == True Then
Call("VendorLoot")
EndIf
$mLootIn = $mLoot ;Reset Counter
Else
;Check if player needs to repair
Call("CheckRepair")
$mLootIn -= 1
EndIf
Call("LeaveGame")
Return
Else
$Window = False ; reset the flag so it doesn't think a window is always up
Return
EndIf
EndIf
EndFunc
;Helper Functions
Func CheckDead()
$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
$deathCount += 1
UpdateTooltip()
LogWrite("Death - ")
$Dead = True
Call("LeaveGame")
Sleep(12000)
Else
$Dead = False
EndIf
$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
Sleep(11000)
$Logout = True
EndIf
EndFunc
Func CheckRepair()
If CheckFor("NewTristram", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 40*$y_ratio) Then
;Sleep(250)
$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
EndIf
EndFunc
Func DoRepair()
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(150*$x_ratio), Round(0*$y_ratio), Round(300*$x_ratio), Round(100*$y_ratio), 0xC5C25A, 2) ; checks for the bright spot on bag at top of vendor
;If Not @error Then
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)
;EndIf
EndFunc
Func CalcTime()
$srt = TimerDiff($rt)
LogWrite("Runtime: " & Round($srt/1000,2) & " seconds." & @CRLF)
$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."& @CRLF)
EndFunc
Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth , $endY = @DesktopHeight , $seconds = 5 ,$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.
If $type = "Area" Then
LogWrite("Area not found ")
EndIf
Return False
EndIf
Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
Return True
EndFunc
Func LeaveGame()
$Logout = true
Call("RandSleep")
LogWrite("Leaving Game" & @CRLF)
Sleep(Random(100, 500))
Send("{Escape}")
Sleep(Random(100, 500))
RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120*$x_ratio, 10*$y_ratio) ;Random Click on the leave button
Call("CalcTime")
EndFunc
Func Loot()
;Sleep(Random(500,2000))
LogWrite("Looting" & @CRLF)
MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
If $LootSets == True Then
$SetCount += LootGear(0x02CE01, 2)
EndIf
If $LootLegendaries == True Then
$LegendaryCount += LootGear(0xBF642F, 0)
EndIf
If $LootRares == True Then
$RareCount += LootGear(0xBBBB00, 2)
EndIf
If $LootTomes == True Then
Call("LootTomes")
EndIf
If $LootMagic == True Then
$MagicCount += LootGear(0x6969FF, 2)
EndIf
If $LootGems == True Then
Call("LootGems")
EndIf
If $LootCustom == True Then
Call("LootCustom")
EndIf
EndFunc
Func LootCustom()
$currentArrayItem = 0
$gX = 0
$gY = 0
for $i = 0 to ($totalItems - 1)
$array = StringSplit($pick[$i],"|")
$file = $array[1]
$accuracy = $array[2]
$urlString = $pngLoc & $file
;LogWrite("Looting " & $file & @CRLF)
While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
MouseMove($gX, $gY, 3)
sleep(Random(75, 150))
MouseClick("left",$gX,$gY,1,1)
Moving(1200)
MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
WEnd
next
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)
If Not @error Then
While Not @error
$count += 1
MouseClick ('left', $Loot[0], $Loot[1])
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 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) ; Magic loot (darker for compatibility)
WEnd
EndIf
Return $count
EndFunc
Func LootGems()
$gX = 0
$gY = 0
While _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,115)
;MouseMove($gX,$gY,3)
sleep(Random(75, 150))
MouseClick("left",$gX,$gY)
$GemCount += 1
Moving(900)
MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
WEnd
EndFunc
Func LootTomes()
$gX = 0
$gY = 0
$Start = 0
;variables are all set, now onto the scan.
While _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,100)
;MouseMove($gX,$gY,3)
sleep(Random(75, 150))
MouseClick("left",$gX,$gY)
$TomeCount += 1
Moving(900)
MouseMove(Round(Random(1400,1920)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
WEnd
EndFunc
Func Moving($time)
Sleep($time/$movementSpeed)
EndFunc
Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10)
$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)
EndFunc
Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10)
$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))
;LogWrite("SleepCheck: (" & $randNum & ", " & $chance & ")" & @CRLF)
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 StashLoot()
LogWrite("Putting Items in Stash" & @CRLF)
Sleep(Random(1000, 1500))
MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
Moving(1875)
;Legendaries
While $StashLegendary == True
Sleep(Random(200, 300))
$LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
If Not @error Then
LogWrite("Stashing Legendary" & @CRLF)
MouseClick("right", $LegendPixel[0], $LegendPixel[1])
Else
ExitLoop
EndIf
WEnd
;Rares
While $StashRare == True
Sleep(Random(200, 300))
$RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4A3C0B, 1)
If Not @error Then
LogWrite("Stashing Rare" & @CRLF)
MouseClick("right", $RarePixel[0], $RarePixel[1])
Else
ExitLoop
EndIf
WEnd
;Tomes
If _ImageSearchArea($pngLoc & "tomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,100) And $StashTomes == True Then
LogWrite("Stashing Tomes" & @CRLF)
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))
EndIf
;Magic
While $StashMagic == True
Sleep(Random(100, 300))
$MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
If Not @error Then
LogWrite("Stashing Magic" & @CRLF)
MouseClick("right", $MagicPixel[0], $MagicPixel[1])
Else
ExitLoop
EndIf
WEnd
Sleep(Random(500, 1000))
LogWrite("Done with Stash" & @CRLF)
Send("{ESCAPE}")
EndFunc
Func TownPortal()
LogWrite("Returning to Town" & @CRLF)
Send("t")
Sleep(6900)
Call("CheckDead")
EndFunc
Func VendorLoot()
LogWrite("Vendoring Items" & @CRLF)
If Not $StashLoot Then ;Move from TP towards vendor
Sleep(Random(300, 500))
MouseClick("left", 1565*$x_ratio, 50*$y_ratio)
Else ;Move from Stash towards vendor
Sleep(Random(300, 500))
MouseClick("left", 1560*$x_ratio, 120*$y_ratio)
EndIf
Moving(3000)
MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
Moving(3000)
;Make sure window is open
;$VendorFound = PixelSearch(Round(180*$x_ratio), Round(0*$y_ratio), Round(360*$x_ratio), Round(120*$y_ratio), 0xC5C25A) ; checks for the bright spot on bag at top of vendor
;If Not @error Then
;All
If $vendorAll == True Then
For $c = 1 To $vendorCols
For $r = 1 To $vendorRows
MouseClick("right", (((($c-1)*50)+32+1398)*$x_ratio), (((($r-1)*51)+32+572)*$y_ratio))
Next
Next
EndIf
;Rares
If $VendorRare == True Then
LogWrite("Selling Rare - ")
$c = 0
While $VendorRare
Sleep(Random(200, 300))
$RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4A3C0B, 1)
If Not @error Then
MouseClick("right", $RarePixel[0], $RarePixel[1])
$c += 1
Else
LogWrite($c & @CRLF)
ExitLoop
EndIf
WEnd
EndIf
;Magic
If $VendorMagic == True Then
LogWrite("Selling Magic - ")
$c = 0
While True
Sleep(Random(100, 300))
$MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
If Not @error Then
MouseClick("right", $MagicPixel[0], $MagicPixel[1])
$c += 1
Else
LogWrite($c & @CRLF)
ExitLoop
EndIf
WEnd
EndIf
Sleep(Random(500, 1000))
LogWrite("Done With Vendor" & @CRLF)
Send("{ESCAPE}")
;Else
;LogWrite("Vendor window not found")
;EndIf
EndFunc
;Hotkey Functions
Func Leave()
$Leave = True
EndFunc
Func Pause()
$Leave = False
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 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, "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","Attack_right",$atk1Time)
IniWrite($ini,"Variability","Attack_left",$atk2Time)
IniWrite($ini, "Additional", "Movement Speed", $movementSpeed)
IniWrite($ini, "Additional", "Pickup Radius", $pickupRadius)
IniWrite($ini, "Beta", "Area", $vendorAll)
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)
If $CreateLog == True Then
FileWriteLine($LogFile, $text)
EndIf
EndFunc
Func UpdateTooltip()
ToolTip("Runs: " & $runCount & ", Cellar Found: " & Round(($cellarCount/$runCount)*100) & "%, Deaths: " & $deathCount, 0, $size[1]-30)
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)
$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","Attack_right",$atk1Time)
$atk2Time = IniRead($ini,"Variability","Attack_left",$atk2Time)
$movementSpeed = IniRead($ini,"Additional","Movement Speed",$movementSpeed)
$pickupRadius = IniRead($ini,"Additional","Pickup Radius",$pickupRadius)
$vendorAll = IniRead($ini,"Beta","Area",$vendorAll)
$vendorRows = IniRead($ini,"Beta","Rows",$vendorRows)
$vendorCols = IniRead($ini,"Beta","Cols",$vendorCols)
EndFunc