Advertisement
jakesmurf

Jakesmurf Gold farm 2.2b

Jun 10th, 2012
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 15.89 KB | None | 0 0
  1. Global $Paused
  2.  Global $Paused
  3.  
  4.  
  5.  
  6. $default_resolutionX = 1920
  7. $default_resolutionY = 1080
  8. $x_ratio = @Desktopwidth / $default_resolutionX
  9. $y_ratio = @Desktopheight / $default_resolutionY
  10. Dim $Color, $Left, $Top, $Right, $Bottom
  11. $Left = 300                        
  12. $Top = 0                            
  13. $Right = 1920                      
  14. $Bottom = 1080
  15. $x = 1
  16. $LeftClear = 1000
  17. $RightClear = 1299
  18. $TopClear = 412
  19. $BottomClear = 620
  20. $LeaveVar = 1
  21. $ResumeVar = 1
  22. $IsDead = 0
  23. $full = false
  24. $ready = false
  25.  
  26. ;color codes
  27. $BlueClear = 0x111E34 ; the color of the "aura" of blue items in your inventory panel
  28. $WhiteClear = 0x100908 ; this one is kinda touchy, but theres a certain shade of gray-ish brown in most white item backgrounds that will detect if you find it
  29. $Amethyst = 0xA56DF1
  30. $Ruby = 0xFA8078
  31. $Emerald = 0x51965B
  32. $Topaz = 0xFFFF59
  33. $DeadText =  0xFFFFFF ; this probably won't need changed, but its the color of the YOU HAVE DIED text.  
  34. $MythicPotion = 0xDC1D1D ; update to make the join game timer work right
  35. $CellarDoor = 0x3B62E3 ; the blue of a HIGHLIGHTED cellar door
  36. $Color = 0xFFFF00   ;rare color code
  37. $Color2 = 0x6969FF  ;blue color code     You can put a ; before the FF part if you don't want to pickup blues.  
  38. $Color3 = 0xBF642F  ;legendary color code
  39. $Color4 = 0x00FF00 ;SET color
  40. $InventoryFull = 0xF30504 ; the color of the red text when you click an item but your inventory is completely full
  41. $ResumeButton = 0xE1B559 ; the color of the red on the resume button from the main menu
  42. $AchievementWindow = 0xFFD594 ; the color of the yellow "x" to close the achievement window
  43. $EscapeWindow = 0xFFD594 ; the color of the yellow "x" to close the escape menu
  44. $DisconnectWindow = 0xB47539 ; the color of the "OK" text on the disconnected window.
  45. $LeaveGameButton = 0xC5803E ; the color of the "E" text on the end of "LEAVE" on the leave game button
  46.  
  47.  
  48.  
  49. $go = True
  50. $going = false
  51.  
  52. While $go = true
  53.    
  54.    HotKeySet("=","Start")
  55.    HotKeySet("x", "Stop")
  56.    
  57.    While $going = true
  58.    Call("StartRun")
  59.    
  60. Wend
  61.  
  62. Wend
  63.  
  64.  
  65.    
  66.          
  67. Func StartRun()
  68.  
  69.          Call("JoinGame")
  70. if $ready = true Then
  71.          MouseClick("middle", Round(500*$x_ratio), Round(250*$y_ratio)) ;starts the run [waypoint 1]
  72.          Sleep(200)
  73.          Send("2")
  74.          Sleep(600)
  75.          MouseClick("middle", 1, Round(370*$y_ratio)) ;waits 1 second then [waypoint 2]
  76.          Call("CheckDead")
  77.          Sleep(100)
  78.          Send("1")
  79.          Sleep(1100)
  80.          MouseClick("middle", Round(400*$x_ratio), Round(600*$y_ratio)) ;middle of courtyard
  81.          Call("CheckDead")
  82.          Sleep(900)
  83.          Send("1")
  84.          Send("3")
  85.          sleep(200)
  86.          Call("CellarCheck")
  87.       Else
  88.          Call("JoinGame")
  89.       EndIf
  90.          Return
  91.       EndFunc
  92.      
  93.       Func CellarCheck()     ;looks for the cellar door
  94.          if $ready = true THen
  95.          MouseMove(Round(300*$x_ratio),Round(100*$y_ratio),1) ;moves cursor over to the cellar  ;moves cursor over to the cellar so the proper blue pixel becomes highlighted  
  96.          Sleep(525)
  97.             $Pixel2 = PixelSearch(0,0,(960 * $x_ratio),(540 * $y_ratio),$CellarDoor,3) ;searches for the specific blue pixel that only occurs when mouse hovers over open cellar
  98.                If Not @error Then
  99.                   MouseClick("left",Round(300 *$x_ratio),Round(100 * $y_ratio)) ;Entrance to cellar
  100.                   Call("RunCellar")
  101.                   Return
  102.                EndIf  
  103.         Call("CheckDead")      
  104.                MouseMove(Round(300*$x_ratio),Round(75*$y_ratio),1) ;moves cursor over to the cellar  ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  105.                Sleep(300)
  106.                   $Pixel2 = PixelSearch(0,0,(960 * $x_ratio),(540 * $y_ratio),$CellarDoor,3) ;searches for the specific blue pixel that only occurs when mouse hovers over open cellar
  107.                If Not @error Then
  108.                   MouseClick("left",Round(300 *$x_ratio),Round(75 * $y_ratio)) ;Entrance to cellar
  109.                   Call("RunCellar")
  110.                   Return
  111.                EndIf
  112.         Call("CheckDead")      
  113.          MouseMove(Round(300*$x_ratio),Round(50*$y_ratio),1) ;moves cursor over to the cellar  ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  114.             Sleep(250)
  115.                   $Pixel2 = PixelSearch(0,0,(960 * $x_ratio),(540 * $y_ratio),$CellarDoor,3) ;searches for the specific blue pixel that only occurs when mouse hovers over open cellar
  116.                      If Not @error Then
  117.                         MouseClick("left",Round(300 *$x_ratio),Round(50 * $y_ratio)) ;Entrance to cellar
  118.                         Call("RunCellar")
  119.                         Return
  120.                      EndIf
  121.         Call("CheckDead")      
  122.          MouseMove(Round(250*$x_ratio),Round(50*$y_ratio),1) ;moves cursor over to the cellar  ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  123.             Sleep(250)
  124.                $Pixel2 = PixelSearch(0,0,(960 * $x_ratio),(540 * $y_ratio),$CellarDoor,3) ;searches for the specific blue pixel that only occurs when mouse hovers over open cellar
  125.                   If Not @error Then
  126.                      MouseClick("left",Round(250 *$x_ratio),Round(50 * $y_ratio)) ;Entrance to cellar
  127.                      Call("RunCellar")
  128.                      Return
  129.                Else
  130.                   Call("NoCellar") ;send you to the townportal sequence
  131.                   Return
  132.                EndIf
  133.                
  134.             Else
  135.                
  136.                call("StartRun")
  137.                Return
  138.                EndIF
  139.    Return
  140.                
  141. EndFunc
  142.  
  143. Func RunCellar()  ;this is the sequence for when you are inside the cellar
  144.    if $ready = true then
  145.  
  146.                   Sleep(150)
  147.                   Send(2)
  148.                   Sleep(2800)
  149.                   Call("CheckDead")  ;am I dead?  
  150.                   MouseClick("middle",Round(531 *$x_ratio),Round(769 * $y_ratio))
  151.                   Sleep(1100)
  152.                   MouseClick("middle",Round(547 *$x_ratio),Round(490 * $y_ratio)) ;moves to doorway leading to rare inside cellar
  153.                   Sleep(500)
  154.                   MouseMove(Round(579 * $x_ratio),Round(209 * $y_ratio),1) ;hovers over the rare Sarkoth
  155.                   Send(4)
  156.                   Sleep(500)
  157.                   Call("CheckDead")  ;am I dead?
  158.                   if $IsDead = 0 Then ; if I'm not dead, then kill Sarkoth
  159.                   Send("{SHIFTDOWN}")
  160.                   Sleep(500)
  161.                   MouseClick("left",Round(600 * $x_ratio),Round(239 * $y_ratio),1) ; cast mark of death
  162.                   sleep(500)
  163.                   MouseDown("right") ;attack middle  with right click
  164.                   Sleep(3800)
  165.                   MouseMove(Round(467 * $x_ratio),Round(269 * $y_ratio),1) ;attack left, add more sleep time if you can't kill minion on left
  166.                   Sleep(3000)
  167.                   MouseMove(Round(682 * $x_ratio),Round(147 * $y_ratio),1) ;attack right           
  168.                   Sleep(2700)
  169.                   MouseUP("right") ; stop attacking
  170.                   Sleep(300)
  171.                   Send("{SHIFTUP}")
  172.                   Sleep(500)
  173.                   MouseClick("middle",Round(579 *$x_ratio),Round(209 * $y_ratio)) ;  walk to location of sarkoth's body
  174.                   Sleep(1400)
  175.                   call("FindItem") ;look for loot
  176.                   call("FindItem")
  177.                   call("FindItem")
  178.                   call("FindItem")
  179.                   call("SearchGems") ; look for gems
  180.                   MouseClick("left",Round(912*$x_ratio),Round(300 * $y_ratio)) ;moves to right top corner for gold
  181.                   Sleep(500)
  182.                   Send("t") ; teleport away
  183.                   Sleep(7500)
  184.                   Call("CheckRepair") ; is it time to repair yet?  
  185.                   Return
  186.                  
  187.                Else ; if I am dead, leave the game prematurely
  188.                  
  189.                   $IsDead = 0
  190.                   Call("LeaveGame")
  191.                   Return
  192.                  
  193.                EndIf
  194.                
  195.                
  196.             Else
  197.                
  198.                Call("StartRun")
  199.            
  200.             EndIf
  201.             EndFunc
  202.            
  203. Func NoCellar() ; town portal sequence if the cellar is not there
  204.                if not @error then
  205.                   Send("2")
  206.                   MouseClick("middle",Round(1300 *$x_ratio),Round(900 * $y_ratio))  ;moves down screen away from cellar in attempt for safety before teleporting back to town
  207.                   Sleep(1100)
  208.                   Send("1")
  209.                   Sleep(100)
  210.                   Call("CheckDead")
  211.                   Send("t")
  212.                   Sleep(7300)
  213.                   Call("CheckDead")
  214.                   Call("CheckRepair")
  215.                  
  216.                   Return
  217.                EndIf
  218. EndFunc
  219.  
  220. Func CheckRepair()
  221.                      If $x > 9 Then ; If I have done 10 or more runs now, go ahead and repair.  
  222.                         MouseClick("middle", Round(1480 * $x_ratio),Round(281 * $y_ratio));begin movement towards merchant
  223.                         Sleep(1400)
  224.                         MouseClick("middle", Round(1316 * $x_ratio),Round(206 * $y_ratio)) ;moves to get merchant in screen
  225.                         Sleep(1750)
  226.                         MouseClick("left", Round(845 * $x_ratio),Round(225 * $y_ratio)) ;NPC Merchant to the right of cain's home
  227.                         Sleep(1000)
  228.                         MouseClick("left", Round(521 * $x_ratio),Round(506 * $y_ratio)) ;button to open up repair menu
  229.                         Sleep(1000)
  230.                         MouseClick("left", Round(260 * $x_ratio),Round(595 * $y_ratio)) ;button to pay for repairs       
  231.                         Sleep(500)
  232.                         Send("{ESCAPE}") ;close menu
  233.                         Sleep(500)
  234.                         $x = 0
  235.                         Call("LeaveGame") ; begins the leave game sequence
  236.                         Return
  237.                      Else
  238.                         $x = $x + 1 ; if I haven't done 10 runs, increase the repair counter
  239.                         Call("LeaveGame") ; and then leave the game
  240.                         Return
  241.                      EndIf   
  242.  
  243. Return
  244.                
  245.             EndFunc
  246.            
  247. Func FindItem()
  248.  
  249.    $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color)  ;searches for rares
  250.     If Not @error Then
  251.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  252.       Sleep(1500)
  253.       Call("CheckInv") ; Check to see if I got the "Inventory full" error message
  254.          if $full = true Then
  255.             call("ClearInv") ; Then drop a white or blue item to make room
  256.          EndIf
  257.       EndIf
  258.    
  259.    If $full = false Then ; If my inventory isn't full, look for blue items
  260.    $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color2 )  ;searches for magics
  261.    If Not @error Then
  262.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)    ;clicks magic
  263.       Sleep(450)
  264.       Call("CheckInv"); Check to see if I got the "Inventory full" error message
  265.     EndIf
  266.  EndIf
  267.  
  268.        $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color3 ) ;searches for legendarys
  269.    If Not @error Then
  270.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)         ;clicks legendary
  271.       Sleep(2000)
  272.       call("CheckInv"); Check to see if I got the "Inventory full" error message
  273.          if $full = true Then
  274.             call("ClearInv"); Then drop a white or blue item to make room
  275.          EndIf
  276.    EndIf    
  277.    
  278.     $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color4)  ;searches for SETS
  279.     If Not @error Then
  280.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  281.       Sleep(2000)
  282.       Call("CheckInv"); Check to see if I got the "Inventory full" error message
  283.          if $full = true Then
  284.             call("ClearInv"); Then drop a white or blue item to make room
  285.          EndIf
  286.    EndIf
  287.    
  288.    Call("SearchGems") ; look for gems
  289.    Return
  290.    
  291. EndFunc  
  292.  
  293.    ; search for gems
  294. Func SearchGems()  
  295.    
  296.    $SearchResult = PixelSearch(300, 45, 1190, $Bottom, $Amethyst,8)  ;searches for gems
  297.     If Not @error Then
  298.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  299.       Sleep(1500)
  300.    EndIf
  301.    $SearchResult = PixelSearch(300, 45, 1190, 624, $Ruby,5)  ;searches for gems
  302.     If Not @error Then
  303.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  304.       Sleep(1500)
  305.    EndIf
  306.    $SearchResult = PixelSearch(300, 45, 1190, 624, $Emerald,9)  ;searches for gems
  307.     If Not @error Then
  308.       MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  309.       Sleep(1500)
  310.    EndIf
  311.  ;     $SearchResult = PixelSearch(300, 45, 1190, 624, $Topaz,2)  ;searches for gems
  312.  ;   If Not @error Then
  313.  ;     MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)  ;IF ITS THERE IT CLICKS IT.
  314.  ;     Sleep(800)
  315.  ;  EndIf
  316.  
  317.  Return
  318.   EndFunc
  319.  
  320.   Func ClearInv()
  321.       Send("{i}") ; open inventory
  322.       Sleep(800)
  323.      $SearchResult = PixelSearch($LeftClear, $TopClear, $RightClear, $BottomClear, $BlueClear)
  324.       If Not @error Then
  325.             MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10) ; click a blue item
  326.             Sleep(500)
  327.             MouseClick("left", Round(697* $x_ratio),Round(459 * $y_ratio)) ; drop a blue item
  328.             Sleep(500)
  329.         EndIf  
  330.                 Send("{ESCAPE}") ; close inventory
  331.                 Sleep(500)
  332.                 Call("FindItem") ; call find item again so it will try to pick up that rare again
  333.                
  334.                 Return
  335.              EndFunc
  336.              
  337. Func CheckInv()
  338.    
  339.          $Pixel3 = PixelSearch(640,90,690,120,$InventoryFull,4)  ; did I get the inventory full error?  
  340.                               If Not @error Then ; yes, I'm full!
  341.                                  $full = true
  342.                               Else
  343.                                  $full = false ; nope! Keep on truckin.  
  344.                               EndIf
  345.                            Return
  346. EndFunc
  347.    
  348. Func LeaveGame()
  349.                         Call("CheckWindow") ; see if I have achievements / escape menu open and if I do, close them
  350.                         Send("{ESCAPE}") ;opens menu
  351.                         Sleep(1000)  
  352.                             $Pixel3 = PixelSearch(665,400,690,425,$LeaveGameButton,8)  ; Did I open escape menu properly?  
  353.                               If Not @error Then ; yes, click to leave
  354.                                  MouseClick("left", Round(956 * $x_ratio),Round(579 * $y_ratio)) ;button to leave game
  355.                                  Sleep(3000)
  356.                                  Call("CheckResume")
  357.                               Else ; can't find leave button, lets try again
  358.                                  Call("LeaveGame")
  359.                               EndIF
  360.                              
  361.                               Return
  362.                      EndFunc
  363.                      
  364. Func CheckResume()
  365.    
  366.    Call("CheckWindow") ; Anything open?  
  367.                      
  368.                      While $LeaveVar < 28 ; As long as I haven't already waited 14 seconds, check to see if you can find the chat box on the main screen
  369.    
  370.                         Sleep(500)
  371.                         $Pixel3 = PixelSearch(1160,700,1180,730,$ResumeButton,1)
  372.                         If Not @error Then ; if you find the chat box, click to resume the game before the full wait timer
  373.                            MouseClick("left", Round(230 * $x_ratio),Round(416 * $y_ratio)) ;button to resume game from main menu
  374.                            Sleep(2000)
  375.                            $LeaveVar = 1 ; reset the backup timer
  376.                            Return
  377.                         Else   ; If I haven't found the button yet, add a half second to the backup timer and go on
  378.                            
  379.                            $LeaveVar = $LeaveVar + 1
  380.                            
  381.                         EndIf
  382.                      WEnd
  383.                  
  384.                            MouseClick("left", Round(230 * $x_ratio),Round(416 * $y_ratio)) ;button to resume game from main menu
  385.                            Sleep(2000)
  386.                            $LeaveVar = 1 ; reset the timer
  387.                            Return ; return the whole stack to the $going while
  388.       EndFunc
  389.      
  390.      
  391. Func JoinGame()
  392.    
  393.                   While $ResumeVar < 18 ; as long as I haven't waited 9 seconds for the load to finish
  394.    
  395.                         Sleep(500)
  396.                         $Pixel3 = PixelSearch(725,720,770,750,$MythicPotion,8) ; look for mythic potion
  397.                         If Not @error Then ; if I find the potion,
  398.                            $ResumeVar = 1 ; reset the backup timer, then end the function.  This will cause the entire stack to return back to the $going while, and restart the loop.  
  399.                            $Ready = true
  400.                     Return
  401.                         Else
  402.                               $Pixel3 = PixelSearch(1160,700,1180,730,$ResumeButton,1) ; maybe I didn't click resume correctly?  Lets look
  403.                                  If Not @error Then ; looks like I'm at the main menu somehow.  Lets resume
  404.                                     MouseClick("left", Round(230 * $x_ratio),Round(416 * $y_ratio)) ;button to resume game from main menu
  405.                                     Sleep(2000)
  406.                                     EndIf
  407.                            $ResumeVar = $ResumeVar + 1
  408.                            $Ready = False
  409.                         EndIf  
  410.                   WEnd
  411.                  
  412.                   If $ResumeVar > 17 Then
  413.                      $Ready = True
  414.                      Return
  415.                   EndIf
  416.  
  417.       EndFunc
  418.      
  419. Func CheckWindow()
  420.    
  421.    $Pixel3 = PixelSearch(1115,75,1125,85,$AchievementWindow,4) ; is the achievement window open?  
  422.       If Not @error Then
  423.          Send("{ESCAPE}")
  424.          Sleep(500)
  425.          Call("CheckResume")
  426.       EndIf
  427.      
  428.     $Pixel3 = PixelSearch(815,150,830,165,$EscapeWindow,4)  ; is the escape window open?  
  429.       If Not @error Then
  430.          Send("{ESCAPE}")
  431.          Sleep(500)
  432.          Call("CheckResume")
  433.       EndIf
  434.      
  435.         $Pixel3 = PixelSearch(670,440,690,460,$DisconnectWindow,5)  ; is the disconnect window open?  
  436.       If Not @error Then
  437.          Send("{ESCAPE}")
  438.          Sleep(2000)
  439.          Call("CheckResume")
  440.       EndIf
  441.    Return
  442.    EndFunc   
  443.    
  444. Func CheckDead()
  445.    
  446.    $Pixel3 = PixelSearch(990,247,1000,259,$DeadText,4) ; is the "YOU HAVE DIED." message there?  
  447.       If Not @error Then
  448.          Sleep(500)
  449.          $IsDead = 1
  450.          Call("LeaveGame") ; You dead.  End the game and start over.  
  451.          Return
  452.       Else
  453.          
  454.          $IsDead = 0 ; HE'S ALIVE.  Lets keep going.  
  455.          Return
  456.       EndIf
  457.  
  458.  EndFunc  
  459.  
  460. Func Stop() ;to allow the script to stop
  461.     Exit
  462. EndFunc
  463.  
  464. Func Start() ; lets get this bitch rollin
  465.     $going = true
  466.  EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement