MrRiots

Self-proclaimed Legend
Moderator
ServUO Version
Publish 58
Ultima Expansion
Endless Journey
Hi!

So I have an issue with the Personal Bless Deeds not adding a tag (Blessed by) on the items. Which seems confusing.

C#:
        [Constructable]
        public PersonalBlessDeed(Mobile owner)
            : base(0x14F0)
        {
            Weight = 1.0;
            LootType = LootType.Blessed;
            Owner = owner;
            InvalidateProperties();
        }

        public PersonalBlessDeed(Serial serial)
            : base(serial)
        {
            Weight = 1.0;
            LootType = LootType.Blessed;
        }

        public override bool DisplayLootType => true;

        [CommandProperty(AccessLevel.GameMaster)]
        public Mobile Owner
        {
            get
            {
                return m_Owner;
            }
            set
            {
                m_Owner = value;
                InvalidateProperties();
            }
        }

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

            writer.Write(0); // version

            writer.Write(m_Owner);
        }

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

            LootType = LootType.Blessed;

            int version = reader.ReadInt();

            m_Owner = reader.ReadMobile();
        }

        public override void AddNameProperty(ObjectPropertyList list)
        {
            string m_name = "a player";

            if (m_Owner != null && !m_Owner.Deleted)
                m_name = m_Owner.Name;

            list.Add(1062195, m_name); // personal bless deed for ~1_NAME~
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (from != m_Owner)
                from.SendLocalizedMessage(1062201, m_Owner != null ? m_Owner.Name : "another player"); // Only the owner, ~1_NAME~, can use this deed.
            else if (!IsChildOf(from.Backpack))
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            else
                from.SendGump(new WarningGump(1060635, 30720, 1062202, 32512, 420, 280, BlessWarning_Callback, this));
        }

        private static void BlessWarning_Callback(Mobile from, bool okay, object state)
        {
            if (!okay)
                return;

            from.SendLocalizedMessage(500506); // Which item do you wish to bless?
            from.Target = new PersonalBlessTarget((PersonalBlessDeed)state);
        }
    }

    public class PersonalBlessTarget : Target // Create targeting class
    {
        private readonly PersonalBlessDeed m_Deed;
        public PersonalBlessTarget(PersonalBlessDeed deed)
            : base(-1, false, TargetFlags.None)
        {
            m_Deed = deed;
        }

        protected override void OnTarget(Mobile from, object target)
        {
            if (target is Mobile)
                from.SendLocalizedMessage(500507); // You can only bless an item!
            else if (target is BaseArmor || target is BaseClothing || target is BaseWeapon || target is BaseJewel)
            {
                Item item = (Item)target;

                if (item.LootType == LootType.Blessed || item.BlessedFor != null || (Mobile.InsuranceEnabled && item.Insured)) // Check if its already newbied (blessed)
                    from.SendLocalizedMessage(1045113); // That item is already blessed
                else if (item.LootType != LootType.Regular)
                    from.SendLocalizedMessage(500509); // You can't bless this object!
                else if (item.RootParent != from) // Make sure its in their pack or they are wearing it
                    from.SendLocalizedMessage(500508); // You may only bless objects that you are carrying.
                else if (m_Deed.RootParent != from)
                    from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
                else
                {
                    // Now we also know the deed is still in the players backpack,
                    // as is the item the player wants to bless. Let's go and
                    // bless it.
                    if (item is BaseArmor)
                    {
                        BaseArmor mitem = (BaseArmor)item;
                        mitem.BlessedBy = from;
                    }
                    else if (item is BaseClothing)
                    {
                        BaseClothing mitem = (BaseClothing)item;
                        mitem.BlessedBy = from;
                    }
                    else if (item is BaseWeapon)
                    {
                        BaseWeapon mitem = (BaseWeapon)item;
                        mitem.BlessedBy = from;
                    }
                    else if (item is BaseJewel)
                    {
                        BaseJewel mitem = (BaseJewel)item;
                        mitem.BlessedBy = from;
                    }

                    item.BlessedFor = from;
                    from.SendLocalizedMessage(1062204); // You personally bless the item for this character.
                    from.PlaySound(0x202);
                    m_Deed.Delete();
                }
            }
            else
                from.SendLocalizedMessage(500509); // You can't bless this object!
        }
    }
 
