From bd48198a512d175b4639ca2d51012b9350f6c407 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 19:29:12 -0500 Subject: [PATCH 1/5] 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); From 1c7c0ee13e4490184772627eedef0eb43d875cb9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 19:51:00 -0500 Subject: [PATCH 2/5] 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); From c9995f3d622ba9a3c1733031c6803479f2439081 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 20:01:58 -0500 Subject: [PATCH 3/5] pets defend owner when "assist" toggled --- src/engine/ai/MobileFSM.java | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index d7aaea16..ae509afa 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) { @@ -432,17 +437,17 @@ 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()) + 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; + } } } From 4fd9a358a6f2a85493f637fd036340c440196f87 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 20:09:37 -0500 Subject: [PATCH 4/5] pets will stop chasing mobs that are no longer a threat to player --- src/engine/ai/MobileFSM.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index ae509afa..acc7d9bb 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -675,8 +675,9 @@ 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); From 3869b3b218ec537d73e497360b5ded7a74fc5175 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 18 Jul 2023 20:17:05 -0500 Subject: [PATCH 5/5] old code cleanup --- src/engine/loot/LootManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 0638569e..550e7ceb 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -224,9 +224,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) {