Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
struggling with camp total capacity
#1
Hi,
i want to use rewrite the getGold.au3 to read the camp capacity. so the bot knows how much troops it has build. this way you can better train troops and start faster to attack, and train the next wave of troops, so troops train while u attack.
for some reason im missing something with the pixels or the coords of the pixels.
ive added the screenshot of the _captureregion that im taking. I presume that the first pixel in the left corner is x=1 and y=1 ? is that correct?
im traying to locate that first digit, the 1
Ive created a new fullCamp.au3 file (which is the same as getGold.au3)
and
ive added my test scripts.
wiztest.au3 is the file you need to run. it opens the bot gui
then in bluestacks open a camp (preferable with 1xx troops)
then press the "u"
in the log screen of the bot you'll see that its not finding the pixel with color 0x606060
Yes, i know im searching 3 times for the same pixelcolor (im using $c1 in all the 3 pixels)
Local $pixel1[3] = [$x + 2, $y + 2, $c1], $pixel2[3] = [$x + 2, $y + 2, $c1], $pixel3[3] = [$x + 2, $y + 2, $c1]
ive adjusted _captureregion with the following lines so i could see the "bitmap" its looking at.
Code:
_ScreenCapture_SaveImage("C:\COC-Bot-master\images\GdiPlus_Screen.bmp", $hHBitmap)
_GDIPlus_ImageSaveToFile($hBitmap,"C:\COC-Bot-master\images\hBitmap.bmp")
that gives me this picture
http://minus.com/i/NZrJncWvP0I6

I appreciate any help on how to do a decent digit search
functions\read text\getCamp.au3
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
;cause our picture is not the complete bs window, reset x and y
$x = 0
$y = 0
;Search for digit 1
$width = 4
Select
Case $type = "Gold"
Local $c1 = Hex(0x606060, 6), $c2 = Hex(0x1c5600, 10), $c3 = Hex(0xd7d7d7, 6)
Case $type = "Elixir"
Local $c1 = Hex(0x968895, 6), $c2 = Hex(0x312D31, 6), $c3 = Hex(0xD8C4D6, 6)
Case $type = "DarkElixir"
Local $c1 = Hex(0x8F8F8F, 6), $c2 = Hex(0x2F2F2F, 6), $c3 = Hex(0xCDCDCD, 6)
Case Else
Local $c1 = Hex(0x969696, 6), $c2 = Hex(0x313131, 6), $c3 = Hex(0xD8D8D8, 6)
EndSelect
Local $pixel1[3] = [$x + 2, $y + 2, $c1], $pixel2[3] = [$x + 2, $y + 2, $c1], $pixel3[3] = [$x + 2, $y + 2, $c1]
;= [$x +1 , $y + 8, $c2], $pixel3[3] = [$x + 4, $y + 9, $c3]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
setlog("Jaaaaaaaaa het is 1")
Return 1
Else
$x += 1
setlog("neee 1e else" & $x)
Local $pixel1[3] = [$x + 2, $y + 2, $c1],$pixel2[3] = [$x + 2, $y + 2, $c1], $pixel3[3] = [$x + 2, $y + 2, $c1]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 1
Else
$x += 2
setlog("neee 2e else" & $x)
Local $pixel1[3] = [$x + 2, $y + 2, $c1], $pixel2[3] = [$x + 2, $y + 2, $c1], $pixel3[3] = [$x + 2, $y + 2, $c1]
If boolPixelSearch($pixel1, $pixel2, $pixel3) Then
$x += $width
Return 1
Else
$x -= 1
EndIf
EndIf
EndIf
Return ""
EndFunc ;==>getDigit
functions\read text\fullCamp.au3
Code:
Func fullCamp($x_start, $y_start)
_CaptureRegion($x_start, $y_start, $x_start + 20, $y_start + 12)
;-----------------------------------------------------------------------------
Local $x = 1, $y = 0
Local $Gold, $i = 0
While getCamp($x, $y + $i, "Gold") = ""
If $i >= 15 Then ExitLoop
$i += 1
WEnd
$x = $x_start
$Gold &= getCamp($x, $y + $i, "Gold")
$Gold &= getCamp($x, $y + $i, "Gold")
$Gold &= getCamp($x, $y + $i, "Gold")
$x += 6
$Gold &= getCamp($x, $y + $i, "Gold")
$Gold &= getCamp($x, $y + $i, "Gold")
$Gold &= getCamp($x, $y + $i, "Gold")
Return $Gold
EndFunc
and in root the wiztest.au3
Code:
#RequireAdmin
#AutoIt3Wrapper_UseX64=n
$sBotVersion = "5.5"
$sBotTitle = "COC Bot v" & $sBotVersion
#include "COCBot\Global Variables.au3"
#include "COCBot\GUI Design.au3"
#include "COCBot\GUI Control.au3"
#include "COCBot\Functions.au3"
#include "COCBot\functions\Read Text\fullCamp.au3"
#include "COCBot\functions\Read Text\getCamp.au3"
#include-once
global $hBitmap
HotKeySet("p", "checkDeadBases")
HotKeySet("o", "pixelColor")
HotkeySet("i", "getLoot")
HotkeySet("u", "getdigits")
func getdigits()
$ichkBackground = 1
setLog("lets get camp")
local $result = fullCamp(589, 193)
setLog("getCamp is " & $result)
EndFunc
while 1
sleep(200)
WEnd
Reply
 


Messages In This Thread
struggling with camp total capacity - by Henk500 - 02-10-2015, 08:32 AM
RE: struggling with camp total capacity - by AtoZ - 02-19-2015, 12:47 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)

About The Bytecode Club

We're a community focused on Reverse Engineering, we try to target Java/Android but we also include other langauges/platforms. We pride ourselves in supporting and free and open sourced applications.

Website