I think the confusion is coming from that "Owner" property, which is essentially trying to stand-in for BlessedFor.
Cleaning up the code helps make it readable, here is the same code with redundancy and nesting minimized;
(I also added a default constructor and a secondary/repeat check in the target handler to validate the deed state)
C#:
        public override bool DisplayLootType => true;

        [Constructable]
        public PersonalBlessDeed()
            : this(null)
        { }

        public PersonalBlessDeed(Mobile owner)
            : base(0x14F0)
        {
            Weight = 1.0;
            BlessedFor = owner;
        }

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

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

            writer.Write(0); // version
        }

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

            reader.ReadInt(); // version
        }

        public override void AddBlessedForProperty(ObjectPropertyList list)
        {
            // do nothing
        }

        public override void AddNameProperty(ObjectPropertyList list)
        {
            var name = BlessedFor?.RawName ?? "a player";

            list.Add(1062195, name); // personal bless deed for ~1_NAME~
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (BlessedFor != null && BlessedFor != from)
            {
                var name = BlessedFor.RawName;

                from.SendLocalizedMessage(1062201, name); // Only the owner, ~1_NAME~, can use this deed.
                return;
            }
            
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                return;
            }

            from.SendGump(new WarningGump(1060635, 30720, 1062202, 32512, 420, 280, BlessWarning_Callback, this));
        }

        private static void BlessWarning_Callback(Mobile from, bool okay, object state)
        {
            if (okay && state is PersonalBlessDeed deed)
            {
                from.SendLocalizedMessage(500506); // Which item do you wish to bless?
                from.Target = new PersonalBlessTarget(deed);
            }
        }

C#:
    public class PersonalBlessTarget : Target // Create targeting class
    {
        private readonly PersonalBlessDeed m_Deed;

        public PersonalBlessTarget(PersonalBlessDeed deed)
            : base(-1, false, TargetFlags.None)
        {
            m_Deed = deed;
        }

        protected override void OnTarget(Mobile from, object target)
        {
            if (m_Deed == null || m_Deed.Deleted || m_Deed.RootParent != from)
            {
                from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
                return;
            }

            if (m_Deed.BlessedFor != null && m_Deed.BlessedFor != from)
            {
                var name = m_Deed.BlessedFor.RawName;

                from.SendLocalizedMessage(1062201, name); // Only the owner, ~1_NAME~, can use this deed.
                return;
            }

            if (!(target is Item item))
            {
                from.SendLocalizedMessage(500507); // You can only bless an item!
                return;
            }
            
            if (!(item is BaseArmor || item is BaseClothing || item is BaseWeapon || item is BaseJewel))
            {
                from.SendLocalizedMessage(500509); // You can't bless this object!
                return;
            }

            if (item.LootType == LootType.Blessed || item.BlessedFor != null || item.Insured)
            {
                from.SendLocalizedMessage(1045113); // That item is already blessed
                return;
            }
            
            if (item.LootType != LootType.Regular)
            {
                from.SendLocalizedMessage(500509); // You can't bless this object!
                return;
            }

            if (item.RootParent != from) // Make sure its in their pack or they are wearing it
            {
                from.SendLocalizedMessage(500508); // You may only bless objects that you are carrying.
                return;
            }

            if (item is BaseArmor armor)
                armor.BlessedBy = from;
            else if (item is BaseClothing clothing)
                clothing.BlessedBy = from;
            else if (item is BaseWeapon weapon)
                weapon.BlessedBy = from;
            else if (item is BaseJewel jewel)
                jewel.BlessedBy = from;

            item.BlessedFor = from;

            from.SendLocalizedMessage(1062204); // You personally bless the item for this character.
            from.PlaySound(0x202);

            m_Deed.Delete();
        }
    }
 
