├── config └── README.md ├── BrokenBot.org ├── functions │ ├── Strategies │ │ ├── Dummy │ │ │ ├── Attack.au3 │ │ │ ├── Search.au3 │ │ │ ├── ReadyCheck.au3 │ │ │ ├── GUIControl.au3 │ │ │ ├── PrepareAttack.au3 │ │ │ ├── PrepNextBattle.au3 │ │ │ ├── Config.au3 │ │ │ ├── Plugin.au3 │ │ │ └── GUIDesign.au3 │ │ ├── Strategies.au3 │ │ ├── LoadDefaults.au3 │ │ ├── SharedFunction.au3 │ │ └── Common │ │ │ └── SharedFunctions.au3 │ ├── GUI │ │ ├── frmAttackConfig.au3 │ │ ├── WindowFixing.au3 │ │ └── frmBugReport.au3 │ ├── Other │ │ ├── ReadText.au3 │ │ ├── StatusCheck.au3 │ │ ├── HSL.au3 │ │ ├── maths.au3 │ │ ├── overlay.au3 │ │ ├── statsubmission.au3 │ │ ├── GeneralFunctions.au3 │ │ └── CallHelper.au3 │ ├── functions.au3 │ ├── Village │ │ ├── TroopSize.au3 │ │ ├── collectResources.au3 │ │ └── clearField.au3 │ └── ImageSearch │ │ ├── checkDarkElix.au3 │ │ └── checkTownhall.au3 ├── License.txt ├── BrokenBot32.dll ├── BrokenBotHelper.exe ├── languages │ ├── Farsi.ini │ ├── Korea.ini │ ├── Deutsch.ini │ ├── Italiano.ini │ ├── Russian.ini │ ├── Turkce.ini │ ├── Belarusian.ini │ └── Ukrainian.ini ├── images │ ├── icons │ │ └── brokenbot.ico │ └── misc │ │ └── brokenbot_logo.jpg ├── README.md └── BrokenBotHelper.au3 ├── COCBot.dll ├── BrokenBot.exe ├── curl ├── curl.exe └── curl license.txt ├── images ├── Lost.bmp ├── break.bmp ├── Client.bmp ├── Walls │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── 10.png │ └── 11.png ├── device.bmp ├── Elix1 │ ├── E9F9.bmp │ ├── e6f9.bmp │ ├── e7f9.bmp │ ├── e8f9.bmp │ ├── E11F8.bmp │ ├── E11F9.bmp │ ├── e10f8.bmp │ ├── e10f9.bmp │ ├── e12f7.bmp │ ├── e12f8.bmp │ └── e12f9.bmp ├── Elix2 │ ├── e6f9.bmp │ ├── e7f9.bmp │ ├── e8f9.bmp │ ├── e9f9.bmp │ ├── e10f8.bmp │ ├── e10f9.bmp │ ├── e11f8.bmp │ ├── e12f7.bmp │ ├── e12f8.bmp │ └── e12f9.bmp ├── Elix3 │ ├── e6f9.bmp │ ├── e7f9.bmp │ ├── e8f9.bmp │ ├── e10f8.bmp │ ├── e10f9.bmp │ ├── e11f8.bmp │ └── e12f8.bmp ├── Elix4 │ ├── e8f9.bmp │ ├── e10f8.bmp │ ├── e10f9.bmp │ ├── e11f8.bmp │ ├── e12f7.bmp │ ├── e12f8.bmp │ └── e12f9.bmp ├── Maintenance.bmp ├── Resource │ ├── bad.bmp │ ├── bad.png │ ├── Dark.jpg │ ├── Elixir.jpg │ ├── Gold.jpg │ ├── Trophy.jpg │ ├── Wall.jpg │ ├── good.bmp │ ├── good.png │ ├── unknown.bmp │ ├── unknown.png │ └── unknown2.png └── ElixSnow │ ├── e10f9.bmp │ ├── e11f8.bmp │ ├── e11f9.bmp │ ├── e8f9.bmp │ └── e9f9.bmp ├── COCBot ├── functions │ ├── Other │ │ ├── Time.au3 │ │ ├── Tab.au3 │ │ ├── Pause.au3 │ │ ├── DisableBS.au3 │ │ ├── EnableBS.au3 │ │ ├── FindPos.au3 │ │ ├── RandomGaussian.au3 │ │ ├── CreateLogFile.au3 │ │ ├── getBSPos.au3 │ │ ├── _NumberFormat.au3 │ │ ├── Click.au3 │ │ ├── LootLogCleanup.au3 │ │ ├── WriteStats.au3 │ │ ├── _Sleep.au3 │ │ ├── SetLog.au3 │ │ ├── stuckHandler.au3 │ │ ├── ClickDrag.au3 │ │ └── General Functions.au3 │ ├── Strategies │ │ ├── Strategies.au3 │ │ └── Standard │ │ │ ├── PrepNextBattle.au3 │ │ │ ├── Plugin.au3 │ │ │ └── AdjustCollPos.au3 │ ├── Pixels │ │ ├── _GetPixelColor.au3 │ │ ├── _PixelSearch.au3 │ │ ├── boolPixelSearch.au3 │ │ ├── _MultiPixelSearch.au3 │ │ ├── _CaptureRegion.au3 │ │ └── _ColorCheck.au3 │ ├── Search │ │ ├── checkNextButton.au3 │ │ ├── PrepareSearch.au3 │ │ └── GetResources.au3 │ ├── Village │ │ ├── isGoldFull.au3 │ │ ├── isElixirFull.au3 │ │ ├── isDarkElixirFull.au3 │ │ ├── Collect.au3 │ │ ├── RequestCC.au3 │ │ ├── CheckFullSpellFactory.au3 │ │ ├── BoostBarracks.au3 │ │ ├── CheckCostPerSearch.au3 │ │ ├── ReArm.au3 │ │ ├── upTroops.au3 │ │ ├── BotStopped.au3 │ │ ├── UpgradeWall.au3 │ │ ├── DonateCheckArmyCamp.au3 │ │ ├── DropTrophy.au3 │ │ └── MainLoop.au3 │ ├── Read Text │ │ ├── getTrophy.au3 │ │ ├── getNormal.au3 │ │ ├── getString.au3 │ │ ├── getGold.au3 │ │ ├── getElixir.au3 │ │ ├── getDarkElixir.au3 │ │ ├── getDigitTH.au3 │ │ ├── getOther.au3 │ │ └── getDigitLastRaid.au3 │ ├── Attack │ │ ├── NameOfTroop.au3 │ │ ├── GoldElixirChange.au3 │ │ └── ReturnHome.au3 │ ├── Main Screen │ │ ├── ZoomOut.au3 │ │ ├── waitMainScreen.au3 │ │ ├── checkMainScreen.au3 │ │ └── checkObstacles.au3 │ └── Image Search │ │ ├── checkButtonUpgrade.au3 │ │ ├── checkTownhall.au3 │ │ ├── ImageSearch.au3 │ │ ├── checkDarkElix.au3 │ │ ├── checkWall.au3 │ │ └── checkDeadBase.au3 └── Functions.au3 ├── strategies └── README.md ├── .gitignore ├── README.md └── BrokenBot.au3 /config/README.md: -------------------------------------------------------------------------------- 1 | This directory houses your configuration files. -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/Attack.au3: -------------------------------------------------------------------------------- 1 | ; Deploy your troops 2 | -------------------------------------------------------------------------------- /COCBot.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/COCBot.dll -------------------------------------------------------------------------------- /BrokenBot.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.exe -------------------------------------------------------------------------------- /curl/curl.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/curl/curl.exe -------------------------------------------------------------------------------- /images/Lost.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Lost.bmp -------------------------------------------------------------------------------- /images/break.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/break.bmp -------------------------------------------------------------------------------- /images/Client.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Client.bmp -------------------------------------------------------------------------------- /images/Walls/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/4.png -------------------------------------------------------------------------------- /images/Walls/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/5.png -------------------------------------------------------------------------------- /images/Walls/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/6.png -------------------------------------------------------------------------------- /images/Walls/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/7.png -------------------------------------------------------------------------------- /images/Walls/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/8.png -------------------------------------------------------------------------------- /images/Walls/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/9.png -------------------------------------------------------------------------------- /images/device.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/device.bmp -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/Search.au3: -------------------------------------------------------------------------------- 1 | ; You are looking for a base to attack 2 | -------------------------------------------------------------------------------- /images/Elix1/E9F9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/E9F9.bmp -------------------------------------------------------------------------------- /images/Elix1/e6f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e6f9.bmp -------------------------------------------------------------------------------- /images/Elix1/e7f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e7f9.bmp -------------------------------------------------------------------------------- /images/Elix1/e8f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e8f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e6f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e6f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e7f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e7f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e8f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e8f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e9f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e9f9.bmp -------------------------------------------------------------------------------- /images/Elix3/e6f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e6f9.bmp -------------------------------------------------------------------------------- /images/Elix3/e7f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e7f9.bmp -------------------------------------------------------------------------------- /images/Elix3/e8f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e8f9.bmp -------------------------------------------------------------------------------- /images/Elix4/e8f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e8f9.bmp -------------------------------------------------------------------------------- /images/Walls/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/10.png -------------------------------------------------------------------------------- /images/Walls/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Walls/11.png -------------------------------------------------------------------------------- /images/Elix1/E11F8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/E11F8.bmp -------------------------------------------------------------------------------- /images/Elix1/E11F9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/E11F9.bmp -------------------------------------------------------------------------------- /images/Elix1/e10f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e10f8.bmp -------------------------------------------------------------------------------- /images/Elix1/e10f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e10f9.bmp -------------------------------------------------------------------------------- /images/Elix1/e12f7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e12f7.bmp -------------------------------------------------------------------------------- /images/Elix1/e12f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e12f8.bmp -------------------------------------------------------------------------------- /images/Elix1/e12f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix1/e12f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e10f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e10f8.bmp -------------------------------------------------------------------------------- /images/Elix2/e10f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e10f9.bmp -------------------------------------------------------------------------------- /images/Elix2/e11f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e11f8.bmp -------------------------------------------------------------------------------- /images/Elix2/e12f7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e12f7.bmp -------------------------------------------------------------------------------- /images/Elix2/e12f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e12f8.bmp -------------------------------------------------------------------------------- /images/Elix2/e12f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix2/e12f9.bmp -------------------------------------------------------------------------------- /images/Elix3/e10f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e10f8.bmp -------------------------------------------------------------------------------- /images/Elix3/e10f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e10f9.bmp -------------------------------------------------------------------------------- /images/Elix3/e11f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e11f8.bmp -------------------------------------------------------------------------------- /images/Elix3/e12f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix3/e12f8.bmp -------------------------------------------------------------------------------- /images/Elix4/e10f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e10f8.bmp -------------------------------------------------------------------------------- /images/Elix4/e10f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e10f9.bmp -------------------------------------------------------------------------------- /images/Elix4/e11f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e11f8.bmp -------------------------------------------------------------------------------- /images/Elix4/e12f7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e12f7.bmp -------------------------------------------------------------------------------- /images/Elix4/e12f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e12f8.bmp -------------------------------------------------------------------------------- /images/Elix4/e12f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Elix4/e12f9.bmp -------------------------------------------------------------------------------- /images/Maintenance.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Maintenance.bmp -------------------------------------------------------------------------------- /images/Resource/bad.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/bad.bmp -------------------------------------------------------------------------------- /images/Resource/bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/bad.png -------------------------------------------------------------------------------- /BrokenBot.org/License.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/License.txt -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/ReadyCheck.au3: -------------------------------------------------------------------------------- 1 | ; Returns true if you are now ready to attack 2 | -------------------------------------------------------------------------------- /images/ElixSnow/e10f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/ElixSnow/e10f9.bmp -------------------------------------------------------------------------------- /images/ElixSnow/e11f8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/ElixSnow/e11f8.bmp -------------------------------------------------------------------------------- /images/ElixSnow/e11f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/ElixSnow/e11f9.bmp -------------------------------------------------------------------------------- /images/ElixSnow/e8f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/ElixSnow/e8f9.bmp -------------------------------------------------------------------------------- /images/ElixSnow/e9f9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/ElixSnow/e9f9.bmp -------------------------------------------------------------------------------- /images/Resource/Dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/Dark.jpg -------------------------------------------------------------------------------- /images/Resource/Elixir.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/Elixir.jpg -------------------------------------------------------------------------------- /images/Resource/Gold.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/Gold.jpg -------------------------------------------------------------------------------- /images/Resource/Trophy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/Trophy.jpg -------------------------------------------------------------------------------- /images/Resource/Wall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/Wall.jpg -------------------------------------------------------------------------------- /images/Resource/good.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/good.bmp -------------------------------------------------------------------------------- /images/Resource/good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/good.png -------------------------------------------------------------------------------- /images/Resource/unknown.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/unknown.bmp -------------------------------------------------------------------------------- /images/Resource/unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/unknown.png -------------------------------------------------------------------------------- /images/Resource/unknown2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/images/Resource/unknown2.png -------------------------------------------------------------------------------- /BrokenBot.org/BrokenBot32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/BrokenBot32.dll -------------------------------------------------------------------------------- /BrokenBot.org/BrokenBotHelper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/BrokenBotHelper.exe -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/GUIControl.au3: -------------------------------------------------------------------------------- 1 | ; Functions to occur when controls on GUI are interacted with 2 | -------------------------------------------------------------------------------- /BrokenBot.org/languages/Farsi.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Farsi.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Korea.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Korea.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Deutsch.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Deutsch.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Italiano.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Italiano.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Russian.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Russian.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Turkce.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Turkce.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Belarusian.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Belarusian.ini -------------------------------------------------------------------------------- /BrokenBot.org/languages/Ukrainian.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/languages/Ukrainian.ini -------------------------------------------------------------------------------- /BrokenBot.org/images/icons/brokenbot.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/images/icons/brokenbot.ico -------------------------------------------------------------------------------- /BrokenBot.org/images/misc/brokenbot_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codebroken/BrokenBot/HEAD/BrokenBot.org/images/misc/brokenbot_logo.jpg -------------------------------------------------------------------------------- /COCBot/functions/Other/Time.au3: -------------------------------------------------------------------------------- 1 | Func Time() ;Gives the time in '[00:00:00 AM/PM]' format 2 | Return "[" & _NowTime(3) & "] " 3 | EndFunc ;==>Time 4 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/PrepareAttack.au3: -------------------------------------------------------------------------------- 1 | ; You've already searched and found the base to attack, this just preps for the actual attack 2 | -------------------------------------------------------------------------------- /COCBot/functions/Strategies/Strategies.au3: -------------------------------------------------------------------------------- 1 | ; Just need a single line for each attack strategy plugin 2 | ; Leave Standard at top! 3 | #include "Standard\Plugin.au3" 4 | -------------------------------------------------------------------------------- /COCBot/functions/Other/Tab.au3: -------------------------------------------------------------------------------- 1 | Func Tab($a, $b) 2 | $Tab = "" 3 | For $i = StringLen($a) To $b Step 1 4 | $Tab &= " " 5 | Next 6 | Return $Tab 7 | EndFunc ;==>Tab 8 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/PrepNextBattle.au3: -------------------------------------------------------------------------------- 1 | ; This occurs before attacking 2 | ; It gives you a chance to fill up barracks with a new round of troops before searching 3 | -------------------------------------------------------------------------------- /strategies/README.md: -------------------------------------------------------------------------------- 1 | This directory houses easily sharable configuration from each plugin. This allows easy sharing of attack and search settings without modifying all your other BrokenBot settings. -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/Config.au3: -------------------------------------------------------------------------------- 1 | Func Dummy_LoadConfig() 2 | 3 | EndFunc ;==>Dummy_LoadConfig 4 | 5 | Func Dummy_SaveConfig($configFile) 6 | IniWrite($configFile, "plugin", "name", "Dummy") 7 | 8 | EndFunc ;==>Dummy_SaveConfig 9 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/_GetPixelColor.au3: -------------------------------------------------------------------------------- 1 | ;Returns color of pixel in the coordinations 2 | 3 | Func _GetPixelColor($iX, $iY) 4 | Local $aPixelColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) 5 | Return Hex($aPixelColor, 6) 6 | EndFunc ;==>_GetPixelColor 7 | -------------------------------------------------------------------------------- /COCBot/functions/Other/Pause.au3: -------------------------------------------------------------------------------- 1 | Func Pause() 2 | Local $count = 0 3 | While GUICtrlRead($btnPause) = "Resume" 4 | $count += 1 5 | If _Sleep(100) Then Return True 6 | If Mod($count, 600) = 0 Then _BumpMouse() 7 | WEnd 8 | Return False 9 | EndFunc ;==>Pause 10 | -------------------------------------------------------------------------------- /COCBot/functions/Other/DisableBS.au3: -------------------------------------------------------------------------------- 1 | Func DisableBS($HWnD, $iButton) 2 | ConsoleWrite('+ Window Handle: ' & $HWnD & @CRLF) 3 | $hSysMenu = _GUICtrlMenu_GetSystemMenu($HWnD, 0) 4 | _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) 5 | _GUICtrlMenu_DrawMenuBar($HWnD) 6 | EndFunc ;==>DisableBS 7 | -------------------------------------------------------------------------------- /COCBot/functions/Other/EnableBS.au3: -------------------------------------------------------------------------------- 1 | Func EnableBS($HWnD, $iButton) 2 | ConsoleWrite('+ Window Handle: ' & $HWnD & @CRLF) 3 | $hSysMenu = _GUICtrlMenu_GetSystemMenu($HWnD, 1) 4 | _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) 5 | _GUICtrlMenu_DrawMenuBar($HWnD) 6 | EndFunc ;==>EnableBS 7 | -------------------------------------------------------------------------------- /COCBot/functions/Other/FindPos.au3: -------------------------------------------------------------------------------- 1 | Func FindPos() 2 | getBSPos() 3 | Local $Pos[2] 4 | While 1 5 | If _IsPressed("01") Then 6 | $Pos[0] = MouseGetPos()[0] - $BSpos[0] 7 | $Pos[1] = MouseGetPos()[1] - $BSpos[1] 8 | Return $Pos 9 | EndIf 10 | WEnd 11 | EndFunc ;==>FindPos 12 | -------------------------------------------------------------------------------- /COCBot/functions/Strategies/Standard/PrepNextBattle.au3: -------------------------------------------------------------------------------- 1 | Func Standard_PrepNextBattle() 2 | ;Resetting this flag only after search successful 3 | ;As this flag will be used in miniReady_Check as well 4 | ;$stuckCount = 0 5 | Standard_Train(True) 6 | EndFunc ;==>Standard_PrepNextBattle 7 | 8 | -------------------------------------------------------------------------------- /COCBot/functions/Other/RandomGaussian.au3: -------------------------------------------------------------------------------- 1 | Func _Random_Gaussian($nMean, $nSD) 2 | Do 3 | $nX = ((2 * Random()) - 1) 4 | $nY = ((2 * Random()) - 1) 5 | $nR = ($nX ^ 2) + ($nY ^ 2) 6 | Until $nR < 1 7 | $nGaus = ($nX * (Sqrt((-2 * (Log($nR) / $nR))))) 8 | Return ($nGaus * $nSD) + $nMean 9 | EndFunc ;==>_Random_Gaussian 10 | -------------------------------------------------------------------------------- /COCBot/functions/Other/CreateLogFile.au3: -------------------------------------------------------------------------------- 1 | Func CreateLogFile() 2 | $sLogPath = $dirLogs & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "." & @MIN & "." & @SEC & ".log" 3 | $sLogFileName = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "." & @MIN & "." & @SEC & ".log" 4 | $hLogFileHandle = FileOpen($sLogPath, $FO_APPEND) 5 | EndFunc ;==>CreateLogFile 6 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/Plugin.au3: -------------------------------------------------------------------------------- 1 | ; #include needed functions 2 | ; Naming format: PluginName_Function 3 | ; Required functions: _LoadGUI, _SaveConfig, _ReadyCheck, _PrepNextBattle, _Search, _PrepareAttack, _Attack 4 | 5 | ; Name your strategy 6 | ; Format necessary for plugins: 7 | ; $StratNames = $StratNames & "|Plugin name" 8 | $StratNames = $StratNames & "|Dummy" 9 | 10 | ; Global variables specific to Plugin may be included here 11 | -------------------------------------------------------------------------------- /COCBot/functions/Other/getBSPos.au3: -------------------------------------------------------------------------------- 1 | Func getBSPos() 2 | $aPos = ControlGetPos($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]") 3 | $tPoint = DllStructCreate("int X;int Y") 4 | DllStructSetData($tPoint, "X", $aPos[0]) 5 | DllStructSetData($tPoint, "Y", $aPos[1]) 6 | _WinAPI_ClientToScreen(WinGetHandle(WinGetTitle($Title)), $tPoint) 7 | 8 | $BSpos[0] = DllStructGetData($tPoint, "X") 9 | $BSpos[1] = DllStructGetData($tPoint, "Y") 10 | EndFunc ;==>getBSPos 11 | -------------------------------------------------------------------------------- /COCBot/functions/Other/_NumberFormat.au3: -------------------------------------------------------------------------------- 1 | ; _NumberFormat 2 | 3 | Func _NumberFormat($Number = "") ; pad numbers with spaces as thousand separator 4 | 5 | If $Number = "" Then Return "" 6 | 7 | If StringLeft($Number, 1) = "-" Then 8 | Return "- " & StringRegExpReplace(StringTrimLeft($Number, 1), "(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))", "\1 ") 9 | Else 10 | Return StringRegExpReplace($Number, "(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))", "\1 ") 11 | EndIf 12 | 13 | EndFunc ;==>_NumberFormat 14 | -------------------------------------------------------------------------------- /COCBot/functions/Search/checkNextButton.au3: -------------------------------------------------------------------------------- 1 | ;Checks for error message (outof sync, inactivity, ect..) 2 | ;Returns False if no error message 3 | 4 | Func checkNextButton() ;Checks for Out of Sync or Connection Lost errors 5 | $Message = _PixelSearch(457, 300, 458, 330, Hex(0x33B5E5, 6), 10) ;Check for out of sync or inactivity 6 | If IsArray($Message) = False Then 7 | Return True ;Button available 8 | Else 9 | Return False ;Out of sync or inactivity error. 10 | EndIf 11 | EndFunc ;==>checkNextButton 12 | -------------------------------------------------------------------------------- /COCBot/functions/Strategies/Standard/Plugin.au3: -------------------------------------------------------------------------------- 1 | #include "Attack.au3" 2 | #include "Config.au3" 3 | #include "GUIControl.au3" 4 | #include "GUIDesign.au3" 5 | #include "PrepareAttack.au3" 6 | #include "PrepNextBattle.au3" 7 | #include "ReadyCheck.au3" 8 | #include "Search.au3" 9 | #include "AdjustCollPos.au3" 10 | 11 | $StratNames = "Standard" 12 | 13 | Global $prevTroopComp = -1 14 | Global $BarbariansComp, $ArchersComp, $GiantsComp, $GoblinsComp, $WBComp 15 | Global $fullarmy, $fullSpellFactory 16 | Global $stuckCount = 0 17 | 18 | 19 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/_PixelSearch.au3: -------------------------------------------------------------------------------- 1 | ;PixelSearch a certain region, works for memory BMP 2 | 3 | Func _PixelSearch($iLeft, $iTop, $iRight, $iBottom, $iColor, $iColorVariation) 4 | _CaptureRegion($iLeft, $iTop, $iRight, $iBottom) 5 | For $x = $iRight - $iLeft To 0 Step -1 6 | For $y = 0 To $iBottom - $iTop 7 | If _ColorCheck(_GetPixelColor($x, $y), $iColor, $iColorVariation) Then 8 | Local $Pos[2] = [$iLeft + $x, $iTop + $y] 9 | Return $Pos 10 | EndIf 11 | Next 12 | Next 13 | Return 0 14 | EndFunc ;==>_PixelSearch 15 | -------------------------------------------------------------------------------- /COCBot/functions/Village/isGoldFull.au3: -------------------------------------------------------------------------------- 1 | ;Checks if your Gold Storages are maxed out 2 | 3 | Func isGoldFull() 4 | _CaptureRegion() 5 | ;----------------------------------------------------------------------------- 6 | If _ColorCheck(_GetPixelColor(658, 33), Hex(0x000000, 6), 6) Then ;Hex is black 7 | If _ColorCheck(_GetPixelColor(660, 33), Hex(0xD4B100, 6), 6) Then ;Hex if color of gold (orange) 8 | SetLog(GetLangText("msgGoldFull"), $COLOR_GREEN) 9 | Return True 10 | EndIf 11 | EndIf 12 | 13 | Return False 14 | EndFunc ;==>isGoldFull 15 | -------------------------------------------------------------------------------- /COCBot/functions/Village/isElixirFull.au3: -------------------------------------------------------------------------------- 1 | ;Checks if your Elixir Storages are maxed out 2 | 3 | Func isElixirFull() 4 | _CaptureRegion() 5 | ;----------------------------------------------------------------------------- 6 | If _ColorCheck(_GetPixelColor(658, 84), Hex(0x000000, 6), 6) Then ;Hex is black 7 | If _ColorCheck(_GetPixelColor(660, 84), Hex(0xAE1AB3, 6), 6) Then ;Hex if color of elixir (purple) 8 | SetLog(GetLangText("msgElixirFull"), $COLOR_GREEN) 9 | Return True 10 | EndIf 11 | EndIf 12 | 13 | Return False 14 | EndFunc ;==>isElixirFull 15 | -------------------------------------------------------------------------------- /COCBot/functions/Village/isDarkElixirFull.au3: -------------------------------------------------------------------------------- 1 | ;Checks if your Elixir Storages are maxed out 2 | 3 | Func isDarkElixirFull() 4 | _CaptureRegion() 5 | ;----------------------------------------------------------------------------- 6 | If _ColorCheck(_GetPixelColor(707, 128), Hex(0x000000, 6), 6) Then ;Hex is black 7 | If _ColorCheck(_GetPixelColor(708, 128), Hex(0x1A0026, 6), 20) Then ;Hex if color of dark elixir 8 | SetLog(GetLangText("msgDarkElixirFull"), $COLOR_GREEN) 9 | Return True 10 | EndIf 11 | EndIf 12 | 13 | Return False 14 | EndFunc ;==>isElixirFull 15 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getTrophy.au3: -------------------------------------------------------------------------------- 1 | ;Returns complete value of Trophy xx 2 | 3 | Func getTrophy($x_start, $y_start) 4 | _CaptureRegion(0, 0, $x_start + 90, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $Trophy, $i = 0 8 | While getDigit($x, $y + $i, "Trophy") = "" 9 | If $i >= 15 Then ExitLoop 10 | $i += 1 11 | WEnd 12 | $x = $x_start 13 | $Trophy &= getDigit($x, $y + $i, "Trophy") 14 | $Trophy &= getDigit($x, $y + $i, "Trophy") 15 | Return $Trophy 16 | EndFunc ;==>getTrophy 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################## 2 | ## Remove files not part of BrokenBot base code ## 3 | ################################################## 4 | 5 | AllTowns/ 6 | Attacks/ 7 | Debug/ 8 | logs/ 9 | Loots/ 10 | config/*.ini 11 | strategies/*.ini 12 | .developer 13 | 14 | ###################### 15 | ## Windows detritus ## 16 | ###################### 17 | 18 | # Windows image file caches 19 | Thumbs.db 20 | ehthumbs.db 21 | 22 | # Autoit BAK file 23 | *.bak 24 | 25 | # Folder config file 26 | Desktop.ini 27 | 28 | # Recycle Bin used on file shares 29 | $RECYCLE.BIN/ 30 | 31 | # Mac crap 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getNormal.au3: -------------------------------------------------------------------------------- 1 | ;Returns complete value of normal xxx 2 | 3 | Func getNormal($x_start, $y_start) 4 | _CaptureRegion(0, 0, $x_start + 90, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $Normal, $i = 0 8 | 9 | $Normal = getDigit($x, $y, "Normal") 10 | 11 | While $Normal = "" 12 | If $i >= 50 Then ExitLoop 13 | $i += 1 14 | $x += 1 15 | $Normal = getDigit($x, $y, "Normal") 16 | WEnd 17 | 18 | $Normal &= getDigit($x, $y, "Normal") 19 | $Normal &= getDigit($x, $y, "Normal") 20 | 21 | Return $Normal 22 | EndFunc ;==>getNormal 23 | -------------------------------------------------------------------------------- /COCBot/functions/Village/Collect.au3: -------------------------------------------------------------------------------- 1 | ;Clickes the collector locations 2 | 3 | Func Collect() 4 | Local $collectx, $collecty, $i = 0 5 | 6 | If $ichkCollect = 1 Then 7 | SetLog(GetLangText("msgCollecting"), $COLOR_BLUE) 8 | _Sleep(250) 9 | Click(1, 1) ;Click Away 10 | While 1 11 | If _Sleep(300) Or $Running = False Then ExitLoop 12 | _CaptureRegion(0, 0, 780) 13 | If _ImageSearch(@ScriptDir & "\images\Collectors\resimg.png", 1, $collectx, $collecty, 20) Then 14 | Click($collectx, $collecty) ;Click collector 15 | ElseIf $i >= 20 Then 16 | ExitLoop 17 | EndIf 18 | $i += 1 19 | Click(1, 1) ;Click Away 20 | WEnd 21 | EndIf 22 | EndFunc ;==>Collect 23 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Strategies.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ; Just need a single line for each attack strategy plugin 7 | ;#include "Dummy\Plugin.au3" 8 | #include "Common\SharedFunctions.au3" 9 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getString.au3: -------------------------------------------------------------------------------- 1 | ;Uses getChar to get the characters of the donation and gets all of the character into a string. 2 | 3 | Func getString($y) 4 | For $i = 0 To 3 5 | Local $x_Temp = 35 6 | If getChar($x_Temp, $y) = " " Or getChar($x_Temp, $y) = "|" Then 7 | $y += 1 8 | Else 9 | ExitLoop 10 | EndIf 11 | Next 12 | Local $x = 35 13 | Local $String = "" 14 | Do 15 | $String &= getChar($x, $y) 16 | Until (StringMid($String, StringLen($String) - 1, 2) = " " Or StringMid($String, StringLen($String), 1) = "|") 17 | $String = StringReplace($String, " ", Null) 18 | $String = StringReplace($String, "|", Null) 19 | 20 | Return $String 21 | EndFunc ;==>getString 22 | -------------------------------------------------------------------------------- /COCBot/functions/Other/Click.au3: -------------------------------------------------------------------------------- 1 | Func Click($x, $y, $times = 1, $speed = 0, $CenteredOn = 0, $BufferDist = -1) 2 | If $CenteredOn = 0 Then 3 | If $times <> 1 Then 4 | For $i = 0 To ($times - 1) 5 | ControlClick($Title, "", "", "left", "1", $x, $y) 6 | If _Sleep($speed, False) Then ExitLoop 7 | Next 8 | Else 9 | ControlClick($Title, "", "", "left", "1", $x, $y) 10 | EndIf 11 | Else 12 | RedLineDeploy($x, $y, $times, $speed, $CenteredOn, $BufferDist) 13 | EndIf 14 | EndFunc ;==>Click 15 | 16 | ; ClickP : takes an array[2] (or array[4]) as a parameter [x,y] 17 | Func ClickP($point, $howMuch = 1, $speed = 0) 18 | Click($point[0], $point[1], $howMuch, $speed) 19 | EndFunc ;==>ClickP 20 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/GUI/frmAttackConfig.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | $frmAttackConfig = GUICreate("Attack config panel", 410, 410, -1, -1, $WS_BORDER + $WS_POPUP, $WS_EX_MDICHILD, $frmBot) 7 | GUISetState(@SW_HIDE, $frmAttackConfig) 8 | -------------------------------------------------------------------------------- /COCBot/functions/Attack/NameOfTroop.au3: -------------------------------------------------------------------------------- 1 | Func NameOfTroop($kind, $plurial = 0) 2 | Switch $kind 3 | Case $eBarbarian 4 | Return "Barbarians" 5 | Case $eArcher 6 | Return "Archers" 7 | Case $eGoblin 8 | Return "Goblins" 9 | Case $eGiant 10 | Return "Giants" 11 | Case $eWallbreaker 12 | Return "Wall Breakers" 13 | Case $eMinion 14 | Return "Minions" 15 | Case $eHog 16 | Return "Hogs" 17 | Case $eValkyrie 18 | Return "Valkyries" 19 | Case $eKing 20 | Return "King" 21 | Case $eQueen 22 | Return "Queen" 23 | Case $eCastle 24 | Return "Clan castle" 25 | Case $eLSpell 26 | Return "Lightning Spell" 27 | Case Else 28 | Return "Unknown" 29 | EndSwitch 30 | EndFunc ;==>NameOfTroop 31 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getGold.au3: -------------------------------------------------------------------------------- 1 | ;Gets complete value of gold xxx,xxx 2 | 3 | Func getGold($x_start, $y_start) 4 | _CaptureRegion(0, 0, $x_start + 90, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $Gold, $i = 0 8 | While getDigit($x, $y + $i, "Gold") = "" 9 | If $i >= 15 Then ExitLoop 10 | $i += 1 11 | WEnd 12 | $x = $x_start 13 | $Gold &= getDigit($x, $y + $i, "Gold") 14 | $Gold &= getDigit($x, $y + $i, "Gold") 15 | $Gold &= getDigit($x, $y + $i, "Gold") 16 | $x += 6 17 | $Gold &= getDigit($x, $y + $i, "Gold") 18 | $Gold &= getDigit($x, $y + $i, "Gold") 19 | $Gold &= getDigit($x, $y + $i, "Gold") 20 | Return $Gold 21 | EndFunc ;==>getGold 22 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getElixir.au3: -------------------------------------------------------------------------------- 1 | ;Returns complete Value of elixir xxx,xxx 2 | 3 | Func getElixir($x_start, $y_start) 4 | _CaptureRegion(0, 0, $x_start + 90, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $Elixir, $i = 0 8 | While getDigit($x, $y + $i, "Elixir") = "" 9 | If $i >= 15 Then ExitLoop 10 | $i += 1 11 | WEnd 12 | $x = $x_start 13 | $Elixir &= getDigit($x, $y + $i, "Elixir") 14 | $Elixir &= getDigit($x, $y + $i, "Elixir") 15 | $Elixir &= getDigit($x, $y + $i, "Elixir") 16 | $x += 6 17 | $Elixir &= getDigit($x, $y + $i, "Elixir") 18 | $Elixir &= getDigit($x, $y + $i, "Elixir") 19 | $Elixir &= getDigit($x, $y + $i, "Elixir") 20 | Return $Elixir 21 | EndFunc ;==>getElixir 22 | -------------------------------------------------------------------------------- /COCBot/functions/Search/PrepareSearch.au3: -------------------------------------------------------------------------------- 1 | ;Goes into a match, breaks shield if it has to 2 | ; Returns True if successful, otherwise False after 10 failed attempts 3 | Func PrepareSearch() ;Click attack button and find match button, will break shield 4 | 5 | Click(60, 614);Click Attack Button 6 | SetLog(GetLangText("msgSearchingMatch")) 7 | If _WaitForColorArea(287, 494, 5, 5, Hex(0xEEAC28, 6), 50) Then 8 | Click(217, 510);Click Find a Match Button 9 | ; Is shield active? 10 | If _WaitForColorArea(513, 416, 5, 5, Hex(0x5DAC10, 6), 50, 1) Then 11 | Click(513, 416) 12 | EndIf 13 | If _WaitForColorArea(23, 523, 25, 10, Hex(0xEE5056, 6), 50, 10) Then Return True 14 | Else 15 | ;Something is wrong here, restart bluestack 16 | restartBlueStack() 17 | EndIf 18 | Return False 19 | EndFunc ;==>PrepareSearch 20 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getDarkElixir.au3: -------------------------------------------------------------------------------- 1 | ;Returns complete value of dark elixir xxx,xxx 2 | 3 | Func getDarkElixir($x_start, $y_start) 4 | _CaptureRegion(0, 0, $x_start + 90, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $DarkElixir, $i = 0 8 | While getDigit($x, $y + $i, "DarkElixir") = "" 9 | If $i >= 15 Then ExitLoop 10 | $i += 1 11 | WEnd 12 | $x = $x_start 13 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 14 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 15 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 16 | $x += 6 17 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 18 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 19 | $DarkElixir &= getDigit($x, $y + $i, "DarkElixir") 20 | Return $DarkElixir 21 | EndFunc ;==>getDarkElixir 22 | -------------------------------------------------------------------------------- /COCBot/functions/Other/LootLogCleanup.au3: -------------------------------------------------------------------------------- 1 | Func LootLogCleanup($no_rotator) 2 | Local $dir_list[3] = ["Loots", "logs", "Debug"] 3 | For $l = 0 To UBound($dir_list) - 1 4 | Local $dir = @ScriptDir & "\" & $dir_list[$l] 5 | If FileExists($dir) == 0 Then 6 | SetLog(GetLangText("msgDirNotFound") & $dir, $COLOR_RED) 7 | ContinueLoop 8 | EndIf 9 | Local $fArray = _FileListToArrayRec($dir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) 10 | If UBound($fArray) == 0 Then ContinueLoop 11 | Local $data_size = $fArray[0] 12 | If $data_size > $no_rotator Then 13 | For $i = 1 To Number($data_size - $no_rotator) 14 | Local $file_path = $fArray[$i] 15 | If Not FileDelete($file_path) Then 16 | SetLog(GetLangText("msgFailDel") & $file_path, $COLOR_RED) 17 | EndIf 18 | Next 19 | EndIf 20 | Next 21 | EndFunc ;==>LootLogCleanup 22 | 23 | -------------------------------------------------------------------------------- /COCBot/functions/Main Screen/ZoomOut.au3: -------------------------------------------------------------------------------- 1 | ;Tries to zoom out of the screen until the borders, located at the top of the game (usually black), is located. 2 | 3 | Func ZoomOut() 4 | $i = 0 5 | _CaptureRegion(0, 0, 860, 2) 6 | If _GetPixelColor(1, 1) <> Hex(0x000000, 6) And _GetPixelColor(850, 1) <> Hex(0x000000, 6) Then SetLog(GetLangText("msgZoomingOut"), $COLOR_GREEN) 7 | While (_GetPixelColor(1, 1) <> Hex(0x000000, 6) And _GetPixelColor(850, 1) <> Hex(0x000000, 6)) And $i <= 40 8 | If BitAND(GUICtrlGetState($btnStop), $GUI_HIDE) Then 9 | _Sleep(600, True, False) 10 | Else 11 | If _Sleep(600) Then Return False 12 | EndIf 13 | If ControlSend($Title, "", "", "{DOWN}") Then $i += 1 14 | _CaptureRegion(0, 0, 860, 2) 15 | WEnd 16 | If _GetPixelColor(1, 1) <> Hex(0x000000, 6) And _GetPixelColor(850, 1) <> Hex(0x000000, 6) Then 17 | Return False 18 | Else 19 | Return True 20 | EndIf 21 | EndFunc ;==>ZoomOut 22 | -------------------------------------------------------------------------------- /COCBot/functions/Other/WriteStats.au3: -------------------------------------------------------------------------------- 1 | ; Outputs stats of battles to log file 2 | Func WriteStats($Skips, $EarnedGold, $EarnedElixir, $EarnedDark) 3 | $sStatPath = $dirLogs & "Loot Results.csv" 4 | If Not FileExists($sStatPath) Then 5 | $hStatFileHandle = FileOpen($sStatPath, $FO_APPEND) 6 | FileWriteLine($hStatFileHandle, "Time,SearchGold,SearchElixir,SearchDark,SearchTrophy,SearchTHLvl,SearchDead,SearchInside,NukeAttack,Skips,EarnedGold,EarnedElixir,EarnedDark") 7 | Else 8 | $hStatFileHandle = FileOpen($sStatPath, $FO_APPEND) 9 | EndIf 10 | FileWriteLine($hStatFileHandle, @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "." & @MIN & "." & @SEC & "," & $searchGold & "," & $searchElixir & "," & $searchDark & "," & $searchTrophy & "," & $searchTH & "," & $searchDead & "," & $THLoc & "," & $NukeAttack & "," & $Skips & "," & $EarnedGold & "," & $EarnedElixir & "," & $EarnedDark) 11 | FileClose($hStatFileHandle) 12 | EndFunc ;==>WriteStats 13 | -------------------------------------------------------------------------------- /COCBot/functions/Main Screen/waitMainScreen.au3: -------------------------------------------------------------------------------- 1 | ;Waits 5 minutes for the pixel of mainscreen to be located, checks for obstacles every 2 seconds. 2 | ;After five minutes, will try to restart bluestacks. 3 | 4 | Func waitMainScreen() ;Waits for main screen to popup 5 | If ($ichkForceBS) = 1 Then 6 | WinActivate($HWnD) 7 | EndIf 8 | SetLog(GetLangText("msgWaitMS"), $COLOR_ORANGE) 9 | For $i = 0 To 150 ;150*2000 = 5 Minutes 10 | _CaptureRegion() 11 | If Not _ColorCheck(_GetPixelColor(284, 28), Hex(0x41B1CD, 6), 20) Then ;Checks for Main Screen 12 | If _Sleep(2000) Then Return 13 | ;If checkObstacles() Then $i = 0 ;See if there is anything in the way of mainscreen 14 | checkObstacles() ;in case of bluestack freeze, this may become dead loop. Just stick to 5 minutes waiting 15 | Else 16 | Return 17 | EndIf 18 | Next 19 | 20 | SetLog(GetLangText("msgUnableLoad"), $COLOR_RED) 21 | If Not restartBlueStack() Then Return 22 | EndFunc ;==>waitMainScreen 23 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/boolPixelSearch.au3: -------------------------------------------------------------------------------- 1 | ;============================================================================================================== 2 | ;===Check Pixels=============================================================================================== 3 | ;-------------------------------------------------------------------------------------------------------------- 4 | ;Using _ColorCheck, checks compares multiple pixels and returns true if they all pass _ColorCheck. 5 | ;-------------------------------------------------------------------------------------------------------------- 6 | 7 | Func boolPixelSearch($pixel1, $pixel2, $pixel3, $variation = 10) 8 | If _ColorCheck(_GetPixelColor($pixel1[0], $pixel1[1]), $pixel1[2], $variation) And _ColorCheck(_GetPixelColor($pixel2[0], $pixel2[1]), $pixel2[2], $variation) And _ColorCheck(_GetPixelColor($pixel3[0], $pixel3[1]), $pixel3[2], $variation) Then Return True 9 | Return False 10 | EndFunc ;==>boolPixelSearch 11 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/ReadText.au3: -------------------------------------------------------------------------------- 1 | Global Enum $textChat = 1, $textMainScreen, $textVillageSearch, $textReturnHome, $textWindows, $textWindowTitles, $textChatUser, $textDeployNumber 2 | Global $textConstants[9][2] = [[0, ""], [10, "chatlog"], [12, "mainscreen"], [12, "villagesearch"], [16, "returnhome"], [10, "smallwindow"], [16, "smallwindowtitle"], [10, "chatuser"], [13, "deploynumber"]] 3 | 4 | Func ReadText($x, $y, $width, $type, $leftaligned = 1, $reversed = 0) 5 | $height = $textConstants[$type][0] 6 | $name = $textConstants[$type][1] 7 | $Result = CallHelper("0 0 860 720 BrokenBotReadText " & $x & " " & $y & " " & $width & " " & $height & " " & $type & " " & $leftaligned & " " & $reversed, 3) 8 | If $Result = $DLLFailed or $Result = $DLLTimeout or $Result = $DLLNegative Then 9 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 10 | Return -1 11 | ElseIf $Result = $DLLLicense Then 12 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 13 | Return -1 14 | Else 15 | Return $Result 16 | EndIf 17 | EndFunc 18 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Dummy/GUIDesign.au3: -------------------------------------------------------------------------------- 1 | Func Dummy_LoadGUI() 2 | ; Required prior to making new tabs 3 | $frmAttackConfig = GUICreate("Attack config panel", 410, 410, -1, -1, $WS_BORDER + $WS_POPUP, $WS_EX_MDICHILD, $frmBot) 4 | Opt('GUIResizeMode', 802) 5 | GUISetState(@SW_HIDE, $frmAttackConfig) 6 | _WinMoved(0, 0, 0, 0) 7 | GUISwitch($frmAttackConfig) 8 | 9 | ; $tabStrat = GUICtrlCreateTab(10, 10, 415, 550) 10 | ; 11 | ; 12 | ; 13 | ; GUI goes in here 14 | ; 15 | ; 16 | ; 17 | ; GUICtrlCreateTabItem("") 18 | 19 | ; Load your configuration 20 | Dummy_LoadConfig() 21 | 22 | ; Declare gui-control functions that require WM_COMMAND here 23 | ;Global $PluginEvents[2][3] 24 | ;$PluginEvents[0][0]=1 ; Number of functions 25 | ;$PluginEvents[1][0]=$control ; Control name 26 | ;$PluginEvents[1][1]=1 ; Windows notification code 27 | ;$PluginEvents[1][2]="_Function" ; Function to call ie. Dummy_Function 28 | 29 | ; Return the handle to the default control you want activated 30 | Return $defaultcontrol 31 | EndFunc ;==>Dummy_LoadGUI 32 | -------------------------------------------------------------------------------- /curl/curl license.txt: -------------------------------------------------------------------------------- 1 | COPYRIGHT AND PERMISSION NOTICE 2 | 3 | Copyright (c) 1996 - 2015, Daniel Stenberg, daniel@haxx.se. 4 | 5 | All rights reserved. 6 | 7 | Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. -------------------------------------------------------------------------------- /BrokenBot.org/functions/GUI/WindowFixing.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func _WinMoved($hWndGUI, $MsgID, $WParam, $LParam) 7 | $curWinLoc = WinGetPos($frmBot) 8 | If ($curWinLoc[0] + 208) < (@DesktopWidth / 2) Then 9 | ; On left side of screen 10 | WinMove($frmAttackConfig, "", $curWinLoc[0] + 426, $curWinLoc[1], 435, $curWinLoc[3]) 11 | $slideOut = 0x00040001 12 | $slideIn = 0x00050002 13 | Else 14 | ; On right side of screen 15 | WinMove($frmAttackConfig, "", $curWinLoc[0] - 439, $curWinLoc[1], 435, $curWinLoc[3]) 16 | $slideOut = 0x00040002 17 | $slideIn = 0x00050001 18 | EndIf 19 | EndFunc ;==>_WinMoved 20 | 21 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/_MultiPixelSearch.au3: -------------------------------------------------------------------------------- 1 | ;Uses multiple pixels with coordinates of each color in a certain region, works for memory BMP 2 | 3 | ;$xSkip and $ySkip for numbers of pixels skip 4 | ;$offColor[2][COLOR/OFFSETX/OFFSETY] offset relative to firstColor coordination 5 | 6 | Func _MultiPixelSearch($iLeft, $iTop, $iRight, $iBottom, $xSkip, $ySkip, $firstColor, $offColor, $iColorVariation) 7 | _CaptureRegion($iLeft, $iTop, $iRight, $iBottom) 8 | For $x = 0 To $iRight - $iLeft Step $xSkip 9 | For $y = 0 To $iBottom - $iTop Step $ySkip 10 | If _ColorCheck(_GetPixelColor($x, $y), $firstColor, $iColorVariation) Then 11 | Local $allchecked = True 12 | For $i = 0 To UBound($offColor) - 1 13 | If _ColorCheck(_GetPixelColor($x + $offColor[$i][1], $y + $offColor[$i][2]), Hex($offColor[$i][0], 6), $iColorVariation) = False Then 14 | $allchecked = False 15 | ExitLoop 16 | EndIf 17 | Next 18 | If $allchecked Then 19 | Local $Pos[2] = [$iLeft + $x, $iTop + $y] 20 | Return $Pos 21 | EndIf 22 | EndIf 23 | Next 24 | Next 25 | Return 0 26 | EndFunc ;==>_MultiPixelSearch 27 | -------------------------------------------------------------------------------- /COCBot/functions/Other/_Sleep.au3: -------------------------------------------------------------------------------- 1 | ; Pauses exectution for number of milliseconds 2 | ; Returns True if bot no longer running 3 | 4 | Func _Sleep($iDelay, $iSleep = True, $ReturnIfStopped = True) 5 | Local $iBegin = TimerInit() 6 | Local $count = 0 7 | While TimerDiff($iBegin) < $iDelay 8 | If $ReturnIfStopped Then 9 | If BitAND(GUICtrlGetState($btnStop), $GUI_HIDE) Then Return True 10 | EndIf 11 | While GUICtrlRead($btnPause) = "Resume" 12 | $count += 1 13 | If Mod($count, 600) = 0 Then _BumpMouse() 14 | If _GUICtrlTab_GetCurSel($tabMain) = 0 Then 15 | ControlShow("", "", $txtLog) 16 | Else 17 | ControlHide("", "", $txtLog) 18 | EndIf 19 | If $iSleep = True Then _ModifiedSleep(50) 20 | WEnd 21 | If _GUICtrlTab_GetCurSel($tabMain) = 0 Then 22 | ControlShow("", "", $txtLog) 23 | Else 24 | ControlHide("", "", $txtLog) 25 | EndIf 26 | If $iSleep = True Then 27 | _ModifiedSleep(50) 28 | Else 29 | _ModifiedSleep(1) 30 | EndIf 31 | WEnd 32 | Return False 33 | EndFunc ;==>_Sleep 34 | 35 | Func _ModifiedSleep($T) 36 | DllCall($KernelDLL, "none", "Sleep", "long", $T) 37 | EndFunc ;==>_ModifiedSLeep -------------------------------------------------------------------------------- /COCBot/functions/Other/SetLog.au3: -------------------------------------------------------------------------------- 1 | Func SetLog($String, $Color = 0x000000) ;Sets the text for the log 2 | _GUICtrlRichEdit_AppendTextColor($txtLog, Time(), 0x000000) 3 | _GUICtrlRichEdit_AppendTextColor($txtLog, $String & @CRLF, _ColorConvert($Color)) 4 | _GUICtrlStatusBar_SetText($statLog, "Status : " & $String) 5 | _FileWriteLog($hLogFileHandle, $String) 6 | EndFunc ;==>SetLog 7 | 8 | Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) 9 | Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) 10 | Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) 11 | _GUICtrlRichEdit_SetFont($hWnd, $FontSize) 12 | _GUICtrlRichEdit_AppendText($hWnd, $sText) 13 | _GUICtrlRichEdit_SetSel($hWnd, $iCp - 1, $iLength + StringLen($sText)) 14 | _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) 15 | _GUICtrlRichEdit_Deselect($hWnd) 16 | EndFunc ;==>_GUICtrlRichEdit_AppendTextColor 17 | 18 | Func _ColorConvert($nColor);RGB to BGR or BGR to RGB 19 | Return _ 20 | BitOR(BitShift(BitAND($nColor, 0x000000FF), -16), _ 21 | BitAND($nColor, 0x0000FF00), _ 22 | BitShift(BitAND($nColor, 0x00FF0000), 16)) 23 | EndFunc ;==>_ColorConvert 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BrokenBot.org - Clash of Clans Bot 2 | Best Free Clash of Clans Bot - Brokenbot https://brokenbot.org 3 | 4 | ## Community 5 | CoC Bot Forums - https://brokenbot.org/forum 6 | 7 | ### Repo status 8 | This repository is no longer maintained. Please visit the links above for current versions. 9 | 10 | ### Credit 11 | Much thanks to: the original creators of this bot at gamebot.org, clashbot.org, cool7su, maxcom, msh2050, usabug, cmestres, samkhowaja and anyone else who I missed but has contributed to this great project! 12 | 13 | Original source from which this is modified (project originally started at gamebot.org): 14 | Modification of v5.8 of bot originally available from http://clashbot.org/forums/index.php?/topic/1010-flawless-clashbot-release-58-recommended/ 15 | 16 | ### License 17 | This project is under GPLv3 licensing - **BUT**- due to the convoluted nature of the origin of this code, a separate license specific to changes made by the BrokenBot.org team is available in the BrokenBot.org directory and applies only to that sub-directory (recursively). 18 | 19 | ---------- 20 | Clash of Clans is a Registered Trademark of SuperCell. This project is not affiliated with SuperCell or any of its affiliates in any way. Project is available without warranty express or implied. 21 | -------------------------------------------------------------------------------- /COCBot/functions/Strategies/Standard/AdjustCollPos.au3: -------------------------------------------------------------------------------- 1 | Func Standard_RemoveInsideCollectors(ByRef $count, ByRef $arCollectors, $maxDistance) 2 | ; From each collector we will check in 8 directions for closest point outside red lines 3 | ; If further than $maxDistance then we will drop this collector from the list 4 | Local $colindex = 0 5 | Do 6 | If CloseToEdge($arCollectors[$colindex][1], $arCollectors[$colindex][2], $maxDistance) Then 7 | $colindex += 1 8 | Else 9 | ; This wasn't a close enough collector so remove it 10 | OverlayX($arCollectors[$colindex][1] - 20, $arCollectors[$colindex][2] - 20, 40, 40, 0xFFFF0000, 3) 11 | If $DebugMode = 1 Then SetLog(GetLangText("msgRemoveCol") & (($arCollectors[$colindex][0] = 14) ? (GetLangText("msgColGM")) : (($arCollectors[$colindex][0] = 15) ? (GetLangText("msgColElix")) : (GetLangText("msgColDE")))) & " (" & $arCollectors[$colindex][1] & ", " & $arCollectors[$colindex][2] & ")") 12 | For $move = $colindex + 1 To $count - 1 13 | $arCollectors[$move - 1][0] = $arCollectors[$move][0] 14 | $arCollectors[$move - 1][1] = $arCollectors[$move][1] 15 | $arCollectors[$move - 1][2] = $arCollectors[$move][2] 16 | Next 17 | $count -= 1 18 | EndIf 19 | Until $colindex >= $count 20 | EndFunc ;==>Standard_RemoveInsideCollectors 21 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/GUI/frmBugReport.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | $frmBugReport = GUICreate(GetLangText("frmBugReport"), 400, 500, -1, -1, $DS_MODALFRAME);, -1, $frmBot) 7 | $lblInstructions = GUICtrlCreateLabel(GetLangText("lblInstructions"), 20, 10, 360, 135) 8 | $lblLog = GUICtrlCreateLabel(GetLangText("lblLog"), 20, 145, 220, 18) 9 | $inpLog = GUICtrlCreateEdit("", 20, 165, 360, 120, $WS_VSCROLL + $ES_MULTILINE + $ES_READONLY) 10 | $lblSettings = GUICtrlCreateLabel(GetLangText("lblSettings"), 20, 290, 150, 18) 11 | $inpSettings = GUICtrlCreateEdit("", 20, 310, 360, 120, $WS_VSCROLL + $ES_MULTILINE + $ES_READONLY) 12 | $btnGitHub = GUICtrlCreateButton(GetLangText("btnGitHub"), 20, 440, 170, 25) 13 | $btnCloseBR = GUICtrlCreateButton(GetLangText("btnCloseBR"), 210, 440, 170, 25) 14 | GUISetState(@SW_HIDE, $frmBugReport) 15 | -------------------------------------------------------------------------------- /COCBot/functions/Village/RequestCC.au3: -------------------------------------------------------------------------------- 1 | Func RequestCC() 2 | If IsChecked($chkRequest) Then 3 | If $CCPos[0] = "" Then 4 | If Not LocateClanCastle() Then Return 5 | SaveConfig() 6 | If _Sleep(1000) Then Return 7 | EndIf 8 | While 1 9 | SetLog(GetLangText("msgRequesting"), $COLOR_BLUE) 10 | Click($CCPos[0], $CCPos[1]) 11 | If _Sleep(1000) Then ExitLoop 12 | _CaptureRegion() 13 | $RequestTroop = _PixelSearch(310, 580, 553, 622, Hex(0x608C90, 6), 10) 14 | If IsArray($RequestTroop) Then 15 | Click($RequestTroop[0], $RequestTroop[1]) 16 | If _Sleep(1000) Then ExitLoop 17 | _CaptureRegion() 18 | If _ColorCheck(_GetPixelColor(340, 245), Hex(0xCC4010, 6), 20) Then 19 | If GUICtrlRead($txtRequest) <> "" Then 20 | Click(430, 140) ;Select text for request 21 | If _Sleep(1000) Then ExitLoop 22 | $TextRequest = GUICtrlRead($txtRequest) 23 | ControlSend($Title, "", "", $TextRequest, 0) 24 | EndIf 25 | If _Sleep(1000) Then ExitLoop 26 | Click(524, 228) 27 | ;Click(340, 228) 28 | Else 29 | SetLog(GetLangText("msgRequestAlready"), $COLOR_ORANGE) 30 | Click(1, 1, 2) 31 | EndIf 32 | Else 33 | SetLog(GetLangText("msgCCNotAvail"), $COLOR_RED) 34 | EndIf 35 | ExitLoop 36 | WEnd 37 | EndIf 38 | EndFunc ;==>RequestCC 39 | -------------------------------------------------------------------------------- /COCBot/functions/Main Screen/checkMainScreen.au3: -------------------------------------------------------------------------------- 1 | ;This function checks whether the pixel, located in the eyes of the builder in mainscreen, is available 2 | ;If it is not available, it calls checkObstacles and also waitMainScreen. 3 | 4 | Func checkMainScreen($Check = False, $maxDelay = 1) ;Checks if in main screen 5 | If $Check = True Then SetLog(GetLangText("msgMSTry"), $COLOR_BLUE) 6 | _WinAPI_EmptyWorkingSet(WinGetProcess($Title)) ; Reduce BlueStacks Memory Usage 7 | 8 | If Not _WaitForColor(284, 28, Hex(0x41B1CD, 6), 20, $maxDelay) Then 9 | While _ColorCheck(_GetPixelColor(284, 28), Hex(0x41B1CD, 6), 20) = False 10 | $HWnD = WinGetHandle($Title) 11 | If (Not checkObstacles()) And (BitAND(GUICtrlGetState($btnStart), $GUI_HIDE)) Then 12 | Click(126, 700, 1, 500) 13 | Local $RunApp = StringReplace(_WinAPI_GetProcessFileName(WinGetProcess($Title)), "Frontend", "RunApp") 14 | Run($RunApp & " -p com.supercell.clashofclans -a com.supercell.clashofclans.GameApp") 15 | EndIf 16 | If _Sleep(3000) Then Return False 17 | waitMainScreen() 18 | WEnd 19 | EndIf 20 | If $Check = True Then SetLog(GetLangText("msgMSLocated"), $COLOR_BLUE) 21 | If Not ZoomOut() Then 22 | SetLog(GetLangText("msgMSFailed"), $COLOR_BLUE) 23 | Return False 24 | Else 25 | Return True 26 | EndIf 27 | 28 | EndFunc ;==>checkMainScreen 29 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/functions.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | #include "GUI\frmAttackConfig.au3" 7 | #include "GUI\frmBugReport.au3" 8 | #include "GUI\WindowFixing.au3" 9 | 10 | #include "ImageSearch\checkDarkElix.au3" 11 | #include "ImageSearch\checkTownhall.au3" 12 | 13 | #include "Other\CallHelper.au3" 14 | #include "Other\checkupdate.au3" 15 | #include "Other\GeneralFunctions.au3" 16 | #include "Other\HSL.au3" 17 | #include "Other\maths.au3" 18 | #include "Other\overlay.au3" 19 | #include "Other\RedLineMath.au3" 20 | #include "Other\ReadChatLog.au3" 21 | #include "Other\ReadText.au3" 22 | #include "Other\statsubmission.au3" 23 | #include "Other\StatusCheck.au3" 24 | 25 | #include "Strategies\LoadDefaults.au3" 26 | #include "Strategies\Strategies.au3" 27 | 28 | #include "Village\TroopSize.au3" 29 | #include "Village\collectResources.au3" 30 | #include "Village\clearField.au3" 31 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/LoadDefaults.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func _PluginDefaults() 7 | $arStrats = StringSplit($StratNames, "|") 8 | For $i = 1 To $arStrats[0] 9 | $searchfile = FileFindFirstFile($dirStrat & "*.ini") 10 | $found = False 11 | While True 12 | $newfile = FileFindNextFile($searchfile) 13 | If @error Then ExitLoop 14 | $strPlugInRead = IniRead($dirStrat & $newfile, "plugin", "name", "") 15 | If $strPlugInRead = $arStrats[$i] Then 16 | $found = True 17 | ExitLoop 18 | EndIf 19 | WEnd 20 | If Not $found Then 21 | SetLog(GetLangText("msgNoDataFound") & $arStrats[$i] & GetLangText("msgNoDefaults")) 22 | Call($arStrats[$i] & "_LoadGUI") 23 | Call($arStrats[$i] & "_SaveConfig", $dirStrat & $arStrats[$i] & " - default.ini") 24 | GUIDelete($frmAttackConfig) 25 | EndIf 26 | FileClose($searchfile) 27 | Next 28 | EndFunc ;==>_PluginDefaults 29 | -------------------------------------------------------------------------------- /COCBot/functions/Village/CheckFullSpellFactory.au3: -------------------------------------------------------------------------------- 1 | Func CheckFullSpellFactory() 2 | SetLog(GetLangText("msgCheckingSF"), $COLOR_BLUE) 3 | $fullSpellFactory = False 4 | 5 | If _Sleep(100) Then Return 6 | 7 | ClickP($TopLeftClient) ;Click Away 8 | 9 | If $SpellPos[0] = "" Then 10 | If Not LocateSpellFactory() Then Return 11 | SaveConfig() 12 | Else 13 | If _Sleep(100) Then Return 14 | Click($SpellPos[0], $SpellPos[1]) ;Click Spell Factory 15 | EndIf 16 | 17 | Local $BSpellPos = _WaitForPixel(214, 581, 368, 583, Hex(0x4084B8, 6), 5, 1) ;Finds Info button 18 | If IsArray($BSpellPos) = False Then 19 | SetLog(GetLangText("msgSFUnavailable"), $COLOR_RED) 20 | If $DebugMode = 2 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "SpellNA-" & @HOUR & @MIN & @SEC & ".png") 21 | Else 22 | Click($BSpellPos[0], $BSpellPos[1]) ;Click Info button 23 | ;If _Sleep(2000) Then Return 24 | _WaitForPixel(690, 150, 710, 170, Hex(0xD80407, 6), 5, 1) ;Finds Red Cross button in new popup window 25 | 26 | _CaptureRegion() 27 | Local $Spellbar = _PixelSearch(707, 210, 709, 213, Hex(0x37A800, 6), 5) 28 | ClickP($TopLeftClient) ;Click Away 29 | If IsArray($Spellbar) Then 30 | $fullSpellFactory = True 31 | SetLog(GetLangText("msgSpellFull"), $COLOR_RED) 32 | EndIf 33 | ClickP($TopLeftClient) ;Click Away 34 | Return $fullSpellFactory 35 | EndIf 36 | 37 | EndFunc ;==>CheckFullSpellFactory 38 | -------------------------------------------------------------------------------- /BrokenBot.org/README.md: -------------------------------------------------------------------------------- 1 | ## BrokenBot.org - Clash of Clans Bot 2 | 3 | ### Community 4 | Forums available for discussion at: http://BrokenBot.org 5 | 6 | ### Reference 7 | For your convenience, and referring to pushbullet's document: 8 | https://docs.pushbullet.com/ 9 | 10 | ### BrokenBot.org Contributors 11 | - codebroken - Filipino 12 | - cool7su - AutoIt Development 13 | - maxcom - AutoIt Development, Web Presence 14 | - msh2050 - AutoIt Development 15 | - usabug - AutoIt Development 16 | - cmestres - AutoIt Development 17 | - samkhowaja - Graphic Design 18 | 19 | ### License 20 | ANY and ALL code included (recursively) in this sub-directory of the project is Under GPLv3 with the following modification: 21 | 22 | - This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 23 | - This code can be incorporated into open source/non-profit projects free of charge and without consent. 24 | - **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 25 | - You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 26 | 27 | ---------- 28 | Clash of Clans is a Registered Trademark of SuperCell. This project is not affiliated with SuperCell or any of its affiliates in any way. Project is available without warranty express or implied. 29 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/checkButtonUpgrade.au3: -------------------------------------------------------------------------------- 1 | Global $checkUpgradelogic 2 | Global $Building[5] 3 | 4 | $Building[0] = @ScriptDir & "\images\Building\upgrade.bmp" 5 | $Building[1] = @ScriptDir & "\images\Building\upgrade1.bmp" 6 | $Building[2] = @ScriptDir & "\images\Building\upgrade2.bmp" 7 | $Building[3] = @ScriptDir & "\images\Building\upgrade3.bmp" 8 | $Building[4] = @ScriptDir & "\images\Building\okay.bmp" 9 | Global $BuildLoc 10 | Global $Tolerance2 11 | 12 | Func checkButtonUpgrade() 13 | Switch _GUICtrlComboBox_GetCurSel($cmbTolerance) 14 | Case 0 15 | $Tolerance2 = 55 16 | Case 1 17 | $Tolerance2 = 35 18 | Case 2 19 | $Tolerance2 = 100 20 | EndSwitch 21 | #cs 22 | If _Sleep(500) Then Return 23 | _CaptureRegion() 24 | For $i = 0 To 4 25 | ; Getting TH Location 26 | If $THLocation = 1 Then 27 | Return $THText[$i] 28 | EndIf 29 | Next 30 | If $THLocation = 0 Then Return "-" 31 | #ce 32 | If _Sleep(500) Then Return 33 | For $i = 0 To 4 34 | _CaptureRegion() 35 | ; $WallLoc = _ImageSearch($Building[$icmbWalls], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall Location 36 | $BuildLoc = _ImageSearch($Building[$i], 1, $txtUpgradeX1, $txtUpgradeY1, $Tolerance2) ; Getting Button upgrade Location 37 | 38 | SetLog(GetLangText("msgUpgrading"), $COLOR_ORANGE) 39 | $checkUpgradelogic = True 40 | Return True 41 | 42 | Next 43 | $checkUpgradelogic = False 44 | SetLog(GetLangText("msgNoUpgradeButton"), $COLOR_RED) 45 | Return False 46 | EndFunc ;==>checkButtonUpgrade 47 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Village/TroopSize.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ; Returns the camp size of a given troop 7 | 8 | Func getTroopSize($troop) 9 | Switch $troop 10 | Case 0, "barb", "barbarian", "B", "Ba" 11 | Return 1 12 | Case 1, "arch", "archer", "Ar", "Arch" 13 | Return 1 14 | Case 2, "gob", "goblin", "Gob" 15 | Return 1 16 | Case 3, "giant", "Gi", "G" 17 | Return 5 18 | Case 4, "Wa", "WB", "wb", "wall breaker" 19 | Return 2 20 | Case 5, "loon", "balloon", "Loon" 21 | Return 5 22 | Case 6, "wiz", "wizard" 23 | Return 4 24 | Case 7, "He", "Heal", "healer" 25 | Return 14 26 | Case 8, "drag", "dragon" 27 | Return 20 28 | Case 9, "Pe", "pekka" 29 | Return 25 30 | Case 10, "min", "minion", "Min" 31 | Return 2 32 | Case 11, "hog", "hogger", "hog rider", "pigger", "Ho" 33 | Return 5 34 | Case 12, "valk", "valkyrie", "Val" 35 | Return 1 36 | Case 13, "Go", "golem" 37 | Return 30 38 | Case 14, "witch" 39 | Return 12 40 | Case Else 41 | Return 999 42 | EndSwitch 43 | EndFunc ;==>getTroopSize 44 | -------------------------------------------------------------------------------- /COCBot/functions/Village/BoostBarracks.au3: -------------------------------------------------------------------------------- 1 | ;==>BoostBarracks 2 | Func BoostBarracks() 3 | If (GUICtrlRead($cmbBoostBarracks) > 0) And ($boostsEnabled = 1) Then 4 | If $barrackPos[0][0] = "" Then 5 | If Not LocateBarrack() Then Return 6 | SaveConfig() 7 | If _Sleep(2000) Then Return 8 | EndIf 9 | While 1 10 | SetLog(GetLangText("msgBoostingBarracks"), $COLOR_BLUE) 11 | 12 | 13 | Click(1, 1) 14 | If _Sleep(1000) Then ExitLoop 15 | Click($barrackPos[0][0], $barrackPos[0][1]) 16 | If _Sleep(1000) Then ExitLoop 17 | _CaptureRegion() 18 | $Boost = _PixelSearch(410, 603, 493, 621, Hex(0xfffd70, 6), 10) 19 | If IsArray($Boost) Then 20 | Click($Boost[0], $Boost[1]) 21 | If _Sleep(1000) Then Return 22 | _CaptureRegion() 23 | If _ColorCheck(_GetPixelColor(420, 375), Hex(0xd2ec78, 6), 20) Then 24 | Click(420, 375) 25 | If _Sleep(2000) Then Return 26 | _CaptureRegion() 27 | If _ColorCheck(_GetPixelColor(586, 267), Hex(0xd80405, 6), 20) Then 28 | _GUICtrlComboBox_SetCurSel($cmbBoostBarracks, 0) 29 | SetLog(GetLangText("msgNotEnoughGem"), $COLOR_RED) 30 | Else 31 | _GUICtrlComboBox_SetCurSel($cmbBoostBarracks, (GUICtrlRead($cmbBoostBarracks) - 1)) 32 | SetLog(GetLangText("msgBoostCompRem") & (GUICtrlRead($cmbBoostBarracks)), $COLOR_GREEN) 33 | EndIf 34 | Else 35 | SetLog(GetLangText("msgBarracksAlready"), $COLOR_ORANGE) 36 | EndIf 37 | If _Sleep(500) Then ExitLoop 38 | Click(1, 1) 39 | Else 40 | SetLog(GetLangText("msgBarracksAlready"), $COLOR_ORANGE) 41 | If _Sleep(1000) Then Return 42 | EndIf 43 | 44 | ExitLoop 45 | WEnd 46 | EndIf 47 | 48 | 49 | EndFunc ;==>BoostBarracks 50 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/StatusCheck.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func StatusCheck($OnMainScreen = True, $WriteLog = False, $maxDelay = 1) 7 | ; Allows for pauses 8 | ; Checks for main screen if $OnMainScreen=True 9 | ; If unable to find zoomed out main screen after resuming, it will continue looping until such time as it does 10 | ; Returns True if bot no longer running after completion. 11 | If Pause() Then Return 12 | If $OnMainScreen Then 13 | Local $waitCounter = 0 14 | While Not checkMainScreen($WriteLog, $maxDelay) 15 | If $waitCounter > 5 Then ;5 minutes passed 16 | restartBlueStack() 17 | $waitCounter = 0 18 | EndIf 19 | If BotStopped(False) Then Return True 20 | SetLog(GetLangText("msgFailedZoomout"), $COLOR_RED) 21 | SetLog(GetLangText("msgWaitMinute"), $COLOR_RED) 22 | If _Sleep(6000) Then Return False 23 | $waitCounter += 1 24 | WEnd 25 | If $PauseBot = True And GUICtrlRead($btnPause) = "Pause" Then btnPause() 26 | If $PauseBot = False And GUICtrlRead($btnPause) = "Resume" Then btnPause() 27 | EndIf 28 | If Pause() Then Return 29 | If BotStopped($OnMainScreen) Then 30 | Return True 31 | Else 32 | Return False 33 | EndIf 34 | EndFunc ;==>StatusCheck 35 | 36 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/checkTownhall.au3: -------------------------------------------------------------------------------- 1 | Func checkTownhall() 2 | $bumpTolerance = 70 3 | If _Sleep(500) Then Return 4 | Do 5 | _CaptureRegion() 6 | For $i = 1 To 50 7 | If FileExists(@ScriptDir & "\images\TH\townhall" & String($i) & ".bmp") Then 8 | $THLocation = _ImageSearch(@ScriptDir & "\images\TH\townhall" & String($i) & ".bmp", 1, $THx, $THy, $bumpTolerance) ; Getting TH Location 9 | If $THLocation = 1 Then 10 | If ((((65 - 280) / (367 - 78)) * ($THx - 78)) + 280 > $THy) Or ((((277 - 62) / (780 - 481)) * ($THx - 481)) + 62 > $THy) Or ((((540 - 343) / (338 - 78)) * ($THx - 78)) + 343 < $THy) Or ((((345 - 538) / (780 - 524)) * ($THx - 524)) + 538 < $THy) Then 11 | $THLocation = 0 12 | $THx = 0 13 | $THy = 0 14 | EndIf 15 | EndIf 16 | If $THLocation = 1 Then 17 | If $DebugMode = 1 Then 18 | $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $THx - 30, $THy - 30, 60, 60, _GDIPlus_ImageGetPixelFormat($hBitmap)) 19 | $j = 1 20 | Do 21 | If Not FileExists($dirDebug & "PosTH-" & $THText[Floor(($i - 1) / 10)] & "-" & $bumpTolerance & "(" & $j & ").jpg") Then ExitLoop 22 | $j = $j + 1 23 | Until $j = 1000 24 | _GDIPlus_ImageSaveToFile($hClone, $dirDebug & "PosTH-" & $THText[Floor(($i - 1) / 10)] & "(" & $j & ").jpg") 25 | _GDIPlus_ImageDispose($hClone) 26 | EndIf 27 | Return $THText[Floor(($i - 1) / 10)] 28 | EndIf 29 | EndIf 30 | Next 31 | $bumpTolerance += 5 32 | Until $bumpTolerance > 80 33 | If $THLocation = 0 Then 34 | If $DebugMode = 1 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "NegTH-" & @HOUR & @MIN & @SEC & ".png") 35 | Return "-" 36 | EndIf 37 | EndFunc ;==>checkTownhall 38 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/_CaptureRegion.au3: -------------------------------------------------------------------------------- 1 | ;Saves a screenshot of the window into memory. 2 | 3 | Func _CaptureRegion($iLeft = 0, $iTop = 0, $iRight = 860, $iBottom = 720, $ReturnBMP = False, $NeedMove = False) 4 | _GDIPlus_BitmapDispose($hBitmap) 5 | _WinAPI_DeleteObject($hHBitmap) 6 | 7 | If IsChecked($chkBackground) Then 8 | Local $iW = Number($iRight) - Number($iLeft), $iH = Number($iBottom) - Number($iTop) 9 | 10 | Local $hDC_Capture = _WinAPI_GetWindowDC(ControlGetHandle($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]")) 11 | Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture) 12 | $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW, $iH) 13 | Local $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) 14 | 15 | DllCall("user32.dll", "int", "PrintWindow", "hwnd", $HWnD, "handle", $hMemDC, "int", 0) 16 | _WinAPI_SelectObject($hMemDC, $hHBitmap) 17 | _WinAPI_BitBlt($hMemDC, 0, 0, $iW, $iH, $hDC_Capture, $iLeft, $iTop, 0x00CC0020) 18 | 19 | Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) 20 | 21 | _WinAPI_DeleteDC($hMemDC) 22 | _WinAPI_SelectObject($hMemDC, $hObjectOld) 23 | _WinAPI_ReleaseDC($HWnD, $hDC_Capture) 24 | Else 25 | If $OverlayVisible And $NeedMove Then 26 | WinMove($frmOverlay, "", 10000, 10000, 860, 720) 27 | EndIf 28 | getBSPos() 29 | $hHBitmap = _ScreenCapture_Capture("", $iLeft + $BSpos[0], $iTop + $BSpos[1], $iRight + $BSpos[0], $iBottom + $BSpos[1]) 30 | Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) 31 | If $OverlayVisible And $NeedMove Then 32 | WinMove($frmOverlay, "", $BSpos[0], $BSpos[1], 860, 720) 33 | EndIf 34 | EndIf 35 | 36 | If $ReturnBMP Then Return $hBitmap 37 | EndFunc ;==>_CaptureRegion 38 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Village/collectResources.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func collectResources() 7 | Local $i, $j = 0 8 | Local $foundResource = False 9 | If $ichkCollect = 1 Then 10 | SetLog(GetLangText("msgCollecting"), $COLOR_BLUE) 11 | Do 12 | $res = CallHelper("0 0 860 720 BrokenBotMatchObject 27 17 1") 13 | If $res <> $DLLFailed And $res <> $DLLTimeout And $res <> $DLLError Then 14 | If $res = $DLLLicense Then 15 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 16 | ElseIf $res = $DLLNegative And Not $foundResource Then 17 | ; failed to find Resources 18 | SetLog(GetLangText("msgNoResources"), $COLOR_RED) 19 | $ResX = 0 20 | $ResY = 0 21 | ExitLoop 22 | Else 23 | $expRet = StringSplit($res, "|", 2) 24 | $numBldg = $expRet[0] 25 | For $j = 1 To UBound($expRet) - 1 Step 6 26 | $ResX = $expRet[$j] 27 | $ResY = $expRet[$j + 1] 28 | If $ResX = 0 And $ResY = 0 Then ExitLoop 29 | If $DebugMode = 1 Then SetLog("Total " & $numBldg & " Resources. X:" & $ResX & " Y:" & $ResY) 30 | Click($ResX, $ResY) 31 | Click(1, 1) 32 | Sleep(300) 33 | Next 34 | $foundResource = True 35 | EndIf 36 | Else 37 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 38 | $ResX = 0 39 | $ResY = 0 40 | Return False ; return 0 41 | EndIf 42 | $i += 1 43 | Until $i = 2 44 | EndIf 45 | Return 46 | EndFunc ;==>collectResources 47 | -------------------------------------------------------------------------------- /COCBot/functions/Village/CheckCostPerSearch.au3: -------------------------------------------------------------------------------- 1 | ;Will detect how much gold per search 2 | Func CheckCostPerSearch() 3 | 4 | If $SearchCost = 0 Then 5 | SetLog(GetLangText("msgCheckGold"), $COLOR_GREEN) 6 | 7 | If $TownHallPos[0] = "" Then 8 | If Not LocateTownHall() Then Return 9 | SaveConfig() 10 | EndIf 11 | 12 | ClickP($TopLeftClient, 2, 250); Click away twice with 250ms delay 13 | StatusCheck() 14 | 15 | Click($TownHallPos[0], $TownHallPos[1]) 16 | $Location = _WaitForPixel(240, 581, 484, 583, Hex(0x4084B8, 6), 6, 2) 17 | 18 | If Not IsArray($Location) Then 19 | SetLog(GetLangText("msgFailedTH"), $COLOR_RED) 20 | Return 21 | Else 22 | Click($Location[0], $Location[1]) 23 | If Not _WaitForColor(698, 160, Hex(0xD80408, 6), 16, 2) Then 24 | SetLog(GetLangText("msgFailedTH"), $COLOR_RED) 25 | ClickP($TopLeftClient, 2, 250) 26 | Return 27 | Else 28 | $MenuBar = StringStripWS(ReadText(175, 138, 500, $textWindowTitles),3) 29 | $THLevel = Number(StringRegExpReplace(StringRight($MenuBar, 25),"[^0-9]","")) 30 | If $THLevel = "1" Then 31 | $SearchCost = 10 32 | ElseIf $THLevel = "2" Then 33 | $SearchCost = 50 34 | ElseIf $THLevel = "3" Then 35 | $SearchCost = 75 36 | ElseIf $THLevel = "4" Then 37 | $SearchCost = 110 38 | ElseIf $THLevel = "5" Then 39 | $SearchCost = 170 40 | ElseIf $THLevel = "6" Then 41 | $SearchCost = 250 42 | ElseIf $THLevel = "7" Then 43 | $SearchCost = 380 44 | ElseIf $THLevel = "8" Then 45 | $SearchCost = 580 46 | ElseIf $THLevel = "9" Then 47 | $SearchCost = 750 48 | ElseIf $THLevel = "10" Then 49 | $SearchCost = 1000 50 | EndIf 51 | 52 | SetLog(GetLangText("msgTHLevel") & $THLevel & GetLangText("msgGoldCPS") & $SearchCost, $COLOR_GREEN) 53 | EndIf 54 | EndIf 55 | ClickP($TopLeftClient, 2, 250); Click away twice with 250ms delay 56 | EndIf 57 | 58 | EndFunc ;==>CheckCostPerSearch 59 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/ImageSearch.au3: -------------------------------------------------------------------------------- 1 | Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $Tolerance) 2 | Return _ImageSearchArea($findImage, $resultPosition, 0, 0, 840, 720, $x, $y, $Tolerance) 3 | EndFunc ;==>_ImageSearch 4 | 5 | Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $Tolerance) 6 | Global $HBMP = $hHBitmap 7 | If Not IsChecked($chkBackground) Then 8 | $HBMP = 0 9 | $x1 += $BSPos[0] 10 | $y1 += $BSPos[1] 11 | $right += $BSPos[0] 12 | $bottom += $BSPos[1] 13 | EndIf 14 | ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) 15 | 16 | If IsString($findImage) Then 17 | If $Tolerance > 0 Then $findImage = "*" & $Tolerance & " " & $findImage 18 | If $HBMP = 0 Then 19 | $result = DllCall(@ScriptDir & "\COCBot.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage) 20 | Else 21 | $result = DllCall(@ScriptDir & "\COCBot.dll", "str", "ImageSearchEx", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage, "ptr", $HBMP) 22 | EndIf 23 | Else 24 | $result = DllCall(@ScriptDir & "\COCBot.dll", "str", "ImageSearchExt", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "int", $Tolerance, "ptr", $findImage, "ptr", $HBMP) 25 | EndIf 26 | 27 | ; If error exit 28 | If IsArray($result) Then 29 | If $result[0] = "0" Then Return 0 30 | Else 31 | SetLog(GetLangText("msgImageSearchNotWork"), $COLOR_RED) 32 | Return 1 33 | EndIf 34 | 35 | 36 | ; Otherwise get the x,y location of the match and the size of the image to 37 | ; compute the centre of search 38 | $array = StringSplit($result[0], "|") 39 | If (UBound($array) >= 4) Then 40 | $x = Int(Number($array[2])) 41 | $y = Int(Number($array[3])) 42 | If $resultPosition = 1 Then 43 | $x = $x + Int(Number($array[4]) / 2) 44 | $y = $y + Int(Number($array[5]) / 2) 45 | EndIf 46 | If $Hide = False Then 47 | $x -= $x1 48 | $y -= $y1 49 | EndIf 50 | Return 1 51 | EndIf 52 | EndFunc ;==>_ImageSearchArea 53 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/ImageSearch/checkDarkElix.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func checkDarkElix() 7 | _CaptureRegion() 8 | $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) 9 | $res = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotMatchBuilding", "ptr", $sendHBitmap, "int", 13, "int", 3, "int", 1, "int", 1, "int", (IsChecked($chkSpeedBoost) ? (1) : (0))) 10 | _WinAPI_DeleteObject($sendHBitmap) 11 | If IsArray($res) Then 12 | If $res[0] = -1 Then 13 | ; failed to find DE 14 | SetLog(GetLangText("msgNoDEStorage"), $COLOR_RED) 15 | If $DebugMode = 1 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "NegDE-" & @HOUR & @MIN & @SEC & ".png") 16 | $DEx = 0 17 | $DEy = 0 18 | Return False ; return 0 19 | ElseIf $res[0] = -2 Then 20 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 21 | Else 22 | $res = StringSplit($res[0], "|", 2) 23 | $DEx = $res[1] 24 | $DEy = $res[2] 25 | If $DebugMode = 1 Then 26 | $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $DEx - 30, $DEy - 30, 60, 60, _GDIPlus_ImageGetPixelFormat($hBitmap)) 27 | $j = 1 28 | Do 29 | If Not FileExists($dirDebug & "PosDE-x" & $DEx & "y" & $DEy & " (" & $j & ").jpg") Then ExitLoop 30 | $j = $j + 1 31 | Until $j = 1000 32 | _GDIPlus_ImageSaveToFile($hClone, $dirDebug & "PosDE-x" & $DEx & "y" & $DEy & " (" & $j & ").jpg") 33 | _GDIPlus_ImageDispose($hClone) 34 | EndIf 35 | Return True 36 | EndIf 37 | Else 38 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 39 | $DEx = 0 40 | $DEy = 0 41 | Return False ; return 0 42 | EndIf 43 | EndFunc ;==>checkDarkElix 44 | -------------------------------------------------------------------------------- /COCBot/functions/Pixels/_ColorCheck.au3: -------------------------------------------------------------------------------- 1 | ;============================================================================================================== 2 | ;============================================================================================================== 3 | ;===Color Variation============================================================================================ 4 | ;-------------------------------------------------------------------------------------------------------------- 5 | ;Checks if the color components exceed $sVari and returns true if they are below $sVari. 6 | ;-------------------------------------------------------------------------------------------------------------- 7 | 8 | Func _ColorCheck($nColor1, $nColor2, $sVari = 5) 9 | Local $Red1, $Red2, $Blue1, $Blue2, $Green1, $Green2 10 | 11 | $Red1 = Dec(StringMid(String($nColor1), 1, 2)) 12 | $Blue1 = Dec(StringMid(String($nColor1), 3, 2)) 13 | $Green1 = Dec(StringMid(String($nColor1), 5, 2)) 14 | 15 | $Red2 = Dec(StringMid(String($nColor2), 1, 2)) 16 | $Blue2 = Dec(StringMid(String($nColor2), 3, 2)) 17 | $Green2 = Dec(StringMid(String($nColor2), 5, 2)) 18 | 19 | If Abs($Blue1 - $Blue2) > $sVari Then Return False 20 | If Abs($Green1 - $Green2) > $sVari Then Return False 21 | If Abs($Red1 - $Red2) > $sVari Then Return False 22 | Return True 23 | EndFunc ;==>_ColorCheck 24 | 25 | ; CheckPixel : takes an array[4] as a parameter, [x, y, color, tolerance] 26 | Func CheckPixel($tab) 27 | If _ColorCheck(_GetPixelColor($tab[0], $tab[1]), Hex($tab[2], 6), $tab[3]) Then 28 | Return True 29 | Else 30 | If $DebugMode = 1 Then 31 | SetLog(GetLangText("msgLocationX") & $tab[0] & " Y:" & $tab[1], $COLOR_RED) 32 | SetLog(GetLangText("msgGot") & _GetPixelColor($tab[0], $tab[1]), $COLOR_RED) 33 | SetLog(GetLangText("msgWanted") & Hex($tab[2], 6), $COLOR_RED) 34 | SetLog(GetLangText("msgVariance") & $tab[3], $COLOR_RED) 35 | _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "Missedcolor-" & $tab[0] & "-" & $tab[1] & "-" & Hex($tab[2], 6) & "-" & _GetPixelColor($tab[0], $tab[1]) & ".png") 36 | EndIf 37 | 38 | Return False 39 | EndIf 40 | EndFunc ;==>CheckPixel 41 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/ImageSearch/checkTownhall.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func checkTownhall() 7 | $res = CallHelper("0 0 860 720 BrokenBotMatchBuilding 1 1 1") 8 | 9 | If $res = $DLLFailed or $res = $DLLTimeout or $res = $DLLError Then 10 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 11 | $THx = 0 12 | $THy = 0 13 | Return "-" ; return 0 14 | Else 15 | If $res = $DLLNegative Then 16 | ; failed to find TH 17 | If $DebugMode = 1 Then 18 | _CaptureRegion() 19 | _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "NegTH-" & @HOUR & @MIN & @SEC & ".png") 20 | EndIf 21 | $THx = 0 22 | $THy = 0 23 | Return "-" ; return 0 24 | ElseIf $res = $DLLLicense Then 25 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 26 | Else 27 | $res = StringSplit($res, "|", 2) 28 | If UBound($res) < 3 Then 29 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 30 | $THx = 0 31 | $THy = 0 32 | Return "-" ; return 0 33 | Else 34 | $THx = $res[1] 35 | $THy = $res[2] 36 | If $DebugMode = 1 Then 37 | _CaptureRegion() 38 | $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $THx - 30, $THy - 30, 60, 60, _GDIPlus_ImageGetPixelFormat($hBitmap)) 39 | $j = 1 40 | Do 41 | If Not FileExists($dirDebug & "PosTH-x" & $THx & "y" & $THy & " (" & $j & ").jpg") Then ExitLoop 42 | $j = $j + 1 43 | Until $j = 1000 44 | _GDIPlus_ImageSaveToFile($hClone, $dirDebug & "PosTH-x" & $THx & "y" & $THy & " (" & $j & ").jpg") 45 | _GDIPlus_ImageDispose($hClone) 46 | EndIf 47 | If $res[4] < 7 Then 48 | Return $THText[0] 49 | Else 50 | Return $THText[$res[4] - 6] 51 | EndIf 52 | EndIf 53 | EndIf 54 | EndIf 55 | EndFunc ;==>checkTownhall 56 | -------------------------------------------------------------------------------- /COCBot/functions/Village/ReArm.au3: -------------------------------------------------------------------------------- 1 | ;==>ReArm 2 | Func ReArm() 3 | If $ichkTrap = 0 Then Return 4 | 5 | SetLog(GetLangText("msgCheckRearm"), $COLOR_BLUE) 6 | 7 | If $TownHallPos[0] = -1 Then 8 | LocateTownHall() 9 | SaveConfig() 10 | EndIf 11 | 12 | ClickP($TopLeftClient, 2, 250); Click away twice with 250ms delay 13 | Click($TownHallPos[0], $TownHallPos[1]) 14 | _WaitForPixel(240, 581, 484, 583, Hex(0x4084B8, 6), 6, 2) 15 | 16 | Local $x1 = 240, $y1 = 562, $x2 = 670, $y2 = 600 ;Coordinates for button search 17 | 18 | ;Traps 19 | Local $offColors[3][3] = [[0x887d79, 24, 34], [0xF3EC55, 69, 7], [0xECEEE9, 77, 0]] ; 2nd pixel brown wrench, 3rd pixel gold, 4th pixel edge of button 20 | Local $RearmPixel = _MultiPixelSearch($x1, $y1, $x2, $y2, 1, 1, Hex(0xF6F9F2, 6), $offColors, 30) ; first gray/white pixel of button 21 | If IsArray($RearmPixel) Then 22 | Click($RearmPixel[0] + 20, $RearmPixel[1] + 20) ; Click RearmButton 23 | If _WaitForColor(350, 420, Hex(0xC83B10, 6), 20, 1) Then 24 | Click(515, 400) 25 | If _Sleep(300) Then Return 26 | SetLog(GetLangText("msgRearmedTraps"), $COLOR_ORANGE) 27 | EndIf 28 | EndIf 29 | 30 | ;Xbow 31 | Local $offColors[3][3] = [[0x8F4B9E, 19, 20], [0xFB5CF4, 70, 7], [0xF0F1EC, 77, 0]]; xbow, elixir, edge 32 | Local $XbowPixel = _MultiPixelSearch($x1, $y1, $x2, $y2, 1, 1, Hex(0xF4F7F0, 6), $offColors, 30) ; button start 33 | If IsArray($XbowPixel) Then 34 | Click($XbowPixel[0] + 20, $XbowPixel[1] + 20) ; Click XbowButton 35 | If _WaitForColor(350, 420, Hex(0xC83B10, 6), 20, 1) Then 36 | Click(515, 400) 37 | If _Sleep(300) Then Return 38 | SetLog(GetLangText("msgRearmedXBow"), $COLOR_ORANGE) 39 | EndIf 40 | EndIf 41 | 42 | ;Inferno 43 | Local $offColors[3][3] = [[0x8D7477, 19, 20], [0x574460, 70, 7], [0xF0F1EC, 77, 0]]; inferno, dark, edge 44 | Local $InfernoPixel = _MultiPixelSearch($x1, $y1, $x2, $y2, 1, 1, Hex(0xF4F7F0, 6), $offColors, 30) 45 | If IsArray($InfernoPixel) Then 46 | Click($InfernoPixel[0] + 20, $InfernoPixel[1] + 20) ; Click InfernoButton 47 | If _WaitForColor(350, 420, Hex(0xC83B10, 6), 20, 1) Then 48 | Click(515, 400) 49 | If _Sleep(300) Then Return 50 | SetLog(GetLangText("msgRearmedInferno"), $COLOR_ORANGE) 51 | EndIf 52 | EndIf 53 | 54 | ClickP($TopLeftClient, 2, 250); Click away twice with 250ms delay 55 | EndFunc ;==>ReArm 56 | -------------------------------------------------------------------------------- /COCBot/functions/Attack/GoldElixirChange.au3: -------------------------------------------------------------------------------- 1 | ;========================================================================== 2 | ; Function name: GoldElixirChange 3 | ; Authored by: 4 | ; Edited by: Samota, 5 | ; 6 | ; Description: Checks if the gold/elixir changes values within 20 seconds, Returns True if changed. Also 7 | ; checks every 5 seconds if gold/elixir = "", meaning battle is over. If either condition is met, return 8 | ; false. 9 | ; Now also check Dark Elixir 10 | ; 11 | ; Notes: If all troops are used, the battle will end when they are all dead, the timer runs out, or the 12 | ; base has been 3-starred. When the battle ends, it is detected within 5 seconds, otherwise it takes up 13 | ; to 20 seconds. 14 | ; 15 | ;========================================================================== 16 | Func GoldElixirChange() 17 | Local $Gold1, $Gold2 18 | Local $Elixir1, $Elixir2 19 | Local $Dark1, $Dark2 20 | Local $ExitOkay = False 21 | Local $FirstTime = True 22 | $ExitTimer = TimerInit() 23 | $Gold1 = ReadText(50, 70, 150, $textVillageSearch) 24 | $Elixir1 = ReadText(50, 99, 150, $textVillageSearch) 25 | $Dark1 = ReadText(50, 128, 80, $textVillageSearch) 26 | 27 | $NoResources = False 28 | 29 | While True 30 | $Gold2 = ReadText(50, 70, 150, $textVillageSearch) 31 | $Elixir2 = ReadText(50, 99, 150, $textVillageSearch) 32 | $Dark2 = ReadText(50, 128, 80, $textVillageSearch) 33 | _CaptureRegion() 34 | If ($Gold1 <> $Gold2 Or $Elixir1 <> $Elixir2 Or $Dark1 <> $Dark2) Then 35 | If (TimerDiff($ExitTimer)/1000 > ($itxtReturnh/2)) And Not $NoResources Then 36 | SetLog(GetLangText("msgLootChange"), $COLOR_GREEN) 37 | EndIf 38 | If Not $NoResources Then $ExitTimer = TimerInit() 39 | $Gold1 = $Gold2 40 | $Elixir1 = $Elixir2 41 | $Dark1 = $Dark2 42 | ElseIf TimerDiff($ExitTimer)/1000 > $itxtReturnh Then 43 | If Not $NoResources Then SetLog(GetLangText("msgNoIncome"), $COLOR_GREEN) 44 | Return 45 | ElseIf ($Gold2 = "" And $Elixir2 = "" And $Dark2 = "") Then 46 | SetLog(GetLangText("msgBattleFinished"), $COLOR_GREEN) 47 | Return 48 | ElseIf ($Gold2 = 0 And $Elixir2 = 0 And ((Not _ColorCheck(_GetPixelColor(38, 136), Hex(0xD3CADA, 6), 40)) ? (True) : ($Dark2 = 0))) Then 49 | If Not $NoResources Then 50 | SetLog(GetLangText("msgNoResource") & $itxtReturnh & GetLangText("msgSeconds"), $COLOR_GREEN) 51 | $NoResources = True 52 | $ExitTimer = TimerInit() 53 | EndIf 54 | EndIf 55 | If _Sleep(100) Then Return 56 | WEnd 57 | 58 | EndFunc ;==>GoldElixirChange 59 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/checkDarkElix.au3: -------------------------------------------------------------------------------- 1 | Func checkDarkElix() 2 | Local $bumpTolerance 3 | Local $maxTolerance 4 | If IsChecked($rdoMaybeSkip) Then 5 | $maxTolerance = 70 6 | $bumpTolerance = 60 7 | Else 8 | $maxTolerance = 100 9 | $bumpTolerance = 70 10 | EndIf 11 | If _Sleep(500) Then Return 12 | Do 13 | _CaptureRegion() 14 | For $i = 1 To 223 15 | If FileExists(@ScriptDir & "\images\DElix\DE" & String($i) & ".png") Then 16 | $DarkElixLocation = _ImageSearch(@ScriptDir & "\images\DElix\DE" & String($i) & ".png", 1, $DEx, $DEy, $bumpTolerance) ; Getting DE Location 17 | If $DarkElixLocation = 1 Then 18 | If ((((65 - 280) / (367 - 78)) * ($DEx - 78)) + 280 > $DEy) Or ((((277 - 62) / (780 - 481)) * ($DEx - 481)) + 62 > $DEy) Or ((((540 - 343) / (338 - 78)) * ($DEx - 78)) + 343 < $DEy) Or ((((345 - 538) / (780 - 524)) * ($DEx - 524)) + 538 < $DEy) Then 19 | $DarkElixLocation = 0 20 | $DEx = 0 21 | $DEy = 0 22 | EndIf 23 | EndIf 24 | If $DarkElixLocation = 1 Then 25 | If $DebugMode = 1 Then 26 | $sPath = $dirDebug & "DataDE.csv" 27 | If Not FileExists($sPath) Then 28 | $hFileHandle = FileOpen($sPath, $FO_APPEND + $FO_CREATEPATH) 29 | FileWriteLine($hFileHandle, "time,i,tolerance") 30 | Else 31 | $hFileHandle = FileOpen($sPath, $FO_APPEND) 32 | EndIf 33 | FileWriteLine($hFileHandle, @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "." & @MIN & "." & @SEC & "," & $i & "," & $bumpTolerance) 34 | FileClose($hFileHandle) 35 | $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $DEx - 30, $DEy - 30, 60, 60, _GDIPlus_ImageGetPixelFormat($hBitmap)) 36 | $j = 1 37 | Do 38 | If Not FileExists($dirDebug & (IsChecked($rdoMaybeSkip) ? ("") : ("LowACC-")) & "PosDE-" & $i & "-" & $bumpTolerance & " (" & $j & ").jpg") Then ExitLoop 39 | $j = $j + 1 40 | Until $j = 1000 41 | _GDIPlus_ImageSaveToFile($hClone, $dirDebug & (IsChecked($rdoMaybeSkip) ? ("") : ("LowACC-")) & "PosDE-" & $i & "-" & $bumpTolerance & " (" & $j & ").jpg") 42 | _GDIPlus_ImageDispose($hClone) 43 | EndIf 44 | Return True 45 | EndIf 46 | EndIf 47 | Next 48 | $bumpTolerance += 10 49 | Until $bumpTolerance > $maxTolerance 50 | 51 | If $DarkElixLocation = 0 Then 52 | SetLog(GetLangText("msgNoDEStorage"), $COLOR_RED) 53 | If $DebugMode = 1 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & (IsChecked($rdoMaybeSkip) ? ("") : ("LowACC-")) & "NegDE-" & @HOUR & @MIN & @SEC & ".png") 54 | $DEx = 0 55 | $DEy = 0 56 | Return False ; return 0 57 | EndIf 58 | EndFunc ;==>checkDarkElix 59 | -------------------------------------------------------------------------------- /COCBot/functions/Other/stuckHandler.au3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Func restartBlueStack() ;Kill and Restart bluestack 4 | If $restartBSAttemptedCount < 3 Then 5 | $restartBSAttemptedCount += 1 6 | If $PushBulletEnabled = 1 Then 7 | Local $iCount = _FileCountLines($sLogPath) 8 | Local $myLines = "" 9 | Local $i 10 | For $i = 1 to 5 11 | $myLines = $myLines & FileReadLine($sLogPath, ($iCount - 5 + $i)) & "\n" 12 | Next 13 | _Push(GetLangText("pushRestartBlueStack"), GetLangText("pushRestartBlueStackMSG") & _ 14 | GetLangText("pushLast5Lines") & $myLines) 15 | EndIf 16 | SetLog(GetLangText("pushRestartBlueStack"), $COLOR_RED) 17 | Local $BSFront = _WinAPI_GetProcessFileName(WinGetProcess($Title)) 18 | If @error Then 19 | Open(False) 20 | $BSFront = _WinAPI_GetProcessFileName(WinGetProcess($Title)) 21 | Else 22 | Local $QuitApp = StringReplace($BSFront, "Frontend", "Quit") 23 | Run($QuitApp) 24 | EndIf 25 | 26 | Sleep(5000) 27 | Local $RunApp = StringReplace($BSFront, "Frontend", "RunApp") 28 | Run($RunApp & " -p com.supercell.clashofclans -a com.supercell.clashofclans.GameApp") 29 | If _Sleep(10000) Then Return False 30 | Local $protection = 0 31 | Do 32 | If _Sleep(5000) Then Return False 33 | $protection += 1 34 | Until (ControlGetHandle($Title, "", "BlueStacksApp1") <> 0) Or $protection >= 60 35 | If $protection >= 60 Then 36 | If $DebugMode = 1 Then 37 | SetLog("Listing all windows:") 38 | Local $aList = WinList() 39 | For $i = 1 To $aList[0][0] 40 | SetLog("Title: " & $aList[$i][0] & " Handle: " & $aList[$i][1]) 41 | Next 42 | SetLog("Exists: " & WinExists($Title, "")) 43 | SetLog("Handle of control: " & ControlGetHandle($Title, "", "BlueStacksApp1") <> 0) 44 | EndIf 45 | restartBlueStack() 46 | Else 47 | $restartBSAttemptedCount = 0 48 | waitMainScreen() 49 | EndIf 50 | 51 | Else 52 | SetLog(GetLangText("msgBSRestartFail"), $COLOR_RED) 53 | btnStop() 54 | $restartBSAttemptedCount = 0 55 | Return False 56 | EndIf 57 | Return True 58 | EndFunc ;==>restartBlueStack 59 | 60 | Func handleBarracksError($i) ;Sets the text for the log 61 | If $i = 0 Then $brerror[0] = True 62 | If $i = 1 Then $brerror[1] = True 63 | If $i = 2 Then $brerror[2] = True 64 | If $i = 3 Then $brerror[3] = True 65 | 66 | If $brerror[0] = True And $brerror[1] = True And $brerror[2] = True And $brerror[3] = True Then 67 | SetLog(GetLangText("msgRestartBarracks"), $COLOR_RED) 68 | If Not restartBlueStack() Then Return 69 | EndIf 70 | EndFunc ;==>handleBarracksError 71 | 72 | Func resetBarracksError() 73 | $brerror[0] = False 74 | $brerror[1] = False 75 | $brerror[2] = False 76 | $brerror[3] = False 77 | EndFunc ;==>resetBarracksError 78 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/HSL.au3: -------------------------------------------------------------------------------- 1 | Func _SatSearch($iLeft, $iTop, $iWidth, $iHeight, $satMin, $satMax) 2 | _CaptureRegion($iLeft, $iTop, $iLeft + $iWidth, $iTop + $iHeight) 3 | Local $RGB[3] 4 | For $x = 0 To $iWidth - 1 5 | For $y = 0 To $iHeight - 1 6 | $color = _GetPixelColor($x, $y) 7 | $RGB[0] = Dec(StringMid(String($Color), 1, 2)) 8 | $RGB[1] = Dec(StringMid(String($Color), 3, 2)) 9 | $RGB[2] = Dec(StringMid(String($Color), 5, 2)) 10 | $HSL = RGBtoHSL($RGB) 11 | If $HSL[1] > $satMin And $HSL[1] < $satMax Then Return True 12 | Next 13 | Next 14 | Return False 15 | EndFunc ;==>_MultiPixelSearch 16 | 17 | Func _HueSearch($iLeft, $iTop, $iWidth, $iHeight, $hueMin, $hueMax) 18 | _CaptureRegion($iLeft, $iTop, $iLeft + $iWidth, $iTop + $iHeight) 19 | Local $RGB[3] 20 | For $x = 0 To $iWidth - 1 21 | For $y = 0 To $iHeight - 1 22 | $color = _GetPixelColor($x, $y) 23 | $RGB[0] = Dec(StringMid(String($Color), 1, 2)) 24 | $RGB[1] = Dec(StringMid(String($Color), 3, 2)) 25 | $RGB[2] = Dec(StringMid(String($Color), 5, 2)) 26 | $HSL = RGBtoHSL($RGB) 27 | If $HSL[0] > $hueMin And $HSL[0] < $hueMax Then Return True 28 | Next 29 | Next 30 | Return False 31 | EndFunc ;==>_MultiPixelSearch 32 | 33 | 34 | Func RGBtoHSL($arColors) 35 | Const $MaxHSL = 100 36 | Const $MaxRGB = 255 37 | 38 | If UBound($arColors) <> 3 Or UBound($arColors, 0) <> 1 Then Return SetError(1, 0, 0) 39 | 40 | Local $nH, $nS, $nL 41 | Local $nR = Number($arColors[0])/$MaxRGB 42 | Local $nG = Number($arColors[1])/$MaxRGB 43 | Local $nB = Number($arColors[2])/$MaxRGB 44 | 45 | Local $nMax = $nR 46 | If $nMax < $nG Then $nMax = $nG 47 | If $nMax < $nB Then $nMax = $nB 48 | 49 | Local $nMin = $nR 50 | If $nMin > $nG Then $nMin = $nG 51 | If $nMin > $nB Then $nMin = $nB 52 | 53 | Local $nMinMaxSum = ($nMax + $nMin) 54 | Local $nMinMaxDiff = ($nMax - $nMin) 55 | 56 | $nL = $nMinMaxSum/2 57 | If $nMinMaxDiff = 0 Then 58 | $nH = 0 59 | $nS = 0 60 | Else 61 | If $nL < 0.5 Then 62 | $nS = $nMinMaxDiff/$nMinMaxSum 63 | Else 64 | $nS = $nMinMaxDiff/(2 - $nMinMaxSum) 65 | EndIf 66 | 67 | Switch $nMax 68 | Case $nR 69 | $nH = ($nG - $nB)/(6 * $nMinMaxDiff) 70 | Case $nG 71 | $nH = ($nB - $nR)/(6 * $nMinMaxDiff) + 1/3 72 | Case $nB 73 | $nH = ($nR - $nG)/(6 * $nMinMaxDiff) + 2/3 74 | EndSwitch 75 | If $nH < 0 Then $nH += 1 76 | If $nH > 1 Then $nH -= 1 77 | EndIf 78 | 79 | $arColors[0] = $nH * $MaxHSL 80 | $arColors[1] = $nS * $MaxHSL 81 | $arColors[2] = $nL * $MaxHSL 82 | 83 | Return $arColors 84 | EndFunc 85 | -------------------------------------------------------------------------------- /COCBot/functions/Attack/ReturnHome.au3: -------------------------------------------------------------------------------- 1 | ;Returns home when in battle, will take screenshot and check for gold/elixir change unless specified not to. 2 | ;Added AbortSearch flag to avoid deadloop while try to recover from search error 3 | Func ReturnHome($TakeSS = 1, $GoldChangeCheck = True, $AbortSearch = False) ;Return main screen 4 | 5 | If $GoldChangeCheck = True Then 6 | GoldElixirChange() ; Waits for gold and elixir to stop changing 7 | If _Sleep(100) Then Return 8 | EndIf 9 | 10 | If $OverlayVisible Then DeleteOverlay() 11 | 12 | $checkKPower = False 13 | $checkQPower = False 14 | SetLog(GetLangText("msgReturnHome"), $COLOR_BLUE) 15 | If $Running = False Then Return 16 | _CaptureRegion() 17 | If _WaitForColorArea(19, 519, 100, 30, Hex(0xEE5056, 6), 50, 2) Then 18 | Click(77, 529) ;Click Surrender 19 | If _WaitForColorArea(280, 372, 130, 50, Hex(0xCF4010, 6), 30, 2) Then 20 | Click(522, 384) ; Click confirm 21 | EndIf 22 | EndIf 23 | 24 | If (_WaitForColor(304, 569, Hex(0x020202, 6), 30, 5) And $AbortSearch = False) Then 25 | If _Sleep(1500) Then Return ;wait until number stop changing. 26 | _CaptureRegion() 27 | $Raid = 1 28 | ;Get Last Raid Resources 29 | $LastRaidGold = ReadText(300, 291, 140, $textReturnHome, 0) 30 | $LastRaidElixir = ReadText(300, 329, 140, $textReturnHome, 0) 31 | _CaptureRegion() 32 | If _ColorCheck(_GetPixelColor(462, 372), Hex(0xF2D668, 6), 40) Then 33 | ; No DE 34 | $LastRaidDarkElixir = 0 35 | $LastRaidTrophy = ReadText(380, 367, 60, $textReturnHome, 0) 36 | Else 37 | $LastRaidDarkElixir = ReadText(300, 367, 140, $textReturnHome, 0) 38 | $LastRaidTrophy = ReadText(380, 403, 60, $textReturnHome, 0) 39 | EndIf 40 | 41 | $GoldTotalLoot += $LastRaidGold 42 | $ElixirTotalLoot += $LastRaidElixir 43 | $DarkTotalLoot += $LastRaidDarkElixir 44 | $TrophyTotalLoot += $LastRaidTrophy 45 | 46 | If $TakeSS = 1 Then 47 | SetLog(GetLangText("msgTakingLootSS"), $COLOR_ORANGE) 48 | Local $Date = @MDAY & "." & @MON & "." & @YEAR 49 | Local $Time = @HOUR & "." & @MIN 50 | $FileName = $Date & "_at_" & $Time & ".jpg" 51 | _CaptureRegion() 52 | _GDIPlus_ImageSaveToFile($hBitmap, $dirLoots & $FileName) 53 | EndIf 54 | If _Sleep(2000) Then Return 55 | Click(428, 544) ;Click Return Home Button 56 | Else 57 | checkMainScreen(True) 58 | EndIf 59 | 60 | If _GUICtrlEdit_GetLineCount($txtLog) > 5000 Then 61 | _GUICtrlEdit_SetText($txtLog, "") 62 | EndIf 63 | Local $counter = 0 64 | While 1 65 | If _Sleep(200) Then Return 66 | _CaptureRegion() 67 | If _ColorCheck(_GetPixelColor(284, 28), Hex(0x41B1CD, 6), 20) Then 68 | Return 69 | EndIf 70 | 71 | $counter += 1 72 | 73 | If $counter >= 50 Then 74 | SetLog(GetLangText("msgCannotReturn"), $COLOR_RED) 75 | checkMainScreen() 76 | Return 77 | EndIf 78 | WEnd 79 | EndFunc ;==>ReturnHome 80 | -------------------------------------------------------------------------------- /COCBot/functions/Main Screen/checkObstacles.au3: -------------------------------------------------------------------------------- 1 | ;Checks whether something is blocking the pixel for mainscreen and tries to unblock 2 | ;Returns True when there is something blocking 3 | 4 | Func checkObstacles() ;Checks if something is in the way for mainscreen 5 | Local $x, $y 6 | _CaptureRegion() 7 | If _ImageSearchArea($device, 0, 237, 321, 293, 346, $x, $y, 80) Then 8 | SetLog(GetLangText("msgAnotherDev") & $itxtReconnect & GetLangText("msgAnotherDevMinutes"), $COLOR_RED) 9 | If _Sleep($itxtReconnect * 60000) Then Return 10 | $iTimeTroops = 0 11 | Click(416, 399);Check for "Another device" message 12 | If _Sleep(6000) Then Return 13 | $Checkrearm = True 14 | ZoomOut() 15 | Return True 16 | EndIf 17 | 18 | If _ImageSearch($break, 0, $x, $y, 80) Then 19 | SetLog(GetLangText("msgTakeBreak"), $COLOR_RED) 20 | If _Sleep(120000) Then Return ; 2 Minutes 21 | Click(416, 399);Check for "Take a break" message 22 | $Checkrearm = True 23 | Return True 24 | EndIf 25 | 26 | If _ImageSearch($maintenance, 0, $x, $y, 80) Then 27 | 28 | SetLog(GetLangText("msgMaintenance"), $COLOR_RED) 29 | If _Sleep(60000) Then Return ; 1 Minutes 30 | Click(416, 399);Check for "Maintenance break" message 31 | $Checkrearm = True 32 | Return True 33 | EndIf 34 | 35 | $Message = _PixelSearch(457, 300, 458, 330, Hex(0x33B5E5, 6), 10) 36 | If IsArray($Message) Then 37 | Click(416, 399);Check for out of sync or inactivity 38 | If _Sleep(6000) Then Return 39 | ZoomOut() 40 | Return True 41 | EndIf 42 | 43 | _CaptureRegion() 44 | If _ColorCheck(_GetPixelColor(235, 209), Hex(0x9E3826, 6), 20) Then 45 | Click(429, 493);See if village was attacked, clicks Okay 46 | $Checkrearm = True 47 | Return True 48 | EndIf 49 | 50 | If _ColorCheck(_GetPixelColor(284, 28), Hex(0x215B69, 6), 20) Then 51 | Click(1, 1) ;Click away If things are open 52 | Return True 53 | EndIf 54 | 55 | If _ColorCheck(_GetPixelColor(819, 55), Hex(0xD80400, 6), 20) Then 56 | Click(819, 55) ;Clicks X 57 | Return True 58 | EndIf 59 | 60 | If _ColorCheck(_GetPixelColor(822, 48), Hex(0xD80408, 6), 20) Or _ColorCheck(_GetPixelColor(830, 59), Hex(0xD80408, 6), 20) Then 61 | Click(822, 48) ;Clicks X 62 | Return True 63 | EndIf 64 | 65 | If _ColorCheck(_GetPixelColor(331, 330), Hex(0xF0A03B, 6), 20) Then 66 | Click(331, 330) ;Clicks chat thing 67 | If _Sleep(1000) Then Return 68 | Return True 69 | EndIf 70 | 71 | If _ColorCheck(_GetPixelColor(429, 519), Hex(0xB8E35F, 6), 20) Then 72 | Click(429, 519) ;If in that victory or defeat scene 73 | Return True 74 | EndIf 75 | 76 | If _ColorCheck(_GetPixelColor(71, 530), Hex(0xC00000, 6), 20) Then 77 | ReturnHome(False, False) ;If End battle is available 78 | Return True 79 | EndIf 80 | 81 | $Message = _PixelSearch(19, 565, 104, 580, Hex(0xD9DDCF, 6), 10) 82 | If IsArray($Message) Then 83 | Click(67, 602);Check if Return Home button available 84 | If _Sleep(2000) Then Return 85 | Return True 86 | EndIf 87 | 88 | Return False 89 | EndFunc ;==>checkObstacles 90 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Village/clearField.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | Func clearField() 7 | Local $j, $numObstacle, $numCleared = 0 8 | If $iClearField = 1 Then 9 | SetLog(GetLangText("msgClearField"), $COLOR_BLUE) 10 | If $FreeBuilder < 1 Then 11 | SetLog(GetLangText("msgNoBuilders"), $COLOR_RED) 12 | Return 13 | EndIf 14 | 15 | $res = CallHelper("0 0 860 720 BrokenBotMatchObject 25 5 4") 16 | 17 | If $res <> $DLLFailed And $res <> $DLLTimeout And $res <> $DLLError Then 18 | If $res = $DLLNegative Then 19 | ; failed to find any obstacles to clear on the field 20 | SetLog(GetLangText("msgNoClearField"), $COLOR_RED) 21 | ElseIf $res = $DLLLicense Then 22 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 23 | Else 24 | $expRet = StringSplit($res, "|", 2) 25 | $numObstacle = $expRet[0] 26 | If $DebugMode = 1 Then SetLog("Total " & $numObstacle & " Obstacles.") 27 | For $j = 1 To UBound($expRet) - 1 Step 6 28 | $ObsX = $expRet[$j] 29 | $ObsY = $expRet[$j + 1] 30 | If $ObsX = 0 And $ObsY = 0 Then ExitLoop 31 | If $ObsY < 65 Then 32 | If $DebugMode = 1 Then SetLog("Obstacle unable to be clicked: " & $ObsX & ", " & $ObsY) 33 | ExitLoop 34 | EndIf 35 | If $ObsX < 70 Then 36 | If $DebugMode = 1 Then SetLog("Obstacle unable to be clicked: " & $ObsX & ", " & $ObsY) 37 | ExitLoop 38 | EndIf 39 | _Sleep(300) 40 | Click($ObsX, $ObsY) 41 | _Sleep(1000) 42 | 43 | $resUI = CallHelper("0 0 860 720 BrokenBotMatchButton 110 1 3") 44 | 45 | If $resUI <> $DLLFailed And $resUI <> $DLLTimeout And $resUI <> $DLLError Then 46 | If $resUI = -1 Or $resUI = -2 Then ExitLoop 47 | $expUIRet = StringSplit($resUI, "|", 2) 48 | If $DebugMode = 1 Then SetLog("Obstacle X:" & $expUIRet[1] & " Y:" & $expUIRet[2]) 49 | _Sleep(300) 50 | Click($expUIRet[1], $expUIRet[2]) 51 | $numCleared += 1 52 | $UIWait = 0 53 | Do 54 | _Sleep(300) 55 | 56 | $resUI = CallHelper("0 0 860 720 BrokenBotMatchButton 111 1 3") 57 | 58 | $expUIRet = StringSplit($resUI, "|", 2) 59 | If $expUIRet[0] = -1 Or $expUIRet[0] = -2 Then ExitLoop 60 | _Sleep(5000) 61 | $UIWait += 1 62 | Until $UIWait = 12 63 | Else 64 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 65 | Return False ; return 0 66 | EndIf 67 | Next 68 | EndIf 69 | Else 70 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 71 | Return False ; return 0 72 | EndIf 73 | If $numCleared > 0 Then 74 | SetLog(GetLangText("msgClearedField") & $numCleared, $COLOR_BLUE) 75 | EndIf 76 | EndIf 77 | Return 78 | EndFunc ;==>clearField 79 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getDigitTH.au3: -------------------------------------------------------------------------------- 1 | Func getDigitTH(ByRef $x, $y) 2 | 3 | ;Search for digit 10 4 | Local $c1 = Hex(0x0A0A0A, 6), $c2 = Hex(0x07090A, 6), $c3 = Hex(0x1C1C1C, 6) 5 | Local $pixel1[3] = [$x + 1, $y + 1, $c1], $pixel2[3] = [$x + 4, $y + 16, $c2], $pixel3[3] = [$x + 19, $y + 9, $c3] 6 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 7 | Return 10 8 | EndIf 9 | 10 | ;Search for digit 9 11 | Local $c1 = Hex(0x060606, 6), $c2 = Hex(0x4F4F4F, 6), $c3 = Hex(0x6F6F6F, 6) 12 | Local $pixel1[3] = [$x + 6, $y + 6, $c1], $pixel2[3] = [$x + 4, $y + 11, $c2], $pixel3[3] = [$x + 8, $y + 16, $c3] 13 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 14 | Return 9 15 | EndIf 16 | 17 | ;Search for digit 8 18 | Local $c1 = Hex(0x050505, 6), $c2 = Hex(0x060606, 6), $c3 = Hex(0x6A6A6A, 6) 19 | Local $pixel1[3] = [$x + 6, $y + 4, $c1], $pixel2[3] = [$x + 6, $y + 10, $c2], $pixel3[3] = [$x + 1, $y + 8, $c3] 20 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 21 | Return 8 22 | EndIf 23 | 24 | ;Search for digit 7 25 | Local $c1 = Hex(0x6E6E6E, 6), $c2 = Hex(0x202020, 6), $c3 = Hex(0x6E6E6E, 6) 26 | Local $pixel1[3] = [$x + 8, $y + 10, $c1], $pixel2[3] = [$x + 5, $y + 4, $c2], $pixel3[3] = [$x + 10, $y + 6, $c3] 27 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 28 | Return 7 29 | EndIf 30 | 31 | ;Search for digit 6 32 | Local $c1 = Hex(0xC7C7C7, 6), $c2 = Hex(0x757575, 6), $c3 = Hex(0x969696, 6) 33 | Local $pixel1[3] = [$x + 6, $y + 4, $c1], $pixel2[3] = [$x + 5, $y + 11, $c2], $pixel3[3] = [$x + 2, $y + 15, $c3] 34 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 35 | Return 6 36 | EndIf 37 | 38 | ;Search for digit 5 39 | Local $c1 = Hex(0xAFAFAF, 6), $c2 = Hex(0xBFBFBF, 6), $c3 = Hex(0x7F7F7F, 6) 40 | Local $pixel1[3] = [$x + 6, $y + 4, $c1], $pixel2[3] = [$x + 2, $y + 13, $c2], $pixel3[3] = [$x + 10, $y + 4, $c3] 41 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 42 | Return 5 43 | EndIf 44 | 45 | ;Search for digit 4 46 | Local $c1 = Hex(0x181818, 6), $c2 = Hex(0x080808, 6), $c3 = Hex(0x0E0E0E, 6) 47 | Local $pixel1[3] = [$x + 3, $y + 3, $c1], $pixel2[3] = [$x + 7, $y + 8, $c2], $pixel3[3] = [$x + 7, $y + 13, $c3] 48 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 49 | Return 4 50 | EndIf 51 | 52 | ;Search for digit 3 53 | Local $c1 = Hex(0xA6A6A6, 6), $c2 = Hex(0x909090, 6), $c3 = Hex(0x212121, 6) 54 | Local $pixel1[3] = [$x + 6, $y + 5, $c1], $pixel2[3] = [$x + 9, $y + 7, $c2], $pixel3[3] = [$x + 6, $y + 11, $c3] 55 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 56 | Return 3 57 | EndIf 58 | 59 | ;Search for digit 2 60 | Local $c1 = Hex(0x777777, 6), $c2 = Hex(0x1F1F1F, 6), $c3 = Hex(0x989898, 6) 61 | Local $pixel1[3] = [$x + 6, $y + 4, $c1], $pixel2[3] = [$x + 6, $y + 11, $c2], $pixel3[3] = [$x + 4, $y + 7, $c3] 62 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 63 | Return 2 64 | EndIf 65 | 66 | ;Search for digit 1 67 | ;Local $c1 = Hex(0x383838, 6), $c2 = Hex(0x171615, 6), $c3 = Hex(0x060606, 6) 68 | ;Local $pixel1[3] = [$x + 1, $y + 1, $c1], $pixel2[3] = [$x + 1, $y + 16, $c2], $pixel3[3] = [$x + 4, $y + 16, $c3] 69 | ;If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 70 | ; Return 1 71 | ;EndIf 72 | 73 | Return "" 74 | EndFunc ;==>getDigitTH 75 | -------------------------------------------------------------------------------- /COCBot/functions/Village/upTroops.au3: -------------------------------------------------------------------------------- 1 | #cs ---------------------------------------------------------------------------- 2 | 3 | AutoIt Version: 3.3.12.0 4 | Author: summoner 5 | 6 | Script Function: 7 | Template AutoIt script. 8 | 9 | #ce ---------------------------------------------------------------------------- 10 | ; Script Start - Add your code below here 11 | 12 | Func GetUpLaboratoryPos() 13 | If _GUICtrlComboBox_GetCurSel($cmbLaboratory) = 24 Then 14 | GUICtrlSetState($chkLab, $GUI_UNCHECKED) 15 | Else 16 | If _GUICtrlComboBox_GetCurSel($cmbLaboratory) > 11 Then 17 | $i=0 18 | Do 19 | _PostMessage_ClickDrag(725, 464, 3, 492, "left", 500) 20 | _ModifiedSleep(1000) 21 | $i += 1 22 | _CaptureRegion() 23 | Until _ColorCheck(_GetPixelColor(123, 409), Hex(0xAAAAA4, 6), 20) Or $i=20 24 | EndIf 25 | Click(133 + Floor(_GUICtrlComboBox_GetCurSel($cmbLaboratory)/2)*106-Floor(_GUICtrlComboBox_GetCurSel($cmbLaboratory)/12)*636, 330 + Mod(_GUICtrlComboBox_GetCurSel($cmbLaboratory), 2)*115) 26 | EndIf 27 | EndFunc ;==>GetUpLaboratoryPos 28 | 29 | Func Laboratory() 30 | If Not IsChecked($chkLab) Then 31 | SetLog(GetLangText("msgLabSkipped"), $COLOR_RED) 32 | ClickP($TopLeftClient) ; Click Away 33 | Return 34 | EndIf 35 | If $LabPos[0] = "" Or $LabPos[1] = "" Then 36 | SetLog(GetLangText("msgLabLocNotSet"), $COLOR_RED) 37 | ClickP($TopLeftClient) ; Click Away 38 | Return 39 | EndIf 40 | Click($LabPos[0], $LabPos[1]);Click Laboratory 41 | If _Sleep(1000) Then Return 42 | SetLog(GetLangText("msgLabSearching") & GUICtrlRead($cmbLaboratory) & "...", $COLOR_BLUE) 43 | Click(507, 597) ; Click Button Research 44 | If _Sleep(3000) Then Return 45 | GetUpLaboratoryPos() ; Click Troops 46 | SetLog(GetLangText("msgLabTroopSearch") & GUICtrlRead($cmbLaboratory) & GetLangText("msgLabTroopFound"), $COLOR_GREEN) 47 | If _Sleep(1000) Then Return 48 | _CaptureRegion() 49 | If _ColorCheck(_GetPixelColor(535, 506), Hex(0x868686, 6), 20) Or _ColorCheck(_GetPixelColor(580, 511), Hex(0x848484, 6), 20) Then 50 | SetLog(GetLangText("msgLabWaiting") & GUICtrlRead($cmbLaboratory) & GetLangText("msgLabAfter"), $COLOR_RED) 51 | If _Sleep(1000) Then Return 52 | ClickP($TopLeftClient, 2) 53 | Else 54 | If _ColorCheck(_GetPixelColor(558, 489), Hex(0xE70A12, 6), 20) Or _ColorCheck(_GetPixelColor(558, 489), Hex(0xE70A12, 6), 20) Then 55 | SetLog(GetLangText("msgLabLowElix") & GUICtrlRead($cmbLaboratory) & "...", $COLOR_RED) 56 | If _Sleep(1000) Then Return 57 | ClickP($TopLeftClient, 2) 58 | Else 59 | If _ColorCheck(_GetPixelColor(558, 489), Hex(0xE70A12, 6), 20) And _ColorCheck(_GetPixelColor(577, 498), Hex(0x2A2A2A, 6), 20) Then 60 | SetLog(GetLangText("msgLabLowDE") & GUICtrlRead($cmbLaboratory) & "...", $COLOR_RED) 61 | If _Sleep(1000) Then Return 62 | ClickP($TopLeftClient, 2) 63 | Else 64 | If _ColorCheck(_GetPixelColor(558, 489), Hex(0xFFFFFF, 6), 20) = True Then 65 | Click(558, 489) ; Click Upgrade troops 66 | SetLog(GetLangText("msgLabUpgrade") & GUICtrlRead($cmbLaboratory) & GetLangText("msgLabDone"), $COLOR_GREEN) 67 | If _Sleep(1000) Then Return 68 | ClickP($TopLeftClient, 2) 69 | GUICtrlSetState($chkLab, $GUI_UNCHECKED) 70 | EndIf 71 | EndIf 72 | EndIf 73 | EndIf 74 | EndFunc ;==>Laboratory 75 | -------------------------------------------------------------------------------- /COCBot/functions/Other/ClickDrag.au3: -------------------------------------------------------------------------------- 1 | ;================================================================================================= 2 | ; Function: _PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left") 3 | ; Description: Sends a mouse click and drag command to a specified window. 4 | ; Parameter(s): $hWnd - The handle or the title of the window. 5 | ; $X1, $Y1 - The x/y position to start the drag operation from. 6 | ; $X2, $Y2 - The x/y position to end the drag operation at. 7 | ; $Button - (optional) The button to click, "left", "right", "middle". Default is the left button. 8 | ; $Delay - (optional) Delay in milliseconds. Default is 50. 9 | ; Requirement(s): A window handle/title. 10 | ; Return Value(s): On Success - Returns true 11 | ; On Failure - Returns false 12 | ; @Error - 0 = No error. 13 | ; 1 = Invalid window handle or title. 14 | ; 2 = Invalid start position. 15 | ; 3 = Invalid end position. 16 | ; 4 = Failed to open the dll. 17 | ; 5 = Failed to send a MouseDown command. 18 | ; 5 = Failed to send a MouseMove command. 19 | ; 7 = Failed to send a MouseUp command. 20 | ; Author(s): KillerDeluxe 21 | ;================================================================================================= 22 | Func _PostMessage_ClickDrag($X1, $Y1, $X2, $Y2, $Button = "left", $Delay = 50) 23 | If Not IsHWnd($Title) And $Title <> "" Then 24 | $Title = WinGetHandle($Title) 25 | EndIf 26 | 27 | If Not IsHWnd($Title) Then 28 | Return SetError(1, "", False) 29 | EndIf 30 | 31 | If Not IsInt($X1) Or Not IsInt($Y1) Then 32 | Return SetError(2, "", False) 33 | EndIf 34 | 35 | If Not IsInt($X2) Or Not IsInt($Y2) Then 36 | Return SetError(3, "", False) 37 | EndIf 38 | 39 | If StringLower($Button) == "left" Then 40 | $Button = $WM_LBUTTONDOWN 41 | $Pressed = 1 42 | ElseIf StringLower($Button) == "right" Then 43 | $Button = $WM_RBUTTONDOWN 44 | $Pressed = 2 45 | ElseIf StringLower($Button) == "middle" Then 46 | $Button = $WM_MBUTTONDOWN 47 | $Pressed = 10 48 | If $Delay == 10 Then $Delay = 100 49 | EndIf 50 | 51 | $User32 = DllOpen("User32.dll") 52 | If @error Then Return SetError(4, "", False) 53 | 54 | DllCall($User32, "bool", "PostMessage", "hwnd", $Title, "int", $Button, "int", "0", "long", _MakeLong($X1, $Y1)) 55 | If @error Then Return SetError(5, "", False) 56 | 57 | _ModifiedSleep($Delay / 2) 58 | 59 | DllCall($User32, "bool", "PostMessage", "hwnd", $Title, "int", $WM_MOUSEMOVE, "int", $Pressed, "long", _MakeLong($X2, $Y2)) 60 | If @error Then Return SetError(6, "", False) 61 | 62 | _ModifiedSleep($Delay / 2) 63 | 64 | DllCall($User32, "bool", "PostMessage", "hwnd", $Title, "int", $Button + 1, "int", "0", "long", _MakeLong($X2, $Y2)) 65 | If @error Then Return SetError(7, "", False) 66 | 67 | DllClose($User32) 68 | Return SetError(0, 0, True) 69 | EndFunc ;==>_PostMessage_ClickDrag 70 | 71 | Func _MakeLong($LowWORD, $HiWORD) 72 | Return BitOR($HiWORD * 0x10000, BitAND($LowWORD, 0xFFFF)) 73 | EndFunc ;==>_MakeLong 74 | -------------------------------------------------------------------------------- /COCBot/functions/Village/BotStopped.au3: -------------------------------------------------------------------------------- 1 | ; Returns True if bot no longer running. 2 | ; There are Commands to Shutdown, Sleep, Halt Attack and Halt Training mode 3 | 4 | Func BotStopped($CheckLimits = True) 5 | Local $Stopped = False 6 | If $CheckLimits Then 7 | If IsChecked($chkBotStop) Then 8 | $MeetCondStop = False 9 | Local $TrophyCount = Number(ReadText(59, 75, 60, $textMainScreen)) 10 | Local $TrophyMax = Number($TrophyCount) > Number($itxtMaxTrophy) 11 | If $TrophyMax Then 12 | $Trophy = "Max. Trophy Reached!" 13 | Else 14 | $Trophy = "" 15 | EndIf 16 | 17 | Switch $icmbBotCond 18 | Case 0 19 | If isGoldFull() And isElixirFull() And isDarkElixirFull() And $TrophyMax Then $MeetCondStop = True 20 | Case 1 21 | If (isGoldFull() And isElixirFull() And isDarkElixirFull()) Or $TrophyMax Then $MeetCondStop = True 22 | Case 2 23 | If isGoldFull() And isElixirFull() And isDarkElixirFull() Then $MeetCondStop = True 24 | Case 3 25 | If isGoldFull() Or isElixirFull() Or isDarkElixirFull() Then $MeetCondStop = True 26 | Case 4 27 | If isDarkElixirFull() Then $MeetCondStop = True 28 | Case 5 29 | If isGoldFull() And isElixirFull() And $TrophyMax Then $MeetCondStop = True 30 | Case 6 31 | If (isGoldFull() And isElixirFull()) Or $TrophyMax Then $MeetCondStop = True 32 | Case 7 33 | If (isGoldFull() Or isElixirFull()) And $TrophyMax Then $MeetCondStop = True 34 | Case 8 35 | If isGoldFull() Or isElixirFull() Or $TrophyMax Then $MeetCondStop = True 36 | Case 9 37 | If isGoldFull() And isElixirFull() Then $MeetCondStop = True 38 | Case 10 39 | If isGoldFull() Or isElixirFull() Then $MeetCondStop = True 40 | Case 11 41 | If isGoldFull() And $TrophyMax Then $MeetCondStop = True 42 | Case 12 43 | If isElixirFull() And $TrophyMax Then $MeetCondStop = True 44 | Case 13 45 | If isGoldFull() Or $TrophyMax Then $MeetCondStop = True 46 | Case 14 47 | If isElixirFull() Or $TrophyMax Then $MeetCondStop = True 48 | Case 15 49 | If isGoldFull() Then $MeetCondStop = True 50 | Case 16 51 | If isElixirFull() Then $MeetCondStop = True 52 | Case 17 53 | If $TrophyMax Then $MeetCondStop = True 54 | EndSwitch 55 | 56 | If $MeetCondStop Then 57 | If $icmbBotCond <> 4 And $icmbBotCond <> 5 And $icmbBotCond <> 10 And $icmbBotCond <> 11 Then 58 | If $Trophy <> "" Then SetLog($Trophy, $COLOR_GREEN) 59 | If _Sleep(500) Then Return 60 | EndIf 61 | Switch $icmbBotCommand 62 | Case 0 63 | SetLog(GetLangText("msgHaltExp"), $COLOR_BLUE) 64 | $CurrentMode = $modeExperience ; Switch to exp mode 65 | If _Sleep(500) Then Return 66 | Case 1 67 | SetLog(GetLangText("msgHaltDonate"), $COLOR_BLUE) 68 | $CurrentMode = $modeDonateTrain ; Halt Attack 69 | If _Sleep(500) Then Return 70 | Case 2 71 | SetLog(GetLangText("msgForceShutdown"), $COLOR_BLUE) 72 | If _Sleep(500) Then Return 73 | Shutdown(5) ; Force Shutdown 74 | btnStop() 75 | Case 3 76 | SetLog(GetLangText("msgSleep"), $COLOR_BLUE) 77 | If _Sleep(500) Then Return 78 | Shutdown(32) ; Sleep / Stand by 79 | btnStop() 80 | EndSwitch 81 | EndIf 82 | EndIf 83 | EndIf 84 | If BitAND(GUICtrlGetState($btnStop), $GUI_HIDE) Then 85 | Return True 86 | Else 87 | Return False 88 | EndIf 89 | EndFunc ;==>BotStopped 90 | -------------------------------------------------------------------------------- /COCBot/functions/Village/UpgradeWall.au3: -------------------------------------------------------------------------------- 1 | Global $wallbuild 2 | Global $walllowlevel 3 | 4 | Func UpgradeWall() 5 | If Not IsChecked($chkWalls) Then Return 6 | 7 | VillageReport() 8 | SetLog(GetLangText("msgCheckWalls")) 9 | $itxtWallMinGold = GUICtrlRead($txtWallMinGold) 10 | $itxtWallMinElixir = GUICtrlRead($txtWallMinElixir) 11 | Local $MinWallGold = Number($GoldCount) > Number($itxtWallMinGold) 12 | Local $MinWallElixir = Number($ElixirCount) > Number($itxtWallMinElixir) 13 | 14 | If IsChecked($UseGold) Then 15 | If $MinWallGold Then 16 | SetLog(GetLangText("msgWallUpGold"), $COLOR_BLUE) 17 | UpgradeWallGold() 18 | Else 19 | SetLog(GetLangText("msgGoldBelowMin"), $COLOR_RED) 20 | EndIf 21 | EndIf 22 | If IsChecked($UseElixir) Then 23 | If $MinWallElixir Then 24 | Setlog(GetLangText("msgWallUpElix"), $COLOR_BLUE) 25 | UpgradeWallelix() 26 | Else 27 | Setlog(GetLangText("msgElixBelowMin"), $COLOR_BLUE) 28 | EndIf 29 | EndIf 30 | 31 | EndFunc ;==>UpgradeWall 32 | 33 | 34 | Func UpgradeWallelix() 35 | If $FreeBuilder = 0 Then 36 | SetLog(GetLangText("msgNoBuilders"), $COLOR_RED) 37 | Click(1, 1) ; Click Away 38 | Return 39 | EndIf 40 | 41 | checkWallE() 42 | If $checkwalllogic Then 43 | Click(1, 1) ; Click Away 44 | _Sleep(600) 45 | Click($WallX, $WallY) 46 | _Sleep(600) 47 | _CaptureRegion() 48 | If _ColorCheck(_GetPixelColor(595, 568), Hex(0xFFFFFF, 6), 20) = False Then 49 | SetLog(GetLangText("msgWallElixorLvl"), $COLOR_ORANGE) 50 | Click(1, 1) ; Click away 51 | _Sleep(1000) 52 | Else 53 | Click(560, 599) ; Click Upgrade 54 | _Sleep(2000) 55 | Click(472, 482) ; Click Okay 56 | SetLog(GetLangText("msgWallUpDone"), $COLOR_BLUE) ; Done upgrade 57 | GUICtrlSetData($lblwallupgradecount, GUICtrlRead($lblwallupgradecount) + 1) 58 | Click(1, 1) ; Click away 59 | _Sleep(1000) 60 | EndIf 61 | EndIf 62 | Click(1, 1) ; Click Away 63 | EndFunc ;==>UpgradeWallelix 64 | 65 | 66 | Func UpgradeWallGold() 67 | If $FreeBuilder = 0 Then 68 | SetLog(GetLangText("msgNoBuilders"), $COLOR_RED) 69 | Click(1, 1) ; Click Away 70 | Return 71 | EndIf 72 | 73 | checkWall() 74 | If $checkwalllogic Then 75 | Click(1, 1) ; Click Away 76 | _Sleep(600) 77 | Click($WallX, $WallY) 78 | _Sleep(600) 79 | _CaptureRegion() 80 | If _ColorCheck(_GetPixelColor(523, 641), Hex(0x000000, 6), 20) = False Then ; checking wall level high than level 8 81 | $walllowlevel = 0 82 | If Not _ColorCheck(_GetPixelColor(500, 570), Hex(0xFEFEFE, 6), 20) Then 83 | SetLog(GetLangText("msgWallNotEnoughGold"), $COLOR_ORANGE) 84 | Click(1, 1) ; Click Away 85 | $wallbuild = 0 86 | Else 87 | Click(505, 596) ; Click Upgrade 88 | _Sleep(2000) 89 | Click(472, 482) ; Click Okay 90 | SetLog(GetLangText("msgWallUpDone"), $COLOR_BLUE) ; Done upgrade 91 | GUICtrlSetData($lblwallupgradecount, GUICtrlRead($lblwallupgradecount) + 1) 92 | _Sleep(1000) 93 | Click(1, 1) ; Click Away 94 | EndIf 95 | Else ; check wall level lower than 8 96 | $walllowlevel = 1 97 | If Not _ColorCheck(_GetPixelColor(547, 570), Hex(0xFFFFFF, 6), 20) Then 98 | SetLog(GetLangText("msgWallNotEnoughGold"), $COLOR_ORANGE) 99 | Click(1, 1) ; Click Away 100 | $wallbuild = 0 101 | Else 102 | Click(505, 596) ; Click Upgrade 103 | _Sleep(2000) 104 | Click(472, 482) ; Click Okay 105 | SetLog(GetLangText("msgWallUpDone"), $COLOR_BLUE) ; Done upgrade 106 | GUICtrlSetData($lblwallupgradecount, GUICtrlRead($lblwallupgradecount) + 1) 107 | _Sleep(1000) 108 | Click(1, 1) ; Click Away 109 | EndIf 110 | EndIf 111 | EndIf 112 | Click(1, 1) ; Click Away 113 | EndFunc ;==>UpgradeWallGold 114 | -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getOther.au3: -------------------------------------------------------------------------------- 1 | ;Returns complete value of other 2 | 3 | Func getOther($x_start, $y_start, $type, $totalcamp = False) 4 | _CaptureRegion(0, 0, $x_start + 120, $y_start + 20) 5 | ;----------------------------------------------------------------------------- 6 | Local $x = $x_start, $y = $y_start 7 | Local $Number, $i = 0 8 | 9 | Switch $type 10 | Case "Trophy" 11 | $Number = getDigit($x, $y, "Other") 12 | 13 | While $Number = "" 14 | If $i >= 50 Then ExitLoop 15 | $i += 1 16 | $x += 1 17 | $Number = getDigit($x, $y, "Other") 18 | WEnd 19 | 20 | $Number &= getDigit($x, $y, "Other") 21 | $Number &= getDigit($x, $y, "Other") 22 | $Number &= getDigit($x, $y, "Other") 23 | 24 | Case "LastRaidGold" 25 | $Number = getDigitlastRaid($x, $y, "LastRaidGold") 26 | 27 | Case "LastRaidElixir" 28 | $Number = getDigitlastRaid($x, $y, "LastRaidElixir") 29 | 30 | Case "LastRaidDarkElixir" 31 | $Number = getDigitlastRaid($x, $y, "LastRaidDarkElixir") 32 | 33 | Case "LastRaidTrophy" 34 | $Number = getDigitlastRaid($x, $y, "LastRaidTrophy") 35 | 36 | Case "Townhall" 37 | $Number = getDigitTH($x, $y) 38 | 39 | While $Number = "" 40 | If $i >= 50 Then ExitLoop 41 | $i += 1 42 | $x += 1 43 | $Number = getDigitTH($x, $y) 44 | WEnd 45 | 46 | Case "Builder" 47 | $Number = getDigit($x, $y, "Builder") 48 | 49 | While $Number = "" 50 | If $i >= 10 Then ExitLoop 51 | $i += 1 52 | $x += 1 53 | $Number = getDigit($x, $y, "Builder") 54 | WEnd 55 | 56 | Case "Gems" 57 | $Number = getDigit($x, $y, "Other") 58 | 59 | While $Number = "" 60 | If $i >= 90 Then ExitLoop 61 | $i += 1 62 | $x += 1 63 | $Number = getDigit($x, $y, "Other") 64 | WEnd 65 | 66 | $Number &= getDigit($x, $y, "Other") 67 | $Number &= getDigit($x, $y, "Other") 68 | $Number &= getDigit($x, $y, "Other") 69 | $x += 6 70 | $Number &= getDigit($x, $y, "Other") 71 | $Number &= getDigit($x, $y, "Other") 72 | $Number &= getDigit($x, $y, "Other") 73 | 74 | Case "Resource" 75 | $Number = getDigit($x, $y, "Resource") 76 | 77 | While $Number = "" 78 | If $i >= 120 Then ExitLoop 79 | $i += 1 80 | $x += 1 81 | $Number = getDigit($x, $y, "Resource") 82 | WEnd 83 | 84 | $Number &= getDigit($x, $y, "Resource") 85 | $Number &= getDigit($x, $y, "Resource") 86 | $Number &= getDigit($x, $y, "Resource") 87 | $x += 6 88 | $Number &= getDigit($x, $y, "Resource") 89 | $Number &= getDigit($x, $y, "Resource") 90 | $Number &= getDigit($x, $y, "Resource") 91 | $x += 6 92 | $Number &= getDigit($x, $y, "Resource") 93 | $Number &= getDigit($x, $y, "Resource") 94 | $Number &= getDigit($x, $y, "Resource") 95 | 96 | Case "Camp" 97 | $Number = getDigitSmall($x, $y, "Camp") 98 | 99 | While $Number = "" 100 | If $i >= 20 Then ExitLoop 101 | $i += 1 102 | $x += 1 103 | $Number = getDigitSmall($x, $y, "Camp") 104 | WEnd 105 | 106 | $Number &= getDigitSmall($x, $y, "Camp") 107 | $Number &= getDigitSmall($x, $y, "Camp") 108 | 109 | If $totalcamp Then 110 | $x += 6 111 | $Number = "" 112 | While $Number = "" 113 | If $i >= 20 Then ExitLoop 114 | $i += 1 115 | $x += 1 116 | $Number = getDigitSmall($x, $y, "Camp") 117 | WEnd 118 | 119 | $Number &= getDigitSmall($x, $y, "Camp") 120 | $Number &= getDigitSmall($x, $y, "Camp") 121 | EndIf 122 | Case "Barrack" 123 | $Number = getDigit($x, $y, "Other") 124 | 125 | While $Number = "" 126 | If $i >= 20 Then ExitLoop 127 | $i += 1 128 | $x += 1 129 | $Number = getDigit($x, $y, "Other") 130 | WEnd 131 | 132 | $Number &= getDigit($x, $y, "Other") 133 | $Number &= getDigit($x, $y, "Other") 134 | $Number &= getDigit($x, $y, "Other") 135 | EndSwitch 136 | 137 | Return $Number 138 | EndFunc ;==>getOther 139 | -------------------------------------------------------------------------------- /COCBot/Functions.au3: -------------------------------------------------------------------------------- 1 | #include "functions\Attack\GoldElixirChange.au3" 2 | #include "functions\Attack\ReturnHome.au3" 3 | #include "functions\Attack\NameOfTroop.au3" 4 | 5 | #include "functions\Config\applyConfig.au3" 6 | #include "functions\Config\readConfig.au3" 7 | #include "functions\Config\saveConfig.au3" 8 | #include "functions\Config\ScreenCoordinates.au3" 9 | 10 | #include "functions\Image Search\ImageSearch.au3" 11 | #include "functions\Image Search\checkButtonUpgrade.au3" 12 | #include "functions\Image Search\checkDeadBase.au3" 13 | #include "functions\Image Search\checkWall.au3" 14 | 15 | #include "functions\Main Screen\checkMainScreen.au3" 16 | #include "functions\Main Screen\checkObstacles.au3" 17 | #include "functions\Main Screen\waitMainScreen.au3" 18 | #include "functions\Main Screen\ZoomOut.au3" 19 | 20 | #include "functions\Notification\PushBullet.au3" 21 | 22 | #include "functions\Other\_Sleep.au3" 23 | #include "functions\Other\Click.au3" 24 | #include "functions\Other\CreateLogFile.au3" 25 | #include "functions\Other\FindPos.au3" 26 | #include "functions\Other\getBSPos.au3" 27 | #include "functions\Other\SetLog.au3" 28 | #include "functions\Other\WriteStats.au3" 29 | #include "functions\Other\Tab.au3" 30 | #include "functions\Other\Time.au3" 31 | #include "functions\Other\BlockInputEx.au3" 32 | #include "functions\Other\_NumberFormat.au3" 33 | #include "functions\Other\RandomGaussian.au3" 34 | #include "functions\Other\stuckHandler.au3" 35 | #include "functions\Other\Experience.au3" 36 | #include "functions\Other\DisableBS.au3" 37 | #include "functions\Other\EnableBS.au3" 38 | #include "functions\Other\General Functions.au3" 39 | #include "functions\Other\LootLogCleanup.au3" 40 | #include "functions\Other\Pause.au3" 41 | #include "functions\Other\RedLineDeploy.au3" 42 | #include "functions\Other\ClickDrag.au3" 43 | 44 | #include "functions\Pixels\_CaptureRegion.au3" 45 | #include "functions\Pixels\_ColorCheck.au3" 46 | #include "functions\Pixels\_GetPixelColor.au3" 47 | #include "functions\Pixels\_PixelSearch.au3" 48 | #include "functions\Pixels\_MultiPixelSearch.au3" 49 | #include "functions\Pixels\boolPixelSearch.au3" 50 | 51 | #include "functions\Read Text\getChar.au3" 52 | #include "functions\Read Text\getDarkElixir.au3" 53 | #include "functions\Read Text\getDigit.au3" 54 | #include "functions\Read Text\getDigitLarge.au3" 55 | #include "functions\Read Text\getDigitSmall.au3" 56 | #include "functions\Read Text\getElixir.au3" 57 | #include "functions\Read Text\getGold.au3" 58 | #include "functions\Read Text\getNormal.au3" 59 | #include "functions\Read Text\getOther.au3" 60 | #include "functions\Read Text\getTrophy.au3" 61 | #include "functions\Read Text\getString.au3" 62 | #include "functions\Read Text\getDigitLastRaid.au3" 63 | #include "functions\Read Text\getDigitTH.au3" 64 | 65 | #include "functions\Search\checkNextButton.au3" 66 | #include "functions\Search\GetResources.au3" 67 | #include "functions\Search\PrepareSearch.au3" 68 | 69 | #include "functions\Strategies\strategies.au3" 70 | 71 | #include "functions\Village\BoostAllBuilding.au3" 72 | #include "functions\Village\BoostBarracks.au3" 73 | #include "functions\Village\CheckFullSpellFactory.au3" 74 | #include "functions\Village\DonateCC.au3" 75 | #include "functions\Village\DonateCheckArmyCamp.au3" 76 | #include "functions\Village\DonateTrain.au3" 77 | #include "functions\Village\DropTrophy.au3" 78 | #include "functions\Village\isGoldFull.au3" 79 | #include "functions\Village\isElixirFull.au3" 80 | #include "functions\Village\isDarkElixirFull.au3" 81 | #include "functions\Village\LocateBuildings.au3" 82 | #include "functions\Village\MainLoop.au3" 83 | #include "functions\Village\ReArm.au3" 84 | #include "functions\Village\RequestCC.au3" 85 | #include "functions\Village\BotStopped.au3" 86 | #include "functions\Village\UpgradeWall.au3" 87 | #include "functions\Village\UpgradeBuilding.au3" 88 | #include "functions\Village\VillageReport.au3" 89 | #include "functions\Village\CheckCostPerSearch.au3" 90 | #include "functions\Village\UpTroops.au3" 91 | #include "functions\Village\UpgradeHeroes.au3" ;==>upgradeHeroes 92 | -------------------------------------------------------------------------------- /COCBot/functions/Search/GetResources.au3: -------------------------------------------------------------------------------- 1 | ;Uses the getGold,getElixir... functions and uses CompareResources until it meets conditions. 2 | ;Will wait ten seconds until getGold returns a value other than "", if longer than 10 seconds - calls checkNextButton 3 | ;-clicks next if checkNextButton returns true, otherwise will restart the bot. 4 | 5 | Func GetResources($MidAttack = 0) ;Reads resources 6 | Local $RetVal[6] 7 | Local $i = 0 8 | Local $x = 0 9 | Local $txtDead = "Live" 10 | 11 | If $MidAttack = 0 And ChkDisconnection() Then 12 | SetLog(GetLangText("msgNoNextButton"), $COLOR_RED) 13 | Return False 14 | EndIf 15 | 16 | If $MidAttack > 0 Then 17 | $RetVal[0] = "" 18 | $RetVal[1] = "" 19 | Else 20 | $fdiffReadGold = TimerDiff($hTimerClickNext) 21 | $RetVal[0] = checkDeadBase() 22 | If $RetVal[0] Then $txtDead = GetLangText("msgDeadInitial") 23 | 24 | $RetVal[1] = checkTownhall() 25 | If $RetVal[1] = "-" Then 26 | $THLoc = "-" 27 | $THquadrant = "-" 28 | $THx = 0 29 | $THy = 0 30 | Else 31 | $THquadrant = 0 32 | If $WideEdge = 1 Then 33 | If ((((85 - 389) / (528 - 131)) * ($THx - 131)) + 389 > $THy) Then 34 | $THquadrant = 1 35 | ElseIf ((((237 - 538) / (723 - 337)) * ($THx - 337)) + 538 > $THy) Then 36 | $THquadrant = 4 37 | Else 38 | $THquadrant = 7 39 | EndIf 40 | If ((((388 - 85) / (725 - 330)) * ($THx - 330)) + 85 > $THy) Then 41 | $THquadrant = $THquadrant + 2 42 | ElseIf ((((537 - 238) / (535 - 129)) * ($THx - 129)) + 238 > $THy) Then 43 | $THquadrant = $THquadrant + 1 44 | EndIf 45 | Else 46 | If ((((70 - 374) / (508 - 110)) * ($THx - 110)) + 374 > $THy) Then 47 | $THquadrant = 1 48 | ElseIf ((((252 - 552) / (742 - 358)) * ($THx - 358)) + 552 > $THy) Then 49 | $THquadrant = 4 50 | Else 51 | $THquadrant = 7 52 | EndIf 53 | If ((((373 - 70) / (744 - 350)) * ($THx - 350)) + 70 > $THy) Then 54 | $THquadrant = $THquadrant + 2 55 | ElseIf ((((552 - 253) / (516 - 108)) * ($THx - 108)) + 253 > $THy) Then 56 | $THquadrant = $THquadrant + 1 57 | EndIf 58 | EndIf 59 | If GUICtrlRead($sldAcc) > -1 Then 60 | If $THquadrant >= 1 And $THquadrant <= 4 Then $THLoc = "Out" 61 | If $THquadrant = 5 Then $THLoc = "In" 62 | If $THquadrant >= 6 And $THquadrant <= 9 Then $THLoc = "Out" 63 | Else 64 | ; Future implementation...better determination of outside TH 65 | SeekEdges() 66 | If CloseToEdge($Thx, $Thy, 80) Then 67 | $THLoc = "Out" 68 | Else 69 | $THLoc = "In" 70 | EndIf 71 | EndIf 72 | EndIf 73 | EndIf 74 | 75 | $RetVal[2] = ReadText(50, 70, 150, $textVillageSearch) 76 | $RetVal[3] = ReadText(50, 99, 150, $textVillageSearch) 77 | If _ColorCheck(_GetPixelColor(38, 136), Hex(0xD3CADA, 6), 40) Then 78 | $RetVal[4] = ReadText(50, 128, 80, $textVillageSearch) 79 | $RetVal[5] = ReadText(50, 170, 67, $textVillageSearch) 80 | Else 81 | $RetVal[4] = 0 82 | $RetVal[5] = ReadText(50, 140, 67, $textVillageSearch) 83 | EndIf 84 | 85 | If $MidAttack = 1 Then 86 | SetLog(GetLangText("msgMidAttack") & " [" & GetLangText("msgGoldinitial") & "]: " & $RetVal[2] & Tab($RetVal[2], 7) & "[" & GetLangText("msgElixirinitial") & "]: " & $RetVal[3] & Tab($RetVal[3], 7) & "[" & GetLangText("msgDarkElixinitial") & "]: " & $RetVal[4] & Tab($RetVal[4], 4) & "[" & GetLangText("msgTrophyInitial") & "]: " & $RetVal[5] & Tab($RetVal[5], 3) & "[" & GetLangText("msgTHInitial") & "]: " & $RetVal[1] & (($RetVal[1] <> "-") ? ("-Q" & $THquadrant) : ("")) & ", " & $THLoc & ", " & $txtDead, $COLOR_BLUE) 87 | ElseIf $MidAttack = 0 Then 88 | $SearchCount += 1 ; Counter for number of searches 89 | SetLog("(" & $SearchCount & ") [" & GetLangText("msgGoldinitial") & "]: " & $RetVal[2] & Tab($RetVal[2], 7) & "[" & GetLangText("msgElixirinitial") & "]: " & $RetVal[3] & Tab($RetVal[3], 7) & "[" & GetLangText("msgDarkElixinitial") & "]: " & $RetVal[4] & Tab($RetVal[4], 4) & "[" & GetLangText("msgTrophyInitial") & "]: " & $RetVal[5] & Tab($RetVal[5], 3) & "[" & GetLangText("msgTHInitial") & "]: " & $RetVal[1] & (($RetVal[1] <> "-") ? ("-Q" & $THquadrant) : ("")) & ", " & $THLoc & ", " & $txtDead, $COLOR_BLUE) 90 | EndIf 91 | Return $RetVal 92 | EndFunc ;==>GetResources 93 | -------------------------------------------------------------------------------- /BrokenBot.au3: -------------------------------------------------------------------------------- 1 | #RequireAdmin 2 | #AutoIt3Wrapper_UseX64=n 3 | #pragma compile(Icon, "BrokenBot.org\images\icons\brokenbot.ico") 4 | #pragma compile(FileDescription, BrokenBot.org - Clash of Clans Bot) 5 | #pragma compile(ProductName, BrokenBot.org - Clash of Clans Bot) 6 | #pragma compile(ProductVersion, 3.3.0) 7 | #pragma compile(FileVersion, 3.3.0) 8 | 9 | #include 10 | 11 | $sBotVersion = "3.3.0" 12 | $sBotTitle = "BrokenBot.org - Break FREE - v" & $sBotVersion 13 | 14 | If FileExists(@ScriptDir & "\.developer") Then 15 | $sBotTitle = "BrokenBot.org - In Development" 16 | EndIf 17 | 18 | Global $StartupLanguage = IniRead(@ScriptDir & "\config\default.ini", "config", "language", "English") 19 | 20 | If _Singleton($sBotTitle, 1) = 0 Then 21 | MsgBox(0, "", GetLangText("boxAlreadyRunning")) 22 | Exit 23 | EndIf 24 | 25 | If @AutoItX64 = 1 Then 26 | MsgBox(0, "", GetLangText("boxCompile1") & @CRLF & GetLangText("boxCompile2")) 27 | Exit 28 | EndIf 29 | 30 | If Not FileExists(@ScriptDir & "\License.txt") Then 31 | $license = InetGet("http://www.gnu.org/licenses/gpl-3.0.txt", @ScriptDir & "\License.txt") 32 | InetClose($license) 33 | EndIf 34 | 35 | #include "COCBot\Global Variables.au3" 36 | #include "COCBot\GUI Design.au3" 37 | #include "COCBot\Functions.au3" 38 | #include "BrokenBot.org\functions\functions.au3" 39 | #include "COCBot\GUI Control.au3" 40 | #include-once 41 | 42 | ; Event registration 43 | GUIRegisterMsg($WM_COMMAND, "GUIControl") 44 | GUIRegisterMsg($WM_SYSCOMMAND, "GUIControl") 45 | GUIRegisterMsg(0x0003, "_WinMoved") 46 | 47 | ; Initialize everything 48 | DirCreate($dirLogs) 49 | DirCreate($dirLoots) 50 | DirCreate($dirAllTowns) 51 | DirCreate($dirDebug) 52 | DirCreate($dirAttack) 53 | DirCreate($dirConfigs) 54 | DirCreate($dirStrat) 55 | readConfig() 56 | applyConfig() 57 | checkupdate() 58 | _PluginDefaults() 59 | _btnRefresh() 60 | _GUICtrlListBox_SetCurSel($lstStrategies, 0) 61 | _lstStrategies() 62 | 63 | HotKeySet("^!+p", "_ScreenShot") 64 | 65 | $sTimer = TimerInit() 66 | AdlibRegister("SetTime", 1000) 67 | 68 | Local $StartImmediately = False 69 | If IsArray($CmdLine) Then 70 | If $CmdLine[0] = 1 Then $StartImmediately = True 71 | If $CmdLine[0] = 2 Then 72 | ; Add option to start with specific profile 73 | EndIf 74 | EndIf 75 | 76 | $hHBitmap = _ScreenCapture_Capture("", 0, 0, 860, 720) 77 | $ret = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotRedLineCheck", "ptr", $hHBitmap, "int", 1, "int", 1, "int", 0, "int", 0, "int", 0) 78 | _WinAPI_DeleteObject($hHBitmap) 79 | 80 | If Not IsArray($ret) Then 81 | If MsgBox($MB_ICONWARNING + $MB_OK, GetLangText("msgMissing"), GetLangText("msgMissing1") & @CRLF & @CRLF & GetLangText("msgMissing2") & @CRLF & @CRLF & GetLangText("msgMissing3") & " " & GetLangText("msgMissing4")) = $IDOK Then 82 | ShellExecute("https://www.microsoft.com/en-us/download/details.aspx?id=40784") 83 | DllClose($KernelDLL) 84 | _GDIPlus_Shutdown() 85 | _Crypt_Shutdown() 86 | _GUICtrlRichEdit_Destroy($txtLog) 87 | Exit 88 | EndIf 89 | ElseIf $ret[0] = -2 Then 90 | MsgBox(48, "BrokenBot.org", GetLangText("msgLicense") & @CRLF & @CRLF & "Please visit BrokenBot.org") 91 | EndIf 92 | 93 | If IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "1", "") = "" Or IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "2", "") = "" Then 94 | GUICtrlSetImage($btnBBValidate, @ScriptDir & "\images\Resource\bad.bmp") 95 | GUICtrlSetTip($btnBBValidate, GetLangText("tipBBValidBad")) 96 | Else 97 | GUICtrlSetData($inpBBPassword, _Decrypt(IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "2", ""))) 98 | _btnBBValidate() 99 | GUICtrlSetData($inpBBPassword, "") 100 | EndIf 101 | 102 | ;Only enable button start after all Initiation done. 103 | GUICtrlSetData($btnStart, GetLangText("btnStart")) 104 | GUICtrlSetState($btnStart, $GUI_ENABLE) 105 | While 1 106 | If $StartImmediately Then 107 | $StartImmediately = False 108 | btnStart() 109 | EndIf 110 | Switch TrayGetMsg() 111 | Case $tiAbout 112 | MsgBox(64 + $MB_APPLMODAL + $MB_TOPMOST, $sBotTitle, "Clash of Clans Bot" & @CRLF & @CRLF & _ 113 | "Version: " & $sBotVersion & @CRLF & _ 114 | "Released under the GNU GPLv3 license.", 0, $frmBot) 115 | Case $tiExit 116 | SetLog(GetLangText("msgExit"), $COLOR_ORANGE) 117 | ExitLoop 118 | EndSwitch 119 | Sleep(50) 120 | WEnd 121 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/checkWall.au3: -------------------------------------------------------------------------------- 1 | ; check Wall function | safar46 2 | Global $checkwalllogic 3 | Global $Wall[8] 4 | For $i = 0 To 7 5 | $Wall[$i] = @ScriptDir & "\images\Walls\" & $i + 4 & ".png" 6 | Next 7 | 8 | Global $WallX = 0, $WallY = 0, $WallLoc = 0 9 | Global $Tolerance2 10 | 11 | Func checkWall() 12 | Switch _GUICtrlComboBox_GetCurSel($cmbTolerance) 13 | Case 0 14 | $Tolerance2 = 55 15 | Case 1 16 | $Tolerance2 = 35 17 | Case 2 18 | $Tolerance2 = 75 19 | EndSwitch 20 | 21 | If _Sleep(500) Then Return 22 | For $i = 0 To 3 23 | _CaptureRegion() 24 | $WallLoc = _ImageSearch($Wall[$icmbWalls], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall Location 25 | If $icmbWalls = 6 Then 26 | If $WallLoc = 0 Then $WallLoc = _ImageSearch($Wall[$icmbWalls + 1], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall lvl 10 Location 27 | EndIf 28 | If $WallLoc = 1 Then 29 | SetLog(GetLangText("msgWallFound") & $icmbWalls + 4 & ", " & GetLangText("msgUpgrading"), $COLOR_GREEN) 30 | $checkwalllogic = True 31 | Return True 32 | EndIf 33 | Next 34 | $checkwalllogic = False 35 | SetLog(GetLangText("msgWallNotFound") & $icmbWalls + 4 & GetLangText("msgWallSkipUpgrade"), $COLOR_RED) 36 | Return False 37 | EndFunc ;==>checkWall 38 | 39 | Func FindWall() 40 | Switch _GUICtrlComboBox_GetCurSel($cmbTolerance) 41 | Case 0 42 | $Tolerance2 = 55 43 | Case 1 44 | $Tolerance2 = 35 45 | Case 2 46 | $Tolerance2 = 75 47 | EndSwitch 48 | 49 | _Sleep(500) 50 | For $i = 0 To 3 51 | _CaptureRegion() 52 | $WallLoc = _ImageSearch($Wall[$icmbWalls], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall Location 53 | If $icmbWalls = 6 Then 54 | If $WallLoc = 0 Then $WallLoc = _ImageSearch($Wall[$icmbWalls + 1], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall lvl 10 Location 55 | EndIf 56 | If $WallLoc = 1 Then 57 | WinActivate($HWnD) 58 | Click($WallX, $WallY) 59 | SetLog(GetLangText("msgWallFound") & $icmbWalls + 4 & " " & GetLangText("msgWallAt") & " PosX: " & $WallX & ", PosY: " & $WallY & "...", $COLOR_GREEN) 60 | Return True 61 | EndIf 62 | Next 63 | SetLog(GetLangText("msgWallNotFound") & $icmbWalls + 4 & GetLangText("msgWallAdjustTol"), $COLOR_RED) 64 | Return False 65 | EndFunc ;==>FindWall 66 | 67 | Func checkWallE() 68 | Switch _GUICtrlComboBox_GetCurSel($cmbTolerance) 69 | Case 0 70 | $Tolerance2 = 55 71 | Case 1 72 | $Tolerance2 = 35 73 | Case 2 74 | $Tolerance2 = 75 75 | EndSwitch 76 | 77 | $cmbWallsFudged = $icmbWallsE + 4 78 | 79 | If _Sleep(500) Then Return 80 | For $i = 0 To 3 81 | _CaptureRegion() 82 | $WallLoc = _ImageSearch($Wall[$cmbWallsFudged], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall Location 83 | If $cmbWallsFudged = 6 Then 84 | If $WallLoc = 0 Then $WallLoc = _ImageSearch($Wall[$cmbWallsFudged + 1], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall lvl 10 Location 85 | EndIf 86 | If $WallLoc = 1 Then 87 | SetLog(GetLangText("msgWallFound") & $cmbWallsFudged + 4 & ", " & GetLangText("msgUpgrading"), $COLOR_GREEN) 88 | $checkwalllogic = True 89 | Return True 90 | EndIf 91 | Next 92 | $checkwalllogic = False 93 | SetLog(GetLangText("msgWallNotFound") & $cmbWallsFudged + 4 & GetLangText("msgWallSkipUpgrade"), $COLOR_RED) 94 | Return False 95 | EndFunc ;==>checkWall 96 | 97 | Func FindWallE() 98 | Switch _GUICtrlComboBox_GetCurSel($cmbTolerance) 99 | Case 0 100 | $Tolerance2 = 55 101 | Case 1 102 | $Tolerance2 = 35 103 | Case 2 104 | $Tolerance2 = 75 105 | EndSwitch 106 | 107 | $cmbWallsFudged = $icmbWallsE + 4 108 | 109 | _Sleep(500) 110 | For $i = 0 To 3 111 | _CaptureRegion() 112 | $WallLoc = _ImageSearch($Wall[$cmbWallsFudged], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall Location 113 | If $cmbWallsFudged = 6 Then 114 | If $WallLoc = 0 Then $WallLoc = _ImageSearch($Wall[$cmbWallsFudged + 1], 1, $WallX, $WallY, $Tolerance2) ; Getting Wall lvl 10 Location 115 | EndIf 116 | If $WallLoc = 1 Then 117 | WinActivate($HWnD) 118 | Click($WallX, $WallY) 119 | SetLog(GetLangText("msgWallFound") & $cmbWallsFudged + 4 & " " & GetLangText("msgWallAt") & " PosX: " & $WallX & ", PosY: " & $WallY & "...", $COLOR_GREEN) 120 | Return True 121 | EndIf 122 | Next 123 | SetLog(GetLangText("msgWallNotFound") & $cmbWallsFudged + 4 & GetLangText("msgWallAdjustTol"), $COLOR_RED) 124 | Return False 125 | EndFunc ;==>FindWall 126 | 127 | -------------------------------------------------------------------------------- /BrokenBot.org/BrokenBotHelper.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ; External script that can run necessary image detection functions asynchronously from main autoit code. 7 | 8 | ; Passed to function: Pointer to BB, pointer to return variable, Background mode, Left, Top, Right, Bottom, Function, ID, MaxNum, Mask, SpeedBoost 9 | #NoTrayIcon 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | $Title = "BlueStacks App Player" 17 | $HWnD = WinGetHandle($Title) 18 | Dim $BSpos[2] 19 | 20 | _GDIPlus_Startup() 21 | 22 | $BackgroundMode = Number($CmdLine[2]) 23 | $iLeft = Number($CmdLine[3]) 24 | $iTop = Number($CmdLine[4]) 25 | $iRight = Number($CmdLine[5]) 26 | $iBottom = Number($CmdLine[6]) 27 | 28 | If $BackgroundMode = 1 Then 29 | $iW = Number($iRight) - Number($iLeft) 30 | $iH = Number($iBottom) - Number($iTop) 31 | $hDC_Capture = _WinAPI_GetWindowDC(ControlGetHandle($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]")) 32 | $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture) 33 | $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW, $iH) 34 | $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) 35 | DllCall("user32.dll", "int", "PrintWindow", "hwnd", $HWnD, "handle", $hMemDC, "int", 0) 36 | _WinAPI_SelectObject($hMemDC, $hHBitmap) 37 | _WinAPI_BitBlt($hMemDC, 0, 0, $iW, $iH, $hDC_Capture, $iLeft, $iTop, 0x00CC0020) 38 | $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) 39 | _WinAPI_DeleteDC($hMemDC) 40 | _WinAPI_SelectObject($hMemDC, $hObjectOld) 41 | _WinAPI_ReleaseDC($HWnD, $hDC_Capture) 42 | Else 43 | $aPos = ControlGetPos($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]") 44 | If Not IsArray($aPos) Then 45 | RegWrite("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer", "REG_SZ", "-4") 46 | Exit 47 | EndIf 48 | $tPoint = DllStructCreate("int X;int Y") 49 | DllStructSetData($tPoint, "X", $aPos[0]) 50 | DllStructSetData($tPoint, "Y", $aPos[1]) 51 | _WinAPI_ClientToScreen(WinGetHandle(WinGetTitle($Title)), $tPoint) 52 | $BSpos[0] = DllStructGetData($tPoint, "X") 53 | $BSpos[1] = DllStructGetData($tPoint, "Y") 54 | $hHBitmap = _ScreenCapture_Capture("", $iLeft + $BSpos[0], $iTop + $BSpos[1], $iRight + $BSpos[0], $iBottom + $BSpos[1]) 55 | $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) 56 | EndIf 57 | 58 | If $CmdLine[1] = 1 Then 59 | $mH = $CmdLine[8] 60 | $mS = $CmdLine[9] 61 | $ci = $CmdLine[10] 62 | $cl = $CmdLine[11] 63 | $cr = $CmdLine[12] 64 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) 65 | $res = DllCall(@ScriptDir & "\BrokenBot32.dll", "str", "BrokenBotRedLineCheck", "ptr", $hCheckHBitmap, "int", $mH, "int", $mS, "int", $ci, "int", $cl, "int", $cr) 66 | ElseIf $CmdLine[1] = 2 Then 67 | $x = $CmdLine[8] 68 | $y = $CmdLine[9] 69 | $width = $CmdLine[10] 70 | $height = $CmdLine[11] 71 | $type = $CmdLine[12] 72 | $leftaligned = $CmdLine[13] 73 | $reversed = $CmdLine[14] 74 | $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $x, $y, $width, $height, _GDIPlus_ImageGetPixelFormat($hBitmap)) 75 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone) 76 | $res = DllCall(@ScriptDir & "\BrokenBot32.dll", "str", "BrokenBotReadText", "ptr", $hCheckHBitmap, "int", $type, "int", $leftaligned, "int", $reversed) 77 | ElseIf $CmdLine[1] = 3 Then 78 | $Function = $CmdLine[7] 79 | $ID = $CmdLine[8] 80 | $MaxNum = $CmdLine[9] 81 | $Mask = $CmdLine[10] 82 | $SpeedBoost = $CmdLine[11] 83 | 84 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) 85 | $res = DllCall(@ScriptDir & "\BrokenBot32.dll", "str", $Function, "ptr", $hCheckHBitmap, "int", number($ID), "int", 3, "int", number($MaxNum), "int", number($Mask), "int", number($SpeedBoost)) 86 | EndIf 87 | 88 | _WinAPI_DeleteObject($hCheckHBitmap) 89 | If IsArray($res) Then 90 | RegWrite("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer", "REG_SZ", $res[0]) 91 | Else 92 | RegWrite("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer", "REG_SZ", "-4") 93 | EndIf 94 | 95 | _WinAPI_DeleteObject($hHBitmap) 96 | _GDIPlus_BitmapDispose($hBitmap) 97 | 98 | _GDIPlus_Shutdown() 99 | 100 | Exit 101 | 102 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/maths.au3: -------------------------------------------------------------------------------- 1 | Global Const $pi = 4 * ATan(1) 2 | 3 | Func FindIntersection($Ax1, $Ay1, $Ax2, $Ay2, $Bx1, $By1, $Bx2, $By2) 4 | $A1 = $Ay2 - $Ay1 5 | $B1 = $Ax1 - $Ax2 6 | $C1 = ($A1 * $Ax1) + ($B1 * $Ay1) 7 | $A2 = $By2 - $By1 8 | $B2 = $Bx1 - $Bx2 9 | $C2 = ($A2 * $Bx1) + ($B2 * $By1) 10 | If $A1 * $B2 <> $A2 * $B1 Then 11 | Local $Return[2] 12 | $Return[0] = ($B2 * $C1 - $B1 * $C2) / ($A1 * $B2 - $A2 * $B1) 13 | $Return[1] = ($A1 * $C2 - $A2 * $C1) / ($A1 * $B2 - $A2 * $B1) 14 | Return $Return 15 | Else 16 | Return -1 17 | EndIf 18 | EndFunc 19 | 20 | Func Max($A, $B) 21 | If $A > $B Then 22 | Return $A 23 | Else 24 | Return $B 25 | EndIf 26 | EndFunc 27 | 28 | Func Min($A, $B) 29 | If $A < $B Then 30 | Return $A 31 | Else 32 | Return $B 33 | EndIf 34 | EndFunc 35 | 36 | Func IsBetween($A, $B, $C) 37 | If $A <= Max($B, $C) And $A >= Min($B, $C) Then Return True 38 | Return False 39 | EndFunc 40 | 41 | Func onSegment($Px, $Py, $Qx, $Qy, $Rx, $Ry) 42 | If $Qx <= Max($Px, $Rx) And $Qx >= Min($Px, $Rx) And $Qy <= Max($Py, $Ry) And $Qy >= Min($Py, $Ry) Then 43 | Return True 44 | Else 45 | Return False 46 | EndIf 47 | EndFunc 48 | 49 | Func Orientation($Px, $Py, $Qx, $Qy, $Rx, $Ry) 50 | $val = ($Qy - $Py) * ($Rx - $Qx) - ($Qx - $Px) * ($Ry - $Qy) 51 | If $val = 0 Then Return 0 52 | Return ($val > 0) ? (1) : (2) 53 | EndFunc 54 | 55 | Func SegmentIntersect($P1x, $P1y, $P2x, $P2y, $Q1x, $Q1y, $Q2x, $Q2y) 56 | $O1 = Orientation($P1x, $P1y, $P2x, $P2y, $Q1x, $Q1y) 57 | $O2 = Orientation($P1x, $P1y, $P2x, $P2y, $Q2x, $Q2y) 58 | $O3 = Orientation($Q1x, $Q1y, $Q2x, $Q2y, $P1x, $P1y) 59 | $O4 = Orientation($Q1x, $Q1y, $Q2x, $Q2y, $P2x, $P2y) 60 | 61 | If $O1 <> $O2 And $O3 <> $O4 Then Return True 62 | If $O1 = 0 And onSegment($P1x, $P1y, $Q1x, $Q1y, $P2x, $P2y) Then Return True 63 | If $O2 = 0 And onSegment($P1x, $P1y, $Q2x, $Q2y, $P2x, $P2y) Then Return True 64 | If $O3 = 0 And onSegment($Q1x, $Q1y, $P1x, $P1y, $Q2x, $Q2y) Then Return True 65 | If $O4 = 0 And onSegment($Q1x, $Q1y, $P2x, $P2y, $Q2x, $Q2y) Then Return True 66 | 67 | Return False 68 | EndFunc 69 | 70 | Func PolarCoord($PointX, $PointY, $CentX, $CentY) 71 | ; Returns difference between points in radius and radians 72 | Local $ReturnCoord[2] 73 | $xLocation = $PointX - $CentX 74 | $yLocation = $PointY - $CentY 75 | Select 76 | Case $xLocation > 0 And $yLocation >= 0 77 | $ReturnCoord[1] = ATan($yLocation / $xLocation) 78 | Case $xLocation > 0 And $yLocation < 0 79 | $ReturnCoord[1] = ATan($yLocation / $xLocation) + 2 * $pi 80 | Case $xLocation < 0 81 | $ReturnCoord[1] = ATan($yLocation / $xLocation) + $pi 82 | Case $xLocation = 0 And $yLocation > 0 83 | $ReturnCoord[1] = $pi / 2 84 | Case $xLocation = 0 And $yLocation < 0 85 | $ReturnCoord[1] = 3 * $pi / 2 86 | Case $xLocation = 0 And $yLocation = 0 87 | $ReturnCoord[1] = 0 88 | EndSelect 89 | $ReturnCoord[0] = Sqrt($xLocation ^ 2 + $yLocation ^ 2) 90 | Return $ReturnCoord 91 | EndFunc 92 | 93 | Func CartCoord($Radius, $Radians) 94 | ; Returns X, Y coordinates from polar input 95 | Local Const $pi = 4 * ATan(1) 96 | Local $ReturnCoord[2] 97 | $ReturnCoord[0] = $Radius * Cos($Radians) 98 | $ReturnCoord[1] = $Radius * Sin($Radians) 99 | Return $ReturnCoord 100 | EndFunc 101 | 102 | Func ToLeft($Xa, $Ya, $Xb, $Yb, $Xc, $Yc) 103 | ; Returns True if Point defined by Xc, Yc is to the left of a line defined by points Xa, Ya and Xb, Yb 104 | return (($Xb - $Xa)*($Yc - $Ya) - ($Yb - $Ya)*($Xc - $Xa)) > 0 105 | EndFunc 106 | 107 | Func SmallerAngleBetween($RadianA, $RadianB) 108 | ; First ensure all angles are between 0 and 2pi 109 | While $RadianA < 0 110 | $RadianA += (2 * $pi) 111 | WEnd 112 | While $RadianA > (2 * $pi) 113 | $RadianA -= (2 * $pi) 114 | WEnd 115 | While $RadianB < 0 116 | $RadianB += (2 * $pi) 117 | WEnd 118 | While $RadianB > (2 * $pi) 119 | $RadianB -= (2 * $pi) 120 | WEnd 121 | 122 | $Diff = $RadianA - $RadianB 123 | While $Diff < 0 124 | $Diff += (2 * $pi) 125 | WEnd 126 | While $Diff > (2 * $pi) 127 | $Diff -= (2 * $pi) 128 | WEnd 129 | 130 | If $Diff > $pi Then 131 | $Diff = (2 * $pi) - $Diff 132 | EndIf 133 | Return $Diff 134 | 135 | EndFunc 136 | 137 | Func IsAngleBetween($RadianA, $RadianB, $RadianC) 138 | $AngleMain = SmallerAngleBetween($RadianA, $RadianB) 139 | $AngleCheck1 = SmallerAngleBetween($RadianA, $RadianC) 140 | $AngleCheck2 = SmallerAngleBetween($RadianB, $RadianC) 141 | If $AngleMain > $AngleCheck1 And $AngleMain > $AngleCheck2 Then 142 | Return True 143 | Else 144 | Return False 145 | EndIf 146 | EndFunc 147 | -------------------------------------------------------------------------------- /COCBot/functions/Image Search/checkDeadBase.au3: -------------------------------------------------------------------------------- 1 | Func checkDeadBase() 2 | Return ZombieSearch() ; just so it compiles 3 | EndFunc ;==>checkDeadBase 4 | 5 | ;checkDeadBase Variables:-------------=========================== 6 | Global $AdjustTolerance = 0 7 | Global $Tolerance[5][11] = [[55, 55, 55, 80, 70, 70, 75, 80, 0, 75, 65], [55, 55, 55, 80, 80, 70, 75, 80, 0, 75, 65], [55, 55, 55, 80, 80, 70, 75, 80, 0, 75, 65], [55, 55, 55, 80, 80, 60, 75, 75, 0, 75, 60], [55, 55, 55, 80, 80, 70, 75, 80, 0, 75, 65]] 8 | Global $ZC = 0, $ZombieCount = 0;, $E 9 | Global $ZombieFileSets = 4 ;Variant Image to use organized as per Folder 10 | Global $ZSExclude = 0 ;Set to 0 to include Elixir Lvl 6, 1 to include lvl 7 and so on.. 11 | Global $Lx[4] = [0, 400, 0, 400] 12 | Global $Ly[4] = [0, 0, 265, 265] 13 | Global $Rx[4] = [460, 860, 400, 860] 14 | Global $Ry[4] = [325, 325, 590, 590] 15 | 16 | Global $Area[5][11][4], $IS_x[11][4], $IS_y[11][4], $E[5][11] 17 | 18 | $E[0][0] = @ScriptDir & "\images\ELIX1\E6F9.bmp" 19 | $E[0][1] = @ScriptDir & "\images\ELIX1\E7F9.bmp" 20 | $E[0][2] = @ScriptDir & "\images\ELIX1\E8F9.bmp" 21 | $E[0][3] = @ScriptDir & "\images\ELIX1\E9F9.bmp" 22 | $E[0][4] = @ScriptDir & "\images\ELIX1\E10F8.bmp" 23 | $E[0][5] = @ScriptDir & "\images\ELIX1\E10F9.bmp" 24 | $E[0][6] = @ScriptDir & "\images\ELIX1\E11F8.bmp" 25 | $E[0][7] = @ScriptDir & "\images\ELIX1\E11F9.bmp" 26 | $E[0][8] = @ScriptDir & "\images\ELIX1\E12F7.bmp" 27 | $E[0][9] = @ScriptDir & "\images\ELIX1\E12F8.bmp" 28 | $E[0][10] = @ScriptDir & "\images\ELIX1\E12F9.bmp" 29 | 30 | $E[1][0] = @ScriptDir & "\images\ELIX2\E6F9.bmp" 31 | $E[1][1] = @ScriptDir & "\images\ELIX2\E7F9.bmp" 32 | $E[1][2] = @ScriptDir & "\images\ELIX2\E8F9.bmp" 33 | $E[1][3] = @ScriptDir & "\images\ELIX2\E9F9.bmp" 34 | $E[1][4] = @ScriptDir & "\images\ELIX2\E10F8.bmp" 35 | $E[1][5] = @ScriptDir & "\images\ELIX2\E10F9.bmp" 36 | $E[1][6] = @ScriptDir & "\images\ELIX2\E11F8.bmp" 37 | $E[1][7] = @ScriptDir & "\images\ELIX2\E11F9.bmp" 38 | $E[1][8] = @ScriptDir & "\images\ELIX2\E12F7.bmp" 39 | $E[1][9] = @ScriptDir & "\images\ELIX2\E12F8.bmp" 40 | $E[1][10] = @ScriptDir & "\images\ELIX2\E12F9.bmp" 41 | 42 | $E[2][0] = @ScriptDir & "\images\ELIX3\E6F9.bmp" 43 | $E[2][1] = @ScriptDir & "\images\ELIX3\E7F9.bmp" 44 | $E[2][2] = @ScriptDir & "\images\ELIX3\E8F9.bmp" 45 | $E[2][3] = @ScriptDir & "\images\ELIX3\E9F9.bmp" 46 | $E[2][4] = @ScriptDir & "\images\ELIX3\E10F8.bmp" 47 | $E[2][5] = @ScriptDir & "\images\ELIX3\E10F9.bmp" 48 | $E[2][6] = @ScriptDir & "\images\ELIX3\E11F8.bmp" 49 | $E[2][7] = @ScriptDir & "\images\ELIX3\E11F9.bmp" 50 | $E[2][8] = @ScriptDir & "\images\ELIX3\E12F7.bmp" 51 | $E[2][9] = @ScriptDir & "\images\ELIX3\E12F8.bmp" 52 | $E[2][10] = @ScriptDir & "\images\ELIX3\E12F9.bmp" 53 | 54 | $E[3][0] = @ScriptDir & "\images\ELIX4\E6F9.bmp" 55 | $E[3][1] = @ScriptDir & "\images\ELIX4\E7F9.bmp" 56 | $E[3][2] = @ScriptDir & "\images\ELIX4\E8F9.bmp" 57 | $E[3][3] = @ScriptDir & "\images\ELIX4\E9F9.bmp" 58 | $E[3][4] = @ScriptDir & "\images\ELIX4\E10F8.bmp" 59 | $E[3][5] = @ScriptDir & "\images\ELIX4\E10F9.bmp" 60 | $E[3][6] = @ScriptDir & "\images\ELIX4\E11F8.bmp" 61 | $E[3][7] = @ScriptDir & "\images\ELIX4\E11F9.bmp" 62 | $E[3][8] = @ScriptDir & "\images\ELIX4\E12F7.bmp" 63 | $E[3][9] = @ScriptDir & "\images\ELIX4\E12F8.bmp" 64 | $E[3][10] = @ScriptDir & "\images\ELIX4\E12F9.bmp" 65 | 66 | #Region ### Check Dead Base Functions ### 67 | ;============================================================================================================== 68 | ;===Main Function============================================================================================== 69 | ;-------------------------------------------------------------------------------------------------------------- 70 | ;Uses imagesearch to see whether a collector is full or semi-full to indicate that it is a dead base 71 | ;Returns True if it is, returns false if it is not a dead base 72 | ;-------------------------------------------------------------------------------------------------------------- 73 | 74 | Func ZombieSearch() 75 | _CaptureRegion() 76 | $ZombieCount = 0 77 | $ZC = 0 78 | For $s = 0 To ($ZombieFileSets - 1) Step 1 79 | For $p = 10 To 0 + $ZSExclude Step -1 80 | If FileExists($E[$s][$p]) Then 81 | $Area[$s][$p][0] = _ImageSearch($E[$s][$p], 1, $IS_x[$p][0], $IS_y[$p][0], $Tolerance[$s][$p] + $AdjustTolerance) 82 | If $Area[$s][$p][0] > 0 Then 83 | $ZC = 1 84 | ExitLoop (2) 85 | EndIf 86 | Else 87 | $Area[$s][$p][0] = 0 88 | EndIf 89 | Next 90 | Next 91 | $ZombieCount += $ZC 92 | If $ZombieCount > 0 Then 93 | Return True 94 | Else 95 | Return False 96 | EndIf 97 | EndFunc ;==>ZombieSearch 98 | #EndRegion ### Check Dead Base Functions ### 99 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/overlay.au3: -------------------------------------------------------------------------------- 1 | Global $frmOverlay 2 | Global $hOverlayGraphics 3 | Global $OverlayVisible = False 4 | Global $GlobalColor 5 | 6 | Func ActivateOverlay() 7 | $OverlayVisible = True 8 | getBSPos() 9 | $frmOverlay = GUICreate("", 860, 720, $BSpos[0], $BSpos[1], 0x84000000, BitOR(0x08000088, $WS_EX_LAYERED)) 10 | GUISetBkColor(0xABCDEF) 11 | _WinAPI_SetLayeredWindowAttributes($frmOverlay, 0xABCDEF, 255) 12 | _WinAPI_SetWindowLong($frmOverlay, -20, BitOR(_WinAPI_GetWindowLong($frmOverlay, -20), 0x00000020)) 13 | GUISetState(@SW_SHOW, $frmOverlay) 14 | 15 | $hOverlayGraphics = _GDIPlus_GraphicsCreateFromHWND($frmOverlay) ;create a graphics object from a window handle 16 | EndFunc ;==>ActivateOverlay 17 | 18 | Func OverlayRect($Left, $Top, $Width, $Height, $Color, $LineWidth, $OnOverlay = True, $OnAttack = True) 19 | $hPenTemp = _GDIPlus_PenCreate($Color, $LineWidth) 20 | If $OverlayVisible And $OnOverlay Then _GDIPlus_GraphicsDrawRect($hOverlayGraphics, $Left, $Top, $Width, $Height, $hPenTemp) 21 | If $BufferAvailable And $OnAttack Then _GDIPlus_GraphicsDrawRect($Buffer, $Left, $Top, $Width, $Height, $hPenTemp) 22 | _GDIPlus_PenDispose($hPenTemp) 23 | EndFunc ;==>OverlayRect 24 | 25 | Func OverlayCircle($CenterX, $CenterY, $Radius, $Color, $LineWidth, $OnOverlay = True, $OnAttack = True) 26 | $hPenTemp = _GDIPlus_PenCreate($Color, $LineWidth) 27 | If $OverlayVisible And $OnOverlay Then _GDIPlus_GraphicsDrawEllipse($hOverlayGraphics, $CenterX - $Radius, $CenterY - $Radius, ($Radius * 2) + 1, ($Radius * 2) + 1, $hPenTemp) 28 | If $BufferAvailable And $OnAttack Then _GDIPlus_GraphicsDrawEllipse($Buffer, $CenterX - $Radius, $CenterY - $Radius, ($Radius * 2) + 1, ($Radius * 2) + 1, $hPenTemp) 29 | _GDIPlus_PenDispose($hPenTemp) 30 | EndFunc ;==>OverlayCircle 31 | 32 | Func OverlayLine($X1, $Y1, $X2, $Y2, $Color, $LineWidth, $OnOverlay = True, $OnAttack = True) 33 | $hPenTemp = _GDIPlus_PenCreate($Color, $LineWidth) 34 | If $OverlayVisible And $OnOverlay Then _GDIPlus_GraphicsDrawLine($hOverlayGraphics, $X1, $Y1, $X2, $Y2, $hPenTemp) 35 | If $BufferAvailable And $OnAttack Then _GDIPlus_GraphicsDrawLine($Buffer, $X1, $Y1, $X2, $Y2, $hPenTemp) 36 | _GDIPlus_PenDispose($hPenTemp) 37 | EndFunc ;==>OverlayLine 38 | 39 | Func OverlayX($Left, $Top, $Width, $Height, $Color, $LineWidth, $OnOverlay = True, $OnAttack = True) 40 | $hPenTemp = _GDIPlus_PenCreate($Color, $LineWidth) 41 | If $OverlayVisible And $OnOverlay Then _GDIPlus_GraphicsDrawLine($hOverlayGraphics, $Left, $Top, $Left + $Width, $Top + $Height, $hPenTemp) 42 | If $OverlayVisible And $OnOverlay Then _GDIPlus_GraphicsDrawLine($hOverlayGraphics, $Left + $Width, $Top, $Left, $Top + $Height, $hPenTemp) 43 | If $BufferAvailable And $OnAttack Then _GDIPlus_GraphicsDrawLine($Buffer, $Left, $Top, $Left + $Width, $Top + $Height, $hPenTemp) 44 | If $BufferAvailable And $OnAttack Then _GDIPlus_GraphicsDrawLine($Buffer, $Left + $Width, $Top, $Left, $Top + $Height, $hPenTemp) 45 | _GDIPlus_PenDispose($hPenTemp) 46 | EndFunc ;==>OverlayX 47 | 48 | Func DeleteOverlay() 49 | _GDIPlus_GraphicsClear($hOverlayGraphics) 50 | _GDIPlus_GraphicsDispose($hOverlayGraphics) 51 | GUIDelete($frmOverlay) 52 | $OverlayVisible = False 53 | EndFunc ;==>DeleteOverlay 54 | 55 | Func CommonColor($iLeft, $iTop, $iWidth, $iHeight) 56 | ; Returns the most common color (close) in a portion of an image 57 | Local $Bins[17576] 58 | For $i = 0 To 17575 59 | $Bins[$i] = 0 60 | Next 61 | $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, $iLeft, $iTop, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32RGB) 62 | $Stride = DllStructGetData($BitmapData, "Stride") 63 | $Width = DllStructGetData($BitmapData, "Width") 64 | $Height = DllStructGetData($BitmapData, "Height") 65 | $PixelFormat = DllStructGetData($BitmapData, "PixelFormat") 66 | $Scan0 = DllStructGetData($BitmapData, "Scan0") 67 | For $row = 0 To $Height - 1 68 | For $col = 0 To $Width - 1 69 | $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col * 4) 70 | $curPixel = DllStructGetData($pixel, 1) 71 | $Red = BitAND(BitShift($curPixel, 16), 0xFF) 72 | $Green = BitAND(BitShift($curPixel, 8), 0xFF) 73 | $Blue = BitAND($curPixel, 0xFF) 74 | $Bins[(Floor($Red / 10) * 676) + (Floor($Green / 10) * 26) + Floor($Blue / 10)] += 1 75 | Next 76 | Next 77 | $Highest = 0 78 | $Loc = 0 79 | For $i = 0 To 17575 80 | If $Highest < $Bins[$i] Then 81 | $Highest = $Bins[$i] 82 | $Loc = $i 83 | EndIf 84 | Next 85 | $Red = Floor($Loc / 676) 86 | $Loc -= ($Red * 676) 87 | $Green = Floor($Loc / 26) 88 | $Blue = $Loc - ($Green * 26) 89 | $Red = ($Red * 10) + 5 90 | $Green = ($Green * 10) + 5 91 | $Blue = ($Blue * 10) + 5 92 | _GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData) 93 | Return Execute("0xFF" & String(Hex($Red, 2)) & String(Hex($Green, 2)) & String(Hex($Blue, 2))) 94 | 95 | EndFunc ;==>CommonColor 96 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/statsubmission.au3: -------------------------------------------------------------------------------- 1 | Global $objError = ObjEvent("AutoIt.Error", "HandleError") 2 | 3 | Func HandleError() 4 | $HexNumber = Hex($objError.number, 8) 5 | ;~ SetLog("Unknown error: " & $HexNumber) 6 | Return SetError(1, $HexNumber) ; something to check for when this function returns 7 | EndFunc 8 | 9 | Func StatSubmission($Attack = False) 10 | If $Attack Then 11 | If $ValidAuth Then 12 | If (Not $SubmissionMade) Or (TimerDiff($SubmissionTimer) > $AttackSubmitdelay) Then 13 | $Result = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotEncrypt", "str", String(Round($SubmissionGold/$SubmissionAttacks)), "str", String(Round($SubmissionElixir/$SubmissionAttacks)), "str", String(Round($SubmissionDE/$SubmissionAttacks)), "str", StringStripWS($THLevel, 3), "str", String($TrophyCountOld), "str", $LastAttackTH, "str", $LastAttackDead, "str", _Decrypt(IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "1", "")), "str", _Decrypt(IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "2", ""))) 14 | If IsArray($Result) Then 15 | If $Result[0] = -1 Then 16 | SetLog(GetLangText("msgDLLError"), $COLOR_RED) 17 | ElseIf $Result[0] = -2 Then 18 | SetLog(GetLangText("msgLicense"), $COLOR_RED) 19 | Else 20 | Setlog(GetLangText("msgSubmitStats")) 21 | Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") 22 | $oHTTP.Open("POST", "http://forum.brokenbot.org/bot_stat_submit.php?a=submit&u=" & _Decrypt(IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "1", "")) & "&p=" & _Decrypt(IniRead(@LocalAppDataDir & "\BrokenBot.org.ini", "default", "2", "")) & "&s=" & URLEncode($Result[0]), False) 23 | $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5") 24 | $oHTTP.SetTimeouts(5000,5000,5000,5000) 25 | $oHTTP.Send("") 26 | If @error Then 27 | Setlog(GetLangText("msgSubmitFailed")) 28 | Else 29 | $SubmitResult = $oHTTP.ResponseText() 30 | If StringStripWS($SubmitResult, 3) = "false" Then 31 | Setlog(GetLangText("msgSubmitFailed")) 32 | Else 33 | If Number(StringStripWS($SubmitResult, 3)) > 0 Then $AttackSubmitdelay = Number(StringStripWS($SubmitResult, 3)) * 1000 34 | Setlog(GetLangText("msgSubmitSuccess")) 35 | $SubmissionGold = 0 36 | $SubmissionElixir = 0 37 | $SubmissionDE = 0 38 | $SubmissionMade = True 39 | $SubmissionAttacks = 0 40 | $SubmissionTimer = TimerInit() 41 | EndIf 42 | EndIf 43 | EndIf 44 | Else 45 | SetLog(GetLangText("msgDLLError") & " " & $Result, $COLOR_RED) 46 | EndIf 47 | EndIf 48 | 49 | $AvgGold = Round($GoldTotalLoot/(TimerDiff($sTimer)/(1000*60*60))) 50 | $AvgElixir = Round($ElixirTotalLoot/(TimerDiff($sTimer)/(1000*60*60))) 51 | $AvgDark = Round($DarkTotalLoot/(TimerDiff($sTimer)/(1000*60*60))) 52 | $AvgTrophy = Round($TrophyTotalLoot/(TimerDiff($sTimer)/(1000*60*60))) 53 | SetLog(GetLangText("msgHourlyAvg") & " [" & GetLangText("msgGoldinitial") & "]: " & _NumberFormat($AvgGold) & " [" & GetLangText("msgElixirinitial") & "]: " & _NumberFormat($AvgElixir) & _ 54 | " [" & GetLangText("msgDarkElixinitial") & "]: " & _NumberFormat($AvgDark) & " [" & GetLangText("msgTrophyInitial") & "]: " & $AvgTrophy) 55 | EndIf 56 | EndIf 57 | If TimerDiff($SearchTimer) > $SearchSubmitdelay And $SubmissionSearches > 0 Then 58 | $Result = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotEncrypt", "str", $SubmissionSGold, "str", $SubmissionSElix, "str", $SubmissionSDE, "str", StringStripWS($THLevel, 3), "str", String($TrophyCountOld), "str", $SubmissionSTH, "str", $SubmissionSDead, "str", _Decrypt("0xC90FAC396189B0825D9A117CE30EAB26"), "str", _Dcrypt("0x86D135F84C56834A1515E77A658D98F1")) 59 | If IsArray($Result) Then 60 | If ($Result[0] <> -1) And ($Result[0] <> -2) Then 61 | Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") 62 | $oHTTP.Open("POST", "http://forum.brokenbot.org/bot_stat_submit.php?a=submit&u=" & _Decrypt("0xC90FAC396189B0825D9A117CE30EAB26") & "&p=" & _Dcrypt("0x86D135F84C56834A1515E77A658D98F1") & "&s=" & URLEncode($Result[0]), False) 63 | $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5") 64 | $oHTTP.SetTimeouts(5000,5000,5000,5000) 65 | $oHTTP.Send("") 66 | If @error Then 67 | If $SearchSubmitdelay < (1000 * 30 * 60) Then $SearchSubmitdelay += 300000 68 | Return 69 | EndIf 70 | $SubmitResult = $oHTTP.ResponseText() 71 | If StringStripWS($SubmitResult, 3) <> "false" Then 72 | If Number(StringStripWS($SubmitResult, 3)) > 0 Then $SearchSubmitdelay = Number(StringStripWS($SubmitResult, 3)) * 1000 73 | Global $SubmissionSGold = "" 74 | Global $SubmissionSElix = "" 75 | Global $SubmissionSDE = "" 76 | Global $SubmissionSTrophy = "" 77 | Global $SubmissionSTH = "" 78 | Global $SubmissionSDead = "" 79 | $SubmissionSearches = 0 80 | $SearchTimer = TimerInit() 81 | EndIf 82 | EndIf 83 | EndIf 84 | EndIf 85 | EndFunc -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/SharedFunction.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ;Function needed by all strategies 7 | 8 | 9 | ;Check Out of Sync or Disconnection, if detected, bump speedBump by 0.5 seconds 10 | Func ChkDisconnection($disconnected = False) 11 | _CaptureRegion() 12 | Local $dummyX = 0 13 | Local $dummyY = 0 14 | If _ImageSearch(@ScriptDir & "\images\Client.bmp", 1, $dummyX, $dummyY, 50) = 1 Then 15 | If $dummyX > 290 And $dummyX < 310 And $dummyY > 325 And $dummyY < 340 Then 16 | $disconnected = True 17 | $speedBump += 500 18 | If $speedBump > 5000 Then 19 | $speedBump = 5000 20 | SetLog("Out of sync! Already searching slowly, not changing anything.", $COLOR_RED) 21 | Else 22 | SetLog("Out of sync! Slowing search speed by 0.5 secs.", $COLOR_RED) 23 | EndIf 24 | EndIf 25 | EndIf 26 | If _ImageSearch(@ScriptDir & "\images\Lost.bmp", 1, $dummyX, $dummyY, 50) = 1 Then 27 | If $dummyX > 320 and $dummyX < 350 and $dummyY > 330 and $dummyY < 350 Then 28 | $disconnected = True 29 | ;Looks like lost connection is not related to search speed, test run without bump 30 | SetLog("Lost Connection!", $COLOR_RED) 31 | ;~ $speedBump += 500 32 | ;~ If $speedBump > 5000 Then 33 | ;~ $speedBump=5000 34 | ;~ SetLog("Lost Connection! Already searching slowly, not changing anything.", $COLOR_RED) 35 | ;~ Else 36 | ;~ SetLog("Lost Connection! Slowing search speed by 0.5 secs.", $COLOR_RED) 37 | ;~ EndIf 38 | EndIf 39 | EndIf 40 | 41 | If $disconnected = True Then 42 | ;increase disconnect counts 43 | GUICtrlSetData($lblresultsearchdisconnected, GUICtrlRead($lblresultsearchdisconnected) + 1) 44 | If $DebugMode = 1 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "DisConnt-" & @HOUR & @MIN & @SEC & ".png") 45 | 46 | If $PushBulletEnabled = 1 and IsChecked($lbldisconnect) Then 47 | Local $iCount = _FileCountLines($sLogPath) 48 | Local $myLines = "" 49 | Local $i 50 | For $i = 1 to 5 51 | $myLines = $myLines & FileReadLine($sLogPath, ($iCount - 5 + $i)) & "\n" 52 | Next 53 | _Push("Disconnected", "Your bot got disconnected while searching for enemy, total disconnections:" & GUICtrlRead($lblresultsearchdisconnected) & "\n" & _ 54 | "Last 5 lines of log:\n" & $myLines) 55 | EndIf 56 | EndIf 57 | Return $disconnected 58 | EndFunc 59 | 60 | 61 | Func ChkKingAvailability() 62 | 63 | $KingAvailable = False 64 | $KingUG = False 65 | ClickP($TopLeftClient) ;Click Away 66 | If $KingPos[0] = "" Then 67 | Return False 68 | Else 69 | if _sleep(500) Then Return 70 | Click($KingPos[0], $KingPos[1]) ;Click King Altar 71 | EndIf 72 | 73 | If _Sleep(500) Then Return 74 | _CaptureRegion() 75 | 76 | Local $KingInfoPos = _WaitForPixel(260, 581, 350, 583, Hex(0x4084B8, 6), 5, 2) ;Finds Info button, wait max 2 seconds 77 | If IsArray($KingInfoPos) = False Then 78 | SetLog(GetLangText("msgKAUnavailable"), $COLOR_RED) 79 | Else ;check if king is available for battle 80 | $KingInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD13D08, 6), 5) ;Finds Healing button 81 | If IsArray($KingInfoPos) = False Then 82 | $KingInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD0EC75, 6), 5) ;Finds Finish now button, when under upgrading 83 | If IsArray($KingInfoPos) Then 84 | $KingUG = True 85 | Else 86 | $KingAvailable = True 87 | EndIf 88 | EndIf 89 | EndIf 90 | Setlog (GetLangText("msgKingAvail") & $KingAvailable) 91 | Return $KingAvailable 92 | EndFunc 93 | 94 | Func ChkQueenAvailability() 95 | 96 | $QueenAvailable = False 97 | $QueenUG = False 98 | 99 | ClickP($TopLeftClient) ;Click Away 100 | If $QueenPos[0] = "" Then 101 | Return False 102 | Else 103 | if _sleep(500) Then Return 104 | Click($QueenPos[0], $QueenPos[1]) ;Click Queen Altar 105 | EndIf 106 | 107 | If _Sleep(500) Then Return 108 | _CaptureRegion() 109 | 110 | Local $QueenInfoPos = _WaitForPixel(260, 581, 350, 583, Hex(0x4084B8, 6), 5, 2) ;Finds Info button, wait max 2 seconds 111 | If IsArray($QueenInfoPos) = False Then 112 | SetLog(GetLangText("msgQAUnavailable"), $COLOR_RED) 113 | Else ;check if king is available for battle 114 | $QueenInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD13D08, 6), 5) ;Finds Healing button 115 | If IsArray($QueenInfoPos) = False Then 116 | $QueenInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD0EC75, 6), 5) ;Finds Finish now button, when under upgrading 117 | If IsArray($QueenInfoPos) Then 118 | $QueenUG = True 119 | Else 120 | $QueenAvailable = True 121 | EndIf 122 | EndIf 123 | EndIf 124 | Setlog (GetLangText("msgQueenAvail") & $QueenAvailable) 125 | Return $QueenAvailable 126 | EndFunc -------------------------------------------------------------------------------- /BrokenBot.org/functions/Strategies/Common/SharedFunctions.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ;Function needed by all strategies 7 | 8 | 9 | ;Check Out of Sync or Disconnection, if detected, bump speedBump by 0.5 seconds 10 | Func ChkDisconnection($disconnected = False) 11 | _CaptureRegion() 12 | Local $dummyX = 0 13 | Local $dummyY = 0 14 | If _ImageSearch(@ScriptDir & "\images\Client.bmp", 1, $dummyX, $dummyY, 50) = 1 Then 15 | If $dummyX > 290 And $dummyX < 310 And $dummyY > 325 And $dummyY < 340 Then 16 | $disconnected = True 17 | $speedBump += 500 18 | If $speedBump > 5000 Then 19 | $speedBump = 5000 20 | SetLog("Out of sync! Already searching slowly, not changing anything.", $COLOR_RED) 21 | Else 22 | SetLog("Out of sync! Slowing search speed by 0.5 secs.", $COLOR_RED) 23 | EndIf 24 | EndIf 25 | EndIf 26 | If _ImageSearch(@ScriptDir & "\images\Lost.bmp", 1, $dummyX, $dummyY, 50) = 1 Then 27 | If $dummyX > 320 and $dummyX < 350 and $dummyY > 330 and $dummyY < 350 Then 28 | $disconnected = True 29 | ;Looks like lost connection is not related to search speed, test run without bump 30 | SetLog("Lost Connection!", $COLOR_RED) 31 | ;~ $speedBump += 500 32 | ;~ If $speedBump > 5000 Then 33 | ;~ $speedBump=5000 34 | ;~ SetLog("Lost Connection! Already searching slowly, not changing anything.", $COLOR_RED) 35 | ;~ Else 36 | ;~ SetLog("Lost Connection! Slowing search speed by 0.5 secs.", $COLOR_RED) 37 | ;~ EndIf 38 | EndIf 39 | EndIf 40 | 41 | If $disconnected = True Then 42 | ;increase disconnect counts 43 | GUICtrlSetData($lblresultsearchdisconnected, GUICtrlRead($lblresultsearchdisconnected) + 1) 44 | If $DebugMode = 1 Then _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "DisConnt-" & @HOUR & @MIN & @SEC & ".png") 45 | 46 | If $PushBulletEnabled = 1 and IsChecked($lbldisconnect) Then 47 | Local $iCount = _FileCountLines($sLogPath) 48 | Local $myLines = "" 49 | Local $i 50 | For $i = 1 to 5 51 | $myLines = $myLines & FileReadLine($sLogPath, ($iCount - 5 + $i)) & "\n" 52 | Next 53 | _Push("Disconnected", "Your bot got disconnected while searching for enemy, total disconnections:" & GUICtrlRead($lblresultsearchdisconnected) & "\n" & _ 54 | GetLangText("pushLast5Lines") & $myLines) 55 | EndIf 56 | EndIf 57 | Return $disconnected 58 | EndFunc 59 | 60 | 61 | Func ChkKingAvailability() 62 | 63 | $KingAvailable = False 64 | $KingUG = False 65 | ClickP($TopLeftClient) ;Click Away 66 | If $KingPos[0] = "" Then 67 | Return False 68 | Else 69 | if _sleep(500) Then Return 70 | Click($KingPos[0], $KingPos[1]) ;Click King Altar 71 | EndIf 72 | 73 | If _Sleep(500) Then Return 74 | _CaptureRegion() 75 | 76 | Local $KingInfoPos = _WaitForPixel(260, 581, 350, 583, Hex(0x4084B8, 6), 5, 2) ;Finds Info button, wait max 2 seconds 77 | If IsArray($KingInfoPos) = False Then 78 | SetLog(GetLangText("msgKAUnavailable"), $COLOR_RED) 79 | Else ;check if king is available for battle 80 | $KingInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD13D08, 6), 5) ;Finds Healing button 81 | If IsArray($KingInfoPos) = False Then 82 | $KingInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD0EC75, 6), 5) ;Finds Finish now button, when under upgrading 83 | If IsArray($KingInfoPos) Then 84 | $KingUG = True 85 | Else 86 | $KingAvailable = True 87 | EndIf 88 | EndIf 89 | EndIf 90 | Setlog (GetLangText("msgKingAvail") & $KingAvailable) 91 | Return $KingAvailable 92 | EndFunc 93 | 94 | Func ChkQueenAvailability() 95 | 96 | $QueenAvailable = False 97 | $QueenUG = False 98 | 99 | ClickP($TopLeftClient) ;Click Away 100 | If $QueenPos[0] = "" Then 101 | Return False 102 | Else 103 | if _sleep(500) Then Return 104 | Click($QueenPos[0], $QueenPos[1]) ;Click Queen Altar 105 | EndIf 106 | 107 | If _Sleep(500) Then Return 108 | _CaptureRegion() 109 | 110 | Local $QueenInfoPos = _WaitForPixel(260, 581, 350, 583, Hex(0x4084B8, 6), 5, 2) ;Finds Info button, wait max 2 seconds 111 | If IsArray($QueenInfoPos) = False Then 112 | SetLog(GetLangText("msgQAUnavailable"), $COLOR_RED) 113 | Else ;check if king is available for battle 114 | $QueenInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD13D08, 6), 5) ;Finds Healing button 115 | If IsArray($QueenInfoPos) = False Then 116 | $QueenInfoPos = _PixelSearch(510, 589, 585, 591, Hex(0xD0EC75, 6), 5) ;Finds Finish now button, when under upgrading 117 | If IsArray($QueenInfoPos) Then 118 | $QueenUG = True 119 | Else 120 | $QueenAvailable = True 121 | EndIf 122 | EndIf 123 | EndIf 124 | Setlog (GetLangText("msgQueenAvail") & $QueenAvailable) 125 | Return $QueenAvailable 126 | EndFunc -------------------------------------------------------------------------------- /COCBot/functions/Read Text/getDigitLastRaid.au3: -------------------------------------------------------------------------------- 1 | ;============================================================================================================== 2 | ;===Get Digit LastRaid========================================================================================= 3 | ;-------------------------------------------------------------------------------------------------------------- 4 | ;Finds pixel color pattern of specific X and Y values, returns digit if pixel color pattern found. 5 | ;-------------------------------------------------------------------------------------------------------------- 6 | 7 | Func getDigitLastRaid(ByRef $x, $y, $type) 8 | 9 | Local $Resource = "" 10 | 11 | While $x <> 440 12 | $x += 1 13 | 14 | ;Check for Negative sign 15 | If $type = "LastRaidTrophy" Then 16 | ;Done 17 | ;Search for negative sign 18 | Local $c1 = Hex(0x979797, 6), $c2 = Hex(0x474747, 6), $c3 = Hex(0xFFFFFF, 6) 19 | Local $pixel1[3] = [$x + 1, $y + 9, $c1], $pixel2[3] = [$x + 5, $y + 13, $c2], $pixel3[3] = [$x + 3, $y + 11, $c3] 20 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 21 | $x += 5 22 | $Resource &= "-" 23 | ContinueLoop 24 | EndIf 25 | EndIf 26 | 27 | ;Done 28 | ;Search for digit 9 29 | Local $c1 = Hex(0xA6A6A6, 6), $c2 = Hex(0x414141, 6), $c3 = Hex(0x8F8F8F, 6) 30 | Local $pixel1[3] = [$x + 6, $y + 5, $c1], $pixel2[3] = [$x + 8, $y + 13, $c2], $pixel3[3] = [$x + 9, $y + 17, $c3] 31 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 32 | $x += 5 33 | $Resource &= 9 34 | ContinueLoop 35 | EndIf 36 | 37 | ;Done 38 | ;Search for digit 8 39 | Local $c1 = Hex(0x575757, 6), $c2 = Hex(0xB7B7B7, 6), $c3 = Hex(0xA7A7A7, 6) 40 | Local $pixel1[3] = [$x + 7, $y + 4, $c1], $pixel2[3] = [$x + 7, $y + 11, $c2], $pixel3[3] = [$x + 12, $y + 8, $c3] 41 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 42 | $x += 5 43 | $Resource &= 8 44 | ContinueLoop 45 | EndIf 46 | 47 | ;Done 48 | ;Search for digit 7 49 | Local $c1 = Hex(0xB8B8B8, 6), $c2 = Hex(0xC1C1C1, 6), $c3 = Hex(0x808080, 6) 50 | Local $pixel1[3] = [$x + 11, $y + 1, $c1], $pixel2[3] = [$x + 5, $y + 8, $c2], $pixel3[3] = [$x + 2, $y + 14, $c3] 51 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 52 | $x += 5 53 | $Resource &= 7 54 | ContinueLoop 55 | EndIf 56 | 57 | ;Done 58 | ;Search for digit 6 59 | Local $c1 = Hex(0xB4B4B4, 6), $c2 = Hex(0x7D7D7D, 6), $c3 = Hex(0xB9B9B9, 6) 60 | Local $pixel1[3] = [$x, $y + 5, $c1], $pixel2[3] = [$x + 5, $y + 6, $c2], $pixel3[3] = [$x + 5, $y + 14, $c3] 61 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 62 | $x += 5 63 | $Resource &= 6 64 | ContinueLoop 65 | EndIf 66 | 67 | ;Done 68 | ;Search for digit 5 69 | Local $c1 = Hex(0x9F9F9F, 6), $c2 = Hex(0xB7B7B7, 6), $c3 = Hex(0x6F6F6F, 6) 70 | Local $pixel1[3] = [$x + 6, $y + 5, $c1], $pixel2[3] = [$x + 7, $y + 12, $c2], $pixel3[3] = [$x + 9, $y + 17, $c3] 71 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 72 | $x += 5 73 | $Resource &= 5 74 | ContinueLoop 75 | EndIf 76 | 77 | ;Done 78 | ;Search for digit 4 79 | Local $c1 = Hex(0x818181, 6), $c2 = Hex(0x686868, 6), $c3 = Hex(0x979797, 6) 80 | Local $pixel1[3] = [$x + 10, $y + 1, $c1], $pixel2[3] = [$x + 8, $y + 10, $c2], $pixel3[3] = [$x + 8, $y + 14, $c3] 81 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 82 | $x += 5 83 | $Resource &= 4 84 | ContinueLoop 85 | EndIf 86 | 87 | ;Done 88 | ;Search for digit 3 89 | Local $c1 = Hex(0xB1B1B1, 6), $c2 = Hex(0xCECECE, 6), $c3 = Hex(0x909090, 6) 90 | Local $pixel1[3] = [$x + 9, $y + 1, $c1], $pixel2[3] = [$x + 7, $y + 6, $c2], $pixel3[3] = [$x + 5, $y + 14, $c3] 91 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 92 | $x += 5 93 | $Resource &= 3 94 | ContinueLoop 95 | EndIf 96 | 97 | ;Done 98 | ;Search for digit 2 99 | Local $c1 = Hex(0x292929, 6), $c2 = Hex(0x464646, 6), $c3 = Hex(0xB8B8B8, 6) 100 | Local $pixel1[3] = [$x + 7, $y + 6, $c1], $pixel2[3] = [$x + 6, $y + 13, $c2], $pixel3[3] = [$x + 7, $y + 14, $c3] 101 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 102 | $x += 5 103 | $Resource &= 2 104 | ContinueLoop 105 | EndIf 106 | 107 | ;Done 108 | ;Search for digit 1 109 | Local $c1 = Hex(0x888888, 6), $c2 = Hex(0x7B7B7B, 6), $c3 = Hex(0xBFBFBF, 6) 110 | Local $pixel1[3] = [$x + 5, $y + 1, $c1], $pixel2[3] = [$x + 2, $y + 17, $c2], $pixel3[3] = [$x + 6, $y + 17, $c3] 111 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 112 | $x += 5 113 | $Resource &= 1 114 | ContinueLoop 115 | EndIf 116 | 117 | ;Done 118 | ;Search for digit 0 119 | Local $c1 = Hex(0x9E9E9E, 6), $c2 = Hex(0x8F8F8F, 6), $c3 = Hex(0xD6D6D6, 6) 120 | Local $pixel1[3] = [$x + 3, $y + 2, $c1], $pixel2[3] = [$x + 10, $y + 6, $c2], $pixel3[3] = [$x + 6, $y + 14, $c3] 121 | If boolPixelSearch($pixel1, $pixel2, $pixel3) Then 122 | $x += 5 123 | $Resource &= 0 124 | ContinueLoop 125 | EndIf 126 | 127 | ;For Dark Elixir, if there is a digit 1 $y set pixel offset 128 | If $x = 440 And $Resource = "" And $type = "LastRaidDarkElixir" Then 129 | $x = 330 130 | $y += 1 131 | EndIf 132 | WEnd 133 | 134 | Return $Resource 135 | 136 | EndFunc ;==>getDigitLastRaid 137 | -------------------------------------------------------------------------------- /COCBot/functions/Other/General Functions.au3: -------------------------------------------------------------------------------- 1 | Func SetTime() 2 | Local $time = _TicksToTime(Int(TimerDiff($sTimer)), $hour, $min, $sec) 3 | If _GUICtrlTab_GetCurSel($tabMain) = 7 Then GUICtrlSetData($lblresultruntime, StringFormat("%02i:%02i:%02i", $hour, $min, $sec)) 4 | If IsChecked($lblpushbulletremote) Then 5 | If StringRight(StringFormat("%02i", $sec), 2) = "30" Then 6 | _RemoteControl() 7 | EndIf 8 | EndIf 9 | EndFunc ;==>SetTime 10 | 11 | Func Initiate() 12 | If IsArray(ControlGetPos($Title, "_ctl.Window", "[CLASS:BlueStacksApp; INSTANCE:1]")) Then 13 | Local $BSsize = [ControlGetPos($Title, "_ctl.Window", "[CLASS:BlueStacksApp; INSTANCE:1]")[2], ControlGetPos($Title, "_ctl.Window", "[CLASS:BlueStacksApp; INSTANCE:1]")[3]] 14 | Local $fullScreenRegistryData = RegRead($REGISTRY_KEY_DIRECTORY, "FullScreen") 15 | Local $guestHeightRegistryData = RegRead($REGISTRY_KEY_DIRECTORY, "GuestHeight") 16 | Local $guestWidthRegistryData = RegRead($REGISTRY_KEY_DIRECTORY, "GuestWidth") 17 | Local $windowHeightRegistryData = RegRead($REGISTRY_KEY_DIRECTORY, "WindowHeight") 18 | Local $windowWidthRegistryData = RegRead($REGISTRY_KEY_DIRECTORY, "WindowWidth") 19 | 20 | Local $BSx = ($BSsize[0] > $BSsize[1]) ? $BSsize[0] : $BSsize[1] 21 | Local $BSy = ($BSsize[0] > $BSsize[1]) ? $BSsize[1] : $BSsize[0] 22 | 23 | $Running = True 24 | 25 | If $BSx <> 860 Or $BSy <> 720 Then 26 | RegWrite($REGISTRY_KEY_DIRECTORY, "FullScreen", "REG_DWORD", "0") 27 | RegWrite($REGISTRY_KEY_DIRECTORY, "GuestHeight", "REG_DWORD", $DEFAULT_HEIGHT) 28 | RegWrite($REGISTRY_KEY_DIRECTORY, "GuestWidth", "REG_DWORD", $DEFAULT_WIDTH) 29 | RegWrite($REGISTRY_KEY_DIRECTORY, "WindowHeight", "REG_DWORD", $DEFAULT_HEIGHT) 30 | RegWrite($REGISTRY_KEY_DIRECTORY, "WindowWidth", "REG_DWORD", $DEFAULT_WIDTH) 31 | SetLog(GetLangText("msgPleaseRestart"), $COLOR_ORANGE) 32 | _Sleep(3000) 33 | $MsgRet = MsgBox(BitOR($MB_OKCANCEL, $MB_SYSTEMMODAL), GetLangText("boxRestart"), GetLangText("boxRestart2") & @CRLF & GetLangText("boxRestart3"), 10) 34 | If $MsgRet <> $IDOK Then 35 | btnStop() 36 | Return 37 | EndIf 38 | EndIf 39 | 40 | WinActivate($Title) 41 | 42 | SetLog(GetLangText("msgWelcome") & $sBotTitle & "!~~~~", $COLOR_PURPLE) 43 | SetLog($Compiled & GetLangText("msgRunningOn") & @OSArch & " OS", $COLOR_GREEN) 44 | SetLog(GetLangText("msgStarting"), $COLOR_ORANGE) 45 | 46 | If IsChecked($lblpushbulletenabled) And IsChecked($lblpushbulletdelete) Then 47 | _DeletePush() 48 | EndIf 49 | 50 | $AttackNow = False 51 | $FirstStart = True 52 | $Checkrearm = True 53 | GUICtrlSetState($cmbBoostBarracks, $GUI_DISABLE) 54 | GUICtrlSetState($btnLocateDarkBarracks, $GUI_DISABLE) 55 | GUICtrlSetState($btnLocateBarracks, $GUI_DISABLE) 56 | GUICtrlSetState($btnLocateCamp, $GUI_DISABLE) 57 | GUICtrlSetState($btnFindWall, $GUI_DISABLE) 58 | GUICtrlSetState($btnFindWall2, $GUI_DISABLE) 59 | GUICtrlSetState($chkBackground, $GUI_DISABLE) 60 | GUICtrlSetState($chkNoAttack, $GUI_DISABLE) 61 | GUICtrlSetState($chkDonateOnly, $GUI_DISABLE) 62 | GUICtrlSetState($chkForceBS, $GUI_DISABLE) 63 | GUICtrlSetState($btnLocateTownHall, $GUI_DISABLE) 64 | GUICtrlSetState($btnLocateKingAltar, $GUI_DISABLE) 65 | GUICtrlSetState($btnLocateQueenAltar, $GUI_DISABLE) 66 | GUICtrlSetState($btnLoad, $GUI_DISABLE) 67 | GUICtrlSetState($btnSave, $GUI_DISABLE) 68 | GUICtrlSetState($btnLocateClanCastle, $GUI_DISABLE) 69 | GUICtrlSetState($btnLocateSFactory, $GUI_DISABLE) 70 | $sTimer = TimerInit() 71 | $GoldTotalLoot = 0 72 | $ElixirTotalLoot = 0 73 | $DarkTotalLoot = 0 74 | $TrophyTotalLoot = 0 75 | 76 | AdlibRegister("SetTime", 1000) 77 | runBot() 78 | GUICtrlSetState($btnStart, $GUI_ENABLE) 79 | GUICtrlSetData($btnStart, "Start Bot") 80 | Else 81 | SetLog(GetLangText("msgNotInGame"), $COLOR_RED) 82 | btnStop() 83 | EndIf 84 | EndFunc ;==>Initiate 85 | 86 | Func Open($initialize = True) 87 | If $64Bit Then ;If 64-Bit 88 | ShellExecute("C:\Program Files (x86)\BlueStacks\HD-StartLauncher.exe") 89 | SetLog(GetLangText("msgStartingBS"), $COLOR_GREEN) 90 | _ModifiedSleep(290) 91 | SetLog(GetLangText("msgWaitingBS"), $COLOR_GREEN) 92 | $Initiate = 0 93 | Check($initialize) 94 | Else ;If 32-Bit 95 | ShellExecute("C:\Program Files\BlueStacks\HD-StartLauncher.exe") 96 | SetLog(GetLangText("msgStartingBS"), $COLOR_GREEN) 97 | _ModifiedSleep(290) 98 | SetLog(GetLangText("msgWaitingBS"), $COLOR_GREEN) 99 | $Initiate = 0 100 | Check($initialize) 101 | EndIf 102 | EndFunc ;==>Open 103 | 104 | Func Check($initialize = True) 105 | If $Initiate > 90 Then 106 | restartBlueStack() 107 | $Initiate = 0 108 | Else 109 | If IsArray(ControlGetPos($Title, "_ctl.Window", "[CLASS:BlueStacksApp; INSTANCE:1]")) Then 110 | SetLog(GetLangText("msgBSLoaded") & ($Initiate) & GetLangText("msgBSLoadSecs"), $COLOR_GREEN) 111 | If $initialize Then Initiate() 112 | Else 113 | _ModifiedSleep(1000) 114 | $Initiate = $Initiate + 1 115 | Check($initialize) 116 | EndIf 117 | EndIf 118 | EndFunc ;==>Check 119 | 120 | Func getfilename($psFilename) 121 | Local $szDrive, $szDir, $szFName, $szExt 122 | _PathSplit($psFilename, $szDrive, $szDir, $szFName, $szExt) 123 | Return $szFName & $szExt 124 | EndFunc ;==>getfilename 125 | 126 | 127 | -------------------------------------------------------------------------------- /COCBot/functions/Village/DonateCheckArmyCamp.au3: -------------------------------------------------------------------------------- 1 | Func Donate_CheckArmyCamp() 2 | SetLog(GetLangText("msgCheckingCamp"), $COLOR_BLUE) 3 | $fullarmy = False 4 | 5 | If _Sleep(100) Then Return 6 | 7 | ClickP($TopLeftClient) ;Click Away 8 | 9 | If $ArmyPos[0] = "" Then 10 | If Not LocateCamp() Then Return 11 | SaveConfig() 12 | Else 13 | If _Sleep(500) Then Return 14 | Click($ArmyPos[0], $ArmyPos[1]) ;Click Army Camp 15 | EndIf 16 | 17 | _CaptureRegion() 18 | If _Sleep(500) Then Return 19 | Local $BArmyPos = _WaitForPixel(309, 581, 433, 583, Hex(0x4084B8, 6), 5) ;Finds Info button 20 | If IsArray($BArmyPos) = False Then 21 | SetLog(GetLangText("msgCampNA"), $COLOR_RED) 22 | Else 23 | Click($BArmyPos[0], $BArmyPos[1]) ;Click Info button 24 | _WaitForPixel(690, 150, 710, 170, Hex(0xD80407, 6), 5, 1) ;Finds Red Cross button in new popup window 25 | If _Sleep(200) Then Return 26 | Local $previouscampcap = Number($itxtcampCap) 27 | For $readattempts = 1 to 20 28 | $CurCamp = StringStripWS(ReadText(426, 194, 280, $textWindows), 8) 29 | $CurCamp = StringStripWS(StringMid($CurCamp, Stringinstr($CurCamp, ":") + 1), 8) 30 | $itxtcampCap = StringMid($CurCamp, Stringinstr($CurCamp, "/") + 1) 31 | If Number($itxtcampCap) > 0 And Number($itxtcampCap) < 300 And (Number($itxtcampCap) >= $previouscampcap Or $failedcampCap) And StringIsDigit($itxtcampCap) And Mod(Number($itxtcampCap),5) = 0 Then 32 | $failedcampCap = False 33 | $CurCamp = StringLeft($CurCamp, StringInStr($CurCamp, "/") - 1) 34 | If Number($CurCamp) >= 0 And Number($CurCamp) <= $itxtcampCap And StringIsDigit($CurCamp) Then 35 | SetLog(GetLangText("msgTotalCampCap") & $CurCamp & "/" & $itxtcampCap, $COLOR_GREEN) 36 | ExitLoop 37 | EndIf 38 | EndIf 39 | If _Sleep(500) Then Return 40 | If $readattempts = 20 Then 41 | SetLog(GetLangText("msgTotalCampCap") & GetLangText("lblUnknownCap"), $COLOR_GREEN) 42 | $CurCamp = 0 43 | If $itxtcampCap = 0 Then 44 | If $previouscampcap > 0 Then 45 | $itxtcampCap = $previouscampcap 46 | Else 47 | $itxtcampCap = 240 48 | $failedcampCap = True 49 | EndIf 50 | ElseIf $itxtcampCap < $previouscampcap Then 51 | $itxtcampCap = $previouscampcap 52 | EndIf 53 | EndIf 54 | Next 55 | 56 | If ($CurCamp/$itxtcampCap) >= ((_GUICtrlComboBox_GetCurSel($cmbRaidcap)+1)/10) Then 57 | $fullarmy = True 58 | Else 59 | _CaptureRegion() 60 | If $FirstStart Then 61 | $ArmyComp = 0 62 | $CurGiant = 0 63 | $CurWB = 0 64 | $CurArch = 0 65 | $CurBarb = 0 66 | $CurGoblin = 0 67 | $CurMinion = 0 68 | $CurHog = 0 69 | $CurValkyrie = 0 70 | EndIf 71 | For $i = 0 To 6 72 | Local $TroopKind = _GetPixelColor(254 + 62 * $i, 375) 73 | Local $TroopKind2 = _GetPixelColor(264 + 62 * $i, 380) 74 | Local $TroopName = "" 75 | Local $TroopQ = StringStripWS(ReadText(239 + (62 * $i), 350, 37, $textWindows), 3) 76 | If StringLeft($TroopQ, 1) = "x" Then $TroopQ = StringRight($TroopQ, StringLen($TroopQ) - 1) 77 | $TroopQ = Number($TroopQ) 78 | If _ColorCheck($TroopKind, Hex(0xEC4989, 6), 30) Then 79 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 80 | If ($CurArch = 0 And $FirstStart) Then $CurArch -= $TroopQ 81 | $TroopName = "Archers" 82 | ElseIf _ColorCheck($TroopKind, Hex(0xFFC020, 6), 30) Then 83 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 84 | If ($CurBarb = 0 And $FirstStart) Then $CurBarb -= $TroopQ 85 | $TroopName = "Barbarians" 86 | ElseIf _ColorCheck($TroopKind, Hex(0xFFC17F, 6), 30) Then 87 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 88 | If ($CurGiant = 0 And $FirstStart) Then $CurGiant -= $TroopQ 89 | $TroopName = "Giants" 90 | ElseIf _ColorCheck($TroopKind, Hex(0x90E658, 6), 30) Then 91 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 92 | If ($CurGoblin = 0 And $FirstStart) Then $CurGoblin -= $TroopQ 93 | $TroopName = "Goblins" 94 | ElseIf _ColorCheck($TroopKind, Hex(0x151F37, 6), 20) Then 95 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 96 | If ($CurMinion = 0 And $FirstStart) Then $CurMinion -= $TroopQ 97 | $TroopName = "Minions" 98 | ElseIf _ColorCheck($TroopKind, Hex(0x4C2E26, 6), 30) Then 99 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 100 | If ($CurHog = 0 And $FirstStart) Then $CurHog -= $TroopQ 101 | $TroopName = "Hogs" 102 | ElseIf _ColorCheck($TroopKind, Hex(0xA95E58, 6), 30) Then 103 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 104 | If ($CurValkyrie = 0 And $FirstStart) Then $CurValkyrie -= $TroopQ 105 | $TroopName = "Valkyries" 106 | ElseIf _ColorCheck($TroopKind2, Hex(0xD06C38, 6), 30) Then 107 | If $TroopQ = 0 Then $TroopQ = 1 ;if we found the image of a troop there has to be at least one 108 | If ($CurWB = 0 And $FirstStart) Then $CurWB -= $TroopQ 109 | $TroopName = "Wallbreakers" 110 | EndIf 111 | If $TroopName = "" Then $TroopName = "Unknown" 112 | If $TroopQ <> 0 Then SetLog("- " & $TroopName & " " & $TroopQ, $COLOR_GREEN) 113 | Next 114 | EndIf 115 | ClickP($TopLeftClient) ;Click Away 116 | $FirstCampView = True 117 | EndIf 118 | Return $fullarmy 119 | EndFunc ;==>Donate_CheckArmyCamp 120 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/GeneralFunctions.au3: -------------------------------------------------------------------------------- 1 | ; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. 2 | ; This code can be incorporated into open source/non-profit projects free of charge and without consent. 3 | ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 4 | ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org 5 | ; 6 | ;Searches for a village that until meets conditions 7 | Func IsChecked($control) 8 | Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED 9 | EndFunc ;==>IsChecked 10 | 11 | Func _ScreenShot() 12 | Local $Date = @MDAY & "." & @MON & "." & @YEAR 13 | Local $Time = @HOUR & "." & @MIN & "." & @SEC 14 | _CaptureRegion() 15 | SetLog($dirDebug & "ScreenShot-" & $Date & " at " & $Time & ".png") 16 | _GDIPlus_ImageSaveToFile($hBitmap, $dirDebug & "ScreenShot-" & $Date & " at " & $Time & ".png") 17 | EndFunc ;==>_ScreenShot 18 | 19 | Func _BumpMouse() 20 | If IsChecked($chkStayAlive) Then 21 | If $shift Then 22 | $shift = False 23 | MouseMove(MouseGetPos(0) + 1, MouseGetPos(1)) 24 | Else 25 | $shift = True 26 | MouseMove(MouseGetPos(0) - 1, MouseGetPos(1)) 27 | EndIf 28 | EndIf 29 | EndFunc ;==>_BumpMouse 30 | 31 | Func _WaitForImage($findImage, $resultPosition, ByRef $x, ByRef $y, $Tolerance, $maxDelay = 10) 32 | For $i = 1 To $maxDelay * 20 33 | $result = _ImageSearch($findImage, $resultPosition, $x, $y, $Tolerance) 34 | If $result = 1 Then Return 1 35 | If _Sleep(50) Then Return 36 | Next 37 | Return 0 38 | EndFunc ;==>_WaitForImage 39 | 40 | Func _WaitForImageArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $Tolerance, $maxDelay = 10) 41 | For $i = 1 To $maxDelay * 20 42 | $result = _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, $x, $y, $Tolerance) 43 | If $result = 1 Then Return 1 44 | If _Sleep(50) Then Return 45 | Next 46 | Return 0 47 | EndFunc ;==>_WaitForImageArea 48 | 49 | Func _WaitForColor($x, $y, $nColor2, $sVari = 5, $maxDelay = 1) 50 | For $i = 1 To $maxDelay * 20 51 | _CaptureRegion() 52 | If _ColorCheck(_GetPixelColor($x, $y), $nColor2, $sVari) Then 53 | Return True 54 | EndIf 55 | If _Sleep(50) Then Return 56 | Next 57 | Return False 58 | EndFunc ;==>_WaitForColor 59 | 60 | Func _WaitForColorArea($left, $top, $width, $height, $nColor2, $sVari = 5, $maxDelay = 1) 61 | For $i = 1 To $maxDelay * 20 62 | _CaptureRegion() 63 | For $x = $left to ($left + $width - 1) 64 | For $y = $top to ($top + $height - 1) 65 | If _ColorCheck(_GetPixelColor($x, $y), $nColor2, $sVari) Then 66 | Return True 67 | EndIf 68 | Next 69 | Next 70 | If _Sleep(50) Then Return 71 | Next 72 | Return False 73 | EndFunc ;==>_WaitForColor 74 | 75 | Func _WaitForPixel($iLeft, $iTop, $iRight, $iBottom, $iColor, $iColorVariation, $maxDelay = 10) 76 | For $i = 1 To $maxDelay * 20 77 | $result = _PixelSearch($iLeft, $iTop, $iRight, $iBottom, $iColor, $iColorVariation) 78 | If IsArray($result) Then Return $result 79 | If _Sleep(50) Then Return 80 | Next 81 | Return False 82 | EndFunc ;==>_WaitForPixel 83 | 84 | Func GetLangText($Key) 85 | $ReturnStr = "" 86 | If IsDeclared("cmbLanguage") Then 87 | $array = _GUICtrlComboBox_GetListArray($cmbLanguage) 88 | $CurrLangSel = $array[_GUICtrlComboBox_GetCurSel($cmbLanguage) + 1] 89 | $ReturnStr = IniRead(@ScriptDir & "\BrokenBot.org\languages\" & $CurrLangSel & ".ini", "general", $Key, "") 90 | If $ReturnStr = "" Then 91 | $ReturnStr = IniRead(@ScriptDir & "\BrokenBot.org\languages\English.ini", "general", $Key, "") 92 | EndIf 93 | Else 94 | $ReturnStr = IniRead(@ScriptDir & "\BrokenBot.org\languages\" & $StartupLanguage & ".ini", "general", $Key, "") 95 | If $ReturnStr = "" Then 96 | $ReturnStr = IniRead(@ScriptDir & "\BrokenBot.org\languages\English.ini", "general", $Key, "") 97 | EndIf 98 | EndIf 99 | Return $ReturnStr 100 | EndFunc ;==>GetLangText 101 | 102 | Func PopulateLanguages() 103 | $searchfile = FileFindFirstFile(@ScriptDir & "\BrokenBot.org\languages\*.ini") 104 | $txtLang = "" 105 | While True 106 | $newfile = FileFindNextFile($searchfile) 107 | If @error Then ExitLoop 108 | $txtLang = $txtLang & StringLeft($newfile, StringLen($newfile) - 4) & "|" 109 | WEnd 110 | FileClose($searchfile) 111 | $txtLang = StringLeft($txtLang, StringLen($txtLang) - 1) 112 | _GUICtrlComboBox_ResetContent($cmbLanguage) 113 | GUICtrlSetData($cmbLanguage, $txtLang) 114 | EndFunc ;==>PopulateLanguages 115 | 116 | Func _Decrypt($sData) 117 | Local $hKey = _Crypt_DeriveKey("DE8D16C2C59B93F3F0682250B", 0x00006610) 118 | Local $sDecrypted = BinaryToString(_Crypt_DecryptData(Binary($sData), $hKey, $CALG_USERKEY)) 119 | _Crypt_DestroyKey($hKey) 120 | Return $sDecrypted 121 | EndFunc ;==>_Decrypt 122 | 123 | Func _Encrypt($sData) 124 | Local $hKey = _Crypt_DeriveKey("DE8D16C2C59B93F3F0682250B", 0x00006610) 125 | Local $bEncrypted = _Crypt_EncryptData($sData, $hKey, $CALG_USERKEY) 126 | _Crypt_DestroyKey($hKey) 127 | Return $bEncrypted 128 | EndFunc ;==>_Encrypt 129 | 130 | Func urlencode($str, $plus = True) 131 | Local $i, $return, $tmp, $exp 132 | $return = "" 133 | $exp = "[a-zA-Z0-9-._~]" 134 | If $plus Then 135 | $str = StringReplace($str, " ", "+") 136 | $exp = "[a-zA-Z0-9-._~+]" 137 | EndIf 138 | For $i = 1 To StringLen($str) 139 | $tmp = StringMid($str, $i, 1) 140 | If StringRegExp($tmp, $exp, 0) = 1 Then 141 | $return &= $tmp 142 | Else 143 | $return &= StringMid(StringRegExpReplace(StringToBinary($tmp, 4), "([0-9A-Fa-f]{2})", "%$1"), 3) 144 | EndIf 145 | Next 146 | Return $return 147 | EndFunc ;==>urlencode 148 | -------------------------------------------------------------------------------- /BrokenBot.org/functions/Other/CallHelper.au3: -------------------------------------------------------------------------------- 1 | Global Const $DLLTimeout = -9 2 | Global Const $DLLFailed = -4 3 | Global Const $DLLError = -3 4 | Global Const $DLLLicense = -2 5 | Global Const $DLLNegative = -1 6 | 7 | Func CallHelper($Command, $Timeout = 30) 8 | 9 | If IsChecked($chkHelper) Then 10 | If StringInStr($Command, "BrokenBotRedLineCheck") Then 11 | $FullCommand = '""' & @ScriptDir & "\BrokenBot.org\BrokenBotHelper.exe" & '""' 12 | $FullCommand &= " 1 " 13 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 14 | $FullCommand &= $Command 15 | ElseIf StringInStr($Command, "BrokenBotReadText") Then 16 | $FullCommand = '""' & @ScriptDir & "\BrokenBot.org\BrokenBotHelper.exe" & '""' 17 | $FullCommand &= " 2 " 18 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 19 | $FullCommand &= $Command 20 | Else 21 | $FullCommand = '""' & @ScriptDir & "\BrokenBot.org\BrokenBotHelper.exe" & '""' 22 | $FullCommand &= " 3 " 23 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 24 | $FullCommand &= $Command & " " 25 | $FullCommand &= (IsChecked($chkSpeedBoost) ? ( "1" ) : ( "0" )) 26 | EndIf 27 | 28 | RegWrite("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer", "REG_SZ", $DLLTimeout) 29 | 30 | Run(@ComSpec & " /c " & $FullCommand, "", @SW_HIDE) 31 | 32 | $index = 0 33 | While (RegRead("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer") = $DLLTimeout) and $index < ($Timeout * 100) 34 | Sleep(10) 35 | $index += 1 36 | WEnd 37 | 38 | $res = StringStripWS(RegRead("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer"), 3) 39 | Return $res 40 | Else 41 | If StringInStr($Command, "BrokenBotRedLineCheck") Then 42 | $FullCommand = "1 " 43 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 44 | $FullCommand &= $Command 45 | ElseIf StringInStr($Command, "BrokenBotReadText") Then 46 | $FullCommand = "2 " 47 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 48 | $FullCommand &= $Command 49 | Else 50 | $FullCommand = "3 " 51 | $FullCommand &= (IsChecked($chkBackground) ? ( "1" ) : ( "0")) & " " 52 | $FullCommand &= $Command & " " 53 | $FullCommand &= (IsChecked($chkSpeedBoost) ? ( "1" ) : ( "0" )) 54 | EndIf 55 | 56 | $CmdLocal = StringSplit($FullCommand, " ") 57 | 58 | $BackgroundMode = Number($CmdLocal[2]) 59 | $iLeft = Number($CmdLocal[3]) 60 | $iTop = Number($CmdLocal[4]) 61 | $iRight = Number($CmdLocal[5]) 62 | $iBottom = Number($CmdLocal[6]) 63 | 64 | If $BackgroundMode = 1 Then 65 | $iW = Number($iRight) - Number($iLeft) 66 | $iH = Number($iBottom) - Number($iTop) 67 | $hDC_Capture = _WinAPI_GetWindowDC(ControlGetHandle($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]")) 68 | $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture) 69 | $hLocalHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW, $iH) 70 | $hObjectOld = _WinAPI_SelectObject($hMemDC, $hLocalHBitmap) 71 | DllCall("user32.dll", "int", "PrintWindow", "hwnd", $HWnD, "handle", $hMemDC, "int", 0) 72 | _WinAPI_SelectObject($hMemDC, $hLocalHBitmap) 73 | _WinAPI_BitBlt($hMemDC, 0, 0, $iW, $iH, $hDC_Capture, $iLeft, $iTop, 0x00CC0020) 74 | $hLocalBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hLocalHBitmap) 75 | _WinAPI_DeleteDC($hMemDC) 76 | _WinAPI_SelectObject($hMemDC, $hObjectOld) 77 | _WinAPI_ReleaseDC($HWnD, $hDC_Capture) 78 | Else 79 | $aPos = ControlGetPos($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]") 80 | If Not IsArray($aPos) Then 81 | RegWrite("HKEY_CURRENT_USER\Software\BrokenBot", "Transfer", "REG_SZ", "-4") 82 | Exit 83 | EndIf 84 | $tPoint = DllStructCreate("int X;int Y") 85 | DllStructSetData($tPoint, "X", $aPos[0]) 86 | DllStructSetData($tPoint, "Y", $aPos[1]) 87 | _WinAPI_ClientToScreen(WinGetHandle(WinGetTitle($Title)), $tPoint) 88 | $BSpos[0] = DllStructGetData($tPoint, "X") 89 | $BSpos[1] = DllStructGetData($tPoint, "Y") 90 | $hLocalHBitmap = _ScreenCapture_Capture("", $iLeft + $BSpos[0], $iTop + $BSpos[1], $iRight + $BSpos[0], $iBottom + $BSpos[1]) 91 | $hLocalBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hLocalHBitmap) 92 | EndIf 93 | 94 | If $CmdLocal[1] = 1 Then 95 | $mH = $CmdLocal[8] 96 | $mS = $CmdLocal[9] 97 | $ci = $CmdLocal[10] 98 | $cl = $CmdLocal[11] 99 | $cr = $CmdLocal[12] 100 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLocalBitmap) 101 | $res = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotRedLineCheck", "ptr", $hCheckHBitmap, "int", $mH, "int", $mS, "int", $ci, "int", $cl, "int", $cr) 102 | ElseIf $CmdLocal[1] = 2 Then 103 | $x = $CmdLocal[8] 104 | $y = $CmdLocal[9] 105 | $width = $CmdLocal[10] 106 | $height = $CmdLocal[11] 107 | $type = $CmdLocal[12] 108 | $leftaligned = $CmdLocal[13] 109 | $reversed = $CmdLocal[14] 110 | $hClone = _GDIPlus_BitmapCloneArea($hLocalBitmap, $x, $y, $width, $height, _GDIPlus_ImageGetPixelFormat($hLocalBitmap)) 111 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone) 112 | $res = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotReadText", "ptr", $hCheckHBitmap, "int", $type, "int", $leftaligned, "int", $reversed) 113 | ElseIf $CmdLocal[1] = 3 Then 114 | $Function = $CmdLocal[7] 115 | $ID = $CmdLocal[8] 116 | $MaxNum = $CmdLocal[9] 117 | $Mask = $CmdLocal[10] 118 | $SpeedBoost = $CmdLocal[11] 119 | 120 | $hCheckHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLocalBitmap) 121 | $res = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", $Function, "ptr", $hCheckHBitmap, "int", number($ID), "int", 3, "int", number($MaxNum), "int", number($Mask), "int", number($SpeedBoost)) 122 | EndIf 123 | 124 | _WinAPI_DeleteObject($hCheckHBitmap) 125 | _WinAPI_DeleteObject($hLocalHBitmap) 126 | _GDIPlus_BitmapDispose($hLocalBitmap) 127 | If IsArray($res) Then 128 | Return $res[0] 129 | Else 130 | Return -4 131 | EndIf 132 | EndIf 133 | EndFunc -------------------------------------------------------------------------------- /COCBot/functions/Village/DropTrophy.au3: -------------------------------------------------------------------------------- 1 | ;Gets trophy count of village and compares to max trophy input. 2 | ;Will drop a troop and return home with no screenshot or gold wait. 3 | 4 | Func DropTrophy() 5 | Local $i 6 | Local $TrophyCount = Number(ReadText(59, 75, 60, $textMainScreen)) 7 | If Number($TrophyCount) > Number($itxtMaxTrophy) Then 8 | SetLog(GetLangText("msgTrophyCount") & $TrophyCount, $COLOR_GREEN) 9 | While Number($TrophyCount) > Number($itxtMinTrophy) 10 | If Number($TrophyCount) > Number($itxtMinTrophy) Then 11 | SetLog(GetLangText("msgDropTrophies"), $COLOR_BLUE) 12 | If StatusCheck() Then Return False 13 | 14 | PrepareSearch() 15 | 16 | ; Make sure end battle button is visible 17 | If Not _WaitForColor(36, 523, Hex(0xEE5056, 6), 50, 10) Then 18 | ChkDisconnection() 19 | Return -1 20 | EndIf 21 | 22 | ; Make sure clouds have cleared 23 | If Not _WaitForColor(1, 670, Hex(0x02070D, 6), 50, 5) Then Return -1 24 | 25 | ; Wait just a bit extra 26 | If _Sleep(100) Then Return 27 | 28 | $KingAt = -1 29 | $QueenAt = -1 30 | $LSpellAt = -1 31 | For $i = 0 To 8 32 | If IdentifyTroopKind($i) = $eKing Then $KingAt = $i 33 | If IdentifyTroopKind($i) = $eQueen Then $QueenAt = $i 34 | If IdentifyTroopKind($i) = $eLSpell Then $LSpellAt = $i 35 | Next 36 | 37 | $Zapped = False 38 | ;~ If $LSpellAt <> -1 Then ; If we found a lightning spell 39 | ;~ $DarkElix = 0 40 | ;~ $Trophies = getTrophy(51, 66 + 90) 41 | ;~ If $Trophies <> "" Then 42 | ;~ $DarkElix = getDarkElixir(51, 66 + 57) 43 | ;~ EndIf 44 | ;~ If Number($DarkElix) >= GUICtrlRead($txtDENukeLimit) Then ; If there is enough DE present 45 | ;~ If checkDarkElix() Then ; If we can see the DE storage 46 | ;~ SelectDropTroupe($LSpellAt) ; All these checks passed so lets zap the damn thing 47 | ;~ If _Sleep(200) Then Return False 48 | ;~ $z = 0 49 | ;~ Do 50 | ;~ Click(Round(_Random_Gaussian($DEx, 2)), Round(_Random_Gaussian($DEy - 5, 2))) 51 | ;~ If _Sleep(200) Then Return False 52 | ;~ $nSpellQty = ReadTroopQuantity($LSpellAt) 53 | ;~ $z = $z + 1 54 | ;~ Until $nSpellQty = 0 Or $z = 100 55 | ;~ $Zapped = True ; We zapped, so don't bother dropping a troop 56 | ;~ EndIf 57 | ;~ EndIf 58 | ;~ If _Sleep(2000) Then Return False 59 | ;~ EndIf 60 | 61 | If Not $Zapped Then 62 | $DropTroop = 0 ; Default to dropping first troop available 63 | If $QueenAt <> -1 Then $DropTroop = $QueenAt 64 | If $KingAt <> -1 Then $DropTroop = $KingAt 65 | SelectDropTroupe($DropTroop) 66 | If _Sleep(200) Then Return False 67 | _CaptureRegion() 68 | $hAttackBitmap = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 860, 720, _GDIPlus_ImageGetPixelFormat($hBitmap)) 69 | SeekEdges() 70 | _GDIPlus_ImageDispose($hAttackBitmap) 71 | $i = 1 72 | Do 73 | Switch Random(0, 3, 1) ; I despise everything looking bottish -- lets randomly drop on some side 74 | Case 0 75 | $x = Round(_Random_Gaussian(((($FurthestTopLeft[4][0] - $FurthestTopLeft[0][0]) / 2) + $FurthestTopLeft[0][0]), (($FurthestTopLeft[4][0] - $FurthestTopLeft[0][0]) / 5))) 76 | $y = Round((($FurthestTopLeft[4][1] - $FurthestTopLeft[0][1]) / ($FurthestTopLeft[4][0] - $FurthestTopLeft[0][0])) * ($x - $FurthestTopLeft[0][0])) + $FurthestTopLeft[0][1] 77 | Case 1 78 | $x = Round(_Random_Gaussian(((($FurthestTopRight[4][0] - $FurthestTopRight[0][0]) / 2) + $FurthestTopRight[0][0]), (($FurthestTopRight[4][0] - $FurthestTopRight[0][0]) / 5))) 79 | $y = Round((($FurthestTopRight[4][1] - $FurthestTopRight[0][1]) / ($FurthestTopRight[4][0] - $FurthestTopRight[0][0])) * ($x - $FurthestTopRight[0][0])) + $FurthestTopRight[0][1] 80 | Case 2 81 | $x = Round(_Random_Gaussian(((($FurthestBottomLeft[4][0] - $FurthestBottomLeft[0][0]) / 2) + $FurthestBottomLeft[0][0]), (($FurthestBottomLeft[4][0] - $FurthestBottomLeft[0][0]) / 5))) 82 | $y = Round((($FurthestBottomLeft[4][1] - $FurthestBottomLeft[0][1]) / ($FurthestBottomLeft[4][0] - $FurthestBottomLeft[0][0])) * ($x - $FurthestBottomLeft[0][0])) + $FurthestBottomLeft[0][1] 83 | Case 3 84 | $x = Round(_Random_Gaussian(((($FurthestBottomRight[4][0] - $FurthestBottomRight[0][0]) / 2) + $FurthestBottomRight[0][0]), (($FurthestBottomRight[4][0] - $FurthestBottomRight[0][0]) / 5))) 85 | $y = Round((($FurthestBottomRight[4][1] - $FurthestBottomRight[0][1]) / ($FurthestBottomRight[4][0] - $FurthestBottomRight[0][0])) * ($x - $FurthestBottomRight[0][0])) + $FurthestBottomRight[0][1] 86 | EndSwitch 87 | If $i = 4 Then 88 | Click($x, $y) 89 | Else 90 | RedLineDeploy($x, $y) 91 | EndIf 92 | $DropFailed = False 93 | If _Sleep(100) Then Return False 94 | _CaptureRegion() 95 | If _ColorCheck(_GetPixelColor(733, 499), Hex(0xEBAD28, 6), 20) Then 96 | $DropFailed = True 97 | EndIf 98 | $i += 1 99 | Until Not $DropFailed Or $i > 4 100 | If $DropTroop = 0 Then ; Don't just assume the troop you dropped was an archer 101 | Switch IdentifyTroopKind(0) 102 | Case $eArcher 103 | $CurArch += 1 104 | Case $eBarbarian 105 | $CurBarb += 1 106 | Case $eGiant 107 | $CurGiant += 1 108 | Case $eGoblin 109 | $CurGoblin += 1 110 | Case $eWallbreaker 111 | $CurWB += 1 112 | Case Else 113 | ; I don't know what we dropped 114 | EndSwitch 115 | EndIf 116 | If _Sleep(300) Then ExitLoop 117 | EndIf 118 | 119 | ReturnHome(False, False) ;Return home no screenshot 120 | If StatusCheck() Then Return False 121 | $TrophyCount = Number(ReadText(59, 75, 60, $textMainScreen)) 122 | SetLog(GetLangText("msgTrophyCount") & $TrophyCount, $COLOR_GREEN) 123 | Else 124 | SetLog(GetLangText("msgDropComplete"), $COLOR_BLUE) 125 | EndIf 126 | WEnd 127 | Return True 128 | EndIf 129 | EndFunc ;==>DropTrophy 130 | -------------------------------------------------------------------------------- /COCBot/functions/Village/MainLoop.au3: -------------------------------------------------------------------------------- 1 | Func runBot() ;Bot that runs everything in order 2 | Local $AttackType 3 | While 1 4 | If TimerDiff($hUpdateTimer) > (1000 * 60 * 60 * 12) Then 5 | checkupdate() 6 | EndIf 7 | 8 | _ReduceMemory() ;=> added to reduce memory use 9 | 10 | ; Configuration and cleanup 11 | $Restart = False 12 | LootLogCleanup(100) 13 | SaveConfig() 14 | readConfig() 15 | applyConfig() 16 | $strPlugInInUse = IniRead($dirStrat & GUICtrlRead($lstStrategies) & ".ini", "plugin", "name", "") 17 | 18 | ;Check attack mode 19 | chkNoAttack() 20 | If StatusCheck(True, True, 3) Then Return 21 | 22 | If $FirstStart And IsChecked($chkHelper) Then 23 | $ret = CallHelper("0 0 860 720 BrokenBotRedLineCheck 1 1 0 0 0", 10) 24 | If $ret = $DLLFailed Or $ret = $DLLTimeout Then 25 | MsgBox($MB_ICONWARNING + $MB_OK, GetLangText("msgMissing"), GetLangText("msgMissingDLL1") & @CRLF & @CRLF & GetLangText("msgMissingDLL2") & @CRLF & @CRLF & GetLangText("msgMissingDLL3")) 26 | GUICtrlSetState($chkHelper, $GUI_UNCHECKED) 27 | ElseIf $ret = $DLLLicense Then 28 | MsgBox(48, "BrokenBot.org", GetLangText("msgLicense") & @CRLF & @CRLF & "Please visit BrokenBot.org") 29 | EndIf 30 | EndIf 31 | 32 | ; Collect stats 33 | VillageReport() 34 | If StatusCheck() Then Return 35 | 36 | CheckCostPerSearch() 37 | If StatusCheck() Then Return 38 | 39 | clearField() 40 | If StatusCheck() Then Return 41 | 42 | If $Checkrearm Then 43 | ReArm() 44 | $Checkrearm = False 45 | EndIf 46 | If StatusCheck() Then Return 47 | 48 | DonateCC() 49 | If StatusCheck() Then Return 50 | 51 | RequestCC() 52 | If StatusCheck() Then Return 53 | 54 | BoostAllBuilding() 55 | If StatusCheck() Then Return 56 | 57 | collectResources() 58 | If StatusCheck() Then Return 59 | 60 | Laboratory() 61 | If StatusCheck() Then Return 62 | 63 | UpgradeBuilding() 64 | If StatusCheck() Then Return 65 | 66 | UpgradeWall() 67 | If StatusCheck() Then Return 68 | 69 | UpgradeHeroes() ;==> upgradeheroes 70 | If StatusCheck() Then Return 71 | 72 | If $PushBulletEnabled = 1 And $PushBulletchatlog = 1 Then 73 | ReadChatLog(Not $ChatInitialized) 74 | EndIf 75 | If StatusCheck() Then Return 76 | 77 | Switch $CurrentMode 78 | Case $modeNormal 79 | Idle($strPlugInInUse) 80 | If StatusCheck() Then Return 81 | 82 | If DropTrophy() Then ContinueLoop 83 | If StatusCheck() Then Return False 84 | 85 | Call($strPlugInInUse & "_PrepNextBattle") 86 | 87 | While True 88 | If StatusCheck() Then Return 89 | 90 | If Not Call($strPlugInInUse & "_miniReadyCheck") Then ExitLoop 91 | 92 | If PrepareSearch() Then 93 | $AttackType = Call($strPlugInInUse & "_Search") 94 | If BotStopped(False) Then Return 95 | If $AttackType = -1 Then 96 | $SearchFailed = True 97 | ContinueLoop 98 | EndIf 99 | 100 | Call($strPlugInInUse & "_PrepareAttack", False, $AttackType) 101 | If BotStopped(False) Then Return 102 | 103 | SetLog(GetLangText("msgBeginAttack")) 104 | Call($strPlugInInUse & "_Attack", $AttackType) 105 | If BotStopped(False) Then Return 106 | 107 | ReturnHome($TakeLootSnapShot) 108 | If StatusCheck() Then Return 109 | Else 110 | If _ColorCheck(_GetPixelColor(820, 15), Hex(0xF88288, 6), 20) Then Click(820, 15) ;Click Red X 111 | If StatusCheck() Then Return 112 | ContinueLoop 113 | EndIf 114 | ExitLoop 115 | WEnd 116 | Case $modeDonateTrain 117 | $fullarmy = Donate_CheckArmyCamp() 118 | If StatusCheck() Then Return False 119 | 120 | If Not $fullarmy Then Donate_Train() 121 | If StatusCheck() Then Return False 122 | 123 | If _Sleep(5000) Then Return 124 | Case $modeDonate 125 | If _Sleep(5000) Then Return 126 | ; Why is this even a mode? 127 | Case $modeExperience 128 | Experience() 129 | EndSwitch 130 | 131 | _BumpMouse() 132 | WEnd 133 | EndFunc ;==>runBot 134 | 135 | Func Idle($Plugin) ;Sequence that runs until Full Army 136 | Local $TimeIdle = 0 ;In Seconds 137 | Local $hTimer = TimerInit() 138 | Local $prevCamp = 0 139 | Local $hTroopTimer = TimerInit() 140 | Local $TimeSinceTroop = 0 141 | While Not Call($Plugin & "_ReadyCheck", $TimeSinceTroop) 142 | If StatusCheck() Then Return 143 | SetLog(GetLangText("msgWaitingFull"), $COLOR_PURPLE) 144 | If $iCollectCounter > $COLLECTATCOUNT Then ; This is prevent from collecting all the time which isn't needed anyway 145 | collectResources() 146 | If StatusCheck() Then Return 147 | $iCollectCounter = 0 148 | EndIf 149 | $iCollectCounter += 1 150 | DonateCC() 151 | _BumpMouse() 152 | $TimeIdle = Round(TimerDiff($hTimer) / 1000, 2) ;In Seconds 153 | If $CurCamp <> $prevCamp Then 154 | $prevCamp = $CurCamp 155 | $hTroopTimer = TimerInit() 156 | EndIf 157 | If $CurCamp = 0 Or $CurCamp = "" Then 158 | $hTroopTimer = TimerInit() ; Not a good fix, but will stop errors for people whose troop size can't be read for now 159 | EndIf 160 | $TimeSinceTroop = TimerDiff($hTroopTimer) / 1000 161 | SetLog(GetLangText("msgTimeIdle") & Floor(Floor($TimeIdle / 60) / 60) & GetLangText("msgTimeIdleHours") & Floor(Mod(Floor($TimeIdle / 60), 60)) & GetLangText("msgTimeIdleMin") & Floor(Mod($TimeIdle, 60)) & GetLangText("msgTimeIdleSec"), $COLOR_ORANGE) 162 | $hIdle = TimerInit() 163 | If IsChecked($mixmodenormexp) Then 164 | Experience() 165 | EndIf 166 | If $closetofull Then 167 | $loopdelay = 1000 168 | Else 169 | $loopdelay = 30000 170 | EndIf 171 | While TimerDiff($hIdle) < $loopdelay 172 | DonateCC(True) 173 | If _Sleep(1000) Then Return 174 | WEnd 175 | If StatusCheck() Then Return 176 | WEnd 177 | EndFunc ;==>Idle 178 | 179 | Func _ReduceMemory() 180 | Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId') 181 | Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0]) 182 | Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) 183 | DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) 184 | Return $ai_Return[0] 185 | EndFunc 186 | --------------------------------------------------------------------------------