diff --git a/assets/voxygen/i18n/en/hud/chat.ron b/assets/voxygen/i18n/en/hud/chat.ron index 1785615df2..6cbf90cd15 100644 --- a/assets/voxygen/i18n/en/hud/chat.ron +++ b/assets/voxygen/i18n/en/hud/chat.ron @@ -12,13 +12,15 @@ "hud.chat.fall_kill_msg": "[{name}] died from fall damage", "hud.chat.suicide_msg": "[{name}] died from self-inflicted wounds", + "hud.chat.pvp_buff_kill_msg": "[{victim}] died of {buff} caused by [{attacker}]", "hud.chat.pvp_melee_kill_msg": "[{attacker}] defeated [{victim}]", "hud.chat.pvp_ranged_kill_msg": "[{attacker}] shot [{victim}]", "hud.chat.pvp_explosion_kill_msg": "[{attacker}] blew up [{victim}]", "hud.chat.pvp_energy_kill_msg": "[{attacker}] killed [{victim}] with magic", - "hud.chat.pvp_buff_kill_msg": "[{attacker}] killed [{victim}]", + "hud.chat.nonexistent_buff_kill_msg": "[{victim}] died of {buff}", + "hud.chat.npc_buff_kill_msg": "[{victim}] died of {buff} caused by [{attacker}]", "hud.chat.npc_melee_kill_msg": "{attacker} killed [{victim}]", "hud.chat.npc_ranged_kill_msg": "{attacker} shot [{victim}]", "hud.chat.npc_explosion_kill_msg": "{attacker} blew up [{victim}]", diff --git a/client/src/lib.rs b/client/src/lib.rs index 34580ab608..21a645c7eb 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1797,6 +1797,12 @@ impl Client { // Needed for cli clients that don't set localization info if message.is_empty() { match kill_source { + KillSource::Player(attacker_uid, KillType::Buff(buff_kind)) => format!( + "[{}] died of {} caused by [{}]", + alias_of_uid(victim), + format!("{:?}", buff_kind).to_lowercase().as_str(), + alias_of_uid(attacker_uid) + ), KillSource::Player(attacker_uid, KillType::Melee) => format!( "[{}] killed [{}]", alias_of_uid(attacker_uid), @@ -1822,6 +1828,17 @@ impl Client { alias_of_uid(attacker_uid), alias_of_uid(victim) ), + KillSource::NonExistent(KillType::Buff(buff_kind)) => format!( + "[{}] died of {}", + alias_of_uid(victim), + format!("{:?}", buff_kind).to_lowercase().as_str() + ), + KillSource::NonPlayer(attacker_name, KillType::Buff(buff_kind)) => format!( + "[{}] died of {} caused by [{}]", + alias_of_uid(victim), + format!("{:?}", buff_kind).to_lowercase().as_str(), + attacker_name + ), KillSource::NonPlayer(attacker_name, KillType::Melee) => { format!("{} killed [{}]", attacker_name, alias_of_uid(victim)) }, @@ -1848,10 +1865,15 @@ impl Client { KillSource::Suicide => { format!("[{}] died from self-inflicted wounds", alias_of_uid(victim)) }, + KillSource::NonExistent(_) => format!("[{}] died", alias_of_uid(victim)), KillSource::Other => format!("[{}] died", alias_of_uid(victim)), } } else { match kill_source { + KillSource::Player(attacker_uid, KillType::Buff(buff_kind)) => message + .replace("{attacker}", &alias_of_uid(attacker_uid)) + .replace("{buff}", format!("{:?}", buff_kind).to_lowercase().as_str()) + .replace("{victim}", &alias_of_uid(victim)), KillSource::Player(attacker_uid, KillType::Melee) => message .replace("{attacker}", &alias_of_uid(attacker_uid)) .replace("{victim}", &alias_of_uid(victim)), @@ -1867,6 +1889,13 @@ impl Client { KillSource::Player(attacker_uid, KillType::Other) => message .replace("{attacker}", &alias_of_uid(attacker_uid)) .replace("{victim}", &alias_of_uid(victim)), + KillSource::NonExistent(KillType::Buff(buff_kind)) => message + .replace("{buff}", format!("{:?}", buff_kind).to_lowercase().as_str()) + .replace("{victim}", &alias_of_uid(victim)), + KillSource::NonPlayer(attacker_name, KillType::Buff(buff_kind)) => message + .replace("{attacker}", attacker_name) + .replace("{buff}", format!("{:?}", buff_kind).to_lowercase().as_str()) + .replace("{victim}", &alias_of_uid(victim)), KillSource::NonPlayer(attacker_name, KillType::Melee) => message .replace("{attacker}", attacker_name) .replace("{victim}", &alias_of_uid(victim)), @@ -1887,6 +1916,9 @@ impl Client { .replace("{environment}", environment), KillSource::FallDamage => message.replace("{name}", &alias_of_uid(victim)), KillSource::Suicide => message.replace("{name}", &alias_of_uid(victim)), + KillSource::NonExistent(_) => { + message.replace("{name}", &alias_of_uid(victim)) + }, KillSource::Other => message.replace("{name}", &alias_of_uid(victim)), } } diff --git a/common/src/combat.rs b/common/src/combat.rs index 7d3cc401c1..da56410bed 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ inventory::item::{armor::Protection, ItemKind}, - HealthChange, HealthSource, Inventory, + BuffKind, HealthChange, HealthSource, Inventory, }, uid::Uid, util::Dir, @@ -17,6 +17,7 @@ pub enum GroupTarget { #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] pub enum DamageSource { + Buff(BuffKind), Melee, Healing, Projectile, @@ -149,6 +150,13 @@ impl Damage { cause: HealthSource::World, } }, + DamageSource::Buff(_) => HealthChange { + amount: -damage as i32, + cause: HealthSource::Damage { + kind: self.source, + by: uid, + }, + }, DamageSource::Other => HealthChange { amount: -damage as i32, cause: HealthSource::Damage { diff --git a/common/src/comp/chat.rs b/common/src/comp/chat.rs index bbba9c8f63..eaa06941fb 100644 --- a/common/src/comp/chat.rs +++ b/common/src/comp/chat.rs @@ -1,4 +1,7 @@ -use crate::{comp::group::Group, uid::Uid}; +use crate::{ + comp::{group::Group, BuffKind}, + uid::Uid, +}; use serde::{Deserialize, Serialize}; use specs::Component; use specs_idvs::IdvStorage; @@ -47,6 +50,7 @@ impl Default for ChatMode { #[derive(Debug, Clone, Serialize, Deserialize)] pub enum KillType { + Buff(BuffKind), Melee, Projectile, Explosion, @@ -59,6 +63,7 @@ pub enum KillType { pub enum KillSource { Player(Uid, KillType), NonPlayer(String, KillType), + NonExistent(KillType), Environment(String), FallDamage, Suicide, diff --git a/common/sys/src/buff.rs b/common/sys/src/buff.rs index 39d66689e2..08f2fa2489 100644 --- a/common/sys/src/buff.rs +++ b/common/sys/src/buff.rs @@ -95,7 +95,7 @@ impl<'a> System<'a> for Sys { HealthSource::Heal { by: buff_owner } } else { HealthSource::Damage { - kind: DamageSource::Other, + kind: DamageSource::Buff(buff.kind), by: buff_owner, } }; diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 15b7d7d595..dc01768a4e 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -100,10 +100,10 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc } else if let Some(stats) = state.ecs().read_storage::().get(char_entity) { KillSource::NonPlayer(stats.name.clone(), cause_of_death) } else { - KillSource::NonPlayer("".to_string(), cause_of_death) + KillSource::NonExistent(cause_of_death) } } else { - KillSource::NonPlayer("".to_string(), cause_of_death) + KillSource::NonExistent(cause_of_death) } }; @@ -131,6 +131,10 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc kind: DamageSource::Energy, by: Some(by), } => get_attacker_name(KillType::Energy, by), + HealthSource::Damage { + kind: DamageSource::Buff(buff_kind), + by: Some(by), + } => get_attacker_name(KillType::Buff(buff_kind), by), HealthSource::Damage { kind: DamageSource::Other, by: Some(by), diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index ff640bbeed..cb281428ff 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -355,6 +355,10 @@ impl<'a> Widget for Chat<'a> { .get("hud.chat.offline_msg") .to_string(), ChatType::Kill(kill_source, _) => match kill_source { + KillSource::Player(_, KillType::Buff(_)) => self + .localized_strings + .get("hud.chat.pvp_buff_kill_msg") + .to_string(), KillSource::Player(_, KillType::Melee) => self .localized_strings .get("hud.chat.pvp_melee_kill_msg") @@ -375,6 +379,14 @@ impl<'a> Widget for Chat<'a> { .localized_strings .get("hud.chat.pvp_other_kill_msg") .to_string(), + KillSource::NonExistent(KillType::Buff(_)) => self + .localized_strings + .get("hud.chat.nonexistent_buff_kill_msg") + .to_string(), + KillSource::NonPlayer(_, KillType::Buff(_)) => self + .localized_strings + .get("hud.chat.npc_buff_kill_msg") + .to_string(), KillSource::NonPlayer(_, KillType::Melee) => self .localized_strings .get("hud.chat.npc_melee_kill_msg") @@ -407,7 +419,7 @@ impl<'a> Widget for Chat<'a> { .localized_strings .get("hud.chat.suicide_msg") .to_string(), - KillSource::Other => self + KillSource::NonExistent(_) | KillSource::Other => self .localized_strings .get("hud.chat.default_death_msg") .to_string(),