Greetings. I have been having a lot of trouble with PixelSearch ever since I first attempted to use it.
I am trying to run a Diablo 3 single player bot, which begins in Act 1. The bot detects when the color of the healthpot is not present on the player belt,
and then begins walking down to Akara to be healed.
The problem I have is that the script will NOT select Akara. I continue to receive the following error:
D:\Computer Files\Autoit\Dust Bot\DustBot1.au3 (46) : ==> Subscript used with non-Array variable.:
MouseClick("left", $akara[0], $akara[1])
MouseClick("left", $akara^ ERROR
I have tried many methods, but the script will not seem to return an x or y coordinate value. Please help, with specific instructions? That would be really great.
Script:
$Active = Run("D:\Games\Diablo II\Diablo II\Diablo II.exe -w")
Sleep(1000)
;Window Move To Top Left Edge
WinMove("Diablo II", "", -3, -25)
Sleep(2000)
;Single Player Click
MouseClick("left", 397, 310, 2, 15)
;Character Slot 1 Selection
MouseClick("left", 179, 131, 2, 15)
Sleep(2000)
$BeltSlot1 = PixelGetColor(440, 582) ; empty color: 1315860
$BeltSlot2 = PixelGetColor(471, 582) ; 21053761
$BeltSlot3 = PixelGetColor(502, 582) ; 1052688
$BeltSlot4 = PixelGetColor(533, 582) ; 263172
While $BeltSlot1 <> 8925220
MouseClick("left", 766, 495, 1, 3)
Sleep(2500)
MouseClick("left", 766, 390, 1, 3)
Sleep(2500)
MouseClick("left", 766, 295, 1, 3)
Sleep(2500)
MouseClick("left", 769, 343, 1, 3)
Sleep(2500)
; I have tried with the While loop and error = 0, and have tried with no isarray function at all.
$akara = PixelSearch(182, 100, 745, 419, 381444, 8, 1)
if isarray($akara) then
MouseClick("Left",$akara[0],$akara[1], 1, 0)
EndIf
Sleep(1000)
; MouseMove($x, $y, 15)
MouseClick("left", $akara[0], $akara[1])
Sleep(10000)
WEnd
;PixelSearch(433, 580, 441, 589
$GameState = 1
If WinActive("Diablo II") = 0 Then
$GameState + 1
EndIf
While $GameState > 0
$RedHealth = PixelGetColor(86, 545)
;MsgBox(0,"The decimal color is", $var)
;6029312 is the red color in middle
$HealthLow = 0
While $HealthLow < 1
$RedHealthMiddle = PixelGetColor(86, 545)
If $RedHealthMiddle <> $RedHealth Then
Send("1")
Sleep(5000)
EndIf
WEnd
WEnd
Exit