add random 10-15 delay between patrolling for mobs

This commit is contained in:
2023-04-16 13:23:42 -05:00
parent ef74d1ae8c
commit db0e9d1847
2 changed files with 14 additions and 9 deletions
+9 -6
View File
@@ -381,8 +381,9 @@ public class MobileFSM {
mob.stopPatrolTime = System.currentTimeMillis();
return;
}
//wait 10 seconds after reaching patrol point before moving again
if(mob.stopPatrolTime + 10000 > System.currentTimeMillis()){
//wait between 10 and 15 seconds after reaching patrol point before moving
int patrolDelay = ThreadLocalRandom.current().nextInt(10000) + 5000;
if(mob.stopPatrolTime + patrolDelay > System.currentTimeMillis()){
//early exit while waiting to patrol again
return;
}
@@ -402,7 +403,7 @@ public class MobileFSM {
}
if (MovementUtilities.canMove(mob)) {
//get the next index of the patrol point from the patrolPoints list
if (mob.lastPatrolPointIndex > mob.patrolPoints.size()) {
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) {
mob.lastPatrolPointIndex = 0;
}
MovementUtilities.aiMove(mob, mob.patrolPoints.get(mob.lastPatrolPointIndex), true);
@@ -607,12 +608,14 @@ public class MobileFSM {
return;
}
if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) {
if (mob.BehaviourType != null && mob.BehaviourType == MobBehaviourType.None) {
return;
}
//if (mob.BehaviourType != null && mob.BehaviourType == MobBehaviourType.None) {
// return;
//}
//TEST CODE FOR BEHAVIOUR CHANGING START
if(mob.BehaviourType == null || mob.BehaviourType.ordinal() == MobBehaviourType.None.ordinal()){
mob.BehaviourType = MobBehaviourType.Simple;
}
//TEST CODE FOR BEHAVIOUR CHANGING END
if (mob.isAlive() == false) {
//no need to continue if mob is dead, check for respawn and move on
CheckForRespawn(mob);