예제 #1
0
        public Walker(Location start, Location end, ObservableCollection<SpecialArea> specialAreas, WalkSender sender)
        {
            _start = start;
            _end = end;
            _walkSender = sender;
            _specialAreas = specialAreas;

        }
예제 #2
0
        public Walker(Location start, Location end)
        {
            _start = start;
            _end = end;

        }
예제 #3
0
 public Point GetPointFromLocation(Location location)
 {
     return new Point(GetXfromLoc(location.X), GetYfromLoc(location.Y));
 }
예제 #4
0
 public Waypoint(WaypointType waypointType, Location location, string action)
 {
     _waypointType = waypointType;
     _location = location;
     _action = action;
 }
예제 #5
0
 public void UseOnMap(Location location, int amount = -1) { }
예제 #6
0
        public void RightClickLoc(Location l)
        {
            int x = GuiGameScreen.Instance.GetXfromLoc(l.X);
            int y = GuiGameScreen.Instance.GetYfromLoc(l.Y);

            switch (_inputType)
            {
                case InputType.Simulate:
                    NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0204, (IntPtr)0, (IntPtr)MakeLParam(x, y));
                    Thread.Sleep(Utils.RandomNumber(_clickTimeStart, _clickTimeEnd));
                    NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0205, (IntPtr)0, (IntPtr)MakeLParam(x, y));
                    break;

                case InputType.Control:
                    MouseMove(new Point(x, y));
                    NativeMethods.mouse_event(MOUSEEVENTF_RIGHTDOWN, x + GameClient.TibiaWindow.Left, y + GameClient.TibiaWindow.Top, 0, (IntPtr)0);
                    Thread.Sleep(Utils.RandomNumber(_clickTimeStart, _clickTimeEnd));
                    NativeMethods.mouse_event(MOUSEEVENTF_RIGHTUP, x + GameClient.TibiaWindow.Left, y + GameClient.TibiaWindow.Top, 0, (IntPtr)0);
                    break;
            }
        }
예제 #7
0
 public double DistanceTo( Location l )
 {
     int xDist = X - l.X;
     int yDist = Y - l.Y;
     int x = (int)Math.Sqrt(xDist * xDist + yDist * yDist);
     return x;
 }
예제 #8
0
 public static Location LocationDir(LocDirection direction, Location baselocation)
 {
     switch (direction)
     {
         case LocDirection.Up:
             return new Location(baselocation.X, baselocation.Y - 1, baselocation.Z);
         case LocDirection.Down:
             return new Location(baselocation.X, baselocation.Y + 1, baselocation.Z);
         case LocDirection.Right:
             return new Location(baselocation.X + 1, baselocation.Y, baselocation.Z);
         case LocDirection.Left:
             return new Location(baselocation.X - 1, baselocation.Y, baselocation.Z);
     }
     return new Location();
 }
예제 #9
0
        public bool LocIsWalkable(byte[] map, Location maploc, Location location, bool senderTargeting = false)
        {
            try
            {
                int dimensionX = location.X - maploc.X;
                int dimensionY = location.Y - maploc.Y;

                byte[][] mapTransformed = new byte[256][];
                for (int i = 0; i < 256; i++)
                    mapTransformed[i] = new byte[256];

                int counter = 0;

                for (int x = 0; x < 256; x++)
                    for (int y = 0; y < 256; y++)
                    {
                        mapTransformed[x][y] = map[counter];
                        counter++;
                    }

                if (dimensionX < 0 || dimensionX > 255)
                    return false;
                if (dimensionY < 0 || dimensionY > 255)
                    return false;

                if (senderTargeting)
                {
                    foreach (SpecialArea area in SpecialAreas.Where(a => a.Active && a.Consideration == WalkSender.Targeting))
                        foreach (Location l in area.Locations)
                        {
                            Point p = LocToPoint(l);
                            mapTransformed[dimensionX][dimensionY] = 0xFF;
                        }
                }

                if (mapTransformed[dimensionX][dimensionY] != 0xFF && mapTransformed[dimensionX][dimensionY] != 0xFA)
                    return true;
                else
                    return false;
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
            return false;
        }
예제 #10
0
        public bool LocIsWalkable(Location location)
        {
            try
            {

                Array.Clear(MemMapa(), 0, MemMapa().Length);

                Array.Copy(Map.MapFromMem(), 65536, MemMapa(), 0, 65536);

                Location maploc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z));

                int dimensionX = location.X - maploc.X;
                int dimensionY = location.Y - maploc.Y;

                byte[][] mapTransformed = new byte[256][];
                for (int i = 0; i < 256; i++)
                    mapTransformed[i] = new byte[256];


                int counter = 0;

                for (int x = 0; x < 256; x++)
                    for (int y = 0; y < 256; y++)
                    {
                        mapTransformed[x][y] = MemMapa()[counter];
                        counter++;
                    }

                if (dimensionX < 0 || dimensionX > 255)
                    return false;
                if (dimensionY < 0 || dimensionY > 255)
                    return false;

                if (mapTransformed[dimensionX][dimensionY] != 0xFF)
                    return true;
                else
                    return false;
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
            return false;
        }
