From 96231260bc1b7cac7d0282f817e10ac12b28ccdd Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 9 Sep 2023 10:37:40 -0500 Subject: [PATCH] consolidated all guards to GuardLogic --- src/engine/mobileAI/MobAI.java | 41 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index d27cb6fe..c1f883a8 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -616,10 +616,8 @@ public class MobAI { switch (mob.behaviourType) { case GuardCaptain: case GuardMinion: - GuardLogic(mob); - break; case GuardWallArcher: - GuardWallArcherLogic(mob); + GuardLogic(mob); break; case Pet1: case SiegeEngine: @@ -953,37 +951,30 @@ public class MobAI { public static void GuardLogic(Mob mob) { try { - if (mob.getCombatTarget() == null) + if (mob.getCombatTarget() == null) { CheckForPlayerGuardAggro(mob); + } else { + //do not need to look to change target if target is already null + AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); - - if (newTarget != null) { + if (newTarget != null) { - if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) + if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) + mob.setCombatTarget(newTarget); + } else mob.setCombatTarget(newTarget); - } else - mob.setCombatTarget(newTarget); - + } } - CheckMobMovement(mob); - CheckForAttack(mob); - } catch (Exception e) { - Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage()); - } - } + if(mob.behaviourType.canRoam) + CheckMobMovement(mob);//all guards that can move check to move - public static void GuardWallArcherLogic(Mob mob) { + if(mob.combatTarget != null) + CheckForAttack(mob); //only check to attack if combat target is not null - try { - if (mob.getCombatTarget() == null) - CheckForPlayerGuardAggro(mob); - else - CheckForAttack(mob); } catch (Exception e) { - Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage()); + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage()); } }