Jump to content
Sign in to follow this  
ChacalGyn

Drop Trophies in BuildersBase

Recommended Posts

Drop Trophies in BuildersBase

MyBot.run.au3

Func _RunFunction($action)

...

 				BuilderBaseReport()
+				; --------------------------------------------
+				; Builder Base Drop Trophies
+				; --------------------------------------------
+				BB_DropTrophies()
 				StartClockTowerBoost()
 				MainSuggestedUpgradeCode()
 				; switch back to normal village
 				SwitchBetweenBases()

 

COCBot/GUI/MBR GUI Design Child Village - Misc.au3

+; --------------------------------------------
+; Builder Base Drop Trophies
+; --------------------------------------------
+Global $g_hChkBB_DropTrophies = 0
+Global $g_hChkBB_OnlyWithLoot = 0
+Global $g_hTxtBB_DropTrophies = 0

...

+		; --------------------------------------------
+		; Builder Base Drop Trophies
+		; --------------------------------------------
+		$g_hChkBB_DropTrophies = GUICtrlCreateCheckbox(GetTranslatedFileIni("MBR GUI Design Child Village - Misc", "ChkBB_DropTrophies", "Drop Trophies and limit it to:"), $x + 100, $y + 46, -1, -1)
+			GUICtrlSetOnEvent(-1, "ChkBB_DropTrophies")
+		$g_hTxtBB_DropTrophies = GUICtrlCreateInput("0", $x + 260, $y + 48, 32, 18, BitOR($SS_RIGHT, $ES_NUMBER))
+			GUICtrlSetOnEvent(-1, "TxtBB_DropTrophies")
+			GUICtrlSetLimit(-1, 6000)
+		$g_hChkBB_OnlyWithLoot = GUICtrlCreateCheckbox(GetTranslatedFileIni("MBR GUI Design Child Village - Misc", "ChkBB_OnlyWithLoot", "Attack Only if Loot available"), $x + 100, $y + 68, -1, -1)
+			GUICtrlSetOnEvent(-1, "ChkBB_OnlyWithLoot")

 

/COCBot/MBR Global Variables.au3

; --------------------------------------------
; Builder Base Drop Trophies
; --------------------------------------------
Global $g_bChkBB_DropTrophies = False
Global $g_bChkBB_OnlyWithLoot = False
Global $g_iTxtBB_DropTrophies = 0

 

/COCBot/functions/Config/applyConfig.au3

+			; --------------------------------------------
+			; BB_DropTrophies
+			; --------------------------------------------
+			GUICtrlSetState($g_hChkBB_DropTrophies, $g_bChkBB_DropTrophies = 1 ? $GUI_CHECKED : $GUI_UNCHECKED)
+			GUICtrlSetData($g_hTxtBB_DropTrophies, $g_iTxtBB_DropTrophies)
*			GUICtrlSetState($g_hChkBB_OnlyWithLoot, $g_bChkBB_OnlyWithLoot = 1 ? $GUI_CHECKED : $GUI_UNCHECKED)

...

+			; --------------------------------------------
+			; BB_DropTrophies
+			; --------------------------------------------
+			ChkBB_DropTrophies()
+			TxtBB_DropTrophies()
+			ChkBB_OnlyWithLoot()

...

+			; --------------------------------------------
+			; BB_DropTrophies
+			; --------------------------------------------
+			$g_bChkBB_DropTrophies = (GUICtrlRead($g_hChkBB_DropTrophies) = $GUI_CHECKED) ? 1 : 0
+			$g_iTxtBB_DropTrophies = GUICtrlRead($g_hTxtBB_DropTrophies)
+			$g_bChkBB_OnlyWithLoot = (GUICtrlRead($g_hChkBB_OnlyWithLoot) = $GUI_CHECKED) ? 1 : 0

 

/COCBot/functions/Config/readConfig.au3

+	; --------------------------------------------
+	; BB_DropTrophies
+	; --------------------------------------------
+	IniReadS($g_bChkBB_DropTrophies, $g_sProfileConfigPath, "other", "ChkBB_DropTrophies", $g_bChkBB_DropTrophies, "Int")
+	IniReadS($g_iTxtBB_DropTrophies, $g_sProfileConfigPath, "other", "TxtBB_DropTrophies", $g_iTxtBB_DropTrophies, "Int")
+	IniReadS($g_bChkBB_OnlyWithLoot, $g_sProfileConfigPath, "other", "ChkBB_OnlyWithLoot", $g_bChkBB_OnlyWithLoot, "Int")

 

