Browse Source

mob aggro issue

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
8156f261fc
  1. 67
      src/engine/mobileAI/MobAI.java

67
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 { try {
@ -735,51 +735,50 @@ public class MobAI {
if (!aiAgent.isAlive()) if (!aiAgent.isAlive())
return; return;
if(!pets) {
ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
ConcurrentHashMap<Integer, Float> 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(); //Player is null, let's remove them from the list.
PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID);
//Player is null, let's remove them from the list. if (loadedPlayer == null) {
loadedPlayers.remove(playerID);
continue;
}
if (loadedPlayer == null) { //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map.
loadedPlayers.remove(playerID);
continue;
}
//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) { //Can't see target, skip aggro.
loadedPlayers.remove(playerID);
continue;
}
//Can't see target, skip aggro. if (!aiAgent.canSee(loadedPlayer))
continue;
if (!aiAgent.canSee(loadedPlayer)) // No aggro for this race type
continue;
// 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) //mob has enemies and this player race is not it
continue;
//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) if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
continue; aiAgent.setCombatTarget(loadedPlayer);
return;
}
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
aiAgent.setCombatTarget(loadedPlayer);
return;
} }
} else{
}
if (aiAgent.getCombatTarget() == null) {
//look for pets to aggro if no players found to aggro //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)) if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} else { } else {
CheckForAggro(mob); CheckForAggro(mob,false);
} }
} }
@ -1212,9 +1211,9 @@ public class MobAI {
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) { if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) {
SafeGuardAggro(mob); //safehold guard SafeGuardAggro(mob); //safehold guard
}else { }else {
CheckForAggro(mob); //normal aggro CheckForAggro(mob,false); //normal aggro
if(mob.combatTarget == null) 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
} }
} }
} }

Loading…
Cancel
Save