mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
* Set the KillType to Other for HealthSource::Healing
* Extend logic to projectiles and explosions
This commit is contained in:
parent
a9086b27a0
commit
57c6160b72
@ -25,7 +25,7 @@ pub enum HealthSource {
|
||||
Command,
|
||||
LevelUp,
|
||||
Item,
|
||||
Healing { by: Uid },
|
||||
Healing { by: Option<Uid> },
|
||||
Unknown,
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ impl<'a> System<'a> for Sys {
|
||||
uid: *uid_b,
|
||||
change: HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Healing { by: *uid },
|
||||
cause: HealthSource::Healing { by: Some(*uid) },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -82,15 +82,27 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
|
||||
if other != owner_uid {
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: other,
|
||||
change: HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Projectile {
|
||||
owner: Some(owner_uid),
|
||||
if damage.healthchange < 0.0 {
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: other,
|
||||
change: HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Projectile {
|
||||
owner: Some(owner_uid),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
} else if damage.healthchange > 0.0 {
|
||||
server_emitter.emit(ServerEvent::Damage {
|
||||
uid: other,
|
||||
change: HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Healing {
|
||||
by: Some(owner_uid),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
projectile::Effect::Knockback(knockback) => {
|
||||
|
@ -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::Healing { by } => {
|
||||
HealthSource::Attack { 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)
|
||||
@ -135,6 +135,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
|
||||
| HealthSource::Command
|
||||
| HealthSource::LevelUp
|
||||
| HealthSource::Item
|
||||
| HealthSource::Healing { by: _ }
|
||||
| HealthSource::Unknown => KillSource::Other,
|
||||
};
|
||||
state.notify_registered_clients(
|
||||
@ -450,7 +451,6 @@ pub fn handle_explosion(
|
||||
power,
|
||||
reagent,
|
||||
});
|
||||
|
||||
let owner_entity = owner.and_then(|uid| {
|
||||
ecs.read_resource::<UidAllocator>()
|
||||
.retrieve_entity_internal(uid.into())
|
||||
@ -493,10 +493,17 @@ pub fn handle_explosion(
|
||||
damage.modify_damage(block, loadout);
|
||||
}
|
||||
|
||||
stats_b.health.change_by(HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Explosion { owner },
|
||||
});
|
||||
if damage.healthchange < 0.0 {
|
||||
stats_b.health.change_by(HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Explosion { owner },
|
||||
});
|
||||
} else if damage.healthchange > 0.0 {
|
||||
stats_b.health.change_by(HealthChange {
|
||||
amount: damage.healthchange as i32,
|
||||
cause: HealthSource::Healing { by: owner },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user