forked from MagicBane/Server
More flushing out minion support.
This commit is contained in:
@@ -110,8 +110,8 @@ public class dbMobHandler extends dbHandlerBase {
|
|||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String name = rs.getString("name");
|
String minionName = rs.getString("name");
|
||||||
Mob toCreate = Mob.createGuardMob(guardCaptain, guardCaptain.getGuild(), guardCaptain.getParentZone(), guardCaptain.building.getLoc(), guardCaptain.getLevel(), name);
|
Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
|
||||||
|
|
||||||
if (toCreate == null)
|
if (toCreate == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -379,4 +379,31 @@ public enum NPCManager {
|
|||||||
|
|
||||||
return buildingSlot;
|
return buildingSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getMaxMinions(Mob guardCaptain) {
|
||||||
|
|
||||||
|
int maxSlots;
|
||||||
|
|
||||||
|
switch (guardCaptain.getRank()) {
|
||||||
|
case 3:
|
||||||
|
maxSlots = 2;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
maxSlots = 3;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
maxSlots = 4;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
maxSlots = 5;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
maxSlots = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
return maxSlots;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,14 +298,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
String pirateName = NPCManager.getPirateName(mobBase);
|
String pirateName = NPCManager.getPirateName(mobBase);
|
||||||
|
|
||||||
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
|
Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName);
|
||||||
return true;
|
|
||||||
|
|
||||||
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
|
|
||||||
|
|
||||||
if (toCreate == null)
|
if (toCreate == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (toCreate != null) {
|
if (toCreate != null) {
|
||||||
toCreate.setDeathTime(System.currentTimeMillis());
|
toCreate.setDeathTime(System.currentTimeMillis());
|
||||||
toCreate.parentZone.zoneMobSet.add(toCreate);
|
toCreate.parentZone.zoneMobSet.add(toCreate);
|
||||||
|
|||||||
+39
-108
@@ -26,7 +26,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.powers.MobPowerEntry;
|
import engine.powers.MobPowerEntry;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
@@ -638,132 +637,64 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
mob.upgradeDateTime = upgradeDateTime;
|
mob.upgradeDateTime = upgradeDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
|
public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) {
|
||||||
|
|
||||||
MobBase minionMobBase;
|
MobBase minionMobBase;
|
||||||
Mob mob;
|
Mob minionMobile;
|
||||||
int maxSlots;
|
|
||||||
|
|
||||||
switch (guardCaptain.getRank()) {
|
int maxSlots = NPCManager.getMaxMinions(guardCaptain);
|
||||||
case 3:
|
|
||||||
maxSlots = 2;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
maxSlots = 3;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
maxSlots = 4;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
maxSlots = 5;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
default:
|
|
||||||
maxSlots = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (guardCaptain.siegeMinionMap.size() == maxSlots)
|
if (guardCaptain.siegeMinionMap.size() == maxSlots)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
minionMobBase = guardCaptain.mobBase;
|
minionMobile = new Mob();
|
||||||
|
minionMobile.level = level;
|
||||||
|
minionMobile.loadID = guardCaptain.loadID;
|
||||||
|
minionMobile.firstName = minionName;
|
||||||
|
minionMobile.equipmentSetID = guardCaptain.equipmentSetID;
|
||||||
|
|
||||||
if (minionMobBase == null)
|
minionMobile.runeSet = guardCaptain.runeSet;
|
||||||
return null;
|
minionMobile.enemy = guardCaptain.enemy;
|
||||||
|
minionMobile.notEnemy = guardCaptain.notEnemy;
|
||||||
|
|
||||||
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true);
|
minionMobile.deathTime = System.currentTimeMillis();
|
||||||
mob.setLevel(level);
|
minionMobile.npcOwner = guardCaptain;
|
||||||
if (guardCaptain.equipmentSetID != 0)
|
minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
||||||
mob.equipmentSetID = guardCaptain.equipmentSetID;
|
minionMobile.BehaviourType = Enum.MobBehaviourType.GuardMinion;
|
||||||
|
minionMobile.guardedCity = guardCaptain.guardedCity;
|
||||||
|
minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID;
|
||||||
|
MovementManager.translocate(minionMobile, guardCaptain.bindLoc, guardCaptain.region);
|
||||||
|
minionMobile.bindLoc = guardCaptain.bindLoc;
|
||||||
|
|
||||||
mob.enemy = guardCaptain.enemy;
|
minionMobile.runAfterLoad();
|
||||||
mob.notEnemy = guardCaptain.notEnemy;
|
minionMobile.despawned = true;
|
||||||
|
minionMobile.despawn();
|
||||||
mob.runAfterLoad();
|
|
||||||
mob.despawned = true;
|
|
||||||
mob.despawn();
|
|
||||||
|
|
||||||
//grab equipment and name from minionbase.
|
//grab equipment and name from minionbase.
|
||||||
|
|
||||||
if (guardCaptain.contract != null) {
|
Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID());
|
||||||
Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID());
|
|
||||||
if (minionType != null) {
|
|
||||||
String rank;
|
|
||||||
|
|
||||||
if (guardCaptain.getRank() < 3)
|
if (minionType != null) {
|
||||||
rank = MBServerStatics.JUNIOR;
|
String rank;
|
||||||
else if (guardCaptain.getRank() < 6)
|
|
||||||
rank = "";
|
|
||||||
else if (guardCaptain.getRank() == 6)
|
|
||||||
rank = MBServerStatics.VETERAN;
|
|
||||||
else
|
|
||||||
rank = MBServerStatics.ELITE;
|
|
||||||
|
|
||||||
mob.firstName = NPCManager.getPirateName(mob.getMobBaseID());
|
if (guardCaptain.getRank() < 3)
|
||||||
mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName();
|
rank = MBServerStatics.JUNIOR;
|
||||||
}
|
else if (guardCaptain.getRank() < 6)
|
||||||
|
rank = "";
|
||||||
|
else if (guardCaptain.getRank() == 6)
|
||||||
|
rank = MBServerStatics.VETERAN;
|
||||||
|
else
|
||||||
|
rank = MBServerStatics.ELITE;
|
||||||
|
|
||||||
|
minionMobile.lastName = rank + " " + minionType.getRace() + " " + minionType.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
|
DbManager.addToCache(minionMobile);
|
||||||
|
|
||||||
mob.isPlayerGuard = true;
|
int slot = guardCaptain.siegeMinionMap.size() + 1;
|
||||||
|
guardCaptain.siegeMinionMap.put(minionMobile, slot);
|
||||||
|
|
||||||
DbManager.addToCache(mob);
|
return minionMobile;
|
||||||
|
|
||||||
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.deathTime = System.currentTimeMillis();
|
|
||||||
mob.npcOwner = guardCaptain;
|
|
||||||
mob.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
|
||||||
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
|
|
||||||
mob.guardedCity = guardCaptain.guardedCity;
|
|
||||||
mob.parentZone = parent;
|
|
||||||
parent.zoneMobSet.add(mob);
|
|
||||||
MovementManager.translocate(mob, guardCaptain.bindLoc, guardCaptain.region);
|
|
||||||
mob.bindLoc = guardCaptain.bindLoc;
|
|
||||||
return mob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
|
public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
|
||||||
|
|||||||
Reference in New Issue
Block a user