コード例 #1
0
ファイル: Player_Death.cs プロジェクト: VeritasGC/Frostcull
        public void HandlePKDeathBroadcast(DamageHistoryInfo lastDamager, DamageHistoryInfo topDamager)
        {
            if (topDamager == null || !topDamager.IsPlayer)
            {
                return;
            }

            var pkPlayer = topDamager.TryGetAttacker() as Player;

            if (pkPlayer == null)
            {
                return;
            }

            if (IsPKDeath(topDamager))
            {
                pkPlayer.PkTimestamp = Time.GetUnixTime();
                pkPlayer.PlayerKillsPk++;

                var globalPKDe = $"{lastDamager.Name} has defeated {Name}!";

                if ((Location.Cell & 0xFFFF) < 0x100)
                {
                    globalPKDe += $" The kill occured at {Location.GetMapCoordStr()}";
                }

                globalPKDe += "\n[PKDe]";

                PlayerManager.BroadcastToAll(new GameMessageSystemChat(globalPKDe, ChatMessageType.Broadcast));
            }
            else if (IsPKLiteDeath(topDamager))
            {
                pkPlayer.PlayerKillsPkl++;
            }
        }
コード例 #2
0
        public void HandlePKDeathBroadcast(DamageHistoryInfo lastDamager, DamageHistoryInfo topDamager)
        {
            if (topDamager == null || !topDamager.IsPlayer)
            {
                return;
            }

            var pkPlayer = topDamager.TryGetAttacker() as Player;

            if (pkPlayer == null)
            {
                return;
            }

            if (IsPKDeath(topDamager))
            {
                pkPlayer.PkTimestamp = Time.GetUnixTime();
                pkPlayer.PlayerKillsPk++;

                string globalPKDe;
                if (pkPlayer.CurrentLandblock.RealmHelpers.IsDuel)
                {
                    globalPKDe = $"{lastDamager.Name} has defeated {Name} in a duel!";
                }
                else
                {
                    globalPKDe = $"{lastDamager.Name} has defeated {Name}!";
                    if (!Location.Indoors)
                    {
                        globalPKDe += $" The kill occured at {Location.GetMapCoordStr()}";
                    }
                }

                globalPKDe += "\n[PKDe]";

                PlayerManager.BroadcastToAll(new GameMessageSystemChat(globalPKDe, ChatMessageType.Broadcast));
            }
            else if (IsPKLiteDeath(topDamager))
            {
                pkPlayer.PlayerKillsPkl++;
            }
        }
コード例 #3
0
ファイル: Player_Death.cs プロジェクト: Mad-Hatz/ACE
        /// <summary>
        /// Called when a player dies, in conjunction with Die()
        /// </summary>
        /// <param name="lastDamager">The last damager that landed the death blow</param>
        /// <param name="damageType">The damage type for the death message</param>
        public override DeathMessage OnDeath(DamageHistoryInfo lastDamager, DamageType damageType, bool criticalHit = false)
        {
            var topDamager = DamageHistory.GetTopDamager(false);

            HandlePKDeathBroadcast(lastDamager, topDamager);

            var deathMessage = base.OnDeath(lastDamager, damageType, criticalHit);

            var lastDamagerObj = lastDamager?.TryGetAttacker();

            if (lastDamagerObj != null)
            {
                lastDamagerObj.EmoteManager.OnKill(this);
            }

            var playerMsg = "";

            if (lastDamager != null)
            {
                playerMsg = string.Format(deathMessage.Victim, Name, lastDamager.Name);
            }
            else
            {
                playerMsg = deathMessage.Victim;
            }

            var msgYourDeath = new GameEventVictimNotification(Session, playerMsg);

            Session.Network.EnqueueSend(msgYourDeath);

            // broadcast to nearby players
            var nearbyMsg = "";

            if (lastDamager != null)
            {
                nearbyMsg = string.Format(deathMessage.Broadcast, Name, lastDamager.Name);
            }
            else
            {
                nearbyMsg = deathMessage.Broadcast;
            }

            var broadcastMsg = new GameMessagePlayerKilled(nearbyMsg, Guid, lastDamager?.Guid ?? ObjectGuid.Invalid);

            log.Debug("[CORPSE] " + nearbyMsg);

            var excludePlayers = new List <Player>();

            var nearbyPlayers = EnqueueBroadcast(excludePlayers, false, broadcastMsg);

            excludePlayers.AddRange(nearbyPlayers);

            if (Fellowship != null)
            {
                Fellowship.OnDeath(this);
            }

            // if the player's lifestone is in a different landblock, also broadcast their demise to that landblock
            if (PropertyManager.GetBool("lifestone_broadcast_death").Item&& Sanctuary != null && Location.Landblock != Sanctuary.Landblock)
            {
                // ActionBroadcastKill might not work if other players around lifestone aren't aware of this player yet...
                // this existing broadcast method is also based on the current visible objects to the player,
                // and the player hasn't entered portal space or teleported back to the lifestone yet, so this doesn't work
                //ActionBroadcastKill(nearbyMsg, Guid, lastDamager.Guid);

                // instead, we get all of the players in the lifestone landblock + adjacent landblocks,
                // and possibly limit that to some radius around the landblock?
                var lifestoneBlock = LandblockManager.GetLandblock(new LandblockId(Sanctuary.Landblock << 16 | 0xFFFF), true);
                lifestoneBlock.EnqueueBroadcast(excludePlayers, true, Sanctuary, LocalBroadcastRangeSq, broadcastMsg);
            }

            return(deathMessage);
        }