Skip to content

Commit

Permalink
Misses still register you as an opponent for NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Oct 11, 2023
1 parent e9c4d4f commit 709ff99
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/map/npc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
};

Expand Down

0 comments on commit 709ff99

Please sign in to comment.