protected override void OnDeathActions() { if (CustomNetworkManager.Instance._isServer) { ConnectedPlayer player = PlayerList.Instance.Get(gameObject); string killerName = null; if (LastDamagedBy != null) { killerName = PlayerList.Instance.Get(LastDamagedBy)?.Name; } if (killerName == null) { killerName = "Stressful work"; } string playerName = player?.Name ?? "dummy"; if (killerName == playerName) { Chat.AddActionMsgToChat(gameObject, "You committed suicide, what a waste.", $"{playerName} committed suicide."); } else if (killerName.EndsWith(playerName)) { // chain reactions Chat.AddActionMsgToChat(gameObject, $" You screwed yourself up with some help from {killerName}", $"{playerName} screwed himself up with some help from {killerName}"); } else { PlayerList.Instance.TrackKill(LastDamagedBy, gameObject); } //drop items in hand if (itemStorage != null) { Inventory.ServerDrop(itemStorage.GetNamedItemSlot(NamedSlot.leftHand)); Inventory.ServerDrop(itemStorage.GetNamedItemSlot(NamedSlot.rightHand)); } if (isServer) { EffectsFactory.BloodSplat(transform.position, BloodSplatSize.large, bloodColor); string descriptor = null; if (player != null) { descriptor = player?.Script?.characterSettings?.PossessivePronoun(); } if (descriptor == null) { descriptor = "their"; } Chat.AddLocalMsgToChat($"<b>{playerName}</b> seizes up and falls limp, {descriptor} eyes dead and lifeless...", (Vector3)registerPlayer.WorldPositionServer); } PlayerDeathMessage.Send(gameObject); } }
/// Sends the death message public static PlayerDeathMessage Send(GameObject recipient) { PlayerDeathMessage msg = new PlayerDeathMessage(); msg.SendTo(recipient); return(msg); }
private void PlayerDeath(PlayerDeathMessage message) { StopSounds(); PlaySong(dyingSong, (s, e) => { AfterDyingSong(); }); }
/// <summary> /// Sends the death message /// </summary> public static PlayerDeathMessage Send(GameObject recipient) { PlayerDeathMessage msg = new PlayerDeathMessage { Recipient = recipient.GetComponent <NetworkIdentity>().netId }; msg.SendTo(recipient); return(msg); }
protected override void OnDeathActions() { if (CustomNetworkManager.Instance._isServer) { PlayerNetworkActions pna = gameObject.GetComponent <PlayerNetworkActions>(); PlayerMove pm = gameObject.GetComponent <PlayerMove>(); ConnectedPlayer player = PlayerList.Instance.Get(gameObject); string killerName = "Stressful work"; if (LastDamagedBy != null) { killerName = PlayerList.Instance.Get(LastDamagedBy).Name; } string playerName = player.Name ?? "dummy"; if (killerName == playerName) { PostToChatMessage.Send(playerName + " commited suicide", ChatChannel.System); //Killfeed } else if (killerName.EndsWith(playerName)) { // chain reactions PostToChatMessage.Send( playerName + " screwed himself up with some help (" + killerName + ")", ChatChannel.System); //Killfeed } else { PlayerList.Instance.UpdateKillScore(LastDamagedBy, gameObject); } pna.DropItem("rightHand"); pna.DropItem("leftHand"); if (isServer) { EffectsFactory.Instance.BloodSplat(transform.position, BloodSplatSize.large); } PlayerDeathMessage.Send(gameObject); //syncvars for everyone pm.isGhost = true; pm.allowInput = true; //consider moving into PlayerDeathMessage.Process() pna.RpcSpawnGhost(); RpcPassBullets(gameObject); //FIXME Remove for next demo pna.RespawnPlayer(10); } }
protected override void OnDeathActions() { if (CustomNetworkManager.Instance._isServer) { PlayerNetworkActions pna = gameObject.GetComponent <PlayerNetworkActions>(); PlayerMove pm = gameObject.GetComponent <PlayerMove>(); ConnectedPlayer player = PlayerList.Instance.Get(gameObject); string killerName = "Stressful work"; if (LastDamagedBy != null) { killerName = PlayerList.Instance.Get(LastDamagedBy).Name; } string playerName = player.Name ?? "dummy"; if (killerName == playerName) { Chat.AddActionMsgToChat(gameObject, "You committed suicide, what a waste.", $"{playerName} committed suicide."); } else if (killerName.EndsWith(playerName)) { // chain reactions Chat.AddActionMsgToChat(gameObject, $" You screwed yourself up with some help from {killerName}", $"{playerName} screwed himself up with some help from {killerName}"); } else { PlayerList.Instance.TrackKill(LastDamagedBy, gameObject); } //drop items in hand Inventory.ServerDrop(itemStorage.GetNamedItemSlot(NamedSlot.leftHand)); Inventory.ServerDrop(itemStorage.GetNamedItemSlot(NamedSlot.rightHand)); if (isServer) { EffectsFactory.BloodSplat(transform.position, BloodSplatSize.large, bloodColor); } PlayerDeathMessage.Send(gameObject); } }
protected override void OnDeathActions() { if (CustomNetworkManager.Instance._isServer) { PlayerNetworkActions pna = gameObject.GetComponent <PlayerNetworkActions>(); PlayerMove pm = gameObject.GetComponent <PlayerMove>(); ConnectedPlayer player = PlayerList.Instance.Get(gameObject); string killerName = "Stressful work"; if (LastDamagedBy != null) { killerName = PlayerList.Instance.Get(LastDamagedBy).Name; } string playerName = player.Name ?? "dummy"; if (killerName == playerName) { PostToChatMessage.Send(playerName + " commited suicide", ChatChannel.System); //Killfeed } else if (killerName.EndsWith(playerName)) { // chain reactions PostToChatMessage.Send( playerName + " screwed himself up with some help (" + killerName + ")", ChatChannel.System); //Killfeed } else { PlayerList.Instance.UpdateKillScore(LastDamagedBy, gameObject); } pna.DropItem(EquipSlot.rightHand); pna.DropItem(EquipSlot.leftHand); if (isServer) { EffectsFactory.Instance.BloodSplat(transform.position, BloodSplatSize.large); } PlayerDeathMessage.Send(gameObject); } }
protected override void OnDeathActions() { if (CustomNetworkManager.Instance._isServer) { PlayerNetworkActions pna = gameObject.GetComponent <PlayerNetworkActions>(); PlayerMove pm = gameObject.GetComponent <PlayerMove>(); ConnectedPlayer player = PlayerList.Instance.Get(gameObject); string killerName = "stressfull work"; if (LastDamagedBy != null) { killerName = PlayerList.Instance.Get(LastDamagedBy).Name; } if (killerName == player.Name) { PostToChatMessage.Send(player.Name + " commited suicide", ChatChannel.System); //Killfeed } else if (killerName.EndsWith(player.Name)) { // chain reactions PostToChatMessage.Send( player.Name + " screwed himself up with some help (" + killerName + ")", ChatChannel.System); //Killfeed } else { PlayerList.Instance.UpdateKillScore(LastDamagedBy, gameObject); string departmentKillText = ""; if (LastDamagedBy != null) { JobDepartment killerDepartment = SpawnPoint.GetJobDepartment(LastDamagedBy.GetComponent <PlayerScript>().JobType); JobDepartment victimDepartment = SpawnPoint.GetJobDepartment(gameObject.GetComponent <PlayerScript>().JobType); if (killerDepartment == victimDepartment) { departmentKillText = ", losing " + killerDepartment.GetDescription() + " 1 point for team killing!"; } else { departmentKillText = ", 1 point to " + killerDepartment.GetDescription() + "!"; } } //TDM demo killfeed PostToChatMessage.Send(killerName + " has killed " + player.Name + departmentKillText, ChatChannel.System); //Combat demo killfeed //PostToChatMessage.Send(killerName + " has killed " + gameObject.name, ChatChannel.System); } pna.ValidateDropItem("rightHand", true, transform.position); pna.ValidateDropItem("leftHand", true, transform.position); if (isServer) { EffectsFactory.Instance.BloodSplat(transform.position, BloodSplatSize.large); } pna.RpcSpawnGhost(); pm.isGhost = true; pm.allowInput = true; RpcPassBullets(gameObject); PlayerDeathMessage.Send(gameObject); //FIXME Remove for next demo pna.RespawnPlayer(10); } }
public override void Handle(PlayerDeathMessage message) { setState(State.Sleep); ownRigidbody2D.velocity = Vector2.zero; }