andygongyb

Witch Doctor Farming Bot - Act 1 cellar (0.7 dev)

Jun 22nd, 2012
2,071
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #cs
  2.     Witch Doctor Cellar Farming Bot - Version 0.7.20120701 [1920x1080 ONLY]
  3.     Developed by Avatar88343 @ Ownedcore (v0.1~v0.4) and andygongyb @ Ownedcore (since v0.5)
  4.     Other contributers:
  5.     Beta tester: liquidsystem @ Ownedcore
  6.  
  7.     What it does:
  8.     *This bot will travel to the cellar in Act 1, kill the mobs, collect the gold and items, and repair your gear.
  9.  
  10.  
  11.     Newbiew Info:
  12.     This is a script that runs on AutoIt. You run this bot by Downloading AutoIt from the web (it's free) and installing it.
  13.     You then paste all this code into any text editor (such as notepad) and save it anywhere on your hard drive. Follow the Select
  14.     steps below to configure this bot before you run it.
  15.  
  16.     Special Instructions for 1920 x 1080:
  17.     1.) Set your game resolution to 1920x1080 (required)
  18.     2.) Set the display mode to Fullscreen Windowed (Don't forget!)
  19.     3.) Follow the Instructions (for all resolutions) section below
  20.  
  21.     Special Instructions for 800 x 600:
  22.  
  23.     1.)Exit Diablo 3
  24.     2.)Go to your document folder and locate the Diablo III folder
  25.     3.)Open the D3Prefs file in any editor (such as notepad)
  26.     4.)Change the following settings to the ones listed below
  27.     "DisplayModeFlags "0"
  28.     DisplayModeWindowMode "1"
  29.     DisplayModeWinLeft "428"
  30.     DisplayModeWinTop "162"
  31.     DisplayModeWinWidth "800"
  32.     DisplayModeWinHeight "600"
  33.     DisplayModeUIOptWidth "800"
  34.     DisplayModeUIOptHeight "600"
  35.     DisplayModeWidth "800"
  36.     DisplayModeHeight "600"
  37.     DisplayModeRefreshRate "75"
  38.     DisplayModeBitDepth "32""
  39.     5.) Follow the Instructions (for all resolutions) section below
  40.  
  41.  
  42.     Instructions (for all resolutions)
  43.     1.) Bind your middle mouse button to Move (found in Key Bindings Option)
  44.     2.) Set your build to this http://us.battle.net/d3/en/calculator/witch-doctor#aZQPkU!VZW!acbbba
  45.     3.) Start Act 1, Quest 6 - Talk to Alaric
  46.     4.) Hire the Scoundrel
  47.     5.) Teleport to The Old Ruins using the waypoint and run left until you reach a checkpoint
  48.     6.) Log out of the game
  49.     7.) Press F2 to start the bot! Space is used to pause and resume the bot
  50.     8.) Press shift + \ to turn off the bot
  51.  
  52.     NOTE:
  53.     *Please make sure you are running the correct resolution settings!
  54.     *You must be running the game in Fullscreen Windoed mode if you're using 1080P
  55.     *You WILL need to edit the values below the comments for better results
  56.  
  57.     FEATURES:
  58.     *Supports 1080P Fullscreen Windowed and 800x600 Windowed (V. 0.5 only supports 1080P currently)
  59.     *Automatic looting of Rare, Legendary, and Set items
  60.     *Also able to loot blue items, tomes, and gems
  61.     *Optionally sells blue items when the bag is full
  62.     *Repairs Items when damaged
  63.     *Detects death and responds accordingly
  64.     *Detects connection lost and automatically reconnect (not tested)
  65.     *Randomization for increased safety
  66.     *Added ability to find Cellar during bad runs
  67.  
  68.     IN DEVELOPMENT:
  69.     *Multi-resolution support (need people to help)
  70.     *Stash use
  71.     *Improved combat
  72.     *Speed improvements
  73.     *Multiple routes to improve safety
  74.     *45 min timeout bug
  75.     *Edit d3config
  76.     *Salvage lv60 blue items automatically
  77.  
  78.  
  79.     **Based on the code by notAres and mackus101. Special thanks to them!
  80. #ce
  81. #RequireAdmin
  82. #include <GUIConstantsEx.au3>
  83. #include <WindowsConstants.au3>
  84. ;======THESE VALUES CAN BE EDITED WITH THE GUI ===================================
  85. $R = 0 ; Leave this as 0 if you are using 1080P. Change it to 1 if you're using 800 x 600
  86. $ComputerLag = 500 ; Additional delay time for switching between scenes
  87. $RunSpeed = 10 ; Enter your character's run speed here
  88. $LootRares = True ; Whether or not to loot rare and legendary items
  89. $LootBlues = True ; Whether or not to loot blue items
  90. $LootGems = True ; Whether or not to loot gems
  91. $LoorSquareGems = False ; Set to False if you want only flawless gems
  92. $LootPotions = True ; Whether or not to loot potions
  93. $LootTomes = True ; Whether or not to loot Tome of Secret
  94. $LootGold = True ; Whether or to collect gold that is missed during the first collection attempt
  95. $Repair = True ; Orders the bot to repair when items are damaged
  96. $SellBlues = True ; Orders the bot to sell blue items when the bag is full
  97. $Skill3CoolDown = 20000 ; Cool down time in ms of the key 3 skill
  98. $Skill4CoolDown = 12000 ; Cool down time in ms of the key 4 skill
  99. $RightClickCoolCown = 8000 ; Cool down time in ms of the right click skill
  100. $LootDelayMult = 5.5 ; Scaler for calculating the delay to run to an item
  101. $RunDelayMult = 1.1 ; Scaler for calculating the delay to run to a position
  102. $CastSpeedMult = 1.1 ; Scaler for calculating casting speed
  103. $FastLoot = True ; Set to False if the char TP to town before finishing looting
  104. $Password = "your password" ; put your password here
  105.  
  106. ;======================================================================
  107.  
  108. Global $Resume[2][2] ; Location of the Resume Button
  109. Global $Leave[2][2] ; Location of the in-game leave button
  110. Global $GameLobbyCode[2][3] ; Contains X, Y, and Hex color of Resume button so we can see if we're there
  111. Global $GameScreenCode[2][3] ; Contains X, Y, and Hex color used to check if we are in an unpaused game
  112. Global $Loc1[2][2] ; First movement
  113. Global $Loc2[2][2] ; Second movement
  114. Global $Loc3[2][2] ; Third movement ttt
  115.  
  116. Global $CellarLocation[2][2] ; Cellar door location
  117. Global $CellarLocation2[2] ; Location of cellar during bad runs (ugly workaround for now)
  118. Global $AltCellar = False
  119.  
  120. Global $MagicLetter[5] ; Blue vow pics
  121. Global $RareLetter[5] ; Rare vow pics
  122. Global $LegLetter[5] ; Legendary vow pics
  123. Global $SetLetter[5] ; Set vow pics
  124.  
  125. Global $Loc5[2][2] ; Cellar hallway
  126. Global $Loc6[2][2] ; Cellar doorway
  127. Global $MonsterLoc[2][2] ; Initial boss location
  128. Global $MonsterSearch[2][4] ; Bounds of where we will find our monsters
  129. Global $GoldLoot1[2][2] ; First place to run when looting
  130. Global $GoldLoot2[2][2] ; Second place to run when looting
  131. Global $GoldLoot3[2][2] ; Third place to run when looting
  132. Global $LootingArea[2][4] ; looting bounds (TL X, TL Y, BR X, BR Y)
  133. Global $CharHitBox[2][4] ; Hitbox around user's character
  134. Global $DeathBounds[2][4] ; Used to detect the % sign in the death text
  135. Global $RepairCoords[2][4][2] ; Four clicks needed to repair
  136. Global $RepairCheck[2][2] ; Used to check for repair icon
  137. Global $CellarOffset[2] ; Used to improve cellar clicking with 1080P/800x600
  138. Global $CellarIcon ; Used to find the yellow cellar icon on the minimap (future use)
  139. Global $pngLoc[2] ; Absolute path of the folder containing pics for image search
  140. Global $LostConnectionOkBtn[2][2] ; The coordinate of the OK button of the "lost connection" window
  141. Global $LostConnectionText0[2][4] ; Image search area of the "lost connection" text
  142. Global $LostConnectionText1[2][4]
  143. Global $LostConnectionText2[2][4]
  144. Global $CharLoc[2][2] ; Location where the character stands
  145. Global $CastLoc[2][2] ; Location to cast Grasp of the Dead in the cellar
  146. Global $SellCoords[2][2] ; Coordinate of the sell button
  147. Global $SlotOffset[2] ; Length of each slot in the item window
  148. Global $ItemStartCoord0[2][4] ; Pixel search area of the first slot on the second column in item window
  149. Global $ItemStartCoord1[2][4]
  150. Global $BagFullCoords[2][4] ; Image search area of the bag full message
  151. Global $IdleCursorCoords[2][2] ; Coordinate of where the cursor should go for not covering any item name
  152. Global $TristramTextCoord[2][4] ; Pixel search area of the Tristram text
  153. Global $RuinTextCoord[2][4] ; Pixel search area of the Ruin text
  154. Global $CellarTextCoord[2][4] ; Pixel search area of the Cellar text
  155. Global $ResumeBtnCoord[2][4] ; Image search area of the resume text
  156. Global $LoginFailText[2][4]
  157. Global $LeaveGameText[2][4]
  158. Global $PwdInput[2][2]
  159. Global $OkBtn0[2][2]
  160. Global $OkBtn1[2][2]
  161. Global $NeedReset
  162. Global $CellarPixel
  163. Global $BagFull
  164. Global $HasBlue
  165. Global $Timer0
  166. Global $Timer1
  167. Global $Moved
  168. Global $Skill3Timer
  169. Global $Skill4Timer
  170. Global $RightClickTimer
  171. Global $Gem
  172.  
  173. ActivateGUI()
  174.  
  175. ;Check for people that can't read instructions
  176. If Int($R) < 0 Or Int($R) > 1 Then
  177.     MsgBox(4096, "A wild illiterate appears appears!", "Aha! I caught you! You did not read the instructions. You need to configure the bot!")
  178.     terminate()
  179. EndIf
  180.  
  181.  
  182. ;Clculate run speed
  183. Global $RunTime = 30 * (100 - $RunSpeed) + 2000 ;Length of time to run in 800x600
  184.  
  185. ;All locations are N dimensional arrays. [0][x] is for 1080P and [1][x] is for 800x600
  186. ;1080P
  187.  
  188. $MagicLetter[0] = "blueA.png"
  189. $MagicLetter[1] = "blueE.png"
  190. $MagicLetter[2] = "blueI.png"
  191. $MagicLetter[3] = "blueO.png"
  192. $MagicLetter[4] = "blueU.png"
  193.  
  194. $RareLetter[0] = "rareA.png"
  195. $RareLetter[1] = "rareE.png"
  196. $RareLetter[2] = "rareI.png"
  197. $RareLetter[3] = "rareO.png"
  198. $RareLetter[4] = "rareU.png"
  199.  
  200. $LegLetter[0] = "legendaryA.png"
  201. $LegLetter[1] = "legendaryE.png"
  202. $LegLetter[2] = "legendaryI.png"
  203. $LegLetter[3] = "legendaryO.png"
  204. $LegLetter[4] = "legendaryU.png"
  205.  
  206. $SetLetter[0] = "setA.png"
  207. $SetLetter[1] = "setE.png"
  208. $SetLetter[2] = "setI.png"
  209. $SetLetter[3] = "setO.png"
  210. $SetLetter[4] = "setU.png"
  211.  
  212.  
  213. ;1920x1080
  214. $pngLoc[0] = "F:\Program Files (x86)\Diablo III\pics\1920x1080\" ; Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
  215. $Resume[0][0] = 319
  216. $Resume[0][1] = 416
  217. $GameLobbyCode[0][0] = 319
  218. $GameLobbyCode[0][1] = 416
  219. $GameLobbyCode[0][2] = 4065536
  220. $GameScreenCode[0][0] = 1119
  221. $GameScreenCode[0][1] = 1044
  222. $GameScreenCode[0][2] = 0xDEFDFE
  223. $LostConnectionOkBtn[0][0] = 957
  224. $LostConnectionOkBtn[0][1] = 630
  225. $LostConnectionText0[0][0] = 765
  226. $LostConnectionText0[0][1] = 493
  227. $LostConnectionText0[0][2] = 853
  228. $LostConnectionText0[0][3] = 525
  229. $LostConnectionText1[0][0] = 765
  230. $LostConnectionText1[0][1] = 493
  231. $LostConnectionText1[0][2] = 864
  232. $LostConnectionText1[0][3] = 525
  233. $LostConnectionText2[0][0] = 765
  234. $LostConnectionText2[0][1] = 493
  235. $LostConnectionText2[0][2] = 812
  236. $LostConnectionText2[0][3] = 517
  237. $ResumeBtnCoord[0][0] = 155
  238. $ResumeBtnCoord[0][1] = 406
  239. $ResumeBtnCoord[0][2] = 242
  240. $ResumeBtnCoord[0][3] = 428
  241. $CharLoc[0][0] = 944
  242. $CharLoc[0][1] = 507
  243. $CastLoc[0][0] = 590
  244. $CastLoc[0][1] = 290
  245. $SellCoords[0][0] = 517
  246. $SellCoords[0][1] = 238
  247. $SlotOffset[0] = 48
  248. $ItemStartCoord0[0][0] = 1460
  249. $ItemStartCoord0[0][1] = 631
  250. $ItemStartCoord0[0][2] = 1462
  251. $ItemStartCoord0[0][3] = 633
  252. $ItemStartCoord1[0][0] = 1460
  253. $ItemStartCoord1[0][1] = 625
  254. $ItemStartCoord1[0][2] = 1468
  255. $ItemStartCoord1[0][3] = 632
  256. $BagFullCoords[0][0] = 1060
  257. $BagFullCoords[0][1] = 125
  258. $BagFullCoords[0][2] = 1120
  259. $BagFullCoords[0][3] = 160
  260. $IdleCursorCoords[0][0] = 400
  261. $IdleCursorCoords[0][1] = 300
  262. $TristramTextCoord[0][0] = 1790
  263. $TristramTextCoord[0][1] = 7
  264. $TristramTextCoord[0][2] = 1900
  265. $TristramTextCoord[0][3] = 30
  266. $RuinTextCoord[0][0] = 1830
  267. $RuinTextCoord[0][1] = 7
  268. $RuinTextCoord[0][2] = 1900
  269. $RuinTextCoord[0][3] = 30
  270. $CellarTextCoord[0][0] = 1820
  271. $CellarTextCoord[0][1] = 7
  272. $CellarTextCoord[0][2] = 1900
  273. $CellarTextCoord[0][3] = 30
  274. $DeathBounds[0][0] = 1390
  275. $DeathBounds[0][1] = 492
  276. $DeathBounds[0][2] = 1450
  277. $DeathBounds[0][3] = 543
  278. $PwdInput[0][0] = 809
  279. $PwdInput[0][1] = 706
  280. $OkBtn1[0][0] = 957
  281. $OkBtn1[0][1] = 854
  282. $LoginFailText[0][0] = 760
  283. $LoginFailText[0][1] = 485
  284. $LoginFailText[0][2] = 816
  285. $LoginFailText[0][3] = 506
  286. $LeaveGameText[0][0] = 903
  287. $LeaveGameText[0][1] = 127
  288. $LeaveGameText[0][2] = 965
  289. $LeaveGameText[0][3] = 151
  290.  
  291. ;800x600
  292. $pngLoc[1] = "F:\Program Files (x86)\Diablo III\pics\800x600\" ; Need people to make those pics
  293. $Resume[1][0] = 174
  294. $Resume[1][1] = 232
  295. $GameLobbyCode[1][0] = 174
  296. $GameLobbyCode[1][1] = 232
  297. $GameLobbyCode[1][2] = 4262400
  298. $GameScreenCode[1][0] = 486
  299. $GameScreenCode[1][1] = 578
  300. $GameScreenCode[1][2] = 0x6C9BFF
  301. ; Need people working on the following coordinates
  302. $LostConnectionOkBtn[1][0] = 0
  303. $LostConnectionOkBtn[1][1] = 0
  304. $LostConnectionText0[1][0] = 0
  305. $LostConnectionText0[1][1] = 0
  306. $LostConnectionText0[1][2] = 0
  307. $LostConnectionText0[1][3] = 0
  308. $LostConnectionText1[1][0] = 0
  309. $LostConnectionText1[1][1] = 0
  310. $LostConnectionText1[1][2] = 0
  311. $LostConnectionText1[1][3] = 0
  312. $LostConnectionText2[1][0] = 0
  313. $LostConnectionText2[1][1] = 0
  314. $LostConnectionText2[1][2] = 0
  315. $LostConnectionText2[1][3] = 0
  316. $ResumeBtnCoord[1][0] = 0
  317. $ResumeBtnCoord[1][1] = 0
  318. $ResumeBtnCoord[1][2] = 0
  319. $ResumeBtnCoord[1][3] = 0
  320. $CharLoc[1][0] = 0
  321. $CharLoc[1][0] = 0
  322. $CastLoc[1][0] = 0
  323. $CastLoc[1][1] = 0
  324. $SellCoords[1][0] = 0
  325. $SellCoords[1][1] = 0
  326. $SlotOffset[1] = 0
  327. $ItemStartCoord0[1][0] = 0
  328. $ItemStartCoord0[1][1] = 0
  329. $ItemStartCoord0[1][2] = 0
  330. $ItemStartCoord0[1][3] = 0
  331. $ItemStartCoord1[1][0] = 0
  332. $ItemStartCoord1[1][1] = 0
  333. $ItemStartCoord1[1][2] = 0
  334. $ItemStartCoord1[1][3] = 0
  335. $BagFullCoords[1][0] = 0
  336. $BagFullCoords[1][1] = 0
  337. $BagFullCoords[1][2] = 0
  338. $BagFullCoords[1][3] = 0
  339. $IdleCursorCoords[1][0] = 0
  340. $IdleCursorCoords[1][1] = 0
  341. $IdleCursorCoords[1][0] = 0
  342. $IdleCursorCoords[1][1] = 0
  343. $TristramTextCoord[1][0] = 0
  344. $TristramTextCoord[1][1] = 0
  345. $TristramTextCoord[1][2] = 0
  346. $TristramTextCoord[1][3] = 0
  347. $RuinTextCoord[1][0] = 0
  348. $RuinTextCoord[1][1] = 0
  349. $RuinTextCoord[1][2] = 0
  350. $RuinTextCoord[1][3] = 0
  351. $CellarTextCoord[1][0] = 0
  352. $CellarTextCoord[1][1] = 0
  353. $CellarTextCoord[1][2] = 0
  354. $CellarTextCoord[1][3] = 0
  355. $DeathBounds[1][0] = 0
  356. $DeathBounds[1][1] = 0
  357. $DeathBounds[1][2] = 0
  358. $DeathBounds[1][3] = 0
  359. $OkBtn0[1][0] = 400
  360. $OkBtn0[1][1] = 352
  361. $PwdInput[1][0] = 318
  362. $PwdInput[1][1] = 390
  363. $OkBtn1[1][0] = 401
  364. $OkBtn1[1][1] = 474
  365. $LoginFailText[1][0] = 0
  366. $LoginFailText[1][1] = 0
  367. $LoginFailText[1][2] = 0
  368. $LoginFailText[1][3] = 0
  369. $LeaveGameText[1][0] = 0
  370. $LeaveGameText[1][1] = 0
  371. $LeaveGameText[1][2] = 0
  372. $LeaveGameText[1][3] = 0
  373.  
  374. ;1920x1080
  375. $Leave[0][0] = 969
  376. $Leave[0][1] = 582
  377.  
  378. ;800x600
  379. $Leave[1][0] = 397
  380. $Leave[1][1] = 322
  381.  
  382. ;1920x1080
  383. $Loc1[0][0] = 500 ;First movement
  384. $Loc1[0][1] = 250
  385. $Loc2[0][0] = 1 ;Second movement
  386. $Loc2[0][1] = 370
  387. $Loc3[0][0] = 400 ;Third Movement
  388. $Loc3[0][1] = 600
  389.  
  390. ;800x600
  391. $Loc1[1][0] = 8 ;First movement
  392. $Loc1[1][1] = 146
  393. $Loc2[1][0] = 7 ;Second movement
  394. $Loc2[1][1] = 300
  395. $Loc3[1][0] = 8 ;Third Movement
  396. $Loc3[1][1] = 300
  397.  
  398. ;1080P
  399. $CellarLocation[0][0] = 307 ;Cellar door location
  400. $CellarLocation[0][1] = 74
  401. ;800x600
  402. $CellarLocation[1][0] = 499 ;Cellar door location
  403. $CellarLocation[1][1] = 148
  404. $CellarLocation2[0] = 439
  405. $CellarLocation2[1] = 145
  406. $AltCellarLocation = False
  407.  
  408. ;Cellar offset
  409. $CellarOffset[0] = 33;
  410. $CellarOffset[1] = 10;
  411.  
  412. ;1080P
  413. $Loc5[0][0] = 116 ;Walk down hallway
  414. $Loc5[0][1] = 986
  415. $Loc6[0][0] = 756 ;enter hallway
  416. $Loc6[0][1] = 308
  417. ;800x600
  418. $Loc5[1][0] = 3 ;Walk down hallway
  419. $Loc5[1][1] = 504
  420. $Loc6[1][0] = 255 ;enter hallway
  421. $Loc6[1][1] = 190
  422.  
  423. ;1080P
  424. $MonsterLoc[0][0] = 577
  425. $MonsterLoc[0][1] = 183
  426. ;800x600
  427. $MonsterLoc[1][0] = 188
  428. $MonsterLoc[1][1] = 111
  429.  
  430. ;1920x1080
  431. $MonsterSearch[0][0] = 162
  432. $MonsterSearch[0][1] = 29
  433. $MonsterSearch[0][2] = 1248
  434. $MonsterSearch[0][3] = 446
  435. ;800x600
  436. $MonsterSearch[1][0] = 40
  437. $MonsterSearch[1][1] = 53
  438. $MonsterSearch[1][2] = 424
  439. $MonsterSearch[1][3] = 191
  440.  
  441. ;1920x1080
  442. $GoldLoot1[0][0] = 402
  443. $GoldLoot1[0][1] = 306
  444. $GoldLoot2[0][0] = 1260
  445. $GoldLoot2[0][1] = 351
  446. $GoldLoot3[0][0] = 911
  447. $GoldLoot3[0][1] = 694
  448. ;800x600
  449. $GoldLoot1[1][0] = 96
  450. $GoldLoot1[1][1] = 181
  451. $GoldLoot2[1][0] = 560
  452. $GoldLoot2[1][1] = 191
  453. $GoldLoot3[1][0] = 349
  454. $GoldLoot3[1][1] = 418
  455.  
  456. ;1080P
  457. $LootingArea[0][0] = 300
  458. $LootingArea[0][1] = 220
  459. $LootingArea[0][2] = 1600
  460. $LootingArea[0][3] = 800
  461. ;800x600
  462. $LootingArea[1][0] = 75
  463. $LootingArea[1][1] = 90
  464. $LootingArea[1][2] = 630
  465. $LootingArea[1][3] = 400
  466.  
  467. ;1080P
  468. $CharHitBox[0][0] = 790
  469. $CharHitBox[0][1] = 315
  470. $CharHitBox[0][2] = 1200
  471. $CharHitBox[0][3] = 730
  472. ;800x600
  473. $CharHitBox[1][0] = 304
  474. $CharHitBox[1][1] = 190
  475. $CharHitBox[1][2] = 468
  476. $CharHitBox[1][3] = 323
  477.  
  478. ;1080P
  479. $RepairCoords[0][0][0] = 1690
  480. $RepairCoords[0][0][1] = 102
  481. $RepairCoords[0][1][0] = 930
  482. $RepairCoords[0][1][1] = 136
  483. $RepairCoords[0][2][0] = 517
  484. $RepairCoords[0][2][1] = 483
  485. $RepairCoords[0][3][0] = 223
  486. $RepairCoords[0][3][1] = 592
  487. ;800x600
  488. $RepairCoords[1][0][0] = 691
  489. $RepairCoords[1][0][1] = 88
  490. $RepairCoords[1][1][0] = 505
  491. $RepairCoords[1][1][1] = 52
  492. $RepairCoords[1][2][0] = 282
  493. $RepairCoords[1][2][1] = 261
  494. $RepairCoords[1][3][0] = 157
  495. $RepairCoords[1][3][1] = 329
  496.  
  497. ;1080P
  498. $RepairCheck[0][0] = 1507
  499. $RepairCheck[0][1] = 36
  500. ;800x600
  501. $RepairCheck[1][0] = 573
  502. $RepairCheck[1][1] = 21
  503.  
  504. Opt('MouseCoordMode', 2)
  505. Opt('PixelCoordMode', 2)
  506. HotKeySet("{DELETE}", "Terminate")
  507. HotKeySet('{PAUSE}', 'Pause')
  508.  
  509. Global $Paused
  510.  
  511. ; Bot starts paused. press space to start.
  512. Pause()
  513.  
  514. ; Assume having blue when the script starts
  515. $HasBlue = True
  516.  
  517. $NeedReset = False
  518.  
  519. Sleep(400) ; Please put a random small number here which will confuse Wardon's harsh function
  520.  
  521. AdlibRegister("CheckDisCon", 3000)
  522. AdlibRegister("CheckGameErr", 3000)
  523.  
  524. Func TimeOut()
  525.     Local $gX, $gY
  526.     $NeedReset = True
  527.     If (Not _ImageSearchArea($pngLoc[$R] & "resume.png", 1, $ResumeBtnCoord[$R][0], $ResumeBtnCoord[$R][1], _
  528.             $ResumeBtnCoord[$R][2], $ResumeBtnCoord[$R][3], $gX, $gY, 90)) And _
  529.             (Not _ImageSearchArea($pngLoc[$R] & "leaving.png", 1, $LeaveGameText[$R][0], $LeaveGameText[$R][1], _
  530.             $LeaveGameText[$R][2], $LeaveGameText[$R][3], $gX, $gY, 90)) Then
  531.         LeaveGame()
  532.         AdlibUnRegister("TimeOut")
  533.         Sleep(12000)
  534.     EndIf
  535. EndFunc   ;==>TimeOut
  536.  
  537. Func CheckDisCon()
  538.     Local $gX, $gY
  539.     If _ImageSearchArea($pngLoc[$R] & "your.png", 1, $LostConnectionText2[$R][0], $LostConnectionText2[$R][1], _
  540.             $LostConnectionText2[$R][2], $LostConnectionText2[$R][3], $gX, $gY, 40) Then
  541.         AdlibUnRegister("CheckDisCon")
  542.         AdlibUnRegister("TimeOut")
  543.         Click($LostConnectionOkBtn[$R][0], $LostConnectionOkBtn[$R][1])
  544.         Sleep(2000)
  545.         Click($PwdInput[$R][0], $PwdInput[$R][1])
  546.         Sleep(500)
  547.         Send($Password)
  548.         Sleep(500)
  549.         Do
  550.             Click($LostConnectionOkBtn[$R][0], $LostConnectionOkBtn[$R][1])
  551.             Sleep(1000)
  552.             Click($OkBtn1[$R][0], $OkBtn1[$R][1])
  553.             Sleep(1000)
  554.         Until Not _ImageSearchArea($pngLoc[$R] & "cannot.png", 1, $LoginFailText[$R][0], $LoginFailText[$R][1], _
  555.                 $LoginFailText[$R][2], $LoginFailText[$R][3], $gX, $gY, 40)
  556.         Sleep(5000)
  557.         $NeedReset = True
  558.         AdlibRegister("CheckDisCon", 3000)
  559.     EndIf
  560. EndFunc   ;==>CheckDisCon
  561.  
  562. Func CheckGameErr()
  563.     Local $gX, $gY
  564.     If _ImageSearchArea($pngLoc[$R] & "game.png", 1, $LostConnectionText0[$R][0], $LostConnectionText0[$R][1], _
  565.             $LostConnectionText0[$R][2], $LostConnectionText0[$R][3], $gX, $gY, 40) Or _
  566.             _ImageSearchArea($pngLoc[$R] & "therewas.png", 1, $LostConnectionText1[$R][0], $LostConnectionText1[$R][1], _
  567.             $LostConnectionText1[$R][2], $LostConnectionText1[$R][3], $gX, $gY, 40) Then
  568.         Click($LostConnectionOkBtn[$R][0], $LostConnectionOkBtn[$R][1])
  569.         $NeedReset = True
  570.     EndIf
  571. EndFunc   ;==>CheckGameErr
  572.  
  573. If $LoorSquareGems Then
  574.     $Gem = "square.png"
  575. Else
  576.     $Gem = "flawless.png"
  577. EndIf
  578.  
  579. WinActivate('Diablo III')
  580. While 1
  581.     If WinActive('Diablo III') Then
  582.  
  583.         Local $gX
  584.         Local $gY
  585.         Local $Count
  586.         Local $HasPotion = False
  587.  
  588.         $AltCellarLocation = False
  589.         $BagFull = False
  590.  
  591.         $NeedReset = False
  592.         AdlibRegister("TimeOut", 150000)
  593.         ;Make sure that we are in the character selection screen ( we are looking at a spot in the Resume game button)
  594.         While 1
  595.             If _ImageSearchArea($pngLoc[$R] & "resume.png", 1, $ResumeBtnCoord[$R][0], _
  596.                     $ResumeBtnCoord[$R][1], $ResumeBtnCoord[$R][2], _
  597.                     $ResumeBtnCoord[$R][3], $gX, $gY, 90) Then
  598.                 ExitLoop
  599.             EndIf
  600.             WinActive('Diablo III')
  601.             If $NeedReset = True Then
  602.                 $NeedReset = False
  603.                 AdlibUnRegister("TimeOut")
  604.                 ContinueLoop 2
  605.             EndIf
  606.         WEnd
  607.  
  608.         ;Resume the game
  609.         For $Count = 5 To 0 Step -1
  610.             Click($Resume[$R][0], $Resume[$R][1])
  611.             Sleep(100)
  612.         Next
  613.  
  614.  
  615.         ;Make sure that we are in the game
  616.         While 1
  617.             If _ImageSearchArea($pngLoc[$R] & "ruins.png", 1, $RuinTextCoord[$R][0], _
  618.                     $RuinTextCoord[$R][1], $RuinTextCoord[$R][2], _
  619.                     $RuinTextCoord[$R][3], $gX, $gY, 90) Then
  620.                 ExitLoop
  621.             EndIf
  622.             WinActive('Diablo III')
  623.  
  624.             If $NeedReset = True Then
  625.                 $NeedReset = False
  626.                 AdlibUnRegister("TimeOut")
  627.                 ContinueLoop 2
  628.             EndIf
  629.         WEnd
  630.  
  631.         Sleep(200 + $ComputerLag)
  632.  
  633.         ;Custom running for the 800x600. Sometimes I wonder if it's faster to just buy everyone a 1080P monitor...
  634.         If Int($R) == 1 Then
  635.             MouseMove(11, 220)
  636.             Send("{4}")
  637.             Sleep(400)
  638.             MouseDown("middle")
  639.             Sleep($RunTime)
  640.  
  641.             MouseUp("middle")
  642.             Sleep(2000)
  643.  
  644.             #cs $CellarIcon = PixelSearch(630, 70, 741, 149, 0x71341A, 5)
  645.                 if not @error then
  646.                 ConsoleWrite("Foundtheseller" & @LF)
  647.  
  648.                 EndIf
  649.             #ce
  650.  
  651.         Else
  652.             Move($Loc1[$R][0], $Loc1[$R][1])
  653.             Sleep(Round(1200 * $RunDelayMult))
  654.             Send("{4}")
  655.             $Skill4Timer = TimerInit()
  656.             Sleep(Round(500 * $RunDelayMult))
  657.             Move($Loc2[$R][0], $Loc2[$R][1])
  658.             Sleep(Round(2100 * $RunDelayMult))
  659.             Move($Loc3[$R][0], $Loc3[$R][1])
  660.             Sleep(Round(1000 * $RunDelayMult))
  661.         EndIf
  662.  
  663.         If $NeedReset = True Then
  664.             $NeedReset = False
  665.             AdlibUnRegister("TimeOut")
  666.             ContinueLoop
  667.         EndIf
  668.  
  669.         ;Check to see if the cellar is there ```````
  670.         MouseMove($CellarLocation[$R][0], $CellarLocation[$R][1])
  671.         Send("{2}")
  672.         Sleep(400)
  673.         If Int($R) = 1 Then
  674.             $CellarPixel = PixelSearch($CellarLocation[$R][0] - 30, $CellarLocation[$R][1] - 30, _
  675.                     $CellarLocation[$R][0] + 20, $CellarLocation[$R][1] + 20, 0x93D7F9, 8)
  676.  
  677.             If @error Then
  678.                 MouseMove($CellarLocation2[0], $CellarLocation2[1])
  679.                 Sleep(300)
  680.                 $CellarPixel = PixelSearch($CellarLocation2[0] - 30, $CellarLocation2[1] - 30, _
  681.                         $CellarLocation2[0] + 20, $CellarLocation2[1] + 20, 0x93D7F9, 8)
  682.                 If Not @error Then
  683.                     $AltCellarLocation = True
  684.                 EndIf
  685.             EndIf
  686.         Else
  687.             $CellarPixel = PixelSearch($CellarLocation[$R][0] - $CellarOffset[$R], $CellarLocation[$R][1] _
  688.                      - $CellarOffset[$R], $CellarLocation[$R][0] + 4, $CellarLocation[$R][1] + 4, 0x334FB7, 6)
  689.         EndIf
  690.  
  691.  
  692.         If $NeedReset = True Then
  693.             $NeedReset = False
  694.             ContinueLoop
  695.         EndIf
  696.  
  697.  
  698.         ;Leave the game if the Cellar is not there
  699.         If @error Then
  700.             BlowSkills($CharLoc[$R][0], $CharLoc[$R][1])
  701.             leaveGame()
  702.             AdlibUnRegister("TimeOut")
  703.             ContinueLoop
  704.         EndIf
  705.  
  706.         ;Enter the cellar
  707.         If $R > 0 And $AltCellar Then
  708.             Click($CellarLocation2[$R][0] - 4, $CellarLocation2[$R][1] - 4)
  709.         Else
  710.             If Not $AltCellarLocation Then
  711.                 Click($CellarLocation[$R][0], $CellarLocation[$R][1])
  712.             Else
  713.                 Click($CellarLocation2[0], $CellarLocation2[1])
  714.             EndIf
  715.         EndIf
  716.  
  717.         $Timer0 = TimerInit()
  718.         While _ImageSearchArea($pngLoc[$R] & "cellar.png", 1, $CellarTextCoord[$R][0], _
  719.                 $CellarTextCoord[$R][1], $CellarTextCoord[$R][2], _
  720.                 $CellarTextCoord[$R][3], $gX, $gY, 90) = 0
  721.             If TimerDiff($Timer0) > 7500 Then
  722.                 BlowSkills($CharLoc[$R][0], $CharLoc[$R][1])
  723.                 leaveGame()
  724.                 AdlibUnRegister("TimeOut")
  725.                 ContinueLoop 2
  726.             EndIf
  727.             If $NeedReset = True Then
  728.                 $NeedReset = False
  729.                 AdlibUnRegister("TimeOut")
  730.                 ContinueLoop 2
  731.             EndIf
  732.         WEnd
  733.  
  734.         Sleep(500 + $ComputerLag)
  735.         ;Inside the celler now - Move to the doorway
  736.         Move($Loc5[$R][0], $Loc5[$R][1])
  737.         Sleep(Round(2600 * $RunDelayMult))
  738.         Move($Loc6[$R][0], $Loc6[$R][1])
  739.         Sleep(Round(1600 * $RunDelayMult))
  740.  
  741.         BlowSkills($CastLoc[$R][0], $CastLoc[$R][1])
  742.  
  743.         ;Kill all the enemies inside
  744.         $Count = 5
  745.         While 1
  746.  
  747.             $MonsterBar = PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], _
  748.                     $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
  749.             If @error Then
  750.                 ConsoleWrite("Didn't find any, attacking to discover potential enemies" & @LF)
  751.                 Attack($MonsterLoc[$R][0], $MonsterLoc[$R][1])
  752.                 Sleep(500)
  753.                 $MonsterBar = PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], _
  754.                         $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
  755.                 If @error Then
  756.                     $Count -= 1
  757.                     If $Count < 0 Then
  758.                         ConsoleWrite("No monsters found - Moving on")
  759.                         ExitLoop
  760.                     Else
  761.                         ContinueLoop
  762.                     EndIf
  763.                 EndIf
  764.             EndIf
  765.             $Count = 1
  766.  
  767.             If TimerDiff($Skill3Timer) > ($Skill3CoolDown + 500) Then
  768.                 $Skill3Timer = TimerInit()
  769.                 MouseMove($MonsterBar[0], $MonsterBar[1], 0)
  770.                 Send("{3}")
  771.             ElseIf TimerDiff($RightClickTimer) > ($RightClickCoolCown + 500) Then
  772.                 $RightClickTimer = TimerInit()
  773.                 MouseClick("right", $MonsterBar[0], $MonsterBar[1])
  774.             Else
  775.                 For $i = 4 To 0 Step -1
  776.                     Attack($MonsterBar[0], $MonsterBar[1])
  777.                     Sleep(100)
  778.                 Next
  779.             EndIf
  780.  
  781.             If $NeedReset = True Then
  782.                 $NeedReset = False
  783.                 AdlibUnRegister("TimeOut")
  784.                 ContinueLoop 2
  785.             EndIf
  786.         WEnd
  787.  
  788.  
  789.         ;Loot the gold and attack anything we missed
  790.         $Timer0 = TimerInit()
  791.         Move($GoldLoot1[$R][0], $GoldLoot1[$R][1])
  792.         While TimerDiff($Timer0) < Round(1800 * $RunDelayMult)
  793.             If $LootPotions Then
  794.                 If _ImageSearchArea($pngLoc[$R] & "potion.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  795.                         $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 90) Then
  796.                     $HasPotion = True
  797.                 EndIf
  798.             EndIf
  799.             If $NeedReset = True Then
  800.                 $NeedReset = False
  801.                 AdlibUnRegister("TimeOut")
  802.                 ContinueLoop 2
  803.             EndIf
  804.         WEnd
  805.         AttackNearbyMonsters()
  806.         $Timer0 = TimerInit()
  807.         Move($GoldLoot2[$R][0], $GoldLoot2[$R][1])
  808.         While TimerDiff($Timer0) < Round(1400 * $RunDelayMult)
  809.             If $LootPotions Then
  810.                 If _ImageSearchArea($pngLoc[$R] & "potion.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  811.                         $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 90) Then
  812.                     $HasPotion = True
  813.                 EndIf
  814.             EndIf
  815.             If $NeedReset = True Then
  816.                 $NeedReset = False
  817.                 AdlibUnRegister("TimeOut")
  818.                 ContinueLoop 2
  819.             EndIf
  820.         WEnd
  821.         AttackNearbyMonsters()
  822.         $Timer0 = TimerInit()
  823.         Move($GoldLoot3[$R][0], $GoldLoot3[$R][1])
  824.         While TimerDiff($Timer0) < Round(1400 * $RunDelayMult)
  825.             If $LootPotions Then
  826.                 If _ImageSearchArea($pngLoc[$R] & "potion.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  827.                         $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 90) Then
  828.                     $HasPotion = True
  829.                 EndIf
  830.             EndIf
  831.             If $NeedReset = True Then
  832.                 $NeedReset = False
  833.                 AdlibUnRegister("TimeOut")
  834.                 ContinueLoop 2
  835.             EndIf
  836.         WEnd
  837.         AttackNearbyMonsters()
  838.  
  839.         ;Check to see if we died
  840.         If CheckForDeath() Then
  841.             LeaveGame()
  842.             ContinueLoop
  843.             AdlibUnRegister("TimeOut")
  844.         EndIf
  845.  
  846.         If $FastLoot Then
  847.             Send("t")
  848.             $Timer1 = TimerInit()
  849.             $Moved = False
  850.         EndIf
  851.  
  852.         ;Loot items
  853.         If $LootGems Then
  854.             $BagFull = LootGems()
  855.         EndIf
  856.  
  857.         If $LootGold Then
  858.             LootGold()
  859.         EndIf
  860.  
  861.         If $LootPotions And $HasPotion Then
  862.             LootPotions()
  863.         EndIf
  864.  
  865.         If $LootBlues And $BagFull = False Then
  866.             $Count = LootItemWrapper($MagicLetter, $BagFull, 10)
  867.             If $Count Then
  868.                 $HasBlue = True
  869.             EndIf
  870.         EndIf
  871.  
  872.         If $LootRares Then
  873.             $Count = LootItemWrapper($RareLetter, $BagFull, 10)
  874.             $Count = LootItemWrapper($SetLetter, $BagFull, 10)
  875.             $Count = LootItemWrapper($LegLetter, $BagFull, 10)
  876.         EndIf
  877.  
  878.         If $LootTomes Then
  879.             LootTomes()
  880.         EndIf
  881.  
  882.         ;Teleport to town
  883.         Send("{t}")
  884.         $Timer0 = TimerInit()
  885.         While _ImageSearchArea($pngLoc[$R] & "tristram.png", 1, $TristramTextCoord[$R][0], _
  886.                 $TristramTextCoord[$R][1], $TristramTextCoord[$R][2], _
  887.                 $TristramTextCoord[$R][3], $gX, $gY, 90) = 0
  888.             If TimerDiff($Timer0) > 30000 Then
  889.                 LeaveGame()
  890.                 AdlibUnRegister("TimeOut")
  891.                 ContinueLoop 2
  892.             EndIf
  893.             If $NeedReset = True Then
  894.                 $NeedReset = False
  895.                 AdlibUnRegister("TimeOut")
  896.                 ContinueLoop 2
  897.             EndIf
  898.         WEnd
  899.  
  900.         Sleep(1000 + $ComputerLag)
  901.  
  902.  
  903.         If $NeedReset = True Then
  904.             $NeedReset = False
  905.             AdlibUnRegister("TimeOut")
  906.             ContinueLoop
  907.         EndIf
  908.         RepairOrSellItems()
  909.  
  910.  
  911.         If $NeedReset = True Then
  912.             $NeedReset = False
  913.             AdlibUnRegister("TimeOut")
  914.             ContinueLoop
  915.         EndIf
  916.         ;Leave the game
  917.         LeaveGame()
  918.         AdlibUnRegister("TimeOut")
  919.  
  920.     EndIf
  921. WEnd
  922.  
  923. Exit -1
  924.  
  925. Func CheckForRepair()
  926.     $RepairNeeded = PixelSearch($RepairCheck[$R][0], $RepairCheck[$R][1], $RepairCheck[$R][0] + 5, _
  927.             $RepairCheck[$R][1] + 5, 0xFFE801, 10)
  928.  
  929.     If Not @error Then
  930.         Return True
  931.     Else
  932.         Return False
  933.     EndIf
  934. EndFunc   ;==>CheckForRepair
  935.  
  936.  
  937. Func RepairOrSellItems()
  938.     Local $NeedRepair
  939.     Local $xx
  940.     Local $yy
  941.     Local $sell
  942.     $NeedRepair = CheckForRepair()
  943.     ; Repair the gears when needed
  944.     If ($NeedRepair And $Repair) Or ($BagFull And $SellBlues And $HasBlue) Then
  945.         Move($RepairCoords[$R][0][0], $RepairCoords[$R][0][1])
  946.         Sleep(Round(3300 * $RunDelayMult))
  947.         MouseMove($RepairCoords[$R][1][0], $RepairCoords[$R][1][1])
  948.         Sleep(400)
  949.         Click($RepairCoords[$R][1][0], $RepairCoords[$R][1][1])
  950.         Sleep(Round(2000 * $RunDelayMult))
  951.         If $NeedRepair And $Repair Then
  952.             Click($RepairCoords[$R][2][0], $RepairCoords[$R][2][1])
  953.             Sleep(Random(700 - 900))
  954.             Click($RepairCoords[$R][3][0], $RepairCoords[$R][3][1])
  955.             Sleep(500)
  956.         EndIf
  957.         ; If the bag is full, sell the blues
  958.         If ($BagFull And $SellBlues And $HasBlue) Then
  959.             Click($SellCoords[$R][0], $SellCoords[$R][1])
  960.             $HasBlue = False
  961.             Sleep(500)
  962.             For $xx = 0 To 8 Step 1
  963.                 For $yy = 0 To 5 Step 1
  964.                     ; An item recently picked up has blue frame arround the slots
  965.                     $sell = PixelSearch($ItemStartCoord0[$R][0] + $xx * $SlotOffset[$R], _
  966.                             $ItemStartCoord0[$R][1] + $yy * $SlotOffset[$R], _
  967.                             $ItemStartCoord0[$R][2] + $xx * $SlotOffset[$R], _
  968.                             $ItemStartCoord0[$R][3] + $yy * $SlotOffset[$R], 0x0000FF, 10)
  969.                     If Not @error Then
  970.                         MouseClick("right", $sell[0], $sell[1])
  971.                     Else
  972.                         ; Otherwise the color of the frame is lighter
  973.                         $sell = PixelSearch($ItemStartCoord1[$R][0] + $xx * $SlotOffset[$R], _
  974.                                 $ItemStartCoord1[$R][1] + $yy * $SlotOffset[$R], _
  975.                                 $ItemStartCoord1[$R][2] + $xx * $SlotOffset[$R], _
  976.                                 $ItemStartCoord1[$R][3] + $yy * $SlotOffset[$R], 0x182A5B, 30)
  977.                         If Not @error Then
  978.                             MouseClick("right", $sell[0], $sell[1])
  979.                         EndIf
  980.                     EndIf
  981.                 Next
  982.             Next
  983.         EndIf
  984.         Sleep(300)
  985.         Send("{esc}")
  986.     EndIf
  987. EndFunc   ;==>RepairOrSellItems
  988.  
  989. Func Terminate()
  990.     Exit 0
  991. EndFunc   ;==>Terminate
  992.  
  993. Func LeaveGame()
  994.     Send("{esc}")
  995.     Sleep(400)
  996.     Click($Leave[$R][0], $Leave[$R][1])
  997. EndFunc   ;==>LeaveGame
  998.  
  999. Func Pause()
  1000.     $Paused = Not $Paused
  1001.     While $Paused
  1002.         Sleep(100)
  1003.         ToolTip('Paused... (Press PAUSE to run it)', 0, 0)
  1004.     WEnd
  1005.     ToolTip("")
  1006. EndFunc   ;==>Pause
  1007.  
  1008. Func Click($x, $y)
  1009.     MouseClick('left', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, 2)
  1010. EndFunc   ;==>Click
  1011.  
  1012. Func Move($x, $y)
  1013.     MouseClick('middle', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, 2)
  1014. EndFunc   ;==>Move
  1015.  
  1016. Func Attack($x, $y)
  1017.     Send("{SHIFTDOWN}")
  1018.     Sleep(20)
  1019.     MouseClick('left', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, 2)
  1020.     Sleep(20)
  1021.     Send("{SHIFTUP}")
  1022. EndFunc   ;==>Attack
  1023.  
  1024. Func Rest($z)
  1025.     Sleep(Random($z, $z + 25))
  1026. EndFunc   ;==>Rest
  1027.  
  1028. Func CheckForDeath()
  1029.     Return _ImageSearchArea($pngLoc[$R] & "percent.png", 1, $DeathBounds[$R][0], $DeathBounds[$R][1], _
  1030.             $DeathBounds[$R][2], $DeathBounds[$R][3], $gX, $gY, 60)
  1031. EndFunc   ;==>CheckForDeath
  1032.  
  1033. Func CalcDist($x, $y)
  1034.     Local $dx = $x - $CharLoc[$R][0]
  1035.     Local $dy = $y - $CharLoc[$R][1]
  1036.     Return Sqrt($dx ^ 2 + $dy ^ 2)
  1037. EndFunc   ;==>CalcDist
  1038.  
  1039. Func LootItemWrapper(ByRef $Array, ByRef $BagFull, $Attempt)
  1040.     Local $Count = 0
  1041.     Local $TmpBagFull
  1042.     If (TimerDiff($Timer1) > 3000) And ($Moved = False) And $FastLoot Then
  1043.         Move($CharLoc[$R][0], $CharLoc[$R][1])
  1044.         $Moved = True
  1045.     EndIf
  1046.     $TmpBagFull = LootItem($Array, $Count, $Attempt)
  1047.     If $TmpBagFull Then
  1048.         $BagFull = True
  1049.     EndIf
  1050.     If ($Moved = True) And $FastLoot Then
  1051.         Send("t")
  1052.         $Timer1 = TimerInit()
  1053.         $Moved = False
  1054.     EndIf
  1055.     Return $Count
  1056. EndFunc   ;==>LootItemWrapper
  1057.  
  1058. Func LootItem(ByRef $Array, ByRef $Count, ByRef $LootAttempts)
  1059.     Local $i
  1060.     Local $gX
  1061.     Local $gY
  1062.     Local $Found = 0
  1063.     Local $Timer
  1064.     Local $Delay
  1065.     For $i = 0 To 4
  1066.         MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1067.         If _ImageSearchArea($pngLoc[$R] & $Array[$i], 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  1068.                 $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 70) Then
  1069.             Click($gX, $gY)
  1070.             $Moved = True
  1071.             $Delay = Round($LootDelayMult * CalcDist($gX, $gY))
  1072.             $Timer = TimerInit()
  1073.             While TimerDiff($Timer) < $Delay
  1074.                 If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
  1075.                         $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
  1076.                     Return True
  1077.                 EndIf
  1078.             WEnd
  1079.             $Found = 1
  1080.             $Count += 1
  1081.         EndIf
  1082.     Next
  1083.  
  1084.     $LootAttempts -= 1
  1085.     If ($LootAttempts = 0) Or ($Found = 0) Then
  1086.         Return False
  1087.     Else
  1088.         Return LootItem($Array, $Count, $LootAttempts)
  1089.     EndIf
  1090. EndFunc   ;==>LootItem
  1091.  
  1092. Func LootGems()
  1093.     Local $gX = 0
  1094.     Local $gY = 0
  1095.     Local $Attempt = 10
  1096.     Local $Timer
  1097.     Local $Delay
  1098.     MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1099.     If (TimerDiff($Timer1) > 3500) And ($Moved = False) And $FastLoot Then
  1100.         Move($CharLoc[$R][0], $CharLoc[$R][1])
  1101.         $Moved = True
  1102.     EndIf
  1103.     While _ImageSearchArea($pngLoc[$R] & $Gem, 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  1104.             $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 120) And $Attempt
  1105.         MouseClick("left", $gX, $gY, 1, 0)
  1106.         $Moved = True
  1107.         $Delay = Round($LootDelayMult * CalcDist($gX, $gY))
  1108.         $Timer = TimerInit()
  1109.         While TimerDiff($Timer) < $Delay
  1110.             If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
  1111.                     $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
  1112.                 If $Moved = True Then
  1113.                     Send("t")
  1114.                     $Timer1 = TimerInit()
  1115.                     $Moved = False
  1116.                 EndIf
  1117.                 Return True
  1118.             EndIf
  1119.         WEnd
  1120.         MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1121.         $Attempt -= 1
  1122.     WEnd
  1123.     If ($Moved = True) And $FastLoot Then
  1124.         Send("t")
  1125.         $Timer1 = TimerInit()
  1126.         $Moved = False
  1127.     EndIf
  1128.     Return False
  1129. EndFunc   ;==>LootGems
  1130.  
  1131. Func LootTomes()
  1132.     Local $gX = 0
  1133.     Local $gY = 0
  1134.     Local $Attempt = 10
  1135.     MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1136.     If (TimerDiff($Timer1) > 3500) And ($Moved = False) And $FastLoot Then
  1137.         Move($CharLoc[$R][0], $CharLoc[$R][1])
  1138.         $Moved = True
  1139.     EndIf
  1140.     While _ImageSearchArea($pngLoc[$R] & "tome.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  1141.             $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 100) And $Attempt
  1142.         MouseClick("left", $gX, $gY, 1, 0)
  1143.         $Moved = True
  1144.         Sleep(Round($LootDelayMult * CalcDist($gX, $gY)))
  1145.         MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1146.         $Attempt -= 1
  1147.     WEnd
  1148.     If ($Moved = True) And $FastLoot Then
  1149.         Send("t")
  1150.         $Timer1 = TimerInit()
  1151.         $Moved = False
  1152.     EndIf
  1153. EndFunc   ;==>LootTomes
  1154.  
  1155. Func LootPotions()
  1156.     Local $gX = 0
  1157.     Local $gY = 0
  1158.     Local $Attempt = 10
  1159.     MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1160.     If (TimerDiff($Timer1) > 3500) And ($Moved = False) And $FastLoot Then
  1161.         Move($CharLoc[$R][0], $CharLoc[$R][1])
  1162.         $Moved = True
  1163.     EndIf
  1164.     While _ImageSearchArea($pngLoc[$R] & "potion.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  1165.             $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 100) And $Attempt
  1166.         MouseClick("left", $gX, $gY, 1, 0)
  1167.         $Moved = True
  1168.         Sleep(Round($LootDelayMult * CalcDist($gX, $gY)))
  1169.         MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1170.         $Attempt -= 1
  1171.     WEnd
  1172.     If ($Moved = True) And $FastLoot Then
  1173.         Send("t")
  1174.         $Timer1 = TimerInit()
  1175.         $Moved = False
  1176.     EndIf
  1177. EndFunc   ;==>LootPotions
  1178.  
  1179. Func LootGold()
  1180.     Local $gX = 0
  1181.     Local $gY = 0
  1182.     Local $Attempt = 10
  1183.     MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1184.     If (TimerDiff($Timer1) > 3500) And ($Moved = False) And $FastLoot Then
  1185.         Move($CharLoc[$R][0], $CharLoc[$R][1])
  1186.         $Moved = True
  1187.     EndIf
  1188.     While _ImageSearchArea($pngLoc[$R] & "gold.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
  1189.             $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 100) And $Attempt
  1190.         MouseClick("middle", $gX, $gY + 20, 1, 0)
  1191.         $Moved = True
  1192.         Sleep(Round($LootDelayMult * CalcDist($gX, $gY + 20)))
  1193.         MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0], 0)
  1194.         $Attempt -= 1
  1195.     WEnd
  1196.     If ($Moved = True) And $FastLoot Then
  1197.         Send("t")
  1198.         $Timer1 = TimerInit()
  1199.         $Moved = False
  1200.     EndIf
  1201. EndFunc   ;==>LootGold
  1202.  
  1203. Func BlowSkills($x, $y)
  1204.     MouseMove($x, $y, 2)
  1205.     ;Cast Voodoo and Grasp of the Dead to ensure safety
  1206.     Send("{1}")
  1207.     Sleep(Round(500 * $CastSpeedMult))
  1208.     Send("{3}")
  1209.     $Skill3Timer = TimerInit()
  1210.     Sleep(Round(500 * $CastSpeedMult))
  1211.     MouseClick("right", $x, $y)
  1212.     $RightClickTimer = TimerInit()
  1213. EndFunc   ;==>BlowSkills
  1214.  
  1215. Func AttackNearbyMonsters()
  1216.     While 1
  1217.         $MonsterData = PixelSearch($CharHitBox[$R][0], $CharHitBox[$R][1], $CharHitBox[$R][2], $CharHitBox[$R][3], 0xEE0000, 10)
  1218.         If @error Then
  1219.             ExitLoop
  1220.         EndIf
  1221.         If TimerDiff($Skill4Timer) > ($Skill4CoolDown + 500) Then
  1222.             Send("{4}")
  1223.             $Skill4Timer = TimerInit()
  1224.         EndIf
  1225.  
  1226.         If TimerDiff($Skill3Timer) > ($Skill3CoolDown + 500) Then
  1227.             MouseMove($MonsterData[0], $MonsterData[1], 0)
  1228.             Send("{3}")
  1229.             $Skill3Timer = TimerInit()
  1230.         ElseIf TimerDiff($RightClickTimer) > ($RightClickCoolCown + 500) Then
  1231.             MouseClick("right", $MonsterData[0], $MonsterData[1], 1, 1)
  1232.             $RightClickTimer = TimerInit()
  1233.         Else
  1234.             For $i = 7 To 0 Step -1
  1235.                 Attack($MonsterData[0], $MonsterData[1])
  1236.                 Sleep(100)
  1237.             Next
  1238.         EndIf
  1239.     WEnd
  1240. EndFunc   ;==>AttackNearbyMonsters
  1241.  
  1242. Func CheckForNearbyMonsters()
  1243.     $MonsterData = PixelSearch($CharHitBox[$R][0], $CharHitBox[$R][1], $CharHitBox[$R][2], $CharHitBox[$R][3], 0xEE0000, 10)
  1244.     If @error Then
  1245.         Return False
  1246.     Else
  1247.         Return True
  1248.     EndIf
  1249. EndFunc   ;==>CheckForNearbyMonsters
  1250.  
  1251. Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
  1252.     $findImage = "*TRANSBLACK " & $findImage
  1253.     If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
  1254.     If @AutoItX64 Then
  1255.         $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1256.     Else
  1257.         $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
  1258.     EndIf
  1259.     If $result = "0" Then Return 0
  1260.  
  1261.     ; Otherwise get the x,y location of the match and the size of the image to
  1262.     ; compute the centre of search
  1263.     $Array = StringSplit($result[0], "|")
  1264.     If (UBound($Array) >= 4) Then
  1265.         $x = Int(Number($Array[2]))
  1266.         $y = Int(Number($Array[3]))
  1267.         If $resultPosition = 1 Then
  1268.             $x = $x + Int(Number($Array[4]) / 2)
  1269.             $y = $y + Int(Number($Array[5]) / 2)
  1270.         EndIf
  1271.         Return 1
  1272.     EndIf
  1273. EndFunc   ;==>_ImageSearchArea
  1274.  
  1275. Func ActivateGUI()
  1276.  
  1277.     ;setup the UI
  1278.     $Waiting = True
  1279.  
  1280.     $Form1 = GUICreate("D3 Witch Doctor bot by Avatar88343 and Andygongyb", 500, 320, -1, -1)
  1281.  
  1282.     GUICtrlCreateLabel("Warning: the script is for education only, not approved for any form of commercial use", _
  1283.             25, 30, 550, -1)
  1284.  
  1285.     GUICtrlCreateLabel("Hotkeys:" & @CRLF & @TAB & "Terminate:" & @TAB & "DELETE" & @CRLF _
  1286.              & @TAB & "Pause:" & @TAB & @TAB & "PAUSE", 25, 50, 550, -1)
  1287.  
  1288.     GUICtrlCreateLabel("Game Resolution", 25, 100, 100, -1)
  1289.     $ResCombo = GUICtrlCreateCombo("", 25, 115, 200, -1)
  1290.     GUICtrlSetData($ResCombo, "1920 x 1080|800 x 600", "Select your Res")
  1291.  
  1292.     GUICtrlCreateLabel("Character run speed (for 800x600)", 275, 100, 200, -1)
  1293.     $RunInput = GUICtrlCreateInput("0", 275, 115, 200, -1)
  1294.  
  1295.     $LootRareCheck = GUICtrlCreateCheckbox("Loot rares/legs/sets", 25, 160)
  1296.     GUICtrlSetState($LootRareCheck, $GUI_CHECKED)
  1297.  
  1298.     $LootBluesCheck = GUICtrlCreateCheckbox("Loot blues", 150, 160)
  1299.     GUICtrlSetState($LootBluesCheck, $GUI_CHECKED)
  1300.  
  1301.     $LootGemsCheck = GUICtrlCreateCheckbox("Loot gems", 275, 160)
  1302.     GUICtrlSetState($LootGemsCheck, $GUI_CHECKED)
  1303.  
  1304.     $LootPotionsCheck = GUICtrlCreateCheckbox("Loot potions", 400, 160)
  1305.     GUICtrlSetState($LootPotionsCheck, $GUI_CHECKED)
  1306.  
  1307.     $LootTomesCheck = GUICtrlCreateCheckbox("Loot tomes of secret", 25, 190)
  1308.     GUICtrlSetState($LootTomesCheck, $GUI_CHECKED)
  1309.  
  1310.     $LootGoldCheck = GUICtrlCreateCheckbox("Collect the gold carefully (slower)", 275, 190)
  1311.     GUICtrlSetState($LootGoldCheck, $GUI_CHECKED)
  1312.  
  1313.     $RepairCheckbox = GUICtrlCreateCheckbox("Repair gears when needed", 25, 220)
  1314.     GUICtrlSetState($RepairCheckbox, $GUI_CHECKED)
  1315.  
  1316.     $SellBluesCheckbox = GUICtrlCreateCheckbox("Sell blue item when the bag is full", 275, 220)
  1317.     GUICtrlSetState($SellBluesCheckbox, $GUI_CHECKED)
  1318.  
  1319.     $StartButton = GUICtrlCreateButton("Start", 175, 260, 150, 33)
  1320.  
  1321.     GUISetState(@SW_SHOW)
  1322.  
  1323.     ;Wait for them to press start
  1324.     While $Waiting
  1325.         $Action = GUIGetMsg()
  1326.  
  1327.         If $Action = $GUI_EVENT_CLOSE Then Terminate()
  1328.         If $Action = $StartButton Then ExitLoop
  1329.  
  1330.         Sleep(50)
  1331.     WEnd
  1332.  
  1333.     ;Get the values
  1334.     $SelectedRes = GUICtrlRead($ResCombo)
  1335.     If $SelectedRes = "1920 x 1080" Then
  1336.         $R = 0
  1337.     ElseIf $SelectedRes = "800 x 600" Then
  1338.         $R = 1
  1339.     Else
  1340.         MsgBox(0, "Error", "You did not select a resolution! Try again")
  1341.         Terminate()
  1342.     EndIf
  1343.  
  1344.     $RunSpeed = Int(GUICtrlRead($RunInput))
  1345.     $LootRares = GUICtrlRead($LootRareCheck) = $GUI_CHECKED
  1346.     $LootBlues = GUICtrlRead($LootBluesCheck) = $GUI_CHECKED
  1347.     $LootGems = GUICtrlRead($LootGemsCheck) = $GUI_CHECKED
  1348.     $LootPotions = GUICtrlRead($LootPotionsCheck) = $GUI_CHECKED
  1349.     $LootTomes = (GUICtrlRead($LootTomesCheck) = $GUI_CHECKED)
  1350.     $LootGold = GUICtrlRead($LootGoldCheck) = $GUI_CHECKED
  1351.     $Repair = GUICtrlRead($RepairCheckbox) = $GUI_CHECKED
  1352.     $SellBlues = (GUICtrlRead($SellBluesCheckbox) = $GUI_CHECKED) And $LootBlues
  1353.  
  1354.     GUISetState(@SW_HIDE)
  1355. EndFunc   ;==>ActivateGUI
Add Comment
Please, Sign In to add comment