Browse Source

cleaned up some aggro rules

master
FatBoy-DOTC 2 years ago
parent
commit
aaff8e7d6b
  1. 41
      src/engine/ai/MobileFSM.java
  2. 2
      src/engine/objects/Mob.java

41
src/engine/ai/MobileFSM.java

@ -451,21 +451,6 @@ public class MobileFSM {
} }
} }
} }
private static void respawn(Mob aiAgent) {
if (!aiAgent.canRespawn())
return;
long spawnTime = aiAgent.getSpawnTime();
if (aiAgent.isPlayerGuard() && aiAgent.npcOwner != null && !aiAgent.npcOwner.isAlive())
return;
if (System.currentTimeMillis() > aiAgent.deathTime + spawnTime) {
aiAgent.respawn();
aiAgent.setCombatTarget(null);
}
}
public static boolean canCast(Mob mob) { public static boolean canCast(Mob mob) {
// Performs validation to determine if a // Performs validation to determine if a
@ -578,6 +563,8 @@ public class MobileFSM {
if (mob == null) { if (mob == null) {
return; return;
} }
//add default behaviour type
mob.BehaviourType = MobBehaviourType.Aggro;
if (mob.isAlive() == false) { if (mob.isAlive() == false) {
//no need to continue if mob is dead, check for respawn and move on //no need to continue if mob is dead, check for respawn and move on
CheckForRespawn(mob); CheckForRespawn(mob);
@ -599,7 +586,7 @@ public class MobileFSM {
CheckMobMovement(mob); CheckMobMovement(mob);
} }
//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.isMoving()) { if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null) {
CheckForAttack(mob); CheckForAttack(mob);
} }
} }
@ -631,11 +618,13 @@ public class MobileFSM {
continue; continue;
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
aiAgent.setAggroTargetID(playerID); aiAgent.setAggroTargetID(playerID);
aiAgent.setCombatTarget(loadedPlayer);
return; return;
} }
} }
} }
private static void CheckMobMovement(Mob mob) { private static void CheckMobMovement(Mob mob) {
mob.updateLocation();
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
//patrol //patrol
int patrolRandom = ThreadLocalRandom.current().nextInt(1000); int patrolRandom = ThreadLocalRandom.current().nextInt(1000);
@ -654,10 +643,11 @@ public class MobileFSM {
patrolRadius = 60; patrolRadius = 60;
MovementUtilities.aiMove(mob, Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius), true); MovementUtilities.aiMove(mob, Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius), true);
}
}
}else { }else {
//chase target //chase target
mob.updateMovementState(); mob.updateMovementState();
mob.updateLocation();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) { if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc(); mob.destination = mob.getCombatTarget().getLoc();
@ -669,8 +659,6 @@ public class MobileFSM {
} }
} }
} }
}
}
private static void CheckForRespawn(Mob aiAgent) { private static void CheckForRespawn(Mob aiAgent) {
//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.
@ -761,4 +749,19 @@ public class MobileFSM {
} }
} }
} }
private static void respawn(Mob aiAgent) {
if (!aiAgent.canRespawn())
return;
long spawnTime = aiAgent.getSpawnTime();
if (aiAgent.isPlayerGuard() && aiAgent.npcOwner != null && !aiAgent.npcOwner.isAlive())
return;
if (System.currentTimeMillis() > aiAgent.deathTime + spawnTime) {
aiAgent.respawn();
aiAgent.setCombatTarget(null);
}
}
} }

2
src/engine/objects/Mob.java

@ -1347,7 +1347,7 @@ public class Mob extends AbstractIntelligenceAgent {
} }
public boolean canRespawn() { public boolean canRespawn() {
return System.currentTimeMillis() > this.despawnTime + 4000; return System.currentTimeMillis() > this.deathTime;
} }
@Override @Override

Loading…
Cancel
Save