Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ImageSearch.au3> ;comment this if you are not using the new looting system
- Global $Paused
- 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
- ;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 = "C:\Users\junqi\Documents\D3" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
- $totalItems = 19 ; This needs to match the number of pngs you are loading
- Global $pick[$totalItems], $size = WinGetClientSize("[TITLE:Diablo III; CLASS:D3 Main Window Class]"), $go = True, $Leave = False, $Dead = False, $Logout = False, $Window = False, $i = 0, $currentArrayItem = 0, $gX = 0, $gY = 0
- If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
- $pick[0] = "legendaryA.png|20"
- $pick[1] = "legendaryE.png|20"
- $pick[2] = "legendaryI.png|10"
- $pick[3] = "legendaryO.png|20"
- $pick[4] = "legendaryU.png|20"
- $pick[5] = "legendaryY.png|20"
- $pick[6] = "setA.png|30"
- $pick[7] = "setE.png|30"
- $pick[8] = "setU.png|30"
- $pick[9] = "setO.png|30"
- $pick[10] = "setI.png|30"
- $pick[11] = "rareA.png|20"
- $pick[12] = "rareE.png|20"
- $pick[13] = "rareI.png|20"
- $pick[14] = "rareO.png|20"
- $pick[15] = "rareU.png|20"
- $pick[16] = "ros.png|40"
- $pick[17] = "uare.png|40"
- $pick[18] = "tome.png|40"
- $LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
- $Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
- $walktime = 3000 ; 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 = 5000 ; 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
- $x_ratio = $size[0] / 1920
- $y_ratio = $size[1] / 1080
- $yellow = 0xFFF000 ; yellow color code (repair icon)
- $red = 0xD90000 ; red color code (repair icon)
- 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
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $Window = False
- ExitLoop
- ElseIf $Dead or $Logout Then
- ExitLoop
- EndIf
- MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
- Sleep(900)
- Send("2")
- Sleep(300)
- MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
- Sleep(1400)
- MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
- Sleep(40)
- Send("2")
- Sleep(20)
- Send("3")
- Sleep(600)
- Send("1")
- Sleep(300)
- MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
- Sleep(790)
- Call("CheckDead")
- If $Window Then
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $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 600x600 box from the top left - where it should always be)
- If Not @error Then
- MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
- Sleep(300)
- Send("2")
- Sleep(350) ; second cast in case the cooldown timer isn't quite right (rarely happens)
- Send("2")
- Sleep($walktime)
- MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
- Sleep(2500)
- MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
- Sleep(10)
- Send("{SHIFTDOWN}")
- MouseDown("right") ;attack middle
- Sleep(1200)
- Send("4")
- Sleep(3000)
- MouseUp("right")
- MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
- MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
- Sleep(40)
- MouseDown("right")
- Sleep(2800)
- MouseUp("right")
- MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
- MouseDown("right")
- Sleep(1800)
- MouseUp("right")
- MouseDown("left")
- MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
- Sleep(1200)
- MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
- Sleep(1200)
- MouseUP("left")
- Sleep(10)
- MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
- Sleep(10)
- Send("{SHIFTUP}")
- Sleep(400)
- MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
- Sleep(2100)
- MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
- Sleep(1100)
- MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
- Sleep(1100)
- Send("4")
- MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
- Send("{ALTDOWN}")
- Call("CheckLoot")
- Send("{ALTUP}")
- SLeep(10)
- 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)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep($loadtime)
- Call("CheckDead")
- If Not $Logout Then
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- EndIf
- Else
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $Window = False ; reset the flag so it doesn't think a window is always up
- EndIf
- Else
- Sleep(10)
- MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
- Sleep(200)
- Send("1")
- Sleep(620)
- Send("2")
- Sleep(40)
- 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)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep($loadtime)
- Call("CheckDead")
- If Not $Logout Then
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- EndIf
- Else
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $Window = False ; reset the flag so it doesn't think a window is always up
- EndIf
- EndIf
- EndIf
- WEnd
- Call("RestartRun")
- 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
- Sleep(100)
- Send("{Escape}")
- Sleep(10)
- MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
- Sleep(11000)
- Sleep($loadtime)
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- Else
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $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)
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- Else
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- $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)
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- 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(1500)
- MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
- Sleep(1500)
- 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)
- MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
- Sleep($loadtime)
- EndIf
- EndFunc
- Func CheckLoot()
- Sleep(Random(500,2000))
- If Not $ImgLoot Then
- $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
- If Not @error Then
- MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
- Sleep(Random(1000,1200))
- MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
- $i+= 1
- If $i <= 6 Then
- Call("CheckLoot")
- SLeep(10)
- EndIf
- EndIf
- $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
- If Not @error Then
- MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
- Sleep(Random(1000,1200))
- MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
- $i+= 1
- If $i <= 6 Then
- Call("CheckLoot")
- SLeep(10)
- EndIf
- EndIf
- If $LootRares Then
- $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
- If Not @error Then
- MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
- Sleep(Random(1000,1200))
- MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
- $i+= 1
- If $i <= 6 Then
- Call("CheckLoot")
- EndIf
- EndIf
- EndIf
- Else
- Call("pickItems")
- 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 RandomSleep()
- If $Timer And Random(1,20) = 20 Then
- Sleep(Random(30000,60000)
- 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