Fixed shockwave and melee crit damage bypassing infinite armor. Made knockback not be applied if infinite armor.

This commit is contained in:
Sam 2020-08-23 16:53:43 -04:00
parent 6327dd18b6
commit d0f068ba63
5 changed files with 11 additions and 7 deletions

View File

@ -36,7 +36,9 @@ impl Damage {
self.healthchange *= 1.0 - damage_reduction;
// Critical damage applies after armor for melee
self.healthchange += critdamage;
if (damage_reduction - 1.0).abs() > f32::EPSILON {
self.healthchange += critdamage;
}
// Min damage
if (damage_reduction - 1.0).abs() > f32::EPSILON && self.healthchange > -10.0 {
@ -77,10 +79,11 @@ impl Damage {
},
DamageSource::Shockwave => {
// Armor
self.healthchange *= 1.0 - loadout.get_damage_reduction();
let damage_reduction = loadout.get_damage_reduction();
self.healthchange *= 1.0 - damage_reduction;
// Min damage
if self.healthchange > -10.0 {
if (damage_reduction - 1.0).abs() > f32::EPSILON && self.healthchange > -10.0 {
self.healthchange = -10.0;
}
},

View File

@ -69,6 +69,7 @@ impl LoadoutBuilder {
/// Builds loadout of creature when spawned
pub fn build_loadout(body: Body, alignment: Alignment, mut main_tool: Option<Item>) -> Self {
#![allow(clippy::single_match)] // For when this is done to more than just golems.
match body {
Body::Golem(golem) => match golem.species {
golem::Species::StoneGolem => {

View File

@ -59,7 +59,7 @@ impl<'a> System<'a> for Sys {
let start_time = std::time::Instant::now();
span!(_guard, "run", "combat::Sys::run");
let mut server_emitter = server_bus.emitter();
let mut local_emitter = local_bus.emitter();
let mut _local_emitter = local_bus.emitter();
// Attacks
for (entity, uid, pos, ori, scale_maybe, attack) in (
&entities,
@ -152,8 +152,7 @@ impl<'a> System<'a> for Sys {
},
});
}
if attack.knockback != 0.0 {
if attack.knockback != 0.0 && damage.healthchange != 0.0 {
server_emitter.emit(ServerEvent::Knockback {
entity: b,
force: attack.knockback

View File

@ -209,7 +209,7 @@ impl<'a> System<'a> for Sys {
},
});
}
if shockwave.knockback != 0.0 {
if shockwave.knockback != 0.0 && damage.healthchange != 0.0 {
if shockwave.knockback < 0.0 {
server_emitter.emit(ServerEvent::Knockback {
entity: b,

View File

@ -79,6 +79,7 @@ pub fn handle_create_npc(
entity.build();
}
#[allow(clippy::too_many_arguments)]
pub fn handle_shoot(
server: &mut Server,
entity: EcsEntity,