forked from MagicBane/Server
infinite loop fix
This commit is contained in:
@@ -108,7 +108,7 @@ public enum NPCManager {
|
|||||||
|
|
||||||
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
||||||
|
|
||||||
necroPet.combatTarget = null;
|
necroPet.setCombatTarget(null);
|
||||||
necroPet.hasLoot = false;
|
necroPet.hasLoot = false;
|
||||||
|
|
||||||
if (necroPet.parentZone != null)
|
if (necroPet.parentZone != null)
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public class MobAI {
|
|||||||
attackDelay = 11000;
|
attackDelay = 11000;
|
||||||
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
|
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
|
||||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||||
if (target.combatTarget == null) {
|
if (target.getCombatTarget() == null) {
|
||||||
target.setCombatTarget(mob);
|
target.setCombatTarget(mob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,14 +638,15 @@ public class MobAI {
|
|||||||
|
|
||||||
//no players loaded, no need to proceed
|
//no players loaded, no need to proceed
|
||||||
|
|
||||||
if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
|
if (mob.playerAgroMap.isEmpty()) {
|
||||||
mob.setCombatTarget(null);
|
if(mob.getCombatTarget() != null)
|
||||||
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
|
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
|
||||||
CheckToSendMobHome(mob);
|
CheckToSendMobHome(mob);
|
||||||
|
|
||||||
if (mob.combatTarget != null) {
|
if (mob.getCombatTarget() != null) {
|
||||||
if (mob.getCombatTarget().isAlive() == false) {
|
if (mob.getCombatTarget().isAlive() == false) {
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
return;
|
return;
|
||||||
@@ -653,7 +654,7 @@ public class MobAI {
|
|||||||
|
|
||||||
if (mob.getCombatTarget().getObjectTypeMask() == MBServerStatics.MASK_PLAYER) {
|
if (mob.getCombatTarget().getObjectTypeMask() == MBServerStatics.MASK_PLAYER) {
|
||||||
|
|
||||||
PlayerCharacter target = (PlayerCharacter) mob.combatTarget;
|
PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget();
|
||||||
|
|
||||||
if (mob.playerAgroMap.containsKey(target.getObjectUUID()) == false) {
|
if (mob.playerAgroMap.containsKey(target.getObjectUUID()) == false) {
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
@@ -745,7 +746,7 @@ public class MobAI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aiAgent.combatTarget == null) {
|
if (aiAgent.getCombatTarget() == null) {
|
||||||
|
|
||||||
//look for pets to aggro if no players found to aggro
|
//look for pets to aggro if no players found to aggro
|
||||||
|
|
||||||
@@ -1046,9 +1047,12 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (mob.npcOwner.getCombatTarget() != null)
|
if (mob.npcOwner.getCombatTarget() != null)
|
||||||
|
if(mob.getCombatTarget() != null && mob.getCombatTarget().equals(mob.npcOwner.getCombatTarget()) == false)
|
||||||
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
||||||
else
|
else
|
||||||
mob.setCombatTarget(null);
|
if(mob.getCombatTarget() != null) {
|
||||||
|
mob.setCombatTarget(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
@@ -1110,7 +1114,7 @@ public class MobAI {
|
|||||||
|
|
||||||
if (mob.getCombatTarget() == null)
|
if (mob.getCombatTarget() == null)
|
||||||
SafeGuardAggro(mob);
|
SafeGuardAggro(mob);
|
||||||
else if (mob.combatTarget.isAlive() == false)
|
else if (mob.getCombatTarget().isAlive() == false)
|
||||||
SafeGuardAggro(mob);
|
SafeGuardAggro(mob);
|
||||||
|
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
@@ -1151,7 +1155,7 @@ public class MobAI {
|
|||||||
|
|
||||||
//check if mob can attack if it isn't wimpy
|
//check if mob can attack if it isn't wimpy
|
||||||
|
|
||||||
if (!mob.BehaviourType.isWimpy && mob.combatTarget != null)
|
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1199,7 +1203,7 @@ public class MobAI {
|
|||||||
if (GuardCanAggro(mob, loadedPlayer) == false)
|
if (GuardCanAggro(mob, loadedPlayer) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer)) {
|
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) {
|
||||||
mob.setCombatTarget(loadedPlayer);
|
mob.setCombatTarget(loadedPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1162,20 +1162,20 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void setCombatTarget(final AbstractWorldObject value) {
|
public final void setCombatTarget(final AbstractWorldObject value) {
|
||||||
if(value.getObjectTypeMask() == MBServerStatics.MASK_MOB) {
|
if(this.getObjectTypeMask() == 2050) {//MOB?
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if (this.isCombat()) {
|
if (this.isCombat()) {
|
||||||
this.setCombat(false);
|
this.setCombat(false);
|
||||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
rwss.setPlayer(this);
|
rwss.setPlayer(this);
|
||||||
DispatchMessage.sendToAllInRange(this, rwss);
|
DispatchMessage.sendToAllInRange(this, rwss);
|
||||||
} else {
|
}
|
||||||
if (!this.isCombat()) {
|
}else {
|
||||||
this.setCombat(true);
|
if (!this.isCombat()) {
|
||||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
this.setCombat(true);
|
||||||
rwss.setPlayer(this);
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
DispatchMessage.sendToAllInRange(this, rwss);
|
rwss.setPlayer(this);
|
||||||
}
|
DispatchMessage.sendToAllInRange(this, rwss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1305,7 +1305,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e.getMessage());
|
Logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
this.combatTarget = null;
|
this.setCombatTarget(null);
|
||||||
this.hasLoot = false;
|
this.hasLoot = false;
|
||||||
this.playerAgroMap.clear();
|
this.playerAgroMap.clear();
|
||||||
|
|
||||||
@@ -1329,7 +1329,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
} else if (this.isPet() || this.isNecroPet()) {
|
} else if (this.isPet() || this.isNecroPet()) {
|
||||||
//this.state = STATE.Disabled;
|
//this.state = STATE.Disabled;
|
||||||
|
|
||||||
this.combatTarget = null;
|
this.setCombatTarget(null);
|
||||||
this.hasLoot = false;
|
this.hasLoot = false;
|
||||||
|
|
||||||
//if (this.parentZone != null)
|
//if (this.parentZone != null)
|
||||||
@@ -1372,7 +1372,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
this.combat = false;
|
this.combat = false;
|
||||||
this.walkMode = true;
|
this.walkMode = true;
|
||||||
this.combatTarget = null;
|
this.setCombatTarget(null);
|
||||||
|
|
||||||
this.hasLoot = this.charItemManager.getInventoryCount() > 0;
|
this.hasLoot = this.charItemManager.getInventoryCount() > 0;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1391,7 +1391,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.mana.set(this.manaMax);
|
this.mana.set(this.manaMax);
|
||||||
this.combat = false;
|
this.combat = false;
|
||||||
this.walkMode = true;
|
this.walkMode = true;
|
||||||
this.combatTarget = null;
|
this.setCombatTarget(null);
|
||||||
this.isAlive.set(true);
|
this.isAlive.set(true);
|
||||||
this.deathTime = 0;
|
this.deathTime = 0;
|
||||||
this.lastBindLoc = this.bindLoc;
|
this.lastBindLoc = this.bindLoc;
|
||||||
@@ -2079,7 +2079,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
PlayerCharacter player = (PlayerCharacter) ac;
|
PlayerCharacter player = (PlayerCharacter) ac;
|
||||||
|
|
||||||
if (this.getCombatTarget() == null) {
|
if (this.getCombatTarget() == null) {
|
||||||
this.combatTarget = ac;
|
this.setCombatTarget(ac);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user