From aec0115d9b86820fee38337f97bb75d1da561e8d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 3 May 2023 19:43:58 -0500 Subject: [PATCH] Added random city grid patrol point for guards with no barracks patrol points assigned --- src/engine/ai/MobileFSM.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index caae9949..038aa69f 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -193,10 +193,12 @@ 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() - 1) { + if(mob.patrolPoints.isEmpty()) { + mob.destination = randomGuardPatrolPoint(mob); + } else if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) { mob.lastPatrolPointIndex = 0; + mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); } - mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); MovementUtilities.aiMove(mob, mob.destination, true); mob.lastPatrolPointIndex += 1; if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { @@ -617,4 +619,10 @@ public class MobileFSM { return !mob.getGuild().getAllyList().contains(target.getGuild()) || !mob.getGuild().getAllyList().contains(target.getGuild().getNation()); return false; } + public static Vector3fImmutable randomGuardPatrolPoint(Mob mob){ + float xPoint = ThreadLocalRandom.current().nextInt(1200) - 600; + float zPoint = ThreadLocalRandom.current().nextInt(1200) - 600; + Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc(); + return new Vector3fImmutable(TreePos.x + xPoint,TreePos.y,TreePos.z + zPoint); + } } \ No newline at end of file