예제 #11
0
 public Walker(Location start, Location end, ObservableCollection<SpecialArea> specialAreas)
 {
     _start = start;
     _end = end;
     _specialAreas = specialAreas;
 }
예제 #12
0
        public static Point LocToPoint(Location l)
        {
            try
            {
                Point p = new Point();
                Location maploc = Map.MapToLocation(Map.MapFileName(Player.X - 256, Player.Y - 256, Player.Z));

                p.X = l.X - maploc.X;
                p.Y = l.Y - maploc.Y;

                return p;
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
            return new Point();
        }
예제 #13
0
        public static Location PointToLoc(int x, int y)
        {
            try
            {
                Location l = new Location();
                Location maploc = Map.MapToLocation(Map.MapFileName(Player.X - 256, Player.Y - 256, Player.Z));

                l.X = maploc.X + x;
                l.Y = maploc.Y + y;
                l.Z = (int)Player.Z;

                return l;
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
            return new Location();
        }
예제 #14
0
 public Walker(Location start, Location end, WalkSender sender)
 {
     _start = start;
     _end = end;
     _walkSender = sender;
 }
예제 #15
0
        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;
        }
예제 #16
0
        public void DrawMap(Collection<Location> locations, bool onlyscreen = false)
        {
            GuiGameScreen.Instance.UpdateGUI();

            Rectangle rect;

            Location baseloc = new Location();
            baseloc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z));
            Collection<Tile> tiles = new Collection<Tile>();

            byte[,] map = new byte[1024, 1024];

            map = Walker.Instance.Map.GetMap(true, out tiles);


            foreach (Tile tile in tiles)
            {
                int x = tile.LocationOnMap.OffsetX;
                int y = tile.LocationOnMap.OffsetY;

                Location location = new Location(x, y, (int)Player.Z);

                int a = onlyscreen ? x : x + 256;
                int b = onlyscreen ? y : y + 256;

                bool walkable = map[tile.PathfinderPoint.X, tile.PathfinderPoint.Y] == (byte)4 ? true : false;

                rect = new Rectangle
                {
                    Width = (GuiGameScreen.Instance.Width / 15),
                    Height = (GuiGameScreen.Instance.Height / 11)
                };

                double cx = x * rect.Width + 2 + GuiGameScreen.Instance.PositionX;
                double cy = y * rect.Height + 2 + GuiGameScreen.Instance.PositionY;

                rect.RadiusX = 3;
                rect.RadiusY = 3;

                rect.SnapsToDevicePixels = true;

                rect.Stroke = Brushes.Green;

                int yspan = 0;

                if (walkable)
                    rect.Stroke = Brushes.Green;
                else
                    rect.Stroke = Brushes.Red;

                if (CaveBot.Instance.DrawItems)
                {
                    foreach (TileItem item in tile.GetItems())
                    {
                        if (item.id != 0)
                        {
                            //PipeClient.Instance.Send(new HudItem(string.Format("{0}{1}{2}", cx, cy, yspan), (uint)cx, (uint)cy + (uint)yspan, 255, 255, 255, 2, item.id.ToString()).ToNetworkMessage());
                            Text(cx, cy + yspan, item.id.ToString(), Colors.White);
                            yspan += 10;
                        }
                    }
                }


                Canvas.SetLeft(rect, cx);
                Canvas.SetTop(rect, cy);

                if (CaveBot.Instance.DrawMap)
                    canvasObj.Children.Add(rect);
            }
        }
