From 1c7c0ee13e4490184772627eedef0eb43d875cb9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 19:51:00 -0500 Subject: [PATCH] mobs aggro to pets --- src/engine/ai/MobileFSM.java | 18 ++++++++++++++++++ .../poweractions/CreateMobPowerAction.java | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index b6ff7fe7..d7aaea16 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -172,6 +172,9 @@ public class MobileFSM { attackDelay = 11000; CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); + if(target.combatTarget == null){ + target.combatTarget = mob; + } } } @@ -429,6 +432,18 @@ public class MobileFSM { return; } } + //look for pets to aggro;;; + HashSet awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobileFSMManager.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET); + for (AbstractWorldObject awoMob : awoList) { + //dont scan self. + if (aiAgent.equals(awoMob)) + continue; + Mob aggroMob = (Mob) awoMob; + //dont attack other guards + if (aggroMob.isPet()) + aiAgent.setCombatTarget(aggroMob); + return; + } } private static void CheckMobMovement(Mob mob) { @@ -669,6 +684,9 @@ public class MobileFSM { float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None))* 0.01f); mob.setHealth(mob.getHealth() + recoveredHealth); mob.getTimestamps().put("HEALTHRECOVERED",System.currentTimeMillis()); + if(mob.getHealth() > mob.getHealthMax()){ + mob.setHealth(mob.getHealthMax()); + } } } } diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index f9cbaeb7..82150a97 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -159,9 +159,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { MovementManager.translocate(pet, owner.getLoc(), owner.region); } pet.recalculateStats(); - if(pet.isPet()){ - pet.healthMax = pet.level * 0.5f * 120; - } + pet.healthMax = pet.level * 0.5f * 120; pet.setHealth(pet.healthMax); PetMsg pm = new PetMsg(5, pet); Dispatch dispatch = Dispatch.borrow(owner, pm);