Advertisement
gaabrielrd

AutoIt Barbarian Script Fix

Sep 24th, 2013
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 44.41 KB | None | 0 0
  1. ;tofuartist, LATM & BlackSack's Barbarian Script
  2.  
  3. ;notAres' Sarkoth Gold Script - 6/16/2012
  4. ;YOU MUST START THE BOT AT THE RESUME GAME SCREEN!
  5. ;Thread: http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/d3-gold-profiles/355316-goldfarming-barbarian-sarkoth-goldfarming-script-autoit-script-1920x1080.html
  6. ;;;;;
  7. ;WONT WORK UNLESS MOVE IS BOUND TO MIDDLE MOUSE (Mouse 3) -- NOT MOVE/INTERACT
  8. ;Required build: http://us.battle.net/d3/en/calculator/barbarian#TUXgkj!ghV!bYabZa
  9. ;Required display mode for cellar detection: "FULLSCREEN WINDOWED"
  10. ;Official supported resolution: 1920x1080
  11. ;;;;;
  12. ;Original by mackus101 @ ownedcore
  13. ;ImageSearch contributions by rvbfreak, goofinator, and asuRob
  14. ;Refactoring and additional functions by Shimizoki
  15.  
  16. ;=========== DO NOT TOUCH ===========;
  17. #RequireAdmin
  18. #include <GUIConstantsEx.au3>
  19. #include <StaticConstants.au3>
  20. #include <WindowsConstants.au3>
  21. Opt('MouseCoordMode', 2)
  22. Opt('PixelCoordMode', 2)
  23. Global $size = WinGetClientSize("[CLASS:D3 Main Window Class]"),
  24.        $ver = "1.9",
  25.        $ini = "tf-Barbarian.ini",
  26.        $hFont = 0,
  27.        $title,
  28.        $Paused,
  29.        $Go = False,
  30.        $i = 0,
  31.        $gX = 0,
  32.        $gY = 0,
  33.        $LegendaryCount = 0,
  34.        $SetCount = 0,
  35.        $RareCount = 0,
  36.        $MagicCount = 0,
  37.        $GemCount = 0,
  38.        $TomeCount = 0,
  39.        $t = TimerInit(),
  40.        $rt = 0, $run = 0,
  41.        $yellow = 0xFFF000,
  42.        $red = 0xD90000,
  43.        $lblRun,
  44.        $lblLocation,
  45.        $lblStatus,
  46.        $lblLast,
  47.        $lblRuntime,
  48.        $lblGear,
  49.        $lblItems
  50. For $i = 0 To Random(3, 6, 1)
  51.         $title &= Chr(Random(97, 122, 1))
  52. Next
  53. For $i = 0 To Random(4, 8, 1)
  54.         $title &= Chr(Random(65, 90, 1))
  55. Next
  56. $title &= " "
  57. Global $gems[8] = ["Ru1.png", "Ru2.png", "Em1.png", "Em2.png", "To1.png", "To2.png", "Am1.png", "Am2.png"]
  58. If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
  59. If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "ERROR", "Why aren't you running the 64-bit AutoIt??? Expect bugs!")
  60. If $size = 0 Then
  61.         MsgBox(16, "Error", "Diablo III is not running, cannot grab resolution!" & @CRLF & "Exiting...")
  62.         Exit
  63. EndIf
  64. ;====================================;
  65.  
  66. ;============= SETTINGS =============;
  67. HotKeySet("=", "Begin") ;script toggled on/off by pressing =
  68. HotKeySet("{PAUSE}", "TogglePause") ;script toggle pause by pressing Pause/Break key
  69. HotKeySet("x", "Stop") ;script stopped by pressing x
  70.  
  71. $movementSpeed = 0 ;This is the % increase movement speed you have. 25 = 25%, 0 = 0%, 50 = 50%
  72.  
  73. ;Custom Loot
  74. $pngLoc = "C:\botd3\" ;Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  75. $totalItems = 1 ;Number of items in the pick array
  76. Global $pick[$totalItems] ;DONT CHANGE THIS
  77.  
  78. ;Array of items to loot (GEMS AND TOMES ALREADY INCLUDED)
  79. $pick[0] = "mythic.png|40" ;png|Tolerance
  80. ;$pick[1] = "item2.png|0"
  81. ;$pick[2] = "item3.png|0"
  82.  
  83. ;Looting
  84. $LootSets = "True" ;True if you want to pick up Sets
  85. $LootLegendaries = "True"       ;True if you want to pick up Legendaries
  86. $LootRares = "True" ;True if you want to pick up Rares
  87. $LootMagic = "True" ;True if you want to pick up Magic
  88. $LootGems = "True" ;True if you want to pick up Gems
  89. $LootTomes = "True" ;True if you want to pick up Tome of Secrets
  90. $LootCustom = "False" ;True if you want to pick up Custom Items (The items in the $pick array above)
  91.  
  92. ;Manage Loot
  93. $mLoot = 5 ;Nuber of successful runs until Stash and Vendor
  94. $mLootOff = 2 ;Stash and Vendor after mLoot +- X number of runs (Variability)
  95.  
  96. ;Stashing
  97. $StashLoot = "True" ;True if you want to store Items in the stash
  98. $IdentifyItems = "False" ;True if you want to identify Items before stashing
  99. ;---
  100. $StashLegendary = "True";True if you want to store Legendary items in the stash
  101. $StashRare = "True" ;True if you want to store Rare items in the stash
  102. $StashMagic = "False" ;True if you want to store Magic items in the stash
  103. $StashTomes = "True" ;True if you want to store Tomes items in the stash
  104. $StashGems = "True" ;True if you want to store Gems items in the stash
  105.  
  106. $GemTab = 3 ;Tab to put gems and tombs in
  107. $ItemTab = 1 ;Tab to put any items in
  108. $NextItemTab = 2 ;Next Tab to put any items in when first one is full
  109.  
  110. ;Vendoring ==NEW SETTINGS==
  111. $VendorLoot = "True" ;True if you want to vendor anything
  112. ;---
  113. $VendorRare = "False" ;True if you want to vendor Rares
  114. $VendorMagic = "True" ;True if you want to vendor Magic
  115. $vendorAll = "False" ;True if you want to right click all items when talking to vendor
  116. $vendorRows = 6 ;# of rows to vendor, starting from the top (default = 5: bottom row is safe)
  117. $vendorCols = 10 ;# of columns to vendor, starting from left
  118.  
  119. ;Variability ==NEW SETTINGS==
  120. $Timer = "True" ;True and the bot will add random sleep intervals
  121. ;---
  122. $walktime = 2400 ;Time (in ms) the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  123. $loadtime = 3400 ;Time (in ms) the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  124. $tptime = 6900 ;Time (in ms) the script waits for teleport before exiting the game
  125. ;====================================;
  126.  
  127. $x_ratio = $size[0] / 1920
  128. $y_ratio = $size[1] / 1080
  129. If FileExists($ini) Then
  130.         Call("ReadINI")
  131.         Call("CreateINI")
  132. Else
  133.         Call("CreateINI")
  134. EndIf
  135.  
  136. $mLootIn = $mLoot ;DO NOT CHANGE, how many more runs till next manage
  137. $movementSpeed = 1 + ($movementSpeed / 100)
  138. $VersionsInfo = "http://dl.dropbox.com/u/9955791/version.ini"
  139. $oldVersion = IniRead("updater.ini", "Version", "Version", $ver)
  140. $newVersion = "0.0"
  141.  
  142. If Not FileExists($pngLoc & "MainMenu.png") Then
  143.         MsgBox(16, "Fatal Error", "FATAL ERROR: Cannot find: " & $pngLoc & "MainMenu.png" & @CRLF & "Make sure your directory is set properly in the script")
  144.         Exit
  145. EndIf
  146.  
  147. Call("SetupGUI")
  148.  
  149. While 1
  150.         Call("RestartRun")
  151. WEnd
  152.  
  153. Func RestartRun()
  154.         If ($Go) Then
  155.                 $i = 0
  156.                                 Send("{SPACE}")
  157.                             Sleep(100)
  158.                 WinSetTitle($title, "", $title & $ver & " - Running")
  159.                                 RandMove(Round(Random(10, 230) * $x_ratio), Round(Random(11, 286) * $y_ratio), 120, 20);Moves mouse out of the way
  160.                 ;Checks if the player is Dead/Logout/Window, then in Old Ruins, then if in Main Menu, etc.
  161.                 If CheckDead() Then
  162.                         Return
  163.                 ElseIf CheckFor("OldRuins", "", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 1, 140) Then
  164.                         Call("TownPortal")
  165.                         Call("LeaveGame")
  166.                         Return
  167.                 ElseIf CheckFor("MainMenu", "", Round(40 * $x_ratio), Round(300 * $y_ratio), Round(400 * $x_ratio), Round(450 * $y_ratio), 7, 140) Then
  168.                         GUICtrlSetData($lblRun, "Run Number: " & $run & " - Runs till vendor: " & $mLootIn)
  169.                         GUICtrlSetData($lblLocation, "Location: Main Menu")
  170.                         GUICtrlSetData($lblStatus, "Status: Starting Game")
  171.                                                 Send("{SPACE}")
  172.                                                 Sleep(100)
  173.                         RandClick("left", Round(230 * $x_ratio), Round(416 * $y_ratio), 120, 20, 1, 6) ;Random Click on the resume button
  174.                         Sleep(10000)
  175.                         MouseClick("left", 170, 55)     ;town portal fix
  176.                         Sleep(8000)
  177.                         $rt = TimerInit()
  178.                         $run += 1
  179.                 ElseIf CheckFor("ExitGame", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(420 * $y_ratio), 1, 140) Then
  180.                         GUICtrlSetData($lblStatus, "Status: Exit window up")
  181.                         MouseClick("left", Round(1064 * $x_ratio), Round(632 * $y_ratio))
  182.                         Sleep(100)
  183.                         Send("{SPACE}")
  184.                         Return
  185.                 ElseIf CheckFor("LimitError", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  186.                         MouseClick("left", Round(960 * $y_ratio), Round(635 * $x_ratio))
  187.                         $rand = Random(40000, 80000)
  188.                         GUICtrlSetData($lblStatus, "Status: Input Limit - Waiting " & Round($rand / 1000) & " seconds.")
  189.                         Sleep($rand)
  190.                         Send("{SPACE}")
  191.                         Return
  192.                 ElseIf CheckFor("Disconnect", "", Round(700 * $x_ratio), Round(340 * $y_ratio), Round(1200 * $x_ratio), Round(600 * $y_ratio), 1, 140) Then
  193.                         GUICtrlSetData($lblStatus, "Status: Network Disconnect window up")
  194.                         MouseClick("left", Round(960 * $x_ratio), Round(632 * $y_ratio))
  195.                         Sleep(100)
  196.                         Send("{SPACE}")
  197.                         Return
  198.                 Else
  199.                         GUICtrlSetData($lblStatus, "ERROR: Cannot find Resume button")
  200.                         Return
  201.                 EndIf
  202.                 ;Make sure we are in the right area before beginning run
  203.                 If CheckFor("OldRuins", "Area", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 6, 180) Then
  204.                         GUICtrlSetData($lblLocation, "Location: Old Ruins")
  205.                         ;Check if player needs to repair
  206.                         Call("CheckRepair")
  207.                         ;Start Run
  208.                         RandClick("middle", Round(587 * $x_ratio),Round(333 * $y_ratio), 2, 2) ;starts the main run
  209.                         Sleep(Random(990,1140))
  210.                         RandMove(Round(96*$x_ratio),Round(383*$y_ratio), 2, 2)
  211.                         Sleep(Random(5, 10))
  212.                         Send("1")
  213.                         Sleep(300)
  214.                         Send("3")
  215.                         Sleep(360)
  216.                         RandClick("right",Round(210*$x_ratio),Round(12*$y_ratio), 10, 10)
  217.                         RandClick("middle", Round(56 * $x_ratio),Round(360 * $y_ratio), 1, 1)
  218.                         Sleep(Random(2300, 2500))
  219.                         ;RandMove(Round(348*$x_ratio),Round(179*$y_ratio), 2, 2) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  220.                        
  221.                         $celx = 348
  222.                         $cely = 179
  223.                         MouseMove(Round($celx*$x_ratio),Round($cely*$y_ratio), 1) ;moves cursor over to the cellar
  224.                         Sleep(200)              
  225.                         $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  226.                         If @error Then
  227.                                   $celx = 309
  228.                                   $cely = 224
  229.                                   MouseMove(Round($celx*$x_ratio),Round($cely*$y_ratio),1) ;moves cursor over to the cellar
  230.                                   Sleep(200)
  231.                                   $Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(600*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  232.                         EndIf
  233.                         $celerr = @error
  234.                        
  235.                         Sleep(10)
  236.                         If Call("CheckDead") Then
  237.                                 Return
  238.                         EndIf
  239.  
  240.                         ;Checks if Dank Cellar is Open
  241.                         ;$Pixel2 = PixelSearch(0, 0, Round(600 * $x_ratio), Round(600 * $y_ratio), 0x334FB7, 3)
  242.                         If Not $celerr Then
  243.                                 GUICtrlSetData($lblStatus, "Status: Cellar - Found")
  244.                                 Sleep(10)
  245.                             RandClick("right",Round(15*$x_ratio),Round(1055*$y_ratio), 10, 10)
  246.                             RandClick("left",Round($celx*$x_ratio),Round($cely*$y_ratio), 1) ;Entrance to cellar
  247.                             Sleep(Random(1400, 1600))
  248.                                 Moving($walktime)
  249.                         Else ;ABORT RUN
  250.                                 GUICtrlSetData($lblStatus, "Status: Cellar - Not Found" & @CRLF)
  251.                                 Sleep(10)
  252.                             Send("{SHIFTDOWN}")
  253.                             RandClick("left", Round(900*$x_ratio), Round(600*$y_ratio), 100, 100) ;earthquake
  254.                             Send("{SHIFTUP}")
  255.                             Sleep(620)
  256.                                 Call("TownPortal")
  257.                                 If Not Call("CheckDead") Then
  258.                                         Call("LeaveGame")
  259.                                 EndIf
  260.                                 Return
  261.                         EndIf
  262.                 Else
  263.                         Call("TownPortal")
  264.                         If Not Call("CheckDead") Then
  265.                                 Call("LeaveGame")
  266.                         EndIf
  267.                         Return
  268.                 EndIf
  269.  
  270.                 ;Checks that the player is in the Dank Cellar
  271.                 If CheckFor("DankCellar", "Area", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 6, 180) Then
  272.                         GUICtrlSetData($lblLocation, "Location: Dank Cellar")
  273.                         Call("CheckDead")
  274.                         RandClick("middle",Round(80*$x_ratio),Round(830*$y_ratio), 1, 1) ;moves to doorway leading to rare inside cellar
  275.                         Sleep(Random(2000, 2400))
  276.                         GUICtrlSetData($lblStatus, "Status: Attacking Sarkoth")
  277.                         RandMove(Round(350*$x_ratio),Round(60*$y_ratio),1) ;hovers over the rare Sarkoth
  278.                         Send("1")
  279.                         Sleep(200)
  280.                         Send("{SHIFTDOWN}")
  281.                         RandClick("left", Round(11*$x_ratio), Round(1037*$y_ratio), 10, 10) ;earthquake
  282.                         Send("{SHIFTUP}")
  283.                         Sleep(200)
  284.                         Send("{SHIFTDOWN}")
  285.                         RandClick("left", Round(11*$x_ratio), Round(1037*$y_ratio), 10, 10) ;earthquake
  286.                         Send("{SHIFTUP}")
  287.                         Sleep(800)
  288.                         Send("2")
  289.                         Sleep(140)
  290.                         Send("2")
  291.                         Sleep(100)
  292.                         Send("4")
  293.                         Sleep(100)
  294.                         Send("4")
  295.                         Sleep(100)
  296.                         Send("4")
  297.                         Sleep(100)
  298.                         Send("4")
  299.                         Sleep(100)
  300.                         Call("CheckDead")
  301.                         Sleep(Random(2600, 3000))
  302.                         RandClick("middle",Round(730*$x_ratio),Round(585*$y_ratio), 1, 1) ;move to left top corner for gold
  303.                         Sleep(Random(850, 1350))
  304.                         RandClick("middle",Round(1205*$x_ratio),Round(380*$y_ratio), 1, 1) ;move to right top corner for gold
  305.                         Sleep(Random(900, 1400))
  306.                         RandClick("middle",Round(1121*$x_ratio),Round(805*$y_ratio), 1, 1) ;move to middle before looting
  307.                         Sleep(Random(2500, 2820))
  308.                         Call("CheckDead")
  309.                         GUICtrlSetData($lblStatus, "Status: Looting")
  310.                         Call("Loot")
  311.                         RandSleep(0, 5, 25)
  312.                         Call("CheckDead")
  313.                         Call("TownPortal")
  314.                 Else
  315.                         Sleep(10)
  316.                         Send("{SHIFTDOWN}")
  317.                         RandClick("left", Round(900*$x_ratio), Round(600*$y_ratio), 100, 100) ;earthquake
  318.                         Send("{SHIFTUP}")
  319.                         Sleep(620)
  320.                         Call("TownPortal")
  321.                         If Not Call("CheckDead") Then
  322.                                 Call("LeaveGame")
  323.                         EndIf
  324.                         Return
  325.                 EndIf
  326.                 ;After successful run
  327.                 If Not Call("CheckDead") Then
  328.                         Sleep(600)
  329.                         If $mLootIn = 1 And CheckFor("NewTristram", "Area", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 4, 200) Then ;If its time to manage loot and we are in town
  330.                             If $IdentifyItems == "True" Then
  331.                                    Call("Identify")
  332.                                 EndIf
  333.                                 If $StashLoot == "True" Then
  334.                                         Call("StashLoot")
  335.                                 EndIf
  336.                                 If $VendorLoot == "True" Then
  337.                                         Call("VendorLoot")
  338.                                 EndIf
  339.                                 $mLootIn = Round(Random($mLoot - $mLootOff, $mLoot + $mLootOff)) ;Reset Counter
  340.                         ElseIf Not CheckFor("NewTristram", "Area", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 1, 200) Then
  341.                                 GUICtrlSetData($lblStatus, "Status: Skipping vendor, not in New Tristram")
  342.                                 Sleep(3000)
  343.                         Else
  344.                                 $mLootIn -= 1
  345.                         EndIf
  346.                         If Not Call("CheckDead") Then
  347.                                 Call("LeaveGame")
  348.                         EndIf
  349.                         Return
  350.                 Else
  351.                         Return
  352.                 EndIf
  353.         EndIf
  354. EndFunc   ;==>RestartRun
  355.  
  356. ;Helper Functions
  357.  
  358. Func SetupGUI()
  359.         $frmBot = GUICreate($title & $ver & " - Updating", 280, 121, Round(1540 * $x_ratio), Round(920 * $y_ratio), -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
  360.         GUISetBkColor(0xC0C0C0)
  361.         $lblRun = GUICtrlCreateLabel("Run Number: 0 - Runs till vendor: 0", 4, 0, 280, 24)
  362.         GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
  363.         GUICtrlSetColor(-1, 0xFF0000)
  364.         $lblLocation = GUICtrlCreateLabel("Location: Main Menu", 12, 20, 240, 17)
  365.         $lblStatus = GUICtrlCreateLabel("Status: ", 12, 35, 240, 17)
  366.         $lblLast = GUICtrlCreateLabel("Last Runtime: 0 seconds", 12, 50, 240, 17)
  367.         $lblRuntime = GUICtrlCreateLabel("Total Runtime: 0 hours, 0 minutes", 12, 65, 240, 17)
  368.         $lblGear = GUICtrlCreateLabel("Legendary: 0 - Set: 0 - Rare: 0", 12, 80, 240, 17)
  369.         $lblItems = GUICtrlCreateLabel("Magic: 0 - Gems: 0 - Tomes: 0", 12, 95, 240, 17)
  370.         GUISetState(@SW_SHOW)
  371. EndFunc   ;==>SetupGUI
  372.  
  373. Func CheckDead()
  374.         $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
  375.         If Not @error Then
  376.                 GUICtrlSetData($lblStatus, "Status: Logging out")
  377.                 Sleep(11000)
  378.                 Sleep($loadtime)
  379.                 Return 1
  380.         EndIf
  381.  
  382.         $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"
  383.         If Not @error Then
  384.                 GUICtrlSetData($lblStatus, "Status: Dead")
  385.                 Call("LeaveGame")
  386.                 Sleep(11000)
  387.                 Sleep($loadtime)
  388.                 Return 1
  389.         Else
  390.                 Return 0
  391.         EndIf
  392. EndFunc   ;==>CheckDead
  393.  
  394. Func CheckRepair()
  395.         $RepairArea = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $yellow)
  396.         If Not @error Then
  397.                 Call("DoRepair")
  398.         EndIf
  399.         $RepairAreaRed = PixelSearch(Round(1480 * $x_ratio), 0, Round(1570 * $x_ratio), Round(100 * $y_ratio), $red)
  400.         If Not @error Then
  401.                 Call("DoRepair")
  402.         EndIf
  403. EndFunc   ;==>CheckRepair
  404.  
  405. Func DoRepair()
  406.         Sleep(Random(75, 150))
  407.         Call("TownPortal")
  408.         If Call("CheckDead") Then
  409.                 Return
  410.         EndIf
  411.         If CheckFor("NewTristram", "Area", 1500 * $x_ratio, 0 * $y_ratio, 1920 * $x_ratio, 80 * $y_ratio, 6, 180) Then
  412.                 RandClick("left", Round(1480 * $x_ratio), Round(281 * $y_ratio), 1, 1) ;begin movement towards merchant
  413.                 Moving(1875)
  414.                 RandClick("left", Round(1316 * $x_ratio), Round(206 * $y_ratio), 1, 1) ;moves to get merchant in screen
  415.                 Moving(1875)
  416.                 RandClick("left", Round(845 * $x_ratio), Round(225 * $y_ratio), 1, 1) ;NPC Merchant to the right of cain's home
  417.                 Sleep(1200)
  418.                 RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  419.                 Sleep(400)
  420.                 RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  421.                 Sleep(Random(1000, 2000))
  422.                 Send("{Escape}")
  423.                 If Not Call("CheckDead") Then
  424.                         Call("LeaveGame")
  425.                 EndIf
  426.         EndIf
  427. EndFunc   ;==>DoRepair
  428.  
  429. Func CalcTime()
  430.         $srt = TimerDiff($rt)
  431.         GUICtrlSetData($lblLast, "Last Runtime: " & Round($srt / 1000, 2) & " seconds.")
  432.         $trt = TimerDiff($t)
  433.         $total = Round((($trt / 1000) / 60) / 60, 4)
  434.  
  435.         ;Total runtime calculation.
  436.         $hours = Floor((($trt / 1000) / 60) / 60)
  437.         $minutes = (($trt / 1000) / 60)
  438.         ;trim minutes if runtime is more then 1 hour.
  439.         If $minutes > 60 Then
  440.                 While $minutes > 60
  441.                         $minutes -= 60
  442.                 WEnd
  443.         EndIf
  444.         GUICtrlSetData($lblRuntime, "Total Runtime: " & $hours & " hours, " & Ceiling($minutes) & " minutes")
  445. EndFunc   ;==>CalcTime
  446.  
  447. Func CheckFor($img, $type = "", $startX = 0, $startY = 0, $endX = @DesktopWidth, $endY = @DesktopHeight, $seconds = 5, $tolerance = 130)
  448.         $c = 0
  449.         $string = $pngLoc & $img & ".png"
  450.         Do
  451.                 $c += 1
  452.                 Sleep(100)
  453.                 If $c > ($seconds * 10) Then ;Make sure we never get stuck here for infinity.
  454.                         If $type = "Area" Then
  455.                                 GUICtrlSetData($lblStatus, "Status: Area not found - " & $img)
  456.                         EndIf
  457.                         Return False
  458.                 EndIf
  459.         Until _ImageSearchArea($string, 1, $startX, $startY, $endX, $endY, $gX, $gY, $tolerance)
  460.         Return True
  461. EndFunc   ;==>CheckFor
  462.  
  463. Func Loot()
  464.         Sleep(Random(500, 2000))
  465.         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  466.         If $LootSets == "True" Then
  467.                 $SetCount += LootGear(0x02CE01, 2)
  468.         EndIf
  469.         If $LootLegendaries == "True" Then
  470.                 $LegendaryCount += LootGear(0xBF642F, 0)
  471.         EndIf
  472.         If $LootRares == "True" Then
  473.                 $RareCount += LootGear(0xBBBB00, 2)
  474.         EndIf
  475.         If $LootGems == "True" Then
  476.                 Call("LootGems")
  477.         EndIf
  478.         If $LootTomes == "True" Then
  479.                 Call("LootTomes")
  480.         EndIf
  481.         If $LootCustom == "True" Then
  482.                 Call("LootCustom")
  483.         EndIf
  484.         If $LootMagic == "True" Then
  485.                 $MagicCount += LootGear(0x6969FF, 2)
  486.         EndIf
  487.         Call("ShowLoot")
  488. EndFunc   ;==>Loot
  489.  
  490. Func LootGear($color, $tolerance = 2)
  491.         $count = 0
  492.         $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  493.         If Not @error Then
  494.                 While Not @error
  495.                         $count += 1
  496.                         MouseClick('left', $Loot[0], $Loot[1], 1, 3)
  497.                         Sleep(Random(800, 1200))
  498.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  499.                         ;Run at max 10 times per quality
  500.                         If $count >= 10 Then
  501.                                 ExitLoop
  502.                         EndIf
  503.                         $Loot = PixelSearch(Round(400 * $x_ratio), 0, Round(1690 * $x_ratio), Round(900 * $y_ratio), $color, $tolerance)
  504.                 WEnd
  505.         EndIf
  506.         Return $count
  507. EndFunc   ;==>LootGear
  508.  
  509. Func LootCustom()
  510.         $count = 0
  511.         $gX = 0
  512.         $gY = 0
  513.         For $i = 0 To ($totalItems - 1)
  514.                 $array = StringSplit($pick[$i], "|")
  515.                 $file = $array[1]
  516.                 $accuracy = $array[2]
  517.                 $urlString = $pngLoc & $file
  518.                 While _ImageSearchArea($pngLoc & $file, 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, $accuracy)
  519.                         $count += 1
  520.                         Sleep(Random(75, 150))
  521.                         MouseClick("left", $gX, $gY, 1, 1)
  522.                         Sleep(Random(800, 1200))
  523.                         MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  524.                         If $count >= 10 Then
  525.                                 ExitLoop
  526.                         EndIf
  527.                 WEnd
  528.         Next
  529. EndFunc   ;==>LootCustom
  530.  
  531. Func LootGems()
  532.         $count = 0
  533.         $gX = 0
  534.         $gY = 0
  535.         While _ImageSearchArea($pngLoc & "square.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  536.                 $count += 1
  537.                 Sleep(Random(75, 150))
  538.                 MouseClick("left", $gX, $gY - 3, 1, 3)
  539.                 $GemCount += 1
  540.                 Sleep(Random(800, 1200))
  541.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  542.                 If $count >= 10 Then
  543.                         ExitLoop
  544.                 EndIf
  545.         WEnd
  546. EndFunc   ;==>LootGems
  547.  
  548. Func LootTomes()
  549.         $count = 0
  550.         $gX = 0
  551.         $gY = 0
  552.         While _ImageSearchArea($pngLoc & "tome.png", 1, 0, 0, @DesktopWidth, @DesktopHeight, $gX, $gY, 90)
  553.                 $count += 1
  554.                 Sleep(Random(75, 150))
  555.                 MouseClick("left", $gX, $gY - 3, 1, 3)
  556.                 $TomeCount += 1
  557.                 Sleep(Random(800, 1200))
  558.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  559.                 If $count >= 10 Then
  560.                         ExitLoop
  561.                 EndIf
  562.         WEnd
  563. EndFunc   ;==>LootTomes
  564.  
  565. Func Identify()
  566.         Send("i")
  567.         Sleep(1300)
  568.         While _ImageSearchArea($pngLoc & "unidentified.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 120)
  569.                 GUICtrlSetData($lblStatus, "Status: Identifying")
  570.                 Sleep(Random(200, 300))
  571.                 MouseClick("right", $gX, $gY, 1)
  572.                 MouseMove(Round(Random(0, 400) * $x_ratio), Round(Random(700, 1080) * $y_ratio), 3) ;Moves mouse out of the way
  573.                 Sleep(Random(3000, 3500))
  574.         WEnd
  575.         Send("i")
  576.         Sleep(600)
  577. EndFunc   ;==>Identify
  578.  
  579. Func ClickTab($Tabno)
  580.         if $Tabno = 1 then RandClick("left", Round(517 * $x_ratio), Round(229 * $y_ratio), 3, 4)
  581.         if $Tabno = 2 then RandClick("left", Round(517 * $x_ratio), Round(361 * $y_ratio), 3, 4)
  582.         if $Tabno = 3 then RandClick("left", Round(517 * $x_ratio), Round(486 * $y_ratio), 3, 4)
  583.         Sleep(Random(100, 200))
  584.  
  585. EndFunc   ;==>ClickTab
  586.  
  587. Func UseNextTab()
  588.         if $ItemTab = $NextItemTab then
  589.                 $StashLegendary = "False"
  590.                 $StashRare = "False"
  591.                 $StashMagic = "False"
  592.         Else
  593.                 $ItemTab = $NextItemTab
  594.         EndIf
  595. EndFunc   ;==>UseNextTab
  596.  
  597. Func StashLoot()
  598.         GUICtrlSetData($lblStatus, "Status: Putting Items in Stash")
  599.         Sleep(Random(1000, 1500))
  600.         MouseClick("left", 1064 * $x_ratio, 256 * $y_ratio)
  601.         Sleep(Random(1500, 2000))
  602.  
  603.         ;Legendaries
  604.         If $StashLegendary == "True" then
  605.                 ClickTab($ItemTab)
  606.                 $sc = 0
  607.                 While $sc < 5
  608.                         Sleep(Random(200, 300))
  609.                         $LegendPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, 0x4D2C0D, 1)
  610.                         If Not @error Then
  611.                                 GUICtrlSetData($lblStatus, "Status: Stashing Legendaries")
  612.                                 MouseClick("right", $LegendPixel[0], $LegendPixel[1], 1, 4)
  613.                         Else
  614.                                 ExitLoop
  615.                         EndIf
  616.                         $sc += 1
  617.                 WEnd
  618.                 if $sc = 5 then
  619.                         Call("UseNextTab")
  620.                 endif
  621.         EndIf
  622.  
  623.         ;Rares
  624.         if $StashRare == "True" then
  625.                 ClickTab($ItemTab)
  626.                 $sc = 0
  627.                 While $sc < 10
  628.                         Sleep(Random(200, 300))
  629.                         $RarePixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, 0x4A3C0B, 1)
  630.                         If Not @error Then
  631.                                 GUICtrlSetData($lblStatus, "Status: Stashing Rares")
  632.                                 MouseClick("right", $RarePixel[0], $RarePixel[1], 1, 4)
  633.                         Else
  634.                                 ExitLoop
  635.                         EndIf
  636.                         $sc += 1
  637.                 WEnd
  638.                 if $sc = 10 then
  639.                         Call("UseNextTab")
  640.                 endif
  641.         EndIf
  642.        
  643.         ;Magic
  644.         if $StashMagic == "True" then
  645.                 ClickTab($ItemTab)
  646.                 $sc = 0
  647.                 While $sc < 20
  648.                         Sleep(Random(100, 300))
  649.                         $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, 0x182037, 1)
  650.                         If Not @error Then
  651.                                 GUICtrlSetData($lblStatus, "Status: Stashing Magic")
  652.                                 MouseClick("right", $MagicPixel[0], $MagicPixel[1], 1, 4)
  653.                         Else
  654.                                 ExitLoop
  655.                         EndIf
  656.                         $sc += 1
  657.                 WEnd
  658.                 if $sc = 20 then
  659.                         Call("UseNextTab")
  660.                 endif
  661.         EndIf
  662.  
  663.         ;Tomes
  664.         If $StashTomes == "True" Then
  665.                 If _ImageSearchArea($pngLoc & "TomeIcon.png", 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, $gX, $gY, 140) Then
  666.                         GUICtrlSetData($lblStatus, "Status: Stashing Tomes")
  667.                                                 ClickTab($GemTab)
  668.                         MouseClick("right", $gX, $gY, 1, 4)
  669.                         Sleep(80)
  670.                 EndIf
  671.         EndIf
  672.  
  673.         ;Gems (DOESN'T STASH BOTTOM ROW!)
  674.         if $StashGems == "True" Then
  675.                 ClickTab($GemTab)
  676.                 GUICtrlSetData($lblStatus, "Status: Stashing Gems")
  677.                 For $i = 0 To 7
  678.                         If _ImageSearchArea($pngLoc & $gems[$i], 1, 1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 820 * $y_ratio, $gX, $gY, 140) Then
  679.  
  680.                                 MouseClick("right", $gX, $gY, 1, 4)
  681.                                 Sleep(Random(400, 600))
  682.  
  683.                         EndIf  
  684.                 Next
  685.         EndIf
  686.         Sleep(Random(1000, 3000))
  687.         Send("{SPACE}")
  688. EndFunc   ;==>StashLoot
  689.  
  690. Func VendorLoot()
  691.         GUICtrlSetData($lblStatus, "Status: Vendoring Items")
  692.         If Not $StashLoot == "True" Then ;Move from TP towards vendor
  693.                 Sleep(Random(300, 500))
  694.                 MouseClick("middle", 1565 * $x_ratio, 50 * $y_ratio)
  695.         Else ;Move from Stash towards vendor
  696.                 Sleep(Random(300, 500))
  697.                 MouseClick("middle", 1560 * $x_ratio, 120 * $y_ratio)
  698.         EndIf
  699.         Sleep(3000)
  700.         MouseClick("left", 1030 * $x_ratio, 210 * $y_ratio) ;Talk to vendor
  701.         Sleep(3000)
  702.  
  703.         ;All
  704.         If $vendorAll == "True" Then
  705.                 For $c = 1 To $vendorCols
  706.                         For $r = 1 To $vendorRows
  707.                                 RandClick("right", (((($c - 1) * 50) + 32 + 1400) * $x_ratio), (((($r - 1) * 51) + 32 + 580) * $y_ratio), 2, 2, 1, 2.5)
  708.                         Next
  709.                 Next
  710.         EndIf
  711.  
  712.         ;Rares
  713.         If $VendorRare == "True" Then
  714.                 $c = 0
  715.                 While $c <= 10
  716.                         Sleep(Random(100, 300))
  717.                         $RarePixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, 0x4A3C0B, 1)
  718.                         If Not @error Then
  719.                                 MouseClick("right", $RarePixel[0], $RarePixel[1], 1, 4)
  720.                                 Sleep(Random(400, 600))
  721.                                 $c += 1
  722.                         Else
  723.                                 ExitLoop
  724.                         EndIf
  725.                 WEnd
  726.         EndIf
  727.  
  728.         ;Magic
  729.         If $VendorMagic == "True" Then
  730.                 $c = 0
  731.                 While $c <= 25
  732.                         Sleep(Random(100, 300))
  733.                         $MagicPixel = PixelSearch(1400 * $x_ratio, 580 * $y_ratio, 1914 * $x_ratio, 888 * $y_ratio, 0x182037, 1)
  734.                         If Not @error Then
  735.                                 MouseClick("right", $MagicPixel[0], $MagicPixel[1], 1, 4)
  736.                                 Sleep(Random(400, 600))
  737.                                 $c += 1
  738.                         Else
  739.                                 ExitLoop
  740.                         EndIf
  741.                 WEnd
  742.         EndIf
  743.  
  744.         Sleep(200)
  745.         RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
  746.         Sleep(300)
  747.         RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
  748.         Sleep(200)
  749.         Sleep(Random(1000, 2000))
  750.         GUICtrlSetData($lblStatus, "Status: Done With Vendor")
  751.         Send("{ESCAPE}")
  752. EndFunc   ;==>VendorLoot
  753.  
  754. Func DoUpdate()
  755.         $ini = InetGet($VersionsInfo, @ScriptDir & "\version.ini") ;download version.ini
  756.         If $ini = 0 Then ;was the download of version.ini successful?
  757.                 MsgBox(16, "Fatal Error", "The server seems to be offline. No update will be done.")
  758.         Else
  759.                 $newVersion = IniRead(@ScriptDir & "\version.ini", "Version", "Version", "") ;reads the new version out of version.ini
  760.                 If $newVersion = $oldVersion Then ;compare old and new
  761.                         ;MsgBox (0,"No update","There is no update available!")
  762.                         FileDelete(@ScriptDir & "\version.ini")
  763.                 Else
  764.                         $msg = MsgBox(68, "Update", "A new version is available: " & $newVersion & "! Current version: " & $oldVersion & @CRLF & "Do you want to download the new version?")
  765.                         If $msg = 7 Then ;No was pressed
  766.                                 FileDelete(@ScriptDir & "\version.ini")
  767.                         ElseIf $msg = 6 Then ;OK was pressed
  768.                                 $downloadLink = IniRead(@ScriptDir & "\version.ini", "Version", "download", "NotFound")
  769.                                 $dlhandle = InetGet($downloadLink, @ScriptDir & "\Update_" & $newVersion & ".zip", 1, 1)
  770.                                 ProgressOn("Update", "Downloading Updates", "", -1, -1, 16) ;creates a progressbar
  771.  
  772.                                 $size = InetGetSize($downloadLink, 1) ;get the size of the update
  773.                                 While Not InetGetInfo($dlhandle, 2)
  774.                                         $Percent = Round((InetGetInfo($dlhandle, 0) / $size) * 100)
  775.                                         ProgressSet($Percent, $Percent & "%") ;update progressbar
  776.                                         Sleep(1)
  777.                                 WEnd
  778.                                 ProgressSet(100, "Done", "Complete") ;show complete progressbar
  779.                                 Sleep(500)
  780.                                 ProgressOff() ;close progress window
  781.                                 IniWrite("updater.ini", "version", "version", $newVersion)
  782.                                 InetClose($dlhandle)
  783.                                 $iniMsg = IniRead(@ScriptDir & "\version.ini", "Version", "message", "Exiting...")
  784.                                 MsgBox(64, "Success", "Download Complete!" & @CRLF & "Please restart the bot by extracting the Au3 from Update_" & $newVersion & ".zip" & @CRLF & $iniMsg)
  785.                                 FileDelete(@ScriptDir & "\version.ini")
  786.                                 Exit
  787.                         EndIf
  788.                 EndIf
  789.         EndIf
  790.         WinSetTitle($title, "", $title & $ver & " - Waiting")
  791. EndFunc   ;==>DoUpdate
  792. Func ReadINI()
  793.         $pngLoc = IniRead($ini, "Custom Loot", "PNG Location", $pngLoc)
  794.         $totalItems = IniRead($ini, "Custom Loot", "Total Items", $totalItems)
  795.         $movementSpeed = IniRead($ini, "Additional", "Movement Speed", $movementSpeed)
  796.         $walktime = IniRead($ini, "Additional", "Walk Time", $walktime)
  797.         $loadtime = IniRead($ini, "Additional", "Load Time", $loadtime)
  798.         $tptime = IniRead($ini, "Additional", "Teleport Time", $tptime)
  799.         $LootSets = IniRead($ini, "Looting", "Sets", $LootSets)
  800.         $LootLegendaries = IniRead($ini, "Looting", "Legendaries", $LootLegendaries)
  801.         $LootRares = IniRead($ini, "Looting", "Rares", $LootRares)
  802.         $LootMagic = IniRead($ini, "Looting", "Magic", $LootMagic)
  803.         $LootGems = IniRead($ini, "Looting", "Gems", $LootGems)
  804.         $LootTomes = IniRead($ini, "Looting", "Tomes", $LootTomes)
  805.         $LootCustom = IniRead($ini, "Looting", "Custom", $LootCustom)
  806.         $mLoot = IniRead($ini, "ManageLoot", "Every", $mLoot)
  807.         $StashLoot = IniRead($ini, "Stashing", "Loot", $StashLoot)
  808.         $StashLegendary = IniRead($ini, "Stashing", "Legendaries", $StashLegendary)
  809.         $StashRare = IniRead($ini, "Stashing", "Rares", $StashRare)
  810.         $StashMagic = IniRead($ini, "Stashing", "Magic", $StashMagic)
  811.         $StashTomes = IniRead($ini, "Stashing", "Tomes", $StashTomes)
  812.         $StashGems = IniRead($ini, "Stashing", "Gems", $StashGems)
  813.         $VendorLoot = IniRead($ini, "Vendoring", "Loot", $VendorLoot)
  814.         $VendorRare = IniRead($ini, "Vendoring", "Rares", $VendorRare)
  815.         $VendorMagic = IniRead($ini, "Vendoring", "Magic", $VendorMagic)
  816.         $vendorAll = IniRead($ini, "Vendoring", "All", $vendorAll)
  817.         $vendorRows = IniRead($ini, "Vendoring", "All-Rows", $vendorRows)
  818.         $vendorCols = IniRead($ini, "Vendoring", "All-Cols", $vendorCols)
  819.         $Timer = IniRead($ini, "Variability", "Timer", $Timer)
  820.         $mLootOff = IniRead($ini, "Variability", "Manage Off By", $mLootOff)
  821. EndFunc   ;==>ReadINI
  822. Func CreateINI()
  823.         IniWrite($ini, "Custom Loot", "PNG Location", $pngLoc)
  824.         IniWrite($ini, "Custom Loot", "Total Items", $totalItems)
  825.         IniWrite($ini, "Additional", "Movement Speed", $movementSpeed)
  826.         IniWrite($ini, "Additional", "Walk Time", $walktime)
  827.         IniWrite($ini, "Additional", "Load Time", $loadtime)
  828.         IniWrite($ini, "Additional", "Teleport Time", $tptime)
  829.         IniWrite($ini, "Looting", "Sets", $LootSets)
  830.         IniWrite($ini, "Looting", "Legendaries", $LootLegendaries)
  831.         IniWrite($ini, "Looting", "Rares", $LootRares)
  832.         IniWrite($ini, "Looting", "Magic", $LootMagic)
  833.         IniWrite($ini, "Looting", "Gems", $LootGems)
  834.         IniWrite($ini, "Looting", "Tomes", $LootTomes)
  835.         IniWrite($ini, "Looting", "Custom", $LootCustom)
  836.         IniWrite($ini, "ManageLoot", "Every", $mLoot)
  837.         IniWrite($ini, "Stashing", "Loot", $StashLoot)
  838.         IniWrite($ini, "Stashing", "Legendaries", $StashLegendary)
  839.         IniWrite($ini, "Stashing", "Rares", $StashRare)
  840.         IniWrite($ini, "Stashing", "Magic", $StashMagic)
  841.         IniWrite($ini, "Stashing", "Tomes", $StashTomes)
  842.         IniWrite($ini, "Stashing", "Gems", $StashGems)
  843.         IniWrite($ini, "Vendoring", "Loot", $VendorLoot)
  844.         IniWrite($ini, "Vendoring", "Rares", $VendorRare)
  845.         IniWrite($ini, "Vendoring", "Magic", $VendorMagic)
  846.         IniWrite($ini, "Vendoring", "All", $vendorAll)
  847.         IniWrite($ini, "Vendoring", "All-Rows", $vendorRows)
  848.         IniWrite($ini, "Vendoring", "All-Cols", $vendorCols)
  849.         IniWrite($ini, "Variability", "Timer", $Timer)
  850.         IniWrite($ini, "Variability", "Manage Off By", $mLootOff)
  851. EndFunc   ;==>CreateINI
  852.  
  853. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  854.         If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  855.         $findImage = "*TRANSBLACK " & $findImage
  856.         If @AutoItX64 Then
  857.                 $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  858.         Else
  859.                 $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  860.         EndIf
  861.         If $result = "0" Then
  862.                 Return 0
  863.         EndIf
  864.  
  865.         ; Otherwise get the x,y location of the match and the size of the image to
  866.         ; compute the centre of search
  867.         $array = StringSplit($result[0], "|")
  868.         If (UBound($array) >= 4) Then
  869.                 $x = Int(Number($array[2]))
  870.                 $y = Int(Number($array[3]))
  871.                 If $resultPosition = 1 Then
  872.                         $x = $x + Int(Number($array[4]) / 2)
  873.                         $y = $y + Int(Number($array[5]) / 2)
  874.                 EndIf
  875.                 Return 1
  876.         EndIf
  877. EndFunc   ;==>_ImageSearchArea
  878.  
  879. Func LeaveGame()
  880.         Call("RandSleep")
  881.         GUICtrlSetData($lblStatus, "Status: Leaving Game")
  882.         Sleep(120)
  883.         Send("{Escape}")
  884.         Sleep(Random(200, 500))
  885.         RandClick("left", Round(956 * $x_ratio), Round(579 * $y_ratio), 120, 20) ;Random Click on the leave button
  886.         RandMove(Round(Random(10, 230) * $x_ratio), Round(Random(11, 286) * $y_ratio), 120, 20)
  887.         Call("CalcTime")
  888. EndFunc   ;==>LeaveGame
  889.  
  890. Func TownPortal()
  891.         GUICtrlSetData($lblStatus, "Status: Returning to Town")
  892.         Send("t")
  893.         Sleep(Random($tptime, $tptime + 500))
  894. EndFunc   ;==>TownPortal
  895.  
  896. Func Moving($time)
  897.         Sleep($time / $movementSpeed)
  898. EndFunc   ;==>Moving
  899.  
  900. Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
  901.         If $xOff < 1 Then $xOff = 1
  902.         If $yOff < 1 Then $yOff = 1
  903.         $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  904.         $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  905.         MouseClick($clickType, $randX, $randY, $clicks, $speed)
  906. EndFunc   ;==>RandClick
  907.  
  908. Func RandMove($xPos, $yPos, $xOff = 20, $yOff = 10)
  909.         $randX = Round(Random($xPos - ($xOff * $x_ratio), $xPos + ($xOff * $x_ratio)))
  910.         $randY = Round(Random($yPos - ($yOff * $y_ratio), $yPos + ($yOff * $y_ratio)))
  911.         MouseMove($randX, $randY)
  912. EndFunc   ;==>RandMove
  913.  
  914. Func RandSleep($min = 15, $max = 30, $chance = 3)
  915.         $randNum = Round(Random(1, 100))
  916.         If $Timer == "True" And $randNum <= $chance Then
  917.                 $sleepTime = Random($min * 1000, $max * 1000)
  918.                 GUICtrlSetData($lblStatus, "Status: Random Sleep - " & Round($sleepTime / 1000) & " secs")
  919.  
  920.                 For $c = 0 To 10
  921.                         Sleep($sleepTime / 10)
  922.                 Next
  923.         EndIf
  924. EndFunc   ;==>RandSleep
  925.  
  926. ;Hotkey Functions
  927.  
  928. Func Begin()
  929.         $Go = Not $Go
  930.         If Not $Go Then WinSetTitle($title, "", $title & $ver & " - Halted")
  931. EndFunc   ;==>Begin
  932.  
  933. Func TogglePause()
  934.         $Paused = Not $Paused
  935.         While $Paused
  936.                 Sleep(100)
  937.                 WinSetTitle($title, "", $title & $ver & " - Paused")
  938.                 ToolTip('Script is "Paused"', 0, 0)
  939.         WEnd
  940.         WinSetTitle($title, "", $title & $ver & " - Running")
  941.         ToolTip("")
  942. EndFunc   ;==>TogglePause
  943.  
  944. Func ShowLoot()
  945.         GUICtrlSetData($lblGear, "Legendary: " & $LegendaryCount & " - Set: " & $SetCount & " - Rare: " & $RareCount)
  946.         GUICtrlSetData($lblItems, "Magic: " & $MagicCount & " - Gems: " & $GemCount & " - Tomes: " & $TomeCount)
  947. EndFunc   ;==>ShowLoot
  948.  
  949. Func Stop() ;to allow the script to stop
  950.         Exit
  951. EndFunc   ;==>Stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement