Browse Source

NPC special price option

lakebane2
FatBoy-DOTC 2 weeks ago
parent
commit
6e66659940
  1. 3
      src/engine/db/handlers/dbNPCHandler.java
  2. 2
      src/engine/net/client/ClientMessagePump.java
  3. 2
      src/engine/net/client/handlers/HirelingServiceMsgHandler.java
  4. 2
      src/engine/net/client/msg/ManageNPCMsg.java
  5. 17
      src/engine/objects/NPC.java

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

@ -207,7 +207,7 @@ public class dbNPCHandler extends dbHandlerBase {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?," 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_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.setString(1, npc.getName());
preparedStatement.setInt(2, (npc.getContract() != null) ? npc.getContract().getObjectUUID() : 0); 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.setFloat(10, npc.getSellPercent());
preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0); preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0);
preparedStatement.setInt(12, npc.getDBID()); preparedStatement.setInt(12, npc.getDBID());
preparedStatement.setInt(13, npc.getSpecialPrice());
preparedStatement.executeUpdate(); preparedStatement.executeUpdate();

2
src/engine/net/client/ClientMessagePump.java

@ -1681,7 +1681,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; 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; Building b = (!npc.isStatic()) ? npc.getBuilding() : null;

2
src/engine/net/client/handlers/HirelingServiceMsgHandler.java

@ -61,7 +61,7 @@ public class HirelingServiceMsgHandler extends AbstractClientMsgHandler {
return true; return true;
npc.setRepairCost(msg.repairCost); npc.setSpecialPrice(msg.repairCost);
ManageNPCMsg outMsg = new ManageNPCMsg(npc); ManageNPCMsg outMsg = new ManageNPCMsg(npc);
Dispatch dispatch = Dispatch.borrow(player, msg); Dispatch dispatch = Dispatch.borrow(player, msg);

2
src/engine/net/client/msg/ManageNPCMsg.java

@ -503,7 +503,7 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(0); writer.putInt(0);
writer.putString("Repair items"); writer.putString("Repair items");
writer.putString("percent"); writer.putString("percent");
writer.putInt(npc.getRepairCost()); //cost for repair writer.putInt(npc.getSpecialPrice()); //cost for repair
writer.putInt(0); writer.putInt(0);
ArrayList<Integer> modPrefixList = npc.getModTypeTable(); ArrayList<Integer> modPrefixList = npc.getModTypeTable();

17
src/engine/objects/NPC.java

@ -79,7 +79,7 @@ public class NPC extends AbstractCharacter {
private HashSet<Integer> canRoll = null; private HashSet<Integer> canRoll = null;
public int parentZoneUUID; public int parentZoneUUID;
public int equipmentSetID = 0; public int equipmentSetID = 0;
private int repairCost = 5; private int specialPrice = 5;
// New NPC constructor. Fill in the blanks and then call // New NPC constructor. Fill in the blanks and then call
// PERSIST. // PERSIST.
@ -153,6 +153,12 @@ public class NPC extends AbstractCharacter {
this.name = rs.getString("npc_name"); this.name = rs.getString("npc_name");
try {
this.specialPrice = rs.getInt("specialPrice");
}catch(Exception e){
this.specialPrice = 5;
}
} catch (Exception e) { } catch (Exception e) {
Logger.error("NPC: " + this.dbID + " :" + e); Logger.error("NPC: " + this.dbID + " :" + e);
e.printStackTrace(); e.printStackTrace();
@ -1290,12 +1296,13 @@ public class NPC extends AbstractCharacter {
return name; return name;
} }
public int getRepairCost() { public int getSpecialPrice() {
return repairCost; return specialPrice;
} }
public void setRepairCost(int repairCost) { public void setSpecialPrice(int specialPrice) {
this.repairCost = repairCost; this.specialPrice = specialPrice;
DbManager.NPCQueries.updateDatabase(this);
} }
public void processUpgradeNPC(PlayerCharacter player) { public void processUpgradeNPC(PlayerCharacter player) {

Loading…
Cancel
Save