Mikthebug

Member
So i have a vendor that buys a lot of the custom stuff i have made, and i want him to sell it back but at a set price.
He only sells the stuff that someone has already sold to him but it has the normal 1.9 increse in price from GenericSell.cs.
And i don't want to change that for everything but only for this vendor and the stuff the sells/buys from the players.
Can something be done in the vendor SB file?

My first idea was to make a code block like this from GenericSell.cs
C#:
            if (item is BaseArmor)
            {
                BaseArmor armor = (BaseArmor)item;

                if (armor.Quality == ItemQuality.Low)
                    price = (int)(price * 0.60);
                else if (armor.Quality == ItemQuality.Exceptional)
                    price = (int)(price * 1.25);

                price += 100 * (int)armor.Durability;

                price += 100 * (int)armor.ProtectionLevel;

                if (price < 1)
                    price = 1;
            }
But i'm not really sure how to get around that they are all diffrent objects armor, weapon etc.

Thankful for any help and ideas :)
 
if you had special armor/weapons named UberWepOne, UberWepTwo, and UberArmorOne and you wanted a specific price for them you could:

C#:
            if (item is UberWepOne)
            {
                price = 5000;
            }
            else if (item is UberWepTwo)
            {
                price = 7000;
            }
            else if (item is UberArmorOne)
            {
                price = 25000;
            } //ect......
 
I get no errors with it but it's still the 1.9 price that is on the vendor.
Maybe i'm doing it wrong in some way?
Line 90-93
GenericSell.cs:
using System;
using System.Collections.Generic;
using Server.Items;
using System.Linq;

namespace Server.Mobiles
{
    public class GenericSellInfo : IShopSellInfo
    {
        private readonly Dictionary<Type, int> m_Table = new Dictionary<Type, int>();
        private Type[] m_Types;
        public GenericSellInfo()
        {
        }

        public Type[] Types
        {
            get
            {
                if (m_Types == null)
                {
                    m_Types = new Type[m_Table.Keys.Count];
                    m_Table.Keys.CopyTo(m_Types, 0);
                }

                return m_Types;
            }
        }
        public void Add(Type type, int price)
        {
            m_Table[type] = price;
            m_Types = null;
        }

        public int GetSellPriceFor(Item item)
        {
            return GetSellPriceFor(item, null);
        }

        public int GetSellPriceFor(Item item, BaseVendor vendor)
        {
            int price = 0;
            m_Table.TryGetValue(item.GetType(), out price);

            if (vendor != null && BaseVendor.UseVendorEconomy)
            {
                IBuyItemInfo buyInfo = vendor.GetBuyInfo().OfType<GenericBuyInfo>().FirstOrDefault(info => info.EconomyItem && info.Type == item.GetType());

                if (buyInfo != null)
                {
                    int sold = buyInfo.TotalSold;
                    price = (int)((double)buyInfo.Price * .75);

                    return Math.Max(1, price);
                }
            }

            if (item is BaseArmor)
            {
                BaseArmor armor = (BaseArmor)item;

                if (armor.Quality == ItemQuality.Low)
                    price = (int)(price * 0.60);
                else if (armor.Quality == ItemQuality.Exceptional)
                    price = (int)(price * 1.25);

                price += 100 * (int)armor.Durability;

                price += 100 * (int)armor.ProtectionLevel;

                if (price < 1)
                    price = 1;
            }
            else if (item is BaseWeapon)
            {
                BaseWeapon weapon = (BaseWeapon)item;

                if (weapon.Quality == ItemQuality.Low)
                    price = (int)(price * 0.60);
                else if (weapon.Quality == ItemQuality.Exceptional)
                    price = (int)(price * 1.25);

                price += 100 * (int)weapon.DurabilityLevel;

                price += 100 * (int)weapon.DamageLevel;

                if (price < 1)
                    price = 1;
            }
            else if (item is EarthCrusher)
            {   
                price = 10000;
            }
            else if (item is BaseBeverage)
            {
                int price1 = price, price2 = price;

                if (item is Pitcher)
                {
                    price1 = 3;
                    price2 = 5;
                }
                else if (item is BeverageBottle)
                {
                    price1 = 3;
                    price2 = 3;
                }
                else if (item is Jug)
                {
                    price1 = 6;
                    price2 = 6;
                }

                BaseBeverage bev = (BaseBeverage)item;

                if (bev.IsEmpty || bev.Content == BeverageType.Milk)
                    price = price1;
                else
                    price = price2;
            }

            return price;
        }

        public int GetBuyPriceFor(Item item)
        {
            return GetBuyPriceFor(item, null);
        }

        public int GetBuyPriceFor(Item item, BaseVendor vendor)
        {
            return (int)(1.90 * GetSellPriceFor(item, vendor));
        }

        public string GetNameFor(Item item)
        {
            if (item.Name != null)
                return item.Name;
            else
                return item.LabelNumber.ToString();
        }

        public bool IsSellable(Item item)
        {
            if (item.QuestItem)
                return false;

            //if ( item.Hue != 0 )
            //return false;

            return IsInList(item.GetType());
        }

        public bool IsResellable(Item item)
        {
            if (item.QuestItem)
                return false;

            //if ( item.Hue != 0 )
            //return false;

            return IsInList(item.GetType());
        }

        public bool IsInList(Type type)
        {
            return m_Table.ContainsKey(type);
        }
    }
}
 
It would need to go before the basearmor check otherwise basearmor/baseweapon would pick it up and it would never get to the part your needing.
C#:
            if (item is EarthCrusher)
            {   
                price = 10000;
            }
            else if (item is BaseArmor)
 
Thanks, that did work but it was not what i had in mind although i did mange to fix it thanks to you. i Just had to put it in a different place, now i just need to figure out how to give all the custom stuff a unic tag that can be used to that i don't have to list every item in here :)
C#:
        public int GetBuyPriceFor(Item item, BaseVendor vendor)
        {
            if (item is EarthCrusher)
                return (int)(10 * GetSellPriceFor(item, vendor));
            else   
                return (int)(1.90 * GetSellPriceFor(item, vendor));
        }
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back