Exemplo n.º 1
0
        /// <summary>
        /// Handling the Jump action from GeneralDataPacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="General">The GeneralDataPacket.</param>
        public static void Handle(Entities.GameClient client, GeneralDataPacket General)
        {
            if (!client.Alive)
            {
                return;
            }
            if (client.ContainsFlag1(Enums.Effect1.IceBlock))
            {
                return;
            }

            if (client.Booth != null)
            {
                client.Booth.CancelBooth();
                client.Pullback();
            }

            client.Action       = Enums.ActionType.None;
            client.AttackPacket = null;

            ushort JumpX = General.Data1Low;
            ushort JumpY = General.Data1High;

            if (Core.Screen.GetDistance(client.X, client.Y, JumpX, JumpY) > 28)
            {
                client.Pullback();
                return;
            }

            if (!client.Map.ValidCoord(JumpX, JumpY))
            {
                client.Pullback();
                return;
            }

            /*DateTime time = new ProjectX_V3_Lib.Time.SystemTime(General.Timestamp);
             * if (client.LastMovement > time)
             * {
             *      client.Pullback(); // speedhack
             *      return;
             * }*/
            if (!(DateTime.Now >= client.LastMovement.AddMilliseconds(400)) && client.LastMoveJump)
            {
                client.Pullback();                 // speedhack
                return;
            }

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

            if (Calculations.BasicCalculations.ChanceSuccess(50))
            {
                client.Stamina += 7;
            }

            client.LastMoveJump = true;
            client.LastMovement = DateTime.Now;
            client.LastX        = client.X;
            client.LastY        = client.Y;
            client.X            = JumpX;
            client.Y            = JumpY;
            client.SendToScreen(General, true);
            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);
                }
            }
        }