From 90ff2d679e407156ce81b442d67a7bffae113b02 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 1 Sep 2023 20:39:31 -0500 Subject: [PATCH] create and use applyMobbaseEffects method, remove old unused methods --- src/engine/gameManager/NPCManager.java | 71 -------------------------- src/engine/objects/Mob.java | 44 ++++++++++++++-- src/engine/objects/MobBase.java | 2 +- 3 files changed, 42 insertions(+), 75 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 420ccf7f..e38b8a69 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -23,77 +23,6 @@ public enum NPCManager { NPC_MANAGER; public static HashMap> _runeSetMap = new HashMap<>(); - public static void applyRuneSetEffects(Mob mob) { - - // Early exit - - if (mob.runeSet == 0) - return; - - // Only captains have contracts - - if (mob.contract != null || mob.isPlayerGuard()) - applyEffectsForRune(mob, 252621); - - // Apply effects from RuneSet - - if (mob.runeSet != 0) - for (int runeID : _runeSetMap.get(mob.runeSet)) - applyEffectsForRune(mob, runeID); - - // Not sure why but apply Warrior effects for some reason? - - applyEffectsForRune(mob, 2518); - } - - public static void applyEffectsForRune(AbstractCharacter character, int runeID) { - - EffectsBase effectsBase; - RuneBase sourceRune = RuneBase.getRuneBase(runeID); - - // Race runes are in the runeset but not in runebase for some reason - - if (sourceRune == null) - return; - - for (MobBaseEffects mbe : sourceRune.getEffectsList()) { - - effectsBase = PowersManager.getEffectByToken(mbe.getToken()); - - if (effectsBase == null) { - Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) { - - if (mbe.getReqLvl() > (int) character.level) - continue; - - Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID())); - - if (eff == null) - continue; - - //Current effect is a higher rank, dont apply. - if (eff.getTrains() > mbe.getRank()) - continue; - - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); - } else { - - if (mbe.getReqLvl() > (int) character.level) - continue; - - character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); - } - - } - } - public static void dismissNecroPet(Mob necroPet, boolean updateOwner) { necroPet.setCombatTarget(null); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 10c1b76d..be9c11eb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -25,6 +25,7 @@ import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; +import engine.powers.EffectsBase; import engine.server.MBServerStatics; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -974,7 +975,7 @@ public class Mob extends AbstractIntelligenceAgent { this.setLoc(this.lastBindLoc); this.stopMovement(this.lastBindLoc); - NPCManager.applyRuneSetEffects(this); + this.applyMobbaseEffects(); this.recalculateStats(); this.setHealth(this.healthMax); @@ -1663,8 +1664,7 @@ public class Mob extends AbstractIntelligenceAgent { if (this.getMobBase().enemy.size() > 0) this.enemy.addAll(this.getMobBase().enemy); } - - NPCManager.applyRuneSetEffects(this); + this.applyMobbaseEffects(); recalculateStats(); this.setHealth(this.healthMax); @@ -1870,5 +1870,43 @@ public class Mob extends AbstractIntelligenceAgent { lock.writeLock().unlock(); } } + public void applyMobbaseEffects(){ + EffectsBase effectsBase; + for (MobBaseEffects mbe : this.mobBase.effectsList) { + + effectsBase = PowersManager.getEffectByToken(mbe.getToken()); + + if (effectsBase == null) { + Logger.info("Mob: " + this.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken()); + continue; + } + + //check to upgrade effects if needed. + if (this.effects.containsKey(Integer.toString(effectsBase.getUUID()))) { + + if (mbe.getReqLvl() > (int) this.level) + continue; + + Effect eff = this.effects.get(Integer.toString(effectsBase.getUUID())); + + if (eff == null) + continue; + //Current effect is a higher rank, dont apply. + if (eff.getTrains() > mbe.getRank()) + continue; + + //new effect is of a higher rank. remove old effect and apply new one. + eff.cancelJob(); + this.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); + } else { + + if (mbe.getReqLvl() > (int) this.level) + continue; + + this.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); + } + + } + } } diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index b10399d6..66a58b7a 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -27,7 +27,7 @@ public class MobBase extends AbstractGameObject { private final String firstName; private final byte level; private final float scale; - private final ArrayList effectsList; + public final ArrayList effectsList; public int bootySet; public Enum.MobBehaviourType fsm; public EnumBitSet notEnemy;