Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #cs
- Witch Doctor Cellar Farming Bot - Version 0.5 [1920x1080 ONLY]
- Developed by Avatar88343 @ Ownedcore and andygongyb @ Ownedcore after V. 0.5
- Other contributers:
- What it does:
- *This bot will travel to the cellar in Act 1, kill the mobs, collect the gold and items, and repair your gear.
- Newbiew Info:
- This is a script that runs on AutoIt. You run this bot by Downloading AutoIt from the web (it's free) and installing it.
- You then paste all this code into any text editor (such as notepad) and save it anywhere on your hard drive. Follow the Select
- steps below to configure this bot before you run it.
- Special Instructions for 1920 x 1080:
- 1.) Set your game resolution to 1920x1080 (required)
- 2.) Set the display mode to Fullscreen Windowed (Don't forget!)
- 3.) Follow the Instructions (for all resolutions) section below
- Special Instructions for 800 x 600:
- 1.)Exit Diablo 3
- 2.)Go to your document folder and locate the Diablo III folder
- 3.)Open the D3Prefs file in any editor (such as notepad)
- 4.)Change the following settings to the ones listed below
- "DisplayModeFlags "0"
- DisplayModeWindowMode "1"
- DisplayModeWinLeft "428"
- DisplayModeWinTop "162"
- DisplayModeWinWidth "800"
- DisplayModeWinHeight "600"
- DisplayModeUIOptWidth "800"
- DisplayModeUIOptHeight "600"
- DisplayModeWidth "800"
- DisplayModeHeight "600"
- DisplayModeRefreshRate "75"
- DisplayModeBitDepth "32""
- 5.) Follow the Instructions (for all resolutions) section below
- Instructions (for all resolutions)
- 1.) Bind your middle mouse button to Move (found in Key Bindings Option)
- 2.) Set your build to this http://us.battle.net/d3/en/calculator/witch-doctor#jaQPZU!VZW!babbca
- 3.) Start Act 1, Quest 6 - Talk to Alaric
- 4.) Hire the Scoundrel
- 5.) Teleport to The Old Ruins using the waypoint and run left until you reach a checkpoint
- 6.) Log out of the game
- 7.) Press F2 to start the bot! Space is used to pause and resume the bot
- 8.) Press shift + \ to turn off the bot
- NOTE:
- *Please make sure you are running the correct resolution settings!
- *You must be running the game in Fullscreen Windoed mode if you're using 1080P
- *You WILL need to edit the values below the comments for better results
- FEATURES:
- *Supports 1080P Fullscreen Windowed and 800x600 Windowed (V. 0.5 only supports 1080P currently)
- *Automatic looting of Rare, Legendary, and Set items
- *Also able to loot blue items, tomes, and gems
- *Optionally sells blue items when the bag is full
- *Repairs Items when damaged
- *Detects death and responds accordingly
- *Detects connection lost and automatically reconnect (not tested)
- *Randomization for increased safety
- *Added ability to find Cellar during bad runs
- IN DEVELOPMENT:
- *Multi-resolution support (need people to help)
- *Stash use
- *Improved combat
- *Speed improvements
- *Multiple routes to improve safety
- *45 min timeout bug
- *Edit d3config
- *Salvage lv60 blue items automatically
- **Based on the code by notAres and mackus101. Special thanks to them!
- #ce
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- ;======THESE VALUES ARE NOT EDITED WITH THE GUI ===================================
- $R = 0 ; Leave this as 0 if you are using 1080P. Change it to 1 if you're using 800 x 600
- $ComputerLag = 1000 ; Increase this by 100-5000 if you have a slow PC.
- $RunSpeed = 10 ; Enter your character's run speed here
- $LootRares = True ; Whether or not to loot rare and legendary items
- $LootBlues = True ; Whether or not to loot blue items
- $LootGems = True ; Whether or not to loot gems
- $LootPotions = True ; Whether or not to loot potions
- $LootTomes = True ; Whether or not to loot Tome of Secret
- $LootGold = True ; Whether or to collect gold that is missed during the first collection attempt
- $Repair = True ; Orders the bot to repair when items are damaged
- $SellBlues = True ; Orders the bot to sell blue items when the bag is full
- ;======================================================================
- Global $Resume[2][2] ;Location of the Resume Button
- Global $Leave[2][2] ;Location of the in-game leave button
- Global $GameLobbyCode[2][3] ;Contains X, Y, and Hex color of Resume button so we can see if we're there
- Global $GameScreenCode[2][3] ;Contains X, Y, and Hex color used to check if we are in an unpaused game
- Global $Loc1[2][2] ;First movement
- Global $Loc2[2][2] ;Second movement
- Global $Loc3[2][2] ;Third movement ttt
- Global $CellarLocation[2][2] ;Cellar door location
- Global $CellarLocation2[2] ;Location of cellar during bad runs (ugly workaround for now)
- Global $AltCellar = False
- Global $Loc5[2][2] ; Cellar hallway
- Global $Loc6[2][2] ; Cellar doorway
- Global $MonsterLoc[2][2] ; Initial boss location
- Global $MonsterSearch[2][4] ; Bounds of where we will find our monsters
- Global $GoldLoot1[2][2] ; First place to run when looting
- Global $GoldLoot2[2][2] ; Second place to run when looting
- Global $GoldLoot3[2][2] ; Third place to run when looting
- Global $LootingArea[2][4] ; looting bounds (TL X, TL Y, BR X, BR Y)
- Global $CharHitBox[2][4] ; Hitbox around user's character
- Global $DeathBounds[2][2] ; Used to detect the "You Have Died" text
- Global $RepairCoords[2][4][2] ; Four clicks needed to repair
- Global $RepairCheck[2][2] ; Used to check for repair icon
- Global $CellarOffset[2] ; Used to improve cellar clicking with 1080P/800x600
- Global $CellarIcon ; Used to find the yellow cellar icon on the minimap (future use)
- Global $pngLoc[2] ; Absolute path of the folder containing pics for image search
- Global $LostConnectionOkBtn[2][2] ; The coordinate of the OK button of the "lost connection" window
- Global $LostConnectionText0[2][4] ; Image search area of the "lost connection" text
- Global $LostConnectionText1[2][4]
- Global $CharLoc[2][2] ; Location where the character stands
- Global $CastLoc[2][2] ; Location to cast Grasp of the Dead in the cellar
- Global $SellCoords[2][2] ; Coordinate of the sell button
- Global $SlotOffset[2] ; Length of each slot in the item window
- Global $ItemStartCoord0[2][4] ; Pixel search area of the first slot on the second column in item window
- Global $ItemStartCoord1[2][4]
- Global $BagFullCoords[2][4] ; Image search area of the bag full message
- Global $IdleCursorCoords[2][2] ; Coordinate of where the cursor should go for not covering any item name
- Global $CellarPixel
- Global $RunDelayMult[2] ; Scaler for calculating the delay to run to an item
- Global $GemLootOffset[2] ; Distance between gem and its text
- Global $BagFull
- Global $HasBlue
- ActivateGUI()
- ;Check for people that can't read instructions
- If Int($R) < 0 Or Int($R) > 1 Then
- MsgBox(4096, "A wild illiterate appears appears!", "Aha! I caught you! You did not read the instructions. You need to configure the bot!")
- terminate()
- EndIf
- ;Clculate run speed
- Global $RunTime = 30 * (100 - $RunSpeed) + 2000 ;Length of time to run in 800x600
- ;All locations are N dimensional arrays. [0][x] is for 1080P and [1][x] is for 800x600
- ;1080P
- ;1920x1080
- $pngLoc[0] = "F:\Program Files (x86)\Diablo III\pics\1920x1080\" ; Location of the .PNGs (NO SUBFOLDERS - ALL PNGS GO HERE)
- $Resume[0][0] = 319
- $Resume[0][1] = 416
- $GameLobbyCode[0][0] = 319
- $GameLobbyCode[0][1] = 416
- $GameLobbyCode[0][2] = 4065536
- $GameScreenCode[0][0] = 1119
- $GameScreenCode[0][1] = 1044
- $GameScreenCode[0][2] = 0xDEFDFE
- $LostConnectionOkBtn[0][0] = 957
- $LostConnectionOkBtn[0][1] = 630
- $LostConnectionText0[0][0] = 764
- $LostConnectionText0[0][1] = 493
- $LostConnectionText0[0][2] = 843
- $LostConnectionText0[0][3] = 521
- $LostConnectionText1[0][0] = 779
- $LostConnectionText1[0][1] = 507
- $LostConnectionText1[0][2] = 853
- $LostConnectionText1[0][3] = 525
- $CharLoc[0][0] = 944
- $CharLoc[0][1] = 507
- $CastLoc[0][0] = 600
- $CastLoc[0][1] = 300
- $SellCoords[0][0] = 517
- $SellCoords[0][1] = 238
- $SlotOffset[0] = 48
- $ItemStartCoord0[0][0] = 1460
- $ItemStartCoord0[0][1] = 631
- $ItemStartCoord0[0][2] = 1462
- $ItemStartCoord0[0][3] = 633
- $ItemStartCoord1[0][0] = 1460
- $ItemStartCoord1[0][1] = 625
- $ItemStartCoord1[0][2] = 1468
- $ItemStartCoord1[0][3] = 632
- $BagFullCoords[0][0] = 1060
- $BagFullCoords[0][1] = 125
- $BagFullCoords[0][2] = 1120
- $BagFullCoords[0][3] = 160
- $IdleCursorCoords[0][0] = 400
- $IdleCursorCoords[0][1] = 300
- $RunDelayMult[0] = 1.5
- ;800x600
- $pngLoc[1] = "F:\Program Files (x86)\Diablo III\pics\800x600\" ; Need people to make those pics
- $Resume[1][0] = 174
- $Resume[1][1] = 232
- $GameLobbyCode[1][0] = 174
- $GameLobbyCode[1][1] = 232
- $GameLobbyCode[1][2] = 4262400
- $GameScreenCode[1][0] = 486
- $GameScreenCode[1][1] = 578
- $GameScreenCode[1][2] = 0x6C9BFF
- ; Need people working on the following coordinates
- $LostConnectionOkBtn[1][0] = 0
- $LostConnectionOkBtn[1][1] = 0
- $LostConnectionText0[1][0] = 0
- $LostConnectionText0[1][1] = 0
- $LostConnectionText0[1][2] = 0
- $LostConnectionText0[1][3] = 0
- $LostConnectionText1[1][0] = 0
- $LostConnectionText1[1][1] = 0
- $LostConnectionText1[1][2] = 0
- $LostConnectionText1[1][3] = 0
- $CharLoc[1][0] = 0
- $CharLoc[1][0] = 0
- $CastLoc[1][0] = 0
- $CastLoc[1][1] = 0
- $SellCoords[1][0] = 0
- $SellCoords[1][1] = 0
- $SlotOffset[1] = 0
- $ItemStartCoord0[1][0] = 0
- $ItemStartCoord0[1][1] = 0
- $ItemStartCoord0[1][2] = 0
- $ItemStartCoord0[1][3] = 0
- $ItemStartCoord1[1][0] = 0
- $ItemStartCoord1[1][1] = 0
- $ItemStartCoord1[1][2] = 0
- $ItemStartCoord1[1][3] = 0
- $BagFullCoords[1][0] = 0
- $BagFullCoords[1][1] = 0
- $BagFullCoords[1][2] = 0
- $BagFullCoords[1][3] = 0
- $IdleCursorCoords[1][0] = 0
- $IdleCursorCoords[1][1] = 0
- $RunDelayMult[1] = 0
- ;1920x1080
- $Leave[0][0] = 969
- $Leave[0][1] = 582
- ;800x600
- $Leave[1][0] = 397
- $Leave[1][1] = 322
- ;1920x1080
- $Loc1[0][0] = 500 ;First movement
- $Loc1[0][1] = 250
- $Loc2[0][0] = 1 ;Second movement
- $Loc2[0][1] = 370
- $Loc3[0][0] = 400 ;Third Movement
- $Loc3[0][1] = 600
- ;800x600
- $Loc1[1][0] = 8 ;First movement
- $Loc1[1][1] = 146
- $Loc2[1][0] = 7 ;Second movement
- $Loc2[1][1] = 300
- $Loc3[1][0] = 8 ;Third Movement
- $Loc3[1][1] = 300
- ;1080P
- $CellarLocation[0][0] = 307 ;Cellar door location
- $CellarLocation[0][1] = 74
- ;800x600
- $CellarLocation[1][0] = 499 ;Cellar door location
- $CellarLocation[1][1] = 148
- $CellarLocation2[0] = 439
- $CellarLocation2[1] = 145
- $AltCellarLocation = False
- ;Cellar offset
- $CellarOffset[0] = 33;
- $CellarOffset[1] = 10;
- ;1080P
- $Loc5[0][0] = 116 ;Walk down hallway
- $Loc5[0][1] = 986
- $Loc6[0][0] = 776 ;enter hallway
- $Loc6[0][1] = 328
- ;800x600
- $Loc5[1][0] = 3 ;Walk down hallway
- $Loc5[1][1] = 504
- $Loc6[1][0] = 255 ;enter hallway
- $Loc6[1][1] = 190
- ;1080P
- $MonsterLoc[0][0] = 577
- $MonsterLoc[0][1] = 183
- ;800x600
- $MonsterLoc[1][0] = 188
- $MonsterLoc[1][1] = 111
- ;1920x1080
- $MonsterSearch[0][0] = 162
- $MonsterSearch[0][1] = 29
- $MonsterSearch[0][2] = 1248
- $MonsterSearch[0][3] = 446
- ;800x600
- $MonsterSearch[1][0] = 40
- $MonsterSearch[1][1] = 53
- $MonsterSearch[1][2] = 424
- $MonsterSearch[1][3] = 191
- ;1920x1080
- $GoldLoot1[0][0] = 402
- $GoldLoot1[0][1] = 306
- $GoldLoot2[0][0] = 1260
- $GoldLoot2[0][1] = 351
- $GoldLoot3[0][0] = 911
- $GoldLoot3[0][1] = 694
- ;800x600
- $GoldLoot1[1][0] = 96
- $GoldLoot1[1][1] = 181
- $GoldLoot2[1][0] = 560
- $GoldLoot2[1][1] = 191
- $GoldLoot3[1][0] = 349
- $GoldLoot3[1][1] = 418
- ;1080P
- $LootingArea[0][0] = 300
- $LootingArea[0][1] = 200
- $LootingArea[0][2] = 1600
- $LootingArea[0][3] = 800
- ;800x600
- $LootingArea[1][0] = 75
- $LootingArea[1][1] = 90
- $LootingArea[1][2] = 630
- $LootingArea[1][3] = 400
- ;1080P
- $CharHitBox[0][0] = 790
- $CharHitBox[0][1] = 315
- $CharHitBox[0][2] = 1200
- $CharHitBox[0][3] = 730
- ;800x600
- $CharHitBox[1][0] = 304
- $CharHitBox[1][1] = 190
- $CharHitBox[1][2] = 468
- $CharHitBox[1][3] = 323
- ;1080P
- $DeathBounds[0][0] = 538
- $DeathBounds[0][1] = 335
- ;800x600
- $DeathBounds[1][0] = 210
- $DeathBounds[1][1] = 180
- ;1080P
- $RepairCoords[0][0][0] = 1690
- $RepairCoords[0][0][1] = 102
- $RepairCoords[0][1][0] = 930
- $RepairCoords[0][1][1] = 136
- $RepairCoords[0][2][0] = 517
- $RepairCoords[0][2][1] = 483
- $RepairCoords[0][3][0] = 223
- $RepairCoords[0][3][1] = 592
- ;800x600
- $RepairCoords[1][0][0] = 691
- $RepairCoords[1][0][1] = 88
- $RepairCoords[1][1][0] = 505
- $RepairCoords[1][1][1] = 52
- $RepairCoords[1][2][0] = 282
- $RepairCoords[1][2][1] = 261
- $RepairCoords[1][3][0] = 157
- $RepairCoords[1][3][1] = 329
- ;1080P
- $RepairCheck[0][0] = 1507
- $RepairCheck[0][1] = 36
- ;800x600
- $RepairCheck[1][0] = 573
- $RepairCheck[1][1] = 21
- Opt('MouseCoordMode', 2)
- Opt('PixelCoordMode', 2)
- HotKeySet("|", "Terminate")
- HotKeySet('{F2}', 'Pause')
- Global $Paused
- ;bot starts paused. press space to start.
- Pause()
- ;Finding loot takes time. We don't want to overdo it
- $LootAttempts = 0
- $GemLootAttempts = 0
- $HasBlue = 0
- Sleep(400) ; Please put a random small number here which will confuse Wardon's harsh function
- WinActivate('Diablo III')
- While 1
- If WinActive('Diablo III') Then
- Local $gX
- Local $gY
- $AltCellarLocation = False
- $LootAttempts = 0
- $GemLootAttempts = 0
- $BagFull = False
- ;Make sure that we are in the character selection screen ( we are looking at a spot in the Resume game button)
- For $i = 15 To 0 Step -1
- If InGameLobby() Then
- ExitLoop
- EndIf
- Sleep(600)
- If _ImageSearchArea($pngLoc[$R] & "game.png", 1, $LostConnectionText0[$R][0], _
- $LostConnectionText0[$R][1], $LostConnectionText0[$R][2], _
- $LostConnectionText0[$R][3], $gX, $gY, 90) _
- Or _ImageSearchArea($pngLoc[$R] & "therewas.png", 1, $LostConnectionText1[$R][0], _
- $LostConnectionText1[$R][1], $LostConnectionText1[$R][2], _
- $LostConnectionText1[$R][3], $gX, $gY, 90) Then
- ; check if we lost connection
- Click($LostConnectionOkBtn[$R][0], $LostConnectionOkBtn[$R][1])
- ContinueLoop
- EndIf
- If $i == 1 Then
- 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)
- Terminate()
- EndIf
- Next
- ;Resume the game
- Click($Resume[$R][0], $Resume[$R][1])
- ;Make sure that we are in the game
- For $i = 12 To 0 Step -1
- If InGameplayScreen() Then
- ExitLoop
- EndIf
- Sleep(1000)
- If $i == 1 Then
- MsgBox(4096, "Error Starting the Game", "The game did not properly load...Are you using English language? Do not use custom themes!", 50)
- Terminate()
- EndIf
- Next
- Rest(200)
- Send("{2}")
- Rest(400)
- ;Custom running for the 800x600. Sometimes I wonder if it's faster to just buy everyone a 1080P monitor...
- If Int($R) == 1 Then
- MouseMove(11, 220)
- Sleep(400)
- Send("{4}")
- MouseDown("middle")
- Sleep($RunTime)
- MouseUp("middle")
- Sleep(2000)
- #cs $CellarIcon = PixelSearch(630, 70, 741, 149, 0x71341A, 5)
- if not @error then
- ConsoleWrite("Foundtheseller" & @LF)
- EndIf
- #ce
- Else
- Move($Loc1[$R][0], $Loc1[$R][1])
- Sleep(200)
- Send("{4}")
- Sleep(500)
- Move($Loc2[$R][0], $Loc2[$R][1])
- Sleep(1100)
- Move($Loc3[$R][0], $Loc3[$R][1])
- EndIf
- ;Check to see if the cellar is there ```````
- MouseMove($CellarLocation[$R][0], $CellarLocation[$R][1])
- Sleep(400)
- If Int($R) = 1 Then
- $CellarPixel = PixelSearch($CellarLocation[$R][0] - 30, $CellarLocation[$R][1] - 30, _
- $CellarLocation[$R][0] + 20, $CellarLocation[$R][1] + 20, 0x93D7F9, 8)
- If @error Then
- MouseMove($CellarLocation2[0], $CellarLocation2[1])
- Sleep(300)
- $CellarPixel = PixelSearch($CellarLocation2[0] - 30, $CellarLocation2[1] - 30, _
- $CellarLocation2[0] + 20, $CellarLocation2[1] + 20, 0x93D7F9, 8)
- If Not @error Then
- $AltCellarLocation = True
- EndIf
- EndIf
- Else
- $CellarPixel = PixelSearch($CellarLocation[$R][0] - $CellarOffset[$R], $CellarLocation[$R][1] _
- - $CellarOffset[$R], $CellarLocation[$R][0] + 4, $CellarLocation[$R][1] + 4, 0x334FB7, 6)
- EndIf
- ;Leave the game if the Cellar is not there
- If @error Then
- ConsoleWrite("Did not find the cellar " & @LF)
- Send("{SHIFTDOWN}")
- Sleep(10)
- Click($CharLoc[$R][0], $CharLoc[$R][1])
- Sleep(300)
- Send("{SHIFTUP}")
- ;Cast Voodoo and Grasp of the Dead to ensure safety
- Send("{1}")
- Rest(300)
- Send("{3}")
- Rest(300)
- leaveGame()
- Sleep(12000)
- ContinueLoop
- EndIf
- ;Enter the cellar
- ConsoleWrite("Entering the Cellar..." & @LF)
- If $R > 0 And $AltCellar Then
- Click($CellarLocation2[$R][0] - 4, $CellarLocation2[$R][1] - 4)
- Else
- If Not $AltCellarLocation Then
- Click($CellarLocation[$R][0], $CellarLocation[$R][1])
- Else
- Click($CellarLocation2[0], $CellarLocation2[1])
- EndIf
- EndIf
- If Int($R) == 1 Then
- Sleep(1000 + $ComputerLag)
- Else
- Sleep(3500 + $ComputerLag)
- EndIf
- ;Check to see if we died
- If CheckForDeath() Then
- ContinueLoop
- EndIf
- ;Inside the celler now - Move to the doorway
- Move($Loc5[$R][0], $Loc5[$R][1])
- Sleep(1500)
- Move($Loc6[$R][0], $Loc6[$R][1])
- ;Cast Grasp of the Dead
- MouseMove($CastLoc[$R][0], $CastLoc[$R][1])
- Sleep(300)
- Send("{3}")
- Sleep(350)
- ;Cast Voodoo
- Send("{1}")
- Sleep(350)
- ;Kill all the enemies inside
- While 1
- $MonsterBar = PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], _
- $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
- If @error Then
- ConsoleWrite("Didn't find any, attacking to discover potential enemies" & @LF)
- Attack($MonsterLoc[$R][0], $MonsterLoc[$R][1])
- Sleep(500)
- $MonsterBar = PixelSearch($MonsterSearch[$R][0], $MonsterSearch[$R][1], _
- $MonsterSearch[$R][2], $MonsterSearch[$R][3], 0xEE0000, 10)
- If @error Then
- ConsoleWrite("No monsters found - Moving on")
- ExitLoop
- EndIf
- EndIf
- ;if CheckForNearbyMonsters() Then
- ;send("{4}")
- ;EndIf
- For $i = 7 To 0 Step -1
- Attack($MonsterBar[0], $MonsterBar[1])
- Sleep(100)
- Next
- WEnd
- ;Loot the gold and attack anything we missed
- Move($GoldLoot1[$R][0], $GoldLoot1[$R][1])
- Sleep(Random(800, 900))
- AttackNearbyMonsters()
- Move($GoldLoot2[$R][0], $GoldLoot2[$R][1])
- Sleep(Random(400, 500))
- AttackNearbyMonsters()
- Move($GoldLoot3[$R][0], $GoldLoot3[$R][1])
- Sleep(Random(400, 500))
- AttackNearbyMonsters()
- ;Loot items
- If $LootRares Then
- $BagFull = LootRares()
- $LootAttemps = 0
- $BagFull = LootLegendaries()
- $LootAttempts = 0
- EndIf
- If $LootBlues And $BagFull = False Then
- $LootAttempts = 0
- $BagFull = LootMagic()
- EndIf
- If $LootGems Then
- LootGems()
- EndIf
- If $LootTomes Then
- LootTomes()
- EndIf
- If $LootPotions Then
- LootPotions()
- EndIf
- If $LootGold Then
- LootGold()
- EndIf
- ;Check to see if we died
- If CheckForDeath() Then
- ContinueLoop
- EndIf
- ;Teleport to town
- Send("{t}")
- Sleep(8000)
- RepairOrSellItems()
- ;Leave the game
- LeaveGame()
- Sleep(1000)
- EndIf
- WEnd
- Func CheckForRepair()
- $RepairNeeded = PixelSearch($RepairCheck[$R][0], $RepairCheck[$R][1], $RepairCheck[$R][0] + 5, _
- $RepairCheck[$R][1] + 5, 0xFFE801, 10)
- If Not @error Then
- Return True
- Else
- Return False
- EndIf
- EndFunc ;==>CheckForRepair
- Func RepairOrSellItems()
- Local $NeedRepair
- Local $xx
- Local $yy
- Local $sell
- $NeedRepair = CheckForRepair()
- ; Repair the gears when needed
- If ($NeedRepair And $Repair) Or ($BagFull And $SellBlues And $HasBlue) Then
- Move($RepairCoords[$R][0][0], $RepairCoords[$R][0][1])
- Sleep(2000 + $ComputerLag)
- MouseMove($RepairCoords[$R][1][0], $RepairCoords[$R][1][1])
- Sleep(400)
- Click($RepairCoords[$R][1][0], $RepairCoords[$R][1][1])
- Sleep(1300 + $ComputerLag)
- If $NeedRepair And $Repair Then
- Click($RepairCoords[$R][2][0], $RepairCoords[$R][2][1])
- Sleep(Random(700 - 900))
- Click($RepairCoords[$R][3][0], $RepairCoords[$R][3][1])
- Sleep(500)
- EndIf
- ; If the bag is full, sell the blues
- If ($BagFull And $SellBlues And $HasBlue) Then
- Click($SellCoords[$R][0], $SellCoords[$R][1]);
- Sleep(500)
- For $xx = 0 To 8 Step 1
- For $yy = 0 To 5 Step 1
- ; An item recently picked up has blue frame arround the slots
- $sell = PixelSearch($ItemStartCoord0[$R][0] + $xx * $SlotOffset[$R], _
- $ItemStartCoord0[$R][1] + $yy * $SlotOffset[$R], _
- $ItemStartCoord0[$R][2] + $xx * $SlotOffset[$R], _
- $ItemStartCoord0[$R][3] + $yy * $SlotOffset[$R], 0x0000FF, 10)
- If Not @error Then
- MouseClick("right", $sell[0], $sell[1])
- Else
- ; Otherwise the color of the frame is lighter
- $sell = PixelSearch($ItemStartCoord1[$R][0] + $xx * $SlotOffset[$R], _
- $ItemStartCoord1[$R][1] + $yy * $SlotOffset[$R], _
- $ItemStartCoord1[$R][2] + $xx * $SlotOffset[$R], _
- $ItemStartCoord1[$R][3] + $yy * $SlotOffset[$R], 0x182A5B, 30)
- If Not @error Then
- MouseClick("right", $sell[0], $sell[1])
- EndIf
- EndIf
- Next
- Next
- EndIf
- Sleep(300)
- Send("{esc}")
- EndIf
- EndFunc ;==>RepairOrSellItems
- Func Terminate()
- Exit 0
- EndFunc ;==>Terminate
- Func LeaveGame()
- Send("{esc}")
- Sleep(400)
- Click($Leave[$R][0], $Leave[$R][1])
- EndFunc ;==>LeaveGame
- Func Pause()
- $Paused = Not $Paused
- While $Paused
- Sleep(100)
- ToolTip('Paused... (Press F2 to run it)', 0, 0)
- WEnd
- ToolTip("")
- EndFunc ;==>Pause
- Func Click($x, $y)
- MouseClick('left', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
- EndFunc ;==>Click
- Func Move($x, $y)
- MouseClick('middle', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
- Sleep(Random(1000, 1500))
- EndFunc ;==>Move
- Func Attack($x, $y)
- MouseClick('right', Random($x - 3, $x + 3), Random($y - 3, $y + 3), 1, Random(0, 1))
- EndFunc ;==>Attack
- Func Rest($z)
- Sleep(Random($z, $z + 25))
- EndFunc ;==>Rest
- Func CheckForDeath()
- ConsoleWrite("Checking to see if we died")
- $Death = PixelSearch($DeathBounds[$R][0], $DeathBounds[$R][0], $DeathBounds[$R][0] + 4, _
- $DeathBounds[$R][0] + 4, 0xFFFFFF)
- If Not @error Then
- ConsoleWrite("Died" & @LF)
- LeaveGame()
- Sleep(10000)
- Return True
- Else
- Return False
- EndIf
- EndFunc ;==>CheckForDeath
- Func CalcDist($x, $y)
- Local $dx = $x - $CharLoc[$R][0]
- Local $dy = $y - $CharLoc[$R][1]
- Return Sqrt($dx ^ 2 + $dy ^ 2)
- EndFunc ;==>CalcDist
- Func LootMagic()
- Local $gX
- Local $gY
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- Return True
- EndIf
- $Magic = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], _
- $LootingArea[$R][3], 0x6969FF, 2) ;
- If Not @error Then
- Click($Magic[0] + 5, $Magic[1] + 2)
- Sleep(100 + Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- Return True
- EndIf
- $HasBlue = 1
- EndIf
- $LootAttempts += 1
- If ($LootAttempts > 5) Then
- Return
- Else
- If LootMagic() Then
- Return True
- EndIf
- EndIf
- Return False
- EndFunc ;==>LootMagic
- Func LootRares()
- Local $gX
- Local $gY
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- Return True
- EndIf
- $Rare = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], _
- $LootingArea[$R][3], 0xBBBB00, 2)
- If Not @error Then
- Click($Rare[0] + 5, $Rare[1] + 2)
- Sleep(100 + Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- Return True
- EndIf
- EndIf
- $LootAttempts += 1
- If ($LootAttempts > 5) Then
- Return
- Else
- If LootRares() Then
- Return True
- EndIf
- EndIf
- Return False
- EndFunc ;==>LootRares
- Func LootLegendaries()
- Local $gX
- Local $gY
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- MsgBox(0, "Oops!", "Your bag is full and you may not want to miss this item")
- terminate()
- EndIf
- $Legendary = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], _
- $LootingArea[$R][3], 0xBF642F, 2) ;
- If Not @error Then
- Click($Legendary[0] + 5, $Legendary[1] + 2)
- Sleep(100 + Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- ; Will terminate if a legendary is present and the bag is full
- MsgBox(0, "Oops!", "Your bag is full and you may not want to miss this item")
- terminate()
- EndIf
- EndIf
- $set = PixelSearch($LootingArea[$R][0], $LootingArea[$R][1], $LootingArea[$R][2], _
- $LootingArea[$R][2], 0x02CE01, 2) ;
- If Not @error Then
- Click($set[0] + 5, $set[1] + 2)
- Sleep(100 + Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- MsgBox(0, "Oops!", "Your bag is full and you may not want to miss this item")
- terminate()
- EndIf
- EndIf
- $LootAttempts += 1
- If ($LootAttempts > 3) Then
- Return
- Else
- LootLegendaries()
- EndIf
- EndFunc ;==>LootLegendaries
- Func LootGems()
- Local $gX = 0
- Local $gY = 0
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- While _ImageSearchArea($pngLoc[$R] & "square.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
- $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 120)
- MouseClick("left", $gX, $gY)
- Sleep(Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- If _ImageSearchArea($pngLoc[$R] & "item.png", 1, $BagFullCoords[$R][0], $BagFullCoords[$R][1], _
- $BagFullCoords[$R][2], $BagFullCoords[$R][3], $gX, $gY, 120) Then
- Return True
- EndIf
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- Sleep(100)
- WEnd
- Return False
- EndFunc ;==>LootGems
- Func LootTomes()
- Local $gX = 0
- Local $gY = 0
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- While _ImageSearchArea($pngLoc[$R] & "tome.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
- $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 120)
- MouseClick("left", $gX, $gY)
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- Sleep(Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- WEnd
- EndFunc ;==>LootTomes
- Func LootPotions()
- Local $gX = 0
- Local $gY = 0
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- While _ImageSearchArea($pngLoc[$R] & "potion.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
- $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 120)
- MouseClick("left", $gX, $gY)
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- Sleep(Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- WEnd
- EndFunc ;==>LootPotions
- Func LootGold()
- Local $gX = 0
- Local $gY = 0
- Local $cnt = 5
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- While _ImageSearchArea($pngLoc[$R] & "gold.png", 1, $LootingArea[$R][0], $LootingArea[$R][1], _
- $LootingArea[$R][2], $LootingArea[$R][3], $gX, $gY, 120) And $cnt
- MouseClick("left", $gX, $gY)
- MouseMove($IdleCursorCoords[$R][0], $IdleCursorCoords[$R][0])
- Sleep(Round($RunDelayMult[$R] * CalcDist($gX, $gY)))
- $cnt -= 1
- WEnd
- EndFunc ;==>LootGold
- Func AttackNearbyMonsters()
- While 1
- $MonsterData = PixelSearch($CharHitBox[$R][0], $CharHitBox[$R][1], $CharHitBox[$R][2], $CharHitBox[$R][3], 0xEE0000, 10)
- If @error Then
- ExitLoop
- EndIf
- Send("{4}")
- Sleep(300)
- For $i = 10 To 0 Step -1
- Attack($MonsterData[0], $MonsterData[1])
- Sleep(100)
- Next
- WEnd
- EndFunc ;==>AttackNearbyMonsters
- Func CheckForNearbyMonsters()
- $MonsterData = PixelSearch($CharHitBox[$R][0], $CharHitBox[$R][1], $CharHitBox[$R][2], $CharHitBox[$R][3], 0xEE0000, 10)
- If @error Then
- Return False
- Else
- Return True
- EndIf
- EndFunc ;==>CheckForNearbyMonsters
- Func SnareNearbyEnemies()
- $MonsterData = PixelSearch($CharHitBox[$R][0], $CharHitBox[$R][1], $CharHitBox[$R][2], $CharHitBox[$R][3], 0xEE0000, 10)
- If Not @error Then
- MouseMove($MonsterData[0], $MonsterData[1])
- Sleep(350)
- Send("{3}")
- Sleep(250)
- EndIf
- EndFunc ;==>SnareNearbyEnemies
- Func InGameLobby()
- MouseMove($GameLobbyCode[$R][0], $GameLobbyCode[$R][1])
- Sleep(300)
- PixelSearch($GameLobbyCode[$R][0], $GameLobbyCode[$R][1], $GameLobbyCode[$R][0] + 10, $GameLobbyCode[$R][1] + 10, $GameLobbyCode[$R][2], 10)
- If Not @error Then
- Return True
- Else
- Return False
- EndIf
- EndFunc ;==>InGameLobby
- Func InGameplayScreen()
- PixelSearch($GameScreenCode[$R][0], $GameScreenCode[$R][1], $GameScreenCode[$R][0] + 4, $GameScreenCode[$R][1] + 3, $GameScreenCode[$R][2], 10)
- If Not @error Then
- Return True
- Else
- Return False
- EndIf
- EndFunc ;==>InGameplayScreen
- Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
- $findImage = "*TRANSBLACK " & $findImage
- If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
- If @AutoItX64 Then
- $result = DllCall("ImageSearchDLL_x64.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
- Else
- $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
- EndIf
- If $result = "0" Then Return 0
- ; Otherwise get the x,y location of the match and the size of the image to
- ; compute the centre of search
- $array = StringSplit($result[0], "|")
- If (UBound($array) >= 4) Then
- $x = Int(Number($array[2]))
- $y = Int(Number($array[3]))
- If $resultPosition = 1 Then
- $x = $x + Int(Number($array[4]) / 2)
- $y = $y + Int(Number($array[5]) / 2)
- EndIf
- Return 1
- EndIf
- EndFunc ;==>_ImageSearchArea
- Func ActivateGUI()
- ;setup the UI
- $Waiting = True
- $Form1 = GUICreate("D3 Witch Doctor bot by Avatar88343 and Andygongyb", 500, 320, -1, -1)
- GUICtrlCreateLabel("Warning: the script is for education only, not approved for any form of commercial use", _
- 25, 30, 550, -1)
- GUICtrlCreateLabel("Hotkeys:" & @CRLF & @TAB & "Terminate:" & @TAB & "SHIFT + \" & @CRLF _
- & @TAB & "Pause:" & @TAB & @TAB & "F2", 25, 50, 550, -1)
- GUICtrlCreateLabel("Game Resolution", 25, 100, 100, -1)
- $ResCombo = GUICtrlCreateCombo("", 25, 115, 200, -1)
- GUICtrlSetData($ResCombo, "1920 x 1080|800 x 600", "Select your Res")
- GUICtrlCreateLabel("Character run speed (for 800x600)", 275, 100, 200, -1)
- $RunInput = GUICtrlCreateInput("0", 275, 115, 200, -1)
- $LootRareCheck = GUICtrlCreateCheckbox("Loot rares/legs/sets", 25, 160)
- GUICtrlSetState($LootRareCheck, $GUI_CHECKED)
- $LootBluesCheck = GUICtrlCreateCheckbox("Loot blues", 150, 160)
- GUICtrlSetState($LootBluesCheck, $GUI_CHECKED)
- $LootGemsCheck = GUICtrlCreateCheckbox("Loot gems", 275, 160)
- GUICtrlSetState($LootGemsCheck, $GUI_CHECKED)
- $LootPotionsCheck = GUICtrlCreateCheckbox("Loot potions", 400, 160)
- GUICtrlSetState($LootPotionsCheck, $GUI_CHECKED)
- $LootTomesCheck = GUICtrlCreateCheckbox("Loot tomes of secret", 25, 190)
- GUICtrlSetState($LootTomesCheck, $GUI_CHECKED)
- $LootGoldCheck = GUICtrlCreateCheckbox("Collect the gold carefully (slower)", 275, 190)
- GUICtrlSetState($LootGoldCheck, $GUI_CHECKED)
- $RepairCheckbox = GUICtrlCreateCheckbox("Repair gears when needed", 25, 220)
- GUICtrlSetState($RepairCheckbox, $GUI_CHECKED)
- $SellBluesCheckbox = GUICtrlCreateCheckbox("Sell blue item when the bag is full", 275, 220)
- GUICtrlSetState($SellBluesCheckbox, $GUI_CHECKED)
- $StartButton = GUICtrlCreateButton("Start", 175, 260, 150, 33)
- GUISetState(@SW_SHOW)
- ;Wait for them to press start
- While $Waiting
- $Action = GUIGetMsg()
- If $Action = $GUI_EVENT_CLOSE Then Terminate()
- If $Action = $StartButton Then ExitLoop
- Sleep(50)
- WEnd
- ;Get the values
- $SelectedRes = GUICtrlRead($ResCombo)
- If $SelectedRes = "1920 x 1080" Then
- $R = 0
- ElseIf $SelectedRes = "800 x 600" Then
- $R = 1
- Else
- MsgBox(0, "Error", "You did not select a resolution! Try again")
- Terminate()
- EndIf
- $RunSpeed = Int(GUICtrlRead($RunInput))
- $LootRares = GUICtrlRead($LootRareCheck) = $GUI_CHECKED
- $LootBlues = GUICtrlRead($LootBluesCheck) = $GUI_CHECKED
- $LootGems = GUICtrlRead($LootGemsCheck) = $GUI_CHECKED
- $LootPotions = GUICtrlRead($LootPotionsCheck) = $GUI_CHECKED
- $LootTomes = (GUICtrlRead($LootTomesCheck) = $GUI_CHECKED) And (Not $LootBlues)
- $LootGold = GUICtrlRead($LootGoldCheck) = $GUI_CHECKED
- $Repair = GUICtrlRead($RepairCheckbox) = $GUI_CHECKED
- $SellBlues = (GUICtrlRead($SellBluesCheckbox) = $GUI_CHECKED) And $LootBlues
- GUISetState(@SW_HIDE)
- EndFunc ;==>ActivateGUI
Add Comment
Please, Sign In to add comment