Carlos_ar

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
Greetings All!

So I have an odd item I'm working on. I want to make an Addon of a Sarcophagus in the closed position. Once it is placed in a player's house, they can double click it and it will switch to the open position (with skeleton), dclick again and the lid disappears, dclick again and it switches to the lidded open position without the skele, then back to closed on the last dclick.

Essentially it will be the closed Sarcophagus with the ability to change the appearance on dclick.

Is there an item that does something similar already in game? Or perhaps can someone nudge me in the direction that I can figure it out?

Thanks in advance!
 
You should be able to do it by checking the ItemID of the component that was used to see if it matches the initial ItemID, then change to the new ItemID.
This should work for both opening and closing actions.

An example of an item that does something similar would be BaseLight as it switches btween On/Off ID's. You can also look at levers and switches too.

With addons, you'll need to override OnComponentUsed() instead of OnDoubleClick.
 
You should be able to do it by checking the ItemID of the component that was used to see if it matches the initial ItemID, then change to the new ItemID.
This should work for both opening and closing actions.

An example of an item that does something similar would be BaseLight as it switches btween On/Off ID's. You can also look at levers and switches too.

With addons, you'll need to override OnComponentUsed() instead of OnDoubleClick.

Thank you Voxpire! I JUST found a great example in the Curtains as well. Diving in to how that works, then to figure out how to do more than one Component class.
*****************
So in this same line... is there a null tile or something you can add to an addon? The closed sarcophagus is 8 tiles and the open one is 10. Meaning there are 2 tiles that aren't used when it is closed.
 
Last edited:
Well... what I have so far.

The deed gives you the choice between East or South facing CLOSED sarcophagi. When you dclick them, they open, revealing a skele inside.

**Want to add partially open sarcophagi and 5 stages; closed, partial open with skele, open with skele, open empty, partial open empty.

Opening Sarcophagi Addons:
using System;
using Server.Gumps;
using Server.Multis;
using Server.Network;

namespace Server.Items
{
    public class KingSarcophagusComponent : AddonComponent
    {
        private int m_OpenLidID;
        
        [CommandProperty(AccessLevel.GameMaster)]
        public int OpenLidID
        {
            get
            {
                return m_OpenLidID;
            }
            set
            {
                m_OpenLidID = value;
            }
        }
        
        public KingSarcophagusComponent (int itemID, int openlidID)
            :base (itemID)
        {
            m_OpenLidID = openlidID;
            
        }
        
        public KingSarcophagusComponent (Serial serial)
            :base(serial)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
            
            if (Addon != null)
            {
                if (from.InRange(Location, 3))
                {
                    foreach (AddonComponent c in Addon.Components)
                    {
                        if (c is KingSarcophagusComponent)
                        {

                            KingSarcophagusComponent kingsarcophagus = (KingSarcophagusComponent)c;                           
                            int temp = kingsarcophagus.ItemID;
                            kingsarcophagus.ItemID = kingsarcophagus.OpenLidID;
                            kingsarcophagus.OpenLidID = temp;
                        }
                    }
                }
                else
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); //I can't reach that.
            }
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt(0); // version

            writer.Write(m_OpenLidID);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();

            m_OpenLidID = reader.ReadInt();
        }       
    }
    
    public class KingSarcophagusAddon : BaseAddon
    {
        public override BaseAddonDeed Deed => new KingSarcophagusDeed();
        [Constructable]
        public KingSarcophagusAddon(bool east)
            : base ()
        {
            if (east)
            {
                AddComponent(new KingSarcophagusComponent(7340, 7349), 0, 1, 0);
                AddComponent(new KingSarcophagusComponent(7339, 7557), 0, 0, 0);
                AddComponent(new KingSarcophagusComponent(7338, 7556), 0, -1, 0);
                AddComponent(new KingSarcophagusComponent(7337, 7555), 1, -1, 0);
                AddComponent(new KingSarcophagusComponent(7336, 7554), 1, 0, 0);
                AddComponent(new KingSarcophagusComponent(7335, 7553), 1, 1, 0);
            }
            else // south
            {
                
                AddComponent(new KingSarcophagusComponent(7292, 7301), 1, 0, 0);
                AddComponent(new KingSarcophagusComponent(7291, 7527), 0, 0, 0);
                AddComponent(new KingSarcophagusComponent(7290, 7526), -1, 0, 0);
                AddComponent(new KingSarcophagusComponent(7289, 7525), -1, 1, 0);
                AddComponent(new KingSarcophagusComponent(7288, 7524), 0, 1, 0);
                AddComponent(new KingSarcophagusComponent(7287, 7523), 1, 1, 0);
            }
        }
    
    
     public KingSarcophagusAddon(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt(0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();
        }
    }
                
    public class KingSarcophagusDeed : BaseAddonDeed
    {
        public override BaseAddon Addon => new KingSarcophagusAddon(m_East);
        

        private bool m_East;

        [Constructable]
        public KingSarcophagusDeed()
            : base()
        {
            LootType = LootType.Blessed;
        }

        public KingSarcophagusDeed(Serial serial)
            : base(serial)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(InternalGump));
                from.SendGump(new InternalGump(this));
            }
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }

        private void SendTarget(Mobile m)
        {
            base.OnDoubleClick(m);
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt(0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();
        }

        private class InternalGump : Gump
        {
            private readonly KingSarcophagusDeed m_Deed;

            public InternalGump(KingSarcophagusDeed deed)
                : base(60, 36)
            {
                m_Deed = deed;

                AddPage(0);

                AddBackground(0, 0, 273, 324, 0x13BE);
                AddImageTiled(10, 10, 253, 20, 0xA40);
                AddImageTiled(10, 40, 253, 244, 0xA40);
                AddImageTiled(10, 294, 253, 20, 0xA40);
                AddAlphaRegion(10, 10, 253, 304);
                AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0);
                AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL
                AddHtmlLocalized(14, 12, 273, 20, 1076581, 0x7FFF, false, false); // Please select your curtain position

                AddPage(1);

                AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South
                AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0);
                AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East
            }

            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0)
                    return;

                m_Deed.m_East = (info.ButtonID != 1);
                m_Deed.SendTarget(sender.Mobile);
            }
        }
    }
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back