Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ImageSearch.au3>
- #include <File.au3>
- Global $Paused
- Global $ingamewait
- Global $wintitle="Diablo III"
- Global $winhandle=Wingethandle($wintitle)
- Opt('MouseCoordMode', 2)
- Opt('PixelCoordMode', 2)
- HotKeySet("=","Leave") ;script started by pressing =
- HotKeySet("-", "Pause") ;script paused by pressing -
- HotKeySet("x", "Stop") ;script stopped by pressing x
- $go = True
- $default_resolutionX = 1920
- $default_resolutionY = 1080
- $x_ratio = @Desktopwidth / $default_resolutionX
- $y_ratio = @Desktopheight / $default_resolutionY
- ;ImageSearch Looting Variables
- $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
- $directory = "D:\gry\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
- $totalItems = 17 ; This needs to match the number of pngs you are loading
- Global $pick[$totalItems]
- $currentArrayItem = 0
- $gX = 0
- $gY = 0
- $gX0 = 0
- $gY0 = 0
- $pick[0] = "uare.png|40"
- $pick[1] = "tome.png|40"
- $pick[2] = "legendaryA.png|20"
- $pick[3] = "legendaryE.png|20"
- $pick[4] = "legendaryI.png|10"
- $pick[5] = "legendaryO.png|20"
- $pick[6] = "legendaryU.png|20"
- $pick[7] = "setA.png|30"
- $pick[8] = "setE.png|30"
- $pick[9] = "setU.png|30"
- $pick[10] = "setO.png|30"
- $pick[11] = "setI.png|30"
- $pick[12] = "rareA.png|20" ; comment/delete these and adjust $totalItems to disable rare looting
- $pick[13] = "rareE.png|20"
- $pick[14] = "rareI.png|20"
- $pick[15] = "rareO.png|20"
- $pick[16] = "rareU.png|20" ; end comment
- $LootGems = False ; Old Methods set to true if you don't want to use imagesearch
- $LootRares = True ; Old Methods set to true if you don't want to use imagesearch
- $Amethyst = 0xAC7FFF
- $Ruby = 0xB01D2D
- $Emerald = 0x58EE33
- $Topaz = 0xFFFF59
- $yellow = 0xFFF000 ; yellow color code (repair icon)
- $red = 0xD90000 ; red color code (repair icon)
- $Timer = false ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
- $walktime = 3600 ; 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 = 4500 ; 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
- $Leave = False
- $Dead = False
- $Window = False
- $Logout = False
- $i = 0
- $Sarkothkill=Iniread("Sarkoth.ini","Misc","Sarkothkill",0)
- $Sarkothnotfound=Iniread("Sarkoth.ini","Misc","Sarkothnotfound",0)
- $Died=Iniread("Sarkoth.ini","Misc","Died",0)
- Call("RestartRun")
- Func RestartRun()
- While $go
- if($Leave) Then
- $i = 0
- Call("CheckExit")
- Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
- Call("CheckDead")
- Call("CheckRepair")
- If $Window Then
- Call("InputReqScrn")
- $Window = False
- ExitLoop
- ElseIf $Dead or $Logout Then
- ExitLoop
- EndIf
- MouseClick("middle", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
- Send("4")
- Sleep(140)
- Send("4")
- Sleep(140)
- Send("4")
- Sleep(140)
- Send("4")
- Sleep(80)
- Send("4")
- Sleep(80)
- Send("4")
- Sleep(80)
- Send("4")
- Sleep(80)
- Send("4")
- Sleep(80)
- Send("4")
- sleep(80)
- Send("3")
- Sleep(300)
- MouseMove(Round(290*$x_ratio),Round(270*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
- Sleep(700)
- Sleep(250)
- Call("CheckDead")
- If $Window Then
- Call("InputReqScrn")
- $Window = False
- ExitLoop
- ElseIf $Dead or $Logout Then
- ExitLoop
- EndIf
- $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
- If Not @error Then
- Send("2")
- sleep(80)
- MouseClick("left",Round(290*$x_ratio),Round(270*$y_ratio)) ;Entrance to cellar
- Cellarwait()
- Send(1)
- Sleep(200)
- Send(2)
- Sleep(200)
- MouseClick("middle",Round(40*$x_ratio),Round(797*$y_ratio)) ;moves to doorway leading to rare inside cellar
- Sleep(3100)
- MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
- Sleep(100)
- Send("{SHIFTDOWN}")
- MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio))
- Sleep(200)
- MouseClick("right",Round(440*$x_ratio),Round(80*$y_ratio))
- Sleep(150)
- MouseDown("right") ;attack middle
- Sleep(3700)
- MouseUP("right")
- Send("{SHIFTUP}")
- Sleep(400)
- MouseClick("middle",Round(564*$x_ratio),Round(222*$y_ratio)) ;location of sarkoth after death
- Sleep(1500)
- MouseClick("middle",Round(1320*$x_ratio),Round(315*$y_ratio)) ;move to right top corner for gold
- Sleep(700)
- MouseClick("middle",Round(880*$x_ratio),Round(748*$y_ratio)) ;move to middle before looting
- Sleep(600)
- Call("CheckLoot")
- Send("t")
- Sleep($tptime)
- Call("RandomSleep")
- Call("CheckDead")
- If Not $Logout And Not $Dead And Not $Window Then
- Sleep(300)
- Send("{ESCAPE}") ;menu
- Sleep(200)
- _FileWriteLog("Botlog.txt", "Sarkoth down")
- $Sarkothkill=$Sarkothkill+1
- IniWrite("Sarkoth.ini","Misc","Sarkothkill",$Sarkothkill)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep($loadtime)
- Call("CheckDead")
- If Not $Logout Then
- Call("InputReqScrn")
- EndIf
- Else
- Call("InputReqScrn")
- $Window = False ; reset the flag so it doesn't think a window is always up
- EndIf
- Else
- mousemove(962,518,1)
- Send("3")
- Sleep(620)
- send("2")
- Sleep(400)
- send("{SHIFTDOWN}")
- sleep(200)
- Mouseclick("left")
- sleep(300)
- send("{SHIFTUP}")
- sleep(400)
- Send("t")
- Sleep($tptime)
- Call("CheckDead")
- Call("RandomSleep")
- _FileWriteLog("Botlog.txt", "Sarkoth not found")
- $Sarkothnotfound=$Sarkothnotfound+1
- IniWrite("Sarkoth.ini","Misc","Sarkothnotfound",$Sarkothnotfound)
- If Not $Logout And Not $Dead And Not $Window Then
- Sleep(300)
- Send("{ESCAPE}") ;menu
- Sleep(200)
- Call("CheckDead")
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep($loadtime)
- Call("CheckDead")
- If Not $Logout Then
- Call("InputReqScrn")
- EndIf
- Else
- Call("InputReqScrn")
- $Window = False ; reset the flag so it doesn't think a window is always up
- EndIf
- EndIf
- EndIf
- WEnd
- Call("InputReqScrn")
- EndFunc
- Func CheckDead()
- Call("CheckWindow")
- $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
- If Not $Window Then
- $Dead = True
- _FileWriteLog("Botlog.txt", "Oh my you have died")
- $Died=$Died+1
- IniWrite("Sarkoth.ini","Misc","Died",$Died)
- Sleep(100)
- Send("{Escape}")
- Sleep(10)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep(11000)
- Call("InputReqScrn")
- Else
- Call("InputReqScrn")
- $Dead = False
- EndIf
- 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)
- Sleep($loadtime)
- If Not $Window Then
- $Dead = True
- $Logout = True
- Sleep($loadtime)
- Call("InputReqScrn")
- Else
- Call("InputReqScrn")
- $Logout = False
- EndIf
- Else
- $Logout = False
- EndIf
- EndFunc
- Func CheckWindow()
- $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
- $Window = True
- Else
- $Window = False
- EndIf
- EndFunc
- Func CheckExit()
- $ExitButton = PixelSearch(Round(1190*$x_ratio), Round(400*$y_ratio), Round(1200*$x_ratio), Round(440*$y_ratio), 0x14100E) ; checks for the grey border of the exit prompt
- If Not @error Then
- Send("{ESCAPE}")
- Sleep(100)
- Send("{SPACE}") ;close any open windows
- Sleep(200)
- MouseMove(1,1) ; reset cursor position before checking for button
- $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
- If $Resume == "400900" Or $Resume == "380900" Then
- Sleep(200)
- Call("InputReqScrn")
- EndIf
- EndIf
- EndFunc
- 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
- Func DoRepair()
- Sleep(100)
- Send("t")
- Sleep($tptime)
- MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
- Sleep(1900)
- MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
- Sleep(1900)
- MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
- Sleep(1200)
- 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)
- Call("CheckDead")
- If Not $Dead and Not $Logout Then
- Send("{ESCAPE}") ;closes repair tab
- Sleep(100)
- Send("{ESCAPE}") ;menu
- Sleep(10)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep($loadtime)
- Call("InputReqScrn")
- EndIf
- EndFunc
- Func CheckLoot()
- Sleep(Random(500,2000))
- $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
- If Not @error Then
- MouseClick ('left', $SetLoot[0], $SetLoot[1])
- Sleep(Random(800,1200))
- $i+= 1
- If $i <= 6 Then
- Call("CheckLoot")
- EndIf
- EndIf
- If $LootRares Then
- $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
- If Not @error Then
- MouseClick ('left', $RareLoot[0], $RareLoot[1])
- Sleep(Random(700,900))
- $i+= 1
- If $i <= 6 Then
- Call("CheckLoot")
- EndIf
- EndIf
- Else
- Call("pickItems")
- EndIf
- If $LootGems Then
- $AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
- If Not @error Then
- MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
- Sleep(Random(900,1400))
- $i+= 1
- If $i <= 10 Then
- Call("CheckLoot")
- EndIf
- EndIf
- $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
- If Not @error Then
- MouseClick("left", $RubyDrop[0], $RubyDrop[1])
- Sleep(Random(900,1400))
- $i+= 1
- If $i <= 10 Then
- Call("CheckLoot")
- EndIf
- EndIf
- $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
- If Not @error Then
- MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
- Sleep(Random(900,1400))
- $i+= 1
- If $i <= 10 Then
- Call("CheckLoot")
- EndIf
- EndIf
- $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
- If Not 1 = 1 Then ; change to 'If Not @error Then' if you want to search for topazes
- MouseClick("left", $TopazDrop[0], $TopazDrop[1])
- Sleep(Random(900,1400))
- $i+= 1
- If $i <= 10 Then
- Call("CheckLoot")
- EndIf
- EndIf
- EndIf
- EndFunc
- Func pickItems()
- $currentArrayItem = 0
- For $gI = 0 to ($totalItems - 1)
- $array = StringSplit($pick[$gI],"|")
- $file = $array[1]
- $accuracy = $array[2]
- $urlString = $directory & $file
- $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
- While $i <= 12 ; max: 13 gems and pieces of gear to loot
- If $Target And ($gX > 15) And ($gY > 15) Then
- ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
- MouseClick("left", $gX, $gY, 1, 0)
- Sleep(Random(1200,1400))
- MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
- Sleep(5)
- $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
- $i+= 1
- Else
- ExitLoop
- EndIf
- WEnd
- Next
- EndFunc
- Func InputReqScrn()
- Menuwait()
- MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
- Ingamewait()
- $Target = _ImageSearchArea($directory & "InputReq.png",1,0,0,@DesktopHeight,@DesktopWidth,$gX0,$gY0,0)
- If $Target And ($gX > 15) And ($gY > 15) Then
- sleep(1500)
- MouseClick("Left",959,632)
- Sleep(Random(1500000,300000))
- MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
- $gX0 = 0
- $gY0 = 0
- Ingamewait()
- EndIf
- EndFunc
- Func Menuwait()
- $menuwait=0
- Do
- sleep(100)
- $menuwait=$menuwait+1
- PixelSearch(1630*$x_ratio ,990*$y_ratio, 1660*$x_ratio ,1030*$y_ratio, 0xAF681B, 20, 1, $winhandle) ; this function waits for that helmet button to appear on the lower right of the main menu
- Until (Not @Error OR $menuwait=100)
- If $menuwait=100 Then
- send("{ESC}")
- sleep(2000)
- send("{ESC}")
- $menuwait=0
- EndIf
- $menuwait=0
- sleep(100)
- EndFunc
- Func Ingamewait()
- Do
- sleep(100)
- $ingamewait=$ingamewait+1
- PixelSearch(1100*$x_ratio ,1000*$y_ratio,1140*$x_ratio ,1060*$y_ratio, 0x426AFA, 20, 1, $winhandle) ; this function waits until the blue townportalbutton appears to recognize that we are ingame
- Until (Not @Error OR $ingamewait=100)
- $ingamewait=0
- sleep(200)
- EndFunc
- Func Cellarwait()
- $menuwait=0
- Do
- sleep(100)
- $menuwait=$menuwait+1
- PixelSearch(811*$x_ratio ,222*$y_ratio, 900*$x_ratio ,320*$y_ratio, 0xFDFD34, 40, 1, $winhandle) ; This function waits until the light of the lamp next to the entrance appears
- Until (Not @Error OR $menuwait=100)
- $menuwait=0
- EndFunc
- Func RandomSleep()
- if ($timer) then
- Sleep(Random(2000,240000))
- EndIf
- EndFunc
- Func Pause()
- $Leave = False
- EndFunc
- Func Stop() ;to allow the script to stop
- Exit
- EndFunc
- Func Leave()
- $Leave = True
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement