I have a shard running on RunUO version 2.1

We discovered a problem with a piece of equipment I made for our shard.

The problem is:

The item adds some Skill Mods when equipped but if the server goes down or if the server is rebooted then the Mods stay on the player but they no longer get removed when the equipment is removed and they no longer get added when they are equipped.

I suspect the problem is a result of the item not being Serialized Deserialized for the Mods but that is just my guess.

So ..
1) If this is the cause . . does anyone know how to properly Serialized Deserialized the item for the Mods?

2) If this is not the cause . . does anyone know how I can fix it?

3) Also . . is there a way for me to allow the item's Skill Mods exceed the player's skill cap?

Any help I can get on this would be very much appreciated.

Here is the scrip I am using:
Code:
using System;

namespace Server.Items
{
    public class SampireChest : StuddedChest
    {
        private SkillMod m_SkillMod0; 
        private SkillMod m_SkillMod1; 
        private SkillMod m_SkillMod2; 

        public override int ArtifactRarity{ get{ return 16; } }

        public override int BasePhysicalResistance{ get{ return 13; } }
        public override int BaseFireResistance{ get{ return 13; } }
        public override int BaseColdResistance{ get{ return 13; } }
        public override int BasePoisonResistance{ get{ return 13; } }
        public override int BaseEnergyResistance{ get{ return 13; } }

        public override int InitMinHits{ get{ return 255; } }
        public override int InitMaxHits{ get{ return 255; } }

        [Constructable]
        public SampireChest()
        {
            Name = "<BASEFONT COLOR=#01FD0E>Draugr Tunic";
            Hue = 1361;

            Attributes.BonusStr = 7;
            Attributes.BonusHits = 7;

            Attributes.BonusDex = 5;
            Attributes.BonusStam = 5;

            Attributes.DefendChance = 5;
            Attributes.ReflectPhysical = 5;

            ArmorAttributes.DurabilityBonus = 100;

            this.HitPoints = this.MaxHitPoints = 255;

            DefineMods();
        }

        private void DefineMods()
        {
            m_SkillMod0 = new DefaultSkillMod( SkillName.Bushido, true, 5 ); 
            m_SkillMod1 = new DefaultSkillMod( SkillName.Necromancy, true, 5 ); 
            m_SkillMod2 = new DefaultSkillMod( SkillName.Swords, true, 5 ); 
        }

        private void SetMods( Mobile wearer )
        {            
            wearer.AddSkillMod( m_SkillMod0 ); 
            wearer.AddSkillMod( m_SkillMod1 ); 
            wearer.AddSkillMod( m_SkillMod2 ); 
        }

        public override bool OnEquip( Mobile from ) 
        { 
            SetMods( from );
            return true;  
        } 

        public override void OnRemoved( object parent ) 
        { 
            if ( parent is Mobile ) 
            { 
                Mobile m = (Mobile)parent;
                m.RemoveStatMod("SampireChest");

                if ( m_SkillMod0 != null ) 
                    m_SkillMod0.Remove(); 

                if ( m_SkillMod1 != null ) 
                    m_SkillMod1.Remove(); 

                if ( m_SkillMod2 != null ) 
                    m_SkillMod2.Remove(); 

                if ( m.Hits > m.HitsMax )
                    m.Hits = m.HitsMax; 
            } 
        } 

        public SampireChest(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();
        }
    }
}

Many Thanks
 
Okay . . hope this helps any others with this problem.

I was finally able to solve my problem of the SkillMod bonuses being permanently lost from items following a server reboot.

The answer (for me) lies in Serial . . not in Serialize or in Deserialize.

So when I changed this:
Code:
public SampireChest( Serial serial ) : base( serial )
{
}

to this:
Code:
public SampireChest( Serial serial ) : base( serial )
{
     DefineMods();

     if ( Parent != null && this.Parent is Mobile ) 
          SetMods( (Mobile)Parent );
}

the item's SkillMods now function the way intended regardless of a player's login/logout/dying or a server reboot etc.
 
I always put it at the end of the Deserialize because that is where it is in the given examples like Blacksmiths Gloves of Mining: GlovesOfMining.cs

Your method is slightly different to that though
 
Again . . I am not confident when it comes to 'Serialize' and 'Deserialize'. The solution I found came from a different script that had placed it in 'Serial'.

If I was to place it in Deserialize, would I use the identical lines or would they need to be worded differently?
 
Try replacing your Deserialize with this

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

            int version = reader.ReadEncodedInt();
            if ( Parent != null && Parent is Mobile ) 
            {
                if ( m_SkillMod0 != null )
                {
                    m_SkillMod0.Remove();
                    m_SkillMod1.Remove();
                    m_SkillMod2.Remove();
                }

                m_SkillMod0 = new DefaultSkillMod( SkillName.Bushido, true, 5 ); 
                ((Mobile)Parent).AddSkillMod( m_SkillMod0 );
                m_SkillMod1 = new DefaultSkillMod( SkillName.Necromancy, true, 5 ); 
                ((Mobile)Parent).AddSkillMod( m_SkillMod1 );
                m_SkillMod2 = new DefaultSkillMod( SkillName.Swords, true, 5 ); 
                ((Mobile)Parent).AddSkillMod( m_SkillMod2 );
            }
        }
 
Seems to work fine.

I assume you have a pre AOS shard then, so you don't have access to the SkillBonuses attributes?
Like
SkillBonuses.SetValues(0, SkillName.Necromancy, 5.0);
 
Back