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!

~Custom Vendor On The Fly~

alambik

Sorceror
~Custom Vendor On The Fly~

Custom Vendors On The Fly
-UPDATED 21th Feb 2006-
MORE NOW!
A context menu is available on the MyVendorBag:
- Repeat : Dupe the bag with its containt ( very useful for several vendor of same type)
- Copy : After targeting a standard vendor, it creates a bag with the items that the standard vendor is selling. It configure those items to mach the same price and amount.



Brief description:

This script allows to use customizable vendors. Those scripts allow:
- To choose which Item to sell simply by adding them in his backpack
- To make invisible bags of items sold by the vendor
- To allow a "Rate" of price for those items (items more expensive in a shop than another for example)
- To allow the player to sell to the vendor those items at 33% of the price




Instalation:

1) Drag and drop scripts in your custom script folder

2) You have to fix the 2 BUGS in cripts/Mobiles/Vendors/GenericBuy.cs

A )Replace:
-----------

Code:
		public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args )
		{
			amount = 20;

with
----

Code:
		public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args )
		{
			if (amount<1)
			amount = 20;

B) Replace this function:
-------------------------

Code:
		//get a new instance of an object (we just bought it)
		public virtual object GetObject()
		{
			if ( m_Args == null || m_Args.Length == 0 )
				return Activator.CreateInstance( m_Type );

			return Activator.CreateInstance( m_Type, m_Args );
			//return (Item)Activator.CreateInstance( m_Type );
		}


By this one:
-----------

Code:
		//get a new instance of an object (we just bought it)
		public virtual object GetObject()
		{
			object myObject;
			
			if ( m_Args == null || m_Args.Length == 0 )
				myObject=Activator.CreateInstance( m_Type );
			else
				myObject=Activator.CreateInstance( m_Type, m_Args );

			if ( m_Type == typeof(Item) )
			{
				((Item)myObject).ItemID=m_ItemID;
				((Item)myObject).Hue=m_Hue;
                                                                /* Next line not well managed. Commented.*/
				/*((Item)myObject).Name=m_Name;*/
			}

			return myObject;
		}


Optional additional change : FRENCH ONLY AT THE MOMENT


Pour avoir des vendeurs plus amusant:

Dans BaseCreature.cs, ajouter dans le switch de la méthode ChangeAIType :
------------------------------------------------------------------------
Code:
				case AIType.AI_MyVendorAI:
					m_AI = new MyVendorAI(this);
					break;

Dans Scripts\Engines\AI\AI\BaseAI.cs, ajouter dans l'"enum" de AIType :
----------------------------------------------------------------------
Code:
		,AI_MyVendor

Enfin dans MyVendor.cs, au début:
--------------------------------
Mettez m_Language à "1" pour le français
Mettez m_MyVendorAI à "true" pour activer un semblant de conversation.



Known bug:
=========
When creating a MyVendor at the first time, it is sometime possible to see all sold items in double. Don't worry about that: all is fixed automaticaly on the next restart of your server.


Usage:
=====

1) Create a vendor:
[add MyVendor

2) Add a vendor bag (optional):
[add MyVendorBag

3) Put the item you want to sell in this bag:
On each item, use the [props command to modify the value you want:
-Name: name of the object
-Amount: maximum amount of items allow to be sold
-Weight: price of one of this item
-Hue: hue of the sold object

3) Customize the Vendor:
Open the vendor backpack and put the vendor bag with the items in it.
A gump propose you to dupe the bag and all its containt eventually (useful when doing one bag per kind of vendor and wanting to dupe it)

4) Validate the changes:
You MUST double click again on the vendor to validate what you put in the backpack.

5) Customize the vendor rate (optional)
The vendor default rate is 1,0
That is to say that all item are sold at their normal price.
If you set the rate to 0,5 for example, all the items will be sold and bought at half of there defined price.
You can change this rate using [props command on the vendor and DOUBLE CLICK on the vendor to compute the new prices.




HOPE YOU'LL ENJOY!
 

ReFro

Wanderer
Errors

When I added the CVotF files I get 2 errors:

Scripts: Compiling C# scripts...failed (2 errors, 0 warnings)
- Error: Scripts\Customs\MyVendor\MyVendor.cs: CS0117: (line 57, column 18) 'Server.Mobiles.AIType' does not contain a definition for 'AI_MyVendor'
- Error: Scripts\Customs\MyVendor\MyVendor.cs: CS0117: (line 139, column 18) 'Server.Mobiles.AIType' does not contain a definition for 'AI_MyVendor'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Any idea what I am doing wrong?

Thanks
 

hydrox

Wanderer
Since

There' hasn't been an update i will finish off the last few commands,
in basecreature.cs
find the location of
Code:
		public virtual void ChangeAIType(AIType NewAI)
		{
			if ( m_AI != null )
				m_AI.m_Timer.Stop();

			m_AI = null;

			if ( this is BaseFactionGuard )
			{
				m_AI = new FactionGuardAI( (BaseFactionGuard) this );
				return;
			}

			switch (NewAI)
			{
				
				case AIType.AI_Melee:
					m_AI = new MeleeAI(this);
					break;
				case AIType.AI_Animal:
					m_AI = new AnimalAI(this);
					break;
				case AIType.AI_Berserk:
					m_AI = new BerserkAI(this);
					break;
				case AIType.AI_Archer:
					m_AI = new ArcherAI(this);
					break;
				case AIType.AI_Healer:
					m_AI = new HealerAI(this);

make sure you enter what i have put here, rather than what is said

Code:
				case AIType.AI_MyVendor:
					m_AI = new MyVendorAI(this);
					break;

so that it's simlar to this

Code:
		public virtual void ChangeAIType(AIType NewAI)
		{
			if ( m_AI != null )
				m_AI.m_Timer.Stop();

			m_AI = null;

			if ( this is BaseFactionGuard )
			{
				m_AI = new FactionGuardAI( (BaseFactionGuard) this );
				return;
			}

			switch (NewAI)
			{
				
				case AIType.AI_MyVendor:
					m_AI = new MyVendorAI(this);
					break;
				case AIType.AI_Melee:
					m_AI = new MeleeAI(this);
					break;
				case AIType.AI_Animal:
					m_AI = new AnimalAI(this);
					break;

then under baseai.cs
enter
Code:
		,AI_MyVendor
under the "theif" line, where `enum` is...
 
Top