diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 314f564a..571532a0 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -727,7 +727,7 @@ public class MobAI { } } - private static void CheckForAggro(Mob aiAgent) { + private static void CheckForAggro(Mob aiAgent, boolean pets) { try { @@ -735,51 +735,50 @@ public class MobAI { if (!aiAgent.isAlive()) return; + if(!pets) { + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; - ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; + for (Entry playerEntry : loadedPlayers.entrySet()) { - for (Entry playerEntry : loadedPlayers.entrySet()) { + int playerID = (int) playerEntry.getKey(); + PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); - int playerID = (int) playerEntry.getKey(); - PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); + //Player is null, let's remove them from the list. - //Player is null, let's remove them from the list. + if (loadedPlayer == null) { + loadedPlayers.remove(playerID); + continue; + } - if (loadedPlayer == null) { - loadedPlayers.remove(playerID); - continue; - } + //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. - //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. + if (!loadedPlayer.isAlive() || loadedPlayer.getHidden() > 0) { + loadedPlayers.remove(playerID); + continue; + } - if (!loadedPlayer.isAlive() || loadedPlayer.getHidden() > 0) { - loadedPlayers.remove(playerID); - continue; - } + //Can't see target, skip aggro. - //Can't see target, skip aggro. + if (!aiAgent.canSee(loadedPlayer)) + continue; - if (!aiAgent.canSee(loadedPlayer)) - continue; + // No aggro for this race type - // No aggro for this race type + if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true) + continue; - if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true) - continue; + //mob has enemies and this player race is not it - //mob has enemies and this player race is not it + if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false) + continue; - if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false) - continue; + if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { + aiAgent.setCombatTarget(loadedPlayer); + return; + } - if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { - aiAgent.setCombatTarget(loadedPlayer); - return; } - - } - - if (aiAgent.getCombatTarget() == null) { + } else{ //look for pets to aggro if no players found to aggro @@ -952,7 +951,7 @@ public class MobAI { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) CheckForPlayerGuardAggro(mob); } else { - CheckForAggro(mob); + CheckForAggro(mob,false); } } @@ -1212,9 +1211,9 @@ public class MobAI { if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) { SafeGuardAggro(mob); //safehold guard }else { - CheckForAggro(mob); //normal aggro + CheckForAggro(mob,false); //normal aggro if(mob.combatTarget == null) - SafeGuardAggro(mob); // look for pets if no players to aggro + CheckForAggro(mob,true); // look for pets if no players to aggro } } }