From 5f6883059f14c043a3e9b67f320384d9ba82470c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 29 Mar 2023 15:42:32 -0400 Subject: [PATCH] Cleanup rune effect application. --- src/engine/gameManager/NPCManager.java | 172 ++++++------------------- src/engine/objects/Mob.java | 4 +- 2 files changed, 44 insertions(+), 132 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 5f9e4995..4c111838 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -28,162 +28,74 @@ public enum NPCManager { _bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS(); } - public static void initializeStaticEffects(Mob mob) { + public static void applyRuneSetEffects(Mob mob) { - EffectsBase eb = null; - for (MobBaseEffects mbe : mob.mobBase.getRaceEffectsList()) { + EffectsBase effectsBase; - eb = PowersManager.getEffectByToken(mbe.getToken()); - - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) mob.level) - continue; - - Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); - - if (eff == null) - continue; - - if (eff.getTrains() > mbe.getRank()) - continue; - - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - if (mbe.getReqLvl() > (int) mob.level) - continue; + //Apply all rune effects. - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } + if (NPCManager._runeSetMap.get(mob.runeSetID).contains(252623)) { + mob.isPlayerGuard = true; + mob.setNoAggro(true); } - //Apply all rune effects. - // Only Captains have contracts - if (mob.contract != null || mob.isPlayerGuard) { - RuneBase guardRune = RuneBase.getRuneBase(252621); - for (MobBaseEffects mbe : guardRune.getEffectsList()) { + // Only captains have contracts - eb = PowersManager.getEffectByToken(mbe.getToken()); + if (mob.contract != null || mob.isPlayerGuard) + applyEffectsForRune(mob, 252621); - if (eb == null) { - Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken()); - continue; - } - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { + // Apply effects from RuneSet - if (mbe.getReqLvl() > (int) mob.level) - continue; + if (mob.runeSetID != 0) + for (int runeID : _runeSetMap.get(mob.runeSetID)) + applyEffectsForRune(mob, runeID); - Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); + // Not sure why but apply Warrior effects for some reason? - if (eff == null) - continue; + applyEffectsForRune(mob, 2518); + } - //Current effect is a higher rank, dont apply. - if (eff.getTrains() > mbe.getRank()) - continue; + public static void applyEffectsForRune(AbstractCharacter character, int runeID) { - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { + EffectsBase effectsBase; + RuneBase sourceRune = RuneBase.getRuneBase(runeID); - if (mbe.getReqLvl() > (int) mob.level) - continue; + for (MobBaseEffects mbe : sourceRune.getEffectsList()) { - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } + effectsBase = PowersManager.getEffectByToken(mbe.getToken()); - RuneBase WarriorRune = RuneBase.getRuneBase(2518); - for (MobBaseEffects mbe : WarriorRune.getEffectsList()) { + if (effectsBase == null) { + Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken()); + continue; + } - eb = PowersManager.getEffectByToken(mbe.getToken()); + //check to upgrade effects if needed. + if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) { - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); + if (mbe.getReqLvl() > (int) character.level) continue; - } - - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) mob.level) - continue; + Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID())); - Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); - - if (eff == null) - continue; + if (eff == null) + continue; - //Current effect is a higher rank, dont apply. - if (eff.getTrains() > mbe.getRank()) - 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(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { + //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) mob.level) - continue; + if (mbe.getReqLvl() > (int) character.level) + continue; - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } + character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); } - } - - // Apply effects from RuneSet - if (mob.runeSetID != 0) - for (int runeID : _runeSetMap.get(mob.runeSetID)) { - - RuneBase rune = RuneBase.getRuneBase(runeID); - - if (rune != null) - for (MobBaseEffects mbe : rune.getEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) mob.level) - continue; - - Effect eff = mob.effects.get(Integer.toString(eb.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(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - - } else { - - if (mbe.getReqLvl() > (int) mob.level) - continue; - - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - } } + } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 04548396..08e11072 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1404,7 +1404,7 @@ public class Mob extends AbstractIntelligenceAgent { this.bindLoc = this.lastBindLoc; this.setLoc(this.lastBindLoc); this.stopMovement(this.lastBindLoc); - NPCManager.initializeStaticEffects(this); + NPCManager.applyRuneSetEffects(this); this.recalculateStats(); this.setHealth(this.healthMax); @@ -2105,7 +2105,7 @@ public class Mob extends AbstractIntelligenceAgent { } try { - NPCManager.initializeStaticEffects(this); + NPCManager.applyRuneSetEffects(this); try { this.initializeSkills();