mob AI aggro cleanup
This commit is contained in:
@@ -394,21 +394,7 @@ public class MobAI {
|
||||
}
|
||||
|
||||
//no players loaded, no need to proceed
|
||||
|
||||
if (mob.playerAgroMap.isEmpty()) {
|
||||
//attempt to reload agro map
|
||||
HashSet<AbstractWorldObject> players = WorldGrid.getObjectsInRangePartial(mob.loc, mob.getAggroRange(), MBServerStatics.MASK_PLAYER);
|
||||
if(players.size() > 0){
|
||||
for(AbstractWorldObject player : players){
|
||||
if(!mob.playerAgroMap.containsKey(player.getObjectUUID())) {
|
||||
PlayerCharacter pc = (PlayerCharacter) player;
|
||||
mob.playerAgroMap.put(pc.getObjectUUID(), 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mob.getCombatTarget() != null)
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,6 +427,7 @@ public class MobAI {
|
||||
if (mob.isMoving()) {
|
||||
mob.updateLocation();
|
||||
}
|
||||
|
||||
boolean combatState = mob.isCombat();
|
||||
mob.setCombat(mob.combatTarget != null);
|
||||
if(combatState != mob.isCombat()){
|
||||
@@ -449,6 +436,7 @@ public class MobAI {
|
||||
rwss.setPlayer(mob);
|
||||
DispatchMessage.sendToAllInRange(mob, rwss);
|
||||
}
|
||||
|
||||
boolean walking = mob.isWalk();
|
||||
mob.setWalkMode(mob.combatTarget == null);
|
||||
if(walking != mob.isWalk()){
|
||||
@@ -490,34 +478,28 @@ public class MobAI {
|
||||
|
||||
if (!aiAgent.isAlive())
|
||||
return;
|
||||
|
||||
if(!pets) {
|
||||
ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
|
||||
|
||||
for (Integer playerEntry : loadedPlayers.keySet()) {
|
||||
|
||||
PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerEntry);
|
||||
|
||||
//Player is null, let's remove them from the list.
|
||||
|
||||
if (loadedPlayer == null) {
|
||||
loadedPlayers.remove(playerEntry);
|
||||
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(playerEntry);
|
||||
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()))
|
||||
continue;
|
||||
|
||||
@@ -536,7 +518,7 @@ public class MobAI {
|
||||
|
||||
//look for pets to aggro if no players found to aggro
|
||||
|
||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET);
|
||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_MOB);
|
||||
|
||||
for (AbstractWorldObject awoMob : awoList) {
|
||||
|
||||
@@ -545,6 +527,9 @@ public class MobAI {
|
||||
if (aiAgent.equals(awoMob))
|
||||
continue;
|
||||
|
||||
if(!((Mob)awoMob).isPet())
|
||||
continue;
|
||||
|
||||
Mob aggroMob = (Mob) awoMob;
|
||||
aiAgent.setCombatTarget(aggroMob);
|
||||
return;
|
||||
@@ -921,24 +906,16 @@ public class MobAI {
|
||||
}
|
||||
|
||||
if (mob.behaviourType.isAgressive) {
|
||||
|
||||
//AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||
|
||||
//if (newTarget != null)
|
||||
// mob.setCombatTarget(newTarget);
|
||||
//else {
|
||||
|
||||
if (mob.getCombatTarget() == null) {
|
||||
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) {
|
||||
SafeGuardAggro(mob); //safehold guard
|
||||
}else {
|
||||
CheckForAggro(mob,false); //normal aggro
|
||||
if(mob.combatTarget == null)
|
||||
CheckForAggro(mob,true); // look for pets if no players to aggro
|
||||
}
|
||||
if (mob.getCombatTarget() == null) {
|
||||
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) {
|
||||
SafeGuardAggro(mob); //safehold guard
|
||||
} else {
|
||||
CheckForAggro(mob, false); //normal aggro
|
||||
if (mob.combatTarget == null)
|
||||
CheckForAggro(mob, true); // look for pets if no players to aggro
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
//check if mob can move for patrol or moving to target
|
||||
|
||||
|
||||
Reference in New Issue
Block a user