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 { @@ -28,99 +28,55 @@ 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());
//Apply all rune effects.
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
if (NPCManager._runeSetMap.get(mob.runeSetID).contains(252623)) {
mob.isPlayerGuard = true;
mob.setNoAggro(true);
}
//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()));
// Only captains have contracts
if (eff == null)
continue;
if (eff.getTrains() > mbe.getRank())
continue;
if (mob.contract != null || mob.isPlayerGuard)
applyEffectsForRune(mob, 252621);
//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.
// Only Captains have contracts
if (mob.contract != null || mob.isPlayerGuard) {
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
if (mob.runeSetID != 0)
for (int runeID : _runeSetMap.get(mob.runeSetID))
applyEffectsForRune(mob, runeID);
eb = PowersManager.getEffectByToken(mbe.getToken());
// Not sure why but apply Warrior effects for some reason?
if (eb == null) {
Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
continue;
applyEffectsForRune(mob, 2518);
}
//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;
public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
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 : WarriorRune.getEffectsList()) {
for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
if (effectsBase == null) {
Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
continue;
}
//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;
Effect eff = mob.effects.get(Integer.toString(eb.getUUID()));
Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
if (eff == null)
continue;
@ -131,59 +87,15 @@ public enum NPCManager { @@ -131,59 +87,15 @@ public enum NPCManager {
//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);
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level)
if (mbe.getReqLvl() > (int) character.level)
continue;
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, 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;
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
}
//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 { @@ -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 { @@ -2105,7 +2105,7 @@ public class Mob extends AbstractIntelligenceAgent {
}
try {
NPCManager.initializeStaticEffects(this);
NPCManager.applyRuneSetEffects(this);
try {
this.initializeSkills();

Loading…
Cancel
Save