Example #1
0
        private void TryRevivePlayer(string[] Input)
        {
            string CharacterName = Input[1];

            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant revive them.");
                return;
            }
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            if (Client == null)
            {
                MessageLog.Print("That character is not ingame right now, cant revive them.");
                return;
            }
            if (Client.Character.IsAlive)
            {
                MessageLog.Print("That character is not dead, cant revive them.");
                return;
            }
            MessageLog.Print("Reviving " + CharacterName + "...");
            Client.Character.IsAlive = true;
            Client.Character.SetDefaultValues();
            CombatPacketSenders.SendLocalPlayerRespawn(Client.ClientID, Client.Character);
            foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID))
            {
                CombatPacketSenders.SendRemotePlayerRespawn(OtherClient.ClientID, Client.Character);
            }
        }
Example #2
0
        /// <summary>
        /// //Tells a client where all the other players are in the world so they can be spawned in before they can enter the world
        /// </summary>
        /// <param name="ClientID">NetworkID for target client</param>
        public static void SendActivePlayerList(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " active player list");

            //Create a new NetworkPacket object to store the data for this active player list
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the other active game clients
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(ClientID);

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.ActivePlayerList);
            Packet.WriteInt(OtherClients.Count);

            //Loop through the list of other clients and write each of their information into the packet data
            foreach (ClientConnection OtherClient in OtherClients)
            {
                //Write each characters name, and current location and rotation values
                Packet.WriteString(OtherClient.Character.Name);
                Packet.WriteBool(OtherClient.Character.IsAlive);
                Packet.WriteVector3(OtherClient.Character.Position);
                Packet.WriteQuaternion(OtherClient.Character.Rotation);
                Packet.WriteInt(OtherClient.Character.CurrentHealth);
                Packet.WriteInt(OtherClient.Character.MaxHealth);
            }

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Example #3
0
        //Tries using the command arguments for killing one of the player characters
        private void TryKillPlayer(string[] Input)
        {
            string CharacterName = Input[1];

            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant kill them.");
                return;
            }
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            if (Client == null)
            {
                MessageLog.Print("That character is not ingame right now, cant kill them.");
                return;
            }
            //Make sure the character is still alive
            if (!Client.Character.IsAlive)
            {
                MessageLog.Print("That character is already dead, cant kill them.");
                return;
            }
            MessageLog.Print("Killing " + CharacterName + "...");
            Client.Character.IsAlive = false;
            Client.Character.RemoveBody(Program.World.World);
            //Client.RemovePhysicsBody(Program.World.WorldSimulation);
            CombatPacketSenders.SendLocalPlayerDead(Client.ClientID);
            foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID))
            {
                CombatPacketSenders.SendRemotePlayerDead(OtherClient.ClientID, Client.Character.Name);
            }
        }
Example #4
0
        public static void HandleClientChatMessage(int ClientID, ref NetworkPacket Packet)
        {
            CommunicationLog.LogIn(ClientID + " chat message");

            //Fetch this ClientConnection and make sure they were able to be found
            ClientConnection Client = ConnectionManager.GetClient(ClientID);

            if (Client == null)
            {
                MessageLog.Print("ERROR: Client not found, unable to handle chat message.");
                return;
            }

            //Extract the message content from the network packet
            string ChatMessage = Packet.ReadString();

            //Get the list of all the other game clients who are already ingame
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(ClientID);

            //Pass this chat message on to all the other clients that are ingame
            foreach (ClientConnection OtherClient in OtherClients)
            {
                PlayerCommunicationPacketSender.SendChatMessage(OtherClient.ClientID, Client.Character.Name, ChatMessage);
            }
        }
Example #5
0
        public static void HandlePlayerRotationUpdate(int ClientID, ref NetworkPacket Packet)
        {
            Quaternion       Rotation = Packet.ReadQuaternion();
            ClientConnection Client   = ConnectionManager.GetClient(ClientID);

            if (Client != null)
            {
                Client.Character.Rotation    = Rotation;
                Client.Character.NewRotation = true;
                foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(ClientID))
                {
                    PlayerManagementPacketSender.SendPlayerRotationUpdate(OtherClient.ClientID, Client.Character);
                }
            }
        }
Example #6
0
        public static void HandlePlayAnimationAlert(int ClientID, ref NetworkPacket Packet)
        {
            CommunicationLog.LogIn(ClientID + " Play Animation Alert");
            string           AnimationName = Packet.ReadString();
            ClientConnection Client        = ConnectionManager.GetClient(ClientID);

            if (Client == null)
            {
                MessageLog.Print("ERROR: Client not found, unable to handle play animation alert.");
                return;
            }
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(ClientID);

            foreach (ClientConnection OtherClient in OtherClients)
            {
                PlayerManagementPacketSender.SendPlayAnimationAlert(OtherClient.ClientID, Client.Character.Name, AnimationName);
            }
        }
Example #7
0
        //Tries using the command arguments for performing a player kick
        private void TryKickPlayer(string[] Input)
        {
            //Get the characters name
            string CharacterName = Input[1];

            //Make sure the character exists
            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant kick them.");
                return;
            }

            //Get the client who this character belongs to
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            //If the client couldnt be found then the character isnt logged in currently
            if (Client == null)
            {
                MessageLog.Print("That character is not in the game right now, cant kick them.");
                return;
            }

            //Show that the player is being kicked
            MessageLog.Print("Kicking " + CharacterName + " from the game...");

            //Tell the client that they have been kicked from the game and mark them to be cleaned up from the game
            SystemPacketSender.SendKickedFromServer(Client.ClientID);
            Client.ConnectionDead = true;

            //Tell everyone else to remove the client from their games
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID);

            foreach (ClientConnection OtherClient in OtherClients)
            {
                PlayerManagementPacketSender.SendRemoveRemotePlayer(OtherClient.ClientID, Client.Character.Name, Client.Character.IsAlive);
            }
        }