public static ClickablePoint GetDonateButton() { int left = ScreenData.ChatArea.Left; int top = ScreenData.ChatArea.Top; int right = ScreenData.ChatArea.Right; int bottom = ScreenData.ChatArea.Bottom; int count = 0; do { DetectableArea area = new DetectableArea(left, top, right, bottom, ScreenData.ChatArea.Color, ScreenData.ChatArea.ShadeVariation); ClickablePoint p1 = CoCHelper.SearchPixelInRect(area); if (!p1.IsEmpty && !(p1.Point.X == -1 || p1.Point.Y == -1)) { return(p1); } if (count >= 100) { break; } if (!p1.IsEmpty && !(p1.Point.X == -1 || p1.Point.Y == -1)) { top = p1.Point.Y; } count++; } while (true); return(new ClickablePoint()); }
public static bool CheckObstacles() { ClickablePoint messagePos = CoCHelper.SearchPixelInRect(ScreenData.Inactivity); if (!messagePos.IsEmpty) { CoCHelper.Click(ScreenData.ReloadButton); Thread.Sleep(7000); return(true); } if (CoCHelper.CheckPixelColor(ScreenData.Attacked)) { CoCHelper.Click(ScreenData.AttackedBtn); return(true); } // The main screen if (CoCHelper.CheckPixelColor(ScreenData.IsMainGrayed)) { CoCHelper.Click(ScreenData.TopLeftClient); return(true); } // If we have a screen with a small x to cancel it, like when you start a fight. if (CoCHelper.CheckPixelColor(ScreenData.SomeXCancelBtn)) { CoCHelper.Click(ScreenData.SomeXCancelBtn); return(true); } // If a fight is on going, than cancel it. if (CoCHelper.CheckPixelColor(ScreenData.CancelFight) || CoCHelper.CheckPixelColor(ScreenData.CancelFight2)) { CoCHelper.Click(ScreenData.CancelFight); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(331, 330), Color.FromArgb(240, 160, 59), 20)) { CoCHelper.ClickBad(new Point(331, 330), 1); Thread.Sleep(1000); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(429, 519), Color.FromArgb(184, 227, 95), 20)) { CoCHelper.ClickBad(new Point(429, 519), 1); return(true); } if (CoCHelper.CheckPixelColorBad(new Point(71, 530), Color.FromArgb(192, 0, 0), 20)) { CoCHelper.ClickBad(new Point(331, 330), 1); ReturnHome(false, false); return(true); } return(false); }
public static void ReArmTraps() { Main.Bot.WriteToOutput("Re-arming all traps...", GlobalVariables.OutputStates.Information); ClickablePoint thPos = new ClickablePoint(109, 309); //(ClickablePoint) DataCollection.BuildingPoints.Where(b => b.Building == Building.TownHall); if (thPos.IsEmpty) { //Main.Bot.LocateTownHall(); TAGS: Ph!d } Tools.CoCHelper.Click(ScreenData.TopLeftClient, 2, 50); Thread.Sleep(500); Tools.CoCHelper.Click(thPos); Thread.Sleep(500); ClickablePoint trapsBtn = Tools.CoCHelper.SearchPixelInRect(ScreenData.ReArmTrapsButton); if (trapsBtn.IsEmpty) { Main.Bot.WriteToOutput("No traps to be re-armed...", GlobalVariables.OutputStates.Information); } else { ClickablePoint reArmBtnMiddle = new ClickablePoint(trapsBtn.Point.X - 30, trapsBtn.Point.Y + 30); Tools.CoCHelper.Click(reArmBtnMiddle); Thread.Sleep(500); Tools.CoCHelper.Click(ScreenData.ReArmTrapsConfirmationButton); Main.Bot.WriteToOutput("All traps re-armed...", GlobalVariables.OutputStates.Information); } }
public static void WaitForMainScreen() { Main.Bot.WriteToOutput("Waiting for Main Screen"); for (int i = 0; i < 150; i++) { if (!CoCHelper.CheckPixelColor(ScreenData.IsMain)) { Thread.Sleep(2000); if (CheckObstacles()) { i = 0; } } else { return; } } Main.Bot.WriteToOutput("Unable to load Clash of Clans, Restarting..."); ClickablePoint appPos = GetAppPos(); CoCHelper.Click(appPos, 1); Thread.Sleep(10000); }
public static bool TrainIt(Troop troopKind, int count) { ClickablePoint pos = ScreenData.GetTrainPos(troopKind); if (!pos.IsEmpty) { Tools.CoCHelper.Click(pos, count, 100); return(true); } return(false); }
public static ClickablePoint GetAppPos() { ClickablePoint p1 = CoCHelper.SearchPixelInRect(ScreenData.ClashApp); if (CoCHelper.IsInColorRange(new ClickablePoint(p1.Point.X + ScreenData.ClashApp2.Point.X, p1.Point.Y + ScreenData.ClashApp2.Point.Y), ScreenData.ClashApp2.Color, ScreenData.ClashApp2.ShadeVariation)) { if (CoCHelper.IsInColorRange(new ClickablePoint(p1.Point.X + ScreenData.ClashApp3.Point.X, p1.Point.Y + ScreenData.ClashApp3.Point.Y), ScreenData.ClashApp3.Color, ScreenData.ClashApp3.ShadeVariation)) { return(p1); } } return(new ClickablePoint()); }
public static void RequestTroops() { if (Main.Bot.IsRequestTroops) { ClickablePoint ccPos = new ClickablePoint(356, 432); //(ClickablePoint)Main.Bot.LocationClanCastle; if (ccPos.IsEmpty) { Main.Bot.LocateClanCastle(); } Main.Bot.WriteToOutput("Requesting for Clan Castle Troops..."); Tools.CoCHelper.Click(ccPos); Thread.Sleep(500); ClickablePoint requestTroop = GetRequestTroopsButton(); if (!requestTroop.IsEmpty) { Tools.CoCHelper.Click(requestTroop); Thread.Sleep(2000); // FF, this only works if forceCapture is Enabled. I modified the CheckPixelColor method slightly until the problem is fixed. => Please check this again, should be fixed if (Tools.CoCHelper.CheckPixelColor(ScreenData.RequestTroopsRedCancel)) { if (!string.IsNullOrEmpty(Main.Bot.RequestTroopsMessage)) { Tools.CoCHelper.Click(ScreenData.RequestTroopsText); Thread.Sleep(300); KeyboardHelper.SendToBS(Main.Bot.RequestTroopsMessage); // TODO: Sending Keystrokes to BlueStacks does not work! Tags: Ph!d, FastFrench } Thread.Sleep(1000); Tools.CoCHelper.Click(ScreenData.RequestTroopsGreenSend); Main.Bot.WriteToOutput("Request successfully made..."); } else { Main.Bot.WriteToOutput("Request's already been made..."); Tools.CoCHelper.Click(ScreenData.TopLeftClient, 2, 50); } } else { Main.Bot.WriteToOutput("Clan Castle not available..."); } } }
public static void CheckMainScreen() { Main.Bot.WriteToOutput(Properties.Resources.OutputTryingToLocateMainScreen, GlobalVariables.OutputStates.Information); while (!CoCHelper.CheckPixelColor(ScreenData.IsMain)) { Thread.Sleep(1000); if (!CheckObstacles()) { ClickablePoint appPos = GetAppPos(); CoCHelper.Click(appPos, 1); } WaitForMainScreen(); } Main.Bot.WriteToOutput("Main Screen Located", GlobalVariables.OutputStates.Information); }
public static ClickablePoint GetRequestTroopsButton() { int left = ScreenData.RequestTroopsButton.Left; int top = ScreenData.RequestTroopsButton.Top; int right = ScreenData.RequestTroopsButton.Right; int bottom = ScreenData.RequestTroopsButton.Bottom; int count = 0; do { DetectableArea area = new DetectableArea(left, top, right, bottom, ScreenData.RequestTroopsButton.Color, ScreenData.RequestTroopsButton.ShadeVariation); ClickablePoint p1 = Tools.CoCHelper.SearchPixelInRect(area); if (!p1.IsEmpty && !(p1.Point.X == -1 || p1.Point.Y == -1)) { if (Tools.CoCHelper.IsInColorRange(new ClickablePoint(p1.Point.X + ScreenData.RequestTroopsButton2.Point.X, p1.Point.Y + ScreenData.RequestTroopsButton2.Point.Y), ScreenData.RequestTroopsButton2.Color, ScreenData.RequestTroopsButton2.ShadeVariation)) { return(p1); } } if (count >= 6) { break; } else { if (!p1.IsEmpty && !(p1.Point.X == -1 || p1.Point.Y == -1)) { left = p1.Point.X; top = p1.Point.Y; } count++; } } while (true); return(new ClickablePoint()); }
static public bool IsInColorRange(ClickablePoint point, Color color, int shadeVariation = 0) { return(FastFindHelper.IsInColorRange(point, color, shadeVariation)); }
static public Color GetPixelColor(ClickablePoint point, bool fn = false) { return(FastFindHelper.GetPixelColor(point, fn)); }
static public bool Click(ClickablePoint point, int nbClick = 1, int delay = 20) { return(BlueStacksHelper.Click(point, nbClick, delay)); }