예제 #17
0
        public static Collection<Location> GetLocationsDimension(Location baseLocation, int left, int top, int right, int down)
        {
            Collection<Location> result = new Collection<Location>();
            Location InitialPosition = baseLocation;

            for (int i = 0; i < left; i++)
                result.Add(new Location(InitialPosition.X - left + i, InitialPosition.Y, InitialPosition.Z));

            for (int i = 0; i <= right; i++)
                result.Add(new Location(InitialPosition.X + i, InitialPosition.Y, InitialPosition.Z));

            for (int i = 0; i < top; i++)
                result.Add(new Location(InitialPosition.X, InitialPosition.Y - top + i, InitialPosition.Z));

            for (int i = 0; i <= down; i++)
                result.Add(new Location(InitialPosition.X, InitialPosition.Y + i, InitialPosition.Z));

            return result;
        }
예제 #18
0
        public void DrawLocations(Collection<Location> locations, bool onlyscreen = false)
        {
            GuiGameScreen.Instance.UpdateGUI();

            Rectangle rect;

            Location baseloc = new Location();
            baseloc = Map.MapToLocation(Map.MapFileName(Player.X, Player.Y, Player.Z));

            Location location;

            for (int x = 0; x < 15; x++)
                for (int y = 0; y < 11; y++)
                {
                    location = new Location((int)Player.X - 7 + x, (int)Player.Y - 5 + y, (int)Player.Z);

                    if (locations != null)
                        if (!locations.Contains(location))
                            continue;

                    int a = onlyscreen ? (int)Player.X - baseloc.X - 7 + x : (int)Player.X - baseloc.X - 7 + x + 256;
                    int b = onlyscreen ? (int)Player.Y - baseloc.Y - 5 + y : (int)Player.Y - baseloc.Y - 5 + y + 256;

                    rect = new Rectangle
                    {
                        Width = (GuiGameScreen.Instance.Width / 15),
                        Height = (GuiGameScreen.Instance.Height / 11)
                    };

                    double cx = x * rect.Width + 2 + GuiGameScreen.Instance.PositionX;
                    double cy = y * rect.Height + 2 + GuiGameScreen.Instance.PositionY;

                    rect.RadiusX = 3;
                    rect.RadiusY = 3;

                    rect.SnapsToDevicePixels = true;

                    Canvas.SetLeft(rect, cx);
                    Canvas.SetTop(rect, cy);

                    if (locations == null)
                    {

                    }
                    else
                    {
                        rect.Stroke = Brushes.Yellow;
                        Text(cx + 10, cy + 10, "Way", Colors.Yellow);
                    }

                    canvasObj.Children.Add(rect);
                }
        }
예제 #19
0
 public bool IsAdjacentTo( Location loc )
 {
     return loc.Z == Z && Math.Max(Math.Abs(X - loc.X), Math.Abs(Y - loc.Y)) <= 1;
 }
예제 #20
0
 public MapGrid(Location loc, bool walkable, Tile tile)
 {
     _location = loc;
     _walkable = walkable;
     _tile = tile;
 }
예제 #21
0
 public bool Equals( Location other )
 {
     return other.X == X && other.Y == Y && other.Z == Z;
 }
예제 #22
0
        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;
        }
