Advertisement
Guest User

Sarkoth-Monk

a guest
Jun 14th, 2012
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 28.30 KB | None | 0 0
  1. #include <ImageSearch.au3> ;comment this if you are not using the new looting system
  2. #include <GUIConstantsEx.au3>
  3. #include <StaticConstants.au3>
  4. #include <WindowsConstants.au3>
  5. #Region ### START Koda GUI section ###
  6. $frmBot = GUICreate("notAres' Sarkoth Bot", 270, 121, 1540, 926, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
  7. $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs until vendor/repair: 0", 4, 4, 260, 17)
  8. GUICtrlSetFont(-1, 5, 800, 0, "MS Sans Serif")
  9. GUICtrlSetColor(-1, 0xFF0000)
  10. $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 31, 19, 240, 17)
  11. $lblStatus = GUICtrlCreateLabel("Status: Resuming Game", 31, 35, 240, 17)
  12. $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 31, 51, 240, 17)
  13. $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 31, 67, 240, 17)
  14. $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 31, 83, 240, 17)
  15. $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 31, 99, 240, 17)
  16. GUISetState(@SW_SHOW)
  17. #EndRegion ### END Koda GUI section ###
  18. Opt('MouseCoordMode', 2)
  19. Opt('PixelCoordMode', 2)
  20. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"), $Paused, $go = True, $Leave = False, $Dead = False, $Logout = False, $Window = False, $ExitButton, $i = 0, $gX = 0, $gY = 0, $LegendaryCount = 0, $SetCount = 0, $RareCount = 0, $MagicCount = 0, $GemCount = 0, $TomeCount = 0, $t = TimerInit(), $rt = 0, $run = 0, $yellow = 0xFFF000, $red = 0xD90000
  21. $VersionsInfo = "http://pastebin.com/raw.php?i=L8hHSZJi"
  22. $oldVersion = IniRead("updater.ini","Version","Version","1.5")
  23. $newVersion = "0.0"
  24. Call("DoUpdate")
  25. HotKeySet("{F1}","Leave")  ;script started by pressing F1
  26. HotKeySet("{F2}", "Pause") ;script paused by pressing F2
  27. HotKeySet("{F3}", "Stop") ;script stopped by pressing F3
  28. HotKeySet("{F4}", "ShowLoot") ;script stopped by pressing F4
  29. If $size = 0 Then
  30.    MsgBox(4096,"Error","Diablo III is not running, cannot grab resolution!")
  31.    Exit
  32. ElseIf ($size[0]/$size[1]) <> 16/9 Then
  33.         $size[1]-=30 ;adjusts ratio for titlebar if not 16:9
  34. EndIf
  35.  
  36. ;============= SETTINGS =============;
  37.  
  38. ;Change to match your abilities (1-4 by default)z
  39. $skillCaltrops = "1"
  40. $skillSmokeScreen = "2"
  41. $skillPreparation = "3"
  42. $skillCompanion = "4"
  43.  
  44. $movementSpeed = 10             ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  45.  
  46. ;Custom Loot
  47. $pngLoc = "C:\pics\"   ;Location of the .PNGs
  48. $totalItems = 18                         ;Number of items in the pick array
  49. Global $pick[$totalItems]       ;DONT CHANGE THIS
  50.  
  51. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  52. $pick[0] = "mythic.png|40"      ;png|Tolerance
  53. $pick[1] = "square.png|40"
  54. $pick[2] = "tome.png|40"
  55. $pick[3] = "legendaryA.png|20"
  56. $pick[4] = "legendaryE.png|20"
  57. $pick[5] = "legendaryI.png|10"
  58. $pick[6] = "legendaryO.png|20"
  59. $pick[7] = "legendaryU.png|20"
  60. $pick[8] = "setA.png|30"
  61. $pick[9] = "setE.png|30"
  62. $pick[10] = "setU.png|30"
  63. $pick[11] = "setO.png|30"
  64. $pick[12] = "setI.png|30"
  65. $pick[13] = "rareA.png|20" ; comment/delete these and adjust $totalItems to disable rare looting
  66. $pick[14] = "rareE.png|20"
  67. $pick[15] = "rareI.png|20"
  68. $pick[16] = "rareO.png|20"
  69. $pick[17] = "rareU.png|20" ; end comment
  70.  
  71. ;Looting
  72. $LootSets = True                ;True if you want to pick up Sets
  73. $LootLegendaries = True ;True if you want to pick up Legendaries
  74. $LootRares = True               ;True if you want to pick up Rares
  75. $LootMagic = True               ;True if you want to pick up Magic
  76. $LootGems = True                ;True if you want to pick up Gems
  77. $LootTomes = True               ;True if you want to pick up Tome of Secrets
  78. $LootCustom = True             ;True if you want to pick up Custom Items (The items in the pick array above)
  79.  
  80. ;Manage Loot
  81. $mLoot = 8                              ;Nuber of successful runs until Stash and Vendor
  82. $mLootOff = 1                   ;Stash and Vendor after mLoot +- X number of runs (Variability)
  83.  
  84. ;Stashing
  85. $StashLoot = True               ;True if you want to store Items in the stash
  86. $StashLegendary = True  ;True if you want to store Legendary items in the stash
  87. $StashRare = True              ;True if you want to store Rare items in the stash
  88. $StashMagic = False     ;True if you want to store Magic items in the stash
  89. $StashTomes = True              ;True if you want to store Tomes items in the stash
  90.  
  91. ;Vendoring
  92. $VendorLoot = True              ;True if you want to vendor Items
  93. $VendorRare = False      ;True if you want to vendor Rares
  94. $VendorMagic = True     ;True if you want to vendor Magic
  95.  
  96. ;Variability
  97. $Timer = False                   ;True and the bot will add random sleep intervals
  98.  
  99. ;====================================;
  100.  
  101. $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
  102. $loadtime = 3400 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  103. $tptime = 6900 ; time in ms the script waits for teleport before exiting the game
  104. $x_ratio = $size[0] / 1440
  105. $y_ratio = $size[1] / 900
  106. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  107. $movementSpeed = 1+($movementSpeed/100)
  108.  
  109. While $go
  110.         Call("RestartRun")
  111.         $nMsg = GUIGetMsg()
  112.         Switch $nMsg
  113.                 Case $GUI_EVENT_CLOSE
  114.                         Exit
  115.         EndSwitch
  116. WEnd
  117.  
  118. Func RestartRun()
  119.         If($Leave) Then
  120.                 $i = 0
  121.                 ;Checks if the player is in the Main Menu
  122.                 If CheckFor("MainMenu") Then
  123.                 $run += 1
  124.                 GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till management: " & $mLootIn)
  125.                 GUICtrlSetData($lblLocation, "Location: Main Menu")
  126.                 GUICtrlSetData($lblStatus, "Status: Starting Game")
  127.                 While True
  128.                         RandClick("left", Round(230*$x_ratio), Round(416*$y_ratio), 120, 20) ;Random Click on the resume button
  129.                         If CheckFor("LimitError", Round(720*$x_ratio), Round(480*$y_ratio), Round(960*$x_ratio), Round(600*$y_ratio), 3) Then
  130.                                 Sleep(Random(1000, 2000))
  131.                                 RandClick("left", Round(960*$y_ratio), Round(635*$x_ratio), 50 ,10)
  132.                                 $rand = Random(40000, 80000)
  133.                                 GUICtrlSetData($lblStatus, "Status: Input Limit Reached - Waiting " & Round($rand/1000) & " seconds.")
  134.                                 Sleep($rand)
  135.                         Else
  136.                                 ExitLoop
  137.                         EndIf
  138.                 WEnd
  139.                 $rt = TimerInit()
  140.                 $Window = False
  141.                 $Logout = False
  142.         Else
  143.                 Return
  144.         EndIf
  145.         If CheckFor("OldRuins", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  146.                 GUICtrlSetData($lblLocation, "Location: Old Ruins")
  147.                 ;Check if player needs to repair
  148.                 Call("CheckRepair")
  149.                 Call("CheckDead")
  150.                 If $Dead OR $Logout Then
  151.                         Return
  152.                 EndIf
  153.  
  154.                 ;Start Run
  155.                 MouseClick("left", Round(0 * $x_ratio),Round(250 * $y_ratio)) ;starts the main run
  156.                      Send("{4 DOWN}")
  157.                      Sleep(3500)
  158.                      Send("{4 UP}")
  159.                      Sleep(100)
  160.                 MouseMove(Round(356*$x_ratio),Round(200*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  161.                 Sleep(790)
  162.                 Call("CheckDead")
  163.                 If $Dead Then
  164.                         Return
  165.                 EndIf
  166.  
  167.                 ;Checks if Dank Cellar is Open
  168.                 $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3)
  169.                 If Not @error Then
  170.                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  171.                         MouseClick("left", Round(356*$x_ratio), Round(200*$y_ratio), 1) ;Entrance to cellar
  172.                         Moving(200)
  173.                         Send($skillSmokeScreen)
  174.                         Moving($walktime)
  175.                 Else ;ABORT RUN
  176.                         GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  177.                         Sleep(10)
  178.                         RandClick("middle", Round(1100*$x_ratio), Round(600*$y_ratio)) ;moves between caltrops for safety before teleporting back to town
  179.                         Moving(250)
  180.                         Send($skillCaltrops)
  181.                         Sleep(620)
  182.                         Send($skillSmokeScreen)
  183.                         Sleep(40)
  184.                         Call("TownPortal")
  185.                         If Not $Logout And Not $Dead And Not $Window Then
  186.                                 Call("LeaveGame")
  187.                                 Return
  188.                         Else
  189.                                 $Window = False ; reset the flag so it doesn't think a window is always up
  190.                                 Return
  191.                         EndIf
  192.                 EndIf
  193.  
  194.                 Call("CheckDead")
  195.                 If $Dead or $Logout Then
  196.                         Return
  197.                 EndIf
  198.         Else
  199.                 Call("TownPortal")
  200.                 If $Dead Then
  201.                         Return
  202.                 EndIf
  203.                 Call("LeaveGame")
  204.                 Return
  205.         EndIf
  206.  
  207.         ;Checks that the player is in the Dank Cellar
  208.         If CheckFor("DankCellar", "Area", 1560*$x_ratio, 0*$y_ratio, 1920*$x_ratio, 60*$y_ratio) Then
  209.                 GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  210.                 MouseClick("middle",Round(110*$x_ratio),Round(1000*$y_ratio)) ;moves to doorway leading to rare inside cellar
  211.                 Sleep(Random(2200, 2800))
  212.                 Send(3)
  213.                 Sleep(30)
  214.                 MouseClick("middle",Round(440*$x_ratio),Round(80*$y_ratio), 1) ;attacks the rare Sarkoth
  215.                 Sleep(2100)
  216.                 Send("{SHIFTDOWN}")
  217.                 Sleep(10)
  218.                 GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  219.                 MouseClick("left")
  220.                 Sleep(10)
  221.                 Send(2)
  222.                 Sleep(10)
  223.                 MouseDown("right") ;attack middle
  224.                 Sleep(12000)
  225.                 MouseClick("right",Round(960*$x_ratio),Round(502*$y_ratio),2)
  226.                 Sleep(100)
  227.                 Send("{SHIFTUP}")
  228.                 Sleep(10)
  229.                 GUICtrlSetData($lblStatus, "Status: Looting")
  230.                 MouseClick("middle",Round(637*$x_ratio),Round(540*$y_ratio)) ;move to left top corner for gold
  231.                 Sleep(1100)
  232.                 MouseClick("middle",Round(1320*$x_ratio),Round(310*$y_ratio)) ;move to right top corner for gold
  233.                 Sleep(1100)
  234.                 MouseClick("middle",Round(975*$x_ratio),Round(827*$y_ratio)) ;move to middle before looting
  235.                 Call("Loot")
  236.                 RandSleep(1, 6, 50)
  237.                 Call("TownPortal")
  238.                 Call("CheckDead")
  239.                 If $Dead or $Logout Then
  240.                         Return
  241.                 EndIf
  242.         Else
  243.                 Send($skillCaltrops)
  244.                 Sleep(620)
  245.                 Send($skillSmokeScreen)
  246.                 Sleep(40)
  247.                 Call("TownPortal")
  248.                 If $Dead Then
  249.                         Return
  250.                 EndIf
  251.                 Call("LeaveGame")
  252.         EndIf
  253.         ;After successful run
  254.         If Not $Logout And Not $Dead And Not $Window Then
  255.                 If $mLootIn == 1 Then ;If its time to manage loot
  256.                         If $StashLoot Then
  257.                                 Call("StashLoot")
  258.                         EndIf
  259.                         If $VendorLoot Then
  260.                                 Call("VendorLoot")
  261.                         EndIf
  262.                         $mLootIn = Round(Random($mLoot-$mLootOff, $mLoot+$mLootOff)) ;Reset Counter
  263.                 Else
  264.                         $mLootIn -= 1
  265.                 EndIf
  266.                         Call("LeaveGame")
  267.                         Return
  268.         Else
  269.                 $Window = False ; reset the flag so it doesn't think a window is always up
  270.                 Return
  271.         EndIf
  272. EndIf
  273. EndFunc
  274.  
  275. ;Helper Functions
  276. Func CheckDead()
  277.         $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"
  278.         If Not @error Then
  279.                 GUICtrlSetData($lblStatus, "Status: Dead")
  280.                 $Dead = True
  281.                 Call("LeaveGame")
  282.                 Sleep(11000)
  283.         Else
  284.                 $Dead = False
  285.         EndIf
  286.  
  287.         $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
  288.         If Not @error Then
  289.                 Sleep(11000)
  290.                 Sleep($loadtime)
  291.         EndIf
  292. EndFunc
  293.  
  294. Func CheckRepair()
  295. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  296.    If Not @error Then
  297.           Call("DoRepair")
  298.    EndIf
  299. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  300.    If Not @error Then
  301.           Call("DoRepair")
  302.    EndIf
  303. EndFunc
  304.  
  305. Func DoRepair()
  306.         Sleep(Random(75, 150))
  307.         Call("TownPortal")
  308.         If $Dead Then
  309.                 Return
  310.         EndIf
  311.         If CheckFor("NewTristram", "Area") Then
  312.                 MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  313.                 Moving(1875)
  314.                 MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  315.                 Moving(1875)
  316.                 MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  317.                 Sleep(1200)
  318.                 MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  319.                 Sleep(400)
  320.                 MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  321.                 Sleep(200)
  322.                 Send("{Escape}")
  323.                 Call("LeaveGame")
  324.         EndIf
  325. EndFunc
  326.  
  327. Func CalcTime()
  328.         $srt = TimerDiff($rt)
  329.         GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt/1000,2) & " seconds.")
  330.         $trt = TimerDiff($t)
  331.         $total = Round((($trt/1000)/60)/60,4)
  332.  
  333.         ;Total runtiume calculation.
  334.         $hours = Floor((($trt/1000)/60)/60)
  335.         $minutes = (($trt/1000)/60)
  336.         ;trim minutes if runtime is more then 1 hour.
  337.         If $minutes > 60 Then
  338.                 While $minutes > 60
  339.                         $minutes -=60
  340.                 WEnd
  341.         EndIf
  342.         GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, "& Ceiling($minutes) &" minutes")
  343.  EndFunc
  344.  
  345.  Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5 ,$tolerance = 100)
  346.         $c = 0
  347.         $string = $pngLoc & $img & ".png"
  348.         Do
  349.                 $c +=1
  350.                 Sleep(100)
  351.                 If $c > ($seconds*10) Then ;Make sure we never get stuck here for infinity.
  352.                         If $type = "Area" Then
  353.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  354.                         EndIf
  355.                         Return False
  356.                 EndIf
  357.         Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  358.         Return True
  359. EndFunc
  360.  
  361. Func LeaveGame()
  362.         $Logout = true
  363.         Call("RandSleep")
  364.         GUICtrlSetData($lblStatus, "Status: Leaving Game")
  365.         Sleep(Random(100, 500))
  366.         Send("{Escape}")
  367.         Sleep(Random(100, 500))
  368.         RandClick("left", Round(956*$x_ratio), Round(579*$y_ratio), 120, 20) ;Random Click on the leave button
  369.         Call("CalcTime")
  370. EndFunc
  371.  
  372. Func Loot()
  373.         Sleep(Random(500,2000))
  374.         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  375.         If $LootSets Then
  376.           $SetCount += LootGear(0x02CE01, 2)
  377.         EndIf
  378.         If $LootLegendaries Then
  379.           $LegendaryCount += LootGear(0xBF642F, 0)
  380.         EndIf
  381.         If $LootRares Then
  382.           $RareCount += LootGear(0xBBBB00, 2)
  383.         EndIf
  384.         If $LootMagic Then
  385.           $MagicCount += LootGear(0x6969FF, 2)
  386.         EndIf
  387.         If $LootGems Then
  388.           Call("LootGems")
  389.         EndIf
  390.         If $LootTomes Then
  391.           Call("LootTomes")
  392.         EndIf
  393.         If $LootCustom Then
  394.           Call("LootCustom")
  395.         EndIf
  396.         Call("ShowLoot")
  397.  EndFunc
  398.  
  399. Func LootGear($color, $tolerance = 2)
  400.    $count = 0
  401.    $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance) ; Magic loot (darker for compatibility)
  402.    If Not @error Then
  403.           While Not @error
  404.                  $count += 1
  405.                  MouseClick ('left', $Loot[0], $Loot[1])
  406.                  Sleep(Random(700,900))
  407.                  MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  408.  
  409.                  ;Run at max 10 times per quality
  410.                  If $count >= 10 Then
  411.                         ExitLoop
  412.                  EndIf
  413.  
  414.                  $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $color, $tolerance) ; Magic loot (darker for compatibility)
  415.           WEnd
  416.    EndIf
  417.    Return $count
  418. EndFunc
  419.  
  420. Func LootCustom()
  421.         $gX = 0
  422.         $gY = 0
  423.         for $i = 0 to ($totalItems - 1)
  424.                 $array = StringSplit($pick[$i],"|")
  425.                 $file = $array[1]
  426.                 $accuracy = $array[2]
  427.                 $urlString = $pngLoc & $file
  428.                 While _ImageSearchArea($pngLoc & $file,1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,$accuracy)
  429.                         sleep(Random(75, 150))
  430.                         MouseClick("left",$gX,$gY,1,1)
  431.                         sleep(Random(800, 1200))
  432.                         MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  433.                 WEnd
  434.         next
  435. EndFunc
  436.  
  437. Func LootGems()
  438.         $gX = 0
  439.         $gY = 0
  440.         While _ImageSearchArea($pngLoc & "square.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  441.                 sleep(Random(75, 150))
  442.                 MouseClick("left",$gX,$gY)
  443.                 $GemCount += 1
  444.                 sleep(Random(800, 1200))
  445.                 MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  446.         WEnd
  447. EndFunc
  448.  
  449. Func LootTomes()
  450.         $gX = 0
  451.         $gY = 0
  452.         While _ImageSearchArea($pngLoc & "tome.png",1,0,0,@DesktopWidth,@DesktopHeight,$gX,$gY,90)
  453.                 sleep(Random(75, 150))
  454.                 MouseClick("left",$gX,$gY)
  455.                 $TomeCount += 1
  456.                 sleep(Random(800, 1200))
  457.                 MouseMove(Round(Random(0,400)*$x_ratio),Round(Random(700,1080)*$y_ratio),3) ;Moves mouse out of the way
  458.         WEnd
  459. EndFunc
  460.  
  461. Func Moving($time)
  462.         Sleep($time/$movementSpeed)
  463. EndFunc
  464.  
  465. Func RandClick($clickType, $xPos, $yPos, $xOff = 20, $yOff = 20)
  466.         $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  467.         $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  468.         MouseClick($clickType, $randX, $randY)
  469. EndFunc
  470.  
  471. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 20)
  472.         $randX = Round(Random($xPos-($xOff*$x_ratio), $xPos+($xOff*$x_ratio)))
  473.         $randY = Round(Random($yPos-($yOff*$y_ratio), $yPos+($yOff*$y_ratio)))
  474.         MouseMove($randX, $randY)
  475. EndFunc
  476.  
  477. Func RandSleep($min = 10, $max = 20, $chance = 5)
  478.         $randNum = Round(Random(1, 100))
  479.         If $Timer And $randNum <= $chance Then
  480.                 $sleepTime = Random($min*1000, $max*1000)
  481.                 GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime/1000) & " secs")
  482.  
  483.                 For $c = 0 To 10
  484.                         Sleep($sleepTime/10)
  485.                 Next
  486.         EndIf
  487. EndFunc
  488.  
  489. Func StashLoot()
  490.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  491.         Sleep(Random(1000, 1500))
  492.         MouseClick("left", 1064*$x_ratio, 256*$y_ratio)
  493.         Sleep(Random(1500, 2000))
  494.  
  495.         ;Legendaries
  496.         While $StashLegendary
  497.                 Sleep(Random(200, 300))
  498.                 $LegendPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4D2C0D, 0)
  499.                 If Not @error Then
  500.                         GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  501.                         MouseClick("right", $LegendPixel[0], $LegendPixel[1])
  502.                 Else
  503.                         ExitLoop
  504.                 EndIf
  505.         WEnd
  506.  
  507.         ;Rares
  508.         While $StashRare
  509.                 Sleep(Random(200, 300))
  510.                 $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4A3C0B, 1)
  511.                 If Not @error Then
  512.                         GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  513.                         MouseClick("right", $RarePixel[0], $RarePixel[1])
  514.                 Else
  515.                         ExitLoop
  516.                 EndIf
  517.         WEnd
  518.  
  519.         ;Tomes
  520.         If _ImageSearchArea($pngLoc & "tomeIcon.png",1,1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio,$gX,$gY,140) Then
  521.                 GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  522.                 MouseClick("left",500*$x_ratio,360*$y_ratio,1,1)
  523.                 Sleep(Random(500, 750))
  524.                 MouseClick("right",$gX,$gY,1,1)
  525.                 Sleep(Random(400, 600))
  526.                 MouseClick("left",500*$x_ratio,200*$y_ratio,1,1)
  527.                 Sleep(Random(200, 500))
  528.         EndIf
  529.  
  530.         ;Magic
  531.         While $StashMagic
  532.                 Sleep(Random(100, 300))
  533.                 $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  534.                 If Not @error Then
  535.                         GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  536.                         MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  537.                 Else
  538.                         ExitLoop
  539.                 EndIf
  540.         WEnd
  541.  
  542.         Sleep(Random(1000, 3000))
  543.         Send("{ESCAPE}")
  544. EndFunc
  545.  
  546. Func TownPortal()
  547.         GUICtrlSetData($lblStatus, "Status: Returning to Town")
  548.         Send("t")
  549.         Sleep(Random($tptime, $tptime+500))
  550.         Call("CheckDead")
  551. EndFunc
  552.  
  553. Func VendorLoot()
  554.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  555.  
  556.         If Not $StashLoot Then ;Move from TP towards vendor
  557.                 Sleep(Random(300, 500))
  558.                 MouseClick("left", 1565*$x_ratio, 50*$y_ratio)
  559.         Else ;Move from Stash towards vendor
  560.                 Sleep(Random(300, 500))
  561.                 MouseClick("left", 1560*$x_ratio, 120*$y_ratio)
  562.         EndIf
  563.         Sleep(3000)
  564.         MouseClick("left", 1030*$x_ratio, 210*$y_ratio) ;Talk to vendor
  565.         Sleep(3000)
  566.  
  567.         ;Rares
  568.         If $VendorRare Then
  569.                 ConsoleWrite("Selling Rare - ")
  570.                 $c = 0
  571.                 While $VendorRare
  572.                         Sleep(Random(200, 300))
  573.                         $RarePixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x4A3C0B, 1)
  574.                         If Not @error Then
  575.                                 MouseClick("right", $RarePixel[0], $RarePixel[1])
  576.                                 $c += 1
  577.                         Else
  578.                                 ConsoleWrite($c & @CRLF)
  579.                                 ExitLoop
  580.                         EndIf
  581.                 WEnd
  582.         EndIf
  583.  
  584.         ;Magic
  585.         If $VendorMagic Then
  586.                 ConsoleWrite("Selling Magic - ")
  587.                 $c = 0
  588.                 While True
  589.                         Sleep(Random(100, 300))
  590.                         $MagicPixel = PixelSearch(1398*$x_ratio, 572*$y_ratio, 1914*$x_ratio, 888*$y_ratio, 0x182037, 2)
  591.                         If Not @error Then
  592.                                 MouseClick("right", $MagicPixel[0], $MagicPixel[1])
  593.                                 $c += 1
  594.                         Else
  595.                                 ConsoleWrite($c & @CRLF)
  596.                                 ExitLoop
  597.                         EndIf
  598.                 WEnd
  599.         EndIf
  600.  
  601.         Sleep(Random(1000, 3000))
  602.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  603.         Send("{ESCAPE}")
  604. EndFunc
  605.  
  606.  
  607. Func DoUpdate()
  608. $Ini = InetGet($VersionsInfo,@ScriptDir & "\version.ini")                                                                                       ;download version.ini
  609. If $Ini = 0 Then                                                                                                                                                                        ;was the download of version.ini successful?
  610.         MsgBox(0,"ERROR","The server seems to be offline. No update will be done.")
  611. Else
  612.     $newVersion = IniRead (@ScriptDir & "\version.ini","Version","Version","")                                          ;reads the new version out of version.ini
  613.     If $NewVersion = $oldVersion Then                                                                                                                           ;compare old and new
  614.         ;MsgBox (0,"No update","There is no update available!")
  615.                 FileDelete(@ScriptDir & "\version.ini")
  616.     Else
  617.         $msg = MsgBox (4,"Update","There is a new version existing: " & $newVersion & " ! You are using: " & $oldVersion & ". Do you want to download the new version?")
  618.                 If $msg = 7 Then                                                                                                                                                        ;No was pressed
  619.             FileDelete(@ScriptDir & "\version.ini")
  620.                 ElseIf $msg = 6 Then                                                                                                                                            ;OK was pressed
  621. ;------------------------------- Begin download the zip file --------------------------------------;
  622.                         $downloadLink = IniRead(@ScriptDir & "\version.ini","Version","download","NotFound")
  623.             $dlhandle = InetGet($downloadLink,@ScriptDir & "\Update.au3",1,1)
  624.             ProgressOn("Update", "Downloading Updates", "",-1,-1,16)                                                                                                            ;creates an progressbar
  625.  
  626.                         $Size = InetGetSize($downloadLink,1)                                                                                                    ;get the size of the update
  627.             While Not InetGetInfo($dlhandle, 2)
  628.                 $Percent = (InetGetInfo($dlhandle,0)/$Size)*100
  629.                 ProgressSet( $Percent, $Percent & " percent")                                                                           ;update progressbar
  630.                 Sleep(1)
  631.             WEnd
  632.             ProgressSet(100 , "Done", "Complete")                                                                                                       ;show complete progressbar
  633.                          sleep(500)
  634.             ProgressOff()                                                                                                                                                       ;close progress window
  635.  
  636. ;------------------------------- Write the new version for future updates --------------------------------------;
  637.             IniWrite("updater.ini","version","version",$NewVersion)
  638.             InetClose($dlhandle)
  639.             MsgBox(-1,"Success","Download Complete! Please restart the bot by running Update.au3")
  640.                         FileDelete(@ScriptDir & "\version.ini")
  641.                         Exit
  642.                 EndIf
  643.     EndIf
  644. EndIf
  645. EndFunc
  646.  
  647. ;Hotkey Functions
  648. Func Leave()
  649.    $Leave = True
  650. EndFunc
  651.  
  652. Func Pause()
  653.    $Leave = False
  654. EndFunc
  655.  
  656. Func ShowLoot()
  657.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  658.         GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " Gems: " & $GemCount & " Tomes: " & $TomeCount)
  659. EndFunc
  660.  
  661. Func Stop() ;to allow the script to stop
  662.     Exit
  663. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement