Advertisement
Avatar88343

Witch Doctor Farming Bot - Act 1 cellar (0.4)

Jun 11th, 2012
5,768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 23.08 KB | None | 0 0
  1. #cs
  2.       Witch Doctor Cellar Farming Bot - Version 0.4[1920x1080 AND 800x600]
  3.       Developed by Avatar88343 @ Ownedcore
  4.       Note: I rushed to put this online so the source is still very messy. I have snippets of code that is no longer used
  5.       and if statements that check for nothing. It will all be cleaned up in 0.4
  6.      
  7.      
  8.       What it does:
  9.             *This bot will travel to the cellar in Act 1, kill the mobs, collect the gold and items, and repair your gear.
  10.      
  11.      
  12.       Newbiew Info:
  13.       This is a script that runs on AutoIt. You run this bot by Downloading AutoIt from the web (it's free) and installing it.
  14.       You then paste all this code into any text editor (such as notepad) and save it anywhere on your hard drive. Follow the Select
  15.       steps below to configure this bot before you run it.
  16.      
  17.        Special Instructions for 1920 x 1080:
  18.        1.) Set your game resolution to 1920x1080 (required)
  19.        2.) Set the display mode to Fullscreen Windowed (Don't forget!)
  20.        3.) Follow the Instructions (for all resolutions) section below
  21.        
  22.        Special Instructions for 800 x 600:
  23.  
  24.        1.)Exit Diablo 3
  25.        2.)Go to your document folder and locate the Diablo III folder
  26.        3.)Open the D3Prefs file in any editor (such as notepad)
  27.        4.)Change the following settings to the ones listed below
  28.        "DisplayModeFlags "0"
  29.        DisplayModeWindowMode "1"
  30.        DisplayModeWinLeft "428"
  31.        DisplayModeWinTop "162"
  32.        DisplayModeWinWidth "800"
  33.        DisplayModeWinHeight "600"
  34.        DisplayModeUIOptWidth "800"
  35.        DisplayModeUIOptHeight "600"
  36.        DisplayModeWidth "800"
  37.        DisplayModeHeight "600"
  38.        DisplayModeRefreshRate "75"
  39.        DisplayModeBitDepth "32""
  40.        5.) Follow the Instructions (for all resolutions) section below
  41.        
  42.      
  43.       Instructions (for all resolutions)
  44.             1.) Bind your middle mouse button to Move (found in Key Bindings Option)
  45.             2.) Set your build to this http://us.battle.net/d3/en/calculator/witch-doctor#jaQPiU!VZW!babbZa
  46.             3.) Start Act 1, Quest 6 - Talk to Alaric
  47.             4.) Hire the Scoundrel
  48.             5.) Teleport to The Old Ruins using the waypoint and run left until you reach a checkpoint
  49.             6.) Log out of the game
  50.             7.) Press Space to start the bot! Space is used to pause and resume the bot
  51.             8.) Press Z to turn off the bot
  52.      
  53.       NOTE:
  54.             *Please make sure you are running the correct resolution settings!
  55.             *You must be running the game in Fullscreen Windoed mode if you're using 1080P
  56.             *You WILL need to edit the values below the comments for better results
  57.      
  58.       FEATURES:
  59.             *Supports 1080P Fullscreen Windowed and 800x600 Windowed
  60.             *Automatic looting of Rare, Legendary, and Set items
  61.             *Repairs Items when damaged
  62.             *Detects death and responds accordingly
  63.             *Able to detect
  64.             *Randomization for increased safety
  65.             *Added ability to find Cellar during bad runs
  66.             *Loots Gems (partly)
  67.      
  68.       IN DEVELOPMENT:
  69.             *Multi-resolution support (very soon)
  70.             *Inventory check and stash use
  71.             *Improved combat
  72.             *Speed improvements
  73.             *Multiple routes to improve safety
  74.             *45 min timeout bug
  75.             *edit d3config
  76.      
  77.      
  78.       **Based on the code by notAres and mackus101. Special thanks to them!
  79. #ce
  80. #include <GUIConstantsEx.au3>
  81. #include <WindowsConstants.au3>
  82. ;======THESE VALUES ARE NOT EDITED WITH THE GUI ===================================
  83. $R              =  0            ;Leave this as 0 if you are using 1080P. Change it to 1 if you're using 800 x 600
  84. $ComputerLag    = 1000          ;Increase this by 100-5000 if you have a slow PC.
  85. $RunSpeed       = 10            ;Enter your character's run speed here
  86. $LootRares      = True          ;Whether or not to loot rare and legendary items
  87. $LootBlues      = True          ;Whether or not to loot blue items
  88. $Repair         = True          ;Orders the bot to repair when items are damaged
  89. $LootGems       = True          ;A bit buggy but works sometimes
  90. $UseStash       = False         ;Not currently supported
  91. ;======================================================================
  92.  
  93. Global $Resume[2][2]            ;Location of the Resume Button         
  94. Global $Leave[2][2]             ;Location of the in-game leave button
  95. Global $GameLobbyCode[2][3]     ;Contains X, Y, and Hex color of Resume button so we can see if we're there
  96. Global $GameScreenCode[2][3]    ;Contains X, Y, and Hex color used to check if we are in an unpaused game
  97. Global $Loc1[2][2]              ;First movement
  98. Global $Loc2[2][2]              ;Second movement
  99. Global $Loc3[2][2]              ;Third movement ttt
  100.  
  101. Global $CellarLocation[2][2]    ;Cellar door location
  102. Global $CellarLocation2[2]      ;Location of cellar during bad runs (ugly workaround for now)
  103. Global $AltCellar = False
  104.  
  105. Global $Loc5[2][2]              ;Cellar hallway
  106. Global $Loc6[2][2]              ;Cellar doorway
  107. Global $MonsterLoc[2][2]        ;Initial boss location
  108. Global $MonsterSearch[2][4]     ;Bounds of where we will find our monsters
  109. Global $GoldLoot1[2][2]         ;First place to run when looting
  110. Global $GoldLoot2[2][2]         ;Second place to run when looting
  111. Global $GoldLoot3[2][2]         ;Third place to run when looting
  112. Global $LootingArea[2][4]       ; looting bounds (TL X, TL Y, BR X, BR Y)
  113. Global $CharHitBox[2][4]        ; Hitbox around user's character
  114. Global $DeathBounds[2][2]       ; Used to detect the "You Have Died" text
  115. Global $RepairCords[2][4][2]    ; Four clicks needed to repair
  116. Global $RepairCheck[2][2]       ; Used to check for repair icon
  117. Global $CellarOffset[2]         ; Used to improve cellar clicking with 1080P/800x600       
  118. Global $CellarIcon              ;Used to find the yellow cellar icon on the minimap (future use)
  119. Global $CellarPixel            
  120. GLobal $GemLootOffset[2]            ;Distance between gem and its text
  121. ActivateGUI()
  122.  
  123. ;Check for people that can't read instructions
  124. if int($R) < 0 OR int($R) > 1 Then
  125.    MsgBox(4096, "A wild illiterate appears appears!" , "Aha! I caught you! You did not read the instructions. You need to configure the bot!")
  126.    terminate()
  127. EndIf
  128.    
  129.  
  130. ;Clculate run speed
  131. Global $RunTime = 30 * (100 - $RunSpeed) + 2000 ;Length of time to run in 800x600
  132.  
  133. ;All locations are N dimensional arrays. [0][x] is for 1080P and [1][x] is for 800x600
  134. ;1080P
  135.  
  136. ;1920x1080
  137. $Resume[0][0] = 319
  138. $Resume[0][1] = 416
  139. $GameLobbyCode[0][0] = 319
  140. $GameLobbyCode[0][1] = 416
  141. $GameLobbyCode[0][2] = 4065536
  142. $GameScreenCode[0][0] = 1119
  143. $GameScreenCode[0][1] = 1044
  144. $GameScreenCode[0][2] = 0xDEFDFE
  145.  
  146. ;800x600
  147. $Resume[1][0] = 174
  148. $Resume[1][1] = 232
  149. $GameLobbyCode[1][0] = 174 
  150. $GameLobbyCode[1][1] = 232
  151. $GameLobbyCode[1][2] = 4262400
  152. $GameScreenCode[1][0] = 486
  153. $GameScreenCode[1][1] = 578
  154. $GameScreenCode[1][2] = 0x6C9BFF
  155.  
  156. ;1920x1080
  157. $Leave[0][0] = 969
  158. $Leave[0][1] = 582
  159.  
  160. ;800x600
  161. $Leave[1][0] = 397
  162. $Leave[1][1] = 322
  163.  
  164. ;1920x1080
  165. $Loc1[0][0]     = 500       ;First movement
  166. $loc1[0][1]     = 250
  167. $loc2[0][0]     = 1         ;Second movement
  168. $loc2[0][1]     = 370
  169. $loc3[0][0]     = 400       ;Third Movement
  170. $loc3[0][1]     = 600      
  171.  
  172. ;800x600
  173. $Loc1[1][0]     = 8         ;First movement
  174. $loc1[1][1]     = 146
  175. $loc2[1][0]     = 7         ;Second movement
  176. $loc2[1][1]     = 300
  177. $loc3[1][0]     = 8         ;Third Movement
  178. $loc3[1][1]     = 300  
  179.  
  180. ;1080P
  181. $CellarLocation[0][0] = 307     ;Cellar door location
  182. $CellarLocation[0][1] = 74
  183. ;800x600
  184. $CellarLocation[1][0] = 499     ;Cellar door location
  185. $CellarLocation[1][1] = 148
  186. $CellarLocation2[0] = 439
  187. $CellarLocation2[1] = 145
  188. $AltCellarLocation = False
  189.  
  190. ;Cellar offset
  191. $CellarOffset[0] = 33;
  192. $CellarOffset[1] = 10;
  193.  
  194. ;1080P
  195. $loc5[0][0]     = 116       ;Walk down hallway 
  196. $loc5[0][1]     = 986          
  197. $loc6[0][0]     = 776       ;enter hallway
  198. $loc6[0][1]     = 328
  199. ;800x600
  200. $loc5[1][0]     = 3         ;Walk down hallway 
  201. $loc5[1][1]     = 504          
  202. $loc6[1][0]     = 255       ;enter hallway
  203. $loc6[1][1]     = 190
  204.  
  205. ;1080P
  206. $MonsterLoc[0][0] = 577
  207. $MonsterLoc[0][1] = 183
  208. ;800x600
  209. $MonsterLoc[1][0] = 188
  210. $MonsterLoc[1][1] = 111
  211.  
  212. ;1920x1080
  213. $MonsterSearch[0][0] = 162
  214. $MonsterSearch[0][1] = 29
  215. $MonsterSearch[0][2] = 1248
  216. $MonsterSearch[0][3] = 446
  217. ;800x600
  218. $MonsterSearch[1][0] = 40
  219. $MonsterSearch[1][1] = 53
  220. $MonsterSearch[1][2] = 424
  221. $MonsterSearch[1][3] = 191
  222.  
  223. ;1920x1080
  224. $GoldLoot1[0][0] = 402
  225. $GoldLoot1[0][1] = 306
  226. $GoldLoot2[0][0] = 1260
  227. $GoldLoot2[0][1] = 351
  228. $GoldLoot3[0][0] = 911
  229. $GoldLoot3[0][1] = 694
  230. ;800x600
  231. $GoldLoot1[1][0] = 96
  232. $GoldLoot1[1][1] = 181
  233. $GoldLoot2[1][0] = 560
  234. $GoldLoot2[1][1] = 191
  235. $GoldLoot3[1][0] = 349
  236. $GoldLoot3[1][1] = 418
  237.  
  238. ;1080P
  239. $LootingArea[0][0] = 318;550
  240. $LootingArea[0][1] = 150;300
  241. $LootingArea[0][2] = 1507;1100
  242. $LootingArea[0][3] = 736;600
  243. ;800x600
  244. $LootingArea[1][0] = 75
  245. $LootingArea[1][1] = 90
  246. $LootingArea[1][2] = 630
  247. $LootingArea[1][3] = 400
  248.  
  249. ;1080P
  250. $CharHitBox[0][0] = 790
  251. $CharHitBox[0][1] = 315
  252. $CharHitBox[0][2] = 1200
  253. $CharHitBox[0][3] = 730
  254. ;800x600
  255. $CharHitBox[1][0] = 304
  256. $CharHitBox[1][1] = 190
  257. $CharHitBox[1][2] = 468
  258. $CharHitBox[1][3] = 323
  259.  
  260. ;1080P
  261. $DeathBounds[0][0] = 538
  262. $DeathBounds[0][1] = 335
  263. ;800x600
  264. $DeathBounds[1][0] = 210
  265. $DeathBounds[1][1] = 180
  266.  
  267. ;1080P
  268. $RepairCords[0][0][0] = 1690
  269. $RepairCords[0][0][1] = 102
  270. $RepairCords[0][1][0] = 930
  271. $RepairCords[0][1][1] = 136
  272. $RepairCords[0][2][0] = 517
  273. $RepairCords[0][2][1] = 483
  274. $RepairCords[0][3][0] = 223
  275. $RepairCords[0][3][1] = 592
  276. ;800x600
  277. $RepairCords[1][0][0] = 691
  278. $RepairCords[1][0][1] = 88
  279. $RepairCords[1][1][0] = 505
  280. $RepairCords[1][1][1] = 52
  281. $RepairCords[1][2][0] = 282
  282. $RepairCords[1][2][1] = 261
  283. $RepairCords[1][3][0] = 157
  284. $RepairCords[1][3][1] = 329
  285.  
  286. ;1080P
  287. $RepairCheck[0][0] = 1507
  288. $RepairCheck[0][1] = 36
  289. ;800x600
  290. $RepairCheck[1][0] = 573
  291. $RepairCheck[1][1] = 21
  292.  
  293. ;Gem stuff
  294. $Amethyst = 0xAC7FFF
  295. $Ruby = 0xB01D2D
  296. $Emerald = 0x58EE33
  297. $Topaz = 0xFFFF59
  298.  
  299. $GemLootOffset[0] = 100
  300. $GemLootOffset[1] = 40
  301.  
  302.  
  303. HotKeySet("z", "Terminate")
  304.  
  305.  
  306. Func Terminate()
  307.     Exit 0
  308.  EndFunc
  309.  
  310. Opt('MouseCoordMode', 2)
  311. Opt('PixelCoordMode', 2)
  312. HotKeySet('{END}', 'Quit')
  313. HotKeySet('{SPACE}', 'Pause')
  314. Global $Paused
  315.  
  316. ;bot starts paused. press space to start.
  317. Pause()
  318.  
  319. ;Finding loot takes time. We don't want to overdo it
  320. $LootAttempts = 0
  321. $GemLootAttempts = 0
  322.  
  323. WinActivate('Diablo III')
  324. While 1
  325.    If WinActive('Diablo III') Then
  326.      
  327.       $AltCellarLocation = False
  328.       $LootAttempts = 0
  329.       $GemLootAttempts = 0
  330.      
  331.       ;Make sure that we are in the character selection screen ( we are looking at a spot in the Resume game button)
  332.       for $i = 15 To 0 step -1
  333.          if InGameLobby() Then
  334.             ExitLoop
  335.          EndIf
  336.          
  337.          sleep(600)
  338.          if $i == 1 Then
  339.             MsgBox(4096, "Error Resuming Game", "You don't seem to be in the lobby. Did you properly configure the bot? Bot will now exit", 50)
  340.             Terminate()
  341.          EndIf
  342.       Next
  343.      
  344.        ;Resume the game
  345.       Click($Resume[$R][0], $Resume[$R][1])
  346.      
  347.        ;Make sure that we are in the game
  348.       for $i = 12 To 0 step -1
  349.          if InGameplayScreen() Then
  350.             ExitLoop
  351.          EndIf
  352.          
  353.          sleep(1000)
  354.          if $i == 1 Then
  355.             MsgBox(4096, "Error Starting the Game", "The game did not properly load...Are you using English language? Do not use custom themes!", 50)
  356.             Terminate()
  357.          EndIf
  358.       Next
  359.      
  360.        
  361.       Rest(200)
  362.       Send("{2}")              
  363.       Rest(400)
  364.      
  365.       ;Custom running for the 800x600. Sometimes I wonder if it's faster to just buy everyone a 1080P monitor...
  366.       if Int($R) == 1 Then
  367.          MouseMove(11, 220)
  368.          Sleep(400)
  369.          Send("{4}")
  370.          MouseDown("middle")
  371.          Sleep($RunTime)
  372.          
  373.          MouseUp("middle")
  374.          Sleep(2000)
  375.          
  376.          #cs $CellarIcon = PixelSearch(630, 70, 741, 149, 0x71341A, 5)
  377.          if not @error then
  378.             ConsoleWrite("Foundtheseller" & @LF)
  379.            
  380.          EndIf
  381.          #ce
  382.          
  383.      Else
  384.          Move($Loc1[$R][0], $Loc1[$R][1])
  385.          Sleep(200)
  386.          Send("{4}")
  387.          Sleep(700)
  388.          Move($Loc2[$R][0], $Loc2[$R][1])
  389.          Sleep(1100)
  390.          Move($Loc3[$R][0], $Loc3[$R][1])
  391.       EndIf
  392.      
  393.      
  394.       ;Check to see if the cellar is there ```````
  395.       MouseMove($CellarLocation[$R][0], $CellarLocation[$R][1])
  396.       Sleep(400)
  397.       if Int($R) = 1 then
  398.           $CellarPixel = PixelSearch($CellarLocation[$R][0]-30, $CellarLocation[$R][1]-30,$CellarLocation[$R][0]+20,$CellarLocation[$R][1]+20, 0x93D7F9,8)
  399.          
  400.           if @error Then
  401.              MouseMove($CellarLocation2[0], $CellarLocation2[1])
  402.              Sleep(300)
  403.              $CellarPixel = PixelSearch($CellarLocation2[0]-30, $CellarLocation2[1]-30,$CellarLocation2[0]+20,$CellarLocation2[1]+20, 0x93D7F9,8)
  404.              if not @error Then
  405.                 $AltCellarLocation = True
  406.              EndIf
  407.          EndIf
  408.       Else
  409.           $CellarPixel = PixelSearch($CellarLocation[$R][0]-$CellarOffset[$R], $CellarLocation[$R][1]-$CellarOffset[$R],$CellarLocation[$R][0]+4,$CellarLocation[$R][1]+4, 0x334FB7,6)
  410.       EndIf
  411.    
  412.       ;Leave the game if the Cellar is not there
  413.       if @error Then
  414.          ConsoleWrite("Did not find the cellar " & @LF)
  415.          Send("{SHIFTDOWN}")
  416.          sleep(10)
  417.          click(300,300)
  418.          sleep(100)
  419.          Send("{SHIFTUP}")
  420.          leaveGame()
  421.          Sleep(12000)
  422.          ContinueLoop
  423.       EndIf
  424.      
  425.       ;Enter the cellar
  426.       ConsoleWrite("Entering the Cellar..." & @LF)
  427.       if $R > 0 AND $AltCellar Then
  428.          Click($CellarLocation2[$R][0] - 4, $CellarLocation2[$R][1] - 4)
  429.       Else
  430.          if not $AltCellarLocation Then
  431.             Click($CellarLocation[$R][0], $CellarLocation[$R][1])
  432.          Else
  433.             Click($CellarLocation2[0], $CellarLocation2[1])
  434.          EndIf
  435.       endif
  436.      
  437.       if Int($R) == 1 Then
  438.          sleep(500+$ComputerLag)
  439.       Else
  440.          Sleep(2500 + $ComputerLag)
  441.       EndIf
  442.      
  443.        ;Check to see if we died
  444.       if CheckForDeath() Then
  445.          ContinueLoop
  446.       EndIf
  447.        
  448.       ;Inside the celler now - Move to the doorway
  449.       Move($Loc5[$R][0], $Loc5[$R][1])
  450.       Sleep(1500)
  451.       Move($Loc6[$R][0], $Loc6[$R][1])
  452.       sleep(10)
  453.       MouseMove($MonsterLoc[$R][0],$MonsterLoc[$R][1])
  454.       Sleep(300)
  455.  
  456.       ;Cast spell some spells on them
  457.       Send("{3}")
  458.       Sleep(350)
  459.       send("{1}")
  460.       sleep(350)
  461.      
  462.  
  463.       ;Kill all the enemies inside
  464.       while 1
  465.          
  466.          $MonsterBar =  PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
  467.          if @error Then
  468.             ConsoleWrite("Didn't find any, attacking to discover potential enemies" & @LF)
  469.             Attack($MonsterLoc[$R][0],$MonsterLoc[$R][1])
  470.             sleep(500)
  471.             $MonsterBar =  PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
  472.             if @error Then
  473.                ConsoleWrite("No monsters found - Moving on")
  474.                ExitLoop
  475.             EndIf
  476.          EndIf
  477.          
  478.          ;if CheckForNearbyMonsters() Then
  479.             ;send("{4}")
  480.          ;EndIf
  481.          
  482.          for $i = 7 To 0 step -1
  483.             Attack($MonsterBar[0], $MonsterBar[1])
  484.             Sleep(100)
  485.           Next
  486.       WEnd
  487.      
  488.      
  489.       ;Loot the gold and attack anything we missed
  490.       Move($GoldLoot1[$R][0], $GoldLoot1[$R][1])
  491.       Sleep(Random(800, 900))
  492.       AttackNearbyMonsters()
  493.       Move($GoldLoot2[$R][0], $GoldLoot2[$R][1])
  494.       Sleep(Random(400,500))
  495.       AttackNearbyMonsters()
  496.       Move($GoldLoot3[$R][0], $GoldLoot3[$R][1])
  497.       sleep(Random(400,500))
  498.       AttackNearbyMonsters()
  499.      
  500.       ;Loot items
  501.       if $LootRares then
  502.          LootRares()
  503.          $LootAttemps = 0
  504.          LootLegendaries()
  505.          $LootAttempts = 0
  506.       EndIf
  507.      
  508.       if $LootBlues Then
  509.          $LootAttempts = 0
  510.          LootMagic()
  511.       EndIf
  512.      
  513.       if $LootGems Then
  514.          LootGems()
  515.       EndIf
  516.          
  517.      
  518.       ;Check to see if we died
  519.       if CheckForDeath() Then
  520.          ContinueLoop
  521.       EndIf
  522.  
  523.  
  524.       ;Teleport to town
  525.       send("{t}")
  526.       sleep(8000)
  527.      
  528.       ;Repair if needed
  529.       if $Repair then
  530.          RepairItems()
  531.       EndIf
  532.      
  533.       ;Leave the game
  534.       LeaveGame()
  535.       Sleep(1000)
  536.  
  537.    EndIf
  538. WEnd
  539.  
  540. Func CheckForRepair()
  541.    $RepairNeeded = PixelSearch($RepairCheck[$R][0],$RepairCheck[$R][1], $RepairCheck[$R][0]+5, $RepairCheck[$R][1]+5, 0xFFE801,10)
  542.    
  543.    if Not @error Then
  544.       return True
  545.    Else
  546.       return False
  547.    EndIf
  548. EndFunc
  549.    
  550.    
  551. Func RepairItems()
  552.    if not CheckForRepair() Then
  553.       Return
  554.    EndIf
  555.    
  556.    Move($RepairCords[$R][0][0] , $RepairCords[$R][0][1])
  557.    Sleep(2700+$ComputerLag)
  558.    MouseMove($RepairCords[$R][1][0] , $RepairCords[$R][1][1])
  559.    Sleep(400)
  560.    Click($RepairCords[$R][1][0] , $RepairCords[$R][1][1])
  561.    sleep(2200+$ComputerLag)
  562.    click($RepairCords[$R][2][0] , $RepairCords[$R][2][1])
  563.    Sleep(Random(700-900))
  564.    Click($RepairCords[$R][3][0] , $RepairCords[$R][3][1])
  565.    Sleep(500)
  566.    send("{esc}")
  567.    
  568. EndFunc
  569.  
  570.  
  571. Func LeaveGame()
  572.    send("{esc}")
  573.    Sleep(400)
  574.    Click($Leave[$R][0], $Leave[$R][1])
  575. EndFunc
  576.  
  577. Func Pause()
  578.    $Paused = Not $Paused
  579.    While $Paused
  580.       Sleep(100)
  581.       ToolTip('Paused... (Press Space to run it)', 0, 0)
  582.    WEnd
  583.    ToolTip("")
  584. EndFunc   ;
  585.  
  586. Func Click($x, $y)
  587.    MouseClick('left', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
  588.    Sleep(Random(1000, 1500))
  589. EndFunc
  590.  
  591. Func Move($x, $y)
  592.    MouseClick('middle', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
  593.    Sleep(Random(1000, 1500))
  594. EndFunc  
  595.  
  596. Func Attack($x, $y)
  597.    MouseClick('right', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
  598. EndFunc    
  599.  
  600. Func Rest($z)
  601.    Sleep(Random($z, $z+25))
  602. EndFunc
  603.  
  604. Func CheckForDeath()
  605.    ConsoleWrite("Checking to see if we died")
  606.    $Death = PixelSearch($DeathBounds[$R][0], $DeathBounds[$R][0], $DeathBounds[$R][0]+4, $DeathBounds[$R][0]+4, 0xFFFFFF)
  607.    if not @error Then
  608.       ConsoleWrite("Died" & @LF)
  609.       LeaveGame()
  610.       Sleep(12000)
  611.       return True
  612.    Else
  613.       return False
  614.    EndIf
  615. EndFunc
  616.  
  617.  
  618. Func LootMagic()
  619.    $Magic = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3], 0x6969FF, 4) ;
  620.    If not @error Then
  621.       Click($Magic[0]+5, $Magic[1]+2)
  622.       Sleep(Random(800,1000))
  623.    EndIf
  624.    
  625.    $LootAttempts+=1
  626.    if($LootAttempts > 5) then
  627.       Return
  628.    Else
  629.       LootMagic()
  630.    EndIf
  631. EndFunc
  632.    
  633.  
  634. Func LootRares()
  635.    $Rare = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3], 0xBBBB00, 4) ;
  636.    If not @error Then
  637.       Click($Rare[0]+5, $Rare[1]+2)
  638.       Sleep(Random(800,1000))
  639.    EndIf
  640.    
  641.    $LootAttempts+=1
  642.    if($LootAttempts > 5) then
  643.       Return
  644.    Else
  645.       LootRares()
  646.    EndIf
  647. EndFunc
  648.    
  649.  
  650.  
  651. Func LootLegendaries()
  652.    $Legendary = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3],0xBF642F, 2) ;
  653.    If not @error Then
  654.       Click($Legendary[0]+5, $Legendary[1]+2)
  655.       Sleep(Random(800,1000))
  656.    EndIf
  657.    
  658.     $set = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][2], 0x02CE01, 2) ;
  659.     If not @error Then
  660.       Click($set[0]+5, $set[1]+2)
  661.       Sleep(Random(800,1000))
  662.    EndIf
  663.      
  664.    $LootAttempts+=1
  665.    if($LootAttempts > 3) then
  666.       Return
  667.    Else
  668.       LootRares()
  669.    EndIf
  670. EndFunc
  671.  
  672. #cs
  673. $Amethyst = 0xAC7FFF
  674. $Ruby = 0xB01D2D
  675. $Emerald = 0x58EE33
  676. $Topaz = 0xFFFF59
  677. #ce
  678. Func LootGems()
  679.    $Gem = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3],$Ruby,6) ;
  680.    If not @error Then
  681.       ConsoleWrite("Found a Ruby!" & @LF)
  682.       $Gem = PixelSearch($Gem[0] - 20, $Gem[1], $Gem[0] + 20, $Gem[1] - $GemLootOffset[$R], 0xFFFFFF)
  683.       If not @error Then
  684.          Click($Gem[0], $Gem[1])
  685.          Sleep(Random(400,600))
  686.       EndIf
  687.    EndIf
  688.    
  689.    $Gem = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3],$Amethyst,8) ;
  690.    If not @error Then
  691.       ConsoleWrite("Found an $Amethyst!" & @LF)
  692.      $Gem = PixelSearch($Gem[0] - 20, $Gem[1], $Gem[0] + 20, $Gem[1] - $GemLootOffset[$R], 0xFFFFFF)
  693.       If not @error Then
  694.          Click($Gem[0], $Gem[1])
  695.          Sleep(Random(400,600))
  696.       EndIf
  697.      
  698.    EndIf
  699.    
  700.    $Gem = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3],$Emerald,11) ;
  701.    If not @error Then
  702.       ConsoleWrite("Found am Emerald!" & @LF)
  703.      $Gem = PixelSearch($Gem[0] - 20, $Gem[1], $Gem[0] + 20, $Gem[1] - $GemLootOffset[$R], 0xFFFFFF)
  704.       If not @error Then
  705.          Click($Gem[0], $Gem[1])
  706.          Sleep(Random(400,600))
  707.       EndIf
  708.    EndIf
  709.    
  710.    $Gem = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], $LootingArea[$R][3],$Topaz,2) ;
  711.    If not @error Then
  712.       ConsoleWrite("Found a Topaz!" & @LF)
  713.      $Gem = PixelSearch($Gem[0] - 20, $Gem[1], $Gem[0] + 20, $Gem[1] - $GemLootOffset[$R], 0xFFFFFF)
  714.       If not @error Then
  715.          Click($Gem[0], $Gem[1])
  716.          Sleep(Random(400,600))
  717.       EndIf
  718.    EndIf
  719.  
  720.      
  721.    $GemLootAttempts+=1
  722.    if($GemLootAttempts > 3) then
  723.       Return
  724.    Else
  725.       LootGems()
  726.    EndIf
  727. EndFunc
  728.  
  729.  
  730.  
  731. Func AttackNearbyMonsters()
  732.    while 1
  733.       $MonsterData =  PixelSearch($CharHitBox[$R][0],$CharHitBox[$R][1],$CharHitBox[$R][2],$CharHitBox[$R][3], 0xEE0000, 10)
  734.          if @error Then
  735.             ExitLoop
  736.          EndIf
  737.      
  738.       send("{4}")
  739.       sleep(300)
  740.       for $i = 10 To 0 step -1
  741.          Attack($MonsterData[0], $MonsterData[1])
  742.          Sleep(100)
  743.       Next
  744.    WEnd
  745. EndFunc
  746.  
  747. Func CheckForNearbyMonsters()
  748.    $MonsterData =  PixelSearch($CharHitBox[$R][0],$CharHitBox[$R][1],$CharHitBox[$R][2],$CharHitBox[$R][3], 0xEE0000, 10)
  749.    if @error Then
  750.       return False
  751.    Else
  752.        return True
  753.     EndIf
  754.  EndFunc
  755.  
  756.  
  757. Func SnareNearbyEnemies()
  758.    $MonsterData =  PixelSearch($CharHitBox[$R][0],$CharHitBox[$R][1],$CharHitBox[$R][2],$CharHitBox[$R][3], 0xEE0000, 10)
  759.    if not @error Then
  760.        MouseMove($MonsterData[0], $MonsterData[1])
  761.        Sleep(350)
  762.        Send("{3}")
  763.        sleep(250)
  764.     EndIf
  765.  EndFunc
  766.  
  767.  
  768.  Func InGameLobby()
  769.     MouseMove($GameLobbyCode[$R][0],$GameLobbyCode[$R][1])
  770.     Sleep(300)
  771.     PixelSearch($GameLobbyCode[$R][0],$GameLobbyCode[$R][1],$GameLobbyCode[$R][0]+10,$GameLobbyCode[$R][1]+10, $GameLobbyCode[$R][2], 10)
  772.     if not @error Then
  773.        return True
  774.     Else
  775.        return False
  776.    EndIf
  777. EndFunc
  778.  
  779.  Func InGameplayScreen()
  780.     PixelSearch($GameScreenCode[$R][0],$GameScreenCode[$R][1],$GameScreenCode[$R][0]+4,$GameScreenCode[$R][1]+3, $GameScreenCode[$R][2], 10)
  781.     if not @error Then
  782.        return True
  783.     Else
  784.        return False
  785.    EndIf
  786. EndFunc
  787.  
  788.  
  789. Func ActivateGUI()
  790.  
  791.    ;setup the UI
  792.    $Waiting = True
  793.  
  794.    $Form1 = GUICreate("D3 Witch Doctor bot by Avatar88343", 400, 200, -1, -1)
  795.    
  796.    $ResLabel = GUICtrlCreateLabel("Game Resolution", 100, 30, 100, -1)
  797.    $ResCombo = GUICtrlCreateCombo("", 100, 45, 200, -1)
  798.    GUICtrlSetData($ResCombo, "1920 x 1080|800 x 600", "Select your Res")
  799.    
  800.    $Runabel = GUICtrlCreateLabel("Character run speed (for 800x600)", 100, 75, 200, -1)
  801.    $RunInput = GUICtrlCreateInput("0" , 100, 90, 200, -1)
  802.    
  803.    $LootRareCheck = GUICtrlCreateCheckbox("Loot Rares",25,130,100,20)
  804.    GUICtrlSetState($LootRareCheck, $GUI_CHECKED)
  805.    
  806.    $LootBluesCheck = GUICtrlCreateCheckbox("Loot Blues",125,130,100,20)
  807.    GUICtrlSetState($LootRareCheck, $GUI_CHECKED)
  808.    
  809.    $LootGemsCheck = GUICtrlCreateCheckbox("Loot Gems (beta)",225,130,100,20)
  810.    
  811.    $RepairCheckbox = GUICtrlCreateCheckbox("Repair",325,130,100,20)
  812.    GUICtrlSetState($RepairCheckbox, $GUI_CHECKED)
  813.    
  814.    $StartButton = GUICtrlCreateButton("Start", 125, 160, 150, 33)
  815.    
  816.    GUISetState(@SW_SHOW)
  817.    
  818.    ;Wait for them to press start
  819.    while $Waiting
  820.       $Action = GUIGetMsg()
  821.      
  822.       if $Action = $GUI_EVENT_CLOSE then Terminate()
  823.       if $Action = $StartButton then ExitLoop
  824.      
  825.       sleep(50)
  826.    WEnd
  827.    
  828.    ;Get the values
  829.    $SelectedRes = GUICtrlRead($ResCombo)
  830.    if $SelectedRes = "1920 x 1080" Then
  831.       $R = 0
  832.    ElseIf $SelectedRes = "800 x 600" Then
  833.       $R = 1
  834.    Else
  835.       msgbox(0,"Error","You did not select a resolution! Try again")
  836.       Terminate()
  837.    EndIf
  838.    
  839.    $Runspeed = int(GUICtrlRead($RunInput))
  840.    $LootRares = GuiCtrlRead($LootRareCheck) = $GUI_CHECKED
  841.    $LootBlues = GuiCtrlRead($LootBluesCheck) = $GUI_CHECKED
  842.    $Repair = GuiCtrlRead($RepairCheckbox) = $GUI_CHECKED
  843.    $LootGems = GuiCtrlRead($LootGemsCheck) = $GUI_CHECKED
  844.    
  845.     GUISetState(@SW_HIDE)
  846. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement