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. 6
      src/engine/objects/Mob.java

15
src/engine/ai/MobileFSM.java

@ -381,8 +381,9 @@ public class MobileFSM {
mob.stopPatrolTime = System.currentTimeMillis(); mob.stopPatrolTime = System.currentTimeMillis();
return; return;
} }
//wait 10 seconds after reaching patrol point before moving again //wait between 10 and 15 seconds after reaching patrol point before moving
if(mob.stopPatrolTime + 10000 > System.currentTimeMillis()){ int patrolDelay = ThreadLocalRandom.current().nextInt(10000) + 5000;
if(mob.stopPatrolTime + patrolDelay > System.currentTimeMillis()){
//early exit while waiting to patrol again //early exit while waiting to patrol again
return; return;
} }
@ -402,7 +403,7 @@ public class MobileFSM {
} }
if (MovementUtilities.canMove(mob)) { if (MovementUtilities.canMove(mob)) {
//get the next index of the patrol point from the patrolPoints list //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; mob.lastPatrolPointIndex = 0;
} }
MovementUtilities.aiMove(mob, mob.patrolPoints.get(mob.lastPatrolPointIndex), true); MovementUtilities.aiMove(mob, mob.patrolPoints.get(mob.lastPatrolPointIndex), true);
@ -607,12 +608,14 @@ public class MobileFSM {
return; return;
} }
if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) { if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) {
if (mob.BehaviourType != null && mob.BehaviourType == MobBehaviourType.None) { //if (mob.BehaviourType != null && mob.BehaviourType == MobBehaviourType.None) {
return; // return;
} //}
//TEST CODE FOR BEHAVIOUR CHANGING START
if(mob.BehaviourType == null || mob.BehaviourType.ordinal() == MobBehaviourType.None.ordinal()){ if(mob.BehaviourType == null || mob.BehaviourType.ordinal() == MobBehaviourType.None.ordinal()){
mob.BehaviourType = MobBehaviourType.Simple; mob.BehaviourType = MobBehaviourType.Simple;
} }
//TEST CODE FOR BEHAVIOUR CHANGING END
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);

6
src/engine/objects/Mob.java

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

Loading…
Cancel
Save