moved createSiegeMob and createGuardMob to the Mob class

This commit is contained in:
2023-04-22 17:16:34 -05:00
parent 8fa20c6f93
commit 38e5081b0e
7 changed files with 195 additions and 192 deletions
-129
View File
@@ -200,136 +200,7 @@ public enum NPCManager {
playerCharacter.necroPets.clear();
}
public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
MobBase minionMobBase;
Mob mob;
int maxSlots = 1;
switch (guardCaptain.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 (guardCaptain.siegeMinionMap.size() == maxSlots)
return null;
minionMobBase = guardCaptain.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 (guardCaptain.contract != null) {
Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID());
if (minionType != null) {
mob.equipmentSetID = minionType.getEquipSetID();
String rank = "";
if (guardCaptain.getRank() < 3)
rank = MBServerStatics.JUNIOR;
else if (guardCaptain.getRank() < 6)
rank = "";
else if (guardCaptain.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 += guardCaptain.siegeMinionMap.size() + 1;
guardCaptain.siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(guardCaptain.building, guardCaptain);
//mob.setBindLoc(loc.add(mob.inBuildingLoc));
mob.setLoc(guardCaptain.building.getLoc());
mob.setLastRegion(AbstractWorldObject.GetRegionByWorldObject(mob));
mob.setBindLoc(guardCaptain.building.getStuckLocation());
mob.deathTime = System.currentTimeMillis();
mob.spawnTime = 900;
mob.npcOwner = guardCaptain;
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
return mob;
}
public static void removeSiegeMinions(Mob mobile) {