Has anyone figured out a correct calculation for the repair costs and wouldn't mind sharing it?
Thank you.
Thank you.
This is literally off by 1-3 silvers, which is pretty awesome, i'll try playing around with it and see if i can figure out the exact cost, if anything i'll post it here.Quote:
It's in the EO source exactly and I don't think it's changed. Grab it from there.
Edit: Nevermind, I thought it was more complicated than this, so I'll just give it to you. I don't remember when we coded this in, so I'm not sure if this is correct but this is (relatively) from our source.
(uint)(EntryPrice - ItemDurability * EntryPrice / ItemMaxDurability);
where EntryPrice is the price of the item when buying from shop, and the others are self-explanatory. Cross reference that with the EO source and let me know as well.
public static UInt32 ItemRepairCost(Item i)
{
DBItem dbi = new DBItem();
if (Program.ItemDatabase.TryGetValue(i.ItemID, out dbi))
{
int nRecoverDurability = Math.Max(0, i.MaxDurability - i.Durability);
if (nRecoverDurability == 0) return 0;
ItemQuality Quality = (ItemQuality)(i.ItemID % 10);
double QualityMultipier = 0.75d;
switch (Quality)
{
case ItemQuality.Super: QualityMultipier = 1.125d; break;
case ItemQuality.Elite: QualityMultipier = 0.975d; break;
case ItemQuality.Unique: QualityMultipier = 0.9d; break;
case ItemQuality.Refined: QualityMultipier = 0.825d; break;
}
int nRepairCost = 0;
if (dbi[ItemStat.SellGold] > 0)
nRepairCost = (int)Math.Ceiling(((Double)dbi[ItemStat.SellGold] * (Double)nRecoverDurability / (Double)i.MaxDurability) * (Double)QualityMultipier);
nRepairCost = Math.Max(1, nRepairCost);
return (UInt32)nRepairCost;
}
else return 0;
}
(uint)Math.Max(1, EntryPrice * (ItemMaxDura - ItemDura) / ItemDura / 2);
int nRecoverDurability = __max(0, GetInt(ITEMDATA_AMOUNTLIMIT) - GetInt(ITEMDATA_AMOUNT)); if (nRecoverDurability == 0) return 0; int nRepairCost = 0; if (GetInt(ITEMDATA_AMOUNTLIMIT) > 0) nRepairCost = GetInt(ITEMDATA_PRICE) * nRecoverDurability / GetInt(ITEMDATA_AMOUNTLIMIT) / 2; return __max(1, nRepairCost);
public uint GetRepairCost()
{
var quality = ItemtypeQuality;
uint numerator = 10;
switch (quality)
{
case 9: numerator = 15; break;
case 8: numerator = 13; break;
case 7: numerator = 12; break;
case 6: numerator = 11; break;
}
var amount = Amount;
uint amountLimit = AmountLimit;
amountLimit -= amount;
amountLimit += amountLimit * 2;
amountLimit = Kernel.MulDiv(TypeData.Price, amountLimit, (uint)AmountLimit * 4);
amountLimit = Kernel.MulDiv(amountLimit, numerator, 10);
return amountLimit;
}
Is that for the market guy, or general repairing? Bro, you're never on MSN anymore!Quote:
And mine (I believe this is from the CO client.. I can't remember):
Code:public uint GetRepairCost() { var quality = ItemtypeQuality; uint numerator = 10; switch (quality) { case 9: numerator = 15; break; case 8: numerator = 13; break; case 7: numerator = 12; break; case 6: numerator = 11; break; } var amount = Amount; uint amountLimit = AmountLimit; amountLimit -= amount; amountLimit += amountLimit * 2; amountLimit = Kernel.MulDiv(TypeData.Price, amountLimit, (uint)AmountLimit * 4); amountLimit = Kernel.MulDiv(amountLimit, numerator, 10); return amountLimit; }