예제 #23
0
        public static bool GoLocation(Location loc)
        {
            switch (Instance._inputType)
            {
                case InputType.Simulate:
                    if (Player.X == loc.X && Player.Y == loc.Y + 1) // up
                    {
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x48, 1), (IntPtr)0x1480001);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x48, 1), (IntPtr)0x1480001);
                    }
                    if (Player.X == loc.X && Player.Y == loc.Y - 1) // down
                    {
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x50, 1), (IntPtr)0x1500001);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x50, 1), (IntPtr)0x1500001);
                    }
                    if (Player.X == loc.X + 1 && Player.Y == loc.Y) // left
                    {
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x4B, 1), (IntPtr)0x14b0001);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x4B, 1), (IntPtr)0x14b0001);
                    }
                    if (Player.X == loc.X - 1 && Player.Y == loc.Y) // right
                    {
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x4D, 1), (IntPtr)0x14d0001);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.SendMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x4D, 1), (IntPtr)0x14d0001);
                    }

                    if (Player.X == loc.X + 1 && Player.Y == loc.Y + 1) // up - left
                    {
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x47, 1), (IntPtr)0);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x47, 1), (IntPtr)0);
                    }
                    if (Player.X == loc.X - 1 && Player.Y == loc.Y + 1) // up - right
                    {
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x49, 1), (IntPtr)0);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x49, 1), (IntPtr)0);
                    }

                    if (Player.X == loc.X + 1 && Player.Y == loc.Y - 1) // down - left
                    {
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x4f, 1), (IntPtr)0);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x4f, 1), (IntPtr)0);
                    }
                    if (Player.X == loc.X - 1 && Player.Y == loc.Y - 1) // down - right
                    {
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0100, (IntPtr)NativeMethods.MapVirtualKey(0x51, 1), (IntPtr)0);
                        Thread.Sleep(Utils.RandomNumber(Instance._pressTimeStart, Instance._pressTimeEnd));
                        NativeMethods.PostMessage(GameClient.Tibia.MainWindowHandle, 0x0101, (IntPtr)NativeMethods.MapVirtualKey(0x51, 1), (IntPtr)0);
                    }
                    break;

                case InputType.Control:
                    //MouseMove(new Point(x, y), MouseMoveTime);
                    //mouse_event(MOUSEEVENTF_LEFTDOWN, x + Client.TibiaWindow.Left, y + Client.TibiaWindow.Top, 0, 0);
                    Thread.Sleep(Utils.RandomNumber(Instance._clickTimeStart, Instance._clickTimeEnd));
                    //mouse_event(MOUSEEVENTF_LEFTUP, x + Client.TibiaWindow.Left, y + Client.TibiaWindow.Top, 0, 0);
                    break;

            }
            return Player.Location == loc;
            }
예제 #24
0
        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;
        }
예제 #25
0
 public void MoveToGround(Location location, int amount = -1) { }
예제 #26
0
        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;
        }
예제 #27
0
 public Waypoint(int waypointID, WaypointType waypointType, Location location, string action)
 {
     _waypointId = waypointID;
     _waypointType = waypointType;
     _location = location;
     _action = action;
 }
예제 #28
0
        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;
        }
예제 #29
0
파일: Map.cs 프로젝트: PimentelM/extibiabot
 public static Location MapToLocation(string fileName)
 {
     try
     {
         Location l = new Location(0, 0, 0);
         fileName = fileName.Substring(fileName.Count() - 12, 8);
         if (fileName.Length == 12 || fileName.Length == 8)
         {
             l.X = Int32.Parse(fileName.Substring(0, 3)) * 256;
             l.Y = Int32.Parse(fileName.Substring(3, 3)) * 256;
             l.Z = Int32.Parse(fileName.Substring(6, 2));
         }
         return l;
     }
     catch (InvalidOperationException ex)
     {
         Helpers.Debug.Report(ex);
     }
     return new Location();
 }
예제 #30
0
        public Bitmap RenderImage()
        {
            Bitmap bitmap = new Bitmap(315,250);
            Bitmap player = global::exTibia.Properties.Resources.Tibia;

            this._locations = Location.GetLocationsDimension(DimensionLeft, DimensionTop, DimensionRight, DimensionDown);

            try
            {
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;

                    Location current;

                    using (Pen pen = new Pen(Brushes.Black))
                    {
                        for (int x = 0; x < 15; x++)
                            for (int y = 0; y < 11; y++)
                            {
                                current = new Location(InitialLocation.X - 7 + x, InitialLocation.Y - 5 + y, InitialLocation.Z);
                                if (x == 7 && y == 5)
                                    g.DrawImage(player, x * 20 + 1, y * 20 + 1, 15, 15);
                                else
                                {
                                    if (this.Locations.Contains(current))
                                        g.FillEllipse(Brushes.Green, x * 20 + 1, y * 20 + 1, 15, 15);
                                    else
                                        g.DrawRectangle(pen, x * 20 + 1, y * 20 + 1, 15, 15);
                                }
                            }
                    }

                }
                return bitmap;
            }
            catch (InvalidOperationException ex)
            {
                bitmap.Dispose();
                Helpers.Debug.Report(ex);
                return null;
            }
        }