forked from MagicBane/Server
mob aggro issue
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Can't see target, skip aggro.
|
||||||
|
|
||||||
|
if (!aiAgent.canSee(loadedPlayer))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// No aggro for this race type
|
||||||
|
|
||||||
|
if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true)
|
||||||
|
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 (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
|
||||||
|
aiAgent.setCombatTarget(loadedPlayer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (loadedPlayer == null) {
|
|
||||||
loadedPlayers.remove(playerID);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
} else{
|
||||||
//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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Can't see target, skip aggro.
|
|
||||||
|
|
||||||
if (!aiAgent.canSee(loadedPlayer))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// No aggro for this race type
|
|
||||||
|
|
||||||
if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true)
|
|
||||||
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 (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
|
|
||||||
aiAgent.setCombatTarget(loadedPlayer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user