From db0e9d1847dfe381ec3c93c3f6698f0d1dd84636 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 16 Apr 2023 13:23:42 -0500 Subject: [PATCH] add random 10-15 delay between patrolling for mobs --- src/engine/ai/MobileFSM.java | 15 +++++++++------ src/engine/objects/Mob.java | 8 +++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 5e696380..c44d4f03 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -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); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 0466edbc..c4281107 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -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) {