From 9c623f277bd5984692cda3096d6f9edf3ac95140 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 3 Mar 2025 21:21:36 -0600 Subject: [PATCH] simplified mob aI --- .../mobileAI/Behaviours/StandardMob.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/engine/mobileAI/Behaviours/StandardMob.java b/src/engine/mobileAI/Behaviours/StandardMob.java index ff71b55f..8426cf99 100644 --- a/src/engine/mobileAI/Behaviours/StandardMob.java +++ b/src/engine/mobileAI/Behaviours/StandardMob.java @@ -16,16 +16,17 @@ import java.util.HashSet; public class StandardMob { public static void run(Mob mob){ - if(!mob.isAlive()){ - CheckForRespawn(mob); - return; - } HashSet inRange = WorldGrid.getObjectsInRangePartial(mob.loc, MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER); if(inRange.isEmpty()) return; + if(!mob.isAlive()){ + CheckForRespawn(mob); + return; + } + if (mob.isMoving()) { mob.setLoc(mob.getMovementLoc()); mob.updateLocation(); @@ -78,7 +79,6 @@ public class StandardMob { } if (!mob.despawned) { - if (mob.getCharItemManager().getInventoryCount() > 0) { if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { mob.despawn(); @@ -193,9 +193,18 @@ public class StandardMob { if(mob.combatTarget != null){ //chase player if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange())) { + if(mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + PlayerCharacter target = (PlayerCharacter)mob.combatTarget; + if(target.isMoving()){ + MovementUtilities.aiMove(mob, mob.combatTarget.loc, false); + return; + }else{ + Vector3fImmutable smoothLoc = Vector3fImmutable.getRandomPointOnCircle(mob.combatTarget.loc,mob.getRange() -1); + MovementUtilities.aiMove(mob, smoothLoc, false); + return; + } + } MovementUtilities.aiMove(mob, mob.combatTarget.loc, false); - }else{ - mob.stopMovement(mob.getMovementLoc()); } }else{ @@ -228,8 +237,6 @@ public class StandardMob { if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange())) return; - mob.updateLocation(); - //InterestManager.forceLoad(mob); InterestManager.setObjectDirty(mob); if (mainHand == null && offHand == null) {