From 709ff9984e03068acb54e770582e1e7401169fef Mon Sep 17 00:00:00 2001 From: Richard Leek Date: Wed, 11 Oct 2023 09:30:08 +0200 Subject: [PATCH] Misses still register you as an opponent for NPCs --- src/map/npc.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/map/npc.rs b/src/map/npc.rs index 3718fbf0..f8174ae5 100644 --- a/src/map/npc.rs +++ b/src/map/npc.rs @@ -88,15 +88,15 @@ impl Npc { let mut rng = rand::thread_rng(); let rand = rng.gen_range(0.0..1.0); - if hit_rate < rand { - return 0; - } - - let damage = match eval_float_with_context(&FORMULAS.damage, &context) { - Ok(amount) => cmp::min(amount.floor() as EOInt, self.hp as EOInt), - Err(e) => { - error!("Failed to calculate damage: {}", e); - 0 + let damage = if hit_rate < rand { + 0 + } else { + match eval_float_with_context(&FORMULAS.damage, &context) { + Ok(amount) => cmp::min(amount.floor() as EOInt, self.hp as EOInt), + Err(e) => { + error!("Failed to calculate damage: {}", e); + 0 + } } };