Repair costs?

03/27/2012 14:17 BlooD-BoY#1
Has anyone figured out a correct calculation for the repair costs and wouldn't mind sharing it?

Thank you.
03/27/2012 14:54 Lateralus#2
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.
03/27/2012 18:22 BlooD-BoY#3
Quote:
Originally Posted by Lateralus View Post
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.
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.

Thank you.
03/27/2012 22:31 .Kinshi#4
Pretty sure I had a version of this in the source I released.

Code:
        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;
        }
03/29/2012 14:36 Lateralus#5
Here's the real calculation gotten from the EO source.

Mine:
Code:
(uint)Math.Max(1, EntryPrice * (ItemMaxDura - ItemDura) / ItemDura / 2);
TQ's:
Code:
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);
Test mine out and see if it's exact.
03/29/2012 17:15 Korvacs#6
Yours is crazy complicated Kinshi =x
03/29/2012 17:33 ×Holo#7
Quote:
Originally Posted by Korvacs View Post
Yours is crazy complicated Kinshi =x
truedat o.o
03/29/2012 18:00 Lateralus#8
Quote:
Originally Posted by Korvacs View Post
Yours is crazy complicated Kinshi =x
I think his is for repairing the maximum durability from that guy in the market.

Edit: Actually, maybe not. =o
03/29/2012 18:41 .Kinshi#9
Quote:
Originally Posted by Korvacs View Post
Yours is crazy complicated Kinshi =x
I coded that a long time ago, so yup :P
And it is perfect, so that's good :D
03/31/2012 00:44 nTL3fTy#10
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;
        }
03/31/2012 08:45 Lateralus#11
Quote:
Originally Posted by nTL3fTy View Post
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;
        }
Is that for the market guy, or general repairing? Bro, you're never on MSN anymore!
03/31/2012 09:46 nTL3fTy#12
Quote:
Originally Posted by Lateralus View Post
Is that for the market guy, or general repairing? Bro, you're never on MSN anymore!
It should be general repairing, and I know. :(
03/31/2012 09:55 Lateralus#13
Quote:
Originally Posted by nTL3fTy View Post
It should be general repairing, and I know. :(
I'm guessing then that EO repairing differs from CO then; what I posted above was gotten from the EO source.
03/31/2012 10:50 Kiyono#14
Quote:
Originally Posted by Lateralus View Post
I'm guessing then that EO repairing differs from CO then; what I posted above was gotten from the EO source.
Still, does it matter that much? The other poster said your version was only few silvers off anyway.
03/31/2012 11:27 Lateralus#15
Quote:
Originally Posted by Kiyono View Post
Still, does it matter that much? The other poster said your version was only few silvers off anyway.
Of course it matters - it's either correct or wrong.