forked from MagicBane/Server
Durability and initial charges migrated to template.
This commit is contained in:
@@ -64,7 +64,7 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
preparedStatement.setInt(2, toAdd.getTemplsteID());
|
||||
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
|
||||
preparedStatement.setInt(4, (short) toAdd.durabilityCurrent);
|
||||
preparedStatement.setInt(5, toAdd.getDurabilityMax());
|
||||
preparedStatement.setInt(5, (int) toAdd.template.item_health_full);
|
||||
|
||||
if (toAdd.getNumOfItems() < 1)
|
||||
preparedStatement.setInt(6, 1);
|
||||
|
||||
@@ -514,7 +514,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += StringUtils.addWS("Qty: "
|
||||
+ df.format(item.getNumOfItems()), 20);
|
||||
output += "Charges: " + (byte) item.chargesRemaining
|
||||
+ '/' + item.getChargesMax();
|
||||
+ '/' + item.template.item_initial_charges;
|
||||
output += newline;
|
||||
output += "Name: " + template.item_base_name;
|
||||
output += newline;
|
||||
|
||||
@@ -75,14 +75,17 @@ public class PrintInventoryCmd extends AbstractDevCmd {
|
||||
int goldCount = 0;
|
||||
|
||||
for (Item item : inventory) {
|
||||
if (item.getItemBase().getType().equals(ItemType.GOLD) == false) {
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID);
|
||||
|
||||
if (item.template.item_type.equals(ItemType.GOLD) == false) {
|
||||
|
||||
String chargeInfo = "";
|
||||
byte chargeMax = item.getChargesMax();
|
||||
int chargeMax = template.item_initial_charges;
|
||||
|
||||
if (chargeMax > 0) {
|
||||
byte charges = (byte) item.chargesRemaining;
|
||||
int charges = item.chargesRemaining;
|
||||
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
||||
}
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
|
||||
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo);
|
||||
} else
|
||||
goldCount += item.getNumOfItems();
|
||||
|
||||
@@ -1246,7 +1246,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
//apply damaged value reduction
|
||||
float durabilityCurrent = (short) sell.durabilityCurrent;
|
||||
float durabilityMax = sell.getDurabilityMax();
|
||||
float durabilityMax = sell.template.item_health_full;
|
||||
float damagedModifier = durabilityCurrent / durabilityMax;
|
||||
cost *= damagedModifier;
|
||||
float bargain = player.getBargain();
|
||||
@@ -1640,7 +1640,8 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
//make sure item is damaged and not destroyed
|
||||
short dur = (short) toRepair.durabilityCurrent;
|
||||
short max = toRepair.getDurabilityMax();
|
||||
short max = (short) toRepair.template.item_health_full;
|
||||
|
||||
//account for durability modifications
|
||||
float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE);
|
||||
max *= (1 + (durMod * 0.01f));
|
||||
|
||||
@@ -2444,13 +2444,14 @@ public class CharacterItemManager {
|
||||
return;
|
||||
|
||||
//don't damage noob gear, hair or beards.
|
||||
if (item.getDurabilityMax() == 0)
|
||||
if (item.template.item_health_full == 0)
|
||||
return;
|
||||
|
||||
if (!item.isCanDestroy())
|
||||
return;
|
||||
|
||||
int dur = (int) (short) item.durabilityCurrent;
|
||||
|
||||
if (dur - amount <= 0) {
|
||||
//destroy the item
|
||||
junk(item);
|
||||
|
||||
@@ -39,8 +39,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public class Item extends AbstractWorldObject {
|
||||
|
||||
private static ConcurrentHashMap<String, Integer> enchantValues = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private short durabilityMax;
|
||||
private byte chargesMax;
|
||||
private final ConcurrentHashMap<AbstractEffectModifier, Float> bonuses = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private final ArrayList<String> effectNames = new ArrayList<>();
|
||||
public Enum.ItemContainerType containerType;
|
||||
@@ -87,7 +85,11 @@ public class Item extends AbstractWorldObject {
|
||||
super(rs);
|
||||
|
||||
this.templsteID = rs.getInt("item_itemBaseID");
|
||||
this.template = ItemTemplate.itemTemplates.get(this.templsteID);
|
||||
|
||||
if (this.template == null)
|
||||
Logger.error("Null template of " + this.templsteID)
|
||||
;
|
||||
// Set container enumeration
|
||||
|
||||
String container = rs.getString("item_container");
|
||||
@@ -115,15 +117,9 @@ public class Item extends AbstractWorldObject {
|
||||
|
||||
this.ownerID = rs.getInt("parent");
|
||||
|
||||
if (this.getItemBase() != null)
|
||||
this.chargesMax = (byte) this.getItemBase().getNumCharges();
|
||||
else
|
||||
this.chargesMax = 0;
|
||||
|
||||
this.chargesRemaining = rs.getByte("item_chargesRemaining");
|
||||
|
||||
this.durabilityCurrent = rs.getShort("item_durabilityCurrent");
|
||||
this.durabilityMax = rs.getShort("item_durabilityMax");
|
||||
|
||||
DbObjectType ownerType;
|
||||
ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID);
|
||||
@@ -221,7 +217,7 @@ public class Item extends AbstractWorldObject {
|
||||
writer.putString(item.customName); // Unknown. pad?
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
|
||||
writer.putFloat((float) item.durabilityMax);
|
||||
writer.putFloat(item.template.item_health_full);
|
||||
writer.putFloat((float) item.durabilityCurrent);
|
||||
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
@@ -708,18 +704,10 @@ public class Item extends AbstractWorldObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte getChargesMax() {
|
||||
return chargesMax;
|
||||
}
|
||||
|
||||
public void setDurabilityCurrent(float value) {
|
||||
this.durabilityCurrent = value;
|
||||
}
|
||||
|
||||
public short getDurabilityMax() {
|
||||
return durabilityMax;
|
||||
}
|
||||
|
||||
public boolean isCanDestroy() {
|
||||
return canDestroy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user