Browse Source

Cleanup rune effect application.

master
MagicBot 2 years ago
parent
commit
5f6883059f
  1. 144
      src/engine/gameManager/NPCManager.java
  2. 4
      src/engine/objects/Mob.java

144
src/engine/gameManager/NPCManager.java

@ -28,99 +28,55 @@ public enum NPCManager {
_bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS(); _bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS();
} }
public static void initializeStaticEffects(Mob mob) { public static void applyRuneSetEffects(Mob mob) {
EffectsBase eb = null; EffectsBase effectsBase;
for (MobBaseEffects mbe : mob.mobBase.getRaceEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken()); //Apply all rune effects.
if (eb == null) { if (NPCManager._runeSetMap.get(mob.runeSetID).contains(252623)) {
Logger.info("EffectsBase Null for Token " + mbe.getToken()); mob.isPlayerGuard = true;
continue; mob.setNoAggro(true);
} }
//check to upgrade effects if needed. // Only captains have contracts
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) if (mob.contract != null || mob.isPlayerGuard)
continue; applyEffectsForRune(mob, 252621);
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); // Apply effects from RuneSet
}
}
//Apply all rune effects. if (mob.runeSetID != 0)
// Only Captains have contracts for (int runeID : _runeSetMap.get(mob.runeSetID))
if (mob.contract != null || mob.isPlayerGuard) { applyEffectsForRune(mob, runeID);
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken()); // Not sure why but apply Warrior effects for some reason?
if (eb == null) { applyEffectsForRune(mob, 2518);
Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
continue;
} }
//check to upgrade effects if needed. public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
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); EffectsBase effectsBase;
} RuneBase sourceRune = RuneBase.getRuneBase(runeID);
}
RuneBase WarriorRune = RuneBase.getRuneBase(2518); for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
for (MobBaseEffects mbe : WarriorRune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken()); effectsBase = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) { if (effectsBase == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken()); Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
continue; continue;
} }
//check to upgrade effects if needed. //check to upgrade effects if needed.
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) if (mbe.getReqLvl() > (int) character.level)
continue; continue;
Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
if (eff == null) if (eff == null)
continue; continue;
@ -131,59 +87,15 @@ public enum NPCManager {
//new effect is of a higher rank. remove old effect and apply new one. //new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob(); eff.cancelJob();
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
} else { } else {
if (mbe.getReqLvl() > (int) mob.level) if (mbe.getReqLvl() > (int) character.level)
continue; 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);
}
}
} }
} }
} }

4
src/engine/objects/Mob.java

@ -1404,7 +1404,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.bindLoc = this.lastBindLoc; this.bindLoc = this.lastBindLoc;
this.setLoc(this.lastBindLoc); this.setLoc(this.lastBindLoc);
this.stopMovement(this.lastBindLoc); this.stopMovement(this.lastBindLoc);
NPCManager.initializeStaticEffects(this); NPCManager.applyRuneSetEffects(this);
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
@ -2105,7 +2105,7 @@ public class Mob extends AbstractIntelligenceAgent {
} }
try { try {
NPCManager.initializeStaticEffects(this); NPCManager.applyRuneSetEffects(this);
try { try {
this.initializeSkills(); this.initializeSkills();

Loading…
Cancel
Save