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!

[RunUO 2.0 SVN] Universal Storage Keys

datguy

Sorceror
I got issues with the MasterKey wanting to get deleted on server start :eek:

*Edit*
My own issues with my editing, not Fenn's update sry....Fixed btw
 

Shakhan

Wanderer
Make sure you have the MasterKey.cs file with the rest of the files for this script. When the server wants to delete something on start that usually means there's a reference to it in the save but the server can't find the .cs to load.

...oops.. sorry didn't see your edit :( .. as you were :)
 

Fenn

Wanderer
The issue datguy had was related to an error in a customized item list entry. Although this system is rather flexible and versatile on the frontend (editing keys and such) it looks like it is easy to break if you create your own entry types, and there are bugs.

Feel free to experiment with creating new types of entries, and feel free to post any success stores you have here! But I just want to warn you that it may be hard, if impossible, to undo damage to a production shard if you don't fully test your modifications beforehand and make sure they're stable. I'm sure this goes without saying, but just wanted to put this down as a reminder.

Anyways, got another tiny addition. I meant fix this in yesterday, but it slipped my mind. The list entry that holds special fishing nets has been tweaked, and will now accept (and properly spit out) fabled fishing nets. This should also be able to handle any other custom defined fishing nets, just so long as the custom net is a child class of SpecialFishingNet, and there is no new properties or constructor parameters found in the custom net that is not found in the SpecialFishingNet class.

Update log has been updated. Enjoy!
 

datguy

Sorceror
In the next update the MasterKey gump could you maybe change the Maximum Storage to something like Current Storage & then display the current keycount in gump. Players don't need to know the Max that they don't have:D
 

Hammerhand

Knight
Found a small bug in the Potion Key. When crafting potions, they stack in the backpack and if left stacked when added to the key, they only count as 1 item and you only get one back, even if you added 20. Whereas if the player separates them, then uses either the add or fill from pack buttons, they show correctly. Stacked = 1 item, separate = correct count. I'm sure this will be an easy fix.
 

Fenn

Wanderer
Ok, thanks for the suggestions and bug reports. I've updated the file and the changelog. Also, I tested this with the latest SVN (version 286) and it works great! I bet it'll work great with RC2 as well, but if someone wants to check and confirm this, it would be appreciated!
 

Hammerhand

Knight
Hey Fenn.. good key system. Found another tiny bug tho. RunicToolKey will take ANY runic, but only give hammers in return. So I made one for FletchersTools & another for TinkerTools. Also made one for Marble w/Chisels. Copied the Smith & Wood keys to create 2 of each for ML content. You were right about the adaptability. :D Oh yeah.. made a separate Gems key for the ML gems that are mined up and the brilliant amber from LJ for crafting the ML weapons. Now pretty much ALL the crafting stuff (including new) can be carried around in a backpack. If you or anyone wants, I'll post them here along with yours to save others the "trouble" of the "difficult, terrible & time consuming chore" of modifying them. (I have no life outside of free shards, here & work) lol :rolleyes:
 

kat20

Sorceror
Joeku;740121 said:
Incredible work man.


Yes incredible. This is very cool, I will you these as reward Items on my shard. And again Thanks a million there are great !!!!:)
 

Fenn

Wanderer
Thanks everyone for your kind words. I'm glad to hear you're enjoying this system.

Hammerhand, you say your runic keys convert a runic tinker kit into hammer when it stores? Or does it show the tinker kit quantity properly in the keys, but when you go to withdraw them, they turn into hammers? There used to be a bug like that, but was fixed a little bit ago. Are you sure all your files are the latest version?

On the shard I'm playing right now, we have a runic storage that holds runic hammers, runic sewing kits, runic tinker kits, and runic fletcher's tools. I can add/withdraw a tinker kit with no funky business. I haven't tried out the sewing kit or fletcher's tools yet, though, but I'm hoping they work too.

The shard I developed this on is right off-the-shelf from the SVN, so I haven't directly tested it with the custom runics and such. If you're still having issues, I can spend some time downloading some common custom scripts and mess with it.

