ServUO Version
Publish Unknown
Ultima Expansion
Mondain's Legacy
I have a Quest on my RunUO version 2.0 Server (that I downloaded a few years ago) to obtain 'Music Scrolls' for a 'Music Box'. The quest has a chance to drop one of 51 songs and players have fun trying to collect them all.

My problem is, the music scrolls are not 'Stackable' so players end up with countless duplicates that become a pain to store and organize. So far I have been unable to script the files involved to make the scrolls 'Stack'.

1) I have checked the graphic in TileData.mul and the Stack flags are set properly.

2) I have edited the 'Song Scroll' files trying to make them 'Stackable' but the usual approach does not work. They just don't want to 'Stack'.

Can someone in the community please take a look at this problem and help me find a solution?

Here is the MusicBoxTrack.cs file I have:

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using Server.ContextMenus;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Items.MusicBox
{
    public class MusicBoxTrack : Item
    {
        private int m_Track;
        public int Track { get { return m_Track; } set { m_Track = value; InvalidateProperties(); } }
        private MusicName m_Song;
        public MusicName Song { get { return m_Song; } set { m_Song = value; InvalidateProperties(); } }

        public override int LabelNumber { get { return m_Track; } }



        public MusicBoxTrack( int track )
            : base(0x2830)
        {
            m_Track = track;
            Name = "Organ Song Track";
            Weight = 1.0;

        }

        public MusicBoxTrack(Serial s)
            : base(s)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            from.SendLocalizedMessage(LabelNumber);
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); // version
            writer.Write((int)m_Track);
            writer.Write((int)m_Song);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
            m_Track = reader.ReadInt();
            m_Song = (MusicName)reader.ReadInt();
        }
    }
}

and . . Here is a sample of one of the Music Scroll files I have edited trying to make it 'Stackable':
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using Server.ContextMenus;
using Server.Network;
using Server.Mobiles;
using Server.Items;

namespace Server.Items.MusicBox
{
    public class DeathTuneSong : MusicBoxTrack
    {

        [Constructable]
        public DeathTuneSong() : this( 1 )
        {
        }

        [Constructable]
        public DeathTuneSong( int amount )
            : base(1075171)
        {
            Stackable = true;
            Amount = amount;
            Song = MusicName.Death;
            //Name = "Death Tune";
        }

        public DeathTuneSong(Serial s)
            : base(s)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}

On the surface (to me) this should work but it doesn't. Can anyone see why?

Many thanks for taking the time to look at this.
 
Thanks Mr Riots. As I said . . "I have checked the graphic in TileData.mul and the Stack flags are set properly."

It's a head scratcher.
 
Hello Hestia . . No I do not have the Generic box checked. Is that a problem? I never understood what that setting was for.

I really appreciate your (and everyone's) time on this.
 
Yes, check mark the Generic box, in tile data, that is what will make items stackable. Make sure you patch all your files. (such as, the client you use for your server, and any others you may have.
After you fix your tile data. You need to do like you did in the example script above. make it stackable in the script.
 
I have a question

When using 10 overlapping scrolls

It doesn't disappear one by one, but the scroll itself disappears

This is the script

Code:
    public class BaneTarget : Target
    {
        private BaneScroll m_Scroll;

        public BaneTarget( BaneScroll scroll ) : base( 1, false, TargetFlags.None )
        {
            m_Scroll = scroll;
        }

        protected override void OnTarget( Mobile from, object target )
        {

         if ( target is BaseMeleeWeapon )
            {
                BaseWeapon item = (BaseWeapon) target;
               
            if( item.RootParent != from )
                    from.SendMessage( "You need to have it in your backpack" );
            else if( item.BlessedFor != null && item.BlessedFor != from )
                    from.SendMessage( "This is not yours" );
            else if( item.ExtendedWeaponAttributes.Bane > 0 )
                    from.SendMessage( "This already have Battle Lust" );
            else if(0.3 > Utility.RandomDouble())
            {
                    item.Delete();
                    from.SendMessage( "Enchant failed, your have destroyed your weapon" );
                    m_Scroll.Delete();
            }
                else
                {
                    item.ExtendedWeaponAttributes.Bane = 1;
                    item.BlessedFor = from;
                    from.SendMessage( "Successfully added" );
                    m_Scroll.Delete();
                }
            }
            else
                from.SendMessage( "Only on weapon" );
        }
    }
I want the scroll to disappear one by one when I use it

m_Scroll.Delete(); What should I add to this command

I think, but I don't know which one to put in

I don't think it has much to do with this article, but I think it does

I'd like to get some help
 
Thanks Hestia . . Ticking off the 'Generic' box in TileData.mul worked . . and I learned something *smiles*
Also . . as Pyro pointed out above . . I added 'target.Consume (1)' so players would not lose an entire stack.

Thank you both so much for your time and help.

*bows*
 
since you just want to consume 1 you dont need to use Consume(1)
Consume() would be fine.

But both do the same :) just a general info
 
Back