I think the confusion is coming from that "Owner" property, which is essentially trying to stand-in for BlessedFor.
Cleaning up the code helps make it readable, here is the same code with redundancy and nesting minimized;
(I also added a default constructor and a secondary/repeat check in the target handler to validate the deed state)
C#:
        public override bool DisplayLootType => true;

        [Constructable]
        public PersonalBlessDeed()
            : this(null)
        { }

        public PersonalBlessDeed(Mobile owner)
            : base(0x14F0)
        {
            Weight = 1.0;
            BlessedFor = owner;
        }

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

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

            writer.Write(0); // version
        }

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

            reader.ReadInt(); // version
        }

        public override void AddBlessedForProperty(ObjectPropertyList list)
        {
            // do nothing
        }

        public override void AddNameProperty(ObjectPropertyList list)
        {
            var name = BlessedFor?.RawName ?? "a player";

            list.Add(1062195, name); // personal bless deed for ~1_NAME~
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (BlessedFor != null && BlessedFor != from)
            {
                var name = BlessedFor.RawName;

                from.SendLocalizedMessage(1062201, name); // Only the owner, ~1_NAME~, can use this deed.
                return;
            }
           
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                return;
            }

            from.SendGump(new WarningGump(1060635, 30720, 1062202, 32512, 420, 280, BlessWarning_Callback, this));
        }

        private static void BlessWarning_Callback(Mobile from, bool okay, object state)
        {
            if (okay && state is PersonalBlessDeed deed)
            {
                from.SendLocalizedMessage(500506); // Which item do you wish to bless?
                from.Target = new PersonalBlessTarget(deed);
            }
        }

C#:
    public class PersonalBlessTarget : Target // Create targeting class
    {
        private readonly PersonalBlessDeed m_Deed;

        public PersonalBlessTarget(PersonalBlessDeed deed)
            : base(-1, false, TargetFlags.None)
        {
            m_Deed = deed;
        }

        protected override void OnTarget(Mobile from, object target)
        {
            if (m_Deed == null || m_Deed.Deleted || m_Deed.RootParent != from)
            {
                from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
                return;
            }

            if (m_Deed.BlessedFor != null && m_Deed.BlessedFor != from)
            {
                var name = m_Deed.BlessedFor.RawName;

                from.SendLocalizedMessage(1062201, name); // Only the owner, ~1_NAME~, can use this deed.
                return;
            }

            if (!(target is Item item))
            {
                from.SendLocalizedMessage(500507); // You can only bless an item!
                return;
            }
           
            if (!(item is BaseArmor || item is BaseClothing || item is BaseWeapon || item is BaseJewel))
            {
                from.SendLocalizedMessage(500509); // You can't bless this object!
                return;
            }

            if (item.LootType == LootType.Blessed || item.BlessedFor != null || item.Insured)
            {
                from.SendLocalizedMessage(1045113); // That item is already blessed
                return;
            }
           
            if (item.LootType != LootType.Regular)
            {
                from.SendLocalizedMessage(500509); // You can't bless this object!
                return;
            }

            if (item.RootParent != from) // Make sure its in their pack or they are wearing it
            {
                from.SendLocalizedMessage(500508); // You may only bless objects that you are carrying.
                return;
            }

            if (item is BaseArmor armor)
                armor.BlessedBy = from;
            else if (item is BaseClothing clothing)
                clothing.BlessedBy = from;
            else if (item is BaseWeapon weapon)
                weapon.BlessedBy = from;
            else if (item is BaseJewel jewel)
                jewel.BlessedBy = from;

            item.BlessedFor = from;

            from.SendLocalizedMessage(1062204); // You personally bless the item for this character.
            from.PlaySound(0x202);

            m_Deed.Delete();
        }
    }
Thanks!

This part gives me an error tho:


C#:
    public override void AddBlessedForProperty(ObjectPropertyList list)
        {
            // do nothing
        }

No suitiable method found to override.
 
I guess you can just leave that method override out, it was meant to prevent the normal BlessedFor cliloc from being added by the base Item class.
 
I guess you can just leave that method override out, it was meant to prevent the normal BlessedFor cliloc from being added by the base Item class.
Gotcha, tried that before posting. Nor displaying blessed by sadly
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back