Code:
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <GuiListBox.au3>
#include <ScrollBarConstants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <ScreenCapture.au3>
#include <String.au3>
Initialize()
#cs
DH Revision by aylwin1991
[Gold/Itemfarming] [AutoIt] Sarkoth Act I Dank Cellar [DH] [Stash, Sell, Repair, +++]
original by zeeNex
Modified by aylwin1991.
Version: 1.DH
www.ownedcore.com
#ce
;///////////////////////////////////////--CONFIG--////////////////////////////////////////////////////////////////////////////////////
; //
; Important //
$ComputerLag = 0 ;Increases time (ms) before and after casting spells //
$MoveDelay = 0 ;Increases time (ms) between movements //
$LootDelay = 0 ;Increases time (ms) between looting //
$SellDelay = 0 ;Increases time (ms) between selling //
$SalvageDelay = 0 ;Increases time (ms) between salvaging //
$StashDelay = 0 ;Increases time (ms) between stashing //
$ReqFiles = "C:\Program Files (x86)\AutoIt3\required files\" ;Location of the required files folder //
; //
; Functions //
$Repair = True ;Orders the bot to repair //
$Sell = True ;Orders the bot to sell magic items //
$Salvage = True ;Orders the bot to salvage magic items //
$KeepHighLevel = False ;Orders the bot to keep items above $KeepLevel //
$KeepLevel = 63 ;Possible values: 60, 61, 62, 63 //
$UseStash = True ;Orders the bot to stash items //
$HighGoldRadius = False ;Orders the bot to use a shorter gold loot route //
; //
; Miscellaneous //
$UseMemRead = False ;Allows the bot to read memory *CAUTION* //
$MemReadDelay = 0 ;Increases time (ms) before scanning for open cellar //
$Sounds = False ;Enable pickup sounds //
$ShowLootArea = False ;Shows lootarea //
$ShowLog = True ;Shows log window //
$SaveStats = True ;Saves statistics per run to a text file //
$SaveLogsPath = "C:\Program Files (x86)\AutoIt3\logs\" ;Folder to save the logs and statistics in //
$InstantLeave = False ;Leaves the game instead of teleporting to town //
; //
; Relogging //
$UseRelogging = False ;Orders the bot to relog on disconnect //
$Password = "XXXXXXXXXXX" ;Your password //
; //
; Looting //
$LootSets = True ;Orders the bot to loot set items //
$LootLegendaries = True ;Orders the bot to loot legendary items //
$LootRares = True ;Orders the bot to loot rare items //
$LootMagics = True ;Orders the bot to loot magic items (includes tomes) //
$LootTomes = True ;Orders the bot to loot tomes //
$LootGems = True ;Orders the bot to loot gems //
$FlawlessOnly = True ;Orders the bot to loot only flawless gems //
; //
$SetLootAmount = 1 ;Amount of set items to loot //
$LegendaryLootAmount = 1 ;Amount of legendary items to loot //
$RareLootAmount = 2 ;Amount of rare items to loot //
$MagicLootAmount = 4 ;Amount of magic items to loot (including tomes) //
$TomeLootAmount = 1 ;Amount of tomes to loot (if $LootMagics = False) //
$GemLootAmount = 2 ;Amount of gems to loot //
; //
$LootingArea[0] = 300 ;Left (lower -> bigger) //
$LootingArea[1] = 100 ;Top (lower -> bigger) //
$LootingArea[2] = 1800 ;Right (higher -> bigger) //
$LootingArea[3] = 900 ;Bot (higher -> bigger) //
; //
; //
; TimeOuts //
$GameLobbyTimeOut = 25 ;Time (s) to wait for entering the gamelobby //
$GameplayScreenTimeOut = 14 ;Time (s) to wait for entering the gameplay screen //
$CellarTimeOut = 8 ;Time (s) to wait for entering the cellar //
$TownTimeOut = 8 ;Time (s) to wait for entering the town //
$MerchantTimeOut = 8 ;Time (s) to wait for reaching the merchant //
$ArtisanTimeOut = 8 ;Time (s) to wait for reaching the artisan //
$StashTimeOut = 8 ;Time (s) to wait for reaching the stash //
; //
;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ScriptStarted()
While 1
While WinActive('Diablo III')
Randomize()
Switch ResumeGame()
Case "LeftGame"
ExitLoop
Case "Network connection lost"
ExitLoop
Case "Relogged"
ExitLoop
EndSwitch
If $UseMemRead = False Then
Switch MoveToCellar()
Case "LeftGame"
ExitLoop
EndSwitch
Switch EnterCellar()
Case "LeftGame"
ExitLoop
Case "Network connection lost"
ExitLoop
Case "Relogged"
ExitLoop
EndSwitch
Else
Switch MoveToCellarMem()
Case "LeftGame"
ExitLoop
EndSwitch
Switch EnterCellarMem()
Case "LeftGame"
ExitLoop
Case "Network connection lost"
ExitLoop
Case "Relogged"
ExitLoop
EndSwitch
EndIf
MoveInCellar()
$travel = 0
LootGold()
Switch LootItems()
Case "LeftGame"
ExitLoop
Case "Network connection lost"
ExitLoop
Case "Relogged"
ExitLoop
EndSwitch
Send("4");
Sleep(750)
If $InstantLeave = False Then
Switch TeleportToTown()
Case "LeftGame"
ExitLoop
Case "Network connection lost"
ExitLoop
Case "Relogged"
ExitLoop
EndSwitch
EndIf
LeaveGame()
WEnd
WEnd
;Routine
Func ResumeGame()
If $UseRelogging = True Then
$Array = StringSplit($ImageFiles[7][4], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Relog()
Return "Relogged"
EndIf
EndIf
Switch InGameLobby()
Case "InGameLobby"
ToLog("Resuming game...")
MouseClick('LEFT', $ResumeButton[0], $ResumeButton[1], 1, 2)
Case "LeftGame"
Return "LeftGame"
Case "Relogged"
Return "Relogged"
EndSwitch
Switch InGameplayScreen()
Case "LeftGame"
Return "LeftGame"
Case "InGamePlayScreen"
Return "InGamePlayScreen"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndFunc
Func MoveToCellar()
If $Runs > 0 Then
$Sek = Floor(TimerDiff($RunTimer) / 1000)
ToLog("Last run took: " & $Sek & "s")
Else
Sleep(1500)
GetGold()
EndIf
$RunTimer = TimerInit()
ToLog("Starting run...")
$Runs += 1
RefreshStats()
Sleep(80 + ($ComputerLag / 2))
ToLog("Moving to cellar - 1")
;Start Run
RandClick("middle", Round(500), Round(250), 2, 2) ;starts the run [waypoint 1]
Moving(900)
Send("{1}")
Moving(600)
ToLog("Moving to cellar - 2")
RandClick("middle", Round(3), Round(370), 2, 2) ;waits ~1 second then [waypoint 2]
Moving(1850)
ToLog("Moving to cellar - 3")
RandClick("middle", Round(400), Round(600), 2, 2) ;middle of courtyard [waypoint 3]
Moving(100)
Send("{1}")
Moving(100)
Send("{3}")
Moving(750)
Send("{2}")
Moving(100)
RandMove(Round(300), Round(70), 1, 1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
Sleep(350)
Return "Moved"
EndFunc
Func MoveToCellarMem()
If $Runs > 0 Then
$Sek = Floor(TimerDiff($RunTimer) / 1000)
ToLog("Last run took: " & $Sek & "s")
Else
Sleep(1500)
GetGold()
EndIf
$RunTimer = TimerInit()
ToLog("Starting run...")
$Runs += 1
RefreshStats()
Sleep(400 + $ComputerLag)
Send("{4}")
Sleep(30 + ($ComputerLag / 2))
ToLog("Moving to cellar - 1")
Move($MoveToCellar1[0], $MoveToCellar1[1])
Sleep(1175 + $MoveDelay)
ToLog("Moving to cellar - 2")
Move($MoveToCellar2[0], $MoveToCellar2[1])
Sleep(1300 + $MemReadDelay)
If CheckCellarMem() = False Then
$CellarOpen = False
Send("{2}")
Sleep(100 + $ComputerLag)
ToLog("Cellar is closed (Memory reading)")
$Closed += 1
RefreshStats()
If $InstantLeave = False Then
Switch TeleportToTown()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
LeaveGame()
Return "LeftGame"
Else
$CellarOpen = True
EndIf
Sleep(750 + $MoveDelay)
ToLog("Moving to cellar - 3")
Move($MoveToCellar3[0], $MoveToCellar3[1])
Sleep(1500 + $MoveDelay)
Send("{2}")
Sleep(50 + $ComputerLag)
Return "Moved"
EndFunc
Func RandMove($xPos, $yPos, $xOff = 10, $yOff = 10, $speed = 1)
$randX = Round(Random($xPos - ($xOff), $xPos + ($xOff)))
$randY = Round(Random($yPos - ($yOff), $yPos + ($yOff)))
MouseMove($randX, $randY, $speed)
EndFunc ;==>RandMove
Func Moving($time)
Sleep($time)
EndFunc ;==>Moving
Func EnterCellar()
MouseMove($CellarLocation[0], $CellarLocation[1], 2)
Sleep(100 + ($ComputerLag / 2))
;
;Checks if Dank Cellar is Open
$Pixel2 = PixelSearch(0, 0, Round(600), Round(600), 0x334FB7, 3)
If Not @error Then
$CellarOpen = True
ToLog("Entering cellar...")
MouseClick("left", Round(300), Round(70), 1) ;Entrance to cellar
Sleep(800)
Send("{1}")
Moving(2800)
Switch InCellar()
Case "InCellar"
Return "InCellar"
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Else ;ABORT RUN
$CellarOpen = False
ToLog("Cellar is closed")
$Closed += 1
RefreshStats()
If $InstantLeave = False Then
Switch TeleportToTown()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
LeaveGame()
Return "LeftGame"
EndIf
EndFunc
Func EnterCellarMem()
ToLog("Entering cellar...")
MouseClick('LEFT', $CellarLocation[0], $CellarLocation[1], 1, 2)
Switch InCellar()
Case "InCellar"
Return "InCellar"
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndFunc
Func MoveInCellar()
ToLog("Moving in cellar - 1")
Move($MoveInCellar1[0], $MoveInCellar1[1])
Sleep(2050 + $MoveDelay)
MouseMove($MonsterLocation[0], $MonsterLocation[1], 2)
ToLog("Using skills...")
Send("{2}") ;Caltrops
Sleep(400 + $ComputerLag)
Send("{SHIFTDOWN}")
MouseClick('Right')
Send("{4}");Ferrets
Sleep(250 + $ComputerLag)
ToLog("Ball of Lightning...")
MouseDown("right")
Sleep(4900)
MouseUp("right")
Send("{1}")
MouseDown("left")
Sleep(4000)
MouseUp("left")
Send("{SHIFTUP}")
ToLog("Moving in cellar - 2")
Move($MoveInCellar2[0], $MoveInCellar2[1])
Sleep(450 + $MoveDelay)
KillSarkoth()
Sleep(50 + ($ComputerLag / 2))
EndFunc
Func KillSarkoth()
ToLog("Killing Sarkoth...")
While 1
$MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
If @error Then
Attack($MonsterLocation[0], $MonsterLocation[1])
Sleep(600)
$MonsterBar = PixelSearch($MonsterSearchArea[0], $MonsterSearchArea[1], $MonsterSearchArea[2], $MonsterSearchArea[3], 0xEE0000, 10)
If @error Then
ExitLoop
EndIf
EndIf
Attack($MonsterBar[0], $MonsterBar[1])
Sleep(100)
WEnd
ToLog("All monsters are dead")
Send("{4}")
Sleep(30 + ($ComputerLag / 2))
EndFunc
Func LootGold()
If $ShowLootArea = True Then
DrawLootArea()
EndIf
ToLog("Looting gold...")
If $HighGoldRadius = False Then
Move($MoveToGoldLoot1a[0], $MoveToGoldLoot1a[1])
Sleep(1500 + $MoveDelay)
AttackNearbyMonsters()
Move($MoveToGoldLoot2[0], $MoveToGoldLoot2[1])
Sleep(1550 + $MoveDelay)
AttackNearbyMonsters()
Move($MoveToGoldLoot3[0], $MoveToGoldLoot3[1])
Sleep(800 + $MoveDelay)
AttackNearbyMonsters()
Else
Move($MoveToGoldLoot1b[0], $MoveToGoldLoot1b[1])
Sleep(1200 + $MoveDelay)
AttackNearbyMonsters()
EndIf
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
EndFunc
Func LootItems()
If $LootSets Then
Send("{ALT}")
Switch LootSets()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
If $LootLegendaries Then
Send("{ALT}")
Switch LootLegendaries()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
If $LootRares Then
Send("{ALT}")
Switch LootRares()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
$RareLootAttempts = 0
EndIf
If $LootMagics Then
Send("{ALT}")
Switch LootMagics()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
$MagicLootAttempts = 0
Else
If $LootTomes Then
Send("{ALT}")
Switch LootTomes()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
$TomeLootAttempts = 0
EndIf
EndIf
If $LootGems Then
Send("{ALT}")
Switch LootGems()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
$GemLootAttempts = 0
EndIf
If $ShowLootArea = True Then
GUIDelete($LootAreaGUI)
EndIf
Return "Looted"
EndFunc
Func RandClick($clickType, $xPos, $yPos, $xOff = 10, $yOff = 10, $clicks = 1, $speed = 4)
If $xOff < 1 Then $xOff = 1
If $yOff < 1 Then $yOff = 1
$randX = Round(Random($xPos - ($xOff), $xPos + ($xOff)))
$randY = Round(Random($yPos - ($yOff), $yPos + ($yOff)))
MouseClick($clickType, $randX, $randY, $clicks, $speed)
EndFunc ;==>RandClick
Func TeleportToTown()
ToLog("Teleporting to town...")
RandClick("middle", Round(1100), Round(600)) ;moves between caltrops for safety before teleporting back to town
Sleep(250)
Send("{2}") ;caltrops
Sleep(620)
Send("{1}") ;smokescreen
Sleep(50 + ($ComputerLag / 2))
Send("{t}")
If $FullBag = False Then
If $CellarOpen = False Then
If $GoldDifference = 0 Then
GUICtrlSetData($DifferenceGoldLabel, "0")
EndIf
$Sek = Floor(TimerDiff($RuntimeTimer) / 1000)
$GPH = Floor(($CurrentGold - $StartGold) / ($Sek / 3600))
GUICtrlSetData($GPHLabel, _StringAddThousandsSep($GPH))
GUICtrlSetData($LastDifferenceGoldLabel, "0")
Else
GetGold()
EndIf
EndIf
Switch InTown()
Case "InTown"
Return "InTown"
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndFunc
;Loot
Func LootSets()
While $SetLootAttempts < $SetLootAmount
ToLog("Searching for sets... " & $SetLootAttempts + 1)
For $gI = 0 To 4
$Array = StringSplit($ImageFiles[1][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
If $travel = 0 Then
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Running to Loot")
MouseClick("middle", $ISx, $ISy, 1, 2)
Sleep(1000 + $LootDelay)
$travel = 1
EndIf
Endif
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Set found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[1], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$SetLootAttempts += 1
$Sets += 1
RefreshStats()
EndIf
EndIf
ExitLoop
EndIf
Next
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
Func LootLegendaries()
While $LegendaryLootAttempts < $LegendaryLootAmount
ToLog("Searching for legendaries... " & $LegendaryLootAttempts + 1)
For $gI = 0 To 4
$Array = StringSplit($ImageFiles[0][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
If $travel = 0 Then
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Running to Loot")
MouseClick("middle", $ISx, $ISy, 1, 2)
Sleep(1000 + $LootDelay)
$travel = 1
EndIf
Endif
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Legendary found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[0], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$LegendaryLootAttempts += 1
$Legendaries += 1
RefreshStats()
EndIf
EndIf
ExitLoop
EndIf
Next
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
Func LootRares()
While $RareLootAttempts < $RareLootAmount
ToLog("Searching for rares... " & $RareLootAttempts + 1)
For $gI = 0 To 4
$Array = StringSplit($ImageFiles[2][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
If $travel = 0 Then
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Running to Loot")
MouseClick("middle", $ISx, $ISy, 1, 2)
Sleep(1000 + $LootDelay)
$travel = 1
EndIf
EndIf
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Rare found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[2], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$RareLootAttempts += 1
$Rares += 1
RefreshStats()
EndIf
EndIf
ExitLoop
EndIf
Next
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
Func LootMagics()
While $MagicLootAttempts < $MagicLootAmount
ToLog("Searching for magics... " & $MagicLootAttempts + 1)
For $gI = 0 To 4
$Array = StringSplit($ImageFiles[3][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
If $travel = 0 Then
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Running to Loot")
MouseClick("middle", $ISx, $ISy, 1, 2)
Sleep(1000 + $LootDelay)
$travel = 1
EndIf
Endif
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Magic found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[3], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$MagicLootAttempts += 1
$Magics += 1
RefreshStats()
EndIf
EndIf
ExitLoop
EndIf
Next
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
Func LootTomes()
While $TomeLootAttempts < $TomeLootAmount
ToLog("Searching for Tomes of Secrets... " & $TomeLootAttempts + 1)
$Array = StringSplit($ImageFiles[4][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Tome of Secrets found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[4], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$TomeLootAttempts += 1
$Tomes += 1
RefreshStats()
EndIf
EndIf
EndIf
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
Func LootGems()
While $GemLootAttempts < $GemLootAmount
ToLog("Searching for Gems... " & $GemLootAttempts + 1)
If $FlawlessOnly = True Then
$Array = StringSplit($ImageFiles[4][6], "|")
Else
$Array = StringSplit($ImageFiles[4][5], "|")
EndIf
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LootingArea[0], $LootingArea[1], $LootingArea[2], $LootingArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Gem found")
If $Sounds = True Then
SoundPlay($ReqFiles & "\sounds\" & $SoundFiles[5], 0)
EndIf
MouseClick("LEFT", $ISx, $ISy, 1, 2)
Sleep(550 + $LootDelay)
MouseMove(Random($LootingArea[0] - 50, $LootingArea[0], 1), Random($LootingArea[1] - 50, $LootingArea[1], 1), 2)
Sleep(50)
If $Salvage = True Or $Sell = True Or $UseStash = True Then
Switch CheckBagFull()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $FullBag = True Then
$FullBag = False
Else
$GemLootAttempts += 1
$Gems += 1
RefreshStats()
EndIf
EndIf
EndIf
If $Target = 0 Then ExitLoop
WEnd
Return "Looted"
EndFunc
;Sell, salvage, store and repair
Func CheckBagFull()
$Array = StringSplit($ImageFiles[6][4], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $FullBagSearchArea[0], $FullBagSearchArea[1], $FullBagSearchArea[2], $FullBagSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
ToLog("Our bag is full")
$FullBag = True
Switch SellItems()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
Return "BagNotFull"
EndFunc
Func SellItems()
If $Salvage = True Then
If $KeepLevel >= 62 Then
$SellCheck = 61
Else
$SellCheck = $KeepLevel
EndIf
Else
$SellCheck = $KeepLevel
EndIf
If $ShowLootArea = True Then
GUIDelete($LootAreaGUI)
EndIf
Switch TeleportToTown()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
If $Sell = True Then
Switch MoveToMerchant()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
ToLog("Selling...")
$Count = 0
RandomizeInventory()
While UBound($Stash) > 0
$r = Random(0, UBound($Stash) - 1, 1)
$Array = StringSplit($ImageFiles[5][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $Stash[$r][0] - 35, $Stash[$r][1] - 35, $Stash[$r][0] + 35, $Stash[$r][1] + 35, 0, 0, $Accuracy)
If Not $Target = 1 Then
MouseMove($Stash[$r][0], $Stash[$r][1], 0)
Sleep(150 + $SellDelay)
$Array = StringSplit($ImageFiles[5][1], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 0, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
For $gI = 2 To 6
$Array = StringSplit($ImageFiles[5][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy, $ISx + 450, $ISy + 90, 0, 0, $Accuracy)
If $Target = 1 Then
If $KeepHighLevel = True Then
Switch $SellCheck
Case 60
For $gI = 1 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop 2
EndIf
Next
Case 61
For $gI = 2 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop 2
EndIf
Next
Case 62
For $gI = 3 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop 2
EndIf
Next
Case 63
$Array = StringSplit($ImageFiles[4][4], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop
EndIf
EndSwitch
MouseClick("RIGHT")
$Count += 1
$Sold += 1
ExitLoop
Else
If $Salvage = True Then
For $gI = 2 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop 2
EndIf
Next
EndIf
MouseClick("RIGHT")
$Count += 1
$Sold += 1
ExitLoop
EndIf
EndIf
Next
MouseMove(Random(1710, 1770, 1), Random(970, 1030, 1), 0)
Sleep(150 + $SellDelay)
EndIf
EndIf
_ArrayDelete($Stash, $r)
WEnd
ToLog("Selling... done - Sold " & $Count & " items")
EndIf
Sleep(100 + ($ComputerLag / 2))
Send("{ESC}")
$RareLootAttempts = 0
$MagicLootAttempts = 0
$TomeLootAttempts = 0
$GemLootAttempts = 0
If $Salvage = True Then
Switch MoveToSalvage()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
Switch MoveToStash()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(150 + $ComputerLag)
MouseClick("LEFT", $PortalLocation[0], $PortalLocation[1], 1, 2)
Switch InCellar()
Case "InCellar"
If $ShowLootArea = True Then
DrawLootArea()
EndIf
Sleep(500 + ($ComputerLag / 2))
Return "InCellar"
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndFunc
Func SalvageItems()
ToLog("Salvaging...")
$Count = 0
MouseClick("LEFT", $SalvageButton[0], $SalvageButton[1], 1, 2)
RandomizeInventory()
While UBound($Stash) > 0
$r = Random(0, UBound($Stash) - 1, 1)
$Array = StringSplit($ImageFiles[5][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $Stash[$r][0] - 25, $Stash[$r][1] - 25, $Stash[$r][0] + 25, $Stash[$r][1] + 25, 0, 0, $Accuracy)
If Not $Target = 1 Then
MouseMove($Stash[$r][0], $Stash[$r][1], 1)
Sleep(150 + $SalvageDelay)
$Array = StringSplit($ImageFiles[5][1], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 0, $SellItemsArea[0], $SellItemsArea[1], $SellItemsArea[2], $SellItemsArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
For $gI = 2 To 6
$Array = StringSplit($ImageFiles[5][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy, $ISx + 420, $ISy + 75, 0, 0, $Accuracy)
If $Target = 1 Then
If $Sell = True Then
If $KeepHighLevel = True Then
Switch $KeepLevel
Case 60
ExitLoop
Case 61
ExitLoop
Case 62
$Array = StringSplit($ImageFiles[4][2], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop
EndIf
Case 63
For $gI = 2 To 3
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop 2
EndIf
Next
EndSwitch
ExitLoop
Else
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop
EndIf
Else
If $KeepHighLevel = True Then
Switch $KeepLevel
Case 60
For $gI = 1 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
ExitLoop 2
EndIf
Next
Case 61
For $gI = 2 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop 2
EndIf
Next
Case 62
For $gI = 3 To 4
$Array = StringSplit($ImageFiles[4][$gI], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop 2
EndIf
Next
Case 63
$Array = StringSplit($ImageFiles[4][4], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ISx, $ISy + 210, $ISx + 140, $ISy + 420, 0, 0, $Accuracy)
If $Target = 1 Then
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop
EndIf
EndSwitch
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop
Else
MouseClick("LEFT")
$Count += 1
$Salvaged += 1
Sleep(50 + $SalvageDelay)
ExitLoop
EndIf
EndIf
EndIf
Next
MouseMove(Random(1710, 1770, 1), Random(970, 1030, 1), 2)
Sleep(150 + $SalvageDelay)
EndIf
EndIf
_ArrayDelete($Stash, $r)
WEnd
ToLog("Salvaging... done - Salvaged " & $Count & " items")
EndFunc
Func PutInStash()
ToLog("Storing items in the stash...")
RandomizeInventory()
While UBound($Stash) > 0
$r = Random(0, UBound($Stash) - 1, 1)
$Array = StringSplit($ImageFiles[5][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $Stash[$r][0] - 25, $Stash[$r][1] - 25, $Stash[$r][0] + 25, $Stash[$r][1] + 25, $ISx, $ISy, $Accuracy)
If Not $Target = 1 Then
MouseClick("RIGHT", $Stash[$r][0], $Stash[$r][1], 1, 0)
Sleep(50 + $StashDelay)
If Not CheckStashFull() = 1 Then
_ArrayDelete($Stash, $r)
EndIf
Else
_ArrayDelete($Stash, $r)
EndIf
If $UseStash = False Then
ExitLoop
EndIf
WEnd
ToLog("Storing items in the stash... done")
EndFunc
Func CheckStashFull()
$Array = StringSplit($ImageFiles[6][3], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $FullStashSearchArea[0], $FullStashSearchArea[1], $FullStashSearchArea[2], $FullStashSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Switch $StashBag
Case 1
ToLog("First stashbag is full - changing...")
Sleep(100 + ($ComputerLag / 2))
MouseClick("LEFT", $StashBag2[0], $StashBag2[1], 1, 2)
$StashBag = 2
Sleep(5000)
Case 2
ToLog("Second stashbag is full - changing...")
Sleep(100 + ($ComputerLag / 2))
MouseClick("LEFT", $StashBag3[0], $StashBag3[1], 1, 2)
$StashBag = 3
Sleep(5000)
Case 3
ToLog("Third stashbag is full - aborting...")
$UseStash = False
EndSwitch
Return 1
EndIf
Return 0
EndFunc
Func RepairItems()
If Not CheckForRepair() Then
Return "NotDamaged"
EndIf
Switch MoveToMerchant()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
ToLog("Repairing...")
MouseClick('LEFT', $RepairButton[0], $RepairButton[1], 1, 2)
Sleep(100 + ($ComputerLag / 2))
MouseClick('LEFT', $AllItemsButton[0], $AllItemsButton[1], 1, 2)
Sleep(100 + ($ComputerLag / 2))
Send("{ESC}")
ToLog("Repairing... done")
Return "Repaired"
EndFunc
Func CheckForRepair()
$RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xFFE801, 10)
If Not @error Then
ToLog("We need to repair")
Return True
Else
$RepairNeeded = PixelSearch($RepairSearchArea[0], $RepairSearchArea[1], $RepairSearchArea[2], $RepairSearchArea[3], 0xDE0000, 10)
If Not @error Then
ToLog("We need to repair")
Return True
Else
Return False
EndIf
EndIf
EndFunc
Func MoveToSalvage()
Sleep(350 + $ComputerLag)
ToLog("Waiting to get to the salvage... (TimeOut " & $ArtisanTimeOut & "s)")
ToLog("Moving to salvage - 1")
Move($MoveToSalvage1[0], $MoveToSalvage1[1])
Sleep($SleepToSalvage + $MoveDelay)
ToLog("Moving to salvage - 2")
Move($MoveToSalvage2[0], $MoveToSalvage2[1])
Sleep($SleepToSalvage + $MoveDelay)
ToLog("Moving to salvage - 3")
MouseClick('LEFT', $SalvageLocation[0], $SalvageLocation[1], 1, 2)
Switch AtSalvage()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
SalvageItems()
Sleep(100 + ($ComputerLag / 2))
Send("{ESC}")
Return "Salvaged"
EndFunc
Func MoveToMerchant()
Sleep(350 + $ComputerLag)
ToLog("Waiting to get to the merchant... (TimeOut " & $MerchantTimeOut & "s)")
ToLog("Moving to merchant - 1")
Move($MoveToMerchant[0], $MoveToMerchant[1])
Sleep(3500 + $MoveDelay)
ToLog("Moving to merchant - 2")
MouseClick('LEFT', $MerchantLocation[0], $MerchantLocation[1], 1, 2)
Switch AtMerchant()
Case "AtMerchant"
Return "AtMerchant"
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndFunc
Func MoveToStash()
ToLog("Waiting to get to the stash... (TimeOut " & $StashTimeOut & "s)")
If $Salvage = True Or $Sell = True Then
ToLog("Moving to stash - 1")
Move($MoveToStash1[0], $MoveToStash1[1])
Sleep($SleepToStash + $MoveDelay)
ToLog("Moving to stash - 2")
Move($MoveToStash2[0], $MoveToStash2[1])
Sleep($SleepToStash + $MoveDelay)
EndIf
If $UseStash = True Then
$StashBag = 1
MouseClick("LEFT", $StashLocation[0], $StashLocation[1], 1, 2)
Switch AtStash()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
PutInStash()
Sleep(100 + ($ComputerLag / 2))
Send("{ESC}")
EndIf
Return "AtStash"
EndFunc
;Check state, cellar, disconnect and death
Func InLoginScreen()
ToLog("Waiting to get into the login screen...")
While 1
$Array = StringSplit($ImageFiles[7][4], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $LoginButtonSearchArea[0], $LoginButtonSearchArea[1], $LoginButtonSearchArea[2], $LoginButtonSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Return True
Else
Sleep(200)
EndIf
WEnd
EndFunc
Func InGameLobby()
ToLog("Waiting to get into the game lobby... (TimeOut " & $GameLobbyTimeOut & "s)")
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][2], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $ResumeButtonSearchArea[0], $ResumeButtonSearchArea[1], $ResumeButtonSearchArea[2], $ResumeButtonSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
$DisconnectState = 0
Return "InGameLobby"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $GameLobbyTimeOut Then
ToLog("GameLobby TimeOut - Trying again")
If $Relogged = True Then
Send("{ESC}")
MouseClick("LEFT", $PasswordField[0] + 250, $PasswordField[1], 1, 2)
For $i = 0 To StringLen($Password) - 1
Send("{BACKSPACE}")
Next
$Relogged = False
Else
MouseMove($ResumeButton[0], $ResumeButton[1] - 100, 0)
LeaveGame()
EndIf
Return "LeftGame"
EndIf
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(200)
EndIf
WEnd
EndFunc
Func InGameplayScreen()
ToLog("Waiting to get into the game... (TimeOut " & $GameplayScreenTimeOut & "s)")
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][3], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $PortalIconSearchArea[0], $PortalIconSearchArea[1], $PortalIconSearchArea[2], $PortalIconSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
$Alive = True
$DisconnectState = 0
Return "InGamePlayScreen"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $GameplayScreenTimeOut Then
$TimeOutTimer = TimerInit()
ToLog("GameplayScreen TimeOut - Leaving")
Return "LeftGame"
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func InCellar()
ToLog("Waiting to get into the cellar... (TimeOut " & $CellarTimeOut & "s)")
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $CellarNameSearchArea[0], $CellarNameSearchArea[1], $CellarNameSearchArea[2], $CellarNameSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Return "InCellar"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $CellarTimeOut Then
ToLog("Cellar TimeOut - Leaving")
LeaveGame()
Return "LeftGame"
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func InTown()
ToLog("Waiting to get into the town... (TimeOut " & $TownTimeOut & "s)")
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][1], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $TownNameSearchArea[0], $TownNameSearchArea[1], $TownNameSearchArea[2], $TownNameSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
If $Repair And Not $FullBag Then
Switch RepairItems()
Case "LeftGame"
Return "LeftGame"
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
EndIf
Return "InTown"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $TownTimeOut Then
$TimeOutCount += 1
If $TimeOutCount = 3 Then
ToLog("Teleport TimeOut - Leaving")
$TimeOutCount = 0
LeaveGame()
Return "LeftGame"
EndIf
$TimeOutTimer = TimerInit()
ToLog("Teleport TimeOut - Trying to teleport again")
ToLog("Teleporting to town...")
Sleep(50 + ($ComputerLag / 2))
Send("{t}")
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func AtSalvage()
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][5], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Return "AtSalvage"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $ArtisanTimeOut Then
ToLog("Salvage TimeOut - Leaving")
LeaveGame()
Return "LeftGame"
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func AtMerchant()
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][5], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Return "AtMerchant"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $MerchantTimeOut Then
ToLog("Merchant TimeOut - Leaving")
LeaveGame()
Return "LeftGame"
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func AtStash()
$TimeOutTimer = TimerInit()
While 1
$Array = StringSplit($ImageFiles[7][6], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $MerchStashSearchArea[0], $MerchStashSearchArea[1], $MerchStashSearchArea[2], $MerchStashSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 Then
Return "AtStash"
Else
If Floor(TimerDiff($TimeOutTimer) / 1000) >= $StashTimeOut Then
ToLog("Stash TimeOut - Leaving")
LeaveGame()
Return "LeftGame"
EndIf
If CheckForDeath() = "LeftGame" Then
Return "LeftGame"
EndIf
Sleep(100)
Switch CheckForDisconnect()
Case "Network connection lost"
Return "Network connection lost"
Case "Relogged"
Return "Relogged"
EndSwitch
Sleep(100)
EndIf
WEnd
EndFunc
Func CheckCellarMem()
Global $_itrObjectManagerA = _MemoryRead($ofs_ObjectManager, $D3Memory, 'ptr')
Global $_itrObjectManagerB = _MemoryRead($_itrObjectManagerA + $ofs__ObjmanagerActorOffsetA, $D3Memory, 'ptr')
Global $_itrObjectManagerCount = $_itrObjectManagerB + $ofs__ObjmanagerActorCount
Global $_itrObjectManagerC = _MemoryRead($_itrObjectManagerB + $ofs__ObjmanagerActorOffsetB, $D3Memory, 'ptr')
Global $_itrObjectManagerD = _MemoryRead($_itrObjectManagerC, $D3Memory, 'ptr')
$Object = IterateObjectList()
$Open = _ArraySearch($Object, "Portal_Square_Blue", 0, 0, 0, 1, 1, 10)
If $Open = -1 then
Return False
Else
Return True
EndIf
EndFunc
Func CheckForDisconnect()
$Array = StringSplit($ImageFiles[6][0], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, $Accuracy)
If $Target = 1 And $DisconnectState = 0 Then
ToLog("We got disconnected")
$Disconnects += 1
RefreshStats()
$DisconnectState = 1
MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 2)
Return "Network connection lost"
EndIf
$Array = StringSplit($ImageFiles[6][1], "|")
$File = $Array[1]
$Accuracy = $Array[2]
$Target = _ImageSearchArea($ReqFiles & "\pics\" & $File, 1, $DisconnectSearchArea[0], $DisconnectSearchArea[1], $DisconnectSearchArea[2], $DisconnectSearchArea[3], $ISx, $ISy, 10)
If $Target = 1 Then
ToLog("We got totally disconnected")
If $DisconnectState = 0 Then
$Disconnects += 1
RefreshStats()
EndIf
$DisconnectState = 2
MouseClick("LEFT", $DisconnectButton[0], $DisconnectButton[1], 1, 2)
InLoginScreen()
If $UseRelogging = True Then
Relog()
Return "Relogged"
Else
Terminate()
EndIf
EndIf
Return "Connected"
EndFunc
Func CheckForDeath()
If $Alive = True Then
$Death = PixelSearch($DeathSearchArea[0], $DeathSearchArea[1], $DeathSearchArea[2], $DeathSearchArea[3], 0xFFFFFF)
If Not @error Then
$Alive = False
ToLog("We are dead... :(")
$Deaths += 1
RefreshStats()
LeaveGame()
Return "LeftGame"
EndIf
EndIf
Return "Alive"
EndFunc
;Miscellaneous
Func Initialize()
OnAutoItExitRegister('OnAutoItExit')
Opt('MouseCoordMode', 2)
Opt('PixelCoordMode', 2)
HotKeySet('{PAUSE}', 'Pause')
HotKeySet('{HOME}', 'Lewt')
HotKeySet('{INS}', 'HideLog')
HotKeySet('{END}', 'Terminate')
Global $travel = 0
Global $lewt = False
Global $LootAreaGUI
Global $LogGUI
Global $ImageFiles[8][7]
Global $SoundFiles[6]
Global $PasswordField[2]
Global $ResumeButton[2]
Global $LeaveButton[2]
Global $DisconnectButton[2]
Global $SalvageButton[2]
Global $MoveToCellar1[2]
Global $MoveToCellar2[2]
Global $MoveToCellar3[2]
Global $MoveInCellar1[2]
Global $MoveInCellar2[2]
Global $MoveToGoldLoot1a[2]
Global $MoveToGoldLoot1b[2]
Global $MoveToGoldLoot2[2]
Global $MoveToGoldLoot3[2]
Global $MoveToSalvage1[2]
Global $MoveToSalvage2[2]
Global $MoveToMerchant[2]
Global $MoveToStash1[2]
Global $MoveToStash2[2]
Global $CellarLocation[2]
Global $MonsterLocation[2]
Global $SalvageLocation[2]
Global $MerchantLocation[2]
Global $StashLocation[2]
Global $PortalLocation[2]
Global $CharHitBox[4]
Global $LoginButtonSearchArea[4]
Global $ResumeButtonSearchArea[4]
Global $PortalIconSearchArea[4]
Global $CellarSearchArea[4]
Global $CellarNameSearchArea[4]
Global $TownNameSearchArea[4]
Global $MerchStashSearchArea[4]
Global $MonsterSearchArea[4]
Global $LootingArea[4]
Global $FullBagSearchArea[4]
Global $SellItemsArea[4]
Global $FullStashSearchArea[4]
Global $RepairSearchArea[4]
Global $DeathSearchArea[4]
Global $DisconnectSearchArea[4]
Global $StashBag2[2]
Global $StashBag3[2]
Global $RepairButton[2]
Global $AllItemsButton[2]
Global $CellarPixel
Global $Log
Global $StatsLabel
Global $StartGoldLabel
Global $CurrentGoldLabel
Global $DifferenceGoldLabel
Global $GPHLabel
Global $LogList
Global $RuntimeTimer
Global $TimeOutTimer
Global $RunTimer
Global $Paused
Global $Show
Global $LegendaryLootAttempts = 0
Global $SetLootAttempts = 0
Global $RareLootAttempts = 0
Global $MagicLootAttempts = 0
Global $TomeLootAttempts = 0
Global $GemLootAttempts = 0
Global $StartTime = @HOUR & ":" & @MIN
Global $Runs = 0
Global $Closed = 0
Global $Runtime = "0h 0m 0s"
Global $Disconnects = 0
Global $Deaths = 0
Global $ISx = 0
Global $ISy = 0
Global $StashBag = 1
Global $Alive = True
Global $DisconnectState = 0
Global $FullBag = False
Global $TimeOutCount = 0
Global $Relogged = False
Global $SellCheck
Global $SleepToSalvage
Global $SleepToStash
Global $StartGold = 0
Global $CurrentGold = 0
Global $LastGold = 0
Global $GoldDifference = 0
Global $LastDifferenceGoldLabel = 0
Global $GPH = 0
Global $CellarOpen
$ImageFiles[0][0] = "legendaryA.png|66"
$ImageFiles[0][1] = "legendaryE.png|66"
$ImageFiles[0][2] = "legendaryI.png|66"
$ImageFiles[0][3] = "legendaryO.png|66"
$ImageFiles[0][4] = "legendaryU.png|66"
$ImageFiles[1][0] = "setA.png|90"
$ImageFiles[1][1] = "setE.png|90"
$ImageFiles[1][2] = "setU.png|90"
$ImageFiles[1][3] = "setO.png|90"
$ImageFiles[1][4] = "setI.png|90"
$ImageFiles[2][0] = "rareA.png|104"
$ImageFiles[2][1] = "rareE.png|104"
$ImageFiles[2][2] = "rareI.png|104"
$ImageFiles[2][3] = "rareO.png|104"
$ImageFiles[2][4] = "rareU.png|104"
$ImageFiles[3][0] = "blueA.png|70"
$ImageFiles[3][1] = "blueE.png|70"
$ImageFiles[3][2] = "blueI.png|70"
$ImageFiles[3][3] = "blueO.png|70"
$ImageFiles[3][4] = "blueU.png|70"
$ImageFiles[4][0] = "tome.png|140"
$ImageFiles[4][1] = "iLVL60.png|30"
$ImageFiles[4][2] = "iLVL61.png|30"
$ImageFiles[4][3] = "iLVL62.png|30"
$ImageFiles[4][4] = "iLVL63.png|30"
$ImageFiles[4][5] = "square.png|110"
$ImageFiles[4][6] = "flawless.png|110"
$ImageFiles[5][0] = "empty.png|75"
$ImageFiles[5][1] = "corner.png|20"
$ImageFiles[5][2] = "sellblueA.png|65"
$ImageFiles[5][3] = "sellblueE.png|65"
$ImageFiles[5][4] = "sellblueI.png|65"
$ImageFiles[5][5] = "sellblueO.png|65"
$ImageFiles[5][6] = "sellblueU.png|65"
$ImageFiles[6][0] = "network.png|10"
$ImageFiles[6][1] = "lost.png|10"
$ImageFiles[6][2] = "bg.jpg|5"
$ImageFiles[6][3] = "not.png|120"
$ImageFiles[6][4] = "you.png|100"
$ImageFiles[7][0] = "dank.png|120"
$ImageFiles[7][1] = "new.png|120"
$ImageFiles[7][2] = "game.png|20"
$ImageFiles[7][3] = "portal.png|120"
$ImageFiles[7][4] = "login.png|10"
$ImageFiles[7][5] = "merchant.png|20"
$ImageFiles[7][6] = "stash.png|20"
$SoundFiles[0] = "legendary.wav"
$SoundFiles[1] = "set.wav"
$SoundFiles[2] = "rare.wav"
$SoundFiles[3] = "magic.wav"
$SoundFiles[4] = "tome.wav"
$SoundFiles[5] = "gem.wav"
$CharHitBox[0] = 790
$CharHitBox[1] = 315
$CharHitBox[2] = 1200
$CharHitBox[3] = 730
$LoginButtonSearchArea[0] = 930
$LoginButtonSearchArea[1] = 845
$LoginButtonSearchArea[2] = 985
$LoginButtonSearchArea[3] = 860
$ResumeButtonSearchArea[0] = 250
$ResumeButtonSearchArea[1] = 410
$ResumeButtonSearchArea[2] = 310
$ResumeButtonSearchArea[3] = 425
$PortalIconSearchArea[0] = 1095
$PortalIconSearchArea[1] = 1000
$PortalIconSearchArea[2] = 1140
$PortalIconSearchArea[3] = 1060
$CellarSearchArea[0] = 160
$CellarSearchArea[1] = 130
$CellarSearchArea[2] = 360
$CellarSearchArea[3] = 280
$CellarNameSearchArea[0] = 1760
$CellarNameSearchArea[1] = 10
$CellarNameSearchArea[2] = 1820
$CellarNameSearchArea[3] = 30
$TownNameSearchArea[0] = 1745
$TownNameSearchArea[1] = 10
$TownNameSearchArea[2] = 1795
$TownNameSearchArea[3] = 30
$MerchStashSearchArea[0] = 225
$MerchStashSearchArea[1] = 30
$MerchStashSearchArea[2] = 300
$MerchStashSearchArea[3] = 115
$MonsterSearchArea[0] = 170
$MonsterSearchArea[1] = 75
$MonsterSearchArea[2] = 1270
$MonsterSearchArea[3] = 470
$FullBagSearchArea[0] = 795
$FullBagSearchArea[1] = 125
$FullBagSearchArea[2] = 830
$FullBagSearchArea[3] = 160
$SellItemsArea[0] = 960
$SellItemsArea[1] = 510
$SellItemsArea[2] = 1680
$SellItemsArea[3] = 910
$FullStashSearchArea[0] = 700
$FullStashSearchArea[1] = 135
$FullStashSearchArea[2] = 730
$FullStashSearchArea[3] = 155
$RepairSearchArea[0] = 1507
$RepairSearchArea[1] = 36
$RepairSearchArea[2] = 1512
$RepairSearchArea[3] = 41
$DeathSearchArea[0] = 538
$DeathSearchArea[1] = 335
$DeathSearchArea[2] = 542
$DeathSearchArea[3] = 339
$DisconnectSearchArea[0] = 840
$DisconnectSearchArea[1] = 410
$DisconnectSearchArea[2] = 950
$DisconnectSearchArea[3] = 440
EndFunc
Func Randomize()
$MoveToCellar1[0] = Random(498, 503, 1)
$MoveToCellar1[1] = Random(248, 253, 1)
$MoveToCellar2[0] = Random(1, 4, 1)
$MoveToCellar2[1] = Random(368, 373, 1)
$MoveInCellar1[0] = Random(114, 119, 1)
$MoveInCellar1[1] = Random(984, 989, 1)
$MoveInCellar2[0] = Random(774, 779, 1)
$MoveInCellar2[1] = Random(326, 331, 1)
$MoveToCellar3[0] = Random(18, 23, 1)
$MoveToCellar3[1] = Random(338, 343, 1)
$MoveToGoldLoot1a[0] = Random(400, 405, 1)
$MoveToGoldLoot1a[1] = Random(304, 309, 1)
$MoveToGoldLoot1b[0] = Random(560, 575, 1)
$MoveToGoldLoot1b[1] = Random(300, 305, 1)
$MoveToGoldLoot2[0] = Random(1258, 1263, 1)
$MoveToGoldLoot2[1] = Random(349, 354, 1)
$MoveToGoldLoot3[0] = Random(909, 914, 1)
$MoveToGoldLoot3[1] = Random(692, 697, 1)
$MoveToMerchant[0] = Random(1688, 1693, 1)
$MoveToMerchant[1] = Random(100, 105, 1)
$MerchantLocation[0] = Random(928, 933, 1)
$MerchantLocation[1] = Random(134, 139, 1)
If $Salvage = False Then
If $Sell = True Then
$MoveToStash1[0] = Random(778, 783, 1)
$MoveToStash1[1] = Random(948, 953, 1)
$MoveToStash2[0] = Random(268, 273, 1)
$MoveToStash2[1] = Random(928, 933, 1)
$StashLocation[0] = Random(803, 808, 1)
$StashLocation[1] = Random(428, 433, 1)
$PortalLocation[0] = Random(648, 653, 1)
$PortalLocation[1] = Random(498, 503, 1)
$SleepToStash = 1675
Else
$StashLocation[0] = Random(1047, 1052, 1)
$StashLocation[1] = Random(257, 262, 1)
$PortalLocation[0] = Random(877, 882, 1)
$PortalLocation[1] = Random(427, 432, 1)
EndIf
Else
If $Sell = False Then
$MoveToSalvage1[0] = Random(1397, 1402, 1)
$MoveToSalvage1[1] = Random(497, 502, 1)
$MoveToSalvage2[0] = Random(1497, 1502, 1)
$MoveToSalvage2[1] = Random(497, 502, 1)
$SalvageLocation[0] = Random(1280, 1285, 1)
$SalvageLocation[1] = Random(397, 402, 1)
$MoveToStash1[0] = Random(397, 402, 1)
$MoveToStash1[1] = Random(482, 487, 1)
$MoveToStash2[0] = Random(597, 602, 1)
$MoveToStash2[1] = Random(447, 452, 1)
$StashLocation[0] = Random(852, 857, 1)
$StashLocation[1] = Random(347, 352, 1)
$PortalLocation[0] = Random(782, 787, 1)
$PortalLocation[1] = Random(427, 432, 1)
$SleepToSalvage = 1250
$SleepToStash = 1325
Else
$MoveToSalvage1[0] = Random(802, 807, 1)
$MoveToSalvage1[1] = Random(957, 962, 1)
$MoveToSalvage2[0] = Random(927, 932, 1)
$MoveToSalvage2[1] = Random(942, 947, 1)
$SalvageLocation[0] = Random(1557, 1562, 1)
$SalvageLocation[1] = Random(587, 592, 1)
$MoveToStash1[0] = Random(397, 402, 1)
$MoveToStash1[1] = Random(482, 487, 1)
$MoveToStash2[0] = Random(597, 602, 1)
$MoveToStash2[1] = Random(447, 452, 1)
$StashLocation[0] = Random(850, 855, 1)
$StashLocation[1] = Random(382, 387, 1)
$PortalLocation[0] = Random(747, 752, 1)
$PortalLocation[1] = Random(447, 452, 1)
$SleepToSalvage = 1550
$SleepToStash = 1550
EndIf
EndIf
$CellarLocation[0] = Random(268, 272, 1)
$CellarLocation[1] = Random(188, 192, 1)
$MonsterLocation[0] = Random(575, 580, 1)
$MonsterLocation[1] = Random(181, 186, 1)
$StashBag2[0] = Random(508, 513, 1)
$StashBag2[1] = Random(358, 363, 1)
$StashBag3[0] = Random(508, 513, 1)
$StashBag3[1] = Random(488, 493, 1)
$RepairButton[0] = Random(515, 520, 1)
$RepairButton[1] = Random(481, 486, 1)
$AllItemsButton[0] = Random(221, 226, 1)
$AllItemsButton[1] = Random(590, 595, 1)
$PasswordField[0] = Random(818, 823, 1)
$PasswordField[1] = Random(703, 708, 1)
$ResumeButton[0] = Random(317, 322, 1)
$ResumeButton[1] = Random(414, 419, 1)
$LeaveButton[0] = Random(967, 972, 1)
$LeaveButton[1] = Random(580, 584, 1)
$DisconnectButton[0] = Random(958, 963, 1)
$DisconnectButton[1] = Random(628, 633, 1)
$SalvageButton[0] = Random(262, 267, 1)
$SalvageButton[1] = Random(292, 297, 1)
EndFunc
Func ScriptStarted()
CheckRequiredFiles()
If $LootLegendaries Then
Global $Legendaries = 0
Else
Global $Legendaries = "-"
EndIf
If $LootSets Then
Global $Sets = 0
Else
Global $Sets = "-"
EndIf
If $LootRares Then
Global $Rares = 0
Else
Global $Rares = "-"
EndIf
If $LootMagics Then
Global $Magics = 0
Global $Tomes = "-"
Else
Global $Magics = "-"
If $LootTomes Then
Global $Tomes = "0"
Else
Global $Tomes = "-"
EndIf
EndIf
If $LootGems Then
Global $Gems = 0
Else
Global $Gems = "-"
EndIf
If $Sell Then
Global $Sold = 0
Else
Global $Sold = "-"
EndIf
If $Salvage Then
Global $Salvaged = 0
Else
Global $Salvaged = "-"
EndIf
Pause()
$RuntimeTimer = TimerInit()
If $ShowLog = True Then
DrawLog()
EndIf
If $ShowLog = True Or $SaveStats = True Then
DirGetSize($SaveLogsPath)
If @error = 1 Then
DirCreate($SaveLogsPath)
EndIf
EndIf
If $UseMemRead = True Then
Global $ofs__ObjmanagerActorOffsetA = 0x8b0
Global $ofs__ObjmanagerActorCount = 0x108
Global $ofs__ObjmanagerActorOffsetB = 0x148
Global $ofs__ObjmanagerActorLinkToCTM = 0x380
Global $_ObjmanagerStrucSize = 0x428
Global $ofs_ObjectManager = 0x015A1BEC
$ProcessList = ProcessList()
For $i = 1 To $ProcessList[0][0]
If $ProcessList[$i][0] = "Diablo III.exe" Then
Global $ProcessID = $ProcessList[$i][1]
ExitLoop
EndIf
Next
Global $D3Memory = _MemoryOpen($ProcessID)
EndIf
ToLog("Bot started")
WinActivate('Diablo III')
EndFunc
Func CheckRequiredFiles()
If (@OSArch = "X64" Or @OSArch = "IA64") And Not @AutoItX64 Then
MsgBox(4096, "Error", "You are running a 64bit system. You need to start the script" & @LF & "with 'Run Script (x64)' or 'Compile Script (x64)'" & @LF & "Exiting...")
Exit 0
EndIf
Local $Files[4]
$Files[0] = "msvcr110.dll"
$Files[1] = "msvcr110d.dll"
If @AutoItX64 Then
$Files[2] = "ImageSearchDLL_x64.dll"
Else
$Files[2] = "ImageSearchDLL.dll"
EndIf
$Files[3] = "tesseract.exe"
For $i = 0 To 2
If Not FileExists(@WindowsDir & "\System32\" & $Files[$i]) Then
If Not FileExists($Files[$i]) Then
MsgBox(4096, "Error", "Couldn't find '" & $Files[$i] & "'." & @LF & "Make sure you have put that file into '" & @WindowsDir & "\System32\' or into the script folder." & @LF & "Exiting...")
Exit 0
EndIf
EndIf
Next
If Not FileExists($ReqFiles & "tesseract\" & $Files[3]) Then
MsgBox(4096, "Error", "Couldn't find '" & $Files[3] & "'." & @LF & "Make sure you are using the latest required files." & @LF & "Exiting...")
Exit 0
EndIf
For $i = 0 To UBound($ImageFiles, 1) - 1
For $x = 0 To UBound($ImageFiles, 2) - 1
If Not $ImageFiles[$i][$x] = "" Then
$Array = StringSplit($ImageFiles[$i][$x], "|")
$File = $Array[1]
If Not FileExists($ReqFiles & "pics\" & $File) Then
MsgBox(4096, "Error", "Couldn't find '" & $File & "'." & @LF & "Either you have set the path to the required files folder wrong or you aren't using latest required files." & @LF & "Exiting...")
Exit 0
EndIf
EndIf
Next
Next
EndFunc
Func Pause()
$Paused = Not $Paused
If $Paused Then ToLog("Paused...")
While $Paused
Sleep(250)
ToolTip('Paused... Press {PAUSE} to continue...', 850, 0)
WEnd
ToolTip('Running... Press {PAUSE} to pause...', 850, 0)
EndFunc
Func Lewt()
$lewt = Not $lewt
If $lewt Then ToLog("Looting...")
While $lewt
Sleep(250)
LootItems()
WEnd
EndFunc
Func RandomizeInventory()
Global $Stash[60][2]
$c = 0
$d = -2
For $a = 0 To 59
$d += 1
If $a = 10 Or $a = 20 Or $a = 30 Or $a = 40 Or $a = 50 Then
$c += 1
$d = -1
EndIf
For $b = 0 To 1
If $a = 0 Then
If $b = 0 Then
$Stash[$a][$b] = 1430
Else
$Stash[$a][$b] = 560
EndIf
Else
If $b = 0 Then
$Stash[$a][$b] = Random(1473, 1483, 1) + (49 * $d)
Else
$Stash[$a][$b] = Random(606, 614, 1) + (49 * $c)
EndIf
EndIf
Next
Next
EndFunc
Func DrawLootArea()
$LootingAreaWidth = $LootingArea[2] - $LootingArea[0]
$LootingAreaHeight = $LootingArea[3] - $LootingArea[1]
$LootAreaGUI = GUICreate("", $LootingAreaWidth + 2, $LootingAreaHeight + 2, $LootingArea[0], $LootingArea[1], $WS_POPUP, BitOR($WS_EX_LAYERED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($LootAreaGUI, 0xABCDEF, 0xA0)
WinSetOnTop($LootAreaGUI, "", 1)
GUISetState(@SW_SHOWNOACTIVATE, $LootAreaGUI)
$hDC = _WinAPI_GetWindowDC($LootAreaGUI)
$hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x0000FF)
$obj_orig = _WinAPI_SelectObject($hDC, $hPen)
$user32_dll = DllOpen("user32.dll")
_WinAPI_DrawLine($hDC, 0, 1, $LootingAreaWidth, 0)
_WinAPI_DrawLine($hDC, 1, 0, 0, $LootingAreaHeight)
_WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, $LootingAreaWidth, 0)
_WinAPI_DrawLine($hDC, $LootingAreaWidth, $LootingAreaHeight, 0, $LootingAreaHeight)
_WinAPI_SetTextColor($hDC, 0x0000FF)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 5)
DllStructSetData($tRECT, "Top", 5)
DllStructSetData($tRECT, "Right", 250)
DllStructSetData($tRECT, "Bottom", 50)
_WinAPI_DrawText($hDC, "Loot Area", $tRECT, 0)
EndFunc
Func DrawLog()
$Width = 475
$Height = 225
$LogGUI = GUICreate("", $Width, $Height, 900 - $Width, 1080 - $Height - 2, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
GUISetBkColor(0x424242)
GUICtrlCreatePic($ReqFiles & "\pics\" & StringTrimRight($ImageFiles[6][2], 2), 0, 0, 0, 0)
_WinAPI_SetLayeredWindowAttributes($LogGUI, 0xEEEEEF, 0xEE)
WinSetOnTop($LogGUI, "", 1)
GUISetState(@SW_SHOWNOACTIVATE, $LogGUI)
$StatsLabel = GUICtrlCreateLabel("", 0, 10, $Width, 45, $SS_CENTER)
GUICtrlSetFont($StatsLabel, 8, 500, 0, "")
GUICtrlSetColor($StatsLabel, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$CurrentGoldLabel = GUICtrlCreateLabel("", 0, $Height - 23, 88, 15, $SS_RIGHT)
GUICtrlSetFont($CurrentGoldLabel, 9, 2000, 0, "Arial")
GUICtrlSetColor($CurrentGoldLabel, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($CurrentGoldLabel, "Current Gold")
$DifferenceGoldLabel = GUICtrlCreateLabel("", 115, $Height - 23, 88, 15, $SS_RIGHT)
GUICtrlSetFont($DifferenceGoldLabel, 9, 2000, 0, "Arial")
GUICtrlSetColor($DifferenceGoldLabel, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($DifferenceGoldLabel, "Total gold gain")
$LastDifferenceGoldLabel = GUICtrlCreateLabel("", 231, $Height - 23, 88, 15, $SS_RIGHT)
GUICtrlSetFont($LastDifferenceGoldLabel, 9, 2000, 0, "Arial")
GUICtrlSetColor($LastDifferenceGoldLabel, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($LastDifferenceGoldLabel, "Last gold gain")
$GPHLabel = GUICtrlCreateLabel("", 347, $Height - 23, 88, 15, $SS_RIGHT)
GUICtrlSetFont($GPHLabel, 9, 2000, 0, "Arial")
GUICtrlSetColor($GPHLabel, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($GPHLabel, "Gold per hour")
$Version = GUICtrlCreateLabel("", 5, 2, 100, 20, $SS_LEFT)
GUICtrlSetFont($Version, 7, 500, 0, "")
GUICtrlSetColor($Version, 0x000000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($Version, "V1.DH")
$Copyright = GUICtrlCreateLabel("", $Width - 55, 2, 50, 20, $SS_RIGHT)
GUICtrlSetFont($Copyright, 7, 500, 0, "")
GUICtrlSetColor($Copyright, 0x000000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetData($Copyright, "AL Rev.")
$LogList = GUICtrlCreateList("", 5, 60, $Width - 10, $Height - 85, $LBS_NOSEL)
GUICtrlSetColor($LogList, 0x000000)
GUICtrlSetFont($LogList, 8)
RefreshStats()
EndFunc
Func HideLog()
If Not $Show Then
GUISetState(@SW_HIDE, $LogGUI)
Else
GUISetState(@SW_SHOWNOACTIVATE, $LogGUI)
EndIf
$Show = Not $Show
EndFunc
Func GetGold()
$Sek = Floor(TimerDiff($RuntimeTimer) / 1000)
Send("{c}")
Sleep(400 + ($ComputerLag/2))
$CurrentGold = _TesseractScreenCapture(0, "", 1, 1, 6000, 905, 1435, 1000, 0)
Sleep(100 + ($ComputerLag/2))
$CurrentGold = StringReplace($CurrentGold,",","")
$CurrentGold = StringReplace($CurrentGold,"'","")
$CurrentGold = StringReplace($CurrentGold,"´","")
$CurrentGold = StringReplace($CurrentGold,"`","")
$CurrentGold = StringReplace($CurrentGold,"‘","")
$CurrentGold = StringReplace($CurrentGold," ","")
$CurrentGold = StringReplace($CurrentGold,"i","1")
$CurrentGold = StringReplace($CurrentGold,"l","1")
$CurrentGold = StringReplace($CurrentGold,"o","0")
$CurrentGold = StringReplace($CurrentGold,"s","5")
$CurrentGold = StringReplace($CurrentGold,"‘","")
$CurrentGold = StringReplace($CurrentGold,@LF,"")
Send("{c}")
If $StartGold = 0 Then
$StartGold = $CurrentGold
$LastGold = $StartGold
GUICtrlSetData($CurrentGoldLabel, _StringAddThousandsSep($CurrentGold))
Else
$GoldDifference = $CurrentGold - $StartGold
$LastGoldDifference = $CurrentGold - $LastGold
$LastGold = $CurrentGold
$Sek = Floor(TimerDiff($RuntimeTimer) / 1000)
$GPH = Floor(($CurrentGold - $StartGold) / ($Sek / 3600))
GUICtrlSetData($CurrentGoldLabel, _StringAddThousandsSep($CurrentGold))
GUICtrlSetData($DifferenceGoldLabel, _StringAddThousandsSep($GoldDifference))
GUICtrlSetData($LastDifferenceGoldLabel, _StringAddThousandsSep($LastGoldDifference))
GUICtrlSetData($GPHLabel, _StringAddThousandsSep($GPH))
EndIf
EndFunc
Func RefreshStats()
If $ShowLog = True Then
GUICtrlSetData($StatsLabel, "Start: " & $StartTime & " | Runs: " & $Runs & " | Closed: " & $Closed & " | Deaths: " & $Deaths & " | Disconnects: " & $Disconnects & @LF & @LF & "Sets: " & $Sets & " | Legendaries: " & $Legendaries & " | Rares: " & $Rares & " | Magics: " & $Magics & " | Tomes: " & $Tomes & " | Gems: " & $Gems & " | Sold: " & $Sold & " | Salvaged: " & $Salvaged)
EndIf
EndFunc
Func ToLog($Text)
If $ShowLog = True Then
GUICtrlSetData($LogList, "<" & @HOUR & ":" & @MIN & ":" & @SEC & "> " & $Text)
GUICtrlSendMsg($LogList, $WM_VSCROLL, $SB_LINEDOWN, 0)
$Log = FileOpen($SaveLogsPath & "log.txt", 1)
FileWriteLine($Log, "<" & @HOUR & ":" & @MIN & ":" & @SEC & "> " & $Text)
If $Text = "Bot closed" Then
FileWriteLine($Log, @LF)
EndIf
FileClose($Log)
EndIf
EndFunc
Func Relog()
ToLog("Relogging...")
MouseClick("LEFT", $PasswordField[0], $PasswordField[1], 1, 2)
Send($Password)
Sleep(1000 + $ComputerLag)
Send("{ENTER}")
$Relogged = True
$DisconnectState = 0
EndFunc
Func SaveStats()
$File = FileOpen($SaveLogsPath & "statistics.txt", 1)
FileWriteLine($File, "=========" & @HOUR & ":" & @MIN & ":" & @SEC & "=========")
FileWriteLine($File, "Startime: " & @TAB & @TAB & $StartTime & @LF & "Runs: " & @TAB & @TAB & $Runs & @LF & "Closed: " & @TAB & @TAB & $Closed & @LF & "Deaths: " & @TAB & @TAB & $Deaths & @LF & "Disconnects: " & @TAB & $Disconnects & @LF & "Runtime: " & @TAB & @TAB & $Runtime & @LF & @LF & "Sets: " & @TAB & @TAB & $Sets & @LF & "Legendaries: " & @TAB & $Legendaries & @LF & "Rares: " & @TAB & @TAB & $Rares & @LF & "Magics: " & @TAB & @TAB & $Magics & @LF & "Tomes: " & @TAB & @TAB & $Tomes & @LF & "Gems: " & @TAB & @TAB & $Gems & @LF & "Sold: " & @TAB & @TAB & $Sold & @LF & "Salvaged: " & @TAB & @TAB & $Salvaged & @LF & @LF & "Startgold: " & @TAB & _StringAddThousandsSep($StartGold) & @LF & "Current gold: " & @TAB & _StringAddThousandsSep($CurrentGold) & @LF & "Gold gain: " & @TAB & _StringAddThousandsSep($GoldDifference) & @LF & "Gold per hour: " & @TAB & _StringAddThousandsSep($GPH))
FileWriteLine($File, @LF)
FileClose($File)
EndFunc
Func Move($x, $y)
MouseClick('MIDDLE', $x, $y, 1, 2)
EndFunc
Func Attack($x, $y)
Send("{SHIFTDOWN}")
MouseClick('Right', $x, $y, 1, 2)
Sleep(250)
MouseClick('Left', $x, $y, 1, 2)
Send("{SHIFTUP}")
EndFunc
Func AttackNearbyMonsters()
$Logged = False
While 1
$MonsterData = PixelSearch($CharHitBox[0], $CharHitBox[1], $CharHitBox[2], $CharHitBox[3], 0xEE0000, 10)
If @error Then
ExitLoop
EndIf
If $Logged = False Then
ToLog("Monster found...")
EndIf
Attack($MonsterData[0], $MonsterData[1])
Sleep(100)
$Logged = True
WEnd
EndFunc
Func LeaveGame()
$Sek = Floor(TimerDiff($RuntimeTimer) / 1000)
$Min = Floor($Sek / 60)
$Hour = Floor($Min / 60)
$Runtime = $Hour & "h " & ($Min - $Hour * 60) & "m " & ($Sek - $Min * 60) & "s"
If $SaveStats = True Then
SaveStats()
EndIf
If $InstantLeave = True Then GetGold()
ToLog("Leaving the game")
Sleep(200 + ($ComputerLag / 2))
Send("{ESC}")
Sleep(100 + ($ComputerLag / 2))
MouseClick('LEFT', $LeaveButton[0], $LeaveButton[1], 1, 2)
Return "LeftGame"
EndFunc
Func Terminate()
ToLog("Terminating... Good bye :)")
Exit 0
EndFunc
Func _ImageSearchArea($FindImage, $ResultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $Tolerance)
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
$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
Func _TesseractScreenCapture($get_last_capture = 0, $delimiter = "", $cleanup = 1, $scale = 2, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $show_capture = 0)
Global $last_capture
Global $tesseract_temp_path = "C:\"
Local $tInfo
Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
Dim $aArray, $final_ocr[1], $xyPos_old = -1, $capture_scale = 3
DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO))
DllStructSetData($tSCROLLINFO, "fMask", $SIF_ALL)
If $last_capture = "" Then
$last_capture = ObjCreate("Scripting.Dictionary")
EndIf
If $get_last_capture = 1 and $last_capture.item(0) <> "" Then
Return $last_capture.item(0)
EndIf
$capture_filename = _TempFile($tesseract_temp_path, "~", ".tif")
$ocr_filename = StringLeft($capture_filename, StringLen($capture_filename) - 4)
$ocr_filename_and_ext = $ocr_filename & ".txt"
CaptureToTIFF("", "", "", $capture_filename, $scale, $left_indent, $top_indent, $right_indent, $bottom_indent)
ShellExecuteWait($ReqFiles & "\tesseract\tesseract.exe", $capture_filename & " " & $ocr_filename, "", "", @SW_HIDE)
If StringCompare($delimiter, "") = 0 Then
$final_ocr = FileRead($ocr_filename_and_ext)
Else
_FileReadToArray($ocr_filename_and_ext, $aArray)
_ArrayDelete($aArray, 0)
_ArrayConcatenate($final_ocr, $aArray)
EndIf
If $show_capture = 1 Then
GUICreate("Tesseract Screen Capture. Note: image displayed is not to scale", 640, 480, 0, 0, $WS_SIZEBOX + $WS_SYSMENU)
GUISetBkColor(0xE0FFFF)
$Obj1 = ObjCreate("Preview.Preview.1")
$Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 0, 640, 480)
$Obj1.ShowFile ($capture_filename, 1)
GUISetState()
If IsArray($final_ocr) Then
_ArrayDisplay($aArray, "Tesseract Text Capture")
Else
MsgBox(0, "Tesseract Text Capture", $final_ocr)
EndIf
GUIDelete()
EndIf
FileDelete($ocr_filename & ".*")
If IsArray($final_ocr) And $cleanup = 1 Then
For $final_ocr_num = 1 To (UBound($final_ocr)-1)
$final_ocr[$final_ocr_num] = StringReplace($final_ocr[$final_ocr_num], ".", "")
$final_ocr[$final_ocr_num] = StringReplace($final_ocr[$final_ocr_num], "'", "")
$final_ocr[$final_ocr_num] = StringReplace($final_ocr[$final_ocr_num], ",", "")
$final_ocr[$final_ocr_num] = StringStripWS($final_ocr[$final_ocr_num], 3)
Next
For $each in $final_ocr
$found_item = _ArrayFindAll($final_ocr, $each)
If IsArray($found_item) Then
If StringCompare($final_ocr[$found_item[0]], "") = 0 Then
_ArrayDelete($final_ocr, $found_item[0])
EndIf
EndIf
For $found_item_num = 2 To UBound($found_item)
_ArrayDelete($final_ocr, $found_item[$found_item_num-1])
Next
Next
EndIf
If $last_capture.item(0) = "" Then
$last_capture.item(0) = $final_ocr
EndIf
$tSCROLLINFO = 0
Return $final_ocr
EndFunc
Func CaptureToTIFF($win_title = "", $win_text = "", $ctrl_id = "", $sOutImage = "", $scale = 1, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0)
Local $hWnd, $hwnd2, $hDC, $hBMP, $hImage1, $hGraphic, $CLSID, $tParams, $pParams, $tData, $i = 0, $hImage2, $pos[4]
Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))
Local $giTIFColorDepth = 24
Local $giTIFCompression = $GDIP_EVTCOMPRESSIONNONE
If StringCompare($ctrl_id, "") <> 0 Then
$hwnd2 = ControlGetHandle($win_title, $win_text, $ctrl_id)
$pos = ControlGetPos($win_title, $win_text, $ctrl_id)
Else
If StringCompare($win_title, "") <> 0 Then
$hwnd2 = WinGetHandle($win_title, $win_text)
$pos = WinGetPos($win_title, $win_text)
Else
$hwnd2 = ""
$pos[0] = 0
$pos[1] = 0
$pos[2] = @DesktopWidth
$pos[3] = @DesktopHeight
EndIf
EndIf
If IsHWnd($hwnd2) Then
WinActivate($win_title, $win_text)
$hBitmap2 = _ScreenCapture_CaptureWnd("", $hwnd2, 0, 0, -1, -1, False)
Else
$hBitmap2 = _ScreenCapture_Capture("", 0, 0, -1, -1, False)
EndIf
_GDIPlus_Startup ()
$hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2)
$hWnd = _WinAPI_GetDesktopWindow()
$hDC = _WinAPI_GetDC($hWnd)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDC, ($pos[2] * $scale) - ($right_indent * $scale), ($pos[3] * $scale) - ($bottom_indent * $scale))
_WinAPI_ReleaseDC($hWnd, $hDC)
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
_GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0 - ($left_indent * $scale), 0 - ($top_indent * $scale), ($pos[2] * $scale) + $left_indent, ($pos[3] * $scale) + $top_indent)
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
$tParams = _GDIPlus_ParamInit(2)
$tData = DllStructCreate("int ColorDepth;int Compression")
DllStructSetData($tData, "ColorDepth", $giTIFColorDepth)
DllStructSetData($tData, "Compression", $giTIFCompression)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGCOLORDEPTH, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "ColorDepth"))
_GDIPlus_ParamAdd($tParams, $GDIP_EPGCOMPRESSION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Compression"))
If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams)
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID, $pParams)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose ($hGraphic)
_WinAPI_DeleteObject($hBitmap2)
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
EndFunc
Func _StringAddThousandsSep($number)
$number = String($number)
Switch StringLen($number)
Case 1
$number = $number
Case 2
$number = $number
Case 3
$number = $number
Case 4
$number = _StringInsert($number, ".", -3)
Case 5
$number = _StringInsert($number, ".", -3)
Case 6
$number = _StringInsert($number, ".", -3)
Case 7
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
Case 8
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
Case 9
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
Case 10
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
$number = _StringInsert($number, ".", -11)
Case 11
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
$number = _StringInsert($number, ".", -11)
Case 12
$number = _StringInsert($number, ".", -3)
$number = _StringInsert($number, ".", -7)
$number = _StringInsert($number, ".", -11)
EndSwitch
Return $number
EndFunc
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $iv_InheritHandle = 1)
If Not ProcessExists($iv_Pid) Then
SetError(1)
Return 0
EndIf
Local $ah_Handle[2] = [DllOpen('kernel32.dll')]
If @Error Then
SetError(2)
Return 0
EndIf
Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $iv_InheritHandle, 'int', $iv_Pid)
If @Error Then
DllClose($ah_Handle[0])
SetError(3)
Return 0
EndIf
$ah_Handle[1] = $av_OpenProcess[0]
Return $ah_Handle
EndFunc
Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
EndIf
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf
EndFunc
Func IterateObjectList()
$_CurOffset = $_itrObjectManagerD
$_Count = _MemoryRead($_itrObjectManagerCount, $D3Memory, 'int')
Dim $OBJ[$_Count+1][13]
For $i = 0 To $_Count Step +1
$_GUID = _MemoryRead($_CurOffset+0x4, $D3Memory, 'ptr')
If $_GUID = 0xffffffff Then
$_PROXY_NAME = -1
$_REAL_NAME = -1
$_ACTORLINK = -1
$_POS_X = -1
$_POS_Y = -1
$_POS_Z = -1
$_DATA = -1
$_DATA2 = -1
Else
$_PROXY_NAME = _MemoryRead($_CurOffset+0x8, $D3Memory, 'char[64]')
$TmpString = StringSplit($_PROXY_NAME,"-")
If IsDeclared("__"&$TmpString[1]) Then
$_REAL_NAME = eval("__"&$TmpString[1])
Else
$_REAL_NAME = $_PROXY_NAME
EndIf
$_ACTORLINK = _MemoryRead($_CurOffset+0x88, $D3Memory, 'ptr')
$_POS_X = _MemoryRead($_CurOffset+0xB0, $D3Memory, 'float')
$_POS_Y = _MemoryRead($_CurOffset+0xB4, $D3Memory, 'float')
$_POS_Z = _MemoryRead($_CurOffset+0xB8, $D3Memory, 'float')
$_DATA = _MemoryRead($_CurOffset+0x1FC, $D3Memory, 'int')
$_DATA2 = _MemoryRead($_CurOffset+0x1Cc, $D3Memory, 'int')
EndIf
$Distance = 0
$OBJ[$i][0] = $_CurOffset
$OBJ[$i][1] = $_GUID
$OBJ[$i][2] = $_PROXY_NAME
$OBJ[$i][3] = $_POS_X
$OBJ[$i][4] = $_POS_Y
$OBJ[$i][5] = $_POS_Z
$OBJ[$i][6] = $_DATA
$OBJ[$i][7] = $_DATA2
$OBJ[$i][8] = $Distance
$OBJ[$i][9] = $_ACTORLINK
$OBJ[$i][10] = $_REAL_NAME
$OBJ[$i][11] = -1
$OBJ[$i][12] = -1
$_CurOffset = $_CurOffset + $_ObjmanagerStrucSize
Next
Return $OBJ
EndFunc
Func OnAutoItExit()
ToLog("Bot closed")
EndFunc