diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 503a79c5..9f4489b5 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -207,7 +207,7 @@ public class dbNPCHandler extends dbHandlerBase { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?," + " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ," - + " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=? WHERE UID = ?")) { + + " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=?, specialPrice=? WHERE UID = ?")) { preparedStatement.setString(1, npc.getName()); preparedStatement.setInt(2, (npc.getContract() != null) ? npc.getContract().getObjectUUID() : 0); @@ -221,6 +221,7 @@ public class dbNPCHandler extends dbHandlerBase { preparedStatement.setFloat(10, npc.getSellPercent()); preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0); preparedStatement.setInt(12, npc.getDBID()); + preparedStatement.setInt(13, npc.getSpecialPrice()); preparedStatement.executeUpdate(); diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 6b5739ec..bdae3100 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1681,7 +1681,7 @@ public class ClientMessagePump implements NetMsgHandler { return; } - int cost = (int)((toRepair.getMagicValue()/max*(max - dur)) + (npc.getRepairCost() * npc.buyPercent)); + int cost = ((int)((toRepair.getMagicValue()/max*(max - dur)) + (npc.getSpecialPrice() * npc.buyPercent))) + npc.getSpecialPrice(); Building b = (!npc.isStatic()) ? npc.getBuilding() : null; diff --git a/src/engine/net/client/handlers/HirelingServiceMsgHandler.java b/src/engine/net/client/handlers/HirelingServiceMsgHandler.java index 68ee899c..4e1783c9 100644 --- a/src/engine/net/client/handlers/HirelingServiceMsgHandler.java +++ b/src/engine/net/client/handlers/HirelingServiceMsgHandler.java @@ -61,7 +61,7 @@ public class HirelingServiceMsgHandler extends AbstractClientMsgHandler { return true; - npc.setRepairCost(msg.repairCost); + npc.setSpecialPrice(msg.repairCost); ManageNPCMsg outMsg = new ManageNPCMsg(npc); Dispatch dispatch = Dispatch.borrow(player, msg); diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 8772b7c0..e0157315 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -503,7 +503,7 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(0); writer.putString("Repair items"); writer.putString("percent"); - writer.putInt(npc.getRepairCost()); //cost for repair + writer.putInt(npc.getSpecialPrice()); //cost for repair writer.putInt(0); ArrayList modPrefixList = npc.getModTypeTable(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index c9390bbe..853979f4 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -79,7 +79,7 @@ public class NPC extends AbstractCharacter { private HashSet canRoll = null; public int parentZoneUUID; public int equipmentSetID = 0; - private int repairCost = 5; + private int specialPrice = 5; // New NPC constructor. Fill in the blanks and then call // PERSIST. @@ -153,6 +153,12 @@ public class NPC extends AbstractCharacter { this.name = rs.getString("npc_name"); + try { + this.specialPrice = rs.getInt("specialPrice"); + }catch(Exception e){ + this.specialPrice = 5; + } + } catch (Exception e) { Logger.error("NPC: " + this.dbID + " :" + e); e.printStackTrace(); @@ -1290,12 +1296,13 @@ public class NPC extends AbstractCharacter { return name; } - public int getRepairCost() { - return repairCost; + public int getSpecialPrice() { + return specialPrice; } - public void setRepairCost(int repairCost) { - this.repairCost = repairCost; + public void setSpecialPrice(int specialPrice) { + this.specialPrice = specialPrice; + DbManager.NPCQueries.updateDatabase(this); } public void processUpgradeNPC(PlayerCharacter player) {