Browse Source

Cleanup rune effect application.

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

172
src/engine/gameManager/NPCManager.java

@ -28,162 +28,74 @@ 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) {
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;
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
// Only Captains have contracts
if (mob.contract != null || mob.isPlayerGuard) {
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
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. // Apply effects from RuneSet
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) if (mob.runeSetID != 0)
continue; 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) applyEffectsForRune(mob, 2518);
continue; }
//Current effect is a higher rank, dont apply. public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one. EffectsBase effectsBase;
eff.cancelJob(); RuneBase sourceRune = RuneBase.getRuneBase(runeID);
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level) for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
continue;
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); effectsBase = PowersManager.getEffectByToken(mbe.getToken());
}
}
RuneBase WarriorRune = RuneBase.getRuneBase(2518); if (effectsBase == null) {
for (MobBaseEffects mbe : WarriorRune.getEffectsList()) { 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) { if (mbe.getReqLvl() > (int) character.level)
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue; continue;
}
//check to upgrade effects if needed.
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
continue;
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. //Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank()) if (eff.getTrains() > mbe.getRank())
continue; continue;
//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