forked from MagicBane/Server
NPc Manager for static NPC classes
This commit is contained in:
@@ -11,6 +11,7 @@ package engine.db.handlers;
|
||||
|
||||
import engine.Enum.ProfitType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.NPCProfits;
|
||||
@@ -330,12 +331,12 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
|
||||
// Handle new mobbbase entries
|
||||
|
||||
if (NPC._pirateNames.get(mobBase) == null)
|
||||
NPC._pirateNames.putIfAbsent(mobBase, new ArrayList<>());
|
||||
if (NPCManager._pirateNames.get(mobBase) == null)
|
||||
NPCManager._pirateNames.putIfAbsent(mobBase, new ArrayList<>());
|
||||
|
||||
// Insert name into proper arraylist
|
||||
|
||||
NPC._pirateNames.get(mobBase).add(pirateName);
|
||||
NPCManager._pirateNames.get(mobBase).add(pirateName);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
@@ -343,7 +344,7 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
Logger.info("names read: " + recordsRead + " for "
|
||||
+ NPC._pirateNames.size() + " mobBases");
|
||||
+ NPCManager._pirateNames.size() + " mobBases");
|
||||
}
|
||||
|
||||
public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long itemBaseID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) {
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.devcmd;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -71,7 +72,7 @@ public abstract class AbstractDevCmd {
|
||||
int targetType = pc.getLastTargetType().ordinal();
|
||||
int targetID = pc.getLastTargetID();
|
||||
if (targetType == GameObjectType.NPC.ordinal()) {
|
||||
NPC b = NPC.getFromCache(targetID);
|
||||
NPC b = NPCManager.getFromCache(targetID);
|
||||
if (b == null) {
|
||||
ChatManager.chatSystemError(pc,
|
||||
"Command Failed. Could not find NPC of ID " + targetID);
|
||||
|
||||
@@ -10,12 +10,10 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
@@ -77,7 +75,7 @@ public class AddNPCCmd extends AbstractDevCmd {
|
||||
} else{
|
||||
loc = pc.loc;
|
||||
}
|
||||
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building);
|
||||
created = NPCManager.createNPC(name, contractID, loc, guild, zone, (short)level, building);
|
||||
created.bindLoc = loc;
|
||||
if(building != null) {
|
||||
created.buildingUUID = building.getObjectUUID();
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.ModType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.net.ItemProductionManager;
|
||||
@@ -47,7 +48,7 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
String itemName = "";
|
||||
NPC npc = NPC.getFromCache(failedItem.getNpcUID());
|
||||
NPC npc = NPCManager.getFromCache(failedItem.getNpcUID());
|
||||
|
||||
if (npc == null) {
|
||||
npcName = "null";
|
||||
|
||||
@@ -14,10 +14,7 @@ import engine.Enum.DbObjectType;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
|
||||
@@ -94,7 +91,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
|
||||
removeBuilding(player, targetBuilding);
|
||||
break;
|
||||
case NPC:
|
||||
targetNPC = NPC.getNPC(targetID);
|
||||
targetNPC = NPCManager.getNPC(targetID);
|
||||
removeNPC(player, targetNPC);
|
||||
break;
|
||||
case MOB:
|
||||
|
||||
@@ -14,6 +14,7 @@ import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
@@ -96,7 +97,7 @@ public class RotateCmd extends AbstractDevCmd {
|
||||
// building failed, try npc
|
||||
NPC npc;
|
||||
if (id != 0)
|
||||
npc = NPC.getNPC(id);
|
||||
npc = NPCManager.getNPC(id);
|
||||
else
|
||||
npc = getTargetAsNPC(pc);
|
||||
if (npc != null) {
|
||||
@@ -156,7 +157,7 @@ public class RotateCmd extends AbstractDevCmd {
|
||||
// building failed, try npc
|
||||
NPC npc;
|
||||
if (id != 0)
|
||||
npc = NPC.getNPC(id);
|
||||
npc = NPCManager.getNPC(id);
|
||||
else
|
||||
npc = getTargetAsNPC(pc);
|
||||
if (npc != null) {
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.devcmd.cmds;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.MobBase;
|
||||
import engine.objects.NPC;
|
||||
@@ -52,7 +53,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
|
||||
boolean complete = false;
|
||||
|
||||
while (complete == false) {
|
||||
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
complete = NPCManager.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
|
||||
if (!complete) {
|
||||
SetNpcEquipSetCmd.lastEquipSetID++;
|
||||
@@ -81,7 +82,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
|
||||
boolean complete = false;
|
||||
|
||||
while (complete == false) {
|
||||
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
complete = NPCManager.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
|
||||
|
||||
if (!complete) {
|
||||
SetNpcEquipSetCmd.lastEquipSetID--;
|
||||
@@ -109,7 +110,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
|
||||
this.throwbackError(pc, e.getMessage());
|
||||
}
|
||||
|
||||
if (!NPC.UpdateEquipSetID(npc, equipSetID)) {
|
||||
if (!NPCManager.UpdateEquipSetID(npc, equipSetID)) {
|
||||
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.devcmd.cmds;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.MobBase;
|
||||
import engine.objects.NPC;
|
||||
@@ -47,7 +48,7 @@ public class SetNpcMobbaseCmd extends AbstractDevCmd {
|
||||
this.throwbackError(player, "Cannot find Mobbase for ID " + mobBaseID);
|
||||
return;
|
||||
}
|
||||
NPC.UpdateRaceID(npc, mobBaseID);
|
||||
NPCManager.UpdateRaceID(npc, mobBaseID);
|
||||
|
||||
WorldGrid.updateObject(npc);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.devcmd.cmds;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.PlayerCharacter;
|
||||
@@ -43,7 +44,7 @@ public class SetNpcNameCmd extends AbstractDevCmd {
|
||||
|
||||
String name = words[0];
|
||||
|
||||
NPC.UpdateName(npc, name);
|
||||
NPCManager.UpdateName(npc, name);
|
||||
|
||||
WorldGrid.updateObject(npc);
|
||||
|
||||
|
||||
@@ -513,7 +513,7 @@ public enum BuildingManager {
|
||||
|
||||
NPC npc = null;
|
||||
|
||||
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, zone, (short) rank, building);
|
||||
npc = NPCManager.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, zone, (short) rank, building);
|
||||
|
||||
if (npc == null)
|
||||
return false;
|
||||
@@ -568,7 +568,7 @@ public enum BuildingManager {
|
||||
Mob mob;
|
||||
NPC npc;
|
||||
|
||||
if (NPC.ISWallArcher(contract)) {
|
||||
if (NPCManager.ISWallArcher(contract)) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
||||
|
||||
@@ -580,7 +580,7 @@ public enum BuildingManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NPC.ISGuardCaptain(contract.getContractID())) {
|
||||
if (NPCManager.ISGuardCaptain(contract.getContractID())) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
|
||||
|
||||
@@ -604,7 +604,7 @@ public enum BuildingManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
npc = NPC.createNPC(pirateName, contract.getObjectUUID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, (short) rank, building);
|
||||
npc = NPCManager.createNPC(pirateName, contract.getObjectUUID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, (short) rank, building);
|
||||
|
||||
if (npc == null)
|
||||
return false;
|
||||
@@ -810,7 +810,7 @@ public enum BuildingManager {
|
||||
}
|
||||
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg();
|
||||
mca.actionType = NPC.SVR_CLOSE_WINDOW;
|
||||
mca.actionType = NPCManager.SVR_CLOSE_WINDOW;
|
||||
mca.setTargetType(building.getObjectType().ordinal());
|
||||
mca.setTargetID(building.getObjectUUID());
|
||||
origin.sendMsg(mca);
|
||||
|
||||
@@ -88,7 +88,7 @@ public enum DbManager {
|
||||
outObject = PlayerManager.getPlayerCharacter(objectUUID);
|
||||
break;
|
||||
case NPC:
|
||||
outObject = NPC.getNPC(objectUUID);
|
||||
outObject = NPCManager.getNPC(objectUUID);
|
||||
break;
|
||||
case Mob:
|
||||
outObject = Mob.getFromCache(objectUUID);
|
||||
|
||||
@@ -2,14 +2,17 @@ package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.math.Quaternion;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -22,6 +25,8 @@ public enum NPCManager {
|
||||
|
||||
NPC_MANAGER;
|
||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||
public static int SVR_CLOSE_WINDOW = 4;
|
||||
public static HashMap<Integer, ArrayList<String>> _pirateNames = new HashMap<>();
|
||||
|
||||
public static void LoadAllRuneSets() {
|
||||
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
|
||||
@@ -286,10 +291,10 @@ public enum NPCManager {
|
||||
// If we cannot find name for this mobbase then
|
||||
// fallback to human male
|
||||
|
||||
if (NPC._pirateNames.containsKey(mobBaseID))
|
||||
nameList = NPC._pirateNames.get(mobBaseID);
|
||||
if (_pirateNames.containsKey(mobBaseID))
|
||||
nameList = _pirateNames.get(mobBaseID);
|
||||
else
|
||||
nameList = NPC._pirateNames.get(2111);
|
||||
nameList = _pirateNames.get(2111);
|
||||
|
||||
if (nameList == null) {
|
||||
Logger.error("Null name list for 2111!");
|
||||
@@ -370,4 +375,384 @@ public enum NPCManager {
|
||||
|
||||
return buildingSlot;
|
||||
}
|
||||
|
||||
public static boolean ISWallArcher(Contract contract) {
|
||||
|
||||
if (contract == null)
|
||||
return false;
|
||||
|
||||
//838, 950, 1051, 1181, 1251, 1351, 1451, 1501, 1526, 1551, 980101,
|
||||
|
||||
return contract.getAllowedBuildings().contains(Enum.BuildingGroup.WALLCORNER) ||
|
||||
contract.getAllowedBuildings().contains(Enum.BuildingGroup.WALLSTRAIGHTTOWER);
|
||||
}
|
||||
|
||||
public static NPC getFromCache(int id) {
|
||||
return (NPC) DbManager.getFromCache(Enum.GameObjectType.NPC, id);
|
||||
}
|
||||
|
||||
public static boolean UpdateName(NPC npc, String value) {
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_NAME(npc, value))
|
||||
return false;
|
||||
|
||||
npc.setName(value);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void serializeNpcForClientMsgOtherPlayer(NPC npc, ByteBufferWriter writer, boolean hideAsciiLastName)
|
||||
throws SerializationException {
|
||||
serializeForClientMsgOtherPlayer(npc, writer);
|
||||
}
|
||||
|
||||
public static void serializeForClientMsgOtherPlayer(NPC npc, ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
//num Runes
|
||||
int cnt = 3;
|
||||
boolean isVamp = false, isHealer = false, isArcher = false, isTrainer = false;
|
||||
int contractID = 0, classID = 0;
|
||||
int extraRune = 0;
|
||||
|
||||
if (npc.contract != null) {
|
||||
contractID = npc.contract.getContractID();
|
||||
classID = npc.contract.getClassID();
|
||||
extraRune = npc.contract.getExtraRune();
|
||||
|
||||
if (extraRune == contractID)
|
||||
extraRune = 0;
|
||||
|
||||
}
|
||||
|
||||
if ((contractID > 252642 && contractID < 252647) || contractID == 252652) {
|
||||
isVamp = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (contractID == 252582 || contractID == 252579 || contractID == 252581
|
||||
|| contractID == 252584 || contractID == 252597 || contractID == 252598
|
||||
|| contractID == 252628 || extraRune == 252582 || extraRune == 252579
|
||||
|| extraRune == 252581 || extraRune == 252584 || extraRune == 252597
|
||||
|| extraRune == 252598 || extraRune == 252628) {
|
||||
isHealer = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (contractID == 252570) {
|
||||
isArcher = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (classID != 0)
|
||||
cnt++;
|
||||
|
||||
if (extraRune != 0 && extraRune != contractID)
|
||||
cnt++;
|
||||
|
||||
writer.putInt(cnt);
|
||||
|
||||
//Race
|
||||
writer.putInt(1);
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.getMobBase() != null)
|
||||
writer.putInt(npc.getMobBase().getLoadID());
|
||||
else
|
||||
writer.putInt(2011);
|
||||
|
||||
writer.putInt(Enum.GameObjectType.NPCRaceRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//Class/Trainer/Whatever
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.contract != null)
|
||||
writer.putInt(contractID);
|
||||
else
|
||||
writer.putInt(2500);
|
||||
|
||||
writer.putInt(Enum.GameObjectType.NPCClassRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//vampire trainer
|
||||
cnt = 0;
|
||||
|
||||
if (extraRune != 0)
|
||||
cnt = serializeExtraRune(npc, extraRune, cnt, writer);
|
||||
if (isVamp)
|
||||
cnt = serializeExtraRune(npc, 252647, cnt, writer);
|
||||
|
||||
//Healer trainer
|
||||
if (isHealer)
|
||||
cnt = serializeExtraRune(npc, 252592, cnt, writer);
|
||||
|
||||
if (classID != 0) {
|
||||
writer.putInt(4);
|
||||
writer.putInt(0);
|
||||
writer.putInt(classID);
|
||||
writer.putInt(Enum.GameObjectType.NPCExtraRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
}
|
||||
|
||||
//Scout trainer
|
||||
if (isArcher)
|
||||
cnt = serializeExtraRune(npc, 252654, cnt, writer);
|
||||
|
||||
//Shopkeeper
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0x3DACC);
|
||||
writer.putInt(Enum.GameObjectType.NPCShopkeeperRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//Send Stats
|
||||
writer.putInt(5);
|
||||
writer.putInt(0x8AC3C0E6); //Str
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xACB82E33); //Dex
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xB15DC77E); //Con
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xE07B3336); //Int
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xFF665EC3); //Spi
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putString(npc.getName());
|
||||
writer.putString("");
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
writer.put((byte) 0);
|
||||
writer.putInt(npc.getObjectType().ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
writer.putFloat(1.0f);
|
||||
writer.putFloat(1.0f);
|
||||
writer.putFloat(1.0f);
|
||||
|
||||
if (npc.region != null)
|
||||
writer.putVector3f(ZoneManager.convertWorldToLocal(npc.building, npc.getLoc()));
|
||||
else
|
||||
writer.putVector3f(npc.getLoc());
|
||||
|
||||
//Rotation
|
||||
float radians = (float) Math.acos(npc.getRot().y) * 2;
|
||||
|
||||
if (npc.building != null)
|
||||
if (npc.building.getBounds() != null && npc.building.getBounds().getQuaternion() != null)
|
||||
radians += (npc.building.getBounds().getQuaternion()).angleY;
|
||||
|
||||
writer.putFloat(radians);
|
||||
|
||||
//Running Speed
|
||||
writer.putInt(0);
|
||||
|
||||
// get a copy of the equipped items.
|
||||
|
||||
if (npc.equip != null) {
|
||||
writer.putInt(npc.equip.size());
|
||||
|
||||
for (MobEquipment me : npc.equip.values())
|
||||
MobEquipment.serializeForClientMsg(me, writer);
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putInt((npc.level / 10));
|
||||
writer.putInt(npc.level);
|
||||
writer.putInt(npc.getIsSittingAsInt()); //Standing
|
||||
writer.putInt(npc.getIsWalkingAsInt()); //Walking
|
||||
writer.putInt(npc.getIsCombatAsInt()); //Combat
|
||||
writer.putInt(2); //Unknown
|
||||
writer.putInt(1); //Unknown - Headlights?
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.building != null && npc.region != null) {
|
||||
writer.putInt(npc.building.getObjectType().ordinal());
|
||||
writer.putInt(npc.building.getObjectUUID());
|
||||
} else {
|
||||
writer.putInt(0); //<-Building Object Type
|
||||
writer.putInt(0); //<-Building Object ID
|
||||
}
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
|
||||
//npc dialog menus from contracts
|
||||
|
||||
if (npc.contract != null) {
|
||||
ArrayList<Integer> npcMenuOptions = npc.contract.getNPCMenuOptions();
|
||||
writer.putInt(npcMenuOptions.size());
|
||||
for (Integer val : npcMenuOptions) {
|
||||
writer.putInt(val);
|
||||
}
|
||||
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.put((byte) 1);
|
||||
|
||||
if (npc.building != null) {
|
||||
writer.putInt(Enum.GameObjectType.StrongBox.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
writer.putInt(Enum.GameObjectType.StrongBox.ordinal());
|
||||
writer.putInt(npc.building.getObjectUUID());
|
||||
} else {
|
||||
writer.putLong(0);
|
||||
writer.putLong(0);
|
||||
}
|
||||
|
||||
if (npc.contract != null)
|
||||
writer.putInt(npc.contract.getIconID());
|
||||
else
|
||||
writer.putInt(0); //npc icon ID
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putShort((short) 0);
|
||||
|
||||
if (npc.contract != null && npc.contract.isTrainer()) {
|
||||
writer.putInt(classID);
|
||||
} else {
|
||||
writer.putInt(0);
|
||||
}
|
||||
|
||||
if (npc.contract != null && npc.contract.isTrainer())
|
||||
writer.putInt(classID);
|
||||
else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putFloat(4);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
|
||||
//Pull guild info from building if linked to one
|
||||
|
||||
Guild.serializeForClientMsg(npc.guild, writer, null, true);
|
||||
|
||||
writer.putInt(1);
|
||||
writer.putInt(0x8A2E);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
//TODO Guard
|
||||
writer.put((byte) 0); //Is guard..
|
||||
|
||||
writer.putFloat(1500f); //npc.healthMax
|
||||
writer.putFloat(1500f); //npc.health
|
||||
|
||||
//TODO Peace Zone
|
||||
writer.put((byte) 1); //0=show tags, 1=don't
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
|
||||
private static int serializeExtraRune(NPC npc, int runeID, int cnt, ByteBufferWriter writer) {
|
||||
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
writer.putInt(runeID);
|
||||
|
||||
if (cnt == 0)
|
||||
writer.putInt(Enum.GameObjectType.NPCClassRuneTwo.ordinal());
|
||||
else
|
||||
writer.putInt(Enum.GameObjectType.NPCClassRuneThree.ordinal());
|
||||
|
||||
writer.putInt(npc.currentID);
|
||||
return cnt + 1;
|
||||
}
|
||||
|
||||
public static NPC createNPC(String name, int contractID, Vector3fImmutable spawn, Guild guild, Zone parent, short level, Building building) {
|
||||
|
||||
NPC newNPC = new NPC();
|
||||
|
||||
newNPC.setName(name);
|
||||
newNPC.contractUUID = contractID;
|
||||
|
||||
if (building == null)
|
||||
newNPC.bindLoc = spawn;
|
||||
else
|
||||
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
newNPC.parentZoneUUID = parent.getObjectUUID();
|
||||
newNPC.guildUUID = guild.getObjectUUID();
|
||||
|
||||
if (building == null)
|
||||
newNPC.buildingUUID = 0;
|
||||
else
|
||||
newNPC.buildingUUID = building.getObjectUUID();
|
||||
|
||||
newNPC.level = level;
|
||||
|
||||
newNPC.buyPercent = .33f;
|
||||
newNPC.sellPercent = 1;
|
||||
|
||||
NPC npc;
|
||||
|
||||
try {
|
||||
npc = DbManager.NPCQueries.PERSIST(newNPC);
|
||||
npc.setObjectTypeMask(MBServerStatics.MASK_NPC);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
npc = null;
|
||||
}
|
||||
|
||||
return npc;
|
||||
}
|
||||
|
||||
public static NPC getNPC(int id) {
|
||||
|
||||
if (id == 0)
|
||||
return null;
|
||||
|
||||
NPC npc = (NPC) DbManager.getFromCache(Enum.GameObjectType.NPC, id);
|
||||
|
||||
if (npc != null)
|
||||
return npc;
|
||||
|
||||
return DbManager.NPCQueries.GET_NPC(id);
|
||||
}
|
||||
|
||||
public static boolean ISGuardCaptain(int contractID) {
|
||||
return Enum.MinionType.ContractToMinionMap.containsKey(contractID);
|
||||
}
|
||||
|
||||
public static boolean UpdateEquipSetID(NPC npc, int equipSetID) {
|
||||
|
||||
if (!LootManager._bootySetMap.containsKey(equipSetID))
|
||||
return false;
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
|
||||
return false;
|
||||
|
||||
npc.equipmentSetID = equipSetID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean UpdateRaceID(NPC npc, int raceID) {
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_MOBBASE(npc, raceID))
|
||||
return false;
|
||||
|
||||
npc.loadID = raceID;
|
||||
npc.mobBase = MobBase.getMobBase(npc.loadID);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static NPCProfits GetNPCProfits(NPC npc) {
|
||||
return NPCProfits.ProfitCache.get(npc.currentID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory(true));
|
||||
break;
|
||||
case NPC:
|
||||
characterTarget = NPC.getFromCache(msg.getTargetID());
|
||||
characterTarget = NPCManager.getFromCache(msg.getTargetID());
|
||||
if (characterTarget == null)
|
||||
return;
|
||||
break;
|
||||
@@ -818,7 +818,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
|
||||
} else if (targetType == GameObjectType.NPC.ordinal())
|
||||
tar = NPC.getFromCache(targetID);
|
||||
tar = NPCManager.getFromCache(targetID);
|
||||
else if (targetType == GameObjectType.Mob.ordinal())
|
||||
tar = Mob.getFromCache(targetID);
|
||||
if (tar == null)
|
||||
@@ -1015,7 +1015,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (targetType == GameObjectType.PlayerCharacter.ordinal())
|
||||
tar = PlayerManager.getFromCache(msg.getTargetID());
|
||||
else if (targetType == GameObjectType.NPC.ordinal())
|
||||
tar = NPC.getFromCache(msg.getTargetID());
|
||||
tar = NPCManager.getFromCache(msg.getTargetID());
|
||||
else if (targetType == GameObjectType.Mob.ordinal())
|
||||
tar = Mob.getFromCache(msg.getTargetID());
|
||||
|
||||
@@ -1150,7 +1150,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (sourcePlayer == null)
|
||||
return;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNPCID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
@@ -1199,7 +1199,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (itemMan == null)
|
||||
return;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNPCID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
@@ -1363,7 +1363,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (sourcePlayer == null)
|
||||
return;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNpcID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNpcID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
@@ -1391,7 +1391,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (itemMan == null) {
|
||||
return;
|
||||
}
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNPCID());
|
||||
if (npc == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1623,7 +1623,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNPCID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class AssetSupportMsgHandler extends AbstractClientMsgHandler {
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
vendor = NPC.getFromCache(msg.getNpcID());
|
||||
vendor = NPCManager.getFromCache(msg.getNpcID());
|
||||
|
||||
if (msg.getMessageType() != 6 && msg.getMessageType() != 7) {
|
||||
if (vendor == null)
|
||||
|
||||
@@ -13,6 +13,7 @@ package engine.net.client.handlers;
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
@@ -52,7 +53,7 @@ public class HirelingServiceMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.npcID);
|
||||
NPC npc = NPCManager.getFromCache(msg.npcID);
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
@@ -415,7 +415,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
msg = (MerchantMsg) baseMsg;
|
||||
npc = NPC.getNPC(msg.getNPCID());
|
||||
npc = NPCManager.getNPC(msg.getNPCID());
|
||||
|
||||
// Early exit if something goes awry
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
|
||||
|
||||
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
|
||||
NPC npc = NPCManager.getFromCache(minionMsg.getNpcID());
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
@@ -4,10 +4,7 @@ import engine.Enum;
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
@@ -74,7 +71,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
if (msg.getPlayerType() == GameObjectType.PlayerCharacter.ordinal())
|
||||
toAdd = PlayerManager.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.NPC.ordinal())
|
||||
toAdd = NPC.getFromCache(msg.getPlayerID());
|
||||
toAdd = NPCManager.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.Mob.ordinal())
|
||||
toAdd = Mob.getFromCache(msg.getPlayerID());
|
||||
else {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg();
|
||||
mca.actionType = NPC.SVR_CLOSE_WINDOW;
|
||||
mca.actionType = NPCManager.SVR_CLOSE_WINDOW;
|
||||
mca.setTargetType(building.getObjectType().ordinal());
|
||||
mca.setTargetID(building.getObjectUUID());
|
||||
origin.sendMsg(mca);
|
||||
@@ -110,7 +110,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
npc = NPC.getFromCache(msg.getNpcUUID());
|
||||
npc = NPCManager.getFromCache(msg.getNpcUUID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
@@ -120,7 +120,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building == null)
|
||||
return;
|
||||
|
||||
NPCProfits profit = NPC.GetNPCProfits(npc);
|
||||
NPCProfits profit = NPCManager.GetNPCProfits(npc);
|
||||
|
||||
if (profit == null)
|
||||
return;
|
||||
@@ -155,7 +155,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
npc = NPC.getFromCache(orderNPCMsg.getNpcUUID());
|
||||
npc = NPCManager.getFromCache(orderNPCMsg.getNpcUUID());
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
@@ -165,7 +165,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
if (building == null)
|
||||
return;
|
||||
|
||||
NPCProfits profit = NPC.GetNPCProfits(npc);
|
||||
NPCProfits profit = NPCManager.GetNPCProfits(npc);
|
||||
|
||||
if (profit == null)
|
||||
return;
|
||||
@@ -428,7 +428,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
if (orderNPCMsg.getObjectType() == GameObjectType.NPC.ordinal()) {
|
||||
|
||||
npc = NPC.getFromCache(orderNPCMsg.getNpcUUID());
|
||||
npc = NPCManager.getFromCache(orderNPCMsg.getNpcUUID());
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
@@ -13,6 +13,7 @@ import engine.Enum.GameObjectType;
|
||||
import engine.Enum.TransactionType;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
@@ -108,7 +109,7 @@ public class ArcViewAssetTransactionsMsg extends ClientNetMsg {
|
||||
name = pc.getCombinedName();
|
||||
break;
|
||||
case NPC:
|
||||
NPC npc = NPC.getFromCache(transaction.getTargetUUID());
|
||||
NPC npc = NPCManager.getFromCache(transaction.getTargetUUID());
|
||||
if (npc != null) {
|
||||
|
||||
if (npc.getBuilding() != null)
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.net.client.msg;
|
||||
|
||||
import engine.Enum.ItemType;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.AbstractNetMsg;
|
||||
@@ -92,7 +93,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
|
||||
|
||||
float sellPercent = 1;
|
||||
|
||||
NPC npc = NPC.getFromCache(npcID);
|
||||
NPC npc = NPCManager.getFromCache(npcID);
|
||||
CharacterItemManager man = null;
|
||||
ArrayList<Item> inventory = null;
|
||||
ArrayList<MobEquipment> sellInventory = null;
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.net.client.msg;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.AbstractNetMsg;
|
||||
@@ -291,7 +292,7 @@ public class ItemProductionMsg extends ClientNetMsg {
|
||||
writer.putInt(0);
|
||||
}
|
||||
|
||||
NPC vendor = NPC.getFromCache(this.npcUUID);
|
||||
NPC vendor = NPCManager.getFromCache(this.npcUUID);
|
||||
if (vendor != null) {
|
||||
if (toRoll.isComplete()) {
|
||||
writer.putInt(0);
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
|
||||
if (this.targetType == GameObjectType.NPC.ordinal()) {
|
||||
|
||||
npc = NPC.getFromCache(this.targetID);
|
||||
npc = NPCManager.getFromCache(this.targetID);
|
||||
|
||||
if (npc == null) {
|
||||
Logger.error("Missing NPC of ID " + this.targetID);
|
||||
@@ -233,7 +233,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.put((byte) 0);
|
||||
writer.putInt(0);
|
||||
|
||||
NPCProfits profit = NPC.GetNPCProfits(npc);
|
||||
NPCProfits profit = NPCManager.GetNPCProfits(npc);
|
||||
|
||||
if (profit == null)
|
||||
profit = NPCProfits.defaultProfits;
|
||||
@@ -598,7 +598,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
|
||||
}
|
||||
|
||||
if (NPC.ISGuardCaptain(mobA.getContract().getContractID()) == false)
|
||||
if (NPCManager.ISGuardCaptain(mobA.getContract().getContractID()) == false)
|
||||
maxSlots = 0;
|
||||
|
||||
writer.putInt(0); //anything other than 0 seems to mess up the client
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.net.client.msg;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
@@ -721,7 +722,7 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
if (characterType == GameObjectType.PlayerCharacter.ordinal())
|
||||
heraldryCharacter = PlayerManager.getFromCache(characterID);
|
||||
else if (characterType == GameObjectType.NPC.ordinal())
|
||||
heraldryCharacter = NPC.getFromCache(characterID);
|
||||
heraldryCharacter = NPCManager.getFromCache(characterID);
|
||||
else if (characterType == GameObjectType.Mob.ordinal())
|
||||
heraldryCharacter = Mob.getFromCache(characterID);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.*;
|
||||
@@ -63,7 +64,7 @@ public class RefineMsg extends ClientNetMsg {
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
if (pc == null)
|
||||
return;
|
||||
NPC npc = NPC.getFromCache(msg.npcID);
|
||||
NPC npc = NPCManager.getFromCache(msg.npcID);
|
||||
if (npc == null)
|
||||
return;
|
||||
int type = msg.type;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.AbstractNetMsg;
|
||||
@@ -109,7 +110,7 @@ public class TrackWindowMsg extends ClientNetMsg {
|
||||
if (objectType == GameObjectType.PlayerCharacter.ordinal())
|
||||
ac = PlayerManager.getFromCache(objectID);
|
||||
else if (objectType == GameObjectType.NPC.ordinal())
|
||||
ac = NPC.getFromCache(objectID);
|
||||
ac = NPCManager.getFromCache(objectID);
|
||||
else if (objectType == GameObjectType.Mob.ordinal())
|
||||
ac = Mob.getFromCache(objectID);
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@ package engine.net.client.msg;
|
||||
import engine.Enum;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.net.*;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.Protocol;
|
||||
@@ -65,7 +62,7 @@ public class TrainMsg extends ClientNetMsg {
|
||||
if (playerCharacter == null)
|
||||
return;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.npcID);
|
||||
NPC npc = NPCManager.getFromCache(msg.npcID);
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class VendorDialogMsg extends ClientNetMsg {
|
||||
}
|
||||
|
||||
// Get NPC that player is talking to
|
||||
NPC npc = NPC.getFromCache(msg.vendorObjectID);
|
||||
NPC npc = NPCManager.getFromCache(msg.vendorObjectID);
|
||||
int npcClassID;
|
||||
|
||||
if (npc == null)
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.net.client.msg.guild;
|
||||
|
||||
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
@@ -295,7 +296,7 @@ class GuildInfoMessageType4 extends GuildInfoMessageType {
|
||||
AbstractCharacter guildLeader;
|
||||
String guildLeaderName = "";
|
||||
if (g.isNPCGuild()) {
|
||||
guildLeader = NPC.getFromCache(g.getGuildLeaderUUID());
|
||||
guildLeader = NPCManager.getFromCache(g.getGuildLeaderUUID());
|
||||
if (guildLeader != null)
|
||||
guildLeaderName = guildLeader.getName();
|
||||
} else {
|
||||
|
||||
@@ -369,7 +369,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
Mob.serializeMobForClientMsgOtherPlayer((Mob) abstractCharacter, writer);
|
||||
break;
|
||||
case NPC:
|
||||
NPC.serializeNpcForClientMsgOtherPlayer((NPC) abstractCharacter, writer, asciiLastName);
|
||||
NPCManager.serializeNpcForClientMsgOtherPlayer((NPC) abstractCharacter, writer, asciiLastName);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package engine.objects;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
@@ -111,7 +112,7 @@ public abstract class AbstractGameObject {
|
||||
return PlayerManager.getPlayerCharacter(tableID);
|
||||
|
||||
case NPC:
|
||||
return NPC.getNPC(tableID);
|
||||
return NPCManager.getNPC(tableID);
|
||||
|
||||
case Mob:
|
||||
return Mob.getMob(tableID);
|
||||
|
||||
@@ -303,7 +303,7 @@ public final class Bane {
|
||||
if(commanderuuid == 0) {
|
||||
//add bane commander NPC
|
||||
int contractID = 1502042;
|
||||
baneCommander = NPC.createNPC("Bane Commander", contractID, spawnLoc, bane.getCity().getGuild(), ZoneManager.findSmallestZone(bane.getStone().loc), (short) 70, bane.getStone());
|
||||
baneCommander = NPCManager.createNPC("Bane Commander", contractID, spawnLoc, bane.getCity().getGuild(), ZoneManager.findSmallestZone(bane.getStone().loc), (short) 70, bane.getStone());
|
||||
try {
|
||||
NPCManager.slotCharacterInBuilding(baneCommander);
|
||||
}catch(Exception e){
|
||||
@@ -314,7 +314,7 @@ public final class Bane {
|
||||
}
|
||||
else
|
||||
{
|
||||
baneCommander = NPC.getNPC(commanderuuid);
|
||||
baneCommander = NPCManager.getNPC(commanderuuid);
|
||||
}
|
||||
//try {
|
||||
// NPCManager.slotCharacterInBuilding(baneCommander);
|
||||
|
||||
@@ -17,10 +17,7 @@ import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.db.archive.MineRecord;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.DoorCloseJob;
|
||||
@@ -969,7 +966,7 @@ public class Building extends AbstractWorldObject {
|
||||
if (this.ownerUUID == 0)
|
||||
return null;
|
||||
if (this.ownerIsNPC)
|
||||
return NPC.getFromCache(this.ownerUUID);
|
||||
return NPCManager.getFromCache(this.ownerUUID);
|
||||
|
||||
return PlayerManager.getFromCache(this.ownerUUID);
|
||||
|
||||
@@ -1092,7 +1089,7 @@ public class Building extends AbstractWorldObject {
|
||||
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
||||
|
||||
if (this.ownerIsNPC) {
|
||||
if (NPC.getNPC(this.ownerUUID) == null)
|
||||
if (NPCManager.getNPC(this.ownerUUID) == null)
|
||||
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
|
||||
} else if (this.ownerUUID != 0) {
|
||||
|
||||
@@ -692,7 +692,7 @@ public class City extends AbstractWorldObject {
|
||||
return null;
|
||||
|
||||
if (this.isNpc == 1)
|
||||
return NPC.getNPC(ownerID);
|
||||
return NPCManager.getNPC(ownerID);
|
||||
else
|
||||
return PlayerManager.getPlayerCharacter(ownerID);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class Guild extends AbstractWorldObject {
|
||||
return null;
|
||||
|
||||
if (guild.ownerIsNPC)
|
||||
return NPC.getFromCache(guild.guildLeaderUUID);
|
||||
return NPCManager.getFromCache(guild.guildLeaderUUID);
|
||||
|
||||
return PlayerManager.getFromCache(guild.guildLeaderUUID);
|
||||
}
|
||||
@@ -831,7 +831,7 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
||||
if (this.ownerIsNPC) {
|
||||
if (NPC.getNPC(this.guildLeaderUUID) == null)
|
||||
if (NPCManager.getNPC(this.guildLeaderUUID) == null)
|
||||
Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID);
|
||||
|
||||
} else if (this.guildLeaderUUID != 0) {
|
||||
|
||||
@@ -12,10 +12,7 @@ package engine.objects;
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PlayerManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.*;
|
||||
import engine.net.ByteBufferReader;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.Dispatch;
|
||||
@@ -849,7 +846,7 @@ public class Item extends AbstractWorldObject {
|
||||
|
||||
public AbstractGameObject getOwner() {
|
||||
if (this.ownerType == OwnerType.Npc)
|
||||
return NPC.getFromCache(this.ownerID);
|
||||
return NPCManager.getFromCache(this.ownerID);
|
||||
else if (this.ownerType == OwnerType.PlayerCharacter)
|
||||
return PlayerManager.getFromCache(this.ownerID);
|
||||
else if (this.ownerType == OwnerType.Mob)
|
||||
|
||||
@@ -231,7 +231,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else
|
||||
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
|
||||
|
||||
if (this.contract != null && NPC.ISGuardCaptain(contract.getContractID())) {
|
||||
if (this.contract != null && NPCManager.ISGuardCaptain(contract.getContractID())) {
|
||||
this.spawnTime = 60 * 15;
|
||||
this.isPlayerGuard = true;
|
||||
}
|
||||
@@ -1012,7 +1012,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.charItemManager.load();
|
||||
|
||||
//load AI for general mobs.
|
||||
if (this.contract != null && NPC.ISWallArcher(this.contract)) {
|
||||
if (this.contract != null && NPCManager.ISWallArcher(this.contract)) {
|
||||
this.BehaviourType = MobBehaviourType.GuardWallArcher;
|
||||
this.isPlayerGuard = true;
|
||||
this.spawnTime = 450;
|
||||
@@ -2156,7 +2156,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.BehaviourType = this.getMobBase().fsm;
|
||||
|
||||
if (this.isPlayerGuard() && this.contract != null)
|
||||
if (NPC.ISWallArcher(this.getContract())) {
|
||||
if (NPCManager.ISWallArcher(this.getContract())) {
|
||||
this.BehaviourType = MobBehaviourType.GuardWallArcher;
|
||||
this.spawnTime = 450;
|
||||
} else {
|
||||
|
||||
+8
-392
@@ -12,7 +12,6 @@ package engine.objects;
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.*;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
@@ -20,7 +19,6 @@ import engine.jobs.UpgradeNPCJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
@@ -45,8 +43,6 @@ import static engine.util.StringUtils.wordCount;
|
||||
|
||||
public class NPC extends AbstractCharacter {
|
||||
|
||||
public static int SVR_CLOSE_WINDOW = 4;
|
||||
public static HashMap<Integer, ArrayList<String>> _pirateNames = new HashMap<>();
|
||||
// Used for thread safety
|
||||
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||
@@ -56,11 +52,11 @@ public class NPC extends AbstractCharacter {
|
||||
public HashMap<Integer, MobEquipment> equip = null;
|
||||
public int runeSetID = 0;
|
||||
public int extraRune2 = 0;
|
||||
protected int loadID;
|
||||
protected MobBase mobBase;
|
||||
public int loadID;
|
||||
public MobBase mobBase;
|
||||
protected String name;
|
||||
protected int dbID;
|
||||
protected int currentID;
|
||||
public int currentID;
|
||||
//used by static npcs
|
||||
protected Zone parentZone;
|
||||
protected float statLat;
|
||||
@@ -166,39 +162,9 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
}
|
||||
|
||||
public static boolean ISWallArcher(Contract contract) {
|
||||
|
||||
if (contract == null)
|
||||
return false;
|
||||
|
||||
//838, 950, 1051, 1181, 1251, 1351, 1451, 1501, 1526, 1551, 980101,
|
||||
|
||||
return contract.getAllowedBuildings().contains(BuildingGroup.WALLCORNER) ||
|
||||
contract.getAllowedBuildings().contains(BuildingGroup.WALLSTRAIGHTTOWER);
|
||||
}
|
||||
|
||||
//This method restarts an upgrade timer when a building is loaded from the database.
|
||||
// Submit upgrade job for this building based upon it's current upgradeDateTime
|
||||
|
||||
public static NPC getFromCache(int id) {
|
||||
return (NPC) DbManager.getFromCache(GameObjectType.NPC, id);
|
||||
}
|
||||
|
||||
public static boolean UpdateName(NPC npc, String value) {
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_NAME(npc, value))
|
||||
return false;
|
||||
|
||||
npc.name = value;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void serializeNpcForClientMsgOtherPlayer(NPC npc, ByteBufferWriter writer, boolean hideAsciiLastName)
|
||||
throws SerializationException {
|
||||
serializeForClientMsgOtherPlayer(npc, writer);
|
||||
}
|
||||
|
||||
public boolean isInSafeZone() {
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(this.getLoc());
|
||||
@@ -211,360 +177,10 @@ public class NPC extends AbstractCharacter {
|
||||
//return this.safeZone;
|
||||
}
|
||||
|
||||
public static void serializeForClientMsgOtherPlayer(NPC npc, ByteBufferWriter writer)
|
||||
throws SerializationException {
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
//num Runes
|
||||
int cnt = 3;
|
||||
boolean isVamp = false, isHealer = false, isArcher = false, isTrainer = false;
|
||||
int contractID = 0, classID = 0;
|
||||
int extraRune = 0;
|
||||
|
||||
if (npc.contract != null) {
|
||||
contractID = npc.contract.getContractID();
|
||||
classID = npc.contract.getClassID();
|
||||
extraRune = npc.contract.getExtraRune();
|
||||
|
||||
if (extraRune == contractID)
|
||||
extraRune = 0;
|
||||
|
||||
}
|
||||
|
||||
if ((contractID > 252642 && contractID < 252647) || contractID == 252652) {
|
||||
isVamp = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (contractID == 252582 || contractID == 252579 || contractID == 252581
|
||||
|| contractID == 252584 || contractID == 252597 || contractID == 252598
|
||||
|| contractID == 252628 || extraRune == 252582 || extraRune == 252579
|
||||
|| extraRune == 252581 || extraRune == 252584 || extraRune == 252597
|
||||
|| extraRune == 252598 || extraRune == 252628) {
|
||||
isHealer = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (contractID == 252570) {
|
||||
isArcher = true;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (classID != 0)
|
||||
cnt++;
|
||||
|
||||
if (extraRune != 0 && extraRune != contractID)
|
||||
cnt++;
|
||||
|
||||
writer.putInt(cnt);
|
||||
|
||||
//Race
|
||||
writer.putInt(1);
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.mobBase != null)
|
||||
writer.putInt(npc.mobBase.getLoadID());
|
||||
else
|
||||
writer.putInt(2011);
|
||||
|
||||
writer.putInt(GameObjectType.NPCRaceRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//Class/Trainer/Whatever
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.contract != null)
|
||||
writer.putInt(contractID);
|
||||
else
|
||||
writer.putInt(2500);
|
||||
|
||||
writer.putInt(GameObjectType.NPCClassRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//vampire trainer
|
||||
cnt = 0;
|
||||
|
||||
if (extraRune != 0)
|
||||
cnt = serializeExtraRune(npc, extraRune, cnt, writer);
|
||||
if (isVamp)
|
||||
cnt = serializeExtraRune(npc, 252647, cnt, writer);
|
||||
|
||||
//Healer trainer
|
||||
if (isHealer)
|
||||
cnt = serializeExtraRune(npc, 252592, cnt, writer);
|
||||
|
||||
if (classID != 0) {
|
||||
writer.putInt(4);
|
||||
writer.putInt(0);
|
||||
writer.putInt(classID);
|
||||
writer.putInt(GameObjectType.NPCExtraRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
}
|
||||
|
||||
//Scout trainer
|
||||
if (isArcher)
|
||||
cnt = serializeExtraRune(npc, 252654, cnt, writer);
|
||||
|
||||
//Shopkeeper
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0x3DACC);
|
||||
writer.putInt(GameObjectType.NPCShopkeeperRune.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
//Send Stats
|
||||
writer.putInt(5);
|
||||
writer.putInt(0x8AC3C0E6); //Str
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xACB82E33); //Dex
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xB15DC77E); //Con
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xE07B3336); //Int
|
||||
writer.putInt(0);
|
||||
writer.putInt(0xFF665EC3); //Spi
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putString(npc.name);
|
||||
writer.putString("");
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
writer.put((byte) 0);
|
||||
writer.putInt(npc.getObjectType().ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
|
||||
writer.putFloat(1.0f);
|
||||
writer.putFloat(1.0f);
|
||||
writer.putFloat(1.0f);
|
||||
|
||||
if (npc.region != null)
|
||||
writer.putVector3f(ZoneManager.convertWorldToLocal(npc.building, npc.getLoc()));
|
||||
else
|
||||
writer.putVector3f(npc.getLoc());
|
||||
|
||||
//Rotation
|
||||
float radians = (float) Math.acos(npc.getRot().y) * 2;
|
||||
|
||||
if (npc.building != null)
|
||||
if (npc.building.getBounds() != null && npc.building.getBounds().getQuaternion() != null)
|
||||
radians += (npc.building.getBounds().getQuaternion()).angleY;
|
||||
|
||||
writer.putFloat(radians);
|
||||
|
||||
//Running Speed
|
||||
writer.putInt(0);
|
||||
|
||||
// get a copy of the equipped items.
|
||||
|
||||
if (npc.equip != null) {
|
||||
writer.putInt(npc.equip.size());
|
||||
|
||||
for (MobEquipment me : npc.equip.values())
|
||||
MobEquipment.serializeForClientMsg(me, writer);
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putInt((npc.level / 10));
|
||||
writer.putInt(npc.level);
|
||||
writer.putInt(npc.getIsSittingAsInt()); //Standing
|
||||
writer.putInt(npc.getIsWalkingAsInt()); //Walking
|
||||
writer.putInt(npc.getIsCombatAsInt()); //Combat
|
||||
writer.putInt(2); //Unknown
|
||||
writer.putInt(1); //Unknown - Headlights?
|
||||
writer.putInt(0);
|
||||
|
||||
if (npc.building != null && npc.region != null) {
|
||||
writer.putInt(npc.building.getObjectType().ordinal());
|
||||
writer.putInt(npc.building.getObjectUUID());
|
||||
} else {
|
||||
writer.putInt(0); //<-Building Object Type
|
||||
writer.putInt(0); //<-Building Object ID
|
||||
}
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
|
||||
//npc dialog menus from contracts
|
||||
|
||||
if (npc.contract != null) {
|
||||
ArrayList<Integer> npcMenuOptions = npc.contract.getNPCMenuOptions();
|
||||
writer.putInt(npcMenuOptions.size());
|
||||
for (Integer val : npcMenuOptions) {
|
||||
writer.putInt(val);
|
||||
}
|
||||
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.put((byte) 1);
|
||||
|
||||
if (npc.building != null) {
|
||||
writer.putInt(GameObjectType.StrongBox.ordinal());
|
||||
writer.putInt(npc.currentID);
|
||||
writer.putInt(GameObjectType.StrongBox.ordinal());
|
||||
writer.putInt(npc.building.getObjectUUID());
|
||||
} else {
|
||||
writer.putLong(0);
|
||||
writer.putLong(0);
|
||||
}
|
||||
|
||||
if (npc.contract != null)
|
||||
writer.putInt(npc.contract.getIconID());
|
||||
else
|
||||
writer.putInt(0); //npc icon ID
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putShort((short) 0);
|
||||
|
||||
if (npc.contract != null && npc.contract.isTrainer()) {
|
||||
writer.putInt(classID);
|
||||
} else {
|
||||
writer.putInt(0);
|
||||
}
|
||||
|
||||
if (npc.contract != null && npc.contract.isTrainer())
|
||||
writer.putInt(classID);
|
||||
else
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
writer.putFloat(4);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
|
||||
//Pull guild info from building if linked to one
|
||||
|
||||
Guild.serializeForClientMsg(npc.guild, writer, null, true);
|
||||
|
||||
writer.putInt(1);
|
||||
writer.putInt(0x8A2E);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
//TODO Guard
|
||||
writer.put((byte) 0); //Is guard..
|
||||
|
||||
writer.putFloat(1500f); //npc.healthMax
|
||||
writer.putFloat(1500f); //npc.health
|
||||
|
||||
//TODO Peace Zone
|
||||
writer.put((byte) 1); //0=show tags, 1=don't
|
||||
writer.putInt(0);
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
|
||||
private static int serializeExtraRune(NPC npc, int runeID, int cnt, ByteBufferWriter writer) {
|
||||
|
||||
writer.putInt(5);
|
||||
writer.putInt(0);
|
||||
writer.putInt(runeID);
|
||||
|
||||
if (cnt == 0)
|
||||
writer.putInt(GameObjectType.NPCClassRuneTwo.ordinal());
|
||||
else
|
||||
writer.putInt(GameObjectType.NPCClassRuneThree.ordinal());
|
||||
|
||||
writer.putInt(npc.currentID);
|
||||
return cnt + 1;
|
||||
}
|
||||
|
||||
public static NPC createNPC(String name, int contractID, Vector3fImmutable spawn, Guild guild, Zone parent, short level, Building building) {
|
||||
|
||||
NPC newNPC = new NPC();
|
||||
|
||||
newNPC.name = name;
|
||||
newNPC.contractUUID = contractID;
|
||||
|
||||
if (building == null)
|
||||
newNPC.bindLoc = spawn;
|
||||
else
|
||||
newNPC.bindLoc = Vector3fImmutable.ZERO;
|
||||
|
||||
newNPC.parentZoneUUID = parent.getObjectUUID();
|
||||
newNPC.guildUUID = guild.getObjectUUID();
|
||||
|
||||
if (building == null)
|
||||
newNPC.buildingUUID = 0;
|
||||
else
|
||||
newNPC.buildingUUID = building.getObjectUUID();
|
||||
|
||||
newNPC.level = level;
|
||||
|
||||
newNPC.buyPercent = .33f;
|
||||
newNPC.sellPercent = 1;
|
||||
|
||||
NPC npc;
|
||||
|
||||
try {
|
||||
npc = DbManager.NPCQueries.PERSIST(newNPC);
|
||||
npc.setObjectTypeMask(MBServerStatics.MASK_NPC);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
npc = null;
|
||||
}
|
||||
|
||||
return npc;
|
||||
}
|
||||
|
||||
public static NPC getNPC(int id) {
|
||||
|
||||
if (id == 0)
|
||||
return null;
|
||||
|
||||
NPC npc = (NPC) DbManager.getFromCache(GameObjectType.NPC, id);
|
||||
|
||||
if (npc != null)
|
||||
return npc;
|
||||
|
||||
return DbManager.NPCQueries.GET_NPC(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters
|
||||
*/
|
||||
|
||||
public static boolean ISGuardCaptain(int contractID) {
|
||||
return MinionType.ContractToMinionMap.containsKey(contractID);
|
||||
}
|
||||
|
||||
public static boolean UpdateEquipSetID(NPC npc, int equipSetID) {
|
||||
|
||||
if (!LootManager._bootySetMap.containsKey(equipSetID))
|
||||
return false;
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
|
||||
return false;
|
||||
|
||||
npc.equipmentSetID = equipSetID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean UpdateRaceID(NPC npc, int raceID) {
|
||||
|
||||
if (!DbManager.NPCQueries.UPDATE_MOBBASE(npc, raceID))
|
||||
return false;
|
||||
|
||||
npc.loadID = raceID;
|
||||
npc.mobBase = MobBase.getMobBase(npc.loadID);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static NPCProfits GetNPCProfits(NPC npc) {
|
||||
return NPCProfits.ProfitCache.get(npc.currentID);
|
||||
}
|
||||
|
||||
public final void submitUpgradeJob() {
|
||||
|
||||
JobContainer jc;
|
||||
@@ -770,9 +386,9 @@ public class NPC extends AbstractCharacter {
|
||||
}
|
||||
|
||||
public float getBuyPercent(PlayerCharacter player) {
|
||||
if (NPC.GetNPCProfits(this) == null || this.guild == null)
|
||||
if (NPCManager.GetNPCProfits(this) == null || this.guild == null)
|
||||
return this.buyPercent;
|
||||
NPCProfits profits = NPC.GetNPCProfits(this);
|
||||
NPCProfits profits = NPCManager.GetNPCProfits(this);
|
||||
if (player.getGuild().equals(this.guild))
|
||||
return profits.buyGuild;
|
||||
if (player.getGuild().getNation().equals(this.guild.getNation()))
|
||||
@@ -782,9 +398,9 @@ public class NPC extends AbstractCharacter {
|
||||
}
|
||||
|
||||
public float getSellPercent(PlayerCharacter player) {
|
||||
if (NPC.GetNPCProfits(this) == null || this.guild == null)
|
||||
if (NPCManager.GetNPCProfits(this) == null || this.guild == null)
|
||||
return 1 + this.sellPercent;
|
||||
NPCProfits profits = NPC.GetNPCProfits(this);
|
||||
NPCProfits profits = NPCManager.GetNPCProfits(this);
|
||||
if (player.getGuild().equals(this.guild))
|
||||
return 1 + profits.sellGuild;
|
||||
if (player.getGuild().getNation().equals(this.guild.getNation()))
|
||||
@@ -913,7 +529,7 @@ public class NPC extends AbstractCharacter {
|
||||
}
|
||||
|
||||
if (this.parentZone.isPlayerCity())
|
||||
if (NPC.GetNPCProfits(this) == null)
|
||||
if (NPCManager.GetNPCProfits(this) == null)
|
||||
NPCProfits.CreateProfits(this);
|
||||
|
||||
//TODO set these correctly later
|
||||
|
||||
@@ -851,7 +851,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
return DbManager.getFromCache(GameObjectType.Building, this.lastTargetID);
|
||||
|
||||
case NPC:
|
||||
return NPC.getFromCache(this.lastTargetID);
|
||||
return NPCManager.getFromCache(this.lastTargetID);
|
||||
|
||||
case Mob:
|
||||
return Mob.getFromCache(this.lastTargetID);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.objects;
|
||||
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ItemProductionMsg;
|
||||
@@ -170,7 +171,7 @@ public class ProducedItem {
|
||||
}
|
||||
|
||||
public boolean finishProduction() {
|
||||
NPC npc = NPC.getFromCache(this.getNpcUID());
|
||||
NPC npc = NPCManager.getFromCache(this.getNpcUID());
|
||||
|
||||
if (npc == null)
|
||||
return false;
|
||||
|
||||
@@ -122,7 +122,7 @@ public class WorldServer {
|
||||
|
||||
public static void trainerInfo(TrainerInfoMsg msg, ClientConnection origin) {
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getObjectID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getObjectID());
|
||||
float sellPercent = 1;
|
||||
|
||||
if (npc != null) {
|
||||
@@ -143,7 +143,7 @@ public class WorldServer {
|
||||
public static void refinerScreen(RefinerScreenMsg msg, ClientConnection origin)
|
||||
throws MsgSendException {
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNpcID());
|
||||
NPC npc = NPCManager.getFromCache(msg.getNpcID());
|
||||
|
||||
if (npc != null)
|
||||
msg.setUnknown02(0); //cost to refine?
|
||||
|
||||
Reference in New Issue
Block a user