Browse Source

implement new patrol system

master
FatBoy-DOTC 2 years ago
parent
commit
0779fbab87
  1. 36
      src/engine/ai/MobileFSM.java
  2. 1
      src/engine/objects/Mob.java

36
src/engine/ai/MobileFSM.java

@ -394,7 +394,7 @@ public class MobileFSM {
DispatchMessage.sendToAllInRange(mob, rwss); DispatchMessage.sendToAllInRange(mob, rwss);
} }
//guard captains inherit barracks patrol points dynamically //guard captains inherit barracks patrol points dynamically
if(mob.isPlayerGuard() && mob.getContract() != null){ if (mob.contract != null && NPC.ISGuardCaptain(mob.contract.getContractID())) {
Building barracks = mob.building; Building barracks = mob.building;
if(barracks != null && barracks.patrolPoints != null && barracks.getPatrolPoints().isEmpty() == false) { if(barracks != null && barracks.patrolPoints != null && barracks.getPatrolPoints().isEmpty() == false) {
mob.patrolPoints = barracks.patrolPoints; mob.patrolPoints = barracks.patrolPoints;
@ -679,39 +679,7 @@ public class MobileFSM {
private static void CheckMobMovement(Mob mob) { private static void CheckMobMovement(Mob mob) {
mob.updateLocation(); mob.updateLocation();
if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) { if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) {
if (mob.getCombatTarget() == null) { patrol(mob);
//patrol
int patrolRandom = ThreadLocalRandom.current().nextInt(1000);
if (patrolRandom <= MBServerStatics.AI_PATROL_DIVISOR) {
if (MovementUtilities.canMove(mob) && !mob.isMoving()) {
if (mob.isPlayerGuard()) {
guardPatrol(mob);
return;
}
float patrolRadius = mob.getSpawnRadius();
if (patrolRadius > 256)
patrolRadius = 256;
if (patrolRadius < 60)
patrolRadius = 60;
MovementUtilities.aiMove(mob, Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius), true);
}
}
} else {
//chase target
mob.updateMovementState();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else {
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
}
}
}
} else{ } else{
//pet logic //pet logic
if(mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID()) == false){ if(mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID()) == false){

1
src/engine/objects/Mob.java

@ -250,6 +250,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.spawnTime = 60 * 15; this.spawnTime = 60 * 15;
this.isPlayerGuard = true; this.isPlayerGuard = true;
this.nameOverride = contract.getName(); this.nameOverride = contract.getName();
this.BehaviourType = MobileFSM.MobBehaviourType.GuardCaptain;
} }
int guildID = rs.getInt("mob_guildUID"); int guildID = rs.getInt("mob_guildUID");

Loading…
Cancel
Save