public static void OnChatMessage(GameClient client, ClientMovementRequestPacket packet)
        {
            var player = client.HeroEntity;
            var zone = client.HeroEntity.Zone;

            if (zone == null)
                return;

            var requestedPosition = packet.CurrentPosition;
            var direction = packet.Direction;

            var distance = Vector2.Distance(requestedPosition, player.Position);
            // Ignore packets claiming to make large leaps and bounds
            if (distance > LenianceFactor)
            {

                Logger.Instance.Warn("The player moved far too much in one frame. Could be lag or a sign of hacking. Attempting to move back");

                // Send the player back to their old position, correcting them
                player.Teleport(player.Position);
                return;
                //client.Connection.Disconnect("Hacking Attempt: Movement pulse exceeded");
            }

            // Set the state
            if (packet.Terminates)
                player.CharacterState = CharacterState.Idle;
            else
                player.CharacterState = CharacterState.Moving;

            // Move the player and set direction
            player.Direction = packet.Direction;
            player.Position = requestedPosition;
        }
Example #2
0
        public static void OnChatMessage(GameClient client, ClientMovementRequestPacket packet)
        {
            var player = client.HeroEntity;
            var zone = client.HeroEntity.Zone;

            if (zone == null)
                return;

            var requestedPosition = packet.CurrentPosition;
            var direction = packet.Direction;

            var distance = Vector2.Distance(requestedPosition, player.Position);
            // Ignore packets claiming to make large leaps and bounds
            if (distance > LenianceFactor)
            {
                Logger.Instance.Debug("Ignoring movement request");
                // Probably changing maps, so just ignore it
                return;
                //client.Connection.Disconnect("Hacking Attempt: Movement pulse exceeded");
            }

            // Set the state
            if (packet.Terminates)
                player.CharacterState = CharacterState.Idle;
            else
                player.CharacterState = CharacterState.Moving;

            // Move the player and set direction
            player.Direction = packet.Direction;
            player.Position = requestedPosition;
        }
Example #3
0
        public static void OnMovementRequest(GameClient client, ClientMovementRequestPacket packet)
        {
            var command = new MoveToCommand(packet.Path);

            var commandQueue = client.Hero.Components.Get<CommandQueue>();

            commandQueue.Enqueue(command);
        }