/COCBot/functions/Config/saveConfig.au3

+	; --------------------------------------------
+	; BB_DropTrophies
+	; --------------------------------------------
+	_Ini_Add("other", "ChkBB_DropTrophies", $g_bChkBB_DropTrophies)
+	_Ini_Add("other", "TxtBB_DropTrophies", $g_iTxtBB_DropTrophies)
+	_Ini_Add("other", "ChkBB_OnlyWithLoot", $g_bChkBB_OnlyWithLoot)

 

Live Content:

 

https://raw.githubusercontent.com/ChackBR/MyBot_v7/master/COCBot/MOD/functions/BB_DropTrophies.au3

 

https://raw.githubusercontent.com/ChackBR/MyBot_v7/master/COCBot/MOD/functions/BB_PrepareAttack.au3

 

 

TO DO:

1 - On prepare attack: Set ZoomOut on Map

2 - On BB attack: Make Custom/Smart Attack

3 - ...

 

 

Anyone who want's can update this code and submit changes to make it better

 

Regards :)

Edited by ChacalGyn
Update 7.6.2.r02
  • Like 5
  • Upvote 6

Share this post


Link to post
Share on other sites

            If isOnBuilderBase() Or (($g_bChkCollectBuilderBase Or $g_bChkStartClockTowerBoost Or $g_iChkBBSuggestedUpgrades Or $g_bChkBB_DropTrophies) And SwitchBetweenBases()) Then
 

Share this post


Link to post
Share on other sites
12 horas atrás, Argentino disse:

            If isOnBuilderBase() Or (($g_bChkCollectBuilderBase Or $g_bChkStartClockTowerBoost Or $g_iChkBBSuggestedUpgrades Or $g_bChkBB_DropTrophies) And SwitchBetweenBases()) Then
 

 

Already done when called:

BuilderBaseReport()
Edited by ChacalGyn
  • Like 1

Share this post


Link to post
Share on other sites
			If isOnBuilderBase() Or (($g_bChkCollectBuilderBase Or $g_bChkStartClockTowerBoost Or $g_iChkBBSuggestedUpgrades Or $g_bChkBB_DropTrophies) And SwitchBetweenBases()) Then
					CollectBuilderBase()
					BuilderBaseReport()
					StartClockTowerBoost()
					MainSuggestedUpgradeCode()
					If $g_bChkBB_DropTrophies Then
					BuilderBaseReport()
					BB_DropTrophies() ;------------------ADDED By RK MOD - by Chacal GYN - Drop Trophies (ID70) ------------------
					EndIf
				SwitchBetweenBases() ; Switch back to normal village, If not DT			
			EndIf

 

Edited by Argentino
  • Like 1

Share this post


Link to post
Share on other sites

In laymen's terms, can this also be used as a BB farm? Like if we have camps full of baby drags, can it dump them all around the map and just hop for  the best? Or does this end attack once a troop is dropped.

Share this post


Link to post
Share on other sites
4 horas atrás, turbomalum disse:

In laymen's terms, can this also be used as a BB farm? Like if we have camps full of baby drags, can it dump them all around the map and just hop for  the best? Or does this end attack once a troop is dropped.

 

Yep !

 

In the future it will use a better Troop Deploy and for sure: Will Win some Battles :)

 

Regards

Edited by ChacalGyn

Share this post


Link to post
Share on other sites
On 31/8/2018 at 17:42, ChacalGyn dijo:

 

¡Sorbo!

 

En el futuro utilizará una mejor Troop Deploy y seguro: Ganará algunas batallas :)

 

Saludos

Mira

https://mega.nz/#!D4diHSQa!hBmgkVu0VEz4CPXJzqoxj46JyM-P_iVjQTuhsrVnXrc

Pruébalo

I let you use everything that mod has, I participate in the modification.

more color tolerance for slots and it work fine

Edited by Argentino

Share this post


Link to post
Share on other sites
; #FUNCTION# ====================================================================================================================
; Name ..........: BB_DropTrophies
; Description ...: 
; Author ........: Chackall++
; Modified ......:
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2016
;                  MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================

Func BB_DropTrophies()
    Local $iBoy = 0
    Local $i = 0
    Local $j = 0

    Local $cPixColor  = ''
    Local $Nside      = 1
    Local $SIDESNAMES = "TR|TL"

    Local $bDegug     = False
    Local $bContinue  = True

    Local $OkButtom[4]     = [ 400, 495 + $g_iBottomOffsetY, 0xE2F98B, 20 ]
    Local $OkBatleEnd[4]   = [ 630, 400 + $g_iBottomOffsetY, 0xE2FA8C, 20 ]
    Local $OkWaitBattle[4] = [ 400, 500 + $g_iBottomOffsetY, 0xF0F0F0, 20 ]
    Local $TroopSlot[4]    = [  40, 638 + $g_iBottomOffsetY, 0x404040, 20 ]
    Local $NextSlotActive[6] = [0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8]
    Local $NextSlotOff[6]  = [0x464646, 0x454545, 0x454545, 0x464646, 0x454545, 0x5198E0]
    Local $NextSlotAdd     = 72
    Local $TroopsToDrop    = 0
    Local $iKing = 0x251CC6
    If _Sleep($DELAYRESPOND) Then Return
    If $g_iTxtBB_DropTrophies > 0 Then $g_aiCurrentLootBB[$eLootTrophyBB] = getTrophyMainScreen(67, 84)
    If _Sleep($DELAYRESPOND) Then Return

    If $g_bChkBB_DropTrophies Then
        ; Click attack button and find a match
        If $g_iTxtBB_DropTrophies > 0 Then
            $i = $g_aiCurrentLootBB[$eLootTrophyBB] - $g_iTxtBB_DropTrophies
        Endif
        If $i > 0 Then 

            If _Sleep($DELAYCHECKOBSTACLES1) Then Return

            If BB_PrepareAttack() Then

                If _Sleep($DELAYCHECKOBSTACLES3 * 2) Then Return

                ; Deploy All Troops From Slot's
                Setlog(" ====== BB Attack ====== ", $COLOR_INFO)
                For $i = 0 to 5
                    If ($i > 0) Then 
                        $TroopSlot[0] += $NextSlotAdd
                        $TroopSlot[2] = $NextSlotOff[$i]
                    EndIf
                    $j = 0
                    $cPixColor = _GetPixelColor($TroopSlot[0], $TroopSlot[1], True)
                    
                    $TroopsToDrop = getTroopCountBig( $TroopSlot[0]+24, $TroopSlot[1]-7 )
                    If ($i > 0) Then 
                        If _Sleep(120) Then Return 
                        If Not _ColorCheck( $cPixColor, Hex($NextSlotOff[$i], 20), $TroopSlot[3]) Then
                            ClickP($TroopSlot, 1, 0, "#0000")
                            Local $x = $TroopSlot[0]
                            Local $y = $TroopSlot[1]
                            $bContinue = False
                            For $b = 0 to 5
                            $x += $NextSlotAdd
                                If _ColorCheck(_GetPixelColor($x, $y), Hex($NextSlotActive[$b], 20), 20) Then 
                                $bContinue = True
                                EndIf
                            Next
                        EndIf                    
                    EndIf
                    If $bContinue Then
                        While Not _ColorCheck( $cPixColor, Hex($TroopSlot[2], 20), $TroopSlot[3])
                            If $iBoy = 0 Then
                            If _Sleep($DELAYRESPOND*3) Then Return
                        If QuickMIS("BC1", $g_sImgMachine, 0, 652, 835, 724, True, False) Then
                                KeepClicks()
                                Local $aBoyDropPoint[2] = [0, 0]
                                        $aBoyDropPoint[0] = $g_iQuickMISX
                                        $aBoyDropPoint[1] = (652 + $g_iQuickMISY)
                                    Setlog("Drop boy on map", $COLOR_GREEN)
                                    ClickP($aBoyDropPoint, 1, 0, "#0000") ; Drop Troop
                                    If _Sleep($DELAYDROPTROOP1 / 5) Then Return
                                    AttackClick(557, 251, 1, SetSleep(0), 0, "#0000")
                                    If _Sleep($DELAYDROPTROOP2 / 5) Then Return
                                $iBoy = 1
                                EndIf
                                    ReleaseClicks()

                            EndIf
                            BB_Attack($Nside, $SIDESNAMES, 8)
                            
                            If $bDegug Then SetLog("BB: Drop Troops - Slot[ " & String( $i + 1 ) & " ], code: 0x" & $cPixColor & " [ " & String( $j ) & " ] Num:[ " & $TroopsToDrop & " ]", $COLOR_DEBUG)
                            If _Sleep(12) Then Return 
                            $j += 1
                            If $j > 5 Then ExitLoop
                            $cPixColor = _GetPixelColor($TroopSlot[0], $TroopSlot[1], True)
                        WEnd
                        If $bDegug Then SetLog("BB: Last Slot Color [ " & String( $i + 1 ) & " ], code: 0x" & $cPixColor & " [ " & String( $i + 1 ) & " ]", $COLOR_DEBUG)
                    EndIf
                Next
                    
                Setlog("Will Wait End Battle for " & String( $DELAYCHECKOBSTACLES4 / 60000 / 2 ) & " minutes then continue", $COLOR_INFO)
                If _Sleep($DELAYCHECKOBSTACLES4 / 2 ) Then Return

                ; If $OkWaitBattle Exists
                $cPixColor = _GetPixelColor($OkWaitBattle[0], $OkWaitBattle[1], True)
                If _ColorCheck( $cPixColor, Hex($OkWaitBattle[2], 20), $OkWaitBattle[3]) Then
                    If $bDegug Then SetLog("BB: Click Okay Buttom for no wait battle end, code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
                    ClickP($OkWaitBattle, 1, 0, "#0000")
                EndIf

                If _Sleep(12) Then Return 

                ; wait $OkButtom to appear
                $j = 0
                $cPixColor = _GetPixelColor($OkButtom[0], $OkButtom[1], True)
                While Not _ColorCheck( $cPixColor, Hex($OkButtom[2], 20), $OkButtom[3])
                    If $bDegug Then SetLog("BB: Click Okay Buttom. [Ok]. code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
                    If _Sleep(12) Then Return 
                    $j += 1
                    If $j > 10 Then ExitLoop
                    $cPixColor = _GetPixelColor($OkButtom[0], $OkButtom[1], True)
                WEnd
                If $j < 10 Then
                    SetLog("BB: Click Okay Buttom. [Ok]. code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
                    ClickP($OkButtom, 1, 0, "#0000")
                Else
                    SetLog("BB: Can't Find Okay Buttom [Ok]. code: 0x" & $cPixColor, $COLOR_ERROR)
                EndIf

                If _Sleep(12) Then Return 

                ; wait $OkBatleEnd to appear
                If $j < 10 Then
                    $j = 0
                    $cPixColor = _GetPixelColor($OkBatleEnd[0], $OkBatleEnd[1], True)
                    While Not _ColorCheck( $cPixColor, Hex($OkBatleEnd[2], 20), $OkBatleEnd[3])
                        If $bDegug Then SetLog("BB: Try Click Okay Buttom [end], code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
                        If _Sleep($DELAYCHECKOBSTACLES3) Then Return
                        $j += 1
                        If $j > 30 Then ExitLoop
                        $cPixColor = _GetPixelColor($OkBatleEnd[0], $OkBatleEnd[1], True)
                    WEnd
                    If $j < 30 Then
                        SetLog("BB: Click Okay Buttom [end], code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
                        ClickP($OkBatleEnd, 1, 0, "#0000")
                    Else
                        SetLog("BB: Can't Find Okay Buttom [End]. code: 0x" & $cPixColor, $COLOR_ERROR)
                    EndIf
                Else

                    If _Sleep(12) Then Return
                    ClickP($aAway, 1, 0, "#0000")

                EndIf

            EndIf

            If _Sleep(12) Then Return
            ClickP($aAway, 1, 0, "#0000")

        Else
            Setlog("Ignore BB Drop Trophies: [Not Needed] [ " & String( $g_iTxtBB_DropTrophies ) & " ]", $COLOR_INFO)
        EndIf
    Else
        Setlog("Ignore BB Drop Trophies [ Disabled ]", $COLOR_INFO)
    Endif

EndFunc    ;==> BB_DropTrophies

Func ChkBB_DropTrophies()
    $g_bChkBB_DropTrophies = (GUICtrlRead($g_hChkBB_DropTrophies) = $GUI_CHECKED) ? 1 : 0
EndFunc   ;==>ChkBB_DropTrophies

Func TxtBB_DropTrophies()
    $g_iTxtBB_DropTrophies = GUICtrlRead($g_hTxtBB_DropTrophies)
EndFunc   ;==>TxtBB_DropTrophies
; #FUNCTION# ====================================================================================================================
; Name ..........: BB_PrepareAttack
; Description ...: 
; Syntax ........: BB_PrepareAttack()
; Author ........: Chackall++
; Modified ......:
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2016
;                  MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================

Func BB_PrepareAttack() ; Click attack button and find a match

	Local $Result = getAttackDisable(346, 182) ; Grab Ocr for TakeABreak check
	Local $cPixColor = ""
	Local $i = 0
	Local $j = 0
	Local $bCanAttack = False
	Local $TroopsOk[4] = [ 310, 355 + $g_iBottomOffsetY, 0xDAF482 , 10 ]
	Local $ReturnFromAttack[4] = [697, 474 + $g_iBottomOffsetY, 0xC3EA6B ,20]
	Local $bDegug = False

	SetLog("BH: Going to Attack... [ " & String( $g_iTxtBB_DropTrophies ) & " ]", $COLOR_INFO)

	If IsMainPageBuilderBase() Then
		If $g_bUseRandomClick = False Then
			ClickP($aAttackButton, 1, 0, "#0149") ; Click Attack Button
		Else
			ClickR($aAttackButtonRND, $aAttackButton[0], $aAttackButton[1], 1, 0)
		EndIf
	EndIf
	If _Sleep($DELAYPREPARESEARCH1) Then Return

	; If $TroopsOk is ready
	$cPixColor = _GetPixelColor($TroopsOk[0], $TroopsOk[1], True)
	If _ColorCheck( $cPixColor, Hex($TroopsOk[2], 6), $TroopsOk[3]) Then
		SetLog("BB: Troops Not Ready [Stop Attack], code: " & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
	Else
		SetLog("BB: Troops Ready, code: " & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
		$bCanAttack = True
	EndIf

	If _Sleep($DELAYCHECKFULLARMY1) Then Return 

	If $bCanAttack Then 

		; If $aBB_FindMatchButton appear
		$cPixColor = _GetPixelColor($aBB_FindMatchButton[0], $aBB_FindMatchButton[1], True)
		If _ColorCheck( $cPixColor, Hex($aBB_FindMatchButton[2], 6), $aBB_FindMatchButton[3]) Then
			If $bDegug Then SetLog("BB: aBB_FindMatchButton, code: [ " & $cPixColor & " ][ " & String( $j ) & " ]", $COLOR_DEBUG)
			If _Sleep($DELAYCHECKFULLARMY1) Then Return 
			If $g_bUseRandomClick = False Then
				ClickP($aBB_FindMatchButton, 1, 0, "#0000") ;Click Find a Match Button
			Else
				ClickR($aBB_FindMatchButtonRND, $aFindMatchButton[0], $aFindMatchButton[1], 1, 0)
			EndIf
		Else
			If _CheckPixel($ReturnFromAttack, $g_bCapturePixel) Then ; Click on Green Join Button on Donate Window
			SetLog("Click okay button.", $COLOR_INFO)
			ClickP($ReturnFromAttack)
			Else
			SetLog("BB: Can't Find Match Buttom. Color Was: 0x" & $cPixColor, $COLOR_ERROR)
			$bCanAttack = False
			EndIf
		EndIf

		If _Sleep($DELAYPREPARESEARCH2) Then Return

		checkAttackDisable($g_iTaBChkAttack, $Result) ;See If TakeABreak msg on screen

		If $g_bDebugSetlog Then SetDebugLog("BB: PrepareAttack exit check $g_bRestart= " & $g_bRestart, $COLOR_DEBUG)

		If $g_bRestart Then ; If we errors, then return
			$g_bIsClientSyncError = False ; reset fast restart flag to stop OOS mode, and rearm, collecting resources etc.
			Return
		EndIf

	Endif

	Return $bCanAttack

EndFunc   ;==>BB_PrepareSearch

; #FUNCTION# ====================================================================================================================
; Name ..........: BB_Attack
; Description ...: 
; Syntax ........: 
; Parameters ....: 
; Return values .: 
; Author ........: 
; Modified ......: 
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2016
;                  MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================

Func BB_Attack($Nside = 1, $SIDESNAMES = "TR|TL", $iTroopToDeploy = 4 )

	Local $aBB_DiamondTop[4]    = [440,  30 + $g_iBottomOffsetY, 0x294949, 10]
	Local $aBB_DiamondBottom[4] = [440, 730 + $g_iBottomOffsetY, 0x2B4847, 10]
	Local $aBB_DiamondLeft[4]   = [ 30, 330 + $g_iBottomOffsetY, 0x213E3E, 10]
	Local $aBB_DiamondRight[4]  = [830, 330 + $g_iBottomOffsetY, 0x2F5351, 10]
	Local $aBB_LineCenter[2]    = [  0,   0]
	Local $i                    = 0
	Local $iHalf                = 0
	Local $iRest                = 0
	Local $aDropCoord[2]        = [  0,   0]
	Local $aDropPointX[4]       = [  0,   0, 0x294949, 10]
	Local $aDropPointY[4]       = [  0,   0, 0x294949, 10]
	Local $iBB_MaxDrop          = 20

	If $iTroopToDeploy < 4 Then $iTroopToDeploy = 4
	If $iTroopToDeploy > 8 Then $iTroopToDeploy = 8

	$iHalf = INT( $iTroopToDeploy / 2 )
	$iRest = $iTroopToDeploy - ( $iHalf * 2 )
	$iHalf += $iRest

	SetLog("BB: Attacking on a single side", $COLOR_INFO)

	$aBB_LineCenter[0] = INT( ( $aBB_DiamondTop[0] + $aBB_DiamondRight[0] ) / 2 )
	$aBB_LineCenter[1] = INT( ( $aBB_DiamondTop[1] + $aBB_DiamondRight[1] ) / 2 )
	$aDropCoord[0]     = INT( ( ( $aBB_LineCenter[0] - $aBB_DiamondTop[0] ) * 0.9 ) / $iHalf )
	$aDropCoord[1]     = INT( ( ( $aBB_LineCenter[1] - $aBB_DiamondTop[1] ) * 0.9 ) / $iHalf )

	KeepClicks()

	For $i = $iHalf To 1 Step -1
		$aDropPointX[0] = $aBB_LineCenter[0] + ( $i * $aDropCoord[0] )
		$aDropPointX[1] = $aBB_LineCenter[1] + ( $i * $aDropCoord[1] )
		$aDropPointY[0] = $aBB_LineCenter[0] - ( $i * $aDropCoord[0] )
		$aDropPointY[1] = $aBB_LineCenter[1] - ( $i * $aDropCoord[1] )
		ClickP($aDropPointX, 1, 0, "#0000") ; Drop Troop
		If _Sleep($DELAYDROPTROOP1 / 5) Then Return
		AttackClick($aDropPointY[0], $aDropPointY[1], 1, SetSleep(0), 0, "#0000")
		If _Sleep($DELAYDROPTROOP2 / 5) Then Return
	Next

	ReleaseClicks()

	If _Sleep($DELAYDROPTROOP2) Then Return

EndFunc   ;==>BB_Attack

 

Share this post


Link to post
Share on other sites
hace 6 horas, ChacalGyn dijo:

 

Gracias por la ayuda

 

Como puedo ver, es el mismo contenido (ya se actualizó en git)

 

Saludos

 

* BuilderMachine no funciona en mis pruebas

no, it does not work, only if you are in a village with 6 slots.

Deploy king +6 slots and and click for the pixel of his ability.

 

 

Updated fix

search okay button and exit

; #FUNCTION# ====================================================================================================================
; Name ..........: BB_DropTrophies
; Description ...: 
; Author ........: Chackall++
; Modified ......:
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2016
;                  MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================
Global $g_iLoopCount = 0

Func BB_DropTrophies()
	Local $iCheck = 0
	Local $iClickMachineX = 0
	Local $iClickMachineY = 0
	Local $i = 0
	Local $j = 0
	$g_iLoopCount = 0

	Local $cPixColor  = ''
	Local $Nside      = 1
	Local $SIDESNAMES = "TR|TL"

	Local $bDegug     = False
	Local $bContinue  = True

	Local $OkButtom[4]     = [ 400, 495 + $g_iBottomOffsetY, 0xE2F98B, 20 ]
	Local $OkBatleEnd[4]   = [ 630, 400 + $g_iBottomOffsetY, 0xE2FA8C, 20 ]
	Local $TroopSlot[4]    = [  40, 638 + $g_iBottomOffsetY, 0x404040, 20 ]
	Local $NextSlotActive[7] = [0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8, 0x5094D8]
	Local $NextSlotOff[7]  = [0x464646, 0x454545, 0x454545, 0x464646, 0x454545, 0x5198E0, 0x5198E0]
	Local $NextSlotAdd     = 72
	Local $TroopsToDrop    = 0

	If _Sleep($DELAYRESPOND) Then Return
	If $g_iTxtBB_DropTrophies > 0 Then $g_aiCurrentLootBB[$eLootTrophyBB] = getTrophyMainScreen(67, 84)
	If _Sleep($DELAYRESPOND) Then Return

	If $g_bChkBB_DropTrophies Then
		; Click attack button and find a match
		If $g_iTxtBB_DropTrophies > 0 Then
			$i = $g_aiCurrentLootBB[$eLootTrophyBB] - $g_iTxtBB_DropTrophies
		Endif
		If $i > 0 Then 

			If _Sleep($DELAYCHECKOBSTACLES1) Then Return

			If BB_PrepareAttack() Then

				If _Sleep($DELAYCHECKOBSTACLES3 * 2) Then Return

				; Deploy All Troops From Slot's
				Setlog(" ====== BB Attack ====== ", $COLOR_INFO)
				For $i = 0 to 6
					If ($i > 0) Then 
						$TroopSlot[0] += $NextSlotAdd
						$TroopSlot[2] = $NextSlotOff[$i]
					EndIf
					$j = 0
					$cPixColor = _GetPixelColor($TroopSlot[0], $TroopSlot[1], True)
					
					$TroopsToDrop = getTroopCountBig( $TroopSlot[0]+24, $TroopSlot[1]-7 )
					If ($i > 0) Then 
						If _Sleep(120) Then Return 
						If Not _ColorCheck( $cPixColor, Hex($NextSlotOff[$i], 20), $TroopSlot[3]) Then
							ClickP($TroopSlot, 1, 0, "#0000")
							Local $x = $TroopSlot[0]
							Local $y = $TroopSlot[1]
							$bContinue = False
							For $b = 0 to 6
							$x += $NextSlotAdd
								If _ColorCheck(_GetPixelColor($x, $y), Hex($NextSlotActive[$b], 20), 20) Then 
								$bContinue = True
								EndIf
							Next
						EndIf					
					EndIf
					If $bContinue Then
						While Not _ColorCheck( $cPixColor, Hex($TroopSlot[2], 20), $TroopSlot[3])
							BB_Attack($Nside, $SIDESNAMES, 8)
							If $g_iLoopCount >= 8 Then ExitLoop
							If $bDegug Then SetLog("BB: Drop Troops - Slot[ " & String( $i + 1 ) & " ], code: 0x" & $cPixColor & " [ " & String( $j ) & " ] Num:[ " & $TroopsToDrop & " ]", $COLOR_DEBUG)
							If _Sleep(12) Then Return 
							$j += 1
							If $j > 6 Then ExitLoop
							$cPixColor = _GetPixelColor($TroopSlot[0], $TroopSlot[1], True)
						WEnd
						If $bDegug Then SetLog("BB: Last Slot Color [ " & String( $i + 1 ) & " ], code: 0x" & $cPixColor & " [ " & String( $i + 1 ) & " ]", $COLOR_DEBUG)
					EndIf
				Next
				While $g_bRunState = True
				If _Sleep(500) Then Return
				; Okay pixel
					If _Sleep(500) Then Return
					Local $iOkayColor[3][3] = [[0xBEE758, 0, 1], [0xA8DD49, 0, 1], [0x7BC726, 0, 1]]
					Local $iOkayPixel = _MultiPixelSearch(279, 378, 646, 685, 1, 1, Hex(0xBFE85A, 6), $iOkayColor, 35)
					
					If IsArray($iOkayPixel) Then
						Local $ClickOkX = $iOkayPixel[0], $ClickOkY = $iOkayPixel[1]
						Setlog("Exit battle", $COLOR_INFO)
						Click($ClickOkX + 279, $ClickOkY + 378)
						ExitLoop
				; ---
						Else
						If _Sleep(500) Then Return
						Local $iOffColor[3][3] = [[0x4C49D5, 0, 1], [0x4C49D5, 0, 1], [0x4C49D5, 0, 1]]
						Local $iButtonPixel = _MultiPixelSearch(22, 658, 472, 726, 1, 1, Hex(0x4C49D5, 6), $iOffColor, 35)
						
						If IsArray($iButtonPixel) Then
							If $iCheck = 0 Then 
							Setlog("Boy on map", $COLOR_GREEN)
							$iClickMachineX = $iButtonPixel[0]
							$iClickMachineY = $iButtonPixel[1]
	
							ClickP($iButtonPixel, 100, 0, "#0000") ; Drop Troop
	
							If _Sleep($DELAYDROPTROOP1 / 5) Then Return
							AttackClick(557, 251, 1, SetSleep(0), 0, "#0000")
							$iCheck = 0
							ElseIf $iCheck = 1 Then
							AttackClick($iClickMachineX + 20, $iClickMachineY + 20, 1, SetSleep(0), 0, "#0000")
							EndIf
						EndIf
					EndIf
					
				WEnd

				If _Sleep($DELAYCHECKOBSTACLES4) Then Return 

				; wait $OkButtom to appear
				$j = 0
				$cPixColor = _GetPixelColor($OkButtom[0], $OkButtom[1], True)
				While Not _ColorCheck( $cPixColor, Hex($OkButtom[2], 20), $OkButtom[3])
					If $bDegug Then SetLog("BB: Click Okay Buttom. [Ok]. code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
					If _Sleep($DELAYCHECKOBSTACLES4) Then Return 
					$j += 1
					If $j > 10 Then ExitLoop
					$cPixColor = _GetPixelColor($OkButtom[0], $OkButtom[1], True)
				WEnd
				If $j < 10 Then
					SetLog("BB: Click Okay Buttom. [Ok]. code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
					ClickP($OkButtom, 1, 0, "#0000")
				Else
					SetLog("BB: Can't Find Okay Buttom [Ok]. code: 0x" & $cPixColor, $COLOR_ERROR)
				EndIf

				If _Sleep($DELAYCHECKOBSTACLES4) Then Return 

				; wait $OkBatleEnd to appear
				If $j < 10 Then
					$j = 0
					$cPixColor = _GetPixelColor($OkBatleEnd[0], $OkBatleEnd[1], True)
					While Not _ColorCheck( $cPixColor, Hex($OkBatleEnd[2], 20), $OkBatleEnd[3])
						If $bDegug Then SetLog("BB: Try Click Okay Buttom [end], code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
						If _Sleep($DELAYCHECKOBSTACLES3) Then Return
						$j += 1
						If $j > 30 Then ExitLoop
						$cPixColor = _GetPixelColor($OkBatleEnd[0], $OkBatleEnd[1], True)
					WEnd
					If $j < 30 Then
						SetLog("BB: Click Okay Buttom [end], code: 0x" & $cPixColor & " [ " & String( $j ) & " ]", $COLOR_DEBUG)
						ClickP($OkBatleEnd, 1, 0, "#0000")
					Else
						SetLog("BB: Can't Find Okay Buttom [End]. code: 0x" & $cPixColor, $COLOR_ERROR)
					EndIf
				Else

					If _Sleep(12) Then Return
					ClickP($aAway, 1, 0, "#0000")

				EndIf

			EndIf

			If _Sleep(12) Then Return
			ClickP($aAway, 1, 0, "#0000")

		Else
			Setlog("Ignore BB Drop Trophies: [Not Needed] [ " & String( $g_iTxtBB_DropTrophies ) & " ]", $COLOR_INFO)
		EndIf
	Else
		Setlog("Ignore BB Drop Trophies [ Disabled ]", $COLOR_INFO)
	Endif

EndFunc	;==> BB_DropTrophies

Func ChkBB_DropTrophies()
	$g_bChkBB_DropTrophies = (GUICtrlRead($g_hChkBB_DropTrophies) = $GUI_CHECKED) ? 1 : 0
EndFunc   ;==>ChkBB_DropTrophies

Func TxtBB_DropTrophies()
	$g_iTxtBB_DropTrophies = GUICtrlRead($g_hTxtBB_DropTrophies)
EndFunc   ;==>TxtBB_DropTrophies

 

Edited by Argentino
  • Like 1
  • Upvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...