Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.1c_zeenexx

Jun 21st, 2012
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 37.10 KB | None | 0 0
  1. #include <WindowsConstants.au3>
  2. #include <Misc.au3>
  3. #include <WinAPI.au3>
  4. #include <StaticConstants.au3>
  5. #include <GuiListBox.au3>
  6. #include <ScrollBarConstants.au3>
  7. #include <Array.au3>
  8.  
  9. #cs
  10.  
  11.    [Gold/Itemfarming] [AutoIt] Sarkoth Act I Dank Cellar [WD] [Stash, Sell, Repair, +++]
  12.                                     by zEEneXx
  13.                                  
  14.                                   Version: 1.1c
  15.                                
  16.                                  www.ownedcore.com
  17.                  
  18. #ce
  19.  
  20. OnAutoItExitRegister ('OnAutoItExit')
  21. Opt('MouseCoordMode', 2)
  22. Opt('PixelCoordMode', 2)
  23.  
  24. HotKeySet('{PAUSE}', 'Pause')
  25. HotKeySet('{END}', 'Terminate')
  26.  
  27. Global $ImageFiles[8][7]
  28. Global $SoundFiles[6]
  29. Global $PasswordField[2]
  30. Global $ResumeButton[2]
  31. Global $LeaveButton[2]
  32. Global $DisconnectButton[2]
  33. Global $MoveToCellar1[2]
  34. Global $MoveToCellar2[2]
  35. Global $MoveToCellar3[2]
  36. Global $MoveInCellar1[2]
  37. Global $MoveInCellar2[2]
  38. Global $MoveToGoldLoot1a[2]
  39. Global $MoveToGoldLoot1b[2]        
  40. Global $MoveToGoldLoot2[2]         
  41. Global $MoveToGoldLoot3[2] 
  42. Global $MoveToMerchant[2]
  43. Global $MoveToStash1[2]
  44. Global $MoveToStash2[2]
  45. Global $CellarLocation[2]  
  46. Global $MonsterLocation[2]
  47. Global $MerchantLocation[2]
  48. Global $StashLocation[2]
  49. Global $PortalLocation[2]
  50. Global $CharHitBox[4]
  51. Global $LoginButtonSearchArea[4]
  52. Global $ResumeButtonSearchArea[4]
  53. Global $PortalIconSearchArea[4]
  54. Global $CellarNameSearchArea[4]
  55. Global $TownNameSearchArea[4]
  56. Global $MerchStashSearchArea[4]
  57. Global $MonsterSearchArea[4]
  58. Global $LootingArea[4]
  59. Global $FullBagSearchArea[4]
  60. Global $SellItemsArea[4]
  61. Global $FullStashSearchArea[4]
  62. Global $RepairSearchArea[4]
  63. Global $DeathSearchArea[4]
  64. Global $DisconnectSearchArea[4]
  65. Global $StashBag2[2]
  66. Global $StashBag3[2]
  67. Global $RepairButton[2]
  68. Global $AllItemsButton[2]
  69. Global $CellarOffset
  70. Global $CellarPixel
  71. Global $Log
  72. Global $Label
  73. Global $LogList
  74. Global $RuntimeTimer
  75. Global $TimeOutTimer
  76. Global $Paused
  77.  
  78. ;///////////////////////////////////////--CONFIG--////////////////////////////////////////////////////////////////////////////////
  79. ;                                                                                                                               //
  80. ;                                       Important                                                                               //
  81. $ComputerLag        = 0                                         ;Increase this in steps of 400 if you have slow loading times   //
  82. $MoveDelay          = 0                                         ;Increase this in steps of 100 if you have movement issues      //
  83. $LootDelay          = 0                                         ;Increase this in steps of 200 if you have looting issues       //
  84. $ImgDir             = "C:\Program Files (x86)\AutoIt3\pics\"    ;Location of the image folder                                   //
  85. ;                                                                                                                               //
  86. ;                                       Functions                                                                               //
  87. $TimeOut            = 7                                         ;How long the bot waits before timeout (in seconds)             //
  88. $Repair             = True                                      ;Orders the bot to repair when items are damaged                //
  89. $Sell               = True                                      ;Orders the bot to sell magic items when bag is full            //
  90. $UseStash           = True                                      ;Orders the bot to put gems and rare items into the stash       //
  91. $HighGoldRadius     = False                                     ;Set this to true if you have more than +18 gold radius         //
  92. ;                                                                                                                               //
  93. ;                                     Miscellaneous                                                                             //
  94. $Sounds             = True                                      ;Enable pickup sounds                                           //
  95. $SoundsDir          = "C:\Program Files (x86)\AutoIt3\sounds\"  ;Location of the sounds folder                                  //
  96. $ShowLootArea       = True                                      ;Shows lootarea                                                 //
  97. $ShowLog            = True                                      ;Shows log overlay                                              //
  98. $SaveStats          = True                                      ;Saves current statistics to a *.txt file                       //
  99. $SaveLogsPath       = "C:\Program Files (x86)\AutoIt3\logs\"    ;Folder to save the logs and statistics in                      //
  100. ;                                                                                                                               //
  101. ;                                      Relogging                                                                                //                                 
  102. $UseRelogging       = True                                      ;Enable Relogging                                               //
  103. $Password           = "xxxxxxxx"                                ;Your password                                                  //
  104. ;                                                                                                                               //
  105. ;                                                                                                                               //
  106. ;                                        Looting                                                                                //
  107. $LootLegendaries    = True                                      ;Loot legendary items                                           //
  108. $LootSets           = True                                      ;Loot set items                                                 //
  109. $LootRares          = True                                      ;Loot rare items                                                //
  110. $LootMagics         = True                                      ;Loot magic items (includes tomes)                              //
  111. $LootTomes          = True                                      ;Loot tomes                                                     //
  112. $LootGems           = True                                      ;Loot gems                                                      //
  113. ;                                                                                                                               //
  114. ;      <<<Changes below have an significant impact on the needed time for one run>>>                                            //
  115. ;                                                                                                                               //
  116. $RareLootAmount     = 1                                         ;Amount of rare items to loot                                   //
  117. $MagicLootAmount    = 3                                         ;Amount of magic items to loot (including tomes)                //
  118. $TomeLootAmount     = 1                                         ;Amount of tomes to loot                                        //
  119. $GemLootAmount      = 2                                         ;Amount of gems to loot                                         //
  120. ;                                                                                                                               //
  121. $LootingArea[0]     = 570                                       ;Left   (lower -> bigger)                                       //
  122. $LootingArea[1]     = 185                                       ;Top    (lower -> bigger)                                       //
  123. $LootingArea[2]     = 1375                                      ;Right  (higher -> bigger)                                      //
  124. $LootingArea[3]     = 720                                       ;Bot    (higher -> bigger)                                      //
  125. ;                                                                                                                               //
  126. ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  127.  
  128. $ImageFiles[0][0]           = "legendaryA.png|60"
  129. $ImageFiles[0][1]           = "legendaryE.png|60"
  130. $ImageFiles[0][2]           = "legendaryI.png|60"
  131. $ImageFiles[0][3]           = "legendaryO.png|60"
  132. $ImageFiles[0][4]           = "legendaryU.png|60"
  133. $ImageFiles[1][0]           = "setA.png|90"
  134. $ImageFiles[1][1]           = "setE.png|90"
  135. $ImageFiles[1][2]           = "setU.png|90"
  136. $ImageFiles[1][3]           = "setO.png|90"
  137. $ImageFiles[1][4]           = "setI.png|90"
  138. $ImageFiles[2][0]           = "rareA.png|102"
  139. $ImageFiles[2][1]           = "rareE.png|102"
  140. $ImageFiles[2][2]           = "rareI.png|102"
  141. $ImageFiles[2][3]           = "rareO.png|102"
  142. $ImageFiles[2][4]           = "rareU.png|102"
  143. $ImageFiles[3][0]           = "blueA.png|70"
  144. $ImageFiles[3][1]           = "blueE.png|70"
  145. $ImageFiles[3][2]           = "blueI.png|70"
  146. $ImageFiles[3][3]           = "blueO.png|70"
  147. $ImageFiles[3][4]           = "blueU.png|70"
  148. $ImageFiles[4][0]           = "tome.png|140"
  149. $ImageFiles[4][1]           = "uare.png|110"
  150. $ImageFiles[5][0]           = "you.png|100"
  151. $ImageFiles[5][1]           = "sellNew.png|55"
  152. $ImageFiles[5][2]           = "sell1x1.png|40"
  153. $ImageFiles[5][3]           = "sell1x2.png|40"
  154. $ImageFiles[5][4]           = "not.png|120"
  155. $ImageFiles[6][0]           = "network.png|10"
  156. $ImageFiles[6][1]           = "lost.png|10"
  157. $ImageFiles[7][0]           = "dank.png|120"
  158. $ImageFiles[7][1]           = "new.png|120"
  159. $ImageFiles[7][2]           = "game.png|20"
  160. $ImageFiles[7][3]           = "portal.png|120"
  161. $ImageFiles[7][4]           = "login.png|5"
  162. $ImageFiles[7][5]           = "merchant.png|20"
  163. $ImageFiles[7][6]           = "stash.png|20"
  164.  
  165. $SoundFiles[0]              = "legendary.wav"
  166. $SoundFiles[1]              = "set.wav"
  167. $SoundFiles[2]              = "rare.wav"
  168. $SoundFiles[3]              = "magic.wav"
  169. $SoundFiles[4]              = "tome.wav"
  170. $SoundFiles[5]              = "gem.wav"
  171.  
  172. $CharHitBox[0]              = 790
  173. $CharHitBox[1]              = 315
  174. $CharHitBox[2]              = 1200
  175. $CharHitBox[3]              = 730
  176.  
  177. $LoginButtonSearchArea[0]   = 930
  178. $LoginButtonSearchArea[1]   = 845
  179. $LoginButtonSearchArea[2]   = 985
  180. $LoginButtonSearchArea[3]   = 860
  181.  
  182. $ResumeButtonSearchArea[0]  = 250
  183. $ResumeButtonSearchArea[1]  = 410
  184. $ResumeButtonSearchArea[2]  = 310
  185. $ResumeButtonSearchArea[3]  = 425
  186.  
  187. $PortalIconSearchArea[0]    = 1095
  188. $PortalIconSearchArea[1]    = 1000
  189. $PortalIconSearchArea[2]    = 1140
  190. $PortalIconSearchArea[3]    = 1060
  191.  
  192. $CellarNameSearchArea[0]    = 1760
  193. $CellarNameSearchArea[1]    = 10
  194. $CellarNameSearchArea[2]    = 1820
  195. $CellarNameSearchArea[3]    = 30
  196.  
  197. $TownNameSearchArea[0]      = 1745
  198. $TownNameSearchArea[1]      = 10
  199. $TownNameSearchArea[2]      = 1795
  200. $TownNameSearchArea[3]      = 30
  201.  
  202. $MerchStashSearchArea[0]    = 225
  203. $MerchStashSearchArea[1]    = 30
  204. $MerchStashSearchArea[2]    = 300
  205. $MerchStashSearchArea[3]    = 115
  206.  
  207. $MonsterSearchArea[0]       = 170
  208. $MonsterSearchArea[1]       = 65
  209. $MonsterSearchArea[2]       = 1270
  210. $MonsterSearchArea[3]       = 470
  211.  
  212. $FullBagSearchArea[0]       = 795
  213. $FullBagSearchArea[1]       = 125
  214. $FullBagSearchArea[2]       = 830
  215. $FullBagSearchArea[3]       = 160
  216.  
  217. $SellItemsArea[0]           = 1460
  218. $SellItemsArea[1]           = 585
  219. $SellItemsArea[2]           = 1900
  220. $SellItemsArea[3]           = 875
  221.  
  222. $FullStashSearchArea[0]     = 700
  223. $FullStashSearchArea[1]     = 135
  224. $FullStashSearchArea[2]     = 730
  225. $FullStashSearchArea[3]     = 155
  226.  
  227. $RepairSearchArea[0]        = 1507
  228. $RepairSearchArea[1]        = 36
  229. $RepairSearchArea[2]        = 1512
  230. $RepairSearchArea[3]        = 41
  231.  
  232. $DeathSearchArea[0]         = 538
  233. $DeathSearchArea[1]         = 335
  234. $DeathSearchArea[2]         = 542
  235. $DeathSearchArea[3]         = 339
  236.  
  237. $DisconnectSearchArea[0]    = 840
  238. $DisconnectSearchArea[1]    = 410
  239. $DisconnectSearchArea[2]    = 950
  240. $DisconnectSearchArea[3]    = 440
  241.  
  242. $CellarOffset               = 33
  243.  
  244. $RareLootAttempts           = 0
  245. $MagicLootAttempts          = 0
  246. $TomeLootAttempts           = 0
  247. $GemLootAttempts            = 0
  248.  
  249. $StartTime                  = @HOUR & ":" & @MIN
  250. $Runs                       = 0
  251. $Closed                     = 0
  252. $Runtime                    = "0h 0m 0s"
  253. $Disconnects                = 0
  254. $Deaths                     = 0
  255.  
  256. $Legendaries                = 0
  257. $Sets                       = 0
  258. $Rares                      = 0
  259. $Magics                     = 0
  260. $Gems                       = 0
  261. $Tomes                      = 0
  262. $Sold                       = 0
  263.  
  264. $ISx                        = 0
  265. $ISy                        = 0
  266. $StashBag                   = 1
  267. $Alive                      = True
  268. $DisconnectState            = 0
  269. $FullBag                    = False
  270.  
  271. $LootingAreaWidth           = $LootingArea[2] - $LootingArea[0]
  272. $LootingAreaHeight          = $LootingArea[3] - $LootingArea[1]
  273.  
  274. ScriptStarted()
  275. Bot()
  276.  
  277. Func Bot()
  278.    While WinActive('Diablo III')
  279.       Randomize()
  280.       ResumeGame()
  281.       MoveToCellar()
  282.       EnterCellar()
  283.       MoveInCellar()
  284.       UseSkills()
  285.       KillSarkoth()
  286.       LootGold()
  287.       LootItems()
  288.       TeleportToTown()
  289.      
  290.       If $Repair Then
  291.          RepairItems()
  292.       EndIf
  293.      
  294.       LeaveGame()
  295.    WEnd
  296. EndFunc
  297.  
  298.  
  299. ;Routine
  300. Func ResumeGame()
  301.    InGameLobby()
  302.    
  303.    ToLog("Resuming game...")
  304.    MouseClick('LEFT', $ResumeButton[0], $ResumeButton[1], 1, 5)
  305.    
  306.    InGameplayScreen()
  307. EndFunc
  308.  
  309. Func MoveToCellar()
  310.    ToLog("Starting run...")
  311.    $Runs+=1
  312.    RefreshStats()
  313.    
  314.    Sleep(200 + $Computerlag)
  315.    Send("{2}")
  316.    Sleep(200 + $Computerlag)
  317.    
  318.    ToLog("Moving to cellar - 1")
  319.    Move($MoveToCellar1[0], $MoveToCellar1[1])
  320.    Sleep(1400 + $MoveDelay)
  321.    
  322.    Send("{4}")
  323.    Sleep(500)
  324.    
  325.    ToLog("Moving to cellar - 2")
  326.    Move($MoveToCellar2[0], $MoveToCellar2[1])
  327.    Sleep(2150 + $MoveDelay)
  328.    
  329.    ToLog("Moving to cellar - 3")
  330.    Move($MoveToCellar3[0], $MoveToCellar3[1])
  331.    Sleep(1250 + $MoveDelay)
  332. EndFunc
  333.  
  334. Func EnterCellar()
  335.    MouseMove($CellarLocation[0], $CellarLocation[1], 5)
  336.    Sleep(400 + $ComputerLag)
  337.    
  338.    $CellarPixel = PixelSearch($CellarLocation[0]-$CellarOffset, $CellarLocation[1]-$CellarOffset, $CellarLocation[0]+4, $CellarLocation[1]+4, 0x334FB7, 6)
  339.    If @error Then
  340.       ToLog("Cellar is closed")
  341.       $Closed+=1
  342.       RefreshStats()
  343.       TeleportToTown()
  344.       LeaveGame()
  345.    EndIf
  346.    
  347.    ToLog("Entering cellar...")
  348.    MouseClick('LEFT', $CellarLocation[0], $CellarLocation[1], 1, 5)
  349.    InCellar()
  350. EndFunc
  351.  
  352. Func MoveInCellar()
  353.    ToLog("Moving in cellar - 1")
  354.    Move($MoveInCellar1[0], $MoveInCellar1[1])
  355.    Sleep(2250 + $MoveDelay)
  356.    
  357.    ToLog("Moving in cellar - 2")
  358.    Move($MoveInCellar2[0], $MoveInCellar2[1])
  359.    Sleep(1260 + $MoveDelay)
  360.    
  361.    MouseMove($MonsterLocation[0],$MonsterLocation[1], 5)
  362.    Sleep(150 + $Computerlag)
  363. EndFunc
  364.    
  365. Func UseSkills()
  366.    ToLog("Using skills...")
  367.    Send("{1}")
  368.    Sleep(400 + $Computerlag)
  369.    
  370.    Send("{3}")
  371.    Sleep(400 + $Computerlag)
  372.    
  373.    MouseClick('RIGHT')
  374.    Sleep(250 + $Computerlag)
  375. EndFunc
  376.    
  377. Func KillSarkoth()
  378.    ToLog("Kill Sarkoth...")
  379.    While 1
  380.       $MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  381.       If @error Then
  382.          Attack($MonsterLocation[0],$MonsterLocation[1])
  383.          Sleep(850)
  384.          
  385.          $MonsterBar =  PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  386.          If @error Then
  387.             ExitLoop
  388.          EndIf
  389.       EndIf
  390.      
  391.       Attack($MonsterBar[0], $MonsterBar[1])
  392.       Sleep(100)
  393.    WEnd
  394.    ToLog("All monsters are dead")
  395. EndFunc
  396.  
  397. Func LootGold()
  398.    ToLog("Looting gold...")
  399.    If $HighGoldRadius = False Then
  400.       Move($MoveToGoldLoot1a[0], $MoveToGoldLoot1a[1])
  401.       Sleep(1500 + $MoveDelay)
  402.       AttackNearbyMonsters()
  403.      
  404.       Move($MoveToGoldLoot2[0], $MoveToGoldLoot2[1])
  405.       Sleep(1500 + $MoveDelay)
  406.       AttackNearbyMonsters()
  407.      
  408.       Move($MoveToGoldLoot3[0], $MoveToGoldLoot3[1])
  409.       Sleep(1500 + $MoveDelay)
  410.       AttackNearbyMonsters()
  411.    Else
  412.       Move($MoveToGoldLoot1b[0], $MoveToGoldLoot1b[1])
  413.       Sleep(1500 + $MoveDelay)
  414.       AttackNearbyMonsters()
  415.    EndIf
  416.    
  417.    MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  418.    Sleep(100)
  419. EndFunc
  420.  
  421. Func LootItems()
  422.    If $LootSets Then
  423.       LootSets()
  424.    EndIf
  425.    
  426.    If $LootLegendaries Then
  427.       LootLegendaries()
  428.    EndIf
  429.    
  430.    If $LootRares Then
  431.       LootRares()
  432.       $RareLootAttempts = 0
  433.    EndIf
  434.    
  435.    If $LootMagics Then
  436.       LootMagics()
  437.       $MagicLootAttempts = 0
  438.    Else
  439.       If $LootTomes Then
  440.          LootTomes()
  441.          $TomesLootAttempts = 0
  442.       EndIf
  443.    EndIf
  444.    
  445.    If $LootGems Then
  446.       LootGems()
  447.       $GemLootAttempts = 0
  448.    EndIf
  449.    
  450.    CheckForDeath()
  451. EndFunc
  452.    
  453. Func TeleportToTown()
  454.    ToLog("Teleporting to town...")
  455.    Sleep(500)
  456.    Send("{t}")
  457.    InTown()
  458. EndFunc
  459.  
  460.  
  461. ;Loot
  462. Func LootLegendaries()
  463.    ToLog("Searching for legendaries...")
  464.    For $gI = 0 to 4
  465.       $Array = StringSplit($ImageFiles[0][$gI],"|")
  466.       $File = $Array[1]
  467.       $Accuracy = $Array[2]
  468.      
  469.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  470.       If $Target = 1 Then
  471.          ToLog("Legendary found")
  472.          $Legendaries+=1
  473.          RefreshStats()
  474.          
  475.          If $Sounds = True Then
  476.             SoundPlay($SoundsDir & $SoundFiles[0], 0)
  477.          EndIf
  478.          
  479.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  480.          Sleep(800 + $LootDelay)
  481.          
  482.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  483.          Sleep(100)
  484.          
  485.          If $Sell = True Then
  486.             CheckBagFull()
  487.             If $FullBag = True Then
  488.                $FullBag = False
  489.                Sleep(300)
  490.                LootLegendaries()
  491.             EndIf
  492.          EndIf
  493.          ExitLoop
  494.       EndIf
  495.    Next
  496. EndFunc
  497.  
  498. Func LootSets()
  499.    ToLog("Searching for sets...")
  500.    For $gI = 0 to 4
  501.       $Array = StringSplit($ImageFiles[1][$gI],"|")
  502.       $File = $Array[1]
  503.       $Accuracy = $Array[2]
  504.      
  505.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  506.       If $Target = 1 Then
  507.          ToLog("Set found")
  508.          $Sets+=1
  509.          RefreshStats()
  510.          
  511.          If $Sounds = True Then
  512.             SoundPlay($SoundsDir & $SoundFiles[1], 0)
  513.          EndIf
  514.          
  515.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  516.          Sleep(800 + $LootDelay)
  517.          
  518.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  519.          Sleep(100)
  520.          
  521.          If $Sell = True Then
  522.             CheckBagFull()
  523.             If $FullBag = True Then
  524.                $FullBag = False
  525.                Sleep(300)
  526.                LootSets()
  527.             EndIf
  528.          EndIf
  529.          ExitLoop
  530.       EndIf
  531.    Next  
  532. EndFunc
  533.  
  534. Func LootRares()
  535.    ToLog("Searching for rares... " & $RareLootAttempts+1)
  536.    For $gI = 0 to 4
  537.       $Array = StringSplit($ImageFiles[2][$gI],"|")
  538.       $File = $Array[1]
  539.       $Accuracy = $Array[2]
  540.      
  541.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  542.       If $Target = 1 Then
  543.          ToLog("Rare found")
  544.          $Rares+=1
  545.          RefreshStats()
  546.          
  547.          If $Sounds = True Then
  548.             SoundPlay($SoundsDir & $SoundFiles[2], 0)
  549.          EndIf
  550.          
  551.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  552.          Sleep(700 + $LootDelay)
  553.          
  554.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  555.          Sleep(100)
  556.          
  557.          If $Sell = True Then
  558.             CheckBagFull()
  559.             If $FullBag = True Then
  560.                $FullBag = False
  561.                Sleep(300)
  562.                LootRares()
  563.             EndIf
  564.          EndIf
  565.          ExitLoop
  566.       EndIf
  567.    Next
  568.    
  569.    $RareLootAttempts+=1    
  570.    
  571.    If($RareLootAttempts >= $RareLootAmount) Then
  572.       Return
  573.    Else
  574.       LootRares()
  575.    EndIf
  576. EndFunc
  577.  
  578. Func LootMagics()
  579.    ToLog("Searching for magics... " & $MagicLootAttempts+1)
  580.    For $gI = 0 to 4
  581.       $Array = StringSplit($ImageFiles[3][$gI],"|")
  582.       $File = $Array[1]
  583.       $Accuracy = $Array[2]
  584.      
  585.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  586.       If $Target = 1 Then
  587.          ToLog("Magic found")
  588.          $Magics+=1
  589.          RefreshStats()
  590.          
  591.          If $Sounds = True Then
  592.             SoundPlay($SoundsDir & $SoundFiles[3], 0)
  593.          EndIf
  594.          
  595.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  596.          Sleep(700 + $LootDelay)
  597.          
  598.          MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  599.          Sleep(100)
  600.          
  601.          If $Sell = True Then
  602.             CheckBagFull()
  603.             If $FullBag = True Then
  604.                $FullBag = False
  605.                Sleep(300)
  606.                LootMagics()
  607.             EndIf
  608.          EndIf
  609.          ExitLoop
  610.       EndIf
  611.    Next
  612.    
  613.    $MagicLootAttempts+=1
  614.    
  615.    If($MagicLootAttempts >= $MagicLootAmount) Then
  616.       Return
  617.    Else
  618.       LootMagics()
  619.    EndIf
  620. EndFunc
  621.  
  622. Func LootTomes()
  623.    ToLog("Searching for Tomes of Secrets... " & $TomeLootAttempts+1)
  624.    $Array = StringSplit($ImageFiles[4][0],"|")
  625.    $File = $Array[1]
  626.    $Accuracy = $Array[2]
  627.    
  628.    $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  629.    If $Target = 1 Then
  630.       ToLog("Tome of Secrets found")
  631.       $Tomes+=1
  632.       RefreshStats()
  633.      
  634.       If $Sounds = True Then
  635.          SoundPlay($SoundsDir & $SoundFiles[4], 0)
  636.       EndIf
  637.      
  638.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  639.       Sleep(700 + $LootDelay)
  640.      
  641.       MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  642.       Sleep(100)
  643.      
  644.       If $Sell = True Then
  645.          CheckBagFull()
  646.          If $FullBag = True Then
  647.             $FullBag = False
  648.             Sleep(300)
  649.             LootTomes()
  650.          EndIf
  651.       EndIf
  652.    EndIf
  653.    
  654.    $TomeLootAttempts+=1
  655.    
  656.    If($TomeLootAttempts >= $TomeLootAmount) Then
  657.       Return
  658.    Else
  659.       LootTomes()
  660.    EndIf
  661. EndFunc
  662.    
  663. Func LootGems()
  664.    ToLog("Searching for gems... " & $GemLootAttempts+1)
  665.    $Array = StringSplit($ImageFiles[4][1],"|")
  666.    $File = $Array[1]
  667.    $Accuracy = $Array[2]
  668.    
  669.    $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  670.    If $Target = 1 Then
  671.       ToLog("Gem found")
  672.       $Gems+=1
  673.       RefreshStats()
  674.      
  675.       If $Sounds = True Then
  676.          SoundPlay($SoundsDir & $SoundFiles[5], 0)
  677.       EndIf
  678.      
  679.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  680.       Sleep(700 + $LootDelay)
  681.      
  682.       MouseMove(Random(100, 140, 1), Random(100, 140, 1), 3)
  683.       Sleep(100)
  684.      
  685.       If $Sell = True Then
  686.          CheckBagFull()
  687.          If $FullBag = True Then
  688.             $FullBag = False
  689.             Sleep(300)
  690.             LootGems()
  691.          EndIf
  692.       EndIf
  693.    EndIf
  694.    
  695.    $GemLootAttempts+=1
  696.    
  697.    If($GemLootAttempts >= $GemLootAmount) Then
  698.       Return
  699.    Else
  700.       LootGems()
  701.    EndIf
  702. EndFunc
  703.  
  704.  
  705. ;Sell, store and repair
  706. Func CheckBagFull()
  707.    $Array = StringSplit($ImageFiles[5][0],"|")
  708.    $File = $Array[1]
  709.    $Accuracy = $Array[2]
  710.    
  711.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullBagSearchArea[0], $FullBagSearchArea[1], $FullBagSearchArea[2], $FullBagSearchArea[3], $ISx, $ISy, $Accuracy)
  712.    If $Target = 1 Then
  713.       ToLog("Our bag is full")
  714.       $FullBag = True
  715.       SellItems()
  716.    EndIf
  717. EndFunc
  718.  
  719. Func SellItems()  
  720.    TeleportToTown()
  721.    MoveToMerchant()
  722.    
  723.    ToLog("Selling...")
  724.    
  725.    $Count = 0
  726.    
  727.    For $gI = 1 to 3
  728.       $Array = StringSplit($ImageFiles[5][$gI],"|")
  729.       $File = $Array[1]
  730.       $Accuracy = $Array[2]
  731.      
  732.       For $i = 30 To 0 step -1
  733.          $Target = _ImageSearchArea($ImgDir & $File, 1, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
  734.          If $Target = 1 Then
  735.             $Count+=1
  736.             $Sold+=1
  737.             RefreshStats()
  738.            
  739.             MouseClick("RIGHT", $ISx, $ISy, 1, 2)
  740.             Sleep(150)
  741.          EndIf
  742.       Next
  743.    Next
  744.    
  745.    ToLog("Selling... done - Sold " & $Count & " items!")
  746.    
  747.    $RareLootAttempts    = 0
  748.    $MagicLootAttempts   = 0
  749.    $TomeLootAttempts    = 0
  750.    $GemLootAttempts     = 0
  751.    
  752.    MoveToStash()
  753.      
  754.    Sleep(300 & $ComputerLag)
  755.    
  756.    MouseClick("LEFT", $PortalLocation[0], $PortalLocation[1], 1, 10)
  757.    InCellar()
  758. EndFunc
  759.  
  760. Func PutInStash()  
  761.    ToLog("Storing items in the stash...")
  762.  
  763.    While UBOUND($Stash) > 0
  764.       $r = Random(0, UBOUND($Stash)-1, 1)
  765.          
  766.       MouseClick("RIGHT", $Stash[$r][0], $Stash[$r][1], 1, 0)
  767.          
  768.       Sleep(75)
  769.       If Not CheckStashFull() = 1 Then
  770.          _ArrayDelete($Stash, $r)
  771.       EndIf
  772.          
  773.       If $UseStash = False Then
  774.          ExitLoop
  775.       EndIf
  776.       $r+=1      
  777.    WEnd
  778.    
  779.    ToLog("Storing items in the stash... done")
  780. EndFunc
  781.  
  782. Func CheckStashFull()
  783.    $Array = StringSplit($ImageFiles[5][4],"|")
  784.    $File = $Array[1]
  785.    $Accuracy = $Array[2]
  786.    
  787.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullStashSearchArea[0], $FullStashSearchArea[1], $FullStashSearchArea[2], $FullStashSearchArea[3], $ISx, $ISy, $Accuracy)
  788.    If $Target = 1 Then
  789.       Switch $StashBag
  790.          Case 1
  791.             ToLog("First stashbag is full - changing...")
  792.             Sleep(200)
  793.             MouseClick("LEFT", $StashBag2[0], $StashBag2[1], 1, 5)
  794.             $StashBag = 2
  795.             Sleep(5000)
  796.          Case 2
  797.             ToLog("Second stashbag is full - changing...")
  798.             Sleep(200)
  799.             MouseClick("LEFT", $StashBag3[0], $StashBag3[1], 1, 5)
  800.             $StashBag = 3
  801.             Sleep(5000)
  802.          Case 3
  803.             ToLog("Third stashbag is full - aborting...")
  804.             $UseStash = False
  805.       EndSwitch
  806.       Return 1
  807.    EndIf
  808.    Return 0
  809. EndFunc
  810.  
  811. Func RepairItems()
  812.    If Not CheckForRepair() Then
  813.       Return
  814.    EndIf
  815.    
  816.    MoveToMerchant()
  817.    
  818.    ToLog("Repairing...")
  819.    MouseClick('LEFT', $RepairButton[0], $RepairButton[1], 1, 5)
  820.    Sleep(500)
  821.    
  822.    MouseClick('LEFT', $AllItemsButton[0], $AllItemsButton[1], 1, 5)
  823.    Sleep(500)
  824.    
  825.    Send("{ESC}")
  826.    ToLog("Repairing... done")
  827. EndFunc
  828.  
  829. Func CheckForRepair()
  830.    $RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xFFE801, 10)
  831.    If Not @error Then
  832.       ToLog("We need to repair")
  833.       Return True
  834.    Else
  835.       Return False
  836.    EndIf
  837. EndFunc
  838.  
  839. Func MoveToMerchant()
  840.    Sleep(500)
  841.    ToLog("Waiting to get to the merchant...")
  842.    
  843.    ToLog("Moving to merchant - 1")
  844.    Move($MoveToMerchant[0] , $MoveToMerchant[1])
  845.    Sleep(3500 + $MoveDelay)
  846.    
  847.    ToLog("Moving to merchant - 2")
  848.    MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 10)
  849.    
  850.    AtMerchant()
  851. EndFunc
  852.  
  853. Func MoveToStash()
  854.    ToLog("Waiting to get to the stash...")
  855.    
  856.    ToLog("Moving to stash - 1")
  857.    Move($MoveToStash1[0] , $MoveToStash1[1])
  858.    Sleep(2050 + $MoveDelay)
  859.    
  860.    ToLog("Moving to stash - 2")
  861.    Move($MoveToStash2[0] , $MoveToStash2[1])
  862.    Sleep(2650 + $MoveDelay)
  863.    
  864.    If $UseStash = True Then
  865.       $StashBag = 1
  866.       MouseClick("LEFT", $StashLocation[0], $StashLocation[1], 1, 10)
  867.       AtStash()
  868.       PutInStash()
  869.       Sleep(200)
  870.       Send("{ESC}")
  871.    EndIf
  872. EndFunc
  873.  
  874.  
  875. ;Check gamestate, disconnect and death
  876. Func InLoginScreen()
  877.    ToLog("Waiting to get into the login screen...")
  878.    
  879.    While 1
  880.       $Array = StringSplit($ImageFiles[7][4],"|")
  881.       $File = $Array[1]
  882.       $Accuracy = $Array[2]
  883.    
  884.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  885.       If $Target = 1 Then
  886.          ExitLoop
  887.       Else
  888.          Sleep(350)
  889.       EndIf
  890.    WEnd  
  891. EndFunc
  892.  
  893. Func InGameLobby()
  894.    ToLog("Waiting to get into the game lobby...")
  895.    
  896.    While 1
  897.       $Array = StringSplit($ImageFiles[7][2],"|")
  898.       $File = $Array[1]
  899.       $Accuracy = $Array[2]
  900.    
  901.       $Target = _ImageSearchArea($ImgDir & $File, 1, $ResumeButtonSearchArea[0], $ResumeButtonSearchArea[1], $ResumeButtonSearchArea[2], $ResumeButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  902.       If $Target = 1 Then
  903.          ExitLoop
  904.       Else
  905.          CheckForDeath()
  906.          Sleep(200)
  907.          CheckForDisconnect()
  908.          Sleep(350)
  909.       EndIf
  910.    WEnd  
  911. EndFunc
  912.  
  913. Func InGameplayScreen()
  914.    ToLog("Waiting to get into the game...")
  915.    
  916.    While 1
  917.       $Array = StringSplit($ImageFiles[7][3],"|")
  918.       $File = $Array[1]
  919.       $Accuracy = $Array[2]
  920.    
  921.       $Target = _ImageSearchArea($ImgDir & $File, 1, $PortalIconSearchArea[0], $PortalIconSearchArea[1], $PortalIconSearchArea[2], $PortalIconSearchArea[3], $ISx, $ISy, $Accuracy)
  922.       If $Target = 1 Then
  923.          $Alive = True
  924.          $DisconnectState = 0
  925.          ExitLoop
  926.       Else
  927.          CheckForDeath()
  928.          Sleep(200)
  929.          CheckForDisconnect()
  930.          Sleep(200)
  931.       EndIf
  932.    WEnd  
  933. EndFunc
  934.  
  935. Func InCellar()
  936.    ToLog("Waiting to get into the cellar...")
  937.    $TimeOutTimer = TimerInit()
  938.    
  939.    While 1
  940.       $Array = StringSplit($ImageFiles[7][0],"|")
  941.       $File = $Array[1]
  942.       $Accuracy = $Array[2]
  943.    
  944.       $Target = _ImageSearchArea($ImgDir & $File, 1, $CellarNameSearchArea[0], $CellarNameSearchArea[1], $CellarNameSearchArea[2], $CellarNameSearchArea[3], $ISx, $ISy, $Accuracy)
  945.       If $Target = 1 Then
  946.          ExitLoop
  947.       Else
  948.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= $TimeOut Then
  949.             ToLog("TimeOut - Leaving")
  950.             LeaveGame()
  951.          EndIf
  952.          CheckForDeath()
  953.          Sleep(200)
  954.          CheckForDisconnect()
  955.          Sleep(200)
  956.       EndIf
  957.    WEnd
  958. EndFunc
  959.  
  960. Func InTown()
  961.    ToLog("Waiting to get into the town...")
  962.    $TimeOutTimer = TimerInit()
  963.    
  964.    While 1
  965.       $Array = StringSplit($ImageFiles[7][1],"|")
  966.       $File = $Array[1]
  967.       $Accuracy = $Array[2]
  968.    
  969.       $Target = _ImageSearchArea($ImgDir & $File, 1, $TownNameSearchArea[0], $TownNameSearchArea[1], $TownNameSearchArea[2], $TownNameSearchArea[3], $ISx, $ISy, $Accuracy)
  970.       If $Target = 1 Then
  971.          ExitLoop
  972.       Else
  973.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= $TimeOut Then
  974.             ToLog("TimeOut - Trying to teleport again")
  975.             TeleportToTown()
  976.          EndIf
  977.          CheckForDeath()
  978.          Sleep(200)
  979.          CheckForDisconnect()
  980.          Sleep(200)
  981.       EndIf
  982.    WEnd  
  983. EndFunc
  984.  
  985. Func AtMerchant()
  986.    $TimeOutTimer = TimerInit()
  987.    
  988.    While 1
  989.       $Array = StringSplit($ImageFiles[7][5],"|")
  990.       $File = $Array[1]
  991.       $Accuracy = $Array[2]
  992.    
  993.       $Target = _ImageSearchArea($ImgDir & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
  994.       If $Target = 1 Then
  995.          ExitLoop
  996.       Else
  997.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= $TimeOut Then
  998.             ToLog("TimeOut - Leaving")
  999.             LeaveGame()
  1000.          EndIf
  1001.          CheckForDeath()
  1002.          Sleep(200)
  1003.          CheckForDisconnect()
  1004.          Sleep(200)
  1005.       EndIf
  1006.    WEnd  
  1007. EndFunc
  1008.  
  1009. Func AtStash()
  1010.    $TimeOutTimer = TimerInit()
  1011.    
  1012.    While 1
  1013.       $Array = StringSplit($ImageFiles[7][6],"|")
  1014.       $File = $Array[1]
  1015.       $Accuracy = $Array[2]
  1016.    
  1017.       $Target = _ImageSearchArea($ImgDir & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
  1018.       If $Target = 1 Then
  1019.          ExitLoop
  1020.       Else
  1021.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= $TimeOut Then
  1022.             ToLog("TimeOut - Leaving")
  1023.             LeaveGame()
  1024.          EndIf
  1025.          CheckForDeath()
  1026.          Sleep(200)
  1027.          CheckForDisconnect()
  1028.          Sleep(200)
  1029.       EndIf
  1030.    WEnd  
  1031. EndFunc
  1032.  
  1033. Func CheckForDisconnect()
  1034.    $Array = StringSplit($ImageFiles[6][0],"|")
  1035.    $File = $Array[1]
  1036.    $Accuracy = $Array[2]
  1037.    
  1038.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, $Accuracy)
  1039.    If $Target = 1 Then
  1040.       ToLog("We got disconnected")
  1041.       $Disconnects+=1
  1042.       RefreshStats()
  1043.       $DisconnectState = 1
  1044.      
  1045.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1046.       InGameLobby()
  1047.    EndIf
  1048.    
  1049.    $Array = StringSplit($ImageFiles[6][1],"|")
  1050.    $File = $Array[1]
  1051.    $Accuracy = $Array[2]
  1052.    
  1053.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
  1054.    If $Target = 1 Then
  1055.       ToLog("We got... totally disconnected")
  1056.       If $DisconnectState = 0 Then
  1057.          $Disconnects+=1
  1058.          RefreshStats()
  1059.       EndIf
  1060.       $DisconnectState = 2
  1061.      
  1062.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1063.       InLoginScreen()  
  1064.    EndIf
  1065.    
  1066.    If $DisconnectState = 2 Then
  1067.       If $UseRelogging = True Then
  1068.          Relog()
  1069.       Else
  1070.          Terminate()
  1071.       EndIf
  1072.    EndIf
  1073. EndFunc
  1074.  
  1075. Func CheckForDeath()
  1076.    If $Alive = True Then
  1077.       $Death = PixelSearch($DeathSearchArea[0], $DeathSearchArea[1], $DeathSearchArea[2], $DeathSearchArea[3], 0xFFFFFF)
  1078.       If Not @error Then
  1079.          $Alive = False
  1080.          ToLog("We are dead... :(")
  1081.          $Deaths+=1
  1082.          RefreshStats()
  1083.          LeaveGame()
  1084.       EndIf
  1085.    EndIf
  1086. EndFunc
  1087.  
  1088.  
  1089. ;Miscellaneous
  1090. Func ScriptStarted()
  1091.    Pause()
  1092.    
  1093.    $RuntimeTimer = TimerInit()
  1094.    
  1095.    If $ShowLootArea = True Then
  1096.       DrawLootArea()   
  1097.    EndIf
  1098.    
  1099.    If $ShowLog = True Then
  1100.       $Log = FileOpen($SaveLogsPath & "log.txt", 1)
  1101.       DrawLog()
  1102.    EndIf
  1103.    
  1104.    If $ShowLog = True Or $SaveStats = True Then
  1105.       DirGetSize($SaveLogsPath)
  1106.       If @error= 1 Then
  1107.          DirCreate($SaveLogsPath)
  1108.       EndIf  
  1109.    EndIf
  1110.    
  1111.    ToLog("Bot started")
  1112.    
  1113.    WinActivate('Diablo III')  
  1114. EndFunc
  1115.  
  1116. Func Pause()
  1117.    ToLog("Paused...")
  1118.    $Paused = Not $Paused
  1119.    
  1120.    While $Paused
  1121.       Sleep(100)
  1122.       ToolTip('Paused... Press {PAUSE} to continue...', 850, 0)
  1123.    WEnd
  1124.    
  1125.    ToolTip("")
  1126. EndFunc
  1127.  
  1128. Func Randomize()
  1129.    Global $Stash[54][2]
  1130.    $c = 0
  1131.    $d = -2
  1132.    For $a = 0 to 53
  1133.       $d+=1
  1134.       If $a = 9 or $a = 18 or $a = 27 or $a = 36 or $a = 45 Then
  1135.          $c+=1
  1136.          $d=-1
  1137.       EndIf
  1138.       For $b = 0 to 1
  1139.          If $b = 0 Then
  1140.             $Stash[$a][$b] = Random(1522, 1532, 1) + (49 * $d)
  1141.          Else
  1142.             $Stash[$a][$b] = Random(606, 614, 1) + (49 * $c)
  1143.          EndIf
  1144.       Next
  1145.    Next
  1146.    
  1147.    $MoveToCellar1[0]        = Random(498, 503, 1)
  1148.    $MoveToCellar1[1]        = Random(248, 253, 1)
  1149.    $MoveToCellar2[0]        = Random(1, 4, 1)
  1150.    $MoveToCellar2[1]        = Random(368, 373, 1)
  1151.    $MoveToCellar3[0]        = Random(398, 403, 1)
  1152.    $MoveToCellar3[1]        = Random(598, 603, 1)  
  1153.  
  1154.    $MoveInCellar1[0]        = Random(114, 119, 1)
  1155.    $MoveInCellar1[1]        = Random(984, 989, 1)          
  1156.    $MoveInCellar2[0]        = Random(774, 779, 1)
  1157.    $MoveInCellar2[1]        = Random(326, 331, 1)
  1158.  
  1159.    $MoveToGoldLoot1a[0]     = Random(400, 405, 1)
  1160.    $MoveToGoldLoot1a[1]     = Random(304, 309, 1)
  1161.    $MoveToGoldLoot1b[0]     = Random(575, 580, 1)
  1162.    $MoveToGoldLoot1b[1]     = Random(304, 309, 1)
  1163.    $MoveToGoldLoot2[0]      = Random(1258, 1263, 1)
  1164.    $MoveToGoldLoot2[1]      = Random(349, 354, 1)
  1165.    $MoveToGoldLoot3[0]      = Random(909, 914, 1)
  1166.    $MoveToGoldLoot3[1]      = Random(692, 697, 1)
  1167.  
  1168.    $MoveToMerchant[0]       = Random(1688, 1693, 1)
  1169.    $MoveToMerchant[1]       = Random(100, 105, 1)
  1170.  
  1171.    $MoveToStash1[0]         = Random(778, 783, 1)
  1172.    $MoveToStash1[1]         = Random(948, 953, 1)
  1173.    $MoveToStash2[0]         = Random(268, 273, 1)
  1174.    $MoveToStash2[1]         = Random(928, 933, 1)
  1175.  
  1176.    $CellarLocation[0]       = Random(305, 309, 1)
  1177.    $CellarLocation[1]       = Random(72, 76, 1)
  1178.  
  1179.    $MonsterLocation[0]      = Random(575, 580, 1)
  1180.    $MonsterLocation[1]      = Random(181, 186, 1)
  1181.  
  1182.    $MerchantLocation[0]     = Random(928, 933, 1)
  1183.    $MerchantLocation[1]     = Random(134, 139, 1)
  1184.  
  1185.    $StashLocation[0]        = Random(803, 808, 1)
  1186.    $StashLocation[1]        = Random(428, 433, 1)
  1187.  
  1188.    $PortalLocation[0]       = Random(648, 653, 1)
  1189.    $PortalLocation[1]       = Random(498, 503, 1)
  1190.  
  1191.    $StashBag2[0]            = Random(508, 513, 1)
  1192.    $StashBag2[1]            = Random(358, 363, 1)
  1193.  
  1194.    $StashBag3[0]            = Random(508, 513, 1)
  1195.    $StashBag3[1]            = Random(488, 493, 1)
  1196.  
  1197.    $RepairButton[0]         = Random(515, 520, 1)
  1198.    $RepairButton[1]         = Random(481, 486, 1)
  1199.  
  1200.    $AllItemsButton[0]       = Random(221, 226, 1)
  1201.    $AllItemsButton[1]       = Random(590, 595, 1)
  1202.    
  1203.    $PasswordField[0]        = Random(818, 823, 1)
  1204.    $PasswordField[1]        = Random(703, 708, 1)
  1205.  
  1206.    $ResumeButton[0]         = Random(317, 322, 1)
  1207.    $ResumeButton[1]         = Random(414, 419, 1)
  1208.  
  1209.    $LeaveButton[0]          = Random(967, 972, 1)
  1210.    $LeaveButton[1]          = Random(580, 584, 1)
  1211.  
  1212.    $DisconnectButton[0]     = Random(958, 963, 1)
  1213.    $DisconnectButton[1]     = Random(628, 633, 1)
  1214. EndFunc
  1215.  
  1216. Func DrawLootArea()
  1217.    $LootAreaGUI = GUICreate("", $LootingAreaWidth + 2, $LootingAreaHeight + 2, $LootingArea[0], $LootingArea[1], $WS_POPUP, BitOR($WS_EX_LAYERED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  1218.    GuiSetBkColor(0xABCDEF)
  1219.    _WinAPI_SetLayeredWindowAttributes($LootAreaGUI, 0xABCDEF, 0xA0)
  1220.    WinSetOnTop($LootAreaGUI, "", 1)
  1221.    GuiSetState()
  1222.    $hDC = _WinAPI_GetWindowDC($LootAreaGUI)
  1223.    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x0000FF)
  1224.    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
  1225.    $user32_dll = DllOpen("user32.dll")
  1226.    _WinAPI_DrawLine($hDC, 0, 1, $LootingAreaWidth, 0)
  1227.    _WinAPI_DrawLine($hDC, 1, 0, 0, $LootingAreaHeight)
  1228.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, $LootingAreaWidth, 0)
  1229.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, 0, $LootingAreaHeight)
  1230.    
  1231.    _WinAPI_SetTextColor($hDC, 0x0000FF)
  1232.    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
  1233.    
  1234.    $tRECT = DllStructCreate($tagRect)
  1235.    DllStructSetData($tRECT, "Left", 5)
  1236.    DllStructSetData($tRECT, "Top", 5)
  1237.    DllStructSetData($tRECT, "Right", 250)
  1238.    DllStructSetData($tRECT, "Bottom", 50)
  1239.    
  1240.    _WinAPI_DrawText($hDC, "Loot Area", $tRect, 0)
  1241. EndFunc
  1242.  
  1243. Func DrawLog()
  1244.    $Width = 475
  1245.    $Height = 200
  1246.    $LogGUI = GUICreate("", $Width, $Height, 1920 - $Width - 5, 1080 - $Height - 5, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  1247.    GuiSetBkColor(0x000000)
  1248.    _WinAPI_SetLayeredWindowAttributes($LogGUI, 0xEEEEEF, 0xEE) ;0xA0
  1249.    WinSetOnTop($LogGUI, "", 1)
  1250.    GuiSetState()
  1251.    
  1252.    $Label = GUICtrlCreateLabel("", 0, 10, $Width, 100, $SS_CENTER)
  1253.    GUICtrlSetFont($Label, 8, 500, 0, "")
  1254.    GuiCtrlSetColor($Label, 0xFFFFFF)
  1255.    
  1256.    $LogList = GUICtrlCreateList("", 5, 60, $Width - 10, $Height - 60, $LBS_NOSEL)
  1257.    GUICtrlSetColor($LogList, 0x000000)
  1258.    GUICtrlSetFont($LogList, 8)
  1259.    
  1260.    RefreshStats()
  1261. EndFunc
  1262.  
  1263. Func RefreshStats()
  1264.    If $ShowLog = True Then
  1265.       GUICtrlSetData($Label, "Start: " & $StartTime & "  |  Runs: " & $Runs & "  |  Closed:  " & $Closed & "  |  Deaths: " & $Deaths & "  |  Disconnects: " & $Disconnects & @LF & @LF & "Legendaries: " & $Legendaries & "  |  Sets: " & $Sets & "  |  Rares: " & $Rares & "  |  Magics: " & $Magics & "  |  Tomes: " & $Tomes & "  |  Gems: " & $Gems & "  |  Sold: " & $Sold)
  1266.    EndIf
  1267. EndFunc
  1268.  
  1269. Func ToLog($Text)
  1270.    If $ShowLog = True Then
  1271.       GUICtrlSetData($LogList, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  1272.       GUICtrlSendMsg($LogList, $WM_VSCROLL, $SB_LINEDOWN, 0)
  1273.    
  1274.       FileWriteLine($Log, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  1275.       If $Text = "Bot closed" Then
  1276.          FileWriteLine($Log, @LF)  
  1277.       EndIf
  1278.    EndIf
  1279. EndFunc
  1280.  
  1281. Func Relog()
  1282.    ToLog("Relogging...")
  1283.    MouseClick("LEFT", $PasswordField[0], $PasswordField[1], 1, 5)
  1284.    Send($Password)
  1285.    
  1286.    Sleep(1000 + $Computerlag)
  1287.    Send("{ENTER}")
  1288.    
  1289.    $DisconnectState = 0
  1290.    Bot()
  1291. EndFunc
  1292.  
  1293. Func SaveStats()
  1294.    $File = FileOpen($SaveLogsPath & "statistics.txt", 1)
  1295.    FileWriteLine($File, "=========" & @HOUR & ":" & @MIN & ":" & @SEC & "=========")
  1296.    FileWriteLine($File, "Startime: " & @TAB & @TAB & $StartTime & @LF & "Runs: " & @TAB & @TAB & $Runs & @LF & "Closed: " & @TAB & @TAB & $Closed & @LF & "Deaths: " & @TAB & @TAB & $Deaths & @LF & "Disconnects: " & @TAB & $Disconnects & @LF & "Runtime: " & @TAB & @TAB & $Runtime & @LF & @LF & "Legendaries: " & @TAB & $Legendaries & @LF & "Sets: " & @TAB & @TAB & $Sets & @LF & "Rares: " & @TAB & @TAB & $Rares & @LF & "Magics: " & @TAB & @TAB & $Magics & @LF & "Tomes: " & @TAB & @TAB & $Tomes & @LF & "Gems: " & @TAB & @TAB & $Gems & @LF & "Sold: " & @TAB & @TAB & $Sold)
  1297.    FileWriteLine($File, @LF)
  1298.    FileClose($File)
  1299. EndFunc
  1300.  
  1301. Func Move($x, $y)
  1302.    MouseClick('MIDDLE', $x, $y, 1, 5)
  1303. EndFunc
  1304.  
  1305. Func Attack($x, $y)
  1306.    Send("{SHIFTDOWN}")
  1307.    MouseClick('LEFT', $x, $y, 1, 2)
  1308.    Send("{SHIFTUP}")
  1309. EndFunc
  1310.  
  1311. Func AttackNearbyMonsters()
  1312.    While 1
  1313.       $MonsterData =  PixelSearch($CharHitBox[0], $CharHitBox[1], $CharHitBox[2], $CharHitBox[3], 0xEE0000, 10)
  1314.       If @error Then
  1315.          ExitLoop
  1316.       EndIf
  1317.       ToLog("Maybe not all monsters are dead...")
  1318.       Send("{4}")
  1319.       Sleep(300)
  1320.      
  1321.       For $i = 10 To 0 step -1
  1322.          Attack($MonsterData[0], $MonsterData[1])
  1323.          Sleep(150)
  1324.       Next
  1325.       ToLog("Hopefully now...")
  1326.    WEnd
  1327. EndFunc
  1328.  
  1329. Func LeaveGame()
  1330.    If $SaveStats = True Then
  1331.       SaveStats()
  1332.    EndIf
  1333.    ToLog("Leaving the game")
  1334.    $Sek     = Floor(TimerDiff($RuntimeTimer) / 1000)
  1335.    $Min     = Floor($Sek / 60)
  1336.    $Hour    = Floor($Min / 60)
  1337.    $Runtime = $Hour & "h " & ($Min - $Hour * 60) & "m " & ($Sek - $Min * 60) & "s"
  1338.      
  1339.    Sleep(1000 + $ComputerLag)
  1340.    
  1341.    Send("{ESC}")
  1342.    Sleep(200)
  1343.    
  1344.    MouseClick('LEFT', $LeaveButton[0], $LeaveButton[1], 1, 5)
  1345.    Sleep(1250 + $Computerlag)
  1346.    
  1347.    Bot()
  1348. EndFunc
  1349.  
  1350. Func Terminate()
  1351.    ToLog("Terminating... Good bye :)")
  1352.    SaveStats()
  1353.    Exit 0
  1354. EndFunc
  1355.  
  1356. Func _ImageSearchArea($FindImage,$ResultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $Tolerance)
  1357.     If $Tolerance > 0 Then $FindImage = "*" & $Tolerance & " " & $FindImage
  1358.        
  1359.     If @AutoItX64 Then
  1360.          $Result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  1361.       Else
  1362.          $Result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  1363.       EndIf
  1364.      
  1365.    If $Result = "0" Then Return 0
  1366.      
  1367.    $Array = StringSplit($Result[0],"|")
  1368.    
  1369.    If(UBound($Array) >= 4) Then
  1370.       $x=Int(Number($Array[2]))
  1371.       $y=Int(Number($Array[3]))
  1372.      
  1373.       If $ResultPosition=1 Then
  1374.          $x=$x + Int(Number($Array[4])/2)
  1375.          $y=$y + Int(Number($Array[5])/2)
  1376.       Endif
  1377.       Return 1
  1378.    EndIf
  1379. EndFunc
  1380.  
  1381. Func OnAutoItExit()
  1382.    ToLog("Bot closed")
  1383. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement