forked from MagicBane/Server
Merge remote-tracking branch 'origin/bugfix-runesandbooties' into magicbox1.5
This commit is contained in:
+49
-658
@@ -11,7 +11,6 @@ package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.ai.MobileFSM;
|
||||
import engine.ai.MobileFSM.STATE;
|
||||
@@ -32,9 +31,7 @@ import engine.net.client.msg.ManageCityAssetsMsg;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
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;
|
||||
|
||||
@@ -58,7 +55,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
//mob specific
|
||||
private final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
|
||||
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
|
||||
public long nextCastTime = 0;
|
||||
public long nextCallForHelp = 0;
|
||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||
@@ -69,48 +66,46 @@ 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;
|
||||
public int spawnTime;
|
||||
//used by static mobs
|
||||
protected int parentZoneID;
|
||||
protected Zone parentZone;
|
||||
public Zone parentZone;
|
||||
protected float statLat;
|
||||
protected float statLon;
|
||||
protected float statAlt;
|
||||
protected Building building;
|
||||
protected Contract contract;
|
||||
public Building building;
|
||||
public Contract contract;
|
||||
private int currentID;
|
||||
private int ownerUID = 0; //only used by pets
|
||||
private boolean hasLoot = false;
|
||||
public 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;
|
||||
public AbstractCharacter npcOwner;
|
||||
public Vector3fImmutable inBuildingLoc = null;
|
||||
private boolean noAggro = false;
|
||||
private STATE state = STATE.Disabled;
|
||||
public STATE state = STATE.Disabled;
|
||||
private int aggroTargetID = 0;
|
||||
private boolean walkingHome = true;
|
||||
private long lastAttackTime = 0;
|
||||
private long deathTime = 0;
|
||||
private final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public long deathTime = 0;
|
||||
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private int patrolPointIndex = 0;
|
||||
private int lastMobPowerToken = 0;
|
||||
private HashMap<Integer, MobEquipment> equip = null;
|
||||
private String nameOverride = "";
|
||||
public String nameOverride = "";
|
||||
private Regions lastRegion = null;
|
||||
private long despawnTime = 0;
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
private int fidalityID = 0;
|
||||
private int equipmentSetID = 0;
|
||||
private int lootSet = 0;
|
||||
private boolean isGuard;
|
||||
private ArrayList<Integer> fidelityRunes = null;
|
||||
public int equipmentSetID = 0;
|
||||
public int runeSetID = 0;
|
||||
public int bootySetID = 0;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
@@ -257,12 +252,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
int guildID = rs.getInt("mob_guildUID");
|
||||
|
||||
|
||||
if (this.fidalityID != 0) {
|
||||
if (this.building != null)
|
||||
this.guild = this.building.getGuild();
|
||||
else
|
||||
this.guild = Guild.getGuild(guildID);
|
||||
} else if (this.building != null)
|
||||
if (this.building != null)
|
||||
this.guild = this.building.getGuild();
|
||||
else
|
||||
this.guild = Guild.getGuild(guildID);
|
||||
@@ -294,34 +284,15 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID));
|
||||
|
||||
|
||||
this.fidalityID = rs.getInt("fidalityID");
|
||||
|
||||
this.equipmentSetID = rs.getInt("equipmentSet");
|
||||
this.runeSetID = rs.getInt("runeSet");
|
||||
this.bootySetID = rs.getInt("bootySet");
|
||||
|
||||
if (this.contract != null)
|
||||
this.equipmentSetID = this.contract.getEquipmentSet();
|
||||
|
||||
this.lootSet = (rs.getInt("lootSet"));
|
||||
this.nameOverride = rs.getString("mob_name");
|
||||
|
||||
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 + "");
|
||||
}
|
||||
@@ -596,8 +567,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;
|
||||
@@ -722,30 +693,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);
|
||||
@@ -817,58 +764,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
mob.upgradeDateTime = upgradeDateTime;
|
||||
}
|
||||
|
||||
public static Vector3fImmutable GetSpawnRadiusLocation(Mob mob) {
|
||||
|
||||
Vector3fImmutable returnLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
if (mob.fidalityID != 0 && mob.building != null) {
|
||||
|
||||
|
||||
Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(mob.localLoc, mob.spawnRadius);
|
||||
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(mob.building, spawnRadiusLoc);
|
||||
|
||||
return buildingWorldLoc;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
boolean run = true;
|
||||
|
||||
while (run) {
|
||||
Vector3fImmutable localLoc = new Vector3fImmutable(mob.statLat + mob.parentZone.absX, mob.statAlt + mob.parentZone.absY, mob.statLon + mob.parentZone.absZ);
|
||||
Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(localLoc, mob.spawnRadius);
|
||||
|
||||
//not a roaming mob, just return the random loc.
|
||||
if (mob.spawnRadius < 12000)
|
||||
return spawnRadiusLoc;
|
||||
|
||||
Zone spawnZone = ZoneManager.findSmallestZone(spawnRadiusLoc);
|
||||
//dont spawn roaming mobs in npc cities
|
||||
if (spawnZone.isNPCCity())
|
||||
continue;
|
||||
|
||||
//dont spawn roaming mobs in player cities.
|
||||
if (spawnZone.isPlayerCity())
|
||||
continue;
|
||||
|
||||
//don't spawn mobs in water.
|
||||
if (HeightMap.isLocUnderwater(spawnRadiusLoc))
|
||||
continue;
|
||||
|
||||
run = false;
|
||||
|
||||
return spawnRadiusLoc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//shouldn't ever get here.
|
||||
|
||||
return returnLoc;
|
||||
}
|
||||
|
||||
private void clearStatic() {
|
||||
|
||||
if (this.parentZone != null)
|
||||
@@ -909,7 +804,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.level = 1;
|
||||
|
||||
//add this npc to building
|
||||
if (this.building != null && this.loadID != 0 && this.fidalityID == 0) {
|
||||
if (this.building != null && this.loadID != 0 && building.getBlueprintUUID() != 0) {
|
||||
|
||||
int maxSlots;
|
||||
maxSlots = building.getBlueprint().getSlotsForRank(this.building.getRank());
|
||||
@@ -955,225 +850,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
Mob.mobMapByDBID.put(this.dbID, this);
|
||||
}
|
||||
|
||||
private void initializeSkills() {
|
||||
|
||||
if (this.mobBase.getMobBaseStats() == null)
|
||||
return;
|
||||
|
||||
long skillVector = this.mobBase.getMobBaseStats().getSkillSet();
|
||||
int skillValue = this.mobBase.getMobBaseStats().getSkillValue();
|
||||
|
||||
if (this.mobBase.getObjectUUID() >= 17233) {
|
||||
for (CharacterSkills cs : CharacterSkills.values()) {
|
||||
SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken());
|
||||
CharacterSkill css = new CharacterSkill(sb, this, 50);
|
||||
this.skills.put(sb.getName(), css);
|
||||
}
|
||||
} else {
|
||||
for (CharacterSkills cs : CharacterSkills.values()) {
|
||||
if ((skillVector & cs.getFlag()) != 0) {
|
||||
SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken());
|
||||
CharacterSkill css = new CharacterSkill(sb, this, skillValue);
|
||||
this.skills.put(sb.getName(), css);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
@@ -1259,16 +935,29 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
public void setParentZone(Zone zone) {
|
||||
|
||||
if (this.parentZone == null) {
|
||||
if (this.parentZone == null){
|
||||
zone.zoneMobSet.add(this);
|
||||
this.parentZone = zone;
|
||||
}
|
||||
|
||||
this.bindLoc = Mob.GetSpawnRadiusLocation(this);
|
||||
this.lastBindLoc = bindLoc;
|
||||
this.setLoc(bindLoc);
|
||||
this.stopMovement(bindLoc);
|
||||
}
|
||||
|
||||
if ( this.building != null) {
|
||||
|
||||
Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat,this.statAlt,this.statLon);
|
||||
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, localLoc);
|
||||
this.setBindLoc(buildingWorldLoc);
|
||||
this.setLoc(buildingWorldLoc);
|
||||
this.endLoc = buildingWorldLoc;
|
||||
this.stopMovement(endLoc);
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat + zone.absX, this.statAlt + zone.absY, this.statLon + zone.absZ);
|
||||
this.setBindLoc(localLoc);
|
||||
this.setLoc(localLoc);
|
||||
this.endLoc = localLoc;
|
||||
this.stopMovement(endLoc);
|
||||
}
|
||||
|
||||
public int getParentZoneID() {
|
||||
|
||||
@@ -1588,7 +1277,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
if (chance <= me.getDropChance()) {
|
||||
MobLoot ml = new MobLoot(this, me.getItemBase(), false);
|
||||
ml.setFidelityEquipID(me.getObjectUUID());
|
||||
this.charItemManager.addItemToInventory(ml);
|
||||
}
|
||||
}
|
||||
@@ -1627,14 +1315,11 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.combatTarget = null;
|
||||
this.isAlive.set(true);
|
||||
|
||||
if (!this.isSiege)
|
||||
this.lastBindLoc = Mob.GetSpawnRadiusLocation(this);
|
||||
else
|
||||
this.lastBindLoc = this.bindLoc;
|
||||
this.lastBindLoc = this.bindLoc;
|
||||
this.bindLoc = this.lastBindLoc;
|
||||
this.setLoc(this.lastBindLoc);
|
||||
this.stopMovement(this.lastBindLoc);
|
||||
this.initializeStaticEffects();
|
||||
NPCManager.applyRuneSetEffects(this);
|
||||
this.recalculateStats();
|
||||
|
||||
this.setHealth(this.healthMax);
|
||||
@@ -1642,8 +1327,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!this.isSiege && !this.isPlayerGuard && contract == null)
|
||||
loadInventory();
|
||||
|
||||
// LoadJob.getInstance();
|
||||
// LoadJob.forceLoad(this);
|
||||
}
|
||||
|
||||
public void despawn() {
|
||||
@@ -2265,10 +1948,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
}
|
||||
|
||||
public Vector3fImmutable getInBuildingLoc() {
|
||||
return inBuildingLoc;
|
||||
}
|
||||
|
||||
public ItemBase getWeaponItemBase(boolean mainHand) {
|
||||
|
||||
if (this.equipmentSetID != 0) {
|
||||
@@ -2338,14 +2017,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
|
||||
try {
|
||||
this.initializeStaticEffects();
|
||||
|
||||
try {
|
||||
this.initializeSkills();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
NPCManager.applyRuneSetEffects(this);
|
||||
recalculateStats();
|
||||
this.setHealth(this.healthMax);
|
||||
|
||||
@@ -2392,10 +2064,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.timeToSpawnSiege = timeToSpawnSiege;
|
||||
}
|
||||
|
||||
public AbstractCharacter getNpcOwner() {
|
||||
return npcOwner;
|
||||
}
|
||||
|
||||
public void setNpcOwner(AbstractCharacter npcOwner) {
|
||||
this.npcOwner = npcOwner;
|
||||
}
|
||||
@@ -2428,81 +2096,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(Building building) {
|
||||
|
||||
// Remove npc from it's building
|
||||
this.state = STATE.Disabled;
|
||||
|
||||
try {
|
||||
this.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (this.parentZone != null)
|
||||
this.parentZone.zoneMobSet.remove(this);
|
||||
|
||||
if (building != null) {
|
||||
building.getHirelings().remove(this);
|
||||
this.removeMinions();
|
||||
}
|
||||
|
||||
// Delete npc from database
|
||||
|
||||
if (DbManager.MobQueries.DELETE_MOB(this) == 0)
|
||||
return false;
|
||||
|
||||
// Remove npc from the simulation
|
||||
|
||||
this.removeFromCache();
|
||||
DbManager.removeFromCache(this);
|
||||
WorldGrid.RemoveWorldObject(this);
|
||||
WorldGrid.removeObject(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeMinions() {
|
||||
|
||||
for (Mob toRemove : this.siegeMinionMap.keySet()) {
|
||||
|
||||
toRemove.state = STATE.Disabled;
|
||||
|
||||
if (this.isMoving()) {
|
||||
|
||||
this.stopMovement(this.getLoc());
|
||||
this.state = STATE.Disabled;
|
||||
|
||||
if (toRemove.parentZone != null)
|
||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
||||
}
|
||||
|
||||
try {
|
||||
toRemove.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
if (toRemove.parentZone != null)
|
||||
toRemove.parentZone.zoneMobSet.remove(toRemove);
|
||||
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
WorldGrid.removeObject(toRemove);
|
||||
DbManager.removeFromCache(toRemove);
|
||||
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRank(int newRank) {
|
||||
|
||||
DbManager.MobQueries.SET_PROPERTY(this, "mob_level", newRank);
|
||||
@@ -2523,14 +2116,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.noAggro = noAggro;
|
||||
}
|
||||
|
||||
public STATE getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(STATE state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getAggroTargetID() {
|
||||
return aggroTargetID;
|
||||
}
|
||||
@@ -2555,14 +2140,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.lastAttackTime = lastAttackTime;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, Boolean> getPlayerAgroMap() {
|
||||
return playerAgroMap;
|
||||
}
|
||||
|
||||
public long getDeathTime() {
|
||||
return deathTime;
|
||||
}
|
||||
|
||||
public void setDeathTime(long deathTime) {
|
||||
this.deathTime = deathTime;
|
||||
}
|
||||
@@ -2583,10 +2160,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
return siegeMinionMap;
|
||||
}
|
||||
|
||||
public Building getBuilding() {
|
||||
return this.building;
|
||||
}
|
||||
|
||||
public DateTime getUpgradeDateTime() {
|
||||
|
||||
lock.readLock().lock();
|
||||
@@ -2598,136 +2171,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Mob createGuardMob(int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
|
||||
|
||||
MobBase minionMobBase;
|
||||
Mob mob;
|
||||
int maxSlots = 1;
|
||||
|
||||
switch (this.getRank()) {
|
||||
case 1:
|
||||
case 2:
|
||||
maxSlots = 1;
|
||||
break;
|
||||
case 3:
|
||||
maxSlots = 2;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
maxSlots = 3;
|
||||
break;
|
||||
case 6:
|
||||
maxSlots = 4;
|
||||
break;
|
||||
case 7:
|
||||
maxSlots = 5;
|
||||
break;
|
||||
default:
|
||||
maxSlots = 1;
|
||||
|
||||
}
|
||||
|
||||
if (siegeMinionMap.size() == maxSlots)
|
||||
return null;
|
||||
|
||||
minionMobBase = this.mobBase;
|
||||
|
||||
if (minionMobBase == null)
|
||||
return null;
|
||||
|
||||
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true);
|
||||
|
||||
mob.despawned = true;
|
||||
|
||||
mob.setLevel(level);
|
||||
//grab equipment and name from minionbase.
|
||||
if (this.contract != null) {
|
||||
MinionType minionType = MinionType.ContractToMinionMap.get(this.contract.getContractID());
|
||||
if (minionType != null) {
|
||||
mob.equipmentSetID = minionType.getEquipSetID();
|
||||
String rank = "";
|
||||
|
||||
if (this.getRank() < 3)
|
||||
rank = MBServerStatics.JUNIOR;
|
||||
else if (this.getRank() < 6)
|
||||
rank = "";
|
||||
else if (this.getRank() == 6)
|
||||
rank = MBServerStatics.VETERAN;
|
||||
else
|
||||
rank = MBServerStatics.ELITE;
|
||||
|
||||
if (rank.isEmpty())
|
||||
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName();
|
||||
else
|
||||
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parent != null)
|
||||
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
|
||||
|
||||
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
|
||||
|
||||
// mob.setMob();
|
||||
mob.isPlayerGuard = true;
|
||||
mob.setParentZone(parent);
|
||||
DbManager.addToCache(mob);
|
||||
mob.runAfterLoad();
|
||||
|
||||
|
||||
RuneBase guardRune = RuneBase.getRuneBase(252621);
|
||||
|
||||
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
|
||||
|
||||
EffectsBase 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);
|
||||
}
|
||||
}
|
||||
|
||||
int slot = 0;
|
||||
slot += siegeMinionMap.size() + 1;
|
||||
|
||||
siegeMinionMap.put(mob, slot);
|
||||
mob.setInBuildingLoc(this.building, this);
|
||||
mob.setBindLoc(loc.add(mob.inBuildingLoc));
|
||||
mob.deathTime = System.currentTimeMillis();
|
||||
mob.spawnTime = 900;
|
||||
mob.npcOwner = this;
|
||||
mob.state = STATE.Respawn;
|
||||
|
||||
return mob;
|
||||
}
|
||||
|
||||
public Contract getContract() {
|
||||
return contract;
|
||||
}
|
||||
@@ -2776,10 +2219,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.lootSync = lootSync;
|
||||
}
|
||||
|
||||
public int getFidalityID() {
|
||||
return fidalityID;
|
||||
}
|
||||
|
||||
public HashMap<Integer, MobEquipment> getEquip() {
|
||||
return equip;
|
||||
}
|
||||
@@ -2788,14 +2227,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
return equipmentSetID;
|
||||
}
|
||||
|
||||
public int getLootSet() {
|
||||
return lootSet;
|
||||
}
|
||||
|
||||
public boolean isGuard() {
|
||||
return this.isGuard;
|
||||
}
|
||||
|
||||
public String getNameOverride() {
|
||||
return nameOverride;
|
||||
}
|
||||
@@ -2806,7 +2237,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
try {
|
||||
|
||||
building = this.getBuilding();
|
||||
building = this.building;
|
||||
|
||||
// Cannot upgrade an npc not within a building
|
||||
|
||||
@@ -2884,7 +2315,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!building.getHirelings().containsKey(this))
|
||||
return;
|
||||
|
||||
if (!this.remove(building)) {
|
||||
if (!NPCManager.removeMobileFromBuilding(this, building)) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return;
|
||||
}
|
||||
@@ -2941,7 +2372,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
WorldGrid.RemoveWorldObject(this);
|
||||
DbManager.removeFromCache(this);
|
||||
if (this.getObjectType() == GameObjectType.Mob) {
|
||||
this.setState(STATE.Disabled);
|
||||
this.state = STATE.Disabled;
|
||||
if (this.getParentZone() != null)
|
||||
this.getParentZone().zoneMobSet.remove(this);
|
||||
}
|
||||
@@ -2973,44 +2404,4 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
}
|
||||
|
||||
public void dismissNecroPet(boolean updateOwner) {
|
||||
|
||||
this.state = STATE.Disabled;
|
||||
|
||||
this.combatTarget = null;
|
||||
this.hasLoot = false;
|
||||
|
||||
if (this.parentZone != null)
|
||||
this.parentZone.zoneMobSet.remove(this);
|
||||
|
||||
try {
|
||||
this.clearEffects();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
this.playerAgroMap.clear();
|
||||
WorldGrid.RemoveWorldObject(this);
|
||||
|
||||
DbManager.removeFromCache(this);
|
||||
|
||||
// YEAH BONUS CODE! THANKS UNNAMED ASSHOLE!
|
||||
//WorldServer.removeObject(this);
|
||||
//WorldGrid.INSTANCE.removeWorldObject(this);
|
||||
//owner.getPet().disableIntelligence();
|
||||
|
||||
PlayerCharacter petOwner = this.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
this.setOwner(null);
|
||||
petOwner.setPet(null);
|
||||
|
||||
if (updateOwner == false)
|
||||
return;
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user