Advertisement
zEEneXx

farming_sarkoth_dank_cellar_wd_1.0e_zeenexx

Jun 18th, 2012
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 27.44 KB | None | 0 0
  1. #include <WindowsConstants.au3>
  2. #include <Misc.au3>
  3. #Include <WinAPI.au3>
  4.  
  5. #cs
  6.  
  7.    [Gold/Itemfarming] [AutoIt] Sarkoth Act I Dank Cellar [WD] [Stash, Sell, Repair, +++]
  8.                                     by zEEneXx
  9.                                  
  10.                                   Version: 1.0e
  11.                                
  12.                                  www.ownedcore.com
  13.                  
  14. #ce
  15.  
  16. Global $ImageFiles[6][5]
  17. Global $SoundFiles[6]
  18. Global $PasswordField[2]
  19. Global $ResumeButton[2]
  20. Global $LeaveButton[2]
  21. Global $DisconnectButton[2]
  22. Global $GameLobbyCode[3]
  23. Global $GameScreenCode[3]
  24. Global $MoveToCellar1[2]
  25. Global $MoveToCellar2[2]
  26. Global $MoveToCellar3[2]
  27. Global $MoveInCellar1[2]
  28. Global $MoveInCellar2[2]
  29. Global $MoveToGoldLoot1[2]         
  30. Global $MoveToGoldLoot2[2]         
  31. Global $MoveToGoldLoot3[2] 
  32. Global $MoveToMerchant[2]
  33. Global $MoveToStash1[2]
  34. Global $MoveToStash2[2]
  35. Global $CellarLocation[2]  
  36. Global $MonsterLocation[2]
  37. Global $MerchantLocation[2]
  38. Global $StashLocation[2]
  39. Global $PortalLocation[2]
  40. Global $CharHitBox[4]
  41. Global $MonsterSearchArea[4]
  42. Global $LootingArea[4]
  43. Global $FullBagSearchArea[4]
  44. Global $SellItemsArea[4]
  45. Global $FullStashSearchArea[4]
  46. Global $RepairSearchArea[4]
  47. Global $DeathSearchArea[4]
  48. Global $DisconnectSearchArea[4]
  49. Global $StashBag2[2]
  50. Global $StashBag3[2]
  51. Global $RepairButton[2]
  52. Global $AllItemsButton[2]
  53. Global $CellarOffset
  54. Global $CellarPixel
  55. Global $Paused
  56.  
  57. ;///////////////////////////////////////--CONFIG--////////////////////////////////////////////////////////////////////////////////
  58. ;                                                                                                                               //
  59. ;                                       Important                                                                               //
  60. $ComputerLag        = 0                                         ;Increase this in steps of 400 if you have slow loading times   //
  61. $MoveDelay          = 0                                         ;Increase this in steps of 100 if you have movement issues      //
  62. $LootDelay          = 0                                         ;Increase this in steps of 200 if you have looting issues       //
  63. $ImgDir             = "C:\Program Files (x86)\AutoIt3\pics\"    ;Location of the image folder                                   //
  64. ;                                                                                                                               //
  65. ;                                       Functions                                                                               //
  66. $Repair             = True                                      ;Orders the bot to repair when items are damaged                //
  67. $Sell               = True                                      ;Orders the bot to sell magic items when bag is full            //
  68. $UseStash           = True                                      ;Orders the bot to put gems and rare items into the stash       //
  69. $HighGoldRadius     = False                                     ;Set this to true if you have more than +18 gold radius         //
  70. ;                                                                                                                               //
  71. ;                                     Miscellaneous                                                                             //
  72. $Sounds             = True                                      ;Enable pickup sounds                                           //
  73. $SoundsDir          = "C:\Program Files (x86)\AutoIt3\sounds\"  ;Location of the sounds folder                                  //
  74. $ShowLootArea       = True                                      ;Shows lootarea                                                 //
  75. $ShowStatTooltip    = True                                      ;Shows statistics from current session                          //
  76. $SaveStats          = True                                      ;Saves current statistics to a *.txt file                       //
  77. $SaveStatsPath      = "C:\Program Files (x86)\AutoIt3\logs\"    ;Folder to save the statistics in                               //
  78. ;                                                                                                                               //
  79. ;                                      Relogging                                                                                //                                 
  80. $UseRelogging       = True                                      ;Enable Relogging                                               //
  81. $Password           = "XXXXXXXX"                                ;Your password                                                  //
  82. ;                                                                                                                               //
  83. ;                                                                                                                               //
  84. ;                                        Looting                                                                                //
  85. $LootLegendaries    = True                                      ;Loot legendary items                                           //
  86. $LootSets           = True                                      ;Loot set items                                                 //
  87. $LootRares          = True                                      ;Loot rare items                                                //
  88. $LootMagics         = True                                      ;Loot magic items (includes tomes)                              //
  89. $LootTomes          = True                                      ;Loot tomes                                                     //
  90. $LootGems           = True                                      ;Loot gems                                                      //
  91. ;                                                                                                                               //
  92. ;      <<<Changes below have an significant impact on the needed time for one run>>>                                            //
  93. ;                                                                                                                               //
  94. $RareLootAmount     = 1                                         ;Amount of rare items to loot                                   //
  95. $MagicLootAmount    = 3                                         ;Amount of magic items to loot (including tomes)                //
  96. $TomeLootAmount     = 1                                         ;Amount of tomes to loot                                        //
  97. $GemLootAmount      = 2                                         ;Amount of gems to loot                                         //
  98. ;                                                                                                                               //
  99. $LootingArea[0]     = 570                                       ;Left   (lower -> bigger)                                       //
  100. $LootingArea[1]     = 185                                       ;Top    (lower -> bigger)                                       //
  101. $LootingArea[2]     = 1375                                      ;Right  (higher -> bigger)                                      //
  102. $LootingArea[3]     = 720                                       ;Bot    (higher -> bigger)                                      //
  103. ;                                                                                                                               //
  104. ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  105.  
  106. $ImageFiles[0][0]           = "legendaryA.png|70"
  107. $ImageFiles[0][1]           = "legendaryE.png|70"
  108. $ImageFiles[0][2]           = "legendaryI.png|70"
  109. $ImageFiles[0][3]           = "legendaryO.png|70"
  110. $ImageFiles[0][4]           = "legendaryU.png|70"
  111. $ImageFiles[1][0]           = "setA.png|90"
  112. $ImageFiles[1][1]           = "setE.png|90"
  113. $ImageFiles[1][2]           = "setU.png|90"
  114. $ImageFiles[1][3]           = "setO.png|90"
  115. $ImageFiles[1][4]           = "setI.png|90"
  116. $ImageFiles[2][0]           = "rareA.png|95"
  117. $ImageFiles[2][1]           = "rareE.png|95"
  118. $ImageFiles[2][2]           = "rareI.png|95"
  119. $ImageFiles[2][3]           = "rareO.png|95"
  120. $ImageFiles[2][4]           = "rareU.png|95"
  121. $ImageFiles[3][0]           = "blueA.png|70"
  122. $ImageFiles[3][1]           = "blueE.png|70"
  123. $ImageFiles[3][2]           = "blueI.png|70"
  124. $ImageFiles[3][3]           = "blueO.png|70"
  125. $ImageFiles[3][4]           = "blueU.png|70"
  126. $ImageFiles[4][0]           = "tome.png|140"
  127. $ImageFiles[4][1]           = "uare.png|110"
  128. $ImageFiles[5][0]           = "you.png|100"
  129. $ImageFiles[5][1]           = "sellNew.png|55"
  130. $ImageFiles[5][2]           = "sell1x1.png|20"
  131. $ImageFiles[5][3]           = "sell1x2.png|20"
  132. $ImageFiles[5][4]           = "not.png|120"
  133.  
  134. $SoundFiles[0]              = "legendary.wav"
  135. $SoundFiles[1]              = "set.wav"
  136. $SoundFiles[2]              = "rare.wav"
  137. $SoundFiles[3]              = "magic.wav"
  138. $SoundFiles[4]              = "tome.wav"
  139. $SoundFiles[5]              = "gem.wav"
  140.  
  141. $PasswordField[0]           = 820
  142. $PasswordField[1]           = 705
  143.  
  144. $ResumeButton[0]            = 319
  145. $ResumeButton[1]            = 416
  146.  
  147. $LeaveButton[0]             = 969
  148. $LeaveButton[1]             = 582
  149.  
  150. $DisconnectButton[0]        = 960
  151. $DisconnectButton[1]        = 630
  152.  
  153. $GameLobbyCode[0]           = 319
  154. $GameLobbyCode[1]           = 416
  155. $GameLobbyCode[2]           = 4065536
  156.  
  157. $GameScreenCode[0]          = 1119
  158. $GameScreenCode[1]          = 1044
  159. $GameScreenCode[2]          = 0xDEFDFE
  160.  
  161. $MoveToCellar1[0]           = 500
  162. $MoveToCellar1[1]           = 250
  163. $MoveToCellar2[0]           = 1
  164. $MoveToCellar2[1]           = 370
  165. $MoveToCellar3[0]           = 400
  166. $MoveToCellar3[1]           = 600  
  167.  
  168. $MoveInCellar1[0]           = 116
  169. $MoveInCellar1[1]           = 986          
  170. $MoveInCellar2[0]           = 776
  171. $MoveInCellar2[1]           = 328
  172.  
  173. $MoveToGoldLoot1[0]         = 577
  174. $MoveToGoldLoot1[1]         = 306
  175. $MoveToGoldLoot2[0]         = 1260
  176. $MoveToGoldLoot2[1]         = 351
  177. $MoveToGoldLoot3[0]         = 911
  178. $MoveToGoldLoot3[1]         = 694
  179.  
  180. $MoveToMerchant[0]          = 1690
  181. $MoveToMerchant[1]          = 102
  182.  
  183. $MoveToStash1[0]            = 780
  184. $MoveToStash1[1]            = 950
  185. $MoveToStash2[0]            = 270
  186. $MoveToStash2[1]            = 930
  187.  
  188. $CellarLocation[0]          = 307
  189. $CellarLocation[1]          = 74
  190.  
  191. $MonsterLocation[0]         = 577
  192. $MonsterLocation[1]         = 183
  193.  
  194. $MerchantLocation[0]        = 930
  195. $MerchantLocation[1]        = 136
  196.  
  197. $StashLocation[0]           = 805
  198. $StashLocation[1]           = 430
  199.  
  200. $PortalLocation[0]          = 650
  201. $PortalLocation[1]          = 500
  202.  
  203. $CharHitBox[0]              = 790
  204. $CharHitBox[1]              = 315
  205. $CharHitBox[2]              = 1200
  206. $CharHitBox[3]              = 730
  207.  
  208. $MonsterSearchArea[0]       = 150
  209. $MonsterSearchArea[1]       = 20
  210. $MonsterSearchArea[2]       = 1248
  211. $MonsterSearchArea[3]       = 446
  212.  
  213. $FullBagSearchArea[0]       = 795
  214. $FullBagSearchArea[1]       = 125
  215. $FullBagSearchArea[2]       = 830
  216. $FullBagSearchArea[3]       = 160
  217.  
  218. $SellItemsArea[0]           = 1460
  219. $SellItemsArea[1]           = 585
  220. $SellItemsArea[2]           = 1900
  221. $SellItemsArea[3]           = 875
  222.  
  223. $FullStashSearchArea[0]     = 700
  224. $FullStashSearchArea[1]     = 135
  225. $FullStashSearchArea[2]     = 730
  226. $FullStashSearchArea[3]     = 155
  227.  
  228. $RepairSearchArea[0]        = 1507
  229. $RepairSearchArea[1]        = 36
  230. $RepairSearchArea[2]        = 1512
  231. $RepairSearchArea[3]        = 41
  232.  
  233. $DeathSearchArea[0]         = 538
  234. $DeathSearchArea[1]         = 335
  235. $DeathSearchArea[2]         = 542
  236. $DeathSearchArea[3]         = 339
  237.  
  238. $DisconnectSearchArea[0]    = 840
  239. $DisconnectSearchArea[1]    = 410
  240. $DisconnectSearchArea[2]    = 950
  241. $DisconnectSearchArea[3]    = 440
  242.  
  243. $StashBag2[0]               = 510
  244. $StashBag2[1]               = 360
  245.  
  246. $StashBag3[0]               = 510
  247. $StashBag3[1]               = 490
  248.  
  249. $RepairButton[0]            = 517
  250. $RepairButton[1]            = 483
  251.  
  252. $AllItemsButton[0]          = 223
  253. $AllItemsButton[1]          = 592
  254.  
  255. $CellarOffset               = 33
  256.  
  257. $RareLootAttempts           = 0
  258. $MagicLootAttempts          = 0
  259. $TomeLootAttempts           = 0
  260. $GemLootAttempts            = 0
  261.  
  262. $StartTime                  = @HOUR & ":" & @MIN & " Uhr"
  263. $Runs                       = 0
  264. $Closed                     = 0
  265. $Runtime                    = "0h 0m 0s"
  266. $Disconnects                = 0
  267. $Deaths                     = 0
  268.  
  269. $Legendaries                = 0
  270. $Sets                       = 0
  271. $Rares                      = 0
  272. $Magics                     = 0
  273. $Gems                       = 0
  274. $Tomes                      = 0
  275. $Sold                       = 0
  276.  
  277. $ISx                        = 0
  278. $ISy                        = 0
  279. $StashBag                   = 1
  280. $DisconnectState            = 0
  281. $FullBag                    = False
  282.  
  283. $LootingAreaWidth           = $LootingArea[2] - $LootingArea[0]
  284. $LootingAreaHeight          = $LootingArea[3] - $LootingArea[1]
  285.  
  286. If $ShowLootArea = True Then
  287.    DrawLootArea()  
  288. EndIf    
  289.  
  290. Opt('MouseCoordMode', 2)
  291. Opt('PixelCoordMode', 2)
  292.  
  293. HotKeySet('{PAUSE}', 'Pause')
  294. HotKeySet('{END}', 'Terminate')
  295.  
  296. Pause()
  297. $Timer = TimerInit()
  298.  
  299. If $ShowStatTooltip = True Then
  300.    ToolTip("Start: " & $StartTime & "  |  Runs: " & $Runs & "  |  Closed:  " & $Closed & "  |  Deaths: " & $Deaths & "  |  Disconnects: " & $Disconnects & "  |  Runtime: " & $Runtime & "  |  Legendaries: " & $Legendaries & "  |  Sets: " & $Sets & "  |  Rares: " & $Rares & "  |  Magics: " & $Magics & "  |  Tomes: " & $Tomes & "  |  Gems: " & $Gems & "  |  Sold: " & $Sold, 530, 0)
  301. EndIf
  302.  
  303. WinActivate('Diablo III')
  304. While 1
  305.    If WinActive('Diablo III') Then
  306.    
  307.       While $DisconnectState < 2
  308.       For $i = 18 To 0 step -1
  309.          If InGameLobby() Then
  310.             ExitLoop
  311.          EndIf
  312.          
  313.          Sleep(600)
  314.          If $i == 1 Then
  315.             CheckForDisconnectState()
  316.             Sleep(2000 + $Computerlag)
  317.          EndIf
  318.       Next
  319.      
  320.       if $SaveStats = True Then
  321.          SaveStats()
  322.       EndIf
  323.      
  324.       MouseClick('LEFT', $ResumeButton[0], $ResumeButton[1], 1, 5)
  325.       Sleep(1250 + $Computerlag)
  326.      
  327.       For $i = 20 To 0 step -1
  328.          If InGameplayScreen() Then
  329.             $DisconnectState = 0
  330.             ExitLoop
  331.          EndIf
  332.          
  333.          Sleep(500)
  334.          If $i == 1 Then
  335.             CheckForDisconnectState()
  336.             Sleep(2000 + $Computerlag)
  337.          EndIf
  338.       Next
  339.      
  340.       If $DisconnectState = 2 Then
  341.          If $UseRelogging = True Then
  342.             Relog()
  343.          Else
  344.             Terminate()
  345.          EndIf
  346.       Else
  347.          If $DisconnectState = 0 Then
  348.             ExitLoop
  349.          EndIf
  350.       EndIf
  351.       WEnd
  352.      
  353.       Sleep(200 + $Computerlag)
  354.       Send("{2}")
  355.       Sleep(200 + $Computerlag)
  356.      
  357.       Move($MoveToCellar1[0], $MoveToCellar1[1])
  358.       Sleep(150 + $MoveDelay)
  359.       Send("{4}")
  360.       Sleep(500)
  361.       Move($MoveToCellar2[0], $MoveToCellar2[1])
  362.       Sleep(900 + $MoveDelay)
  363.       Move($MoveToCellar3[0], $MoveToCellar3[1])
  364.      
  365.       MouseMove($CellarLocation[0], $CellarLocation[1], 5)
  366.       Sleep(400 + $MoveDelay)
  367.      
  368.       $CellarPixel = PixelSearch($CellarLocation[0]-$CellarOffset, $CellarLocation[1]-$CellarOffset, $CellarLocation[0]+4, $CellarLocation[1]+4, 0x334FB7, 6)
  369.       If @error Then
  370.          Sleep(200 + $Computerlag)
  371.          MouseClick('RIGHT')
  372.          Sleep(400 + $Computerlag)
  373.          $Closed+=1
  374.          Send("{t}")
  375.          Sleep(6500 + $Computerlag)
  376.          LeaveGame()
  377.          ContinueLoop
  378.       EndIf
  379.      
  380.       MouseClick('LEFT', $CellarLocation[0], $CellarLocation[1], 1, 5)
  381.       Sleep(4450 + $Computerlag)
  382.      
  383.       If CheckForDeath() Then
  384.          ContinueLoop
  385.       EndIf
  386.        
  387.       Move($MoveInCellar1[0], $MoveInCellar1[1])
  388.       Sleep(1100 + $MoveDelay)
  389.       Move($MoveInCellar2[0], $MoveInCellar2[1])
  390.       Sleep(10 + $MoveDelay)
  391.       MouseMove($MonsterLocation[0],$MonsterLocation[1], 5)
  392.       Sleep(150 + $Computerlag)
  393.  
  394.       Send("{1}")
  395.       Sleep(200 + $Computerlag)
  396.       MouseClick('RIGHT')
  397.       Sleep(400 + $Computerlag)
  398.       Send("{3}")
  399.       Sleep(150 + $Computerlag)
  400.      
  401.       While 1
  402.          $MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  403.          If @error Then
  404.             Attack($MonsterLocation[0],$MonsterLocation[1])
  405.             Sleep(850)
  406.             $MonsterBar =  PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
  407.             If @error Then
  408.                ExitLoop
  409.             EndIf
  410.          EndIf
  411.      
  412.          For $i = 7 To 0 step -1
  413.             Attack($MonsterBar[0], $MonsterBar[1])
  414.             Sleep(100)
  415.           Next
  416.       WEnd
  417.      
  418.       If $HighGoldRadius = True Then
  419.          Move($MoveToGoldLoot1[0], $MoveToGoldLoot1[1])
  420.          Sleep(250 + $MoveDelay)
  421.          AttackNearbyMonsters()
  422.       Else
  423.          Move(402, 306)
  424.          Sleep(250 + $MoveDelay)
  425.          AttackNearbyMonsters()
  426.          Move($MoveToGoldLoot2[0], $MoveToGoldLoot2[1])
  427.          Sleep(250 + $MoveDelay)
  428.          AttackNearbyMonsters()
  429.          Move($MoveToGoldLoot3[0], $MoveToGoldLoot3[1])
  430.          Sleep(250 + $MoveDelay)
  431.          AttackNearbyMonsters()
  432.       EndIf
  433.      
  434.       MouseMove(120, 120, 3)
  435.       Sleep(100)
  436.      
  437.       If $LootSets Then
  438.          LootSets()
  439.       EndIf
  440.      
  441.       If $LootLegendaries Then
  442.          LootLegendaries()
  443.       EndIf
  444.      
  445.       If $LootRares Then
  446.          LootRares()
  447.          $RareLootAttempts = 0
  448.       EndIf
  449.      
  450.       If $LootMagics Then
  451.          LootMagics()
  452.          $MagicLootAttempts = 0
  453.       Else
  454.          If $LootTomes Then
  455.             LootTomes()
  456.             $TomesLootAttempts = 0
  457.          EndIf
  458.       EndIf
  459.      
  460.       If $LootGems Then
  461.          LootGems()
  462.          $GemLootAttempts = 0
  463.       EndIf
  464.      
  465.       If CheckForDeath() Then
  466.          ContinueLoop
  467.       EndIf
  468.      
  469.       Sleep(500)
  470.       Send("{t}")
  471.       Sleep(7000 + $Computerlag)
  472.      
  473.       If $Repair Then
  474.          RepairItems()
  475.       EndIf
  476.      
  477.       LeaveGame()
  478.       Sleep(1000 + $Computerlag)
  479.    EndIf
  480. WEnd
  481.  
  482.  
  483. ;Loot
  484. Func LootLegendaries()
  485.    For $gI = 0 to 4
  486.       $array = StringSplit($ImageFiles[0][$gI],"|")
  487.       $file = $array[1]
  488.       $accuracy = $array[2]
  489.    
  490.       $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  491.       If $target = 1 Then
  492.          If $Sounds = True Then
  493.             SoundPlay($SoundsDir & $SoundFiles[0], 0)
  494.          EndIf
  495.          $Legendaries+=1
  496.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  497.          Sleep(800 + $LootDelay)
  498.          MouseMove(120, 120, 3)
  499.          Sleep(100)
  500.          If $Sell = True Then
  501.             CheckBagFull()
  502.             If $FullBag = True Then
  503.             $FullBag = False
  504.             Sleep(300)
  505.             LootLegendaries()
  506.             EndIf
  507.          EndIf
  508.       EndIf
  509.    Next
  510. EndFunc
  511.  
  512. Func LootSets()
  513.    For $gI = 0 to 4
  514.       $array = StringSplit($ImageFiles[1][$gI],"|")
  515.       $file = $array[1]
  516.       $accuracy = $array[2]
  517.    
  518.       $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  519.       If $target = 1 Then
  520.          If $Sounds = True Then
  521.             SoundPlay($SoundsDir & $SoundFiles[1], 0)
  522.          EndIf
  523.          $Sets+=1
  524.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  525.          Sleep(800 + $LootDelay)
  526.          MouseMove(120, 120, 3)
  527.          Sleep(100)
  528.          If $Sell = True Then
  529.             CheckBagFull()
  530.             If $FullBag = True Then
  531.                $FullBag = False
  532.                Sleep(300)
  533.                LootSets()
  534.             EndIf
  535.          EndIf
  536.       EndIf
  537.    Next  
  538. EndFunc
  539.  
  540. Func LootRares()
  541.    For $gI = 0 to 4
  542.       $array = StringSplit($ImageFiles[2][$gI],"|")
  543.       $file = $array[1]
  544.       $accuracy = $array[2]
  545.    
  546.       $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  547.       If $target = 1 Then
  548.          If $Sounds = True Then
  549.             SoundPlay($SoundsDir & $SoundFiles[2], 0)
  550.          EndIf
  551.          $Rares+=1
  552.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  553.          Sleep(700 + $LootDelay)
  554.          MouseMove(120, 120, 3)
  555.          Sleep(100)
  556.          If $Sell = True Then
  557.             CheckBagFull()
  558.             If $FullBag = True Then
  559.                $FullBag = False
  560.                Sleep(300)
  561.                LootRares()
  562.             EndIf
  563.          EndIf
  564.          ExitLoop
  565.       EndIf
  566.    Next
  567.        
  568.    $RareLootAttempts+=1    
  569.          
  570.    If($RareLootAttempts >= $RareLootAmount) Then
  571.       Return
  572.    Else
  573.       LootRares()
  574.    EndIf
  575. EndFunc
  576.  
  577. Func LootMagics()
  578.    For $gI = 0 to 4
  579.       $array = StringSplit($ImageFiles[3][$gI],"|")
  580.       $file = $array[1]
  581.       $accuracy = $array[2]
  582.    
  583.       $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  584.       If $target = 1 Then
  585.          If $Sounds = True Then
  586.             SoundPlay($SoundsDir & $SoundFiles[3], 0)
  587.          EndIf
  588.          $Magics+=1
  589.          MouseClick("LEFT", $ISx, $ISy, 1, 4)
  590.          Sleep(700 + $LootDelay)
  591.          MouseMove(120, 120, 3)
  592.          Sleep(100)
  593.          If $Sell = True Then
  594.             CheckBagFull()
  595.             If $FullBag = True Then
  596.                $FullBag = False
  597.                Sleep(300)
  598.                LootMagics()
  599.             EndIf
  600.          EndIf
  601.          ExitLoop
  602.       EndIf
  603.    Next
  604.  
  605.    $MagicLootAttempts+=1
  606.    
  607.    If($MagicLootAttempts >= $MagicLootAmount) Then
  608.       Return
  609.    Else
  610.       LootMagics()
  611.    EndIf
  612. EndFunc
  613.  
  614. Func LootTomes()
  615.    $array = StringSplit($ImageFiles[4][0],"|")
  616.    $file = $array[1]
  617.    $accuracy = $array[2]
  618.    
  619.    $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  620.    If $target = 1 Then
  621.       If $Sounds = True Then
  622.             SoundPlay($SoundsDir & $SoundFiles[4], 0)
  623.          EndIf
  624.       $Tomes+=1
  625.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  626.       Sleep(700 + $LootDelay)
  627.       MouseMove(120, 120, 3)
  628.       Sleep(100)
  629.       If $Sell = True Then
  630.          CheckBagFull()
  631.          If $FullBag = True Then
  632.             $FullBag = False
  633.             Sleep(300)
  634.             LootTomes()
  635.          EndIf
  636.       EndIf
  637.    EndIf
  638.    
  639.    $TomeLootAttempts+=1
  640.          
  641.    If($TomeLootAttempts >= $TomeLootAmount) Then
  642.       Return
  643.    Else
  644.       LootTomes()
  645.    EndIf
  646. EndFunc
  647.    
  648. Func LootGems()
  649.    $array = StringSplit($ImageFiles[4][1],"|")
  650.    $file = $array[1]
  651.    $accuracy = $array[2]
  652.    
  653.    $target = _ImageSearchArea($ImgDir & $file, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $accuracy)
  654.    If $target = 1 Then
  655.       If $Sounds = True Then
  656.             SoundPlay($SoundsDir & $SoundFiles[5], 0)
  657.          EndIf
  658.       $Gems+=1
  659.       MouseClick("LEFT", $ISx, $ISy, 1, 4)
  660.       Sleep(700 + $LootDelay)
  661.       MouseMove(120, 120, 3)
  662.       Sleep(100)
  663.       If $Sell = True Then
  664.          CheckBagFull()
  665.          If $FullBag = True Then
  666.             $FullBag = False
  667.             Sleep(300)
  668.             LootGems()
  669.          EndIf
  670.       EndIf
  671.    EndIf
  672.    
  673.    $GemLootAttempts+=1
  674.          
  675.    If($GemLootAttempts >= $GemLootAmount) Then
  676.       Return
  677.    Else
  678.       LootGems()
  679.    EndIf
  680. EndFunc
  681.  
  682.  
  683. ;Sell, store and repair
  684. Func CheckBagFull()
  685.    $array = StringSplit($ImageFiles[5][0],"|")
  686.    $file = $array[1]
  687.    $accuracy = $array[2]
  688.    
  689.    $target = _ImageSearchArea($ImgDir & $file, 1, $FullBagSearchArea[0], $FullBagSearchArea[1], $FullBagSearchArea[2], $FullBagSearchArea[3], $ISx, $ISy, $accuracy)
  690.    If $target = 1 Then
  691.       $FullBag = True
  692.       SellItems()
  693.    EndIf
  694. EndFunc
  695.  
  696. Func SellItems()
  697.    Sleep(750)
  698.    Send("{t}")
  699.    Sleep(7000 + $Computerlag)
  700.    Move($MoveToMerchant[0] , $MoveToMerchant[1])
  701.    Sleep(2500 + $MoveDelay)
  702.    MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 10)
  703.    Sleep(2250 + $MoveDelay)
  704.    
  705.    For $gI = 1 to 3
  706.       $array = StringSplit($ImageFiles[5][$gI],"|")
  707.       $file = $array[1]
  708.       $accuracy = $array[2]
  709.  
  710.       For $i = 40 To 0 step -1
  711.          $target = _ImageSearchArea($ImgDir & $file, 1, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $accuracy)
  712.          If $target = 1 Then
  713.             $Sold+=1
  714.             MouseClick("RIGHT", $ISx, $ISy, 1, 0)
  715.             Sleep(250)
  716.          EndIf
  717.       Next
  718.    Next
  719.    
  720.    $RareLootAttempts    = 0
  721.    $MagicLootAttempts   = 0
  722.    $TomeLootAttempts    = 0
  723.    $GemLootAttempts     = 0
  724.    
  725.    Move($MoveToStash1[0] , $MoveToStash1[1])
  726.    Sleep(800 + $MoveDelay)
  727.    Move($MoveToStash2[0] , $MoveToStash2[1])
  728.    Sleep(1200 + $MoveDelay)
  729.    If $UseStash = True Then
  730.       $StashBag = 1
  731.       ToStash()
  732.       Sleep(200)
  733.       Send("{ESC}")
  734.    EndIf
  735.    Sleep(700)
  736.    MouseClick("LEFT", $PortalLocation[0], $PortalLocation[1], 1, 10)
  737.    Sleep(3000 + $Computerlag)
  738. EndFunc
  739.  
  740. Func ToStash()
  741.    Sleep(300)
  742.    MouseClick("LEFT", $StashLocation[0], $StashLocation[1], 1, 10)
  743.    Sleep(500)
  744.    
  745.    For $x = 0 to 5 step + 1
  746.       $xC = 1527
  747.       For $i = -1 To 8 step + 1
  748.          MouseClick("RIGHT", $xC + ($i*47), 610 + ($x*50), 1, 0)
  749.          Sleep(25)
  750.          If CheckStashFull() = 1 Then
  751.             if($i>0) Then
  752.                $xC-=47
  753.             EndIf
  754.             $i-=1
  755.          EndIf
  756.          If $UseStash = False Then
  757.             ExitLoop (2)
  758.          EndIf
  759.       Next
  760.    Next
  761. EndFunc
  762.  
  763. Func CheckStashFull()
  764.    $array = StringSplit($ImageFiles[5][4],"|")
  765.    $file = $array[1]
  766.    $accuracy = $array[2]
  767.    
  768.    $target = _ImageSearchArea($ImgDir & $file, 1, $FullStashSearchArea[0], $FullStashSearchArea[1], $FullStashSearchArea[2], $FullStashSearchArea[3], $ISx, $ISy, $accuracy)
  769.    If $target = 1 Then
  770.       Switch $StashBag
  771.       Case 1
  772.          Sleep(200)
  773.          MouseClick("LEFT", $StashBag2[0], $StashBag2[1], 1, 5)
  774.          $StashBag = 2
  775.          Sleep(5000)
  776.       Case 2
  777.          Sleep(200)
  778.          MouseClick("LEFT", $StashBag3[0], $StashBag3[1], 1, 5)
  779.          $StashBag = 3
  780.          Sleep(5000)
  781.       Case 3
  782.          $UseStash = False
  783.       EndSwitch
  784.       Return 1
  785.    EndIf
  786.    Return 0
  787. EndFunc
  788.  
  789. Func RepairItems()
  790.    If Not CheckForRepair() Then
  791.       Return
  792.    EndIf
  793.    Move($MoveToMerchant[0] , $MoveToMerchant[1])
  794.    Sleep(2500 + $MoveDelay)
  795.    MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 10)
  796.    Sleep(2500 + $MoveDelay)
  797.    MouseClick('LEFT', $RepairButton[0], $RepairButton[1], 1, 5)
  798.    Sleep(500)
  799.    MouseClick('LEFT', $AllItemsButton[0], $AllItemsButton[1], 1, 5)
  800.    Sleep(500)
  801.    Send("{ESC}")
  802. EndFunc
  803.  
  804. Func CheckForRepair()
  805.    $RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xFFE801,10)
  806.    If Not @error Then
  807.       Return True
  808.    Else
  809.       Return False
  810.    EndIf
  811. EndFunc
  812.  
  813.  
  814. ;Check gamestate, death and disconnect
  815. Func InGameLobby()
  816.     PixelSearch($GameLobbyCode[0], $GameLobbyCode[1], $GameLobbyCode[0]+10, $GameLobbyCode[1]+10, $GameLobbyCode[2], 10)
  817.     If Not @error Then
  818.        Return True
  819.     Else
  820.        Return False
  821.    EndIf
  822. EndFunc
  823.  
  824. Func InGameplayScreen()
  825.     PixelSearch($GameScreenCode[0], $GameScreenCode[1], $GameScreenCode[0]+4, $GameScreenCode[1]+3, $GameScreenCode[2], 10)
  826.     If Not @error Then
  827.        Return True
  828.     Else
  829.        Return False
  830.    EndIf
  831. EndFunc
  832.  
  833. Func CheckForDeath()
  834.    $Death = PixelSearch($DeathSearchArea[0], $DeathSearchArea[1], $DeathSearchArea[2], $DeathSearchArea[3], 0xFFFFFF)
  835.    If Not @error Then
  836.       $Deaths+=1
  837.       LeaveGame()
  838.       Sleep(12000 + $Computerlag)
  839.       Return True
  840.    Else
  841.       Return False
  842.    EndIf
  843. EndFunc
  844.  
  845. Func CheckForDisconnectState()
  846.    $target = _ImageSearchArea($ImgDir & "network.png", 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
  847.    If $target = 1 Then
  848.       $Disconnects+=1
  849.       $DisconnectState = 1
  850.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  851.       Sleep(3000 + $Computerlag)
  852.    EndIf
  853.    
  854.    $target = _ImageSearchArea($ImgDir & "lost.png", 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
  855.    If $target = 1 Then
  856.       If $DisconnectState = 0 Then
  857.          $Disconnects+=1
  858.       EndIf
  859.       $DisconnectState = 2
  860.       MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 5)
  861.       Sleep(3000 + $Computerlag)   
  862.    EndIf
  863. EndFunc
  864.  
  865. Func Relog()
  866.    MouseClick("LEFT", $PasswordField[0], $PasswordField[1], 1, 5)
  867.    Send($Password)
  868.    Sleep(1000 + $Computerlag)
  869.    Send("{ENTER}")
  870.    Sleep(8000 + $Computerlag)
  871.    $DisconnectState = 0
  872. EndFunc
  873.  
  874.  
  875. ;Miscellaneous
  876. Func AttackNearbyMonsters()
  877.    While 1
  878.       $MonsterData =  PixelSearch($CharHitBox[0], $CharHitBox[1], $CharHitBox[2], $CharHitBox[3], 0xEE0000, 10)
  879.       If @error Then
  880.          ExitLoop
  881.       EndIf
  882.       Send("{4}")
  883.       Sleep(300)
  884.       For $i = 10 To 0 step -1
  885.          Attack($MonsterData[0], $MonsterData[1])
  886.          Sleep(150)
  887.       Next
  888.    WEnd
  889. EndFunc
  890.  
  891. Func Attack($x, $y)
  892.    Send("{SHIFTDOWN}")
  893.    MouseClick('LEFT', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, 0)
  894.    Send("{SHIFTUP}")
  895. EndFunc
  896.  
  897. Func Move($x, $y)
  898.    MouseClick('MIDDLE', $x, $y, 1, 5)
  899.    Sleep(1250)
  900. EndFunc
  901.  
  902. Func SaveStats()
  903.    DirGetSize($SaveStatsPath)
  904.    If @error= 1 Then
  905.       DirCreate($SaveStatsPath)
  906.    EndIf
  907.    $File = FileOpen($SaveStatsPath & "statistics.txt", 2)
  908.    FileWriteLine($File, "=========" & @HOUR & ":" & @MIN & ":" & @SEC & "=========")
  909.    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)
  910.    FileClose($File)
  911. EndFunc
  912.  
  913. Func DrawLootArea()
  914.    $hFullScreen = WinGetHandle("Program Manager")
  915.    $hGUI = GUICreate("", $LootingAreaWidth + 2, $LootingAreaHeight + 2, $LootingArea[0], $LootingArea[1], $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TRANSPARENT))
  916.    GuiSetBkColor(0xABCDEF)
  917.    _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 0xA0)
  918.    WinSetOnTop($hGUI, "", 1)
  919.    GuiSetState()
  920.    $hDC = _WinAPI_GetWindowDC($hGUI)
  921.    $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x0000FF)
  922.    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)
  923.    $user32_dll = DllOpen("user32.dll")
  924.    _WinAPI_DrawLine($hDC, 0, 1, $LootingAreaWidth, 0)
  925.    _WinAPI_DrawLine($hDC, 1, 0, 0, $LootingAreaHeight)
  926.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, $LootingAreaWidth, 0)
  927.    _WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, 0, $LootingAreaHeight)
  928. EndFunc
  929.  
  930. Func LeaveGame()
  931.    $Runs+=1
  932.    $Sek     = Floor(TimerDIff($Timer) / 1000)
  933.    $Min     = Floor($Sek / 60)
  934.    $Hour    = Floor($Min / 60)
  935.    $Runtime = $Hour & "h " & ($Min-$Hour*60) & "m " & ($Sek-$Min*60) & "s"
  936.    If $ShowStatTooltip = True Then
  937.       ToolTip("Start: " & $StartTime & "  |  Runs: " & $Runs & "  |  Closed:  " & $Closed & "  |  Deaths: " & $Deaths & "  |  Disconnects: " & $Disconnects & "  |  Runtime: " & $Runtime & "  |  Legendaries: " & $Legendaries & "  |  Sets: " & $Sets & "  |  Rares: " & $Rares & "  |  Magics: " & $Magics & "  |  Tomes: " & $Tomes & "  |  Gems: " & $Gems & "  |  Sold: " & $Sold, 530, 0)
  938.    EndIf
  939.    Send("{ESC}")
  940.    Sleep(200)
  941.    MouseClick('LEFT', $LeaveButton[0], $LeaveButton[1], 1, 5)
  942.    Sleep(1250 + $Computerlag)
  943. EndFunc
  944.  
  945. Func Pause()
  946.    $Paused = Not $Paused
  947.    While $Paused
  948.       Sleep(100)
  949.       ToolTip('Paused... Press {PAUSE} to continue...', 850, 0)
  950.    WEnd
  951.    If $ShowStatTooltip = True Then
  952.       ToolTip("Start: " & $StartTime & "  |  Runs: " & $Runs & "  |  Closed:  " & $Closed & "  |  Deaths: " & $Deaths & "  |  Disconnects: " & $Disconnects & "  |  Runtime: " & $Runtime & "  |  Legendaries: " & $Legendaries & "  |  Sets: " & $Sets & "  |  Rares: " & $Rares & "  |  Magics: " & $Magics & "  |  Tomes: " & $Tomes & "  |  Gems: " & $Gems & "  |  Sold: " & $Sold, 530, 0)
  953.    Else
  954.       ToolTip("")
  955.    EndIf
  956. EndFunc
  957.  
  958. Func Terminate()
  959.    SaveStats()
  960.    Exit 0
  961. EndFunc
  962.  
  963. Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
  964.     If $tolerance>0 Then $findImage = "*" & $tolerance & " " & $findImage
  965.    
  966.     If @AutoItX64 Then
  967.          $result = DllCall("ImageSearchDLL_x64.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  968.       Else
  969.          $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
  970.    EndIf
  971.    
  972.     If $result = "0" Then Return 0
  973.  
  974.    $array = StringSplit($result[0],"|")
  975.    If(UBound($array) >= 4) Then
  976.       $x=Int(Number($array[2]))
  977.       $y=Int(Number($array[3]))
  978.       If $resultPosition=1 Then
  979.          $x=$x + Int(Number($array[4])/2)
  980.          $y=$y + Int(Number($array[5])/2)
  981.       Endif
  982.       Return 1
  983.    EndIf
  984. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement