How to make items stackable

We try to put in new spawn areas, quests, events, items and scripts. This is where you submit your wish.
Locked
Penny
Legendary Scribe
Posts: 210
Joined: Thu Oct 01, 2009 12:05 pm

How to make items stackable

Post by Penny »

Very easy, I will show how this is done for granite.

In Granite.cs, edit this part:

Code: Select all

public BaseGranite( CraftResource resource ) : base( 0x1779 )
		{
			Weight = 10.0;
			Hue = CraftResources.GetHue( resource );
			Stackable = true;	//ADD THIS
			m_Resource = resource;
		}
Then edit the tiledata.mul using a .mul editor (i used UO Mul Editor 0.6.8, found here):

1) Tools menu -> Art browser
2) look for the granite graphics (found it pretty much in the middle)
3) Right click the graphic -> choose "Show tiledata editor"
4) Check the "Generic/Stackable" option
5) Save the changes

Now you'd need to have everyone download the new tiledata.mul, and replace the old one.

Also scripts for stonekeys and graniteboxes would need to be edited so that they work for
stacked granite i.e. when granite is added, the amount in the stack is added, not just one.

Editing StoneWorkersKeys.cs:

Change this:

Code: Select all

public void EndCombine(Mobile from, object o)
 {
            if (o is Item && (((Item)o).IsChildOf(from.Backpack) || ((Item)o).IsChildOf(from.BankBox)))
            {
                Item curItem = o as Item;
                if (curItem is BaseGranite)
                {
                    if (curItem is DullCopperGranite)
                    {
                        if (DullCopper + curItem.Amount > StorageLimit)
                            from.SendMessage("You are trying to add "+ ......
                        else
                        {
                            curItem.Delete();
                            DullCopper = (DullCopper + 1);
                            from.SendGump(new StoneWorkersKeyGump((PlayerMobile)from, this));
                            BeginCombine(from);
                        }
                    }
         .
         . 
         .
Into this:

Code: Select all

public void EndCombine(Mobile from, object o)
        {
	    if (o is Item && (((Item)o).IsChildOf(from.Backpack) || ((Item)o).IsChildOf(from.BankBox)))
            {
                Item curItem = o as Item;
                if (curItem is BaseGranite)
                {
                    if (curItem is DullCopperGranite)
                    {
                        if (DullCopper + curItem.Amount > StorageLimit)
                            from.SendMessage("You are trying to add "+ .....
                        else
                        {
                            DullCopper = (DullCopper + curItem.Amount);     //"+1" -> "curItem.Amount"
                            curItem.Delete();  // moved this one row down
                            from.SendGump(new StoneWorkersKeyGump((PlayerMobile)from, this));
                            BeginCombine(from);
                        }
                    }
And repeat this for every granite type. I dont have the script for granite box, but i think it's
pretty much the same.
Failure is not an option, it's a standard.
User avatar
+Colibri
Administrator
Posts: 4073
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: How to make items stackable

Post by +Colibri »

Aye i know, but the hard part is getting everyone to download the new .mul file. Which will probably create a big chaos about, "why wont they stack for me?"

When the new client is released (i.e. a little fresher client with probably a few more things in it, and the new hues), it will come with a little program that will look for updates on the site and will download the latest .mul files (probably just tiledata and statics).
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
Penny
Legendary Scribe
Posts: 210
Joined: Thu Oct 01, 2009 12:05 pm

Re: How to make items stackable

Post by Penny »

Yeah that is the hard part :P
Failure is not an option, it's a standard.
Kimitsu
Expert Scribe
Posts: 34
Joined: Wed Jan 06, 2010 5:43 am

Re: How to make items stackable

Post by Kimitsu »

will you be able to sit on granite if it's stackable?
Locked