As for the ML mining and lumberjack loot, yea, for sure! If you want to post your code, I'd gladly incorporate it in.
 

Hammerhand

Knight
No, the one you posted on here, even the latest one for the runic tool kit takes any runic but only gives hammers. So I did one for fletcher and another for tink. Otherwise, the fletcher & tink kits stored in the runic key come out as hammers and are only usable for smithy skill.
 

Fenn

Wanderer
Ok, to test this, I downloaded a set of runic tools from [URL="http://www.runuo.com/forums/showthread.php?t=83717&highlight=runic+toolls]here[/URL] and then inserted the following into the RunicToolKey.cs EntryStructure definition:

Code:
//note: "RunicTinkerTools" may not be the exact name.. working from memory here
entry.Add( new RunicToolEntry( typeof( RunicTinkerTools ), CraftResource.Valorite, "Valorite" ) );

When I booted up my server, the RunicToolKey could distinguish between the valorite smith hammer and the valorite tinker tools, as I could add/remove both without any issue.

What I suggest, is make sure the type listed in the EntryStructure of the tool(s) is the correct type (eg. RunicTinkerTools or whatever) and not the base class (eg. BaseRunicTool ). Also, make sure you've updated all the files, not just the ones in the Items directory, but also the Main Data Management directory.

Like I said, this works fine for me, as well as the production shard I play on. Unless you're using some different kind of custom runic tools that are misbehaving with the keys, I don't know what else to suggest.
 

Fenn

Wanderer
Very small update. I edited the instructions for modifying the plant gump, and hopefully it should be less confusing. Also, I made a static method under BaseStoreKey:

Code:
public static Item FindItemByType( Container pack, Type type )

This does exactly what the standard Container.FindItemByType method does, except if nothing is found in the specified container, it proceeds to look within that container for any keys, withdraw if found, and return the withdrawn item. This should prove useful for custom scripts requiring certain items in the user's backpack. An example of this is the (probably common) [band and [bandself commands, which require a bandage in the backpack. Repalce every

Code:
pack.FindItemByType( typeof( Bandage ) )

with

Code:
BaseStoreKey.FindItemByType( pack, typeof( Bandage ) )

and your [band,[bandself commands will draw from keys if no bandages are found in the backpack.

Enjoy!
 

Fenn

Wanderer
Very quick little update. An unhandled exception in invalid buttond id's the master key gump has been properly handled. I also quickly made a new list entry that hold repair deeds, and stuck it into the smithy keys example item.

EDIT: Put a few more little gems in based on suggestions from players. The player command [pick looks for a lockpick in the backpack, withdraws from keys if necessary, and brings up the lockpick cursor. Also, there's instructions for modifying the Mark spell so that it will withdraw a rune from the keys if none are found in the backpack. Both of these are optional of course, but you will need to manually add the code to Mark.cs if you want it in.
 

Fenn

Wanderer
Yet another update. This is basically bugfixes and such for items and keys with insurance and blessed status. Also fixed the system so potion kegs can be properly added to potion entries. Details in the changelog!
 

Fenn

Wanderer
Small bug fixes for the list entries. They were not withdrawing properly when you applied a filter, and the gump was always resetting to the first page when you did something. These have both been fixed in the latest version.
 

Aurboda

Sorceror
I just can't thank you enough for these scripts, they are just what we need!

I'm trying to figure a way to have keys accept BaseAddonDeeds in a list. similar to how the treasure maps and special fishing nets are listed.

this is what i added into ItemListEntries:
Code:
	public class BaseAddonDeedListEntry : ItemListEntry 
	{
		public override int GumpWidth{ get{ return 400; } }
		
		public override List<ItemListEntryColumn> Columns
		{
			get
			{
				if( _Columns == null )
				{
					List<ItemListEntryColumn> columns = base.Columns;
					
					//add in specifics for this list type here
					//no special listing for fishing nets
					
					return columns;
				}
				
				return _Columns;
			}
		}
		
		//master constructor, use the net hue to hue the entry
		public BaseAddonDeedListEntry( Item item ) : base ( item, item.GetType().Name, item.Hue - 1 )
		{
		}
		
		//world load constructor
		public BaseAddonDeedListEntry( GenericReader reader ) : base( reader )
		{
		}
		
		//clone constructor
		public BaseAddonDeedListEntry( BaseAddonDeedListEntry entry ) : base( entry )
		{
		}
		
		//this generates an item from what is stored in the entry.  Note no exception handling
		public override Item GenerateItem()
		{
			//this allows for derived classes of fishing net to fit into this entry.
			BaseAddonDeed net = (BaseAddonDeed)Activator.CreateInstance( _Type );
			
			//note: gump hue display is shifted by 1 for some crazy reason
			net.Hue = _Hue + 1;
			
			return net;
		}
		
		
		//this checks if the item you're attempting to create with is proper.  The child classes define specifics for this
		public override bool AllGood( Item item )
		{
			if( !base.AllGood( item ) )
			{
				return false;
			}
			
			//TODO: move this to base class, since the _Type is specified in ListEntry?
			if( !( item is BaseAddonDeed ) )
			{
				return false;
			}
			
			return true;
		}
		
		//this is used to drive the cloning process - derived classes fire their associated clone constructor
		public override ItemListEntry Clone()
		{
			return new BaseAddonDeedListEntry( this );
			
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			
			writer.Write( 0 );
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			
			int version = reader.ReadInt();
		}
		
		
	}

this is the key I come up with
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Solaris.ItemStore;							//for connection to resource store data objects

namespace Server.Items
{
	//item derived from BaseResourceKey
	public class AddonDeedKey : BaseStoreKey
	{
		public override int DisplayColumns{ get{ return 1; } }
		
		public override List<StoreEntry> EntryStructure
		{
			get
			{
				List<StoreEntry> entry = base.EntryStructure;
				
				entry.Add( new ListEntry( typeof( BaseAddonDeed ), typeof( BaseAddonDeedListEntry ), "Fishing Nets" ) );

				return entry;
			}
		}
		
		
		
		[Constructable]
		public AddonDeedKey() : base( 1861 )		//hue 1861
		{
			Name = "Addon Deed Keys";
		}
		
		
		
		//this loads properties specific to the store, like the gump label, and whether it's a dynamic storage device
		protected override ItemStore GenerateItemStore()
		{
			//load the basic store info
			ItemStore store = base.GenerateItemStore();

			//properties of this storage device
			store.Label = "Treasure Hunter's Storage";
			
			store.Dynamic = false;
			store.OfferDeeds = false;
			return store;
		}
		
		//serial constructor
		public AddonDeedKey( Serial serial ) : base( serial )
		{
		}
		
		//events
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			
			writer.Write( 0 );
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			
			int version = reader.ReadInt();
		}
	}



}

The key accepts the deeds, and returns the correct deed, but in the key's gump it doesn't display the name of the deed. is there a way to get the gump to display the type of BaseAddonDeed?
 

Fenn

Wanderer
Awesome idea, Aurboda! You'll be happy to know that you were doing everything right. It turns out I had a slight bug with the gumps, where it was tyring to display hue 0 list item entries incorrectly. I've repaired that bug, and incorporated your work into the release along with a few tweaks and such. Thanks!

Details in changelog as usual.
 

Fenn

Wanderer
Another quick bugfix, for list entry gumps. Details in changelog.

*edited Monday April 7, 2008* To avoid looking like I'm bumping this up unnecessarily, I'll just quickly mention the update here. Small bugfix to block the Fill from Backpack drawing from locked containers.
 

prplbeast

Sorceror
i have a lil ? on the runic tool key

first i would like to say this is sweet & very easy to mod or make more keys to hold things that are not already there & thank you.

ok now a lil prob im having is i tryed adding runic fletcher tools & it all works except the fact that i can nopt add them in game here is how i have it in runictoolkey.cs
Code:
 entry.Add(new RunicToolEntry(typeof(RunicFletcherTool), CraftResource.Pine, "Pine", 0, 30, -5, 3));
the art & the name are all there but when i try to add them it tells me "That cannot be stored in this"
any help would be great
& thanx again great system :D
 
Top