mob respawn fix

This commit is contained in:
2023-04-21 12:56:09 -05:00
parent 881907c53a
commit e5b7bd1fa6
2 changed files with 7 additions and 45 deletions
+6 -33
View File
@@ -33,7 +33,7 @@ public class MobileFSM {
if(mob == null){
return;
}
if(target == null){
if(target == null || target.isAlive() == false){
mob.setCombatTarget(null);
return;
}
@@ -449,12 +449,14 @@ public class MobileFSM {
private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis());
return;
}
//handles checking for respawn of dead mobs even when no players have mob loaded
//Despawn Timer with Loot currently in inventory.
if (aiAgent.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn();
return;
}
//No items in inventory.
} else {
@@ -462,16 +464,18 @@ public class MobileFSM {
if (aiAgent.isHasLoot()) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn();
return;
}
//Mob never had Loot.
} else {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
aiAgent.despawn();
//update time of death after mob despawns so respawn time happens after mob despawns.
return;
}
}
}
if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnTime * 1000)) {
aiAgent.despawn();
aiAgent.respawn();
}
}
@@ -509,37 +513,6 @@ public class MobileFSM {
mob.setCombatTarget(null);
}
}
public static void dead(Mob aiAgent) {
//Despawn Timer with Loot currently in inventory.
if (aiAgent.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn();
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent.setDeathTime(System.currentTimeMillis());
//aiAgent.state = STATE.Respawn;
}
//No items in inventory.
} else {
//Mob's Loot has been looted.
if (aiAgent.isHasLoot()) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn();
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent.setDeathTime(System.currentTimeMillis());
//aiAgent.state = STATE.Respawn;
}
//Mob never had Loot.
} else {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
aiAgent.despawn();
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent.setDeathTime(System.currentTimeMillis());
//aiAgent.state = STATE.Respawn;
}
}
}
}
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
+1 -12
View File
@@ -1196,7 +1196,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.isSiege) {
this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead;
MobileFSM.dead(this);
try {
this.clearEffects();
} catch (Exception e) {
@@ -1239,12 +1238,6 @@ public class Mob extends AbstractIntelligenceAgent {
WorldGrid.RemoveWorldObject(this);
DbManager.removeFromCache(this);
// YEAH BONUS CODE! THANKS UNNAMED ASSHOLE!
//WorldServer.removeObject(this);
//WorldGrid.INSTANCE.removeWorldObject(this);
//owner.getPet().disableIntelligence();
PlayerCharacter petOwner = this.getOwner();
if (petOwner != null) {
@@ -1257,11 +1250,6 @@ public class Mob extends AbstractIntelligenceAgent {
} else {
//cleanup effects
this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead;
MobileFSM.dead(this);
playerAgroMap.clear();
if (!this.isPlayerGuard && this.equip != null) {
@@ -2008,6 +1996,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.BehaviourType = Enum.MobBehaviourType.GuardCaptain;
}
}
this.deathTime = 0;
} catch (Exception e) {
Logger.error(e.getMessage());
}