um4given

Autoit Sarkoth Script

Jun 8th, 2012
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 13.65 KB | None | 0 0
  1. ;ASS(Autoit Sarkoth Script)  ver 1.1.2
  2.     ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  3.     ;Tested With DH build: http://d3db.com/tool/calculator/demon-hunter/28243
  4.     ;Required Max Discipline: 35
  5.     ;Required display mode for cellar detection: "16:9, Tested with 1600*900"
  6.     ;Features:
  7.     ;Selling Junks Supported
  8.     ;Loot scanning. You can choose which quality to loot.
  9.     ;Automatic repair on yellow status icon
  10.     ;Automatic resolution adjustment(need testing)
  11.     ;Stuck Avoidance
  12.     ;Tooltip on pause
  13.     ;Very safe approach, almosot no deaths
  14.    ;Original:
  15.     ;[Goldfarming] AFK 150k-200k Gold Per Hour by mackus101 @ ownedcore
  16.    
  17.     Global $Paused
  18.      
  19.     HotKeySet("=","TogglePause")  ;script can be START and PAUSE by pressing = Also Show some statistics
  20.     HotKeySet("x", "Stop") ;script can be Stopped by pressing x
  21.      
  22.     Global $loadtime = 3500
  23.     Global $waittime = 4000
  24.     Global $LForLegendary = True, $TotalLegendary = 0 ;Loot Legendary Items
  25.     Global $LForSet = True, $TotalSet = 0 ;Loot Set Items
  26.     Global $LForRare = True, $TotalRare = 0 ;Loot Rare Items
  27.     Global $LForMagic = True, $TotalMagic = 0 ;Loot Magic Items
  28.     Global $LForJunk = True, $TotalJunk = 0 ;Loot Junk Items
  29.     Global $Runs = 0 ;for tracking Number of Runs(Do not modify it)
  30.     Global $VoidRuns = 0 ;To keep track of howmany times Cellar Spawns
  31.     Global $SellItems = True ;If you want to sell Magic and Junk Items
  32.     Global $SelPeriod = 12 ; How many Runs before Selling Junks
  33.    
  34.     $Run = False
  35.     $default_resolutionX = 1920
  36.     $default_resolutionY = 1080
  37.     $x_ratio = @Desktopwidth / $default_resolutionX
  38.     $y_ratio = @Desktopheight / $default_resolutionY
  39.      
  40.      
  41.    While True
  42.       if($Run) Then
  43.          $Runs += 1
  44.          Sleep(3000)
  45.          If CheckInGame() Then  
  46.             If CheckRepair() Then   ;Repair is needed
  47.                Teleport()
  48.                While Not CheckInTown() ;Wait till get in town
  49.                   If Not CheckDead() Then ;to prevent Teleporting after coming back to life
  50.                      Teleport()
  51.                   EndIf
  52.                WEnd
  53.                Sleep(100)
  54.                Repair()
  55.                Sleep(100)
  56.                ResetRun()
  57.             Else
  58.                GetToMiddle()
  59.                If CheckCellar() Then
  60.                   GetToCellar()
  61.                   CheckDead()
  62.                   FightSarkoth()
  63.                   MouseClick("left",Round(579 *$x_ratio),Round(209 * $y_ratio)) ;location of sarkoth after death
  64.                   $TotalMagic += 1 ;Counts Magic item at Sarkoth Location
  65.                   CheckLoot()
  66.                   MouseClick("left",Round(1100 *$x_ratio),Round(324 * $y_ratio)) ;moves to right top corner for gold
  67.                   Sleep(500)
  68.                   MouseClick("left",Round(487 *$x_ratio),Round(813 * $y_ratio)) ;moves to left top corner for gold
  69.                   Sleep(1500)
  70.                   If Not CheckDead() Then
  71.                      Teleport()
  72.                      While Not CheckInTown() ;Wait till get in town
  73.                      WEnd
  74.                      if ($Runs / $SelPeriod == Round($Runs/$SelPeriod)) AND $SellItems Then
  75.                         SellJunk()
  76.                      EndIf  
  77.                      Sleep(300)
  78.                      ResetRun()
  79.                   EndIf
  80.                Else
  81.                   $VoidRuns += 1
  82.                   GetToSafety()                
  83.                   Teleport()
  84.                   While Not CheckInTown() ;Wait till get in town
  85.                      If Not CheckDead() Then ;to prevent Teleporting after coming back to life
  86.                         Teleport()
  87.                      EndIf
  88.                   WEnd
  89.                   if ($Runs / $SelPeriod == Round($Runs/$SelPeriod)) AND $SellItems Then
  90.                      SellJunk()
  91.                   EndIf  
  92.                   Sleep(300)
  93.                   If CheckInTown() Then
  94.                      ResetRun()
  95.                   EndIf
  96.                EndIf ;End of checkcellar
  97.             EndIf ;End of checkrepair
  98.          Else
  99.             GetInGame();Resume the game
  100.          EndIf ;End of checkingame
  101.       EndIf ;End of Run
  102.    WEnd ;End of Script
  103.      
  104.    Func CheckDead()
  105.       $Pixeltest = PixelGetColor(Round(740*$x_ratio), Round(850*$y_ratio))
  106.        If Hex($Pixeltest, 6) == "0C0404" OR Hex($Pixeltest, 6) == "310000" Then
  107.           Sleep(100)
  108.           Send("{Escape}")
  109.           Sleep(10)
  110.           MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  111.           Sleep(10000)
  112.           Sleep($waittime)
  113.           MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  114.           Sleep($loadtime)
  115.           $Flag = True
  116.        Else
  117.           $Flag = False  
  118.        EndIf
  119.        Return $Flag
  120.    EndFunc
  121.      
  122.    Func CheckInGame()
  123.       $TeleportButton = PixelSearch(Round(1104*$x_ratio), Round(1008*$y_ratio), Round(1134*$x_ratio), Round(1032*$y_ratio), 0xD9F3FD, 2);Detects If player is in game
  124.          If Not @error Then
  125.             Return True
  126.          Else
  127.             Return False
  128.        EndIf
  129.     EndFunc
  130.    
  131.     Func  GetInGame()
  132.       Send("{SPACE}") ;close any open windows
  133.       Sleep(100)
  134.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  135.       Sleep($loadtime)
  136.    EndFunc
  137.    
  138.    Func CheckInTown()
  139.       $TownBox = PixelSearch(Round(666*$x_ratio), Round(912*$x_ratio), Round(708*$y_ratio), Round(954*$x_ratio), 0x8D6F47);Detects If player is in Town
  140.          If Not @error Then
  141.             Return True
  142.          Else
  143.             Return False
  144.        EndIf
  145.    EndFunc  
  146.      
  147.    Func CheckLoot()
  148.          If $LForLegendary Then
  149.             $i = 0
  150.             While $i < 2
  151.                   Send("{LALT}")
  152.                   Sleep(200)
  153.                   $Legendary = PixelSearch(Round(756*$x_ratio), Round(360*$y_ratio), Round(1080*$x_ratio), Round(668*$y_ratio), 0xBF642F, 2, 3) ;searches main window for color of legendary lootz
  154.                   If Not @error Then
  155.                         ToolTip("Legendary Loot Has been Find",700, 450)
  156.                         Sleep(2000)
  157.                         ToolTip("")
  158.                         $TotalLegendary += 1
  159.                         if IsArray($Legendary) then
  160.                               MouseClick ('left', $Legendary[0], $Legendary[1])
  161.                               Sleep(Random(400,1200))
  162.                         EndIf  
  163.                   EndIf
  164.                   $i = $i+1
  165.             WEnd
  166.          EndIf 
  167.          If $LForSet Then
  168.          $i = 0
  169.             While $i < 1
  170.                   Send("{LALT}")
  171.                   Sleep(200)
  172.                   $Set = PixelSearch(Round(756*$x_ratio), Round(360*$y_ratio), Round(1080*$x_ratio), Round(668*$y_ratio), 0x00FF00, 1, 3) ; searches main window for color of Set lootz
  173.                   If Not @error Then
  174.                         ToolTip("Set Loot Has been Find",700, 450)
  175.                         Sleep(2000)
  176.                         ToolTip("")
  177.                         $TotalSet += 1
  178.                         ToolTip("")
  179.                         if IsArray($Set) then
  180.                               MouseClick ('left', $Set[0], $Set[1])
  181.                               Sleep(Random(400,1200))
  182.                         EndIf  
  183.                   EndIf
  184.                   $i = $i+1
  185.             WEnd
  186.          EndIf
  187.          If $LForRare Then
  188.          $i = 0
  189.             While $i < 3
  190.                   Send("{LALT}")
  191.                   Sleep(200)
  192.                   $Rare = PixelSearch(Round(756*$x_ratio), Round(360*$y_ratio), Round(1080*$x_ratio), Round(668*$y_ratio), 0xFFFF00, 2, 3) ; rare lootz (also f3f45b)
  193.                   If Not @error Then
  194.                         ToolTip("Rare Loot Has been Find",700, 450)
  195.                         Sleep(1000)
  196.                         ToolTip("")
  197.                         $TotalRare += 1
  198.                         ToolTip("")
  199.                         if IsArray($Rare) then
  200.                               MouseClick ('left', $Rare[0], $Rare[1])
  201.                               Sleep(Random(400,1200))
  202.                         EndIf  
  203.                   EndIf
  204.                   $i = $i+1
  205.             WEnd
  206.          EndIf 
  207.          If $LForMagic Then
  208.             $i = 0
  209.             While $i < 5
  210.                   Send("{LALT}")
  211.                   Sleep(200)
  212.                   $Magic = PixelSearch(630, 300, 900, 550, 0x6969FF, 5, 3) ; magic lootz
  213.                   If Not @error Then
  214.                         ;ToolTip("Magic Loot Has been Find",700, 450)
  215.                         Sleep(200)
  216.                         ;ToolTip("")
  217.                         $TotalMagic += 1
  218.                         if IsArray($Magic) then
  219.                               MouseClick ('left', $Magic[0], $Magic[1])
  220.                               Sleep(Random(400,1200))
  221.                         EndIf  
  222.                   EndIf
  223.                   $i = $i+1
  224.             WEnd
  225.          EndIf
  226.          If $LForJunk Then
  227.             $i = 0
  228.             While $i < 5
  229.                   Send("{LALT}")
  230.                   Sleep(200)
  231.                   $Junk = PixelSearch(Round(756*$x_ratio), Round(360*$y_ratio), Round(1080*$x_ratio), Round(668*$y_ratio), 0xFFFFFF, 3, 3) ; Junk lootz
  232.                   If Not @error Then
  233.                         ;ToolTip("Jagic Loot Has been Find",700, 450)
  234.                         Sleep(400)
  235.                         ;ToolTip("")
  236.                         $TotalJunk += 1
  237.                         if IsArray($Junk) then
  238.                               MouseClick ('left', $Junk[0], $Junk[1])
  239.                               Sleep(Random(400,1200))
  240.                         EndIf  
  241.                   EndIf
  242.                   $i = $i+1
  243.             WEnd
  244.          EndIf 
  245.    EndFunc
  246.    
  247.    Func  ResetRun()
  248.       Send("{ESCAPE}") ;opens menu
  249.       Sleep(100)
  250.       MouseClick("left", Round(956*$x_ratio),Round(579*$y_ratio)) ;button to leave game
  251.       Sleep($waittime) ;Wait to get in game menu
  252.       Send("{SPACE}") ;close any open windows
  253.       MouseClick("left", Round(230*$x_ratio),Round(416*$y_ratio)) ;button to resume game from main menu
  254.       Sleep($loadtime)
  255.    EndFunc
  256.                  
  257.    Func Teleport()
  258.       Send("t")
  259.       Sleep(7500)
  260.    EndFunc
  261.    
  262.    Func CheckRepair()
  263.       $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1900*$x_ratio), Round(50*$y_ratio), 0xFFF000, 2);searches top right screen for yellow of broken armor
  264.          If Not @error Then
  265.             Return True
  266.          EndIf
  267.       $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1900*$x_ratio), Round(50*$y_ratio), 0xD90000, 2);searches top right screen for red of broken armor
  268.          If Not @error Then
  269.             Return True
  270.          EndIf
  271.       Return False
  272.    EndFunc
  273.    
  274.    Func Repair()
  275.       MouseClick("middle", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  276.       Sleep(1500)
  277.       MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  278.       Sleep(1500)
  279.       MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  280.       Sleep(1500)
  281.       MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  282.       Sleep(1500)
  283.       MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  284.       Sleep(100)
  285.       Send("{ESCAPE}") ;closes repair tab
  286.    EndFunc
  287.    
  288.    Func SellJunk()
  289.       $left = 1854*$x_ratio
  290.       $right = 1882.8*$x_ratio
  291.       MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  292.       Sleep(1500)
  293.       MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  294.       Sleep(1500)
  295.       MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  296.       Sleep(1500)
  297.       For $j = 1 To 10
  298.          $top = 836.4*$y_ratio
  299.          $bottom = 861.6*$y_ratio
  300.          For $k = 1 To 6  
  301.             ;MouseMove($left, $top, 1)
  302.             $JunkItem = PixelSearch($left, $top, $right, $bottom, 0x130B08, 1, 2) ;search Inventory for Junk Items to sell
  303.             If Not @error Then
  304.                   if IsArray($JunkItem) then
  305.                      MouseClick ('right', $JunkItem[0], $JunkItem[1], 1)
  306.                   EndIf  
  307.             EndIf
  308.             Sleep(200)
  309.             $RareItem = PixelSearch($left, $top, $right, $bottom, 0x11213A, 5, 2) ;search Inventory for Magic Items to sell
  310.             If Not @error Then
  311.                   if IsArray($RareItem) then
  312.                         MouseClick ('right', $RareItem[0], $RareItem[1], 1)
  313.                   EndIf  
  314.             EndIf    
  315.          $top -= 48*$y_ratio
  316.          $bottom -= 48*$y_ratio  
  317.          Next
  318.          $left -= 48*$x_ratio
  319.          $right -= 48*$x_ratio
  320.       Next
  321.       Sleep(100)
  322.       Send("{SPACE}") ;closes Merchant Window    
  323.    EndFunc
  324.    
  325.    Func GetToMiddle()
  326.       MouseClick("middle", 587 * $x_ratio,335* $y_ratio) ;starts the main run
  327.       Sleep(600)
  328.       Sleep(1000)
  329.       Send("2") ;Smoke Screen
  330.       MouseClick("middle", 96 * $x_ratio,383 * $y_ratio)
  331.       Sleep(800)
  332.       Send("1")
  333.       Sleep(1200)
  334.       MouseClick("middle", Round(417 * $x_ratio),Round(422 * $y_ratio)) ;middle of area outside of cellar
  335.       Sleep(100)
  336.       Send("1")
  337.       Sleep(1500)
  338.       Send("3") ;Caltrops
  339.    EndFunc
  340.    
  341.    Func GetToSafety()
  342.       Send("{SHIFTDOWN}")
  343.       MouseDown("left")
  344.       Sleep(100)
  345.       MouseUp("left")
  346.       Send("{SHIFTUP}")
  347.       Sleep(100)
  348.       MouseClick("middle", Round(1115 *$x_ratio), Round(205 * $y_ratio), 1) ;moves up screen away from cellar in attempt for safety before teleporting back to town
  349.       Sleep(100)
  350.       Send("1")
  351.       Sleep(300)
  352.    EndFunc  
  353.                                        
  354.    Func CheckCellar()  
  355.       Sleep(400)
  356.       MouseMove(Round(115 * $x_ratio),Round(210 * $y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted   
  357.       Sleep(500)
  358.       Global $Cellar = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;searches for the specific blue pixel that only occurs when mouse hovers over open cellar
  359.       If Not @error Then
  360.          Return True
  361.       Else
  362.          MouseMove(Round(150 * $x_ratio), Round(108 * $y_ratio), 1) ;moves cursor over to the Alternate cellar Location so the proper blue pixel becomes highlighted   
  363.          Sleep(800)
  364.          $AltCellar = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;searches for the specific blue pixel
  365.          If IsArray($AltCellar) Then
  366.             Return True
  367.          EndIf
  368.       EndIf
  369.       Return False
  370.    EndFunc
  371.    
  372.    Func GetToCellar()  
  373.       Sleep(100)
  374.       Send("2") ;Smoke Screen
  375.       If IsArray($Cellar) Then
  376.          MouseClick("left",Round(115 *$x_ratio),Round(210 * $y_ratio)) ;Entrance to cellar
  377.          Sleep(4000)
  378.       Else
  379.          MouseClick("left",Round(150 *$x_ratio),Round(108 * $y_ratio)) ;Entrance to cellar
  380.          Sleep(5000)
  381.       EndIf
  382.    EndFunc
  383.    
  384.    Func FightSarkoth()
  385.       Send(2)
  386.       Sleep(100)
  387.       MouseClick("left",Round(531 *$x_ratio),Round(769 * $y_ratio))
  388.       Sleep(600)
  389.       MouseClick("left",Round(547 *$x_ratio),Round(490 * $y_ratio)) ;moves to doorway leading to rare inside cellar
  390.       Sleep(1500)
  391.       MouseMove(Round(579 * $x_ratio),Round(209 * $y_ratio),1) ;hovers over the rare Sarkoth
  392.       Send(4)
  393.       Sleep(1000)
  394.       Send("{SHIFTDOWN}")
  395.       MouseDown("right") ;attack middle
  396.       Sleep(3800)
  397.       MouseMove(Round(467 * $x_ratio),Round(269 * $y_ratio),1) ;attack left, add more sleep time if you can't kill minion on left
  398.       Sleep(3000)
  399.       MouseMove(Round(682 * $x_ratio),Round(147 * $y_ratio),1) ;attack right
  400.       Sleep(800)
  401.       MouseMove(Round(579 * $x_ratio),Round(209 * $y_ratio),1) ;move back to middle
  402.       Sleep(1000)
  403.       MouseUP("right")
  404.       Sleep(300)
  405.       Send("{SHIFTUP}")
  406.    EndFunc
  407.                      
  408.    Func TogglePause()
  409.     $Run = Not $Run
  410.     While Not $Run
  411.         Sleep(100)
  412.         ToolTip("So far "&$Runs&" Runs("&$VoidRuns&" Void Runs): "&$TotalLegendary&" Legendaries, "&$TotalSet&" Sets, "&$TotalRare&" Rares, "&$TotalMagic&" Magic, "&$TotalJunk&" Junks Looted",700, 450)
  413.     WEnd
  414.     ToolTip("")
  415.    EndFunc   ;==>TogglePause
  416.      
  417.     Func Stop() ;to allow the script to stop
  418.         Exit 0
  419.     EndFunc
Advertisement
Add Comment
Please, Sign In to add comment