Rolling now dodges melee attacks again.

This commit is contained in:
Sam 2021-01-27 20:54:45 -05:00
parent 78879d5189
commit 18aa315f0d
2 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,7 @@ impl Attack {
self self
} }
#[allow(clippy::too_many_arguments)]
pub fn apply_attack( pub fn apply_attack(
&self, &self,
target_group: GroupTarget, target_group: GroupTarget,
@ -72,6 +73,7 @@ impl Attack {
inventory: Option<&Inventory>, inventory: Option<&Inventory>,
attacker_uid: Uid, attacker_uid: Uid,
dir: Dir, dir: Dir,
target_dodging: bool,
) -> Vec<ServerEvent> { ) -> Vec<ServerEvent> {
let is_crit = thread_rng().gen::<f32>() < self.crit_chance; let is_crit = thread_rng().gen::<f32>() < self.crit_chance;
let mut accumulated_damage = 0.0; let mut accumulated_damage = 0.0;
@ -80,6 +82,7 @@ impl Attack {
.damages .damages
.iter() .iter()
.filter(|d| d.target.map_or(true, |t| t == target_group)) .filter(|d| d.target.map_or(true, |t| t == target_group))
.filter(|d| !(matches!(d.target, Some(GroupTarget::OutOfGroup)) && target_dodging))
{ {
let change = damage.damage.modify_damage( let change = damage.damage.modify_damage(
inventory, inventory,

View File

@ -134,6 +134,7 @@ impl<'a> System<'a> for Sys {
inventory_b_maybe, inventory_b_maybe,
*uid, *uid,
dir, dir,
is_dodge,
); );
if !server_events.is_empty() { if !server_events.is_empty() {