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!

[RUO 2.0+] Economy - Item Appraising & Evaluation

Vorspire

Knight
[RUO 2.0+] Economy - Item Appraising & Evaluation

@"Economy Deluxe",
@"1.0.0.1",
@"GNU/GPL",
@"RunUO 2.0",
@"Vorspire",
@"Rhovanion-PK: CORE",
@"http://www.rpk-uo.com",
@"A simple, innovative system to provide a library of methods designed to appraise the value of any given item.",
@"Includes unique, user-friendly, in-game interface with dynamic options.",
@"Uses simple, safe saving and loading techniques, ensuring your configuration is always constant over server restarts.",
@"Evaluate a trashed item's worth.",
@"Evaluate item worth on a global economy scale.",
@"Evaluate item worth and convert it into a currency value for use with donation pricing."

Use the command: [EcoApp to call the in-game Economy Manager.

File List:
Rich (BB code):
-Economy
--Appraisers
+++Appraiser.cs //Base Appraiser
+++ArmorAppraiser.cs //Armor Appraiser
+++ItemAppraiser.cs //Item Appraiser
+++JewelAppraiser.cs //Jewel Appraiser
+++WeaponAppraiser.cs //Weapon Appraiser
--Gumps
+++EconomyManager.cs //Economy Manager Interface
--Items
+++TrashChest.cs //Trash Chest Using Economy for Reward Evaluation
--Misc
+++EconomyHandler.cs //Handles the Entire Economy System
+++EconomyProfiles.cs //Declares Economy Profiles
--Mobiles
+++ExampleNPC.cs //NPC Using Economy to Evaluate Value of Loot upon Death.

RunUO Boot Log
Rich (BB code):
[Economy Deluxe] Initializing...
[Economy Deluxe] Initialize Success.
[Economy Deluxe] Loading...
[Economy Deluxe] System enabled.
[Economy Deluxe] Loaded 4 appraisers
[Economy Deluxe] Load completed in 0.0 seconds.
 

Attachments

  • Global List.jpg
    Global List.jpg
    158.9 KB · Views: 678
  • Trash Chest List.jpg
    Trash Chest List.jpg
    161.6 KB · Views: 397
  • Appraiser Settings.jpg
    Appraiser Settings.jpg
    212 KB · Views: 461
  • Bonus Items List.jpg
    Bonus Items List.jpg
    170.7 KB · Views: 308
  • Adding a Bonus Item.jpg
    Adding a Bonus Item.jpg
    154.4 KB · Views: 298
  • Economy.rar
    19 KB · Views: 144

Vorspire

Knight
Just for added notes...

The Trash Chest will automatically Evaluate a pile of gold coins as the exact amount of the pile and reward the player with the same amount of gold.
This does not apply to Bank Checks, Gold Bars, or other currency conversions.

If any item is Worthless, including Gold, the system will Evaluate the item at the base Worthless Value, the same applies to Bonus Items, except the bonus is added to the final standard evaluation.
 

Vorspire

Knight
Another example for use with this could be to add an Economy Stone that when placed, links itself to the region it's in, and then have every vendor reference the Economy Stone's Appraisers to evaluate items in their stock.

EG:
Code:
//IEntity, Item
Appraiser.Evaluate( npc.EconomyStone, stockItem );

or

//IEntity, Type
Appraiser.Evaluate( npc.EconomyStone, stockItemType );

I dunno... it's just there :D It could be used for so many things.. not just Gold :D You could even use this to decide how much Experience an Item needs to equip it, or dependig on the Appraiser and Profile used, can be scaled to decide Strength requirements etc.

I would have also included a custom vendor and SBInfo script, if they weren't so damn annoying to edit :D
 
Having an error:

Errors:

+ Customs/Economy/Misc/EconomyHandler.cs:
CS0246: Line 132: The type or namespace name 'CommandEventArgs' could not be
found (are you missing a using directive or an assembly reference?)

Using SVN 299..
 

Vorspire

Knight
Ahh Damnit, even though my RunUO Bootlog claims it is 2.0, it is actually RunUO 1.0 with new Framework Support... I forgot to update the Command System crap... How annoying :D

OK, made sufficient changes. Thanks for that warning.
 

Vorspire

Knight
I'm not entirely sure what it's uses are, for they are many.

This is entirely for staff, well, the interface/manager is...

I just wanted to add some umph into trash rewards, but i also wanted to make this diversable.

So you tell me what you could use it for :p
 

Dreadfull

Sorceror
Basically it allows a player to trash items normally non-sellable and get some worth out of them based off their original value?
 

Vorspire

Knight
Any items, for that matter :p

But this isn't just limited to trash evaluation, see the ExampleEconomyNPC and how it evaluates how much gold it should drop in it's loot OnDeath, by evaluating the loot it drops in total.

This system is ambiguous lol, it has no specific purpose and I only wrote it because I was bored and maybe the coding techniques I have used in the code could be of good reference to anyon needing to build a versatile gump, recursively check items or containers, or figure out how to link something to an item without having to edit the item scripts :D
It can even be referenced for the ways in which it can construct types, search for types, etc, or how to add in special targets or even how to add in fail-safe user prompts :D
 

Mideon

Page
This is an interesting idea, but could you provide a bit more detail on how it works?

How are items appraised? Does the user have to define how much things are worth? Is this handled automatically with set values? Does the system detect how much of something is in the world and adjust worth based on supply demand as well?
 

Vorspire

Knight
Everything in the scripts is annotated with explicit descriptions of what each part of the system does :D


Imagine that you had a simple Trash Chest, and that you created all the standard CommandProperty variables that show up in [props - such as, the Base Worth of an item, and a property that denotes a factor for each property of a certain item...

Take WeaponAppraiser for example...

Imagine it wasn't in it's own class, and all of the properties in that class were hard-coded into the Trash Chest instead, you'd have to edit the de/serialization methods for that item to save/load each property in the Trash Chest.

The basis of this system enables you to appl the WeaponAppraiser properties to any item, without actually editing that item script at all, therefore making the entire system dynamic.

This is still quite confusing for me to describe tbh lol...
Let me see if I can explain this simply...

The Trash Chest constructor contains code that initializes a new instance of WeaponAppraiser and attaches that Appraiser instance to that chest.

Now, the methods used for when an item is dropped into the chest are overridden...
In those methods we call the static method Appraiser.Evaluate( IEntity parent, Item toEval ); where toEval is the reference to the dropped item.

The Appraiser Evaluation detects every Appraiser instance that is associated with the Trash Chest and uses each one to Evaluate the dropped item.

So, if the dropped item is of Type BaseWeapon, all Appraisers that do not handle BaseWeapon will return 0.0 value, but the WeaponAppraiser instance associated with the Trash Chest will evaluate the dropped weapon according to the weapon properties, like Quality, Accuracy, etc and multiply them by the Weapon Appraiser's factor settings.

Given that 'tChest' represents an instance of TrashChest, 'toEval' represents a dropped item of Type BaseWeapon and 'from" represents the player dropping the item:
Code:
//Finds and evaluates the item worth with every Appraiser associated with tChest.
//Calls the method named "OnEvaluated( Item toEval, ref double val )" on each Appraiser instance.

double val = Appraiser.Evaluate( tChest, toEval );

//ItemAppraiser returns 0.0
//ArmorAppraiser returns 0.0
//JewelAppraiser returns 0.0
//WeaponAppraiser returns 50.0

//Turn the val of 50.0 into Gold and give it to the player.
Gold gold = new Gold( (int)val );
from.AddToBackpack( gold );

//Trash the item (delete)
toEval.Delete();

The WeaponAppraiser returned 50.0 for the weapon, because the other appraisers don't evaluate BaseWeapon.
It decided this value based on the WeaponAppraiser settings that you select...
Code:
		public override void OnEvaluated(Item toEval, ref double val)
		{
			if (toEval == null || toEval.Deleted)
				return;

			if (toEval is BaseWeapon)
			{
				val += EvaluateWeapon((BaseWeapon)toEval);
			}

			base.OnEvaluated(toEval, ref val);
		}

		public virtual double EvaluateWeapon(BaseWeapon weapon)
		{
			double val = 0.0;

			val += (w_QualityFactor * (int)weapon.Quality);
			val += (w_DurabilityLevelFactor * (int)weapon.DurabilityLevel);
			val += (w_DamageLevelFactor * (int)weapon.DamageLevel);
			val += (w_AccuracyLevelFactor * (int)weapon.AccuracyLevel);
			val += (w_ArtifactRarityFactor * weapon.ArtifactRarity);
			val += (w_CraftResourceFactor * (int)weapon.Resource);

			if (weapon.Attributes.BonusStr != 0)
				val += (w_BonusStrFactor * weapon.Attributes.BonusStr);

			if (weapon.Attributes.BonusDex != 0)
				val += (w_BonusDexFactor * weapon.Attributes.BonusDex);

			if (weapon.Attributes.BonusInt != 0)
				val += (w_BonusIntFactor * weapon.Attributes.BonusInt);

			if (weapon.Attributes.BonusHits != 0)
				val += (w_BonusHitsFactor * weapon.Attributes.BonusHits);

			if (weapon.Attributes.BonusStam != 0)
				val += (w_BonusStamFactor * weapon.Attributes.BonusStam);

			if (weapon.Attributes.BonusMana != 0)
				val += (w_BonusManaFactor * weapon.Attributes.BonusMana);

			return val;
		};

Those "factors" are editable in-game via the manager interface and are loaded/saved dynamically.


///

The method for Appraiser.Evaluate can also take an extra argument called '(bool) useHighestOffer'

Which will automatically return 'val' as the highest offer from all of the Appraiser instances assocaited with 'tChest', when false, it will combine the total evaluations of all of the assocaited Appraiser instances and return that sum.

I hope that clears some things up :p
 

skills3200

Sorceror
I must say the concept of this script is a amazing idea so great job there on thinking it up and for the time making it.

The ability to reward players for dumping items is brilliant.

I have installed this and managed to get 2gp for a crappy starting dagger. I then did something and managed to crash the server..

Code:
RunUO Version 2.0, Build 3344.39098
Operating System: Microsoft Windows NT 6.0.6000.0
.NET Framework: 2.0.50727.3053
Time: 10/07/2009 15:56:52
Mobiles: 1
Items: 23
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Economy.EconomyManager.CreateViewParentPage()
   at Server.Economy.EconomyManager..ctor(Mobile editor, EconomyManagerPage page, Appraiser appraiser, IEntity parent, Int32 subPage)
   at Server.Economy.EconomyManager.Refresh(Mobile editor, EconomyManagerPage page, Appraiser appraiser, IEntity parent, Int32 subPage)
   at Server.Economy.EconomyManager.OnResponse(NetState sender, RelayInfo info)
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)

Also where have you defined what the chest gives ie gold i would like to make it so it gives something else like tokens or what ever.

Great work on script keep up the good work
 

Vorspire

Knight
The Trash Chest is just another Example of the usage of the system;
The actual Appraiser always returns a double-type value that you can easily manipulate to use with any amount of other items.
 

Lesdat

Sorceror
sounds like a great idea. upon install i get this erroe:

The type namespace "Linq" does not exist in the name space System are you missing an assembly reference?
this is in economyProfiles.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;//<--------------------- this ?
using System.Text;

namespace Server.Economy
{
    /// <summary>
    /// Economy Profile Index
    /// </summary>
    public enum EconomyProfile
    {
        Default = 0,
        Poor = 1,
        Mediocre = 2,
        Rich = 3,
        FilthyRich = 4,
        Royalty = 5,
        ShoopDaWoop = 6
    }

    public class EconomyProfiles
    {
        /// <summary>
        /// Profile Factor Library.
        /// This should always be the same length as the Profile Index.
        /// </summary>
        public static double[] ProfileFactors = new double[]
        {
            1.0, //Default
            1.3, //Poor
            1.6, //Mediocre
            2.0, //Rich
            2.5, //FilthyRich
            5.0, //Royalty
            10.0, //ShoopDaWoop
        };
    }
}
Using Run uo 2.1.3993.2599
 
Top