mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Provide buff information on killed entities
This commit is contained in:
parent
16c865ac27
commit
ec79890335
@ -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}]",
|
||||
|
@ -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)),
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
}
|
||||
};
|
||||
|
@ -100,10 +100,10 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
|
||||
} else if let Some(stats) = state.ecs().read_storage::<Stats>().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),
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user