diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 26cf8cbb..cc1e6fd8 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -105,6 +105,11 @@ public class MobileFSM { mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } } + if(target.getPet() != null){ + if(target.getPet().getCombatTarget() == null && target.getPet().assist() == true){ + target.getPet().setCombatTarget(mob); + } + } } public static void AttackBuilding(Mob mob, Building target) { @@ -172,6 +177,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; + } } } @@ -432,6 +440,18 @@ public class MobileFSM { return; } } + if(aiAgent.combatTarget == null) { + //look for pets to aggro if no players found 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; + aiAgent.setCombatTarget(aggroMob); + return; + } + } } private static void CheckMobMovement(Mob mob) { @@ -658,11 +678,26 @@ public class MobileFSM { mob.killCharacter("no owner"); } } - if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive()) - mob.setCombatTarget(null); + if (mob.getCombatTarget() != null) + if(!mob.getCombatTarget().isAlive() || mob.getCombatTarget().getLoc().distanceSquared(mob.getOwner().getLoc()) > 75) + mob.setCombatTarget(null); if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) CheckMobMovement(mob); CheckForAttack(mob); + //recover health + if(mob.getTimestamps().containsKey("HEALTHRECOVERED") == false){ + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + } + if(mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000){ + if(mob.getHealth() < mob.getHealthMax()) { + 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()); + } + } + } } private static void HamletGuardLogic(Mob mob) { diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 55944f87..89e75d95 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -225,9 +225,6 @@ public class LootManager { } int min = (int)(mobLevel * 2.5f); int roll = ThreadLocalRandom.current().nextInt(max-min) + min; - if(roll >= 191){ - int poo = 0; - } return roll; } public static void AddGenTableRow(int tableID, GenTableRow row) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d9941202..0f94021d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1490,6 +1490,9 @@ public class Mob extends AbstractIntelligenceAgent { float s; h = this.mobBase.getHealthMax(); + if(this.isPet()){ + h = this.level * 0.5f * 120; + } m = this.statSpiCurrent; s = this.statConCurrent; diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index b7454a5f..44a10751 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -18,6 +18,7 @@ package engine.powers.poweractions; +import com.sun.prism.impl.ps.BaseShaderContext; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; @@ -140,10 +141,17 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { ((Mob) awo).setCombatTarget(source); ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); DispatchMessage.sendToAllInRange(source, msg); + ((Mob)awo).refresh(); + } + } + if (awo != null && awo.getObjectType() == GameObjectType.Mob) { + if(((Mob)awo).isPet()) { + ((Mob) awo).recalculateStats(); } } this.effect.startEffect(source, awo, trains, eff); } + } protected void _applyEffectForItem(Item item, int trains) { diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index c13bcd5a..82150a97 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -158,6 +158,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { if(pet.isSiege() == false) { MovementManager.translocate(pet, owner.getLoc(), owner.region); } + pet.recalculateStats(); + pet.healthMax = pet.level * 0.5f * 120; + pet.setHealth(pet.healthMax); PetMsg pm = new PetMsg(5, pet); Dispatch dispatch = Dispatch.borrow(owner, pm); DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);