From e78aea573509df7ad36cf970c6d2687ab66cd1b3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 23:52:40 -0500 Subject: [PATCH] Assign patrol points added as static method to NPC manager --- src/engine/gameManager/NPCManager.java | 21 +++++++++++++++++++++ src/engine/objects/Mob.java | 20 +------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 79468b9a..07553a4d 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -403,4 +403,25 @@ public enum NPCManager { return maxSlots; } + public static void AssignPatrolPoints(Mob mob) { + mob.patrolPoints = new ArrayList<>(); + + for (int i = 0; i < 5; ++i) { + float patrolRadius = mob.getSpawnRadius(); + + if (patrolRadius > 256) + patrolRadius = 256; + + if (patrolRadius < 60) + patrolRadius = 60; + + Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius); + mob.patrolPoints.add(newPatrolPoint); + + if (i == 1) { + mob.loc = newPatrolPoint; + mob.endLoc = newPatrolPoint; + } + } + } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1d275bd1..a94db668 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1737,25 +1737,7 @@ public class Mob extends AbstractIntelligenceAgent { if (this.guardCaptain == null && this.isPlayerGuard == false && !isPet() == false && isNecroPet() == false) { - this.patrolPoints = new ArrayList<>(); - - for (int i = 0; i < 5; ++i) { - float patrolRadius = this.getSpawnRadius(); - - if (patrolRadius > 256) - patrolRadius = 256; - - if (patrolRadius < 60) - patrolRadius = 60; - - Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(this.getBindLoc(), patrolRadius); - this.patrolPoints.add(newPatrolPoint); - - if (i == 1) { - this.loc = newPatrolPoint; - this.endLoc = newPatrolPoint; - } - } + NPCManager.AssignPatrolPoints(this); } this.deathTime = 0;