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); } }
//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); } }
public static void PerformPlayerAttacks(Simulation World) { //Get a list of every client who's character is performing an attack this turn, and a list of every client who's character is currently inside the PVP battle arena List <ClientConnection> AttackingClients = ClientSubsetFinder.GetClientsAttacking(); List <ClientConnection> ClientsInArena = PVPBattleArena.GetClientsInside(); //Loop through all of the attacking clients so their attacks can be processed foreach (ClientConnection AttackingClient in AttackingClients) { //If the AttackingClient is inside the BattleArena, check their attack against the other players also in the arena if (ClientsInArena.Contains(AttackingClient)) { //Get a list of all the other clients in the arena to check the attack against List <ClientConnection> OtherClients = PVPBattleArena.GetClientsInside(); OtherClients.Remove(AttackingClient); foreach (ClientConnection OtherClient in OtherClients) { //Check the distance between the clients attack position and the other client to see if the attack hit float AttackDistance = Vector3.Distance(AttackingClient.Character.AttackPosition, OtherClient.Character.Position); if (AttackDistance <= 1.5f) { //Reduce the other characters health OtherClient.Character.CurrentHealth -= 1; //Send a damage alert to all clients if they survive the attack if (OtherClient.Character.CurrentHealth > 0) { CombatPacketSenders.SendLocalPlayerTakeHit(OtherClient.ClientID, OtherClient.Character.CurrentHealth); foreach (ClientConnection OtherOtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(OtherClient.ClientID)) { CombatPacketSenders.SendRemotePlayerTakeHit(OtherOtherClient.ClientID, OtherClient.Character.Name, OtherClient.Character.CurrentHealth); } } //Send a death alert to all clients if they are killed by the attack if (OtherClient.Character.CurrentHealth <= 0) { OtherClient.Character.IsAlive = false; OtherClient.Character.RemoveBody(World); CombatPacketSenders.SendLocalPlayerDead(OtherClient.ClientID); foreach (ClientConnection OtherOtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(OtherClient.ClientID)) { CombatPacketSenders.SendRemotePlayerDead(OtherOtherClient.ClientID, OtherClient.Character.Name); } } } } } //Disable the clients Attack flag now that the attack has been processed AttackingClient.Character.AttackPerformed = false; } }
//Respawns any clients characters who were dead and clicked the respawn button public static void RespawnDeadPlayers(Simulation World) { foreach (ClientConnection RespawningClient in ClientSubsetFinder.GetClientsAwaitingRespawn()) { RespawningClient.Character.SetDefaultValues(); RespawningClient.Character.InitializeBody(World, RespawningClient.Character.Position); RespawningClient.Character.IsAlive = true; CombatPacketSenders.SendLocalPlayerRespawn(RespawningClient.ClientID, RespawningClient.Character); foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(RespawningClient.ClientID)) { CombatPacketSenders.SendRemotePlayerRespawn(OtherClient.ClientID, RespawningClient.Character); } RespawningClient.Character.WaitingToRespawn = false; } }