Code:
Func AnalScan()
GUICtrlSetData($lblStatus, "Status: Unhighlighting new items")
For $i = 0 To 9
For $j = 0 To 5
MouseMove(Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio), 1)
Next
Next
EndFunc
Func AnalLoot()
DebugLog(@CRLF & "****************************************************" & @CRLF & _
"iLvl Analyzing " & @CRLF & _
"****************************************************")
AnalScan()
ArrayClear($structArray)
$rt = TimerInit()
GUICtrlSetData($lblStatus, "Status: Stashing And Analyzing Loot")
For $i = 0 To 9
For $j = 0 To 5
$myStruct = DllStructCreate($struct)
DllStructSetData($myStruct, "x", Round(($slot1x + $i * $offset) * $x_ratio))
DllStructSetData($myStruct, "y", Round(($slot1y + $j * $offset) * $y_ratio))
If $size[0] = "1920" or $size[0] = "1600" Then
$SlotPixelLine = PixelSearch(Round(($slotLineTopX + $i * $offset) * $x_ratio), Round(($slotLineTopY + $j * $offset) * $y_ratio), Round(($slotLineBotX + $i * $offset) * $x_ratio), Round(($slotLineBotY + $j * $offset) * $y_ratio), 0x2C1B14,1)
Else
$SlotPixelLine = PixelSearch(Round(($slotLineTopX + $i * $offset) * $x_ratio), Round(($slotLineTopY + $j * $offset) * $y_ratio), Round(($slotLineBotX + $i * $offset) * $x_ratio), Round(($slotLineBotY + $j * $offset) * $y_ratio), 0x312018,1)
Endif
$MiddleOfCell = PixelSearch(Round(($CellMiddleTopX + $i * $offset) * $x_ratio), Round(($CellMiddleTopY + $j * $offset) * $y_ratio), Round(($CellMiddleBotX + $i * $offset) * $x_ratio), Round(($CellMiddleBotY + $j * $offset) * $y_ratio), 0x130C08)
If Not IsArray($MiddleOfCell) Then
If IsArray($SlotPixelLine) Or $slotError >= 1 Or $j = 0 Then
$slotError = 0
MouseMove(Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio),1)
Sleep($AnalSpeed)
$ItemInfo = StringSplit(GetItemInfo(), ",")
If StringRegExp($ItemInfo[1],"Magic") Then
DebugLog("Magic Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
If $ItemInfo[2] < 0 Then
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Magic")
$AnalVendor = 1
Else
If $ItemInfo[2] >= $MagicStashiLvl Then
MouseClick("Right", Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio), 1)
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Magic")
Elseif $ItemInfo[2] <= $MagicSalvageiLvl And $ItemInfo[2] > $MagicVendoriLvl Then
DllStructSetData($myStruct, "vendor", false)
DllStructSetData($myStruct, "salvage", true)
DllStructSetData($myStruct, "itemtype", "Magic")
$AnalSalvage = 1
Elseif $ItemInfo[2] <= $MagicVendoriLvl Then
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Magic")
$AnalVendor = 1
EndIf
EndIf
ElseIf StringRegExp($ItemInfo[1],"Rare") Then
DebugLog("Rare Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
If $ItemInfo[2] < 0 Then
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Rare")
$AnalRareIdentify = 1
$AnalVendor = 1
Else
If $ItemInfo[2] >= $RareStashiLvl Then
MouseClick("Right", Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio), 1)
Elseif $ItemInfo[2] <= $RareSalvageiLvl And $ItemInfo[2] > $RareVendoriLvl Then
DllStructSetData($myStruct, "vendor", false)
DllStructSetData($myStruct, "salvage", true)
DllStructSetData($myStruct, "itemtype", "Rare")
$AnalSalvage = 1
ElseIf $ItemInfo[2] <= $RareVendoriLvl Then
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Rare")
$AnalRareIdentify = 1
$AnalVendor = 1
EndIf
EndIf
ElseIf StringRegExp($ItemInfo[1],"Set") Or StringRegExp($ItemInfo[1],"Legendary") Then
DebugLog($ItemInfo[1] & " Item Found iLvl=" &$ItemInfo[2]&" @ Cell " & $i & "," & $j)
MouseClick("Right", Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio), 1)
ElseIf StringRegExp($ItemInfo[1],"Crafting") Or StringRegExp($ItemInfo[1],"Tomes") Or StringRegExp($ItemInfo[1],"Gem") Or StringRegExp($ItemInfo[1],"Tome") _
Or StringRegExp($ItemInfo[1],"RareRing") Or StringRegExp($ItemInfo[1], "RareAmmy") Or StringRegExp($ItemInfo[1], "BlackSmithPlan") Then
DebugLog($ItemInfo[1] & " @ Cell " & $i & "," & $j)
MouseClick("Right", Round(($slot1x + $i * $offset) * $x_ratio), Round(($slot1y + $j * $offset) * $y_ratio), 1)
ElseIf $ItemInfo[1] = 0 Then
DebugLog("Unknown Item Found iLvl=0 @ Cell " & $i & "," & $j)
DllStructSetData($myStruct, "vendor", true)
DllStructSetData($myStruct, "salvage", false)
DllStructSetData($myStruct, "itemtype", "Uknown")
$AnalVendor = 1
Else
$slotError += 1
EndIF
EndIf
EndIf
If CheckFullStash() = 0 Then ExitLoop
$structArray[$i][$j] = $myStruct
Next
Next
$srt = TimerDiff($rt)
$AnalTime = Round($srt / 1000, 2)
DebugLog(@CRLF & "iLvl Analyzing took " & $AnalTime & " Seconds" & @CRLF & _
"****************************************************")
EndFunc ;==>AnalLoot
Func DoIdentify()
$rt = TimerInit()
DebugLog("Identifying Rare Items" & @CRLF & _
"****************************************************")
Send("i")
For $i = 0 To 9
For $j = 0 To 5
$tmp = $structArray[$i][$j]
$type = DllStructGetData($tmp, "itemtype")
$shouldVendor = DllStructGetData($tmp, "vendor")
If $type = "Rare" And $shouldVendor = True Then
$xpos = DllStructGetData($tmp, "x")
$ypos = DllStructGetData($tmp, "y")
DebugLog("Rare to Identify " & $i & "," & $j)
ConsoleWrite($xpos&","&$ypos&" iDENT" & @CRLF)
MouseClick("Right",$xpos,$ypos,1)
Sleep(Random(2800, 3000))
EndIF
$tmp = 0
Next
Next
Send("i")
$AnalRareIdentify = 0
$srt = TimerDiff($rt)
$AnalTime = Round($srt / 1000, 2)
DebugLog(@CRLF & "Identifying Rares Took " & $AnalTime & " Seconds" & @CRLF & _
"****************************************************")
EndFunc
Func DoSalvage()
$rt = TimerInit()
DebugLog("Salvaging Items" & @CRLF & _
"****************************************************")
MouseClick("Left",Round(1860* $x_ratio),Round(301 * $y_ratio),1)
sleep(2200)
MouseClick("Left",Round(523 * $x_ratio),Round(484 * $y_ratio),1)
sleep(300)
MouseClick("Left",Round(265 * $x_ratio),Round(290 * $y_ratio),1)
If Not _ImageSearchArea("CurrentInventory.png", 1, Round(1603 * $x_ratio), Round(164 * $y_ratio), Round(1870 * $x_ratio), Round(542 * $y_ratio), $gX, $gY, 0) Then
GUICtrlSetData($lblStatus, "Status: Frozen to prevent vendor of worn item, sorry....")
TogglePause()
EndIf
For $i = 0 To 9
For $j = 0 To 5
$tmp = $structArray[$i][$j]
$shouldSalvage = DllStructGetData($tmp, "salvage")
If $shouldSalvage = True Then
DebugLog("Item to Salvage " & $i & "," & $j)
$xpos = DllStructGetData($tmp, "x")
$ypos = DllStructGetData($tmp, "y")
$type = DllStructGetData($tmp, "itemtype")
ConsoleWrite($xpos&","&$ypos&" Salvage" & @CRLF)
MouseClick("Left",$xpos,$ypos,1)
If $type = "Rare" Then
Send("{Enter}")
EndIf
sleep(150)
EndIF
$tmp = 0
Next
Next
Send("{Space}")
$srt = TimerDiff($rt)
$AnalTime = Round($srt / 1000, 2)
DebugLog(@CRLF & "Salvaging Items Took " & $AnalTime & " Seconds" & @CRLF & _
"****************************************************")
$StoredText = ""
EndFunc
Func VendorLoot()
$rt = TimerInit()
DebugLog("Vendoring Items" & @CRLF & _
"****************************************************")
If $AnalSalvage = 1 Then
MouseClick("left",Round(1078 * $x_ratio), Round(41 * $y_ratio), 6) ;NPC Merchant to the right of cain's home
sleep(2200)
MouseClick("left",Round(889 * $x_ratio), Round(398 * $y_ratio), 6) ;NPC Merchant to the right of cain's home
sleep(500)
Else
Sleep(Random(300, 500))
MouseMove(1525 * $x_ratio, 70 * $y_ratio)
Send("{" & $Skill3 & " down}")
Sleep($timingWormHole)
Send("{" & $Skill3 & " up}")
MouseClick("left", Round(796 * $x_ratio), Round(474 * $y_ratio), 6) ;NPC Merchant to the right of cain's
EndIf
sleep(300)
$arr = 0
If Not _ImageSearchArea("CurrentInventory.png", 1, Round(1603 * $x_ratio), Round(164 * $y_ratio), Round(1870 * $x_ratio), Round(542 * $y_ratio), $gX, $gY, 0) Then
GUICtrlSetData($lblStatus, "Status: Frozen to prevent salvage of worn item, sorry....")
TogglePause()
EndIf
For $i = 0 To 9
For $j = 0 To 5
$tmp = $structArray[$i][$j]
$shouldVendor = DllStructGetData($tmp, "vendor")
If $shouldVendor = True Then
DebugLog("Item to Vendor " & $i & "," & $j)
$xpos = DllStructGetData($tmp, "x")
$ypos = DllStructGetData($tmp, "y")
ConsoleWrite($xpos&","&$ypos&" Vendor" & @CRLF)
MouseClick("Right",$xpos,$ypos,1)
EndIf
$tmp = 0
Next
Next
Sleep(200)
RandClick("left", Round(521 * $x_ratio), Round(506 * $y_ratio), 1, 1) ;button to open up repair menu
Sleep(300)
RandClick("left", Round(260 * $x_ratio), Round(595 * $y_ratio), 1, 1) ;button to pay for repairs
Sleep(200)
Send("{ESCAPE}")
$srt = TimerDiff($rt)
$AnalTime = Round($srt / 1000, 2)
DebugLog(@CRLF & "Vendoring Items Took " & $AnalTime & " Seconds" & @CRLF & _
"****************************************************")
EndFunc ;==>VendorLoot
Func GetItemInfo()
$gX = 0
$gY = 0
$Type = 0
$CheckRing = 0
$mousePos = MouseGetPos()
Local $Rings[2] = ["RareRing","RareAmmy"]
Local $MiscItems[4] = ["Crafting","Tomes","Gem","BlackSmithPlan"]
Local $ItemQuality[8] = ["Magic","MagicRed","Rare","RareRed","Legendary","LegendaryRed","Set","SetRed"]
For $i = 0 to Ubound($ItemQuality) -1
If _ImageSearchArea($pngLoc & $ItemQuality[$i] & ".png",1, Round($mousePos[0] - 400 * $x_ratio), 625 * $y_ratio , Round($mousePos[0] - 100 * $x_ratio),850 * $y_ratio,$gX,$gY, 30) Then
$Type = $ItemQuality[$i]
If StringRegExp($Type,"Rare") Or StringRegExp($Type,"Legendary") Or StringRegExp($Type,"Set") Then
$CheckRing = 1
EndIf
ExitLoop
Else
$Type = 0
EndIf
Next
If $CheckRing = 1 Then
For $i = 0 to Ubound($Rings) -1
If _ImageSearchArea($pngLoc & $Rings[$i] & ".png",1, Round($mousePos[0] - 400 * $x_ratio), 625 * $y_ratio , Round($mousePos[0] - 100 * $x_ratio), 850 * $y_ratio,$gX,$gY, 90) Then
Return $Rings[$i] & "," & $RareStashiLvl
ExitLoop
EndIf
Next
ElseIf $Type = 0 Then
For $i = 0 to Ubound($MiscItems) -1
If _ImageSearchArea($pngLoc & $MiscItems[$i] & ".png",1, Round($mousePos[0] - 400 * $x_ratio), 625 * $y_ratio , Round($mousePos[0] - 100 * $x_ratio), 850 * $y_ratio,$gX,$gY, 90) Then
Return $MiscItems[$i] & "," & $RareStashiLvl
ExitLoop
EndIf
Next
EndIf
If _ImageSearchArea($pngLoc & "ItemLevel1920x1080.png",1, $mousePos[0]-470*$x_ratio, 750 * $y_ratio, $mousePos[0] - 275 * $x_ratio, 1025 * $y_ratio,$gX,$gY, 90) Then
$capture = _TesseractScreenCapture(0, "", 1, 4, Round($gX-5 * $x_ratio), Round($gY-10 * $y_ratio), Round($gX + 80 * $x_ratio), Round($gY + 10 * $y_ratio), 0)
$Fixed = StringRegExpReplace($capture,"Q","9")
$iLvl = StringRegExpReplace($Fixed,"[a-zA-Z|:;~.,ยป<?_=+|-]","")
$StringLength = StringLen($iLvl)
If $StringLength > 2 Then
$StringLength -= 3
$iLvl = StringMid($iLvl, $StringLength, 2)
EndIF
Return $Type & "," & $iLvl
Else
Return 0
EndIf
EndFunc
Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
$findImage = "*TRANSBLACK " & $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
EndIf
; 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