Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding WBs
#1
So I'm trying to add WBs into the mix. I know this will be an option down the road, but I'm impatient, and wanted to try adding myself Wink

I'm trying to figure out logistically how this would work. From looking at the code, these cases click the troop selection until the color changes/dims, correct? Smile

Code:
Switch $barrackTroop[$i]
Case 0
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 329, $BSpos[1] + 297), 6), Hex(0xDC3F70, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(220, 320) ;Barbarian
WEnd
Case 1
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(331, 320) ;Archer
WEnd
Case 2
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(432, 320) ;Giant
WEnd
Case 3
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(546, 320) ;Goblins
WEnd
Case 4
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(648, 320) ;Wallbreakers
WEnd
EndSwitch

I've added Case 4 as wallbreakers with the correct coords, but I can't figure out where this comes into play.

Could I just modify the Click() in the Giant case & have it click each 4 times?

Any tips would be great!
Reply
#2
I managed to get it working; not quite as well as I wanted, but it will do for now.
Modified Build: Cross Bot 5.3.4 - 5.4.2.2
I simply modified Case 2 (Giants) to train 1 Giant or 1 WB at a time & set (in the front end) 1 barrack to train "Giants", the others Barbs & Archers. I end up with about 4-5 Giants & WBs, with 180 camp capacity (bigger camps would get 1-2 more). I added Sleep(65000) before Trainn() so it doesn't get backlogged & keep spitting out the same one. It takes about 15 min to fill my camps.
Added Giants to barrack options
Code:
$cmbBarrack1 = GUICtrlCreateCombo("", 275, 150, 110, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarians|Archers|Giants", "Barbarians") ; "Barbarians|Archers|Giants|Goblins"
$cmbBarrack2 = GUICtrlCreateCombo("", 275, 175, 110, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarians|Archers|Giants", "Barbarians") ; "Barbarians|Archers|Giants|Goblins"
$cmbBarrack3 = GUICtrlCreateCombo("", 275, 200, 110, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarians|Archers|Giants", "Archers") ; "Barbarians|Archers|Giants|Goblins"
$cmbBarrack4 = GUICtrlCreateCombo("", 275, 225, 110, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarians|Archers|Giants", "Archers") ; "Barbarians|Archers|Giants|Goblins"
Modified Training so Giant would also train WB
Code:
Switch $barrackTroop[$i]
Case 0
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 329, $BSpos[1] + 297), 6), Hex(0xDC3F70, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(220, 320) ;Barbarian
WEnd
Case 1
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(331, 320) ;Archer
WEnd
Case 2
;While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
;If $RunState = False Then ExitLoop (2)
If $Toggtroop = 1 Then
Click(650, 320, 1, 10) ;WBs
$Toggtroop = 0
Else
Click(432, 320, 1, 10) ;Giant
$Toggtroop = 1
EndIf
;Click(432, 320) ;Giant
;WEnd
Case 3
While _ColorCheckVariation(Hex(PixelGetColor($BSpos[0] + 217, $BSpos[1] + 297), 6), Hex(0xF8AD20, 6), 20)
If $RunState = False Then ExitLoop (2)
Click(546, 320) ;Goblins
WEnd
EndSwitch
Modified "Use All Troops" case
Code:
Func Attack() ;Selects which algorithm
While 1
SetLog("======Beginning Attack======")
Switch $icmbAlgorithm
Case 0 ;Barbarians + Archers
atkAlgorithmBarch()
Case 1 ;Use All Troops
;SetLog("Not Available yet, using Barch instead...")
If _Sleep(2000) Then ExitLoop
;atkAlgorithmBarch()
atkAlgorithmAllt()
EndSwitch
ExitLoop
WEnd
EndFunc   ;==>Attack
New function for Use All Troops (only updated 4 sides)
Code:
Func atkAlgorithmAllt() ;Attack Algorithm for Allt
While 1
Local $Giant = -1, $Wb = -1, $Barb = -1, $Arch = -1, $CC = -1
Global $King = -1, $Queen = -1
For $i = 0 To 6
If $atkTroops[$i][0] = "Giant" Then
$Giant = $i
ElseIf $atkTroops[$i][0] = "Wallbreaker" Then
$Wb = $i
ElseIf $atkTroops[$i][0] = "Barbarian" Then
$Barb = $i
ElseIf $atkTroops[$i][0] = "Archer" Then
$Arch = $i
ElseIf $atkTroops[$i][0] = "Clan Castle" Then
$CC = $i
ElseIf $atkTroops[$i][0] = "King" Then
$King = $i
ElseIf $atkTroops[$i][0] = "Queen" Then
$Queen = $i
EndIf
Next
If _Sleep(500) Then ExitLoop
Switch $deploySettings
Case 0 ;Two sides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetLog("~Attacking in two sides...")
If _Sleep(1000) Then ExitLoop
Local $numBarbPerSpot = Ceiling((($atkTroops[$Barb][1] / 2) / 5) / 2)
Local $numArchPerSpot = Ceiling((($atkTroops[$Arch][1] / 2) / 5) / 2)
SetLog("Dropping first wave of Barbarians")
For $i = 0 To 4 ;Drop first round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next
If _Sleep(1000) Then ExitLoop
SetLog("Dropping first wave of Archers")
For $i = 0 To 4 ;Drop first round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next
If _Sleep(2000) Then ExitLoop ;-------------------------------------------
SetLog("Dropping second wave of Barbarians")
For $i = 0 To 4 ;Drop second round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next
If _Sleep(1000) Then ExitLoop
SetLog("Dropping second wave of Archers")
For $i = 0 To 4 ;Drop second round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next
dropHeroes($TopLeft[3][0], $TopLeft[3][1], $King, $Queen)
If _Sleep(1000) Then ExitLoop
;If $CC <> -1 Then dropCC($TopLeft[3][0], $TopLeft[3][1], $CC)
Case 1 ;Three sides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetLog("~Attacking in three sides...")
If _Sleep(1000) Then ExitLoop
Local $numBarbPerSpot = Ceiling((($atkTroops[$Barb][1] / 3) / 5) / 2)
Local $numArchPerSpot = Ceiling((($atkTroops[$Arch][1] / 3) / 5) / 2)

SetLog("Dropping first wave of Barbarians")
For $i = 0 To 4 ;Drop first round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next

If _Sleep(1000) Then ExitLoop

SetLog("Dropping first wave of Archers")
For $i = 0 To 4 ;Drop first round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next

If _Sleep(2000) Then ExitLoop ;-------------------------------------------

SetLog("Dropping second wave of Barbarians")
For $i = 0 To 4 ;Drop second round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next

If _Sleep(1000) Then ExitLoop

SetLog("Dropping second wave of Archers")
For $i = 0 To 4 ;Drop second round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next

dropHeroes($TopRight[3][0], $TopRight[3][1], $King, $Queen)
If _Sleep(1000) Then ExitLoop
;If $CC <> -1 Then dropCC($TopRight[3][0], $TopRight[3][1], $CC)
Case 2 ;Four sides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetLog("~Attacking in all sides...")
If _Sleep(1000) Then ExitLoop
Local $numGiantPerSpot = Ceiling((($atkTroops[$Giant][1] / 4) / 5) / 2)
Local $numWbPerSpot = Ceiling((($atkTroops[$Wb][1] / 4) / 5) / 2)
Local $numBarbPerSpot = Ceiling((($atkTroops[$Barb][1] / 4) / 5) / 2)
Local $numArchPerSpot = Ceiling((($atkTroops[$Arch][1] / 4) / 5) / 2)

SetLog("Dropping first wave of Giants")
For $i = 0 To 4 ;Drop first round of Giants
Click(68 + (72 * $Giant), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numGiantPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numGiantPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numGiantPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numGiantPerSpot, 1)
Next

If _Sleep(4500) Then ExitLoop

SetLog("Dropping first wave of Wallbreakers")
For $i = 0 To 4 ;Drop first round of Wallbreakers
Click(68 + (72 * $Wb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numWbPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numWbPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numWbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numWbPerSpot, 1)
Next

If _Sleep(1000) Then ExitLoop

SetLog("Dropping first wave of Barbarians")
For $i = 0 To 4 ;Drop first round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numBarbPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next

If _Sleep(1000) Then ExitLoop

SetLog("Dropping first wave of Archers")
For $i = 0 To 4 ;Drop first round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numArchPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next

If _Sleep(2000) Then ExitLoop ;-------------------------------------------

SetLog("Dropping second wave of Barbarians")
For $i = 0 To 4 ;Drop second round of Barbarians
Click(68 + (72 * $Barb), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numBarbPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numBarbPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numBarbPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numBarbPerSpot, 1)
Next

If _Sleep(1000) Then ExitLoop

SetLog("Dropping second wave of Archers")
For $i = 0 To 4 ;Drop second round of Archers
Click(68 + (72 * $Arch), 595) ;Select Troop
If _Sleep(100) Then ExitLoop (2)
Click($TopLeft[$i][0], $TopLeft[$i][1], $numArchPerSpot, 1)
Click($TopRight[$i][0], $TopRight[$i][1], $numArchPerSpot, 1)
Click($BottomLeft[$i][0], $BottomLeft[$i][1], $numArchPerSpot, 1)
Click($BottomRight[$i][0], $BottomRight[$i][1], $numArchPerSpot, 1)
Next

dropHeroes($BottomLeft[3][0], $BottomLeft[3][1], $King, $Queen)
If _Sleep(1000) Then ExitLoop
;If $CC <> -1 Then dropCC($BottomLeft[3][0], $BottomLeft[3][1], $CC)
EndSwitch

If _Sleep(100) Then ExitLoop
SetLog("Dropping left over troops")
$atkTroops[$Barb][1] = Number(getNormal(40 + (72 * $Barb), 565))
$atkTroops[$Arch][1] = Number(getNormal(40 + (72 * $Arch), 565))

While $atkTroops[$Barb][1] <> 0
Click(68 + (72 * $Barb), 595)
Click($TopLeft[3][0], $TopLeft[3][1], $atkTroops[$Barb][1], 1)

$atkTroops[$Barb][1] = Number(getNormal(40 + (72 * $Barb), 565))
WEnd

If _Sleep(1000) Then ExitLoop

While $atkTroops[$Arch][1] <> 0
Click(68 + (72 * $Arch), 595)
Click($TopLeft[3][0], $TopLeft[3][1], $atkTroops[$Arch][1], 1)

$atkTroops[$Arch][1] = Number(getNormal(40 + (72 * $Arch), 565))
WEnd

If _Sleep(100) Then ExitLoop

;Activate KQ's power
If $checkKPower <> -1 Or $checkQPower <> -1 Then
SetLog("Waiting " & $delayActivateKQ / 1000 & " seconds before activating King/Queen")
_Sleep($delayActivateKQ)
If $checkKPower <> -1 Then
SetLog("Activate King's power")
Click(68 + (72 * $checkKPower), 595)
EndIf
If $checkQPower <> -1 Then
SetLog("Activate Queen's power")
Click(68 + (72 * $checkQPower), 595)
EndIf
EndIf

SetLog("~Finished Attacking, waiting to finish")
ExitLoop
WEnd
EndFunc   ;==>atkAlgorithmAllt

This is probably a sloppy way of doing it, but if anyone wants to try it out before it's officially an option, have at it Smile
Reply
#3
hi nice can you give me more info where should i paste that code i mean what line? i want to try to coc bot v5.4.2.2 not cross version thanks Smile and should i need to copy all that code into cocbot v5.4.2.2 or the last code you post it thanks
Reply
#4
Reply
#5
Try adding this near the top below Global $Tolerance
Code:
Global $Toggtroop = 0
Reply
#6
Reply
#7
Hey there Barracoda,

I would like to do the same thing as you did adding your code to the cross version.
But I don't seem to understand where to put the code.
I searched for the lines in your code but don't find some of them to paste it in the correct place.

Would you mind to mind telling me where to put in the snippets?
Thanks in advance
Reply
#8
Just search for function name, or first line of snippet. The only part you won't find is the last block of code: atkAlgorithmAllt() - just add that block after the end of the barch one.
Reply
#9
Thanks Barracoda,

I managed to implement your functions.
I even added the Global $Toggtroop = 0 as mentioned in post #5.
But I also get the error on line 18615. I do not get where this is coming from.
Any ideas?
Reply
#10
I don't know what variable is on line 18,615 since there are less than 3,000 in the actual au3 file.
Double check that you copied everything & there are no typos :D Also are you modifying the cross bot or a diff version?
Reply
 


Forum Jump:


Users browsing this thread: 1 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