From 6a870fd184c30b315528345bdc8e78bbe4872a9a Mon Sep 17 00:00:00 2001 From: gregchan550 <86044792+gregchan550@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:06:42 +1000 Subject: [PATCH] fixed bug where melee mob was moving in between attacks so itd get too close and not attack anymore --- .../csse3200/game/components/tasks/MobTask/MobTask.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 38a73799..d3b2b978 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -155,6 +155,9 @@ public void update() { animate(); runFlag = false; } + if (!enemyDetected() && melee) { + runFlag = true; + } if (melee && enemyDetected() && gameTime.getTime() - lastTimeAttacked >= MELEE_ATTACK_SPEED) { changeState(State.ATTACK); meleeAttackFlag = true; @@ -178,7 +181,9 @@ public void update() { if (animation.isFinished()) { movementTask.start(); changeState(State.RUN); - runFlag = true; + if (!melee) { + runFlag = true; + } } } case DODGE -> {