The Bytecode Club
Log inJoin the club
Video Game Reverse Engineering

Developing Bot

Started by Antidote · Dec 5, 2014

1,033 replies21,297,466 viewsLocked
Dec 27, 2014#501

for imagesearch i always used 24-bit-bitmaps. try to make them not too big, something between 5x5 and 10x10 should be enough and play around with the accuracy.
but i said that before, buildings in coc all look a bit different on pixelsize. before this bot i wrote my own one with imagesearch and it was horrible. dont rely on imagesearch too much!
btw. i just looked into donating troops.
it's pretty easy 2 implement with pixelsearch.
this function is not finished cause im 2 lazy right now and my clan would be mad if i donate archers when they want dragons. dont know if its worth to work something out to read what they actually want to have donated :D

Func Donate()
GUICtrlSetData($Results, "Func Donate" & @CRLF, -1)
$Donate = PixelSearch(0,290,67,400,0xF80603,1,1,$HWnD) ;Looking for new Chat Messages
If IsArray($Donate) = True Then
ControlClick ($HWnD, "","", "left", "1", $Donate[0], $Donate[1]) ; Click Open Chat
sleep(2000)
$Request = PixelSearch(0,120,230,670,0xD0E971,1,1,$HWnD)
If IsArray($Donate) = True Then
ControlClick ($HWnD, "","", "left", "1", $Request[0], $Request[1]) ; Click on Request
sleep(2000)
EndIf
EndIf
EndFunc

Tell me if opening the chat (with new messages in it) and clicking donate-button once is working for you other guys cause of possible color-variations!

Dec 27, 2014#502

@Kojometa

At first, I only took 4x6 pixels for imagesearch since I thought it would filter out many pixel variations. But then I thought it would be better to get 10x9 pixels to include the initial frame of the elixir to prevent matching with the storages.. But I still excluded the snow in the img which I think I should have included. Then just now, an idea popped to my head.. If I can't get a hit at low tolerance, I could as well run another imagesearch with another batch of a bit different image. ex. Normal variants, a bit different variant, and Snow filled collectors.

Btw, have you tried imagesearch identifying collectors?

Dec 27, 2014#503

i have an image i already sent to antidote about 5 days ago wich is working pretty good for collecting ressources (the bubbles above collectors).
but i never looked at the collectors themselfes. i also think its not nessesary to look for dead fish i already mentioned why, a few posts before.
i dont know how about you, but i have full storages already with the current version 😉

Dec 27, 2014#504

i have an image i already sent to antidote about 5 days ago wich is working pretty good for collecting ressources (the bubbles above collectors).
but i never looked at the collectors themselfes. i also think its not nessesary to look for dead fish i already mentioned why, a few posts before.
i dont know how about you, but i have full storages already with the current version 😉

Setting at 100k, with barrack boost. Every 2 hr is like 2-3mil

Dec 27, 2014#505

What trophy range do you guys running?

Dec 27, 2014#506

What trophy range do you guys running?

Silver II - around 1140 trophies

Dec 27, 2014#507

If you downloaded lazypressing you should have a lazypressing folder.. mine was at c:lazypressing, they have BMP's in there that it uses in image search, no need to make our own if those work..

Dec 27, 2014#508

i have an image i already sent to antidote about 5 days ago wich is working pretty good for collecting ressources (the bubbles above collectors).
but i never looked at the collectors themselfes. i also think its not nessesary to look for dead fish i already mentioned why, a few posts before.
i dont know how about you, but i have full storages already with the current version 😉

What th and trophy are you in? I'm currently at th9, it's pretty hard to farm. With the current version, it's like bully mode without wall breakers, so it's doomed to fail. Loot penalty affects farming big time. Actually I once tried to run the program and I lost 300K. Settings were barchers 130k gold+elix. I even tried 1 barb, 1 giant, 2 archers without success. But sometimes I get lucky with zombies 😎

Dec 27, 2014#509

@Antidote,GKevinOD,Others

Here is my revised imagesearch code for zombie detection. I simplified it to 2x2 (4 search areas instead of 9). You may add it to func village search TWICE for double check.

 
#include <ImageSearch.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "Terminate")

HotKeySet("p", "checkForImage")

Func Terminate()
    Exit 0
 EndFunc

opt("mousecoordmode",0)

Global $Title = "BlueStacks App Player"
Global $HWnD = WinGetHandle (WinGetTitle($Title))

Global $ZC=0,$ZombieCount=0, $E
Global $SearchZombie=0, $ZombieCount=0
Global $Tolerance=90

Global $Lx[4]= [ 0, 400, 0, 400 ]
Global $Ly[4]= [ 0, 0, 265, 265 ]
Global $Rx[4]= [ 460, 860, 400, 860 ]
Global $Ry[4]= [ 325, 325, 590, 590 ]

Global $Area[5][4], $IS_x[8][4], $IS_y[8][4], $E[3][5]

$E[0][0] = @ScriptDir&"\ELIX1\E9F9.bmp"
$E[0][1] = @ScriptDir&"\ELIX1\E10F8.bmp"
$E[0][2] = @ScriptDir&"\ELIX1\E10F9.bmp"
$E[0][3] = @ScriptDir&"\ELIX1\E11F8.bmp"
$E[0][4] = @ScriptDir&"\ELIX1\E11F9.bmp"

$E[1][0] = @ScriptDir&"\ELIX2\E9F9.bmp"
$E[1][1] = @ScriptDir&"\ELIX2\E10F8.bmp"
$E[1][2] = @ScriptDir&"\ELIX2\E10F9.bmp"
$E[1][3] = @ScriptDir&"\ELIX2\E11F8.bmp"
$E[1][4] = @ScriptDir&"\ELIX2\E11F9.bmp"

$E[2][0] = @ScriptDir&"\ELIX3\E9F9.bmp"
$E[2][1] = @ScriptDir&"\ELIX3\E10F8.bmp"
$E[2][2] = @ScriptDir&"\ELIX3\E10F9.bmp"
$E[2][3] = @ScriptDir&"\ELIX3\E11F8.bmp"
$E[2][4] = @ScriptDir&"\ELIX3\E11F9.bmp"


ZombieSearch()

Func ZombieSearch()
   WinActivate ($HWnD)
   $SearchZombie=0
   $ZombieCount=0
   For $i=0 to 3 Step 1 ;Search per area
	  IS_Area($i)
	  $ZombieCount=$ZombieCount+$ZC
   Next

If $ZombieCount > 0 Then
   $SearchZombie=1
EndIf

MsgBox(0,"","$ZombieCount= "&$ZOmbieCount&", $SearchZombie= "&$SearchZombie&", $MatchCount= "&$MatchCount&@CRLF&"----------------FILE1 E9F9"&@CRLF&$Area[0][0]&","&$Area[0][1]&@CRLF&$Area[0][2]&","&$Area[0][3]&@CRLF&"----------------FILE2: E10F8"&@CRLF&$Area[1][0]&","&$Area[1][1]&@CRLF&$Area[1][2]&","&$Area[1][3]&@CRLF&"----------------FILE3:E10F9"&@CRLF&$Area[2][0]&","&$Area[2][1]&@CRLF&$Area[2][2]&","&$Area[2][3]&@CRLF&"----------------FILE4:E11F8"&@CRLF&$Area[3][0]&","&$Area[3][1]&@CRLF&$Area[3][2]&","&$Area[3][3]&@CRLF&"----------------FILE4:E11F9"&@CRLF&$Area[4][0]&","&$Area[4][1]&@CRLF&$Area[4][2]&","&$Area[4][3]&@CRLF)

EndFunc

Func IS_Area($i) 
   $ZC =0

For $s=0 to 2 Step 1
   For $p=0 to 4 Step 1
		 $Area[$p][$i]=_ImageSearchArea($E[$s][$p],0,$Lx[$i],$Ly[$i],$Rx[$i],$Ry[$i], $IS_x[$p][$i], $IS_y[$p][$i],$Tolerance)

		 If $Area[$p][$i]>0 Then
			   $ZC=1
		 EndIf

		 If $ZC=1 Then
			ExitLoop
		 EndIf
   Next

;   MsgBox(0,"","$Area ["&$i&"] $ZC: "&$ZC&" $march="&$match&" ElixSet["&$s&"] = "&$Area[0][$i]&","&$Area[1][$i]&","&$Area[2][$i]&","&$Area[3][$i]&","&$Area[4][$i])
   If $ZC=1 Then
	  ExitLoop
   EndIf

 Next
;   MsgBox(0,"",$E&" $Area ["&$p&"]["&$i&"] $ZC: "&$ZC&" = "&@CRLF&$Area[$p][0]&","&$Area[$p][1]&","&$Area[$p][2]&@CRLF&""&$Area[$p][3]&","&$Area[$p][4]&","&$Area[$p][5]&@CRLF&""&$Area[$p][6]&","&$Area[$p][7]&","&$Area[$p][8])

EndFunc
Dec 27, 2014#510

@Antidote,GKevinOD,Others

Here is my revised imagesearch code for zombie detection. I simplified it to 2x2 (4 search areas instead of 9). You may add it to func village search TWICE for double check.

@AtoZ, What is zombie since I'm not able to see your bmp file?

This discussion is closed.