Guest User

need help with it

a guest
Jun 11th, 2012
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ImageSearch.au3> ;comment this if you are not using the new looting system
  2. Global $Paused
  3. Opt('MouseCoordMode', 2)
  4. Opt('PixelCoordMode', 2)
  5. HotKeySet("=","Leave")  ;script started by pressing =
  6. HotKeySet("-", "Pause") ;script paused by pressing -
  7. HotKeySet("x", "Stop") ;script stopped by pressing x
  8.  
  9. ;ImageSearch Looting Variables
  10. $ImgLoot = True ; set this to true if you want to use ImageSearch looting system. False will revert to old PixelSearch method
  11. $directory = "C:\Users\junqi\Documents\D3" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  12. $totalItems = 19 ; This needs to match the number of pngs you are loading
  13. 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
  14. If ($size[0]/$size[1]) <> 16/9 Then $size[1]-=30 ; adjusts ratio for titlebar if not 16:9
  15. $pick[0] = "legendaryA.png|20"
  16. $pick[1] = "legendaryE.png|20"
  17. $pick[2] = "legendaryI.png|10"
  18. $pick[3] = "legendaryO.png|20"
  19. $pick[4] = "legendaryU.png|20"
  20. $pick[5] = "legendaryY.png|20"
  21. $pick[6] = "setA.png|30"
  22. $pick[7] = "setE.png|30"
  23. $pick[8] = "setU.png|30"
  24. $pick[9] = "setO.png|30"
  25. $pick[10] = "setI.png|30"
  26. $pick[11] = "rareA.png|20"
  27. $pick[12] = "rareE.png|20"
  28. $pick[13] = "rareI.png|20"
  29. $pick[14] = "rareO.png|20"
  30. $pick[15] = "rareU.png|20"
  31. $pick[16] = "ros.png|40"
  32. $pick[17] = "uare.png|40"
  33. $pick[18] = "tome.png|40"
  34.  
  35. $LootRares = True ; set this to false if you don't want the bot to pick up rares (old looting method only)
  36. $Timer = False ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  37. $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
  38. $loadtime = 5000 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  39. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  40. $x_ratio = $size[0] / 1920
  41. $y_ratio = $size[1] / 1080
  42. $yellow = 0xFFF000 ; yellow color code (repair icon)
  43. $red = 0xD90000 ; red color code (repair icon)
  44.  
  45. Call("RestartRun")
  46. Func RestartRun()
  47.    While $go
  48.       if($Leave) Then
  49.          $i = 0
  50.          Call("CheckExit")
  51.          Sleep(850) ;had to add this since the icon doesn't show up RIGHT away in game
  52.          Call("CheckDead")
  53.          Call("CheckRepair")
  54.          If $Window Then
  55.             MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  56.             Sleep($loadtime)
  57.             $Window = False
  58.             ExitLoop
  59.          ElseIf $Dead or $Logout Then
  60.             ExitLoop
  61.          EndIf
  62.          MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
  63.          Sleep(900)
  64.          Send("2")
  65.          Sleep(300)
  66.          MouseClick("middle", 1, Round(370*$y_ratio)) ;waits ~1 second then [waypoint 2]
  67.          Sleep(1400)
  68.          MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard [waypoint 3]
  69.          Sleep(40)
  70.          Send("2")
  71.          Sleep(20)
  72.          Send("3")
  73.          Sleep(600)
  74.          Send("1")
  75.          Sleep(300)
  76.          MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  77.          Sleep(790)
  78.          Call("CheckDead")
  79.          If $Window Then
  80.             MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  81.             Sleep($loadtime)
  82.             $Window = False
  83.             ExitLoop
  84.          ElseIf $Dead or $Logout Then
  85.             ExitLoop
  86.          EndIf
  87.          $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)
  88.                If Not @error Then
  89.                   MouseClick("left",Round(300*$x_ratio),Round(100*$y_ratio)) ;Entrance to cellar
  90.                   Sleep(300)
  91.                   Send("2")
  92.                   Sleep(350) ; second cast in case the cooldown timer isn't quite right (rarely happens)
  93.                   Send("2")
  94.                   Sleep($walktime)
  95.                   MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  96.                   Sleep(2500)
  97.                   MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  98.                   Sleep(10)
  99.                   Send("{SHIFTDOWN}")
  100.                   MouseDown("right") ;attack middle
  101.                   Sleep(1200)
  102.                   Send("4")
  103.                   Sleep(3000)
  104.                   MouseUp("right")
  105.                   MouseClick("left",Round(440*$x_ratio),Round(80*$y_ratio),2)
  106.                   MouseMove(Round(240*$x_ratio),Round(75*$y_ratio),1) ;attack left
  107.                   Sleep(40)
  108.                   MouseDown("right")
  109.                   Sleep(2800)
  110.                   MouseUp("right")
  111.                   MouseMove(Round(590*$x_ratio),Round(50*$y_ratio),1) ;attack right
  112.                   MouseDown("right")
  113.                   Sleep(1800)
  114.                   MouseUp("right")
  115.                   MouseDown("left")
  116.                   MouseMove(Round(Random(240,260)*$x_ratio),Round(75*$y_ratio),1) ;attack left
  117.                   Sleep(1200)
  118.                   MouseMove(Round(Random(560,600)*$x_ratio),Round(50*$y_ratio),1) ;attack right
  119.                   Sleep(1200)
  120.                   MouseUP("left")
  121.                   Sleep(10)
  122.                   MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2) ;break the table & chair
  123.                   Sleep(10)
  124.                   Send("{SHIFTUP}")
  125.                   Sleep(400)
  126.                   MouseClick("middle",Round(530*$x_ratio),Round(170*$y_ratio)) ;location of sarkoth after death
  127.                   Sleep(2100)
  128.                   MouseClick("middle",Round(580*$x_ratio),Round(460*$y_ratio)) ;move to left top corner for gold
  129.                   Sleep(1100)
  130.                   MouseClick("middle",Round(1330*$x_ratio),Round(330*$y_ratio)) ;move to right top corner for gold
  131.                   Sleep(1100)
  132.                   Send("4")
  133.                   MouseClick("middle",Round(1010*$x_ratio),Round(940*$y_ratio)) ;move to middle before looting
  134.                   Send("{ALTDOWN}")
  135.                   Call("CheckLoot")
  136.                   Send("{ALTUP}")
  137.                   SLeep(10)
  138.                   Send("t")
  139.                   Sleep($tptime)
  140.                   Call("RandomSleep")
  141.                   Call("CheckDead")
  142.                   If Not $Logout And Not $Dead And Not $Window Then
  143.                      Sleep(300)
  144.                      Send("{ESCAPE}") ;menu
  145.                      Sleep(200)
  146.                      MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  147.                      Sleep($loadtime)
  148.                      Call("CheckDead")
  149.                      If Not $Logout Then
  150.                         MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  151.                         Sleep($loadtime)
  152.                      EndIf
  153.                   Else
  154.                      MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  155.                      Sleep($loadtime)
  156.                      $Window = False ; reset the flag so it doesn't think a window is always up
  157.                   EndIf
  158.                Else
  159.                   Sleep(10)
  160.                   MouseClick("middle",Round(1100*$x_ratio),Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  161.                   Sleep(200)
  162.                   Send("1")
  163.                   Sleep(620)
  164.                   Send("2")
  165.                   Sleep(40)
  166.                   Send("t")
  167.                   Sleep($tptime)
  168.                   Call("RandomSleep")
  169.                   Call("CheckDead")
  170.                   If Not $Logout And Not $Dead And Not $Window Then
  171.                      Sleep(300)
  172.                      Send("{ESCAPE}") ;menu
  173.                      Sleep(200)
  174.                      MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  175.                      Sleep($loadtime)
  176.                      Call("CheckDead")
  177.                      If Not $Logout Then
  178.                         MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  179.                         Sleep($loadtime)
  180.                      EndIf
  181.                   Else
  182.                      MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  183.                      Sleep($loadtime)
  184.                      $Window = False ; reset the flag so it doesn't think a window is always up
  185.                   EndIf
  186.             EndIf
  187.       EndIf
  188.    WEnd
  189.    Call("RestartRun")
  190. EndFunc
  191.  
  192. Func CheckDead()
  193. Call("CheckWindow")
  194. $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"
  195. If Not @error Then
  196.    If Not $Window Then
  197.       $Dead = True
  198.       Sleep(100)
  199.       Send("{Escape}")
  200.       Sleep(10)
  201.       MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  202.       Sleep(11000)
  203.       Sleep($loadtime)
  204.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  205.       Sleep($loadtime)
  206.    Else
  207.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  208.       Sleep($loadtime)
  209.       $Dead = False
  210.    EndIf
  211. Else
  212.    $Dead = False
  213. EndIf
  214. $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
  215. If Not @error Then
  216.    Sleep(11000)
  217.    Sleep($loadtime)
  218.    If Not $Window Then
  219.       $Dead = True
  220.       $Logout = True
  221.       Sleep($loadtime)
  222.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  223.       Sleep($loadtime)
  224.    Else
  225.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  226.       Sleep($loadtime)
  227.       $Logout = False
  228.    EndIf
  229. Else
  230.    $Logout = False
  231. EndIf
  232. EndFunc
  233.  
  234. Func CheckWindow()
  235. $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
  236. If Not @error Then
  237.    Sleep(200)
  238.    Send("{SPACE}") ;close any open windows
  239.    $Window = True
  240. Else
  241.    $Window = False
  242. EndIf
  243. EndFunc
  244.  
  245. Func CheckExit()
  246. $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
  247. If Not @error Then
  248.    Send("{ESCAPE}")
  249.    Sleep(100)
  250.    Send("{SPACE}") ;close any open windows
  251.    Sleep(200)
  252.    MouseMove(1,1) ; reset cursor position before checking for button
  253.    $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  254.    If $Resume == "400900" Or $Resume == "380900" Then
  255.       Sleep(200)
  256.       MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  257.       Sleep($loadtime)
  258.    EndIf
  259. EndIf
  260. EndFunc
  261.  
  262. Func CheckRepair()
  263. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  264.    If Not @error Then
  265.       Call("DoRepair")
  266.    EndIf
  267. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  268.    If Not @error Then
  269.       Call("DoRepair")
  270.    EndIf
  271. EndFunc
  272.  
  273. Func DoRepair()
  274. Sleep(100)
  275. Send("t")
  276. Sleep($tptime)
  277. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  278. Sleep(1500)
  279. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  280. Sleep(1500)
  281. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  282. Sleep(1200)
  283. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  284. Sleep(400)
  285. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  286. Sleep(200)
  287. Call("CheckDead")
  288. If Not $Dead and Not $Logout Then
  289.    Send("{ESCAPE}") ;closes repair tab
  290.    Sleep(100)
  291.    Send("{ESCAPE}") ;menu
  292.    Sleep(10)
  293.    MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  294.    Sleep($loadtime)
  295.    MouseClick("left", Round(140*$x_ratio),Round(420*$y_ratio)) ;button to resume game from main menu
  296.    Sleep($loadtime)
  297. EndIf
  298. EndFunc
  299.  
  300. Func CheckLoot()
  301. Sleep(Random(500,2000))
  302. If Not $ImgLoot Then
  303.    $SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  304.    If Not @error Then
  305.       MouseClick ('left', $SetLoot[0], $SetLoot[1], 1, 0)
  306.       Sleep(Random(1000,1200))
  307.       MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  308.       $i+= 1
  309.       If $i <= 6 Then
  310.          Call("CheckLoot")
  311.          SLeep(10)
  312.       EndIf
  313.    EndIf
  314.    $LegendaryLoot= PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBF642F, 2) ; legendary loot
  315.    If Not @error Then
  316.       MouseClick ('left', $LegendaryLoot[0], $LegendaryLoot[1], 1, 0)
  317.       Sleep(Random(1000,1200))
  318.       MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  319.       $i+= 1
  320.       If $i <= 6 Then
  321.          Call("CheckLoot")
  322.          SLeep(10)
  323.       EndIf
  324.    EndIf
  325.    If $LootRares Then
  326.       $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1900*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility)
  327.       If Not @error Then
  328.          MouseClick ('left', $RareLoot[0], $RareLoot[1], 1, 0)
  329.          Sleep(Random(1000,1200))
  330.          MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  331.          $i+= 1
  332.          If $i <= 6 Then
  333.          Call("CheckLoot")
  334.          EndIf
  335.       EndIf
  336.    EndIf
  337. Else
  338.    Call("pickItems")
  339. EndIf
  340. EndFunc
  341.  
  342. Func pickItems()
  343. $currentArrayItem = 0
  344. For $gI = 0 to ($totalItems - 1)
  345.    $array = StringSplit($pick[$gI],"|")
  346.    $file = $array[1]
  347.    $accuracy = $array[2]
  348.    $urlString = $directory & $file
  349.    $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  350.    While $i <= 12 ; max: 13 gems and pieces of gear to loot
  351.       If $Target And ($gX > 15) And ($gY > 15) Then
  352.          ;MsgBox(4096,"Debug",$urlString & " " & $gX & "-" & $gY)
  353.          MouseClick("left", $gX, $gY, 1, 0)
  354.          Sleep(Random(1200,1400))
  355.          MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  356.          Sleep(5)
  357.          $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  358.          $i+= 1
  359.       Else
  360.          ExitLoop
  361.       EndIf
  362.    WEnd
  363. Next
  364. EndFunc
  365.  
  366. Func RandomSleep()
  367.    If $Timer And Random(1,20) = 20 Then
  368.       Sleep(Random(30000,60000)
  369.    EndIf
  370. EndFunc
  371.  
  372. Func Pause()
  373.    $Leave = False
  374. EndFunc
  375.  
  376. Func Stop() ;to allow the script to stop
  377.     Exit
  378. EndFunc
  379.  
  380. Func Leave()
  381.    $Leave = True
  382. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment