xbebenk / MBR_xbebenkMod

GNU General Public License v3.0
60 stars 27 forks source link

Find a solution to attack BB2 twice with 200% #117

Closed Hoith95 closed 1 year ago

Hoith95 commented 1 year ago

Hello. it's me again :D I'm Vietnamese, so my English is limited, but I'm learning programming and I'm passionate about clash of clans and I really want to contribute to community software like Mybot.

I really appreciate it because you guys created mybot and developed it. i have tested many ways to fix mybot working better, but i am having trouble with many things...and don't know who to ask. now i tried to improve the code a bit so i can attack 2nd time with 200% awesome.

I know the code has many problems because I don't really understand the code of mybot. so please refer to what I edit and help the mybot community to perfect it soon. Thanks. Video: https://youtu.be/oIr-NOyFq6s

AttackBB.au3

Func OkayBBEnd() ; Find if battle has ended and click okay
    Local $bRet = False
    Local $sDamage = 0, $sTmpDamage = 0, $bCountSameDamage = 0

    For $i = 1 To 500
        SetLog("Waiting EndBattle Screen #" & $i, $COLOR_ACTION)

        $sDamage = getOcrOverAllDamage(780, 529)
        SetLog("[" & $i & "] OkayBBEnd LoopCheck, Overall Damage : " & $sDamage, $COLOR_DEBUG2)
        If Number($sDamage) = Number($sTmpDamage) Then 
            $bCountSameDamage += 1
        Else
            $bCountSameDamage = 0

        If $sTmpDamage = 100 Then
            SetLog("Enter the second wave of attack..", $COLOR_BLUE)
            Local $aBBAttackBar
            If CorrectAttackBarBB($aBBAttackBar) Then 
                AttackBB()
            Else
                $aBBAttackBar = GetAttackBarBB()
                AttackBB($aBBAttackBar)
            If _Sleep(500) Then Return
            EndIf
        EndIf

        EndIf
        $sTmpDamage = Number($sDamage)
        If $bCountSameDamage > 50 Then 
            SetLog("OkayBBEnd LoopCheck: No Change on Overall Damage, Exit!", $COLOR_ERROR)
            ExitLoop
        EndIf

        If QuickMIS("BC1", $g_sImgBBReturnHome, 390, 520, 470, 560) Then
            Click($g_iQuickMISX, $g_iQuickMISY)
            SetLog("Congrats Chief, Stars Bonus Awarded", $COLOR_INFO)
            $bRet = False
            ExitLoop
        EndIf

        If IsProblemAffect(True) Then Return
        If Not $g_bRunState Then Return
        If _Sleep(500) Then Return
    Next

    If ReturnHomeDropTrophyBB(True) Then $bRet = True

    For $i = 1 To 10
        If _Sleep(500) Then Return
        If BBBarbarianHead("OkayBBEnd") Then
            ClickP($aOkayButton)
        ExitLoop
        EndIf
    Next

    If Not $bRet Then SetLog("Could not find finish battle screen", $COLOR_ERROR)
    Return $bRet

EndFunc

============================= GetAttackBarBB.au3

    For $k = 0 To UBound($aSlotX) - 1
        If Not $g_bRunState Then Return

        $Troopx = $aSlotX[$k]
        $ColorPickBannerX = $aSlotX[$k] + 37 ; location to pick color from TroopSlot banner

        If $bRemaining Then 
            If $g_bDebugSetlog Then SetLog("Slot [" & $k & "]: isBlueBanner=" & String($isBlueBanner) & " isVioletBanner=" & String($isVioletBanner), $COLOR_DEBUG2)
            If QuickMIS("BC1", $g_sImgDirBBTroops, $Troopx, $iTroopBanners, $Troopx + 73, 670) Then 
                If $g_bDebugSetlog Then SetLog("Slot [" & $k & "]: TroopBanner ColorpickX=" & $ColorPickBannerX, $COLOR_DEBUG2)
                $isDarkGreyBanner = _ColorCheck(_GetPixelColor($ColorPickBannerX, $iTroopBanners, True), Hex(0x282828, 6), 10, Default, "isDarkGreyBanner") ; DartkGrey Banner on TroopSlot = Troop Already Deployed
                $isGreyBanner = _ColorCheck(_GetPixelColor($ColorPickBannerX, $iTroopBanners, True), Hex(0x707070, 6), 10, Default, "isGreyBanner") ;Grey Banner on TroopSlot = Troop Die
                If $isDarkGreyBanner Or $isGreyBanner Then ContinueLoop ;skip read troop as they detected deployed or die

                $isVioletBanner = _ColorCheck(_GetPixelColor($ColorPickBannerX, $iTroopBanners, True), Hex(0xC434FC, 6), 30, Default, "isVioletBanner") ; Violet Banner on TroopSlot = TroopSlot Quantity = 1 
                $isBlueBanner = _ColorCheck(_GetPixelColor($ColorPickBannerX, $iTroopBanners, True), Hex(0x3874FF, 6), 30, Default, "isBlueBanner") ; Blue Banner on TroopSlot = TroopSlot Quantity > 1 

                If $isBlueBanner Or $isVioletBanner Then
                    $Troop =  $g_iQuickMISName
                    $Troopy = $iSelectTroopY
                    If $isBlueBanner Then $iCount = Number(getOcrAndCapture("coc-tbb", $ColorPickBannerX, $iTroopBanners - 12, 35, 28, True))
                    If $isVioletBanner Then $iCount = 6

                    Local $aTempElement[1][5] = [[$Troop, $Troopx, $Troopy, $k, $iCount]] ; element to add to attack bar list
                    _ArrayAdd($aBBAttackBar, $aTempElement)
                EndIf
            EndIf
        Else

