02-02-2015, 01:27 AM
nicely done
i've got news about the th location on the map.
i've adjusted the _ImageSearchArea function in a way that works most of the times
no background mode, it' only for foreground as i'm unable to get a non black screenshot in background mode.
i've got news about the th location on the map.
i've adjusted the _ImageSearchArea function in a way that works most of the times
no background mode, it' only for foreground as i'm unable to get a non black screenshot in background mode.
Code:
Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $Tolerance)
if $Tolerance > 0 then $findImage = "*" & $Tolerance & " " & $findImage
If $ichkBackground = 0 Then
$x1 += $BSPos[0]
$y1 += $BSPos[1]
$right += $BSPos[0]
$bottom += $BSPos[1]
EndIf
If IsString($findImage) Then
if $tolerance > 0 then
$findImage = "*" & $tolerance & " " & $findImage
EndIf
EndIf
$result = DllCall("COCBot32.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
; If error exit
If IsArray($result) Then
If $result[0] = "0" Then Return 0
Else
SetLog("Error cannot check for Dead Base, Attacking...")
Return 1
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) - $x1
$y=$y + Int(Number($array[5])/2) - $y1
endif
return 1
EndIf
EndFunc