Mobs have runes loaded at bootstrap and effects applied. Moved logic to NPCManager.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.objects.BootySetEntry;
|
||||
import engine.objects.EquipmentSetEntry;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -26,4 +27,163 @@ public enum NPCManager {
|
||||
public static void LoadAllBootySets() {
|
||||
_bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS();
|
||||
}
|
||||
|
||||
public static void initializeStaticEffects(Mob mob) {
|
||||
|
||||
EffectsBase eb = null;
|
||||
for (MobBaseEffects mbe : mob.mobBase.getRaceEffectsList()) {
|
||||
|
||||
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;
|
||||
|
||||
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 all rune effects.
|
||||
// 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 (eb == 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(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);
|
||||
}
|
||||
}
|
||||
|
||||
RuneBase WarriorRune = RuneBase.getRuneBase(2518);
|
||||
for (MobBaseEffects mbe : WarriorRune.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
protected short statIntCurrent;
|
||||
protected short statSpiCurrent;
|
||||
protected short unusedStatPoints;
|
||||
protected short level;
|
||||
public short level;
|
||||
protected int exp;
|
||||
protected Vector3fImmutable bindLoc;
|
||||
protected Vector3fImmutable faceDir;
|
||||
@@ -496,26 +496,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
return this.statSpiCurrent;
|
||||
}
|
||||
|
||||
public final void setStatStrCurrent(final short value) {
|
||||
this.statStrCurrent = (value < 1) ? (short) 1 : value;
|
||||
}
|
||||
|
||||
public final void setStatDexCurrent(final short value) {
|
||||
this.statDexCurrent = (value < 1) ? (short) 1 : value;
|
||||
}
|
||||
|
||||
public final void setStatConCurrent(final short value) {
|
||||
this.statConCurrent = (value < 1) ? (short) 1 : value;
|
||||
}
|
||||
|
||||
public final void setStatIntCurrent(final short value) {
|
||||
this.statIntCurrent = (value < 1) ? (short) 1 : value;
|
||||
}
|
||||
|
||||
public final void setStatSpiCurrent(final short value) {
|
||||
this.statSpiCurrent = (value < 1) ? (short) 1 : value;
|
||||
}
|
||||
|
||||
public short getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
@@ -1917,16 +1897,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.itemCasting = itemCasting;
|
||||
}
|
||||
|
||||
public static void MoveInsideBuilding(PlayerCharacter source, AbstractCharacter ac){
|
||||
MoveToPointMsg moveMsg = new MoveToPointMsg();
|
||||
moveMsg.setPlayer(ac);
|
||||
moveMsg.setTarget(ac, BuildingManager.getBuildingFromCache(ac.inBuildingID));
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(source, moveMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
}
|
||||
|
||||
//updates
|
||||
public void update(){
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
protected AtomicFloat health = new AtomicFloat();
|
||||
public float healthMax;
|
||||
protected boolean load = true;
|
||||
protected ConcurrentHashMap<String, Effect> effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public ConcurrentHashMap<String, Effect> effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private int objectTypeMask = 0;
|
||||
private Bounds bounds;
|
||||
|
||||
|
||||
+7
-243
@@ -34,7 +34,6 @@ import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.world.WorldServer;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -69,7 +68,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
protected int dbID; //the database ID
|
||||
protected int loadID;
|
||||
protected boolean isMob;
|
||||
protected MobBase mobBase;
|
||||
public MobBase mobBase;
|
||||
protected float spawnRadius;
|
||||
protected int spawnTime;
|
||||
//used by static mobs
|
||||
@@ -79,14 +78,14 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
protected float statLon;
|
||||
protected float statAlt;
|
||||
protected Building building;
|
||||
protected Contract contract;
|
||||
public Contract contract;
|
||||
private int currentID;
|
||||
private int ownerUID = 0; //only used by pets
|
||||
private boolean hasLoot = false;
|
||||
private AbstractWorldObject fearedObject = null;
|
||||
private int buildingID;
|
||||
private boolean isSiege = false;
|
||||
private boolean isPlayerGuard = false;
|
||||
public boolean isPlayerGuard = false;
|
||||
private long timeToSpawnSiege;
|
||||
private AbstractCharacter npcOwner;
|
||||
private Vector3fImmutable inBuildingLoc = null;
|
||||
@@ -112,7 +111,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
public int bootySetID = 0;
|
||||
private int lootSet = 0;
|
||||
private boolean isGuard;
|
||||
private ArrayList<Integer> fidelityRunes = null;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
@@ -311,21 +309,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (this.fidalityID != 0)
|
||||
this.nameOverride = rs.getString("mob_name");
|
||||
|
||||
if (this.fidalityID != 0) {
|
||||
|
||||
Zone parentZone = ZoneManager.getZoneByUUID(this.parentZoneID);
|
||||
if (parentZone != null) {
|
||||
this.fidelityRunes = WorldServer.ZoneFidelityMobRunes.get(parentZone.getLoadNum()).get(this.fidalityID);
|
||||
|
||||
if (this.fidelityRunes != null)
|
||||
for (Integer runeID : this.fidelityRunes) {
|
||||
if (runeID == 252623) {
|
||||
this.isGuard = true;
|
||||
this.noAggro = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(currentID + "");
|
||||
}
|
||||
@@ -600,8 +583,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
|
||||
int level = mob.getLevel();
|
||||
level = (level < 0) ? 0 : level;
|
||||
level = (level > 50) ? 50 : level;
|
||||
level = Math.max(level, 0);
|
||||
level = Math.min(level, 50);
|
||||
|
||||
double minGold;
|
||||
double maxGold;
|
||||
@@ -726,30 +709,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
return skill.getModifiedAmount();
|
||||
}
|
||||
|
||||
public static int getBuildingSlot(Mob mob) {
|
||||
int slot = -1;
|
||||
|
||||
if (mob.building == null)
|
||||
return -1;
|
||||
|
||||
|
||||
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(mob.building.getMeshUUID());
|
||||
|
||||
if (buildingModel == null)
|
||||
return -1;
|
||||
|
||||
|
||||
if (mob.building.getHirelings().containsKey(mob))
|
||||
slot = (mob.building.getHirelings().get(mob));
|
||||
|
||||
|
||||
if (buildingModel.getNPCLocation(slot) == null)
|
||||
return -1;
|
||||
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) {
|
||||
|
||||
HashSet<AbstractWorldObject> mobsInRange = WorldGrid.getObjectsInRangePartial(source, MBServerStatics.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB);
|
||||
@@ -984,199 +943,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeStaticEffects() {
|
||||
|
||||
EffectsBase eb = null;
|
||||
for (MobBaseEffects mbe : this.mobBase.getRaceEffectsList()) {
|
||||
|
||||
eb = PowersManager.getEffectByToken(mbe.getToken());
|
||||
|
||||
if (eb == null) {
|
||||
Logger.info("EffectsBase Null for Token " + mbe.getToken());
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to upgrade effects if needed.
|
||||
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
Effect eff = this.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();
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
} else {
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//Apply all rune effects.
|
||||
// Only Captains have contracts
|
||||
if (contract != null || this.isPlayerGuard) {
|
||||
RuneBase guardRune = RuneBase.getRuneBase(252621);
|
||||
for (MobBaseEffects mbe : guardRune.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 (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
Effect eff = this.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();
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
}
|
||||
}
|
||||
|
||||
RuneBase WarriorRune = RuneBase.getRuneBase(2518);
|
||||
for (MobBaseEffects mbe : WarriorRune.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 (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
Effect eff = this.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();
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.fidelityRunes != null) {
|
||||
|
||||
for (int fidelityRune : this.fidelityRunes) {
|
||||
|
||||
RuneBase rune = RuneBase.getRuneBase(fidelityRune);
|
||||
|
||||
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 (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
Effect eff = this.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();
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
for (RuneBase rune : this.mobBase.getRunes()) {
|
||||
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 (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
Effect eff = this.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();
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) this.level)
|
||||
continue;
|
||||
|
||||
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters
|
||||
@@ -1638,7 +1404,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.bindLoc = this.lastBindLoc;
|
||||
this.setLoc(this.lastBindLoc);
|
||||
this.stopMovement(this.lastBindLoc);
|
||||
this.initializeStaticEffects();
|
||||
NPCManager.initializeStaticEffects(this);
|
||||
this.recalculateStats();
|
||||
|
||||
this.setHealth(this.healthMax);
|
||||
@@ -1646,8 +1412,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!this.isSiege && !this.isPlayerGuard && contract == null)
|
||||
loadInventory();
|
||||
|
||||
// LoadJob.getInstance();
|
||||
// LoadJob.forceLoad(this);
|
||||
}
|
||||
|
||||
public void despawn() {
|
||||
@@ -2341,7 +2105,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
|
||||
try {
|
||||
this.initializeStaticEffects();
|
||||
NPCManager.initializeStaticEffects(this);
|
||||
|
||||
try {
|
||||
this.initializeSkills();
|
||||
|
||||
Reference in New Issue
Block a user