======================

xbebenk commented 1 year ago

nice video did you not read my comments ?, value $isVioletBanner = true, troop Quantity = 1, so forcing it to 6 is not the way how it works there is no redlines on second stage village attack, this is why I force stop bot from attacking

enjoy your change

Hoith95 commented 1 year ago

Hello. I understand the problem you've stated, and understanding the change from 1 = 6 is really only a temporary solution since I haven't found a better solution yet. because when the value = 1, the bot deploying the 2nd batch of soldiers often misses the units dropped in the 1st wave, I tried harder to fix it but really mybot code I don't know how to deploy , call functions, commands maybe I need more time to understand mybot code better, I'd be happy if I could be of some help to the mybot team and community.

Hoith95 commented 1 year ago

I tested and watched for about 2 3 hours to see if the way I adjusted the milk was stable or not and really, it was only relatively fine, usable. but it should be noted that you have to choose to drop the last battle machine before the bot deploys the 2nd wave. Moreover when I try to write 1 more attack code for the 2nd time in the way of the 1st deployment, it fails, maybe my code is wrong somewhere so it didn't redeploy attack scenario like wave 1. i think if you can adjust when dame = 100% then call 2nd attack deploy command for example, just rerun like the 1st wave and it will be fine I think it will be better than the way I am using is using the same attack script of the 1st wave. Once again I thank you and the team and also for what you share .

Hoith95 commented 1 year ago

about the red line in the 2nd wave I also thought, if possible, run zoom uot then drop the pieces on the outer edges, and identify the pieces that have been successfully dropped and let the bot recognize, and the pieces If the drop fails, let it drop again in another location, so the 2nd wave will be fine, there will be no more soldiers left behind like the way I am using, because of my intention when adjusting the $isVioletBanner value. = true, troop Quantity = 6 is to let the bot drop the remaining troops, but I understand that's not a good solution. My little personal share, thank you.

xbebenk commented 1 year ago

thanks for your idea

Hoith95 commented 1 year ago

Hello, I'm very happy if my idea can help you and Team mybot so that it can be completed soon to help the community. I also just downloaded and tested your dev version continuously so I can help with testing if there are any bugs, the newly released version is great, I ran it for about 30 minutes and sat and watched how it worked.

there is only one small problem using the new dev version is that because i use nox emulator instead of bs5 in the MBR Global Variables.au3 section Global $g_bAndroidAdbUseMyBot = False ; Use MyBot provided adb.exe and not the one from emulator I have to set it to True for nox to work. If possible please improve it so that nox users like me can use it without tweaking the code, for example when mybot detects that nox is being used then = True and if it is bs5 then = False for example.

Once again I thank you and the development team, best of luck to you and the team. I'm also trying to write 1 2 more features to integrate into mybot but it's not complete yet, when it's good I'll share it with you and the community later, still bye bye and see you soon.

xbebenk commented 1 year ago

maybe your nox adb was corrupted because you once using "replace with dummy" please verify your nox_adb.exe on nox folder, the size should be around 1.4 MB if your nox_abd size is < 1MB, then it was replaced by dummy adb https://mega.nz/file/ss1wWZBb#XYp7qV15qk_xycEhP1RX05hcFXrwIsB2Ru-zebL0Ufc i have this nox_adb, you can download and replace your with this

Hoith95 commented 1 year ago

có thể nox adb của bạn đã bị hỏng vì bạn đã từng sử dụng "thay thế bằng dummy" , vui lòng xác minh nox_adb.exe của bạn trên thư mục nox, kích thước phải khoảng 1,4 MB nếu kích thước nox_abd của bạn < 1 MB, thì nó đã được thay thế bằng adb dummy https:/ /mega.nz/file/ss1wWZBb#XYp7qV15qk_xycEhP1RX05hcFXrwIsB2Ru-zebL0Ufc tôi có nox_adb này, bạn có thể tải xuống và thay thế bằng cái này

hi, you are right. awesome thank you so much.

nhumber commented 1 year ago

latests commits get through round 2 of BB very well ;-) you guys are crushing it

NothingJustBlank commented 1 year ago

Added different solution for BB2.0 attacks