mob pulse delay added to mobAI

This commit is contained in:
2023-08-01 21:26:14 -05:00
parent b47848d63d
commit b8cb90cdd0
2 changed files with 16 additions and 7 deletions
+11 -6
View File
@@ -382,6 +382,13 @@ public class MobAI {
if (mob == null) if (mob == null)
return; return;
if(mob.getTimestamps().containsKey("lastExecution") == false){
mob.getTimestamps().put("lastExecution",System.currentTimeMillis());
}
if(System.currentTimeMillis() < mob.getTimeStamp("lastExecution")){
return;
}
mob.getTimestamps().put("lastExecution",System.currentTimeMillis() + MobAIThread.AI_PULSE_MOB_THRESHOLD);
if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { if (mob.despawned && mob.getMobBase().getLoadID() == 13171) {
//trebuchet spawn handler //trebuchet spawn handler
CheckForRespawn(mob); CheckForRespawn(mob);
@@ -439,10 +446,6 @@ public class MobAI {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
if(target.getClientConnection() == null){
mob.setCombatTarget(null);
return;
}
} }
} }
//if(mob.getTimestamps().containsKey("LOCATIONSYNC") == false){ //if(mob.getTimestamps().containsKey("LOCATIONSYNC") == false){
@@ -705,14 +708,16 @@ public class MobAI {
case PlayerCharacter: case PlayerCharacter:
case Mob: case Mob:
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange()); MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange() + 1);
break; break;
case Building: case Building:
mob.destination = mob.getCombatTarget().getLoc(); mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0); MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0);
break; break;
} }
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == true){
mob.stopMovement(mob.getLoc());
}
} }
} }
} catch(Exception e){ } catch(Exception e){
+5 -1
View File
@@ -704,7 +704,11 @@ public class WorldServer {
Logger.error("Unable to find PlayerCharacter to logout"); Logger.error("Unable to find PlayerCharacter to logout");
return; return;
} }
//remove player from loaded mobs agro maps
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) {
Mob loadedMob = (Mob) awo;
loadedMob.playerAgroMap.remove(player.getObjectUUID());
}
player.getTimestamps().put("logout", System.currentTimeMillis()); player.getTimestamps().put("logout", System.currentTimeMillis());
player.setEnteredWorld(false); player.setEnteredWorld(false);