NB: camp location is hard coded!!! this need to be changed to locate camp and use those coords!
enclosed files reads the exact amount of troops in camp. this way you can start when troop in camp is >95%
nb: in the last script the camp location is hard coded. this need to be changed to do a locate, just like barracks
Code:
;==============================================================================================================
;===Get Digit=============================================================================================
;--------------------------------------------------------------------------------------------------------------
;Finds pixel color pattern of specific X and Y values, returns digit if pixel color pattern found.
;--------------------------------------------------------------------------------------------------------------
Func getCamp(ByRef $x, $y, $type)
Local $width = 0
;Search for digit 1
$width = 5
Select
Case $type = "Gold"
Local $c1 = Hex(0x070706, 6), $c2 = Hex(0xbebebe, 6), $c3 = Hex(0x9c9c9c, 6)
EndSelect
Local $pixel1[3] = [$x + 1, $y , $c1], $pixel2[3] = [$x + 2, $y + 3, $c2], $pixel3[3] = [$x + 2, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 1
Else ;Solves the problem when the spaces between the middle goes from 6 to 5 pixels
Local $pixel1[3] = [$x , $y , $c1], $pixel2[3] = [$x + 1, $y + 3, $c2], $pixel3[3] = [$x + 1, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 1
EndIf
EndIf
;Search for digit 2
$width = 8
Select
Case $type = "Gold"
Local $c1 = Hex(0x9f9f9f, 6), $c2 = Hex(0x010101, 6), $c3 = Hex(0x060606, 6)
EndSelect
Local $pixel1[3] = [$x + 4, $y + 7 , $c1], $pixel2[3] = [$x + 6, $y + 7, $c2], $pixel3[3] = [$x + 2, $y + 3, $c3]
;= [$x +1 , $y + 8, $c2], $pixel3[3] = [$x + 4, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 2
Else ;Solves the problem when the spaces between the middle goes from 6 to 5 pixels
Local $pixel1[3] = [$x + 3, $y + 7 , $c1], $pixel2[3] = [$x + 5, $y + 7, $c2], $pixel3[3] = [$x + 1, $y + 3, $c3]
;= [$x +1 , $y + 8, $c2], $pixel3[3] = [$x + 4, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 2
EndIf
EndIf
;Search for digit 3
$width = 8
Select
Case $type = "Gold"
Local $c1 = Hex(0x0e0e0e, 6), $c2 = Hex(0x000000, 6), $c3 = Hex(0x191919, 6)
EndSelect
Local $pixel1[3] = [$x + 4, $y + 3 , $c1], $pixel2[3] = [$x + 2, $y + 5, $c2], $pixel3[3] = [$x + 4, $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 3
Else
Local $pixel1[3] = [$x + 3, $y + 3 , $c1], $pixel2[3] = [$x + 1, $y + 5, $c2], $pixel3[3] = [$x + 3, $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 3
EndIf
EndIf
;Get digit 4
$width = 9
Select
Case $type = "Gold"
Local $c1 = Hex(0xb0b0b0, 6), $c2 = Hex(0xc9c9c9, 6), $c3 = Hex(0x7b7b7b, 6)
EndSelect
Local $pixel1[3] = [$x + 3, $y + 2, $c1], $pixel2[3] = [$x + 2, $y + 4, $c2], $pixel3[3] = [$x + 1, $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 4
Else
Local $pixel1[3] = [$x + 2, $y + 2, $c1], $pixel2[3] = [$x + 1, $y + 4, $c2], $pixel3[3] = [$x , $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 4
EndIf
EndIf
;Digit is 5
$width = 8
Select
Case $type = "Gold"
Local $c1 = Hex(0xb7b7b7, 6), $c2 = Hex(0x404040, 6), $c3 = Hex(0xa6a6a6, 6)
EndSelect
Local $pixel1[3] = [$x + 2, $y + 8 , $c1], $pixel2[3] = [$x + 1, $y + 1, $c2], $pixel3[3] = [$x + 4, $y + 6, $c3]
;= [$x +1 , $y + 8, $c2], $pixel3[3] = [$x + 4, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 5
Else
Local $pixel1[3] = [$x + 1, $y + 8 , $c1], $pixel2[3] = [$x , $y + 1, $c2], $pixel3[3] = [$x + 3, $y + 6, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 5
EndIf
EndIf
;Digit is 6
$width = 9
Select
Case $type = "Gold"
Local $c1 = Hex(0xa6a6a6, 6), $c2 = Hex(0x040404, 6), $c3 = Hex(0x030303, 6)
EndSelect
Local $pixel1[3] = [$x + 4, $y + 3 , $c1], $pixel2[3] = [$x + 5, $y + 7, $c2], $pixel3[3] = [$x + 7, $y + 3, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 6
Else
Local $pixel1[3] = [$x + 3, $y + 3 , $c1], $pixel2[3] = [$x + 4, $y + 7, $c2], $pixel3[3] = [$x + 6, $y + 3, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 6
EndIf
EndIf
;Digit is 7
$width = 8
Select
Case $type = "Gold"
Local $c1 = Hex(0xbfbfbf, 6), $c2 = Hex(0xcfcfcf, 6), $c3 = Hex(0xcfcfcf, 6)
EndSelect
Local $pixel1[3] = [$x + 4, $y + 2 , $c1], $pixel2[3] = [$x + 7, $y + 3, $c2], $pixel3[3] = [$x + 6, $y + 5, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 7
Else
Local $pixel1[3] = [$x + 3, $y + 2 , $c1], $pixel2[3] = [$x + 6, $y + 3, $c2], $pixel3[3] = [$x + 5, $y + 5, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 7
EndIf
EndIf
;Digit is 8
$width = 9
Select
Case $type = "Gold"
Local $c1 = Hex(0xd0d0d0, 6), $c2 = Hex(0x6f6f6f, 6), $c3 = Hex(0x040404, 6)
EndSelect
Local $pixel1[3] = [$x + 5, $y + 4 , $c1], $pixel2[3] = [$x + 5, $y + 2, $c2], $pixel3[3] = [$x + 5, $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 8
Else
Local $pixel1[3] = [$x + 4, $y + 4 , $c1], $pixel2[3] = [$x + 4, $y + 2, $c2], $pixel3[3] = [$x + 4, $y + 7, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 8
EndIf
EndIf
;Digit is 9
$width = 9
Select
Case $type = "Gold"
Local $c1 = Hex(0xbfbfbf, 6), $c2 = Hex(0x4d4d4d, 6), $c3 = Hex(0x070707, 6)
EndSelect
Local $pixel1[3] = [$x + 5, $y + 6 , $c1], $pixel2[3] = [$x + 5, $y + 7, $c2], $pixel3[3] = [$x + 5, $y + 3, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 9
Else
Local $pixel1[3] = [$x + 4, $y + 6 , $c1], $pixel2[3] = [$x + 4, $y + 7, $c2], $pixel3[3] = [$x + 4, $y + 3, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 9
EndIf
EndIf
;Digit is 0
$width = 10
Select
Case $type = "Gold"
Local $c1 = Hex(0x050505, 6), $c2 = Hex(0x080808, 6), $c3 = Hex(0xbdbdbd, 6)
EndSelect
Local $pixel1[3] = [$x + 5, $y + 4 , $c1], $pixel2[3] = [$x + 6, $y + 6, $c2], $pixel3[3] = [$x + 4, $y + 6, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 0
Else
Local $pixel1[3] = [$x + 4, $y + 4 , $c1], $pixel2[3] = [$x + 5, $y + 6, $c2], $pixel3[3] = [$x + 3, $y + 6, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 0
EndIf
EndIf
Return ""
EndFunc ;==>getDigit
NB: the camp location need to be fixed. in this script its hard coded and need to be change to locate camp just like barracks,