Ejemplo n.º 1
0
        private static void PopulateDeathAlerts()
        {
            deathAlerts = new Dictionary <string, List <string> >();

            Traverse      tDamageTypes = Traverse.Create(typeof(HitData.DamageTypes));
            List <string> damageTypes  = tDamageTypes.Fields();

            foreach (string damageType in damageTypes)
            {
                PopulateDeathAlerts(damageType);
            }
        }
Ejemplo n.º 2
0
        public static void ShowDeathAlert(Player player)
        {
            if (Settings.EnableShoutOnDeath.Value)
            {
                string text = Localization.instance.Localize(GetRandomDeathShout());
                Chat.instance.SendText(Talker.Type.Shout, text);
            }

            if (Settings.EnableAlertOnDeath.Value)
            {
                HitData   hit = lastHitData;
                string    lastAttackerName = "themself";
                Character attacker         = hit.GetAttacker();
                if (attacker)
                {
                    lastAttackerName = attacker.GetHoverName();
                }

                Traverse      tDamages         = Traverse.Create(hit.m_damage);
                List <string> damageFieldNames = tDamages.Fields();

                float  max = 0.0f;
                string highestDamageType = "m_damage";
                foreach (string fieldName in damageFieldNames)
                {
                    float value = tDamages.Field <float>(fieldName).Value;
                    if (value > max)
                    {
                        max = value;
                        highestDamageType = fieldName;
                    }
                }

                if (highestDamageType == "m_damage" && player.IsSwiming())
                {
                    highestDamageType = "m_drowning";
                }

                string damageTypeString = Localization.instance.Localize(GetRandomDeathAlert(highestDamageType));

                ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "ShowMessage", new object[]
                {
                    (int)MessageHud.MessageType.Center,
                    Localization.instance.Localize("$deathalert_killed_by_msg_peers", player.GetPlayerName(), lastAttackerName, damageTypeString)
                });
            }
        }