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,
|
Command,
|
||||||
LevelUp,
|
LevelUp,
|
||||||
Item,
|
Item,
|
||||||
Healing { by: Uid },
|
Healing { by: Option<Uid> },
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
uid: *uid_b,
|
uid: *uid_b,
|
||||||
change: HealthChange {
|
change: HealthChange {
|
||||||
amount: damage.healthchange as i32,
|
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 {
|
if other != owner_uid {
|
||||||
server_emitter.emit(ServerEvent::Damage {
|
if damage.healthchange < 0.0 {
|
||||||
uid: other,
|
server_emitter.emit(ServerEvent::Damage {
|
||||||
change: HealthChange {
|
uid: other,
|
||||||
amount: damage.healthchange as i32,
|
change: HealthChange {
|
||||||
cause: HealthSource::Projectile {
|
amount: damage.healthchange as i32,
|
||||||
owner: Some(owner_uid),
|
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) => {
|
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(_player) = state.ecs().read_storage::<Player>().get(entity) {
|
||||||
if let Some(uid) = state.ecs().read_storage::<Uid>().get(entity) {
|
if let Some(uid) = state.ecs().read_storage::<Uid>().get(entity) {
|
||||||
let kill_source = match cause {
|
let kill_source = match cause {
|
||||||
HealthSource::Attack { by } | HealthSource::Healing { by } => {
|
HealthSource::Attack { by } => {
|
||||||
// Get attacker entity
|
// Get attacker entity
|
||||||
if let Some(char_entity) = state.ecs().entity_from_uid(by.into()) {
|
if let Some(char_entity) = state.ecs().entity_from_uid(by.into()) {
|
||||||
// Check if attacker is another player or entity with stats (npc)
|
// 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::Command
|
||||||
| HealthSource::LevelUp
|
| HealthSource::LevelUp
|
||||||
| HealthSource::Item
|
| HealthSource::Item
|
||||||
|
| HealthSource::Healing { by: _ }
|
||||||
| HealthSource::Unknown => KillSource::Other,
|
| HealthSource::Unknown => KillSource::Other,
|
||||||
};
|
};
|
||||||
state.notify_registered_clients(
|
state.notify_registered_clients(
|
||||||
@ -450,7 +451,6 @@ pub fn handle_explosion(
|
|||||||
power,
|
power,
|
||||||
reagent,
|
reagent,
|
||||||
});
|
});
|
||||||
|
|
||||||
let owner_entity = owner.and_then(|uid| {
|
let owner_entity = owner.and_then(|uid| {
|
||||||
ecs.read_resource::<UidAllocator>()
|
ecs.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal(uid.into())
|
.retrieve_entity_internal(uid.into())
|
||||||
@ -493,10 +493,17 @@ pub fn handle_explosion(
|
|||||||
damage.modify_damage(block, loadout);
|
damage.modify_damage(block, loadout);
|
||||||
}
|
}
|
||||||
|
|
||||||
stats_b.health.change_by(HealthChange {
|
if damage.healthchange < 0.0 {
|
||||||
amount: damage.healthchange as i32,
|
stats_b.health.change_by(HealthChange {
|
||||||
cause: HealthSource::Explosion { owner },
|
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