From bd48198a512d175b4639ca2d51012b9350f6c407 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 19:29:12 -0500 Subject: [PATCH] pets stats calculate properly & pet buffs no longer nerf pet --- src/engine/ai/MobileFSM.java | 11 +++++++++++ src/engine/objects/Mob.java | 3 +++ .../powers/poweractions/ApplyEffectPowerAction.java | 8 ++++++++ .../powers/poweractions/CreateMobPowerAction.java | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index d856b162..b6ff7fe7 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -660,6 +660,17 @@ public class MobileFSM { 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()); + } + } } private static void HamletGuardLogic(Mob mob) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5fc298ad..4f9be0e5 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1489,6 +1489,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..f9cbaeb7 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -158,6 +158,11 @@ public class CreateMobPowerAction extends AbstractPowerAction { if(pet.isSiege() == false) { MovementManager.translocate(pet, owner.getLoc(), owner.region); } + pet.recalculateStats(); + if(pet.isPet()){ + 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);