|
|
@ -12,7 +12,6 @@ package engine.objects; |
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum.*; |
|
|
|
import engine.Enum.*; |
|
|
|
import engine.InterestManagement.WorldGrid; |
|
|
|
import engine.InterestManagement.WorldGrid; |
|
|
|
import engine.exception.SerializationException; |
|
|
|
|
|
|
|
import engine.gameManager.*; |
|
|
|
import engine.gameManager.*; |
|
|
|
import engine.job.JobContainer; |
|
|
|
import engine.job.JobContainer; |
|
|
|
import engine.job.JobScheduler; |
|
|
|
import engine.job.JobScheduler; |
|
|
@ -20,7 +19,6 @@ import engine.jobs.UpgradeNPCJob; |
|
|
|
import engine.math.Bounds; |
|
|
|
import engine.math.Bounds; |
|
|
|
import engine.math.Vector3f; |
|
|
|
import engine.math.Vector3f; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.net.ByteBufferWriter; |
|
|
|
|
|
|
|
import engine.net.Dispatch; |
|
|
|
import engine.net.Dispatch; |
|
|
|
import engine.net.DispatchMessage; |
|
|
|
import engine.net.DispatchMessage; |
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
@ -45,8 +43,6 @@ import static engine.util.StringUtils.wordCount; |
|
|
|
|
|
|
|
|
|
|
|
public class NPC extends AbstractCharacter { |
|
|
|
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
|
|
|
|
// Used for thread safety
|
|
|
|
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
|
|
|
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
|
|
|
private final ArrayList<MobLoot> rolling = new ArrayList<>(); |
|
|
|
private final ArrayList<MobLoot> rolling = new ArrayList<>(); |
|
|
@ -56,11 +52,11 @@ public class NPC extends AbstractCharacter { |
|
|
|
public HashMap<Integer, MobEquipment> equip = null; |
|
|
|
public HashMap<Integer, MobEquipment> equip = null; |
|
|
|
public int runeSetID = 0; |
|
|
|
public int runeSetID = 0; |
|
|
|
public int extraRune2 = 0; |
|
|
|
public int extraRune2 = 0; |
|
|
|
protected int loadID; |
|
|
|
public int loadID; |
|
|
|
protected MobBase mobBase; |
|
|
|
public MobBase mobBase; |
|
|
|
protected String name; |
|
|
|
protected String name; |
|
|
|
protected int dbID; |
|
|
|
protected int dbID; |
|
|
|
protected int currentID; |
|
|
|
public int currentID; |
|
|
|
//used by static npcs
|
|
|
|
//used by static npcs
|
|
|
|
protected Zone parentZone; |
|
|
|
protected Zone parentZone; |
|
|
|
protected float statLat; |
|
|
|
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.
|
|
|
|
//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
|
|
|
|
// 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() { |
|
|
|
public boolean isInSafeZone() { |
|
|
|
|
|
|
|
|
|
|
|
Zone zone = ZoneManager.findSmallestZone(this.getLoc()); |
|
|
|
Zone zone = ZoneManager.findSmallestZone(this.getLoc()); |
|
|
@ -211,360 +177,10 @@ public class NPC extends AbstractCharacter { |
|
|
|
//return this.safeZone;
|
|
|
|
//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 |
|
|
|
* 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() { |
|
|
|
public final void submitUpgradeJob() { |
|
|
|
|
|
|
|
|
|
|
|
JobContainer jc; |
|
|
|
JobContainer jc; |
|
|
@ -770,9 +386,9 @@ public class NPC extends AbstractCharacter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public float getBuyPercent(PlayerCharacter player) { |
|
|
|
public float getBuyPercent(PlayerCharacter player) { |
|
|
|
if (NPC.GetNPCProfits(this) == null || this.guild == null) |
|
|
|
if (NPCManager.GetNPCProfits(this) == null || this.guild == null) |
|
|
|
return this.buyPercent; |
|
|
|
return this.buyPercent; |
|
|
|
NPCProfits profits = NPC.GetNPCProfits(this); |
|
|
|
NPCProfits profits = NPCManager.GetNPCProfits(this); |
|
|
|
if (player.getGuild().equals(this.guild)) |
|
|
|
if (player.getGuild().equals(this.guild)) |
|
|
|
return profits.buyGuild; |
|
|
|
return profits.buyGuild; |
|
|
|
if (player.getGuild().getNation().equals(this.guild.getNation())) |
|
|
|
if (player.getGuild().getNation().equals(this.guild.getNation())) |
|
|
@ -782,9 +398,9 @@ public class NPC extends AbstractCharacter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public float getSellPercent(PlayerCharacter player) { |
|
|
|
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; |
|
|
|
return 1 + this.sellPercent; |
|
|
|
NPCProfits profits = NPC.GetNPCProfits(this); |
|
|
|
NPCProfits profits = NPCManager.GetNPCProfits(this); |
|
|
|
if (player.getGuild().equals(this.guild)) |
|
|
|
if (player.getGuild().equals(this.guild)) |
|
|
|
return 1 + profits.sellGuild; |
|
|
|
return 1 + profits.sellGuild; |
|
|
|
if (player.getGuild().getNation().equals(this.guild.getNation())) |
|
|
|
if (player.getGuild().getNation().equals(this.guild.getNation())) |
|
|
@ -913,7 +529,7 @@ public class NPC extends AbstractCharacter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.parentZone.isPlayerCity()) |
|
|
|
if (this.parentZone.isPlayerCity()) |
|
|
|
if (NPC.GetNPCProfits(this) == null) |
|
|
|
if (NPCManager.GetNPCProfits(this) == null) |
|
|
|
NPCProfits.CreateProfits(this); |
|
|
|
NPCProfits.CreateProfits(this); |
|
|
|
|
|
|
|
|
|
|
|
//TODO set these correctly later
|
|
|
|
//TODO set these correctly later
|
|
|
|