Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.1_zeenexx

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