Browse Source

resist loading refactored as static method to NPCManager

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
7079bb6a63
  1. 53
      src/engine/gameManager/NPCManager.java
  2. 2
      src/engine/objects/AbstractCharacter.java
  3. 60
      src/engine/objects/Mob.java

53
src/engine/gameManager/NPCManager.java

@ -346,4 +346,57 @@ public enum NPCManager {
} }
} }
} }
public static void applyMobbaseEffects(Mob mob) {
EffectsBase effectsBase;
for (MobBaseEffects mbe : mob.mobBase.effectsList) {
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
if (effectsBase == 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(effectsBase.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level)
continue;
Effect eff = mob.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();
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level)
continue;
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
}
}
}
public static void applyEquipmentResists(Mob mob){
if(mob.equip != null){
for(MobEquipment equipped : mob.equip.values()){
ItemBase itemBase = equipped.getItemBase();
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush,0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash,0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce,0) + itemBase.getCrushResist());
}
}
}
}
} }

2
src/engine/objects/AbstractCharacter.java

@ -88,7 +88,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected AtomicFloat mana = new AtomicFloat(); protected AtomicFloat mana = new AtomicFloat();
protected float manaMax; // Health/Mana/Stamina protected float manaMax; // Health/Mana/Stamina
protected AtomicBoolean isAlive = new AtomicBoolean(true); protected AtomicBoolean isAlive = new AtomicBoolean(true);
protected Resists resists = new Resists("Genric"); public Resists resists = new Resists("Genric");
protected ConcurrentHashMap<String, JobContainer> timers; protected ConcurrentHashMap<String, JobContainer> timers;
protected ConcurrentHashMap<String, Long> timestamps; protected ConcurrentHashMap<String, Long> timestamps;
protected int atrHandOne; protected int atrHandOne;

60
src/engine/objects/Mob.java

@ -25,7 +25,6 @@ import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.PlaceAssetMsg;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -70,7 +69,7 @@ public class Mob extends AbstractIntelligenceAgent {
private int currentID; private int currentID;
private long lastAttackTime = 0; private long lastAttackTime = 0;
private int lastMobPowerToken = 0; private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null; public HashMap<Integer, MobEquipment> equip = null;
private DeferredPowerJob weaponPower; private DeferredPowerJob weaponPower;
private DateTime upgradeDateTime = null; private DateTime upgradeDateTime = null;
private boolean lootSync = false; private boolean lootSync = false;
@ -974,7 +973,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.setLoc(this.lastBindLoc); this.setLoc(this.lastBindLoc);
this.stopMovement(this.lastBindLoc); this.stopMovement(this.lastBindLoc);
this.applyMobbaseEffects(); NPCManager.applyMobbaseEffects(this);
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
@ -1663,8 +1662,8 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.getMobBase().enemy.size() > 0) if (this.getMobBase().enemy.size() > 0)
this.enemy.addAll(this.getMobBase().enemy); this.enemy.addAll(this.getMobBase().enemy);
} }
this.applyMobbaseEffects(); NPCManager.applyMobbaseEffects(this);
this.applyEquipmentResists(); NPCManager.applyEquipmentResists(this);
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
@ -1683,18 +1682,6 @@ public class Mob extends AbstractIntelligenceAgent {
} }
public void applyEquipmentResists(){
if(this.equip != null){
for(MobEquipment equipped : this.equip.values()){
ItemBase itemBase = equipped.getItemBase();
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
this.resists.setResist(DamageType.Crush, this.resists.getResist(DamageType.Crush,0) + itemBase.getCrushResist());
this.resists.setResist(DamageType.Slash, this.resists.getResist(DamageType.Slash,0) + itemBase.getCrushResist());
this.resists.setResist(DamageType.Pierce, this.resists.getResist(DamageType.Pierce,0) + itemBase.getCrushResist());
}
}
}
}
@Override @Override
protected ConcurrentHashMap<Integer, CharacterPower> initializePowers() { protected ConcurrentHashMap<Integer, CharacterPower> initializePowers() {
return new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); return new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
@ -1875,43 +1862,4 @@ public class Mob extends AbstractIntelligenceAgent {
lock.writeLock().unlock(); 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);
}
}
}
} }

Loading…
Cancel
Save