Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.1a_zeenexx

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