Browse Source

add random 10-15 delay between patrolling for mobs

master
FatBoy-DOTC 2 years ago
parent
commit
db0e9d1847
  1. 15
      src/engine/ai/MobileFSM.java
  2. 8
      src/engine/objects/Mob.java

15
src/engine/ai/MobileFSM.java

@ -381,8 +381,9 @@ public class MobileFSM { @@ -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 { @@ -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 { @@ -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);

8
src/engine/objects/Mob.java

@ -299,9 +299,11 @@ public class Mob extends AbstractIntelligenceAgent { @@ -299,9 +299,11 @@ public class Mob extends AbstractIntelligenceAgent {
this.equipmentSetID = this.contract.getEquipmentSet();
this.nameOverride = rs.getString("mob_name");
if(rs.getString("fsm").length() > 1) {
this.BehaviourType = MobileFSM.MobBehaviourType.valueOf(rs.getString("fsm"));
} else{
try {
if (rs.getString("fsm").length() > 1) {
this.BehaviourType = MobileFSM.MobBehaviourType.valueOf(rs.getString("fsm"));
}
}catch(Exception ex) {
this.BehaviourType = MobileFSM.MobBehaviourType.None;
}
} catch (Exception e) {

Loading…
Cancel
Save