From 9f7aa61fbdda4c00aba10752312e32cb30ff5c5c Mon Sep 17 00:00:00 2001 From: Caleb Cochran Date: Tue, 25 Feb 2020 20:48:09 -0600 Subject: [PATCH] Fixing #504 - Enemies stop attacking after combat --- common/src/sys/agent.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index f2268d439c..3d126f4ecd 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -124,7 +124,7 @@ impl<'a> System<'a> for Sys { if thread_rng().gen::() < 0.1 { choose_target = true; } - }, + } Activity::Follow(target, chaser) => { if let (Some(tgt_pos), _tgt_stats) = (positions.get(*target), stats.get(*target)) @@ -146,14 +146,14 @@ impl<'a> System<'a> for Sys { } else { do_idle = true; } - }, + } Activity::Attack { target, chaser, been_close, .. } => { - if let (Some(tgt_pos), _tgt_stats, tgt_alignment) = ( + if let (Some(tgt_pos), Some(tgt_stats), tgt_alignment) = ( positions.get(*target), stats.get(*target), alignments @@ -164,7 +164,8 @@ impl<'a> System<'a> for Sys { // Don't attack entities we are passive towards // TODO: This is here, it's a bit of a hack if let Some(alignment) = alignment { - if (*alignment).passive_towards(tgt_alignment) { + if (*alignment).passive_towards(tgt_alignment) || tgt_stats.is_dead + { do_idle = true; break 'activity; } @@ -207,7 +208,7 @@ impl<'a> System<'a> for Sys { } else { do_idle = true; } - }, + } } }