public async Task ScanMini(bool autoClose = true) { while (ai.isIdle == false) { Console.WriteLine("Press the Enter key to exit the program at any time... "); Console.ReadLine(); Log.Info("Scanning for Mini Boss... Please wait..."); await this.Action.OpenMVP(); Point MonsterImage; //await Task.Delay(2000); Bitmap bmp = ImageSearch.PrintWindow((IntPtr)screenHandle); MonsterImage = ImageSearch.SearchFromImage(bmp, "resources/smokie.png"); Timer_Mini = new List <int>(); Bitmap crop; if (MonsterImage.X == -1 && MonsterImage.Y == -1) { Log.Error("Cannot find a reference point."); } //TODO export loop to aync function for (int i = 0; i < 5; i++) { try { Point TempPoint; bmp = ImageSearch.PrintWindow((IntPtr)screenHandle); TempPoint = new Point(MonsterImage.X + 360, MonsterImage.Y + 110 * i); crop = ImageSearch.CropImage(bmp, TempPoint, 180, 50); crop.Save($"mob{i}.bmp"); Timer_Mini.Add(OCR.ExtractTime(OCR.RawOCR(crop))); Log.Info($"{MobName_Mini[i]}: {Timer_Mini[i].ToString()} minutes"); await Task.Delay(400); } catch (Exception e) { Log.Info($"Error {e}"); } } //TODO //var loop = asyncFunctionCall() //check timer: while loop is not resolved? // if timer > 10 seconds: continue to line 123 // await loop Log.Success("Successfully scanned!"); if (autoClose) { this.ClickImage("resources/close-button.png"); } await Scheduler.ScheduleHunt(Timer_Mini); } }
public async Task <int> GetMonsterSpawnTime(Point point) { var bmp = ImageSearch.PrintWindow((IntPtr)screenHandle); var timeArea = new Point(point.X + 360, point.Y); var crop = ImageSearch.CropImage(bmp, timeArea, 180, 50); //crop.Save($"mob{imageName}.bmp"); int waitTime = OCR.ExtractTime(this.ai.OCR.RawOCR(crop)); //Log.Info($"{imageName}: {Timer_Mini_extra} minutes"); await Task.Delay(400); return(waitTime); }
private void ScanImage(List <Monster> monsterList) { foreach (var monster in monsterList) { Bitmap bmp = ImageSearch.PrintWindow((IntPtr)_ai.screenHandle); var leftBmp = ImageSearch.CropImage(bmp, new Point(0, 0), 720, 670); Point location = Scan(leftBmp, monster.GetImagePath()); if (location.X == -1 && location.Y == -1) { continue; } location.Y += monster.GetMonsterImagePositionOffsetY(); location.X += 360; Bitmap crop = ImageSearch.CropImage(bmp, location, 185, 60); monster.MinutesToSpawn = OCR.ExtractTime(_OCR.RawOCR(crop)); //_log.Info($"{monster.GetName()}: {monster.MinutesToSpawn} minutes"); } }
//990,395 public async Task GoToKafraAgent() { await Task.Delay(500); await ai.Action.ButterflyWing(); await Task.Delay(4000); await DelayOnLocation(); await OpenMap(); await Task.Delay(600); var kafraLocationOnMap = new Point(990, 395); ai.Click(kafraLocationOnMap); await CloseMap(); await Task.Delay(7000); Bitmap bmp = ImageSearch.PrintWindow((IntPtr)ai.screenHandle); await Task.Delay(250); Point kafraImg = await GetKafraImage(bmp); await Task.Delay(250); Bitmap bmp2 = ImageSearch.CropImage(bmp, kafraImg); ai.Click(new Point(kafraImg.X + 2, kafraImg.Y - 2));//adjusted click from image await Task.Delay(1000); //ai.ClickImage("resources/teleport.png"); ai.Click(new Point(1112, 472));//teleport await Task.Delay(2000); }
public async Task <string> GetCurrentLocation() { await Task.Delay(200); var isMapOpen = await IsMapOpen(); var map = new Point(1188, 49); if (isMapOpen) { ai.Click(new Point(1243, 134));//close map await Task.Delay(200); ai.Click(map); //1188, 49 } else { ai.Click(map); //1188, 49 } await Task.Delay(300); Bitmap bmp2 = new Bitmap(ImageSearch.PrintWindow((IntPtr)this.ai.screenHandle)); var TempPoint = new Point(940, 150); Bitmap crop = ImageSearch.CropImage(bmp2, TempPoint, 220, 40); var text = ai.getOCRText(crop); Regex regex = new Regex(@"([a-zA-Z\s]+)"); Match match = regex.Match(text); var val = match.Groups[0].Value; string location = ""; if (val.Length < 10 && val.Contains("tera")) { location = "Prontera"; } else if (val.Contains("West")) { location = "Prontera West Gate"; } else if (val.Contains("Lab")) { location = "Labyrinth Forest"; } else if (val.Contains("SDuth") && val.Contains("Gate")) { location = "Prontera South Gate"; } else if (val.Contains("GDblin FDrest") || val.Contains("GDblin") || val.Contains("Goblin") || val.Contains("Goblin Forest")) { location = "Goblin Forest"; } else if (val.Contains("Desert")) { location = "Sograt Desert"; } else if (val.Contains("Cave")) { location = "Underwater Cave"; } else if (val.Contains("ntains")) { location = "Mjolnir Mountains"; } else if (val.Contains("Pay") && val.Contains("SDuth")) { location = "Payon South"; } var westgate = val.Length; bmp2.Dispose(); await Task.Delay(400); ai.Click(new Point(1243, 134));//close map return(location); }