From e5b7bd1fa68ef96c0c4f5a16aa96de0027f86ff3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 21 Apr 2023 12:56:09 -0500 Subject: [PATCH] mob respawn fix --- src/engine/ai/MobileFSM.java | 39 ++++++------------------------------ src/engine/objects/Mob.java | 13 +----------- 2 files changed, 7 insertions(+), 45 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 9f131f65..5cae621d 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -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) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e6120bea..26a9f43f 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -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()); }