bool DistWaitStraight() { try { #region Checking if we must move or no if (Player.Location.DistanceTo(Target.Location) >= Rule.Distance) { Thread.Sleep(new Random().Next(300, 600)); return true; } #endregion #region Refreshing map byte[] map = new byte[65536]; Array.Copy(Map.MapFromMem(), 65536, map, 0, 65536); Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z)); #endregion #region Choosing a destination Location destination = new Location(-1, -1, -1); IEnumerable<Location> possibleDestinations = new List<Location>(); for (int i = 0; i < Rule.Distance; i++) { possibleDestinations = Location.Locations().Where(l => (l.DistanceTo(Target.Location) == (Rule.Distance - i)) && (!l.Equals(Player.Location)) && (!l.Equals(Target.Location)) && (Walker.Instance.LocIsWalkable(map, maploc, l, true))) .OrderByDescending(l => Math.Abs((Math.Abs(l.X - Target.X) + Math.Abs(l.Y - Target.Y)))) .OrderBy(l => l.DistanceTo(Player.Location)); if (possibleDestinations.Count() > 0) { destination = possibleDestinations.FirstOrDefault(); break; } } #endregion #region Walking if (destination.IsValid()) { Walker.Instance.Walksender = WalkSender.Targeting; Walker.Instance.SkipNode = false; Walker.Instance.WalkingMethod = CaveBot.Instance.WalkingMethod; Walker.Instance.SpecialAreas.Clear(); foreach (SpecialArea area in CaveBot.Instance.SpecialAreasList.Where(a => a.Active && a.Consideration == WalkSender.Targeting)) Walker.Instance.SpecialAreas.Add(area); Walker.Instance.Start = Player.Location; if (!destination.IsValid()) return true; Walker.Instance.End = destination; bool result = false; Queues.Add(Task.TargeterStance, new Action(() => { result = Walker.Instance.Walk(); }), 90, 100, true, true); if (destination != Target.Location) Thread.Sleep(50); return result; } #endregion } catch (InvalidOperationException ex) { Helpers.Debug.Report(ex); } catch (NullReferenceException ex) { Helpers.Debug.Report(ex); } return true; }
bool MeleeParry() { try { #region Checking if we must move or no List<Creature> creatures = Creature.CreaturesInBw().Where(c => Targeting.Instance.InTargeting(c.Name) && c.Location.IsAdjacentTo(Player.Location) && c.ID != Target.ID).ToList(); System.Diagnostics.Debug.WriteLine(String.Format("creatures.Count: {0}", creatures.Count)); if (creatures.Count == 0) { Thread.Sleep(new Random().Next(300,600)); return true; } #endregion #region Refreshing map byte[] map = new byte[65536]; Array.Copy(Map.MapFromMem(), 65536, map, 0, 65536); Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z)); #endregion #region Choosing a destination Location destination = new Location(-1, -1, -1); List<Location> locationsWithMonster = new List<Location>(); if (creatures.Count > 0) { creatures.ForEach(c => { locationsWithMonster.Add(c.Location); }); locationsWithMonster = locationsWithMonster.OrderBy(l => l.DistanceTo(Player.Location)).ToList(); } destination = Location.Locations().Where(l => (l.DistanceTo(Target.Location) == 1) && (!l.Equals(Player.Location)) && (!l.Equals(Target.Location))) .OrderByDescending(l => l.DistanceTo(locationsWithMonster.ElementAt(0))) .FirstOrDefault(); #endregion #region Walking if (destination.IsValid()) { Walker.Instance.Walksender = WalkSender.Targeting; Walker.Instance.SkipNode = false; Walker.Instance.WalkingMethod = CaveBot.Instance.WalkingMethod; Walker.Instance.SpecialAreas.Clear(); foreach (SpecialArea area in CaveBot.Instance.SpecialAreasList.Where(a => a.Active && a.Consideration == WalkSender.Targeting)) Walker.Instance.SpecialAreas.Add(area); Walker.Instance.Start = Player.Location; if (!destination.IsValid()) return true; Walker.Instance.End = destination; bool result = false; Queues.Add(Task.TargeterStance, new Action(() => { result = Walker.Instance.Walk(); }), 90, 100, true, true); if (destination != Target.Location) Thread.Sleep(50); return result; } #endregion } catch (InvalidOperationException ex) { Helpers.Debug.Report(ex); } catch (NullReferenceException ex) { Helpers.Debug.Report(ex); } return true; }
bool MeleeStrike() { try { Location destination = new Location(-1, -1, -1); if (Player.Location.DistanceTo(Target.Location) > 1) { Thread.Sleep(250); return true; } else { #region Refreshing map byte[] map = new byte[65536]; Array.Copy(Map.MapFromMem(), 65536, map, 0, 65536); Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z)); #endregion #region Player.X != Target.X ( and Player.Y == Target.Y ) if ((Player.X != Target.X) && (Player.Y != Target.Y)) { destination = Location.GetLocationsDimension(2, 2, 2, 2).Where(l => (l.X == Target.X || l.Y == Target.Y) && Walker.Instance.LocIsWalkable(map, maploc, l, true)) .OrderBy(l => Player.Location.DistanceTo(l)).FirstOrDefault(); } #endregion } #region Walking if (destination.IsValid()) { Walker.Instance.Walksender = WalkSender.Targeting; Walker.Instance.SkipNode = false; Walker.Instance.WalkingMethod = CaveBot.Instance.WalkingMethod; Walker.Instance.SpecialAreas.Clear(); foreach (SpecialArea area in CaveBot.Instance.SpecialAreasList.Where(a => a.Active && a.Consideration == WalkSender.Targeting)) Walker.Instance.SpecialAreas.Add(area); Walker.Instance.Start = Player.Location; Walker.Instance.End = destination; bool result = false; Queues.Add(Task.TargeterStance, new Action(() => { result = Walker.Instance.Walk(); }), 90, 100, true, true); if (destination != Target.Location) Thread.Sleep(50); return result; } #endregion #region Turn to monster if ((Player.X == Target.X) && (Player.Y == Target.Y - 1)) InputControl.Turn(2); if ((Player.X == Target.X) && (Player.Y == Target.Y + 1)) InputControl.Turn(8); if ((Player.X == Target.X + 1) && (Player.Y == Target.Y)) InputControl.Turn(4); if ((Player.X == Target.X - 1) && (Player.Y == Target.Y)) InputControl.Turn(6); #endregion } catch (InvalidOperationException ex) { Helpers.Debug.Report(ex); } catch (NullReferenceException ex) { Helpers.Debug.Report(ex); } return false; }
bool MeleeCircle() { try { Location destination = new Location(-1, -1, -1); #region Refreshing map byte[] map = new byte[65536]; Array.Copy(Map.MapFromMem(), 65536, map, 0, 65536); Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z)); #endregion #region Choosing a destination destination = Location.Locations().Where(l => (l.DistanceTo(Target.Location) == 2) && (Walker.Instance.LocIsWalkable(map, maploc, l, true))) .OrderByDescending(l => Math.Abs(l.X - Target.X)) .OrderByDescending(l => Math.Abs(l.Y - Target.Y)) .OrderBy(l => Player.Location.DistanceTo(l)) .FirstOrDefault(); #endregion #region Walking if (destination.IsValid()) { Walker.Instance.Walksender = WalkSender.Targeting; Walker.Instance.SkipNode = false; Walker.Instance.WalkingMethod = CaveBot.Instance.WalkingMethod; Walker.Instance.SpecialAreas.Clear(); foreach (SpecialArea area in CaveBot.Instance.SpecialAreasList.Where(a => a.Active && a.Consideration == WalkSender.Targeting)) Walker.Instance.SpecialAreas.Add(area); Walker.Instance.Start = Player.Location; if (!destination.IsValid()) return true; Walker.Instance.End = destination; bool result = false; Queues.Add(Task.TargeterStance, new Action(() => { result = Walker.Instance.Walk(); }), 90, 100, true, true); if (destination != Target.Location) Thread.Sleep(50); return result; } #endregion } catch (InvalidOperationException ex) { Helpers.Debug.Report(ex); } catch (NullReferenceException ex) { Helpers.Debug.Report(ex); } return true; }
bool MeleeApproach() { try { Location destination = new Location(-1, -1, -1); if (Player.Location.DistanceTo(Target.Location) > 1) { destination = Target.Location; } else { #region Refreshing map byte[] map = new byte[65536]; Array.Copy(Map.MapFromMem(), 65536, map, 0, 65536); Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z)); #endregion #region Player.X == Target.X if (Player.X == Target.X) { Thread.Sleep(100); if (new Random().Next(1, 2) == 1) { if (Walker.Instance.LocIsWalkable(map,maploc,Location.LocationDir(LocDirection.Left, Player.Location),true)) destination = Location.LocationDir(LocDirection.Left, Player.Location); else if (Walker.Instance.LocIsWalkable(map,maploc,Location.LocationDir(LocDirection.Right, Player.Location),true)) destination = Location.LocationDir(LocDirection.Right, Player.Location); } else { if (Walker.Instance.LocIsWalkable(map,maploc,Location.LocationDir(LocDirection.Right, Player.Location),true)) destination = Location.LocationDir(LocDirection.Right, Player.Location); else if (Walker.Instance.LocIsWalkable(map, maploc, Location.LocationDir(LocDirection.Left, Player.Location), true)) destination = Location.LocationDir(LocDirection.Left, Player.Location); } } #endregion #region Player.Y == Target.Y if (Player.Y == Target.Y) { Thread.Sleep(100); if (new Random().Next(1, 2) == 1) { if (Walker.Instance.LocIsWalkable(map,maploc,Location.LocationDir(LocDirection.Up, Player.Location))) destination = Location.LocationDir(LocDirection.Up, Player.Location); else if (Walker.Instance.LocIsWalkable(map, maploc, Location.LocationDir(LocDirection.Down, Player.Location))) destination = Location.LocationDir(LocDirection.Down, Player.Location); } else { if (Walker.Instance.LocIsWalkable(map, maploc, Location.LocationDir(LocDirection.Down, Player.Location))) destination = Location.LocationDir(LocDirection.Down, Player.Location); else if (Walker.Instance.LocIsWalkable(map, maploc, Location.LocationDir(LocDirection.Up, Player.Location))) destination = Location.LocationDir(LocDirection.Up, Player.Location); } } #endregion } #region Walking if (destination.IsValid()) { Walker.Instance.Walksender = WalkSender.Targeting; Walker.Instance.SkipNode = false; Walker.Instance.WalkingMethod = CaveBot.Instance.WalkingMethod; Walker.Instance.SpecialAreas.Clear(); foreach (SpecialArea area in CaveBot.Instance.SpecialAreasList.Where(a => a.Active && a.Consideration == WalkSender.Targeting)) Walker.Instance.SpecialAreas.Add(area); Walker.Instance.Start = Player.Location; Walker.Instance.End = destination; bool result = false; Queues.Add(Task.TargeterStance, new Action(() => { result = Walker.Instance.Walk(); }), 90, 100, true, true); if (destination != Target.Location) Thread.Sleep(50); return result; } #endregion } catch (InvalidOperationException ex) { Helpers.Debug.Report(ex); } catch (NullReferenceException ex) { Helpers.Debug.Report(ex); } return false; }