Browse Source

mob respawn fix

master
FatBoy-DOTC 2 years ago
parent
commit
e5b7bd1fa6
  1. 39
      src/engine/ai/MobileFSM.java
  2. 13
      src/engine/objects/Mob.java

39
src/engine/ai/MobileFSM.java

@ -33,7 +33,7 @@ public class MobileFSM {
if(mob == null){ if(mob == null){
return; return;
} }
if(target == null){ if(target == null || target.isAlive() == false){
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@ -449,12 +449,14 @@ public class MobileFSM {
private static void CheckForRespawn(Mob aiAgent) { private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) { if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis()); aiAgent.setDeathTime(System.currentTimeMillis());
return;
} }
//handles checking for respawn of dead mobs even when no players have mob loaded //handles checking for respawn of dead mobs even when no players have mob loaded
//Despawn Timer with Loot currently in inventory. //Despawn Timer with Loot currently in inventory.
if (aiAgent.getCharItemManager().getInventoryCount() > 0) { if (aiAgent.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn(); aiAgent.despawn();
return;
} }
//No items in inventory. //No items in inventory.
} else { } else {
@ -462,16 +464,18 @@ public class MobileFSM {
if (aiAgent.isHasLoot()) { if (aiAgent.isHasLoot()) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn(); aiAgent.despawn();
return;
} }
//Mob never had Loot. //Mob never had Loot.
} else { } else {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
aiAgent.despawn(); 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)) { if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnTime * 1000)) {
aiAgent.despawn();
aiAgent.respawn(); aiAgent.respawn();
} }
} }
@ -509,37 +513,6 @@ public class MobileFSM {
mob.setCombatTarget(null); 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) { private static void chaseTarget(Mob mob) {
mob.updateMovementState(); mob.updateMovementState();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {

13
src/engine/objects/Mob.java

@ -1196,7 +1196,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.isSiege) { if (this.isSiege) {
this.deathTime = System.currentTimeMillis(); this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead; //this.state = STATE.Dead;
MobileFSM.dead(this);
try { try {
this.clearEffects(); this.clearEffects();
} catch (Exception e) { } catch (Exception e) {
@ -1239,12 +1238,6 @@ public class Mob extends AbstractIntelligenceAgent {
WorldGrid.RemoveWorldObject(this); WorldGrid.RemoveWorldObject(this);
DbManager.removeFromCache(this); DbManager.removeFromCache(this);
// YEAH BONUS CODE! THANKS UNNAMED ASSHOLE!
//WorldServer.removeObject(this);
//WorldGrid.INSTANCE.removeWorldObject(this);
//owner.getPet().disableIntelligence();
PlayerCharacter petOwner = this.getOwner(); PlayerCharacter petOwner = this.getOwner();
if (petOwner != null) { if (petOwner != null) {
@ -1257,11 +1250,6 @@ public class Mob extends AbstractIntelligenceAgent {
} else { } else {
//cleanup effects //cleanup effects
this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead;
MobileFSM.dead(this);
playerAgroMap.clear(); playerAgroMap.clear();
if (!this.isPlayerGuard && this.equip != null) { if (!this.isPlayerGuard && this.equip != null) {
@ -2008,6 +1996,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.BehaviourType = Enum.MobBehaviourType.GuardCaptain; this.BehaviourType = Enum.MobBehaviourType.GuardCaptain;
} }
} }
this.deathTime = 0;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }

Loading…
Cancel
Save