Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.1b_zeenexx

Jun 20th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 34.12 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.1b
  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|120"
  157. $ImageFiles[6][3]           = "new.png|120"
  158. $ImageFiles[6][4]           = "game.png|20"
  159. $ImageFiles[6][5]           = "portal.png|120"
  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.    Sleep(200 + $Computerlag)
  382.    Send("{2}")
  383.    Sleep(200 + $Computerlag)
  384.    
  385.    ToLog("Moving to cellar - 1")
  386.    Move($MoveToCellar1[0], $MoveToCellar1[1])
  387.    Sleep(1400 + $MoveDelay)
  388.    
  389.    Send("{4}")
  390.    Sleep(500)
  391.    
  392.    ToLog("Moving to cellar - 2")
  393.    Move($MoveToCellar2[0], $MoveToCellar2[1])
  394.    Sleep(2150 + $MoveDelay)
  395.    
  396.    ToLog("Moving to cellar - 3")
  397.    Move($MoveToCellar3[0], $MoveToCellar3[1])
  398.    Sleep(1250 + $MoveDelay)
  399. EndFunc
  400.  
  401. Func EnterCellar()
  402.    MouseMove($CellarLocation[0], $CellarLocation[1], 5)
  403.    Sleep(400 + $ComputerLag)
  404.    
  405.    $CellarPixel = PixelSearch($CellarLocation[0]-$CellarOffset, $CellarLocation[1]-$CellarOffset, $CellarLocation[0]+4, $CellarLocation[1]+4, 0x334FB7, 6)
  406.    If @error Then
  407.       ToLog("Cellar is closed")
  408.       $Closed+=1
  409.       RefreshStats()
  410.       TeleportToTown()
  411.       LeaveGame()
  412.    EndIf
  413.    
  414.    ToLog("Entering cellar...")
  415.    MouseClick('LEFT', $CellarLocation[0], $CellarLocation[1], 1, 5)
  416.    InCellar()
  417. EndFunc
  418.  
  419. Func MoveInCellar()
  420.    ToLog("Moving in cellar - 1")
  421.    Move($MoveInCellar1[0], $MoveInCellar1[1])
  422.    Sleep(2250 + $MoveDelay)
  423.    
  424.    ToLog("Moving in cellar - 2")
  425.    Move($MoveInCellar2[0], $MoveInCellar2[1])
  426.    Sleep(1260 + $MoveDelay)
  427.    
  428.    MouseMove($MonsterLocation[0],$MonsterLocation[1], 5)
  429.    Sleep(150 + $Computerlag)
  430. EndFunc
  431.    
  432. Func UseSkills()
  433.    ToLog("Using skills...")
  434.    Send("{1}")
  435.    Sleep(400 + $Computerlag)
  436.    
  437.    Send("{3}")
  438.    Sleep(400 + $Computerlag)
  439.    
  440.    MouseClick('RIGHT')
  441.    Sleep(250 + $Computerlag)
  442. EndFunc
  443.    
  444. Func KillSarkoth()
  445.    ToLog("Kill Sarkoth...")
  446.    While 1
  447.       $MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  448.       If @error Then
  449.          Attack($MonsterLocation[0],$MonsterLocation[1])
  450.          Sleep(850)
  451.          
  452.          $MonsterBar =  PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  453.          If @error Then
  454.             ExitLoop
  455.          EndIf
  456.       EndIf
  457.      
  458.       Attack($MonsterBar[0], $MonsterBar[1])
  459.       Sleep(100)
  460.    WEnd
  461.    ToLog("All monsters are dead")
  462. EndFunc
  463.  
  464. Func LootGold()
  465.    ToLog("Looting gold...")
  466.    If $HighGoldRadius = False Then
  467.       Move($MoveToGoldLoot1a[0], $MoveToGoldLoot1a[1])
  468.       Sleep(1500 + $MoveDelay)
  469.       AttackNearbyMonsters()
  470.      
  471.       Move($MoveToGoldLoot2[0], $MoveToGoldLoot2[1])
  472.       Sleep(1500 + $MoveDelay)
  473.       AttackNearbyMonsters()
  474.      
  475.       Move($MoveToGoldLoot3[0], $MoveToGoldLoot3[1])
  476.       Sleep(1500 + $MoveDelay)
  477.       AttackNearbyMonsters()
  478.    Else
  479.       Move($MoveToGoldLoot1b[0], $MoveToGoldLoot1b[1])
  480.       Sleep(1500 + $MoveDelay)
  481.       AttackNearbyMonsters()
  482.    EndIf
  483.    
  484.    MouseMove(120, 120, 3)
  485.    Sleep(100)
  486. EndFunc
  487.  
  488. Func LootItems()
  489.    If $LootSets Then
  490.       LootSets()
  491.    EndIf
  492.    
  493.    If $LootLegendaries Then
  494.       LootLegendaries()
  495.    EndIf
  496.    
  497.    If $LootRares Then
  498.       LootRares()
  499.       $RareLootAttempts = 0
  500.    EndIf
  501.    
  502.    If $LootMagics Then
  503.       LootMagics()
  504.       $MagicLootAttempts = 0
  505.    Else
  506.       If $LootTomes Then
  507.          LootTomes()
  508.          $TomesLootAttempts = 0
  509.       EndIf
  510.    EndIf
  511.    
  512.    If $LootGems Then
  513.       LootGems()
  514.       $GemLootAttempts = 0
  515.    EndIf
  516.    
  517.    CheckForDeath()
  518. EndFunc
  519.    
  520. Func TeleportToTown()
  521.    ToLog("Teleporting to town...")
  522.    Sleep(500)
  523.    Send("{t}")
  524.    InTown()
  525. EndFunc
  526.  
  527.  
  528. ;Loot
  529. Func LootLegendaries()
  530.    ToLog("Searching for legendaries...")
  531.    For $gI = 0 to 4
  532.       $Array = StringSplit($ImageFiles[0][$gI],"|")
  533.       $File = $Array[1]
  534.       $Accuracy = $Array[2]
  535.      
  536.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  537.       If $Target = 1 Then
  538.          ToLog("Legendary found")
  539.          $Legendaries+=1
  540.          RefreshStats()
  541.          
  542.          If $Sounds = True Then
  543.             SoundPlay($SoundsDir & $SoundFiles[0], 0)
  544.          EndIf
  545.          
  546.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  547.          Sleep(800 + $LootDelay)
  548.          
  549.          MouseMove(120, 120, 3)
  550.          Sleep(100)
  551.          
  552.          If $Sell = True Then
  553.             CheckBagFull()
  554.             If $FullBag = True Then
  555.                $FullBag = False
  556.                Sleep(300)
  557.                LootLegendaries()
  558.             EndIf
  559.          EndIf
  560.          ExitLoop
  561.       EndIf
  562.    Next
  563. EndFunc
  564.  
  565. Func LootSets()
  566.    ToLog("Searching for sets...")
  567.    For $gI = 0 to 4
  568.       $Array = StringSplit($ImageFiles[1][$gI],"|")
  569.       $File = $Array[1]
  570.       $Accuracy = $Array[2]
  571.      
  572.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  573.       If $Target = 1 Then
  574.          ToLog("Set found")
  575.          $Sets+=1
  576.          RefreshStats()
  577.          
  578.          If $Sounds = True Then
  579.             SoundPlay($SoundsDir & $SoundFiles[1], 0)
  580.          EndIf
  581.          
  582.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  583.          Sleep(800 + $LootDelay)
  584.          
  585.          MouseMove(120, 120, 3)
  586.          Sleep(100)
  587.          
  588.          If $Sell = True Then
  589.             CheckBagFull()
  590.             If $FullBag = True Then
  591.                $FullBag = False
  592.                Sleep(300)
  593.                LootSets()
  594.             EndIf
  595.          EndIf
  596.          ExitLoop
  597.       EndIf
  598.    Next  
  599. EndFunc
  600.  
  601. Func LootRares()
  602.    ToLog("Searching for rares... " & $RareLootAttempts+1)
  603.    For $gI = 0 to 4
  604.       $Array = StringSplit($ImageFiles[2][$gI],"|")
  605.       $File = $Array[1]
  606.       $Accuracy = $Array[2]
  607.      
  608.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  609.       If $Target = 1 Then
  610.          ToLog("Rare found")
  611.          $Rares+=1
  612.          RefreshStats()
  613.          
  614.          If $Sounds = True Then
  615.             SoundPlay($SoundsDir & $SoundFiles[2], 0)
  616.          EndIf
  617.          
  618.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  619.          Sleep(700 + $LootDelay)
  620.          
  621.          MouseMove(120, 120, 3)
  622.          Sleep(100)
  623.          
  624.          If $Sell = True Then
  625.             CheckBagFull()
  626.             If $FullBag = True Then
  627.                $FullBag = False
  628.                Sleep(300)
  629.                LootRares()
  630.             EndIf
  631.          EndIf
  632.          ExitLoop
  633.       EndIf
  634.    Next
  635.    
  636.    $RareLootAttempts+=1    
  637.    
  638.    If($RareLootAttempts >= $RareLootAmount) Then
  639.       Return
  640.    Else
  641.       LootRares()
  642.    EndIf
  643. EndFunc
  644.  
  645. Func LootMagics()
  646.    ToLog("Searching for magics... " & $MagicLootAttempts+1)
  647.    For $gI = 0 to 4
  648.       $Array = StringSplit($ImageFiles[3][$gI],"|")
  649.       $File = $Array[1]
  650.       $Accuracy = $Array[2]
  651.      
  652.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  653.       If $Target = 1 Then
  654.          ToLog("Magic found")
  655.          $Magics+=1
  656.          RefreshStats()
  657.          
  658.          If $Sounds = True Then
  659.             SoundPlay($SoundsDir & $SoundFiles[3], 0)
  660.          EndIf
  661.          
  662.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  663.          Sleep(700 + $LootDelay)
  664.          
  665.          MouseMove(120, 120, 3)
  666.          Sleep(100)
  667.          
  668.          If $Sell = True Then
  669.             CheckBagFull()
  670.             If $FullBag = True Then
  671.                $FullBag = False
  672.                Sleep(300)
  673.                LootMagics()
  674.             EndIf
  675.          EndIf
  676.          ExitLoop
  677.       EndIf
  678.    Next
  679.    
  680.    $MagicLootAttempts+=1
  681.    
  682.    If($MagicLootAttempts >= $MagicLootAmount) Then
  683.       Return
  684.    Else
  685.       LootMagics()
  686.    EndIf
  687. EndFunc
  688.  
  689. Func LootTomes()
  690.    ToLog("Searching for Tomes of Secrets... " & $TomeLootAttempts+1)
  691.    $Array = StringSplit($ImageFiles[4][0],"|")
  692.    $File = $Array[1]
  693.    $Accuracy = $Array[2]
  694.    
  695.    $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  696.    If $Target = 1 Then
  697.       ToLog("Tome of Secrets found")
  698.       $Tomes+=1
  699.       RefreshStats()
  700.      
  701.       If $Sounds = True Then
  702.          SoundPlay($SoundsDir & $SoundFiles[4], 0)
  703.       EndIf
  704.      
  705.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  706.       Sleep(700 + $LootDelay)
  707.      
  708.       MouseMove(120, 120, 3)
  709.       Sleep(100)
  710.      
  711.       If $Sell = True Then
  712.          CheckBagFull()
  713.          If $FullBag = True Then
  714.             $FullBag = False
  715.             Sleep(300)
  716.             LootTomes()
  717.          EndIf
  718.       EndIf
  719.    EndIf
  720.    
  721.    $TomeLootAttempts+=1
  722.    
  723.    If($TomeLootAttempts >= $TomeLootAmount) Then
  724.       Return
  725.    Else
  726.       LootTomes()
  727.    EndIf
  728. EndFunc
  729.    
  730. Func LootGems()
  731.    ToLog("Searching for gems... " & $GemLootAttempts+1)
  732.    $Array = StringSplit($ImageFiles[4][1],"|")
  733.    $File = $Array[1]
  734.    $Accuracy = $Array[2]
  735.    
  736.    $Target = _ImageSearchArea($ImgDir & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
  737.    If $Target = 1 Then
  738.       ToLog("Gem found")
  739.       $Gems+=1
  740.       RefreshStats()
  741.      
  742.       If $Sounds = True Then
  743.          SoundPlay($SoundsDir & $SoundFiles[5], 0)
  744.       EndIf
  745.      
  746.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  747.       Sleep(700 + $LootDelay)
  748.      
  749.       MouseMove(120, 120, 3)
  750.       Sleep(100)
  751.      
  752.       If $Sell = True Then
  753.          CheckBagFull()
  754.          If $FullBag = True Then
  755.             $FullBag = False
  756.             Sleep(300)
  757.             LootGems()
  758.          EndIf
  759.       EndIf
  760.    EndIf
  761.    
  762.    $GemLootAttempts+=1
  763.    
  764.    If($GemLootAttempts >= $GemLootAmount) Then
  765.       Return
  766.    Else
  767.       LootGems()
  768.    EndIf
  769. EndFunc
  770.  
  771.  
  772. ;Sell, store and repair
  773. Func CheckBagFull()
  774.    $Array = StringSplit($ImageFiles[5][0],"|")
  775.    $File = $Array[1]
  776.    $Accuracy = $Array[2]
  777.    
  778.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullBagSearchArea[0], $FullBagSearchArea[1], $FullBagSearchArea[2], $FullBagSearchArea[3], $ISx, $ISy, $Accuracy)
  779.    If $Target = 1 Then
  780.       ToLog("Our bag is full")
  781.       $FullBag = True
  782.       SellItems()
  783.    EndIf
  784. EndFunc
  785.  
  786. Func SellItems()  
  787.    TeleportToTown()
  788.    MoveToMerchant()
  789.    
  790.    ToLog("Selling...")
  791.    
  792.    $Count = 0
  793.    
  794.    For $gI = 1 to 3
  795.       $Array = StringSplit($ImageFiles[5][$gI],"|")
  796.       $File = $Array[1]
  797.       $Accuracy = $Array[2]
  798.      
  799.       For $i = 30 To 0 step -1
  800.          $Target = _ImageSearchArea($ImgDir & $File, 1, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
  801.          If $Target = 1 Then
  802.             $Count+=1
  803.             $Sold+=1
  804.             RefreshStats()
  805.            
  806.             MouseClick("RIGHT", $ISx, $ISy, 1, 2)
  807.             Sleep(150)
  808.          EndIf
  809.       Next
  810.    Next
  811.    
  812.    ToLog("Selling... done - Sold " & $Count & " items!")
  813.    
  814.    $RareLootAttempts    = 0
  815.    $MagicLootAttempts   = 0
  816.    $TomeLootAttempts    = 0
  817.    $GemLootAttempts     = 0
  818.    
  819.    MoveToStash()
  820.    
  821.    If $UseStash = True Then
  822.       $StashBag = 1
  823.       PutInStash()
  824.       Sleep(200)
  825.       Send("{ESC}")
  826.    EndIf
  827.    
  828.    Sleep(500)
  829.    
  830.    MouseClick("LEFT", $PortalLocation[0], $PortalLocation[1], 1, 10)
  831.    Sleep(3000 + $Computerlag)
  832. EndFunc
  833.  
  834. Func PutInStash()  
  835.    MouseClick("LEFT", $StashLocation[0], $StashLocation[1], 1, 10)
  836.    Sleep(500)
  837.    
  838.    ToLog("Storing items in the stash...")
  839.    
  840.    For $Row = 0 to 5 step + 1
  841.       $x = 1527
  842.       $y = 610
  843.      
  844.       For $Column = -1 To 8 step + 1
  845.          MouseClick("RIGHT", $x + (47 * $Column), $y + (50 * $Row), 1, 0)
  846.          Sleep(25)
  847.          
  848.          If CheckStashFull() = 1 Then
  849.             If($Column > 0) Then
  850.                $x-=47
  851.             EndIf
  852.             $Column-=1
  853.          EndIf
  854.          
  855.          If $UseStash = False Then
  856.             ExitLoop (2)
  857.          EndIf
  858.       Next
  859.    Next
  860.    ToLog("Storing items in the stash... done")
  861. EndFunc
  862.  
  863. Func CheckStashFull()
  864.    $Array = StringSplit($ImageFiles[5][4],"|")
  865.    $File = $Array[1]
  866.    $Accuracy = $Array[2]
  867.    
  868.    $Target = _ImageSearchArea($ImgDir & $File, 1, $FullStashSearchArea[0], $FullStashSearchArea[1], $FullStashSearchArea[2], $FullStashSearchArea[3], $ISx, $ISy, $Accuracy)
  869.    If $Target = 1 Then
  870.       Switch $StashBag
  871.          Case 1
  872.             ToLog("First stashbag is full - changing...")
  873.             Sleep(200)
  874.             MouseClick("LEFT", $StashBag2[0], $StashBag2[1], 1, 5)
  875.             $StashBag = 2
  876.             Sleep(5000)
  877.          Case 2
  878.             ToLog("Second stashbag is full - changing...")
  879.             Sleep(200)
  880.             MouseClick("LEFT", $StashBag3[0], $StashBag3[1], 1, 5)
  881.             $StashBag = 3
  882.             Sleep(5000)
  883.          Case 3
  884.             ToLog("Third stashbag is full - aborting...")
  885.             $UseStash = False
  886.       EndSwitch
  887.       Return 1
  888.    EndIf
  889.    Return 0
  890. EndFunc
  891.  
  892. Func RepairItems()
  893.    If Not CheckForRepair() Then
  894.       Return
  895.    EndIf
  896.    
  897.    MoveToMerchant()
  898.    
  899.    ToLog("Repairing...")
  900.    MouseClick('LEFT', $RepairButton[0], $RepairButton[1], 1, 5)
  901.    Sleep(500)
  902.    
  903.    MouseClick('LEFT', $AllItemsButton[0], $AllItemsButton[1], 1, 5)
  904.    Sleep(500)
  905.    
  906.    Send("{ESC}")
  907.    ToLog("Repairing... done")
  908. EndFunc
  909.  
  910. Func CheckForRepair()
  911.    $RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xFFE801, 10)
  912.    If Not @error Then
  913.       ToLog("We need to repair")
  914.       Return True
  915.    Else
  916.       Return False
  917.    EndIf
  918. EndFunc
  919.  
  920. Func MoveToMerchant()
  921.    ToLog("Moving to merchant - 1")
  922.    Move($MoveToMerchant[0] , $MoveToMerchant[1])
  923.    Sleep(3500 + $MoveDelay)
  924.    
  925.    ToLog("Moving to merchant - 2")
  926.    MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 10)
  927.    Sleep(2250 + $MoveDelay)
  928. EndFunc
  929.  
  930. Func MoveToStash()
  931.    ToLog("Moving to stash - 1")
  932.    Move($MoveToStash1[0] , $MoveToStash1[1])
  933.    Sleep(2050 + $MoveDelay)
  934.    
  935.    ToLog("Moving to stash - 2")
  936.    Move($MoveToStash2[0] , $MoveToStash2[1])
  937.    Sleep(2650 + $MoveDelay)
  938. EndFunc
  939.  
  940.  
  941. ;Check gamestate, disconnect and death
  942. Func InLoginScreen()
  943.    While 1
  944.       $Array = StringSplit($ImageFiles[6][6],"|")
  945.       $File = $Array[1]
  946.       $Accuracy = $Array[2]
  947.    
  948.       $Target = _ImageSearchArea($ImgDir & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  949.       If $Target = 1 Then
  950.          ExitLoop
  951.       Else
  952.          Sleep(350)
  953.       EndIf
  954.    WEnd  
  955. EndFunc
  956.  
  957. Func InGameLobby()
  958.    ToLog("Waiting to get into the game lobby...")
  959.    While 1
  960.       $Array = StringSplit($ImageFiles[6][4],"|")
  961.       $File = $Array[1]
  962.       $Accuracy = $Array[2]
  963.    
  964.       $Target = _ImageSearchArea($ImgDir & $File, 1, $ResumeButtonSearchArea[0], $ResumeButtonSearchArea[1], $ResumeButtonSearchArea[2], $ResumeButtonSearchArea[3], $ISx, $ISy, $Accuracy)
  965.       If $Target = 1 Then
  966.          ExitLoop
  967.       Else
  968.          CheckForDeath()
  969.          Sleep(200)
  970.          CheckForDisconnect()
  971.          Sleep(350)
  972.       EndIf
  973.    WEnd  
  974. EndFunc
  975.  
  976. Func InGameplayScreen()
  977.    ToLog("Waiting to get into the game...")
  978.    While 1
  979.       $Array = StringSplit($ImageFiles[6][5],"|")
  980.       $File = $Array[1]
  981.       $Accuracy = $Array[2]
  982.    
  983.       $Target = _ImageSearchArea($ImgDir & $File, 1, $PortalIconSearchArea[0], $PortalIconSearchArea[1], $PortalIconSearchArea[2], $PortalIconSearchArea[3], $ISx, $ISy, $Accuracy)
  984.       If $Target = 1 Then
  985.          $Alive = True
  986.          $DisconnectState = 0
  987.          ExitLoop
  988.       Else
  989.          CheckForDeath()
  990.          Sleep(200)
  991.          CheckForDisconnect()
  992.          Sleep(200)
  993.       EndIf
  994.    WEnd  
  995. EndFunc
  996.  
  997. Func InCellar()
  998.    ToLog("Waiting to get into the cellar...")
  999.    $TimeOutTimer = TimerInit()
  1000.    While 1
  1001.       $Array = StringSplit($ImageFiles[6][2],"|")
  1002.       $File = $Array[1]
  1003.       $Accuracy = $Array[2]
  1004.    
  1005.       $Target = _ImageSearchArea($ImgDir & $File, 1, $CellarNameSearchArea[0], $CellarNameSearchArea[1], $CellarNameSearchArea[2], $CellarNameSearchArea[3], $ISx, $ISy, $Accuracy)
  1006.       If $Target = 1 Then
  1007.          ExitLoop
  1008.       Else
  1009.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 7 Then
  1010.             ToLog("TimeOut - Leaving")
  1011.             LeaveGame()
  1012.          EndIf
  1013.          CheckForDeath()
  1014.          Sleep(200)
  1015.          CheckForDisconnect()
  1016.          Sleep(200)
  1017.       EndIf
  1018.    WEnd
  1019. EndFunc
  1020.  
  1021. Func InTown()
  1022.    ToLog("Waiting to get into the town...")
  1023.    $TimeOutTimer = TimerInit()
  1024.    While 1
  1025.       $Array = StringSplit($ImageFiles[6][3],"|")
  1026.       $File = $Array[1]
  1027.       $Accuracy = $Array[2]
  1028.    
  1029.       $Target = _ImageSearchArea($ImgDir & $File, 1, $TownNameSearchArea[0], $TownNameSearchArea[1], $TownNameSearchArea[2], $TownNameSearchArea[3], $ISx, $ISy, $Accuracy)
  1030.       If $Target = 1 Then
  1031.          ExitLoop
  1032.       Else
  1033.          If Floor(TimerDiff($TimeOutTimer) / 1000) >= 7 Then
  1034.             ToLog("TimeOut - Trying to teleport again")
  1035.             TeleportToTown()
  1036.          EndIf
  1037.          CheckForDeath()
  1038.          Sleep(200)
  1039.          CheckForDisconnect()
  1040.          Sleep(200)
  1041.       EndIf
  1042.    WEnd  
  1043. EndFunc
  1044.  
  1045. Func CheckForDisconnect()
  1046.    $Array = StringSplit($ImageFiles[6][0],"|")
  1047.    $File = $Array[1]
  1048.    $Accuracy = $Array[2]
  1049.    
  1050.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, $Accuracy)
  1051.    If $Target = 1 Then
  1052.       ToLog("We got disconnected")
  1053.       $Disconnects+=1
  1054.       RefreshStats()
  1055.       $DisconnectState = 1
  1056.      
  1057.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1058.       InGameLobby()
  1059.    EndIf
  1060.    
  1061.    $Array = StringSplit($ImageFiles[6][1],"|")
  1062.    $File = $Array[1]
  1063.    $Accuracy = $Array[2]
  1064.    
  1065.    $Target = _ImageSearchArea($ImgDir & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
  1066.    If $Target = 1 Then
  1067.       ToLog("We got... totally disconnected")
  1068.       If $DisconnectState = 0 Then
  1069.          $Disconnects+=1
  1070.          RefreshStats()
  1071.       EndIf
  1072.       $DisconnectState = 2
  1073.      
  1074.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  1075.       InLoginScreen()  
  1076.    EndIf
  1077.    
  1078.    If $DisconnectState = 2 Then
  1079.       If $UseRelogging = True Then
  1080.          Relog()
  1081.       Else
  1082.          Terminate()
  1083.       EndIf
  1084.    EndIf
  1085. EndFunc
  1086.  
  1087. Func CheckForDeath()
  1088.    If $Alive = True Then
  1089.       $Death = PixelSearch($DeathSearchArea[0], $DeathSearchArea[1], $DeathSearchArea[2], $DeathSearchArea[3], 0xFFFFFF)
  1090.       If Not @error Then
  1091.          $Alive = False
  1092.          ToLog("We are dead... :(")
  1093.          $Deaths+=1
  1094.          RefreshStats()
  1095.          LeaveGame()
  1096.       EndIf
  1097.    EndIf
  1098. EndFunc
  1099.  
  1100.  
  1101. ;Miscellaneous
  1102. Func ScriptStarted()
  1103.    Pause()
  1104.    
  1105.    $Timer = TimerInit()
  1106.    
  1107.    If $ShowLootArea = True Then
  1108.       DrawLootArea()   
  1109.    EndIf
  1110.    
  1111.    If $ShowLog = True Then
  1112.       $Log = FileOpen($SaveLogsPath & "log.txt", 1)
  1113.       DrawLog()
  1114.    EndIf
  1115.    
  1116.    If $ShowLog = True Or $SaveStats = True Then
  1117.       DirGetSize($SaveLogsPath)
  1118.       If @error= 1 Then
  1119.          DirCreate($SaveLogsPath)
  1120.       EndIf  
  1121.    EndIf
  1122.    
  1123.    ToLog("Bot started")
  1124.    
  1125.    WinActivate('Diablo III')  
  1126. EndFunc
  1127.  
  1128. Func Pause()
  1129.    ToLog("Paused...")
  1130.    $Paused = Not $Paused
  1131.    
  1132.    While $Paused
  1133.       Sleep(100)
  1134.       ToolTip('Paused... Press {PAUSE} to continue...', 850, 0)
  1135.    WEnd
  1136.    
  1137.    ToolTip("")
  1138. EndFunc
  1139.  
  1140. Func DrawLootArea()
  1141.    $LootAreaGUI = GUICreate("", $LootingAreaWidth + 2, $LootingAreaHeight + 2, $LootingArea[0], $LootingArea[1], $WS_POPUP, BitOR($WS_EX_LAYERED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  1142.    GuiSetBkColor(0xABCDEF)
  1143.    _WinAPI_SetLayeredWindowAttributes($LootAreaGUI, 0xABCDEF, 0xA0)
  1144.    WinSetOnTop($LootAreaGUI, "", 1)
  1145.    GuiSetState()
  1146.    $hDC = _WinAPI_GetWindowDC($LootAreaGUI)
  1147.    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x0000FF)
  1148.    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
  1149.    $user32_dll = DllOpen("user32.dll")
  1150.    _WinAPI_DrawLine($hDC, 0, 1, $LootingAreaWidth, 0)
  1151.    _WinAPI_DrawLine($hDC, 1, 0, 0, $LootingAreaHeight)
  1152.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, $LootingAreaWidth, 0)
  1153.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, 0, $LootingAreaHeight)
  1154.    
  1155.    _WinAPI_SetTextColor($hDC, 0x0000FF)
  1156.    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
  1157.    
  1158.    $tRECT = DllStructCreate($tagRect)
  1159.    DllStructSetData($tRECT, "Left", 5)
  1160.    DllStructSetData($tRECT, "Top", 5)
  1161.    DllStructSetData($tRECT, "Right", 250)
  1162.    DllStructSetData($tRECT, "Bottom", 50)
  1163.    
  1164.    _WinAPI_DrawText($hDC, "Loot Area", $tRect, 0)
  1165. EndFunc
  1166.  
  1167. Func DrawLog()
  1168.    $Width = 475
  1169.    $Height = 200
  1170.    $LogGUI = GUICreate("", $Width, $Height, 1920 - $Width - 5, 1080 - $Height - 5, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
  1171.    GuiSetBkColor(0x000000)
  1172.    _WinAPI_SetLayeredWindowAttributes($LogGUI, 0xEEEEEF, 0xEE) ;0xA0
  1173.    WinSetOnTop($LogGUI, "", 1)
  1174.    GuiSetState()
  1175.    
  1176.    $Label = GUICtrlCreateLabel("", 0, 10, $Width, 100, $SS_CENTER)
  1177.    GUICtrlSetFont($Label, 8, 500, 0, "")
  1178.    GuiCtrlSetColor($Label, 0xFFFFFF)
  1179.    
  1180.    $LogList = GUICtrlCreateList("", 5, 60, $Width - 10, $Height - 60, $LBS_NOSEL)
  1181.    GUICtrlSetColor($LogList, 0x000000)
  1182.    GUICtrlSetFont($LogList, 8)
  1183.    
  1184.    RefreshStats()
  1185. EndFunc
  1186.  
  1187. Func RefreshStats()
  1188.    If $ShowLog = True Then
  1189.       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)
  1190.    EndIf
  1191. EndFunc
  1192.  
  1193. Func ToLog($Text)
  1194.    If $ShowLog = True Then
  1195.       GUICtrlSetData($LogList, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  1196.       GUICtrlSendMsg($LogList, $WM_VSCROLL, $SB_LINEDOWN, 0)
  1197.    
  1198.       FileWriteLine($Log, "<" & @Hour & ":" & @MIN & ":" & @SEC & "> " & $Text)
  1199.       If $Text = "Bot closed" Then
  1200.          FileWriteLine($Log, @LF)  
  1201.       EndIf
  1202.    EndIf
  1203. EndFunc
  1204.  
  1205. Func Relog()
  1206.    ToLog("Relogging...")
  1207.    MouseClick("LEFT", $PasswordField[0], $PasswordField[1], 1, 5)
  1208.    Send($Password)
  1209.    
  1210.    Sleep(1000 + $Computerlag)
  1211.    Send("{ENTER}")
  1212.    
  1213.    $DisconnectState = 0
  1214.    Bot()
  1215. EndFunc
  1216.  
  1217. Func SaveStats()
  1218.    $File = FileOpen($SaveLogsPath & "statistics.txt", 1)
  1219.    FileWriteLine($File, "=========" & @HOUR & ":" & @MIN & ":" & @SEC & "=========")
  1220.    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)
  1221.    FileWriteLine($File, @LF)
  1222.    FileClose($File)
  1223. EndFunc
  1224.  
  1225. Func Move($x, $y)
  1226.    MouseClick('MIDDLE', $x, $y, 1, 5)
  1227. EndFunc
  1228.  
  1229. Func Attack($x, $y)
  1230.    Send("{SHIFTDOWN}")
  1231.    MouseClick('LEFT', $x, $y, 1, 2)
  1232.    Send("{SHIFTUP}")
  1233. EndFunc
  1234.  
  1235. Func AttackNearbyMonsters()
  1236.    While 1
  1237.       $MonsterData =  PixelSearch($CharHitBox[0], $CharHitBox[1], $CharHitBox[2], $CharHitBox[3], 0xEE0000, 10)
  1238.       If @error Then
  1239.          ExitLoop
  1240.       EndIf
  1241.       ToLog("Maybe not all monsters are dead...")
  1242.       Send("{4}")
  1243.       Sleep(300)
  1244.      
  1245.       For $i = 10 To 0 step -1
  1246.          Attack($MonsterData[0], $MonsterData[1])
  1247.          Sleep(150)
  1248.       Next
  1249.       ToLog("Hopefully now...")
  1250.    WEnd
  1251. EndFunc
  1252.  
  1253. Func LeaveGame()
  1254.    If $SaveStats = True Then
  1255.          SaveStats()
  1256.    EndIf
  1257.    ToLog("Leaving the game")
  1258.    $Sek     = Floor(TimerDiff($Timer) / 1000)
  1259.    $Min     = Floor($Sek / 60)
  1260.    $Hour    = Floor($Min / 60)
  1261.    $Runtime = $Hour & "h " & ($Min - $Hour * 60) & "m " & ($Sek - $Min * 60) & "s"
  1262.      
  1263.    Sleep(1000 + $ComputerLag)
  1264.    
  1265.    Send("{ESC}")
  1266.    Sleep(200)
  1267.    
  1268.    MouseClick('LEFT', $LeaveButton[0], $LeaveButton[1], 1, 5)
  1269.    Sleep(1250 + $Computerlag)
  1270.    
  1271.    Bot()
  1272. EndFunc
  1273.  
  1274. Func Terminate()
  1275.    ToLog("Terminating... Good bye :)")
  1276.    SaveStats()
  1277.    Exit 0
  1278. EndFunc
  1279.  
  1280. Func _ImageSearchArea($FindImage,$ResultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $Tolerance)
  1281.     If $Tolerance > 0 Then $FindImage = "*" & $Tolerance & " " & $FindImage
  1282.        
  1283.     If @AutoItX64 Then
  1284.          $Result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  1285.       Else
  1286.          $Result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$FindImage)
  1287.       EndIf
  1288.      
  1289.    If $Result = "0" Then Return 0
  1290.      
  1291.    $Array = StringSplit($Result[0],"|")
  1292.    
  1293.    If(UBound($Array) >= 4) Then
  1294.       $x=Int(Number($Array[2]))
  1295.       $y=Int(Number($Array[3]))
  1296.      
  1297.       If $ResultPosition=1 Then
  1298.          $x=$x + Int(Number($Array[4])/2)
  1299.          $y=$y + Int(Number($Array[5])/2)
  1300.       Endif
  1301.       Return 1
  1302.    EndIf
  1303. EndFunc
  1304.  
  1305. Func OnAutoItExit()
  1306.    ToLog("Bot closed")
  1307. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement