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 { @@ -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 { @@ -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 { @@ -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 { @@ -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) {

13
src/engine/objects/Mob.java

@ -1196,7 +1196,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -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 { @@ -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 { @@ -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 { @@ -2008,6 +1996,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.BehaviourType = Enum.MobBehaviourType.GuardCaptain;
}
}
this.deathTime = 0;
} catch (Exception e) {
Logger.error(e.getMessage());
}

Loading…
Cancel
Save