RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Vendors

awdball

Sorceror
Vendors

Q1) How do I increase how often my vendors restock?
Q2) How do I change the minimum amount they stock?

================================================

A1) This is mostly controlled by the RestockDelay method on the BaseVendor class. The Restock method on the BaseVendor class is called whenever someone tries to buy from them, just before they show their wares, if the time since their last restock is greater than the value returned by RestockDelay.

Looking in Scripts\Mobiles\Vendors\BaseVendor.cs at Line 152 through 158 ( in both V1RC0 and Beta 36 )
Code:
                public virtual TimeSpan RestockDelay
                {
                        get
                        {
                                return TimeSpan.FromHours( 1 );
                        }
                }
Changing this to
Code:
                public virtual TimeSpan RestockDelay
                {
                        get
                        {
                                return TimeSpan.FromMinutes( 15 );
                        }
                }
Will get them to restock every fifteen minutes instead of every hour.

================================================

A2) The initial stock on hand is defined when the GenericBuyInfo is created. However the ongoing stocking level is controlled by the OnRestock method in GenericBuyInfo. If all the stock is bought up then on the next restock the vendor 'orders more'. If there's too much leftovers then the vendor reduces his stock by half.

Looking in Scripts\Mobiles\Vendors\GenericBuy.cs at Line 138 in V1RC0 (line 137 in Beta36) we find the OnRestock method. The lines (arround 159) to pay attention to, read as follows:
Code:
                                else if ( halfQuantity > 20 )
                                        halfQuantity /= 2;

                                if ( m_Amount >= halfQuantity )
                                        m_MaxAmount = halfQuantity;
If this is changed to
Code:
                                else if ( halfQuantity > 80 )
                                        halfQuantity /= 2;

                                if ( m_Amount >= halfQuantity )
                                        m_MaxAmount = halfQuantity;
Then none of your vendors will ever stock less than 80. NOTE because of the way this gets halved each time from 640 down, 80 works as expected, but if we had 64 as the number then the vendor would end up stocking 40. If you want to control inventory to a specific minimum level, say 11 for example, then changing to:
Code:
                                else
                                        halfQuantity /= 2;

                                if ( m_Amount >= halfQuantity )
                                        m_MaxAmount = Math.Max(halfQuantity,11);
will do what you want.

If you always wanted 999 stock on hand then replacing the whole method with
Code:
                public void OnRestock()
                {
                        m_Amount = 999;
                }
would work.
-----------------------------------------------------------------------------------------------------------------------------------
awdball · NON-beligerent Forum Member · · · · ;^) · · · · RUNUO-FAQ · · [CODE] Post CODE inside tags [/CODE]
The team for moderation on RUNUO Forums · · · · HelpSomeone · · CAPitalizaTION Counts m_BeCareful!
(old school c coder learning and luvin c#) · · · · · · · Great C# Tutorial
 
Top