From a8579670cf47e377b610f379cf030a973b18579f Mon Sep 17 00:00:00 2001 From: Swrup Date: Thu, 8 Jul 2021 21:05:32 +0200 Subject: [PATCH] make apply_attack() return if attack was actually applied --- common/src/combat.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 43a998f43c..34e8c224c6 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -171,7 +171,8 @@ impl Attack { attack_source: AttackSource, mut emit: impl FnMut(ServerEvent), mut emit_outcome: impl FnMut(Outcome), - ) { + ) -> bool { + let mut is_applied = false; let is_crit = thread_rng().gen::() < self.crit_chance; let mut accumulated_damage = 0.0; for damage in self @@ -180,6 +181,7 @@ impl Attack { .filter(|d| d.target.map_or(true, |t| t == target_group)) .filter(|d| !(matches!(d.target, Some(GroupTarget::OutOfGroup)) && target_dodging)) { + is_applied = true; let damage_reduction = Attack::compute_damage_reduction( &target, attack_source, @@ -340,6 +342,7 @@ impl Attack { } }, }) { + is_applied = true; match effect.effect { CombatEffect::Knockback(kb) => { let impulse = kb.calculate_impulse(dir); @@ -423,6 +426,7 @@ impl Attack { } } } + is_applied } }