Guest User

Need Help

a guest
Aug 4th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 12.31 KB | None | 0 0
  1. Opt('MouseCoordMode', 0)
  2. Opt('PixelCoordMode', 0)
  3. Opt('SendKeyDelay', 50) ; Default speed
  4.  
  5. HotKeySet('{END}', 'Quit')
  6. HotKeySet('{F10}', 'Pause')
  7.  
  8. Global $Paused
  9. Global $DebugOn = True
  10.  
  11.  
  12. $Amethyst = 0xA56DF1
  13. $Ruby = 0xFA8078
  14. $Emerald = 0x51965B
  15. $Topaz = 0xFFFF59
  16. $Left = 64
  17. $Top = 42
  18. $Right = 720
  19. $Bottom = 519
  20. $Rare = 0xFFFF00 ; rare color
  21. $Magic = 0x6969FF ; blue color
  22. $Legendary = 0xBF642F ; legendary color
  23. $Set = 0x00FF00 ; set color
  24.  
  25.  
  26. ; bot starts paused. press F10 to start.
  27. Pause()
  28.  
  29.  
  30. WinActivate('Diablo III')
  31. While 1
  32.    If WinActive('Diablo III') Then
  33.  
  34.      checkResume()
  35.       Sleep(400)
  36.       Click(134, 255) ; click resume
  37.       Sleep(3800) ; load
  38.      $repair = PixelSearch(579,49,584,53,0xFFF000,2) ; searches top right screen for broken armor
  39.  
  40.       If (Not @error) Or (CheckInv() == 1) Then
  41.                  InvRepair()
  42.       Else
  43.        Send('3')
  44.        Sleep(20)
  45.        Teleport()
  46.        Sleep(20)
  47.        Send('1')
  48.        Sleep(30)
  49.        $yellow = PixelSearch(643, 109, 698, 163, 0xF5CD37, 10) ; checks minimap for cellar
  50.        If Not @error Then ; found cellar
  51.                  DEBUG("Cellar found")
  52.          Move(66,435)
  53.          Move(134, 249)
  54.          Sleep(150)
  55.          $blue = PixelSearch(430, 132, 602, 267, 0x5D80DB, 5) ; gets position of cellar
  56.          If Not @error Then
  57.             MouseClick("left", $blue[0], $blue[1], 1, Random(6,7))
  58.             Sleep(1100)
  59.          EndIf
  60.          Sleep(1500)
  61.          Move(126, 494)
  62.          Move(176, 252)
  63.          Click(349, 595) ; choose hydra
  64.          Click(217, 171) ; cast hydra
  65.                  Shoot(131, 161, 2)
  66.          MouseClickDrag ( "right", 131, 171 , 260, 106, 15)
  67.          ;MouseClickDrag ( "right", 131, 171 , 260, 106, 15)
  68.          Shoot(223, 170, 40)
  69.          Sleep(650) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -< время простоя до сбора
  70.          Move(98, 146)
  71.                  Sleep(300)
  72.                  MouseClick('middle', 453, 281, 1, Random(0, 1))
  73.                  Sleep(150)
  74.          MouseClick("right", 259, 549, 1, 2)
  75.          FindItem()
  76.                  TownPortal()
  77.                  Sleep(300)
  78.                  Send("{ESCAPE}") ; opens menu
  79.                  Sleep(Random(300,350))
  80.                  Click(407,345) ; leaves
  81.                  Sleep(Random(1990,2010))
  82.        Else ; cellar not found
  83.                  DEBUG("Cellar not found")
  84.                  SafetyFirst() ; will go into archon and use skill '1' to blow things up
  85.          TownPortal()
  86.                  Sleep(300)
  87.          Send("{ESCAPE}") ; opens menu
  88.          Sleep(400)
  89.          Click(407, 345) ; leaves
  90.          Sleep(2000)
  91.        EndIf
  92.      EndIf
  93.    EndIf
  94. WEnd
  95.  
  96. Func TownPortal()
  97.    Send('t')
  98.    Sleep(6600)
  99. EndFunc
  100.  
  101.  
  102. Func SafetyFirst()
  103.    MouseClick("right", 500, 500, 1, Random(0, 1)) ; archon activation
  104.    Sleep(380) ;380
  105.    Send('1') ; AoE skill 1
  106.    Sleep(100)
  107. EndFunc
  108.  
  109.  
  110. Func Move($x, $y)
  111.    MouseClick('middle', $x, $y, 1, Random(0, 1))
  112.    Sleep(1500)
  113. EndFunc   ;==>Move
  114.  
  115.  
  116. Func checkResume()
  117.    Local $check = 0
  118.    While $check == 0
  119.    $resume = PixelSearch(63, 255, 83, 269, 0x2C0100,10)
  120.      If Not @error Then ; at menu, hits resume
  121.        $check = 1
  122.        DEBUG("RESUME")
  123.         Else
  124.        Sleep(100)
  125.            If CheckDisconnect() Then
  126.                   Send("{ENTER}")
  127.                   Sleep(800)
  128.                  
  129.            EndIf
  130.      EndIf
  131.    WEnd
  132. EndFunc
  133.  
  134.  
  135. Func Shoot($x, $y, $clicks)
  136.    MouseClick('right', $x, $y, $clicks, 4)
  137.    Sleep(Random(100, 150))
  138. EndFunc   ;==>Shoot
  139.  
  140.  
  141. Func Teleport()
  142.    MouseMove(5, 199)
  143.    SendUntil('2', 2000)
  144.    Sleep(Random(50, 150))
  145. EndFunc   ;==>Teleport
  146.  
  147. Func CheckRare()
  148.    Send("{i}")
  149.    Sleep(100)
  150.    $unidRare1 = PixelSearch(772,463,790,500,0xFFFFFF,5) ; looks at the question mark which is white
  151.    $unidRare2 = PixelSearch(745,463,763,500,0xFFFFFF,5)
  152.    If (Not IsArray($unidRare1)) And (Not IsArray($unidRare2)) Then ; not a rare in last slot
  153.           Send("{i}")
  154.           Return 1
  155.    EndIf
  156.    ; rare in last slot
  157.    Send("{i}")
  158.    Return 0
  159. EndFunc
  160.  
  161.  
  162. Func Click($x, $y)
  163.    MouseClick('left', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
  164.    Sleep(Random(100, 140))
  165. EndFunc   ;==>Click
  166.  
  167.  
  168. Func FindItem()
  169.    Sleep(50)
  170.    $work = 1
  171.    $checkCount = 0
  172.    $checkFull = 0
  173.    While $work == 1 And $checkCount <15
  174.      If CheckInv() == 1 Then ; full and cannot pickup remaining items
  175.                 DEBUG("Inventory full, ending item finding")
  176.                 ExitLoop
  177.          EndIf
  178.      DEBUG("Search Item")
  179.      $work = 0
  180.       $SearchResult = PixelSearch(382, 131, $Right, $Bottom, $Rare) ; searches for rares
  181.       If Not @error Then
  182.         MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  183.         Sleep(350)
  184.         $work = 1
  185.         $checkCount = $checkCount +1
  186.          EndIf
  187.  
  188.      $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Magic ) ; searches for magics
  189.      If Not @error Then
  190.        MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  191.        Sleep(350)
  192.        $work = 1
  193.        $checkCount = $checkCount +1
  194.      EndIf
  195.  
  196.       $SearchResult = PixelSearch(382, 131, $Right, $Bottom, $Legendary ) ; searches for legendaries
  197.       If Not @error Then
  198.         MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  199.         Sleep(350)
  200.         $work = 1
  201.         $checkCount = $checkCount +1
  202.       EndIf
  203.       $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Set) ; searches for set
  204.       If Not @error Then
  205.         MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  206.         Sleep(350)
  207.         $work = 1
  208.         $checkCount = $checkCount +1
  209.       EndIf
  210.  
  211.       ;search for gems ; ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
  212.  
  213.      ;$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Amethyst,9) ; searches for amethyst
  214.     ;If Not @error Then
  215.       ;MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  216.        ;Sleep(350)
  217.        ;$work = 1
  218.        ;$checkCount = $checkCount +1
  219.      ;EndIf
  220.     ;$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Ruby,6) ; searches for ruby
  221.      ;If Not @error Then
  222.      ; MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; clicks if found
  223.     ;   Sleep(350)
  224.     ;  $work = 1
  225.     ;   $checkCount = $checkCount +1
  226.    ;  EndIf
  227.     ;$SearchResult = PixelSearch(382, 131, $Right, $Bottom, $Topaz,4) ;searches for topaz
  228.    ;  If Not @error Then
  229.     ;  MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ;IF ITS THERE IT CLICKS IT.
  230.     ;  Sleep(350)
  231.     ;  $work = 1
  232.     ;   $checkCount = $checkCount +1
  233.     ; EndIf
  234.     ; $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Emerald,9) ;searches for emerald
  235.     ; If Not @error Then
  236.     ;   MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ;IF ITS THERE IT CLICKS IT.
  237.     ;   Sleep(350)
  238.     ;   $work = 1
  239.     ;   $checkCount = $checkCount +1
  240.    ;  EndIf ; gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
  241.   WEnd
  242.   If $checkFull == 1 Then
  243.           TownPortal()
  244.    EndIf
  245.  
  246.    DEBUG("Finished Item Searching")
  247. EndFunc
  248.  
  249.  
  250. Func CheckDeath() ; returns 1 if dead
  251.    $death = PixelSearch(285, 491, 308, 508, 0x2C0100,2)
  252.    If @error Then ; not dead
  253.           Return 0
  254.    Else ; you died
  255.           DEBUG("DEAD")
  256.       Sleep(200)
  257.       Send("{ESCAPE}") ;opens menu
  258.           Sleep(400)
  259.           Click(407, 345) ;leaves
  260.           Sleep(12000)
  261.           Return 1
  262.    EndIf
  263. EndFunc
  264.  
  265. Func CheckDisconnect()
  266.    $status = PixelSearch(400, 375, 416, 385, 0xA76933, 2)
  267.    If @error Then
  268.           Return False
  269.        Else
  270.          
  271.           Debug("Disconnected..")
  272.                Sleep(800)
  273.           Return False ;True
  274.    EndIf
  275. EndFunc
  276.  
  277.  
  278. Func CheckInv() ; returns 1 if full
  279.    Send("{i}") ; opens inventory
  280.    Sleep(250)
  281.    ; will check if any bottom 4 right-most boxes are occupied Rows 5 and 6, Columns 9 and 10.
  282.    $row5col9 = PixelSearch(763, 481, 765, 483, 0x100907,5)
  283.    $row5col10 = PixelSearch(789, 481, 791, 483, 0x100808,5)
  284.    $row6col9 = PixelSearch(763, 507, 765, 510, 0x100907,5)
  285.    $row6col10 = PixelSearch(789, 507, 791, 510, 0x100808,5)
  286.    If (Not IsArray($row5col10)) Or (Not IsArray($row6col10)) Or (Not IsArray($row5col9)) Or (Not IsArray($row6col9)) Then
  287.      DEBUG("FULL")
  288.          ;Beep(1000, 1000)
  289.          Send("{i}")
  290.      Return 1
  291.   EndIf
  292.    Send("{i}") ; closes inventory
  293.    Return 0
  294. EndFunc
  295.  
  296.  
  297. Func InvRepair()
  298.      DEBUG("Going to repair")
  299.        $slot1x = 538 ; first slot x coordinate
  300.        $slot1y = 367 ; first slot y coordinate
  301.        $offset = 27 ; offset for each slot
  302.  
  303.          TownPortal()
  304.                  If InTown() == 1 Then ; TP interrupted, leave game before trying to repair because you are not in Town
  305.                         Return
  306.                  Else
  307.                         Debug("In town, beginning repair trip")
  308.                         If CheckRare() == 0 Then ; rare is in last of the 4 slots, need to store
  309.                            MouseClick("left",465,172) ; clicks stash after town portal
  310.                            Sleep(700)
  311.                            MouseClick("left",292,296) ; clicks third tab in stash
  312.                            Sleep(300)
  313.                            For $i = 756 To 782 Step 26
  314.                                   For $j = 474 To 497 Step 23
  315.                                      MouseClick("right",$i,$j, 1, Random(0,1)) ; stashes those possible rares in the bottom right corner
  316.                                   Next
  317.                            Next
  318.                            Send("{ESCAPE}") ; close stash
  319.                            MouseClick("left", 686, 94) ; begins movement towards merchant
  320.                            Sleep(2400)
  321.                            MouseClick("left", 505, 153) ; clicks merchant
  322.                            Sleep(1300)
  323.                         Else ; no need to storage, move normally to merchant
  324.                            MouseClick("left", 700, 147) ; begins movement towards merchant
  325.                            Sleep(2400)
  326.                            MouseClick("left", 531, 51) ; clicks merchant
  327.                            Sleep(2800)
  328.                         EndIf
  329.                         For $i = 0 To 9
  330.                            For $j = 0 To 5
  331.                                   MouseClick("right", $slot1x + ($i * $offset), $slot1y + ($j * $offset), 1, Random(0,1))
  332.                                   Sleep(Random(35,40))
  333.                            Next
  334.                         Next
  335.                         Click(294, 296) ; open up repair menu
  336.                         Sleep(200)
  337.                         Click(186, 326) ; pay for repairs
  338.                         Sleep(500)
  339.                         $inBag = PixelSearch(780, 474, 782, 476, 0x130C08,5)
  340.                         If @error Then
  341.                            DEBUG("Not at shop")
  342.                            Send("{ESCAPE}") ; opens menu
  343.                            Sleep(400)
  344.                            Click(407, 345) ; leaves
  345.                            Sleep(12000)
  346.                         Else
  347.                            Send("{ESCAPE}") ; closes shop
  348.                            Sleep(50)
  349.                            Send("{ESCAPE}") ; opens menu
  350.                            Sleep(400)
  351.                            Click(407, 345) ; leaves
  352.                            Sleep(2000)
  353.                         EndIf
  354.                  EndIf
  355. EndFunc
  356.  
  357.  
  358. Func InTown()
  359.    Debug("Checking if in town")
  360.    Sleep(180)
  361.    $check = PixelSearch(261,551,263,553,0xB17C2D,5)
  362.    If @error Then ; not in town
  363.           Debug("Not in town")
  364.           Send("{ESCAPE}") ; opens menu
  365.           Sleep(400)
  366.       Click(407, 345) ; leaves
  367.       Sleep(12000)
  368.           Return 1
  369.    EndIf
  370.    Return 0 ; in town
  371. EndFunc
  372.  
  373.  
  374. Func Pause()
  375.    $Paused = Not $Paused
  376.    While $Paused
  377.       Sleep(100)
  378.       ToolTip('Paused...', 0, 0)
  379.    WEnd
  380.    ToolTip("")
  381. EndFunc   ;==>Pause
  382.  
  383.  
  384. Func SendUntil($text, $milliseconds)
  385.     $time = TimerInit()
  386.     Do
  387.         Send($text)
  388.     Until TimerDiff($time) > $milliseconds
  389. EndFunc
  390.  
  391.  
  392. Func Quit()
  393.    Exit
  394. EndFunc   ;==>Quit
  395.  
  396.  
  397. Func DEBUG($MESSAGE)
  398.    If $DebugOn Then
  399.       ToolTip($MESSAGE, 0, 0)
  400.    EndIf
  401. EndFunc   ;==>Debug Info
Advertisement
Add Comment
Please, Sign In to add comment