Exemplo n.º 1
0
        /// <summary>
        /// Handles the movement packet.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="packet">The packet.</param>
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            if (client.ContainsFlag1(Enums.Effect1.IceBlock))
            {
                return;
            }

            client.Action       = Enums.ActionType.None;
            client.AttackPacket = null;
            client.LastMoveJump = false;
            using (var move = new MovementPacket(packet))
            {
                if (move.EntityUID != client.EntityUID)
                {
                    return;
                }

                int NewX = 0, NewY = 0;
                int NewDir = 0;

                switch (move.WalkMode)
                {
                case Enums.WalkMode.Run:
                case Enums.WalkMode.Walk:
                {
                    NewDir = (int)move.Direction % 8;
                    NewX   = client.X + DeltaX[NewDir];
                    NewY   = client.Y + DeltaY[NewDir];
                    break;
                }

                case Enums.WalkMode.Mount:
                {
                    NewDir = (int)move.Direction % 24;
                    NewX   = client.X + DeltaMountX[NewDir];
                    NewY   = client.Y + DeltaMountY[NewDir];
                    break;
                }
                }

                if (client.Map.ValidCoord(NewX, NewY))
                {
                    client.LastX = client.X;
                    client.LastY = client.LastY;

                    client.LastMovement = DateTime.Now;
                    client.X            = (ushort)NewX;
                    client.Y            = (ushort)NewY;
                    client.Direction    = (byte)NewDir;
                    client.SendToScreen(move, true);

                    if (client.Battle != null)
                    {
                        if (!client.Battle.EnterArea(client))
                        {
                            client.X = client.LastX;
                            client.Y = client.LastY;
                            client.Pullback();
                            return;
                        }
                        else if (!client.Battle.LeaveArea(client))
                        {
                            client.X = client.LastX;
                            client.Y = client.LastY;
                            client.Pullback();
                            return;
                        }
                    }

                    Data.AdvancedSkill.SkillInArea(client, client.X, client.Y);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the movement packet.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="packet">The packet.</param>
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            if (client.ContainsFlag1(Enums.Effect1.IceBlock))
                return;

            client.Action = Enums.ActionType.None;
            client.AttackPacket = null;
            client.LastMoveJump = false;
            using (var move = new MovementPacket(packet))
            {
                if (move.EntityUID != client.EntityUID)
                    return;

                int NewX = 0, NewY = 0;
                int NewDir = 0;

                switch (move.WalkMode)
                {
                    case Enums.WalkMode.Run:
                    case Enums.WalkMode.Walk:
                        {
                            NewDir = (int)move.Direction % 8;
                            NewX = client.X + DeltaX[NewDir];
                            NewY = client.Y + DeltaY[NewDir];
                            break;
                        }
                    case Enums.WalkMode.Mount:
                        {
                            NewDir = (int)move.Direction % 24;
                            NewX = client.X + DeltaMountX[NewDir];
                            NewY = client.Y + DeltaMountY[NewDir];
                            break;
                        }
                }

                if (client.Map.ValidCoord(NewX, NewY))
                {
                    client.LastX = client.X;
                    client.LastY = client.LastY;

                    client.LastMovement = DateTime.Now;
                    client.X = (ushort)NewX;
                    client.Y = (ushort)NewY;
                    client.Direction = (byte)NewDir;
                    client.SendToScreen(move, true);

                    if (client.Battle != null)
                    {
                        if (!client.Battle.EnterArea(client))
                        {
                            client.X = client.LastX;
                            client.Y = client.LastY;
                            client.Pullback();
                            return;
                        }
                        else if (!client.Battle.LeaveArea(client))
                        {
                            client.X = client.LastX;
                            client.Y = client.LastY;
                            client.Pullback();
                            return;
                        }
                    }

                    Data.AdvancedSkill.SkillInArea(client, client.X, client.Y);
                }
            }
        }