Browse Source

Cleanup of value handling

combat-2
MagicBot 8 months ago
parent
commit
a1f233723f
  1. 2
      src/engine/net/client/handlers/VendorBuyMsgHandler.java
  2. 14
      src/engine/objects/Item.java

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

@ -90,7 +90,7 @@ public class VendorBuyMsgHandler extends AbstractClientMsgHandler { @@ -90,7 +90,7 @@ public class VendorBuyMsgHandler extends AbstractClientMsgHandler {
if (!itemMan.hasRoomInventory(me.template.item_wt))
return true;
int cost = me.magicValue;
int cost = me.getValue();
float bargain = sourcePlayer.getBargain();

14
src/engine/objects/Item.java

@ -1152,10 +1152,20 @@ public class Item extends AbstractWorldObject { @@ -1152,10 +1152,20 @@ public class Item extends AbstractWorldObject {
*/
public int getValue() {
int modifiedValue;
if (this.flags.contains(ItemFlags.Identified))
return this.magicValue;
modifiedValue = this.magicValue;
else
modifiedValue = this.value;
if (this.template.item_initial_charges > 0)
modifiedValue = modifiedValue * (this.chargesRemaining / this.template.item_initial_charges);
if (this.template.combat_health_full > 0)
modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.combat_health_full));
return this.value;
return modifiedValue;
}
/**

Loading…
Cancel
Save