Browse Source

create and use applyMobbaseEffects method, remove old unused methods

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
90ff2d679e
  1. 71
      src/engine/gameManager/NPCManager.java
  2. 44
      src/engine/objects/Mob.java
  3. 2
      src/engine/objects/MobBase.java

71
src/engine/gameManager/NPCManager.java

@ -23,77 +23,6 @@ public enum NPCManager { @@ -23,77 +23,6 @@ public enum NPCManager {
NPC_MANAGER;
public static HashMap<Integer, ArrayList<Integer>> _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);

44
src/engine/objects/Mob.java

@ -25,6 +25,7 @@ import engine.net.Dispatch; @@ -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 { @@ -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 { @@ -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 { @@ -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);
}
}
}
}

2
src/engine/objects/MobBase.java

@ -27,7 +27,7 @@ public class MobBase extends AbstractGameObject { @@ -27,7 +27,7 @@ public class MobBase extends AbstractGameObject {
private final String firstName;
private final byte level;
private final float scale;
private final ArrayList<MobBaseEffects> effectsList;
public final ArrayList<MobBaseEffects> effectsList;
public int bootySet;
public Enum.MobBehaviourType fsm;
public EnumBitSet<Enum.MonsterType> notEnemy;

Loading…
Cancel
Save