|
Custom Script Releases This forum is where you can release your custom scripts for other users to use. Please note: By releasing your scripts here you are submitting them to the public and as such agree to publish them under the GPL licensing terms. The RunUO Team has made its software GPL for you to use and enjoy you should do the same for anything based off of RunUO. |
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
02-02-2007, 07:14 PM | #1 (permalink) |
Lurker
Join Date: Aug 2003
Posts: 17
|
[RunUO 2.0 RC1] Randomized Vendor Prices and Amounts
I never liked the fact that every vendor charges the exact same for a given item, pays the same for said item, and has the same quantity of that item for sale. I wanted some variation in all of the above to simulate a real economy a bit better. After a bit of mashing up code, I came up with the following changes. The result is that buy and sell prices, as well as the amounts, are randomized when the vendor is initially spawned. Each vendor therefore has his or her own pricing scale, meaning that you might want to shop around before purchasing or selling large quantities of items. It adds a bit more roleplay to the game.
The system uses the default sb* files without changes. Originally I was editting every one of them heavily, but was pointed towards modifying the loading functions instead (thanks Lord_Greywolf and Sotho Tal Ker). The functions use the base amounts listed in the sb* files and randomize them as follows: Purchasing from vendor(set in GetRandBuyPriceFor()) Min. Price - 80% of listed price Max. Price 130% of listed price Selling to a vendor(set in GetRandSellPriceFor()) Min. Price - 70% of listed price Max. Price - 120% of listed price Amount of item vendor carries(set in GetRandAmountFor()) Min. Amount - 40% of listed amount Max. Amount - 160% of listed amount You can change the min and max values to whatever you prefer. The functions are weighted so that the majority of the time the values are roughly what's listed in the sb* files, with occasional values much higher or lower. Optionally, you can force the vendor to randomize these numbers every time they restock, rather than only when they're spawned, to better simulate the changing prices in a real economy. Three files are modified: genericbuy.cs, genericsell.cs, and optionally, basevendor.cs. These are all located in the .\scripts\mobiles\vendors\ folder. GenericBuy.cs Change: Code:
public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args ) { amount = 20; m_Type = type; m_Price = price; m_MaxAmount = m_Amount = amount; m_ItemID = itemID; m_Hue = hue; m_Args = args; if ( name == null ) m_Name = (1020000 + (itemID & 0x3FFF)).ToString(); else m_Name = name; } Code:
public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args ) { //amount = 20; m_Type = type; m_Price = GetRandBuyPriceFor( price ); m_MaxAmount = m_Amount = GetRandBuyAmountFor( amount ); m_ItemID = itemID; m_Hue = hue; m_Args = args; if ( name == null ) m_Name = (1020000 + (itemID & 0x3FFF)).ToString(); else m_Name = name; } Code:
public virtual void OnRestock() //may be public void OnRestock() { if ( m_Amount <= 0 ) { Code:
public static int GetRandBuyPriceFor( int itemPrice ) { int lowPrice = (int)( .8 * itemPrice ); int highPrice = (int)( 1.3 * itemPrice ); int price = 0; for ( int i = 1; i <= 3; i++ ) { price += Utility.RandomMinMax( lowPrice, highPrice ); } price /= 3; if ( price < 1 ) price = 1; return price; } public static int GetRandBuyAmountFor( int itemAmount ) { int lowAmount = (int)( .4 * itemAmount ); int highAmount = (int)( 1.6 * itemAmount ); int amount = 0; for ( int i = 1; i <= 3; i++ ) { amount += Utility.RandomMinMax( lowAmount, highAmount ); } amount /= 3; if ( amount < 1 ) amount = 1; return amount; } Change: Code:
public void Add( Type type, int price ) { m_Table[type] = price; m_Types = null; } Code:
public void Add( Type type, int price ) { m_Table[type] = GetRandSellPriceFor( price ); m_Types = null; } public static int GetRandSellPriceFor( int itemPrice ) { int lowPrice = (int)( .7 * itemPrice ); int highPrice = (int)( 1.2 * itemPrice ); int price = 0; for ( int i = 1; i <= 3; i++ ) { price += Utility.RandomMinMax( lowPrice, highPrice ); } price /= 3; if ( price < 1 ) price = 1; return price; } Just below: Code:
public virtual void Restock() { m_LastRestock = DateTime.Now; Code:
LoadSBInfo(); Last edited by the_hopkins; 02-06-2007 at 06:06 PM. Reason: Bugfix |
02-03-2007, 01:15 AM | #2 (permalink) |
Master of the Internet
|
I am very glad you got this working!!!!
Will be giving it a look see - and probaly be using it
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
02-06-2007, 03:44 PM | #5 (permalink) |
Master of the Internet
|
found the little bug in it - but not your bug - the origional bug put in by the runuo staff - you just carried it on
in genericbuy Code:
public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args ) { amount = 20; m_Type = type;
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
02-06-2007, 06:05 PM | #6 (permalink) |
Lurker
Join Date: Aug 2003
Posts: 17
|
Yah, I've got it commented out in the above scripts, but I did forget to highlight it as something you need to change in your own file. That was the first thing I did when I installed RunUO, and I kinda forgot the file didn't come that way. Thanks for pointing that out.
|
02-06-2007, 06:48 PM | #7 (permalink) | |
Forum Expert
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 36
Posts: 3,974
|
Interesting now if you could also make it Region/Map Specific it could be even more "real" by making so that things in Tokuno that are "normal" priced in say Vesper would be ALOT more expensive because of importing. On something like that... also maybe combining it with the Colored ore cost changes that someone provided ages ago on the Forums...
__________________
Quote:
Just a Simple Staff Tool You can leave me messages. Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else." |
|
02-07-2007, 12:05 AM | #8 (permalink) |
Lurker
Join Date: Aug 2003
Posts: 17
|
Greystar:
I was thinking about making prices region specific for my shard, too. That shouldn't really be a problem; the SB* files should be able to be set up to be region specific (I haven't gotten a chance to look into it yet), and my changes will then modify those prices as they normally would. You should just be able to add <using Server.Regions> to the includes in your SB* files, then call whatever property contains the current region and act on that. Switch statements work within SB* files, as do if statements, so you could either (in pseudo-code): Code:
if ( CurrentRegion = Vesper ) { Add GenericBuyInfo with Price = 100 Continue for each item you want to vary in price by region } else if ( CurrentRegion = Tokuno ) { Add GenericBuyInfo with Price = 300 Continue for each item } Code:
Switch ( CurrentRegion ) case Vesper: Add GenericBuyInfo with Price = 100 Continue for each item break case Tokuno: Add GenericBuyInfo with Price = 300 Continue for each item break As for the colored ore price changes, that's high on my list, although I probably wouldn't bundle it in with these changes, because there are several different colored resource packages out there. I'm using Daat99's OWLTR, and Karmageddon (I think) has one, and there's at least one other. I imagine a colored resource pricing mod would need to be tailored specifically for each one. I know when I was rooting around in the code, I spotted a function to alter the price based on the item's quality and I thought it would be an easy matter to just hook into that function and modify price based on color as well (guess it might have been a good idea to write down where the function was, huh? ). |
02-07-2007, 04:59 PM | #10 (permalink) | ||
Forum Expert
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 36
Posts: 3,974
|
Quote:
yeah the best place for it would probably be in the actual sell/buy code, but I'm not too sure and I don't really script anymore and dont even run a shard, but I thought it might be a good idea. Just throwing out suggestions... I've used both Daat99's code and Karmageddons I stopped using Daat99s when it started getting too complicated for what I wanted and went for something easier to edit, both is good code though.
__________________
Quote:
Just a Simple Staff Tool You can leave me messages. Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else." |
||
12-18-2008, 12:48 PM | #12 (permalink) |
Lurker
|
Someone have a version of this excellent script compatible with RunUO RC2 ?
I've a lot of errors when i use it :x Errors: + Mobiles/Vendors/GenericBuy.cs: CS0535: Line 9: 'Server.Mobiles.GenericBuyInfo' does not implement interface member 'Server.IBuyItemInfo.GetEntity()' + Mobiles/Vendors/BeverageBuy.cs: CS0115: Line 29: 'Server.Mobiles.BeverageBuyInfo.GetEntity()': no suitable m ethod found to override + Mobiles/Vendors/PresetMapBuy.cs: CS0115: Line 18: 'Server.Mobiles.PresetMapBuyInfo.GetEntity()': no suitable method found to override :/
__________________
Onirim, Administrator of UO Classic [fr] (uoclassic.free.fr) |
12-23-2008, 04:58 PM | #13 (permalink) |
Forum Novice
Join Date: Feb 2008
Location: UOResurgence.com
Age: 28
Posts: 211
|
If you just put the edits into your original RC2 files as described above (instead of replacing them with the posted .cs files) then the script edits still work fine. The errors are because the GenericBuy and GenericSell files that are modified as posted are from prior to RC2.
Also, post RC2 that line regarding amount is already deleted from the GenericBuy.cs file. (Note that those posts were coming from February 2007, before the change)
__________________
|
Bookmarks |
Tags |
None |
Currently Active Users Viewing This Thread: 1 (1 members and 0 guests) | |
Nockar |
|
|