Browse Source

New npc creation work.

master
MagicBot 1 year ago
parent
commit
df6b9e48d3
  1. 12
      src/engine/db/handlers/dbNPCHandler.java
  2. 16
      src/engine/objects/NPC.java

12
src/engine/db/handlers/dbNPCHandler.java

@ -38,16 +38,16 @@ public class dbNPCHandler extends dbHandlerBase {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `npc_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { PreparedStatement preparedStatement = connection.prepareStatement("CALL `npc_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
preparedStatement.setLong(1, toAdd.getParentZoneID()); preparedStatement.setLong(1, toAdd.parentZoneUUID);
preparedStatement.setString(2, toAdd.getName()); preparedStatement.setString(2, toAdd.getName());
preparedStatement.setInt(3, toAdd.getContractID()); preparedStatement.setInt(3, toAdd.contractUUID);
preparedStatement.setInt(4, toAdd.getGuildUUID()); preparedStatement.setInt(4, toAdd.guildUUID);
preparedStatement.setFloat(5, toAdd.getSpawnX()); preparedStatement.setFloat(5, toAdd.getSpawnX());
preparedStatement.setFloat(6, toAdd.getSpawnY()); preparedStatement.setFloat(6, toAdd.getSpawnY());
preparedStatement.setFloat(7, toAdd.getSpawnZ()); preparedStatement.setFloat(7, toAdd.getSpawnZ());
preparedStatement.setInt(8, toAdd.getLevel()); preparedStatement.setInt(8, toAdd.level);
preparedStatement.setFloat(9, toAdd.getBuyPercent()); preparedStatement.setFloat(9, toAdd.buyPercent);
preparedStatement.setFloat(10, toAdd.getSellPercent()); preparedStatement.setFloat(10, toAdd.sellPercent);
if (toAdd.getBuilding() != null) if (toAdd.getBuilding() != null)
preparedStatement.setInt(11, toAdd.buildingUUID); preparedStatement.setInt(11, toAdd.buildingUUID);

16
src/engine/objects/NPC.java

@ -66,8 +66,8 @@ public class NPC extends AbstractCharacter {
protected float statLat; protected float statLat;
protected float statLon; protected float statLon;
protected float statAlt; protected float statAlt;
protected float sellPercent; //also train percent public float sellPercent; //also train percent
protected float buyPercent; public float buyPercent;
protected int vendorID; protected int vendorID;
protected ArrayList<Integer> modTypeTable; protected ArrayList<Integer> modTypeTable;
protected ArrayList<Integer> modSuffixTable; protected ArrayList<Integer> modSuffixTable;
@ -77,8 +77,8 @@ public class NPC extends AbstractCharacter {
protected boolean isStatic = false; protected boolean isStatic = false;
private DateTime upgradeDateTime = null; private DateTime upgradeDateTime = null;
private HashSet<Integer> canRoll = null; private HashSet<Integer> canRoll = null;
private int parentZoneID; public int parentZoneUUID;
private int equipmentSetID = 0; public int equipmentSetID = 0;
private int repairCost = 5; private int repairCost = 5;
// New NPC constructor. Fill in the blanks and then call // New NPC constructor. Fill in the blanks and then call
@ -104,7 +104,7 @@ public class NPC extends AbstractCharacter {
this.currentID = this.dbID; this.currentID = this.dbID;
this.setObjectTypeMask(MBServerStatics.MASK_NPC); this.setObjectTypeMask(MBServerStatics.MASK_NPC);
this.contractUUID = rs.getInt("npc_contractID"); this.contractUUID = rs.getInt("npc_contractID");
this.parentZoneID = rs.getInt("parent"); this.parentZoneUUID = rs.getInt("parent");
this.gridObjectType = GridObjectType.STATIC; this.gridObjectType = GridObjectType.STATIC;
this.equipmentSetID = rs.getInt("equipmentSet"); this.equipmentSetID = rs.getInt("equipmentSet");
this.runeSetID = rs.getInt("runeSet"); this.runeSetID = rs.getInt("runeSet");
@ -468,7 +468,7 @@ public class NPC extends AbstractCharacter {
else else
newNPC.bindLoc = Vector3fImmutable.ZERO; newNPC.bindLoc = Vector3fImmutable.ZERO;
newNPC.parentZoneID = parent.getObjectUUID(); newNPC.parentZoneUUID = parent.getObjectUUID();
newNPC.guildUUID = guild.getObjectUUID(); newNPC.guildUUID = guild.getObjectUUID();
if (building == null) if (building == null)
@ -724,7 +724,7 @@ public class NPC extends AbstractCharacter {
return this.parentZone; return this.parentZone;
} }
public int getParentZoneID() { public int getParentZoneUUID() {
if (this.parentZone != null) if (this.parentZone != null)
return this.parentZone.getObjectUUID(); return this.parentZone.getObjectUUID();
@ -891,7 +891,7 @@ public class NPC extends AbstractCharacter {
// Configure parent zone adding this NPC to the // Configure parent zone adding this NPC to the
// zone collection // zone collection
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID);
this.parentZone.zoneNPCSet.remove(this); this.parentZone.zoneNPCSet.remove(this);
this.parentZone.zoneNPCSet.add(this); this.parentZone.zoneNPCSet.add(this);

Loading…
Cancel
Save