Code:
$SleepRun = 90 ; the amount of the runs before it pauses
Global $Paused
HotKeySet("=","Start") ;script can START by pressing =
HotKeySet("-", "Pause") ;script can be Pause by pressing -
HotKeySet("x", "Stop") ;script can be Stopped by pressing x
;-----------------------------------------------------
;-----------------------------------------------------
; Settings
$ShootingTime = 8000 ;Default: 5000 ;Time in 1/1000 sec to shoot at sarkoth. Increase if you can't kill him.
$DebugMode = True ;Default: False ;True / false Activate/Deactivate logging. Will create log file in your script folder
$ShutDown = False ;Default: False ;True shuts down the computer
;-----------------------------------------------------
;-----------------------------------------------------
; Time 29 sec
;-----------------------------------------------------
;-----------------------------------------------------
; areas
Global $LootArea[4]
$LootArea[0] = 450
$LootArea[1] = 115
$LootArea[2] = 1550
$LootArea[3] = 864
Global $FullScreen[4]
$FullScreen[0] = 0
$FullScreen[1] = 0
$FullScreen[2] = 1920
$FullScreen[3] = 1080
Global $InventoryArea[4]
$InventoryArea[0] = 1400
$InventoryArea[1] = 584
$InventoryArea[2] = 1900
$InventoryArea[3] = 1874
$go = True
$Run = False
$runMade = 0
$Break = 0
$Input = 250 ;amount of runs before it either puases for 2 hours or shuts down the computer
While $go
if($Run) Then
$Pixel1 = PixelSearch(1482,20,1535,95,0xFFF000) ;searches top right screen for yellow of broken armor
If Not @error Then
;we need to repair
ToLog("We need to repair")
Sleep(8000)
MouseClick("left", 1380 + GetRandomInt(0, 50), 30 + GetRandomInt(0, 10)) ;clicks the blacksmith
Sleep(5500)
MouseClick("left", 520, 575) ;button to open up repair menu
Sleep(1500)
MouseClick("left", 260, 595) ;button to pay for repairs
Sleep(2500)
Send("{ESCAPE}") ;close windows
Sleep(200);
ToLog("Repairing completed... Resuming the game")
ResumeGame()
Else
;starts the run
RunToCellarArea()
Attack()
CheckDeath()
ResumeGame()
EndIf
EndIf
WEnd
Func Pause()
$Run = False
EndFunc
Func Stop() ;to allow the script to stop
ToLog("Stopping the bot")
Exit
EndFunc
Func Start()
ToLog("Starting the bot")
$Run = True
EndFunc
Func StatusCheck()
if Not CheckDeath() Then
ToLog("Status check: Death")
Return False
EndIf
if Not CheckConnection() Then
ToLog("Status check: Connection lost")
Return False
EndIf
Return True
EndFunc
Func CheckDeath()
;ToLog("Checking death")
$Pixel3 = PixelSearch(830,840,860,850,0xe69f4f )
if Not @error Then
$Pixel3 = PixelSearch(700,830,730,860,0x180000 )
if Not @error Then
; ToLog("Death check 1 failed... you're dead")
ResumeGame()
Return False
EndIf
EndIf
$Pixel3 = PixelSearch(830,840,860,850,0x4b4742 )
if Not @error Then
$Pixel3 = PixelSearch(700,830,730,860,0x060201 )
if Not @error Then
;ToLog("Death check 2 failed... you're dead")
ResumeGame()
Return False
EndIf
EndIf
;ToLog("Death check Success!... you're still alive!")
Return True
EndFunc
Func CheckConnection()
;ToLog("Checking connection")
$Pixel3 = PixelSearch(860,417,1068,438,0xf09901 )
if Not @error Then
$Pixel3 = PixelSearch(900,620,920,640,0x230400 )
if Not @error Then
ToLog("Connection test failed")
MouseClick("left", 910, 630)
ResumeGame()
Return False
EndIf
EndIf
;ToLog("Connection test success")
Return True
EndFunc
Func Loading()
$Pixel3 = PixelSearch(1700,168,1775,240,0x00a6ff )
if Not @error Then
; pixel found = loading is over
Sleep(300)
Return False
EndIf
;Still on loading screen
return True
EndFunc
Func GetRandomInt($min, $max)
Return Round(Random($min, $max))
EndFunc
Func RunToCellarArea()
ToLog("Running to cellar")
$sleep = 0
MouseClick("middle", 1385, 305 + GetRandomInt(0, 5))
$sleep = 1450 + GetRandomInt(0, 50)
Sleep($sleep)
Send("4")
Sleep(1000)
MouseClick("middle", 1764, 876)
$sleep = 1950 + GetRandomInt(0, 50)
Sleep($sleep)
MouseClick("middle", 1420 + GetRandomInt(20, 50), 390)
$sleep = 1750 + GetRandomInt(50, 150)
Sleep($sleep)
MouseClick("left", 700, 330)
Sleep(3000)
Send("{ESCAPE}")
MouseClick("left", 760 + GetRandomInt(0, 50), 350 + GetRandomInt(0, 40))
$sleep = 2150 + GetRandomInt(50, 150)
Sleep($sleep)
MouseClick("middle", 985 + GetRandomInt(0, 50), 880 + GetRandomInt(0, 50))
$sleep = 1250 + GetRandomInt(0, 50)
Sleep($sleep)
MouseClick("middle", 970 + GetRandomInt(0, 50), 820 + GetRandomInt(0, 50))
$sleep = 1050 + GetRandomInt(0, 50)
Sleep($sleep)
endFunc
Func Attack()
ToLog("Begin the attack !")
$ShootingTimeDone = 0
$ShootingStep = Round($ShootingTime * .2) - 20
$sleep = 0
MouseMove(1040 + GetRandomInt(10, 20), 539 + GetRandomInt(10, 20))
Send("3")
Sleep(500)
Send("1")
Sleep(500)
Send("1")
Sleep(500)
Send("1")
Sleep(500)
Send("2")
Send("{SHIFTDOWN}")
MouseDown("right")
$sleep = $ShootingStep * 2 + GetRandomInt(100, 250)
$ShootingTimeDone = $ShootingTimeDone + $sleep
Sleep($sleep)
MouseUP("right")
Send("{SHIFTUP}")
ToLog("Attack loop done.")
EndFunc
Func MouseActionOnPixelColor($mouseBtn, $color, $area, $searchCount, $timeBetweenFinds = 0, $randomRange = 4)
$cnt = 0
$Searching = True
while $Searching
$Pixel3 = PixelSearch($area[0],$area[1],$area[2],$area[3],$color)
if Not @error Then
MouseClick($mouseBtn, $Pixel3[0] + GetRandomInt(0,$randomRange), $Pixel3[1] + GetRandomInt(0,$randomRange))
Sleep($timeBetweenFinds)
$cnt = $cnt + 1
if $cnt > $searchCount Then
$Searching = False
EndIf
Else
$Searching = False
EndIf
WEnd
EndFunc
Func ResumeGame()
ToLog("Resuming game")
; move the mouse to be sure it's not over the pixel we're looking for
MouseMove(100, 100,1)
$Searching = True
while $Searching
$Pixel3 = PixelSearch(800,550,1125,610,0xf3aa55 )
if Not @error Then
$Pixel = PixelSearch(800, 610, 1125, 660, 0xf3aa55)
if Not @error Then
ToLog("Click 'leave game'")
; this check return if there is a button under the one we,re going to click. If there is not, we're on the select character screen and would click on "exit game" if we proceed
MouseClick("left", GetRandomInt(810,1115), GetRandomInt(560, 600)) ;button to leave game
$Searching = False
Else
Send("{ESCAPE}") ;close menu
CloseErrorMessage()
ExitLoop
EndIf
Else
Send("{ESCAPE}") ;close menu
CloseErrorMessage()
Sleep(1000)
EndIf
WEnd
; check if profile screen is open
$Pixel3 = PixelSearch(1565,98,1593,126,0xffd794 )
if Not @error Then
ToLog("Closing profile screen")
Send("{ESCAPE}") ;close profile
EndIf
$Searching = True
while $Searching
$Pixel3 = PixelSearch(60,384,411,450,0x3c0700 )
if Not @error Then
$Break = $Break + 1
Limit()
GameInput()
ToLog("Clicking resume from Main menu")
MouseClick("left", GetRandomInt(70,401), GetRandomInt(394,440)) ;button to resume game from main menu
$Searching = False
Else
CloseErrorMessage()
EndIf
WEnd
while Loading()
;will get out of the loop when loading is over and resume the script
WEnd
EndFunc
Func Limit()
If $Break = $SleepRun Then
$SleepRun = $SleepRun + 95
ToLog("Opening Auction House")
MouseClick("left", 238,641) ;button to open Auction House
Sleep(6000)
ToLog("Closing Auction House")
Send("{ESCAPE}") ;close Auction House
Sleep(3000)
ToLog("Closing Diablo 3")
Send("{ESCAPE}")
MouseClick("left", 962,580) ;button to close diablo 3
Sleep(1000)
MouseClick("left", 847,635) ;ok to close diablo 3
ToLog("Pausing for 1 hour")
Sleep(3600000)
ToLog("Opening Diablo 3")
Run("") ;opens Diablo 3 <----- Loctaion of the Diablo III.exe
Sleep(4000)
MouseClick("left", 1217,696) ;Launches D3
Sleep(15000)
ToLog("Entering Password")
Send("") ; <------- your password to log in the game
MouseClick("left", 961,853) ;button to log in
Sleep(10000)
Endif
EndFunc
Func GameInput()
If $Break = $Input Then
$Input = $Input + 250
$SleepRun = $SleepRun + 70
ToLog("Input Limit Has Been Reached")
ToLog("Closing Diablo 3")
Send("{ESCAPE}")
MouseClick("left", 962,580) ;button to close diablo 3
Sleep(1000)
MouseClick("left", 847,635) ;ok to close diablo 3
PowerOff()
ToLog("Pausing for 2 hour")
Sleep(7600000)
ToLog("Opening Diablo 3")
Run("") ;opens Diablo 3 <----- Loctaion of the Diablo III.exe
Sleep(4000)
MouseClick("left", 1217,696) ;Launches D3
Sleep(15000)
ToLog("Entering Password")
Send("") ; <------- your password to log in the game
MouseClick("left", 961,853) ;button to log in
Sleep(10000)
EndIf
EndFunc
Func PowerOff()
If ($ShutDown) Then
Sleep(2000)
ToLog("Shutting down the computer")
Shutdown(9) ;shuts down the computer
EndIf
EndFunc
Func CloseErrorMessage()
$Pixel3 = PixelSearch(860,417,1068,438,0xf09901 )
if Not @error Then
$Pixel3 = PixelSearch(900,620,920,640,0x230400 )
if Not @error Then
MouseClick("left", 910, 630)
EndIf
EndIf
EndFunc
Func ToLog($text)
if Not $DebugMode Then
TrayTip("file", "not debug mode", 1)
Return
EndIf
$log = FileOpen ( @ScriptDir & "\log.txt", 1)
If $log = -1 Then
TrayTip("file", "not found", 1)
Return
EndIf
FileWrite($log, @mon & "/" & @MDAY & " @ " & @HOUR & ":" & @MIN & ":" & @SEC & " - " & $text)
FileWrite($log, @CRLF)
FileClose($log)
EndFunc