Do not make healing items deal damage

This commit is contained in:
Matthew Martin 2020-09-08 22:14:17 +02:00
parent b0dc35aa21
commit a9086b27a0
3 changed files with 12 additions and 2 deletions

View File

@ -25,6 +25,7 @@ pub enum HealthSource {
Command,
LevelUp,
Item,
Healing { by: Uid },
Unknown,
}

View File

@ -129,7 +129,7 @@ impl<'a> System<'a> for Sys {
damage.modify_damage(block, loadout);
}
if damage.healthchange != 0.0 {
if damage.healthchange < 0.0 {
server_emitter.emit(ServerEvent::Damage {
uid: *uid_b,
change: HealthChange {
@ -137,7 +137,16 @@ impl<'a> System<'a> for Sys {
cause: HealthSource::Attack { by: *uid },
},
});
} else if damage.healthchange > 0.0 {
server_emitter.emit(ServerEvent::Damage {
uid: *uid_b,
change: HealthChange {
amount: damage.healthchange as i32,
cause: HealthSource::Healing { by: *uid },
},
});
}
if attack.knockback != 0.0 {
local_emitter.emit(LocalEvent::ApplyForce {
entity: b,

View File

@ -60,7 +60,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
if let Some(_player) = state.ecs().read_storage::<Player>().get(entity) {
if let Some(uid) = state.ecs().read_storage::<Uid>().get(entity) {
let kill_source = match cause {
HealthSource::Attack { by } => {
HealthSource::Attack { by } | HealthSource::Healing { by } => {
// Get attacker entity
if let Some(char_entity) = state.ecs().entity_from_uid(by.into()) {
// Check if attacker is another player or entity with stats (npc)