Пример #1
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (name == TalismanSlayerName.None)
            {
                return(false);
            }

            Type[] types = m_Table[name];

            if (types == null || m == null)
            {
                return(false);
            }

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i] == type)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (!m_Table.ContainsKey(name))
            {
                return(false);
            }

            Type[] types = m_Table[name];

            if (types == null || m == null)
            {
                return(false);
            }

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public static double GetWeight(this TalismanSlayerName attr)
        {
            if (!TalismanSlayerAttrFactors.ContainsKey(attr))
            {
                TalismanSlayerAttrFactors.Add(attr, new AttributeFactors());
            }

            return(TalismanSlayerAttrFactors[attr].Weight);
        }
Пример #4
0
        public static int GetInc(this TalismanSlayerName attr)
        {
            if (!TalismanSlayerAttrFactors.ContainsKey(attr))
            {
                TalismanSlayerAttrFactors.Add(attr, new AttributeFactors());
            }

            return(TalismanSlayerAttrFactors[attr].Inc);
        }
Пример #5
0
        public static Type[] GetSlayer(TalismanSlayerName name)
        {
            if (m_Table == null)
            {
                InitSlayer();
            }

            return((Type[])m_Table[name]);
        }
Пример #6
0
        private static bool HasTalismanSlayer(Item item, string name, TalismanSlayerName attr)
        {
            PropertyInfo pi = item.GetType().GetProperty(name, TypeOfTalismanSlayerName);

            if (pi == null)
            {
                return(false);
            }

            return((TalismanSlayerName)pi.GetValue(item, null) == attr);
        }
Пример #7
0
        public static int GetModForAttribute(TalismanSlayerName attr)
        {
            foreach (KeyValuePair <int, ImbuingDefinition> kvp in m_Table)
            {
                int mod = kvp.Key;
                ImbuingDefinition def = kvp.Value;

                if (def.Attribute is TalismanSlayerName && (TalismanSlayerName)def.Attribute == attr)
                {
                    return(mod);
                }
            }

            return(-1);
        }
Пример #8
0
 public static void SetMax(this TalismanSlayerName attr, int max)
 {
     if (!TalismanSlayerAttrFactors.ContainsKey(attr))
     {
         TalismanSlayerAttrFactors.Add(
             attr,
             new AttributeFactors
         {
             Max = max
         });
     }
     else
     {
         TalismanSlayerAttrFactors[attr].Max = max;
     }
 }
Пример #9
0
 public static void SetInc(this TalismanSlayerName attr, int inc)
 {
     if (!TalismanSlayerAttrFactors.ContainsKey(attr))
     {
         TalismanSlayerAttrFactors.Add(
             attr,
             new AttributeFactors
         {
             Inc = inc
         });
     }
     else
     {
         TalismanSlayerAttrFactors[attr].Inc = inc;
     }
 }
Пример #10
0
 public static void SetMin(this TalismanSlayerName attr, int min)
 {
     if (!TalismanSlayerAttrFactors.ContainsKey(attr))
     {
         TalismanSlayerAttrFactors.Add(
             attr,
             new AttributeFactors
         {
             Min = min
         });
     }
     else
     {
         TalismanSlayerAttrFactors[attr].Min = min;
     }
 }
Пример #11
0
 public static void SetWeight(this TalismanSlayerName attr, double weight)
 {
     if (!TalismanSlayerAttrFactors.ContainsKey(attr))
     {
         TalismanSlayerAttrFactors.Add(
             attr,
             new AttributeFactors
         {
             Weight = weight
         });
     }
     else
     {
         TalismanSlayerAttrFactors[attr].Weight = weight;
     }
 }
Пример #12
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (m == null || !m_Table.TryGetValue(name, out var types) || types == null)
            {
                return(false);
            }

            var type = m.GetType();

            for (var i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
		public static bool Slays( TalismanSlayerName name, Mobile m )
		{
			if ( !m_Table.ContainsKey( name ) )
				return false;

			Type[] types = m_Table[ name ];
			
			if ( types == null || m == null )
				return false;

			Type type = m.GetType();

			for ( int i = 0; i < types.Length; i++ )
			{
				if ( types[ i ] == type )
					return true;
			}

			return false;
		}
Пример #14
0
        public static bool Check(TalismanSlayerName name, BaseCreature creature)
        {
            Type[] types = GetSlayer(name);

            if (types == null || creature == null)
            {
                return(false);
            }

            for (int i = 0; i < types.Length; i++)
            {
                Type type = types[i];

                if (type == creature.GetType())
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #15
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (m.SpecialSlayerMechanics)
            {
                if (m.SlayerVulnerabilities.Contains(name.ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (!m_Table.ContainsKey(name))
            {
                return(false);
            }

            Type[] types = m_Table[name];

            if (types == null || m == null)
            {
                return(false);
            }

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #16
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();

                if (GetSaveFlag(flags, SaveFlag.Attributes))
                {
                    m_AosAttributes = new AosAttributes(this, reader);
                }
                else
                {
                    m_AosAttributes = new AosAttributes(this);
                }

                if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
                {
                    m_AosSkillBonuses = new AosSkillBonuses(this, reader);
                }
                else
                {
                    m_AosSkillBonuses = new AosSkillBonuses(this);
                }

                // Backward compatibility
                if (GetSaveFlag(flags, SaveFlag.Owner))
                {
                    BlessedFor = reader.ReadMobile();
                }

                if (GetSaveFlag(flags, SaveFlag.Protection))
                {
                    m_Protection = new TalismanAttribute(reader);
                }
                else
                {
                    m_Protection = new TalismanAttribute();
                }

                if (GetSaveFlag(flags, SaveFlag.Killer))
                {
                    m_Killer = new TalismanAttribute(reader);
                }
                else
                {
                    m_Killer = new TalismanAttribute();
                }

                if (GetSaveFlag(flags, SaveFlag.Summoner))
                {
                    m_Summoner = new TalismanAttribute(reader);
                }
                else
                {
                    m_Summoner = new TalismanAttribute();
                }

                if (GetSaveFlag(flags, SaveFlag.Removal))
                {
                    m_Removal = (TalismanRemoval)reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.KarmaLoss))
                {
                    m_KarmaLoss = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Skill))
                {
                    m_Skill = (SkillName)reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.SuccessBonus))
                {
                    m_SuccessBonus = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus))
                {
                    m_ExceptionalBonus = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.MaxCharges))
                {
                    m_MaxCharges = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Charges))
                {
                    m_Charges = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.MaxChargeTime))
                {
                    m_MaxChargeTime = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.ChargeTime))
                {
                    m_ChargeTime = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Slayer))
                {
                    m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt();
                }

                m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed);

                break;
            }
            }

            if (Parent is Mobile)
            {
                Mobile m = (Mobile)Parent;

                m_AosAttributes.AddStatBonuses(m);
                m_AosSkillBonuses.AddTo(m);

                if (m_ChargeTime > 0)
                {
                    StartTimer();
                }
            }
        }
Пример #17
0
		public static bool Slays( TalismanSlayerName name, Mobile m )
		{
			if ( name == TalismanSlayerName.None )
				return false;

			Type[] types = m_Table[ name ];
			
			if ( types == null || m == null )
				return false;

			Type type = m.GetType();
				
			for ( int i = 0; i < types.Length; i++ )
			{
				if ( types[ i ] == type )
					return true;
			}
			
			return false;
		}
Пример #18
0
 public static string ToString(this TalismanSlayerName attr, double val, bool html = true)
 {
     return(GetPropertyString(val, html));
 }
Пример #19
0
 public static bool IsSuper(this TalismanSlayerName attr)
 {
     return(SuperTalismanSlayers.Contains(attr));
 }
Пример #20
0
		public static bool HasSlayer(this Item item, TalismanSlayerName attr)
		{
			return (HasTalismanSlayer(item, "Slayer", attr) || HasTalismanSlayer(item, "Slayer1", attr) ||
					HasTalismanSlayer(item, "Slayer2", attr) || HasTalismanSlayer(item, "Slayer3", attr) ||
					HasTalismanSlayer(item, "Slayer4", attr));
		}
Пример #21
0
 public static bool Slays(TalismanSlayerName name, Mobile m)
 {
     if (m == null || !m_Table.TryGetValue(name, out Type[] types) || types == null)
Пример #22
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (!m_Table.ContainsKey(name))
                return false;

            Type[] types = m_Table[name];

            if (types == null || m == null)
                return false;

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                    return true;
            }

            return false;
        }
Пример #23
0
		private static bool HasTalismanSlayer(Item item, string name, TalismanSlayerName attr)
		{
			var pi = item.GetType().GetProperty(name, TypeOfTalismanSlayerName);

			if (pi == null)
			{
				return false;
			}

			return ((TalismanSlayerName)pi.GetValue(item, null) == attr);
		}
Пример #24
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 0:
				{
					SaveFlag flags = (SaveFlag) reader.ReadEncodedInt();

					if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
						m_AosAttributes = new AosAttributes( this, reader );
					else
						m_AosAttributes = new AosAttributes( this );

					if ( GetSaveFlag( flags, SaveFlag.SkillBonuses ) )
						m_AosSkillBonuses = new AosSkillBonuses( this, reader );
						
					if ( GetSaveFlag( flags, SaveFlag.Owner ) )
						m_Owner = reader.ReadMobile();
					
					
					m_Protection = new TalismanAttribute();	
						
					if ( GetSaveFlag( flags, SaveFlag.Protection ) )					
						m_Protection.Deserialize( reader );
					else
						m_Protection = null;
						
					m_Killer = new TalismanAttribute();	
						
					if ( GetSaveFlag( flags, SaveFlag.Killer ) )
						m_Killer.Deserialize( reader );
					else
						m_Killer = null;
						
					m_Summoner = new TalismanAttribute();		
						
					if ( GetSaveFlag( flags, SaveFlag.Summoner ) )
						m_Summoner.Deserialize( reader );
					else
						m_Summoner = null;
						
					if ( GetSaveFlag( flags, SaveFlag.Removal ) )
						m_Removal = (TalismanRemoval) reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.KarmaLoss ) )
						m_KarmaLoss = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.Skill ) )
						m_Skill = (SkillName) reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.SuccessBonus ) )
						m_SuccessBonus = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.ExceptionalBonus ) )
						m_ExceptionalBonus = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.MaxCharges ) )
						m_MaxCharges = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.Charges ) )
						m_Charges = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.MaxChargeTime ) )
						m_MaxChargeTime = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.ChargeTime ) )
						m_ChargeTime = reader.ReadEncodedInt();
						
					if ( GetSaveFlag( flags, SaveFlag.Slayer ) )
						m_Slayer = (TalismanSlayerName) reader.ReadEncodedInt();
						
					m_Blessed = GetSaveFlag( flags, SaveFlag.Blessed );
					
					break;
				}
			}
			
			if ( Parent is Mobile && ChargeTime > 0 )
				StartTimer();
				
			if ( m_AosSkillBonuses == null )
				m_AosSkillBonuses = new AosSkillBonuses( this );
				
			if ( Core.AOS && Parent is Mobile )
				m_AosSkillBonuses.AddTo( (Mobile)Parent );
				
			int strBonus = m_AosAttributes.BonusStr;
			int dexBonus = m_AosAttributes.BonusDex;
			int intBonus = m_AosAttributes.BonusInt;

			if ( Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0) )
			{
				Mobile m = (Mobile)Parent;

				string modName = Serial.ToString();

				if ( strBonus != 0 )
					m.AddStatMod( new StatMod( StatType.Str, modName + "Str", strBonus, TimeSpan.Zero ) );

				if ( dexBonus != 0 )
					m.AddStatMod( new StatMod( StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero ) );

				if ( intBonus != 0 )
					m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
			}

			if ( Parent is Mobile )
				((Mobile)Parent).CheckStatTimers();
		}
Пример #25
0
		public static Type[] GetSlayer( TalismanSlayerName name )
		{
			if ( m_Table == null )
				InitSlayer();
				
			return (Type[]) m_Table[ name ];
		}
Пример #26
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
				case 0:
					{
						SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Attributes))
							m_AosAttributes = new AosAttributes(this, reader);
						else
							m_AosAttributes = new AosAttributes(this);

						if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
							m_AosSkillBonuses = new AosSkillBonuses(this, reader);
						else
							m_AosSkillBonuses = new AosSkillBonuses(this);

						// Backward compatibility
						if (GetSaveFlag(flags, SaveFlag.Owner))
							BlessedFor = reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.Protection))
							m_Protection = new TalismanAttribute(reader);
						else
							m_Protection = new TalismanAttribute();

						if (GetSaveFlag(flags, SaveFlag.Killer))
							m_Killer = new TalismanAttribute(reader);
						else
							m_Killer = new TalismanAttribute();

						if (GetSaveFlag(flags, SaveFlag.Summoner))
							m_Summoner = new TalismanAttribute(reader);
						else
							m_Summoner = new TalismanAttribute();

						if (GetSaveFlag(flags, SaveFlag.Removal))
							m_Removal = (TalismanRemoval)reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.OldKarmaLoss))
							m_AosAttributes.IncreasedKarmaLoss = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Skill))
							m_Skill = (SkillName)reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.SuccessBonus))
							m_SuccessBonus = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus))
							m_ExceptionalBonus = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.MaxCharges))
							m_MaxCharges = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Charges))
							m_Charges = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.MaxChargeTime))
							m_MaxChargeTime = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.ChargeTime))
							m_ChargeTime = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Slayer))
							m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt();

						m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed);

						break;
					}
			}

			if (Parent is Mobile)
			{
				Mobile m = (Mobile)Parent;

				m_AosAttributes.AddStatBonuses(m);
				m_AosSkillBonuses.AddTo(m);

				if (m_ChargeTime > 0)
					StartTimer();
			}
		}
Пример #27
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();

                if (GetSaveFlag(flags, SaveFlag.Attributes))
                {
                    m_AosAttributes = new AosAttributes(this, reader);
                }
                else
                {
                    m_AosAttributes = new AosAttributes(this);
                }

                if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
                {
                    m_AosSkillBonuses = new AosSkillBonuses(this, reader);
                }

                if (GetSaveFlag(flags, SaveFlag.Owner))
                {
                    m_Owner = reader.ReadMobile();
                }


                m_Protection = new TalismanAttribute();

                if (GetSaveFlag(flags, SaveFlag.Protection))
                {
                    m_Protection.Deserialize(reader);
                }
                else
                {
                    m_Protection = null;
                }

                m_Killer = new TalismanAttribute();

                if (GetSaveFlag(flags, SaveFlag.Killer))
                {
                    m_Killer.Deserialize(reader);
                }
                else
                {
                    m_Killer = null;
                }

                m_Summoner = new TalismanAttribute();

                if (GetSaveFlag(flags, SaveFlag.Summoner))
                {
                    m_Summoner.Deserialize(reader);
                }
                else
                {
                    m_Summoner = null;
                }

                if (GetSaveFlag(flags, SaveFlag.Removal))
                {
                    m_Removal = (TalismanRemoval)reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.KarmaLoss))
                {
                    m_KarmaLoss = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Skill))
                {
                    m_Skill = (SkillName)reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.SuccessBonus))
                {
                    m_SuccessBonus = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus))
                {
                    m_ExceptionalBonus = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.MaxCharges))
                {
                    m_MaxCharges = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Charges))
                {
                    m_Charges = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.MaxChargeTime))
                {
                    m_MaxChargeTime = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.ChargeTime))
                {
                    m_ChargeTime = reader.ReadEncodedInt();
                }

                if (GetSaveFlag(flags, SaveFlag.Slayer))
                {
                    m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt();
                }

                m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed);

                break;
            }
            }

            if (Parent is Mobile && ChargeTime > 0)
            {
                StartTimer();
            }

            if (m_AosSkillBonuses == null)
            {
                m_AosSkillBonuses = new AosSkillBonuses(this);
            }

            if (Core.AOS && Parent is Mobile)
            {
                m_AosSkillBonuses.AddTo((Mobile)Parent);
            }

            int strBonus = m_AosAttributes.BonusStr;
            int dexBonus = m_AosAttributes.BonusDex;
            int intBonus = m_AosAttributes.BonusInt;

            if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0))
            {
                Mobile m = (Mobile)Parent;

                string modName = Serial.ToString();

                if (strBonus != 0)
                {
                    m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
                }

                if (dexBonus != 0)
                {
                    m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
                }

                if (intBonus != 0)
                {
                    m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
                }
            }

            if (Parent is Mobile)
            {
                ((Mobile)Parent).CheckStatTimers();
            }
        }
Пример #28
0
		public static bool Check( TalismanSlayerName name, BaseCreature creature )
		{
			Type[] types = GetSlayer( name );
			
			if ( types == null || creature == null )
				return false;
				
			for ( int i = 0; i < types.Length; i ++ )
			{
				Type type = types[ i ];
				
				if ( type == creature.GetType() )
					return true;
			}
			
			return false;
		}
Пример #29
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {

            if (m.SpecialSlayerMechanics)
            {
                if (m.SlayerVulnerabilities.Contains(name.ToString()))
                    return true;
                else
                    return false;
                
            }

            if (!m_Table.ContainsKey(name))
                return false;

            Type[] types = m_Table[name];
			
            if (types == null || m == null)
                return false;

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                    return true;
            }

            return false;
        }
Пример #30
0
 public static bool HasSlayer(this Item item, TalismanSlayerName attr)
 {
     return(HasTalismanSlayer(item, "Slayer", attr) || HasTalismanSlayer(item, "Slayer1", attr) ||
            HasTalismanSlayer(item, "Slayer2", attr) || HasTalismanSlayer(item, "Slayer3", attr) ||
            HasTalismanSlayer(item, "Slayer4", attr));
 }
Пример #31
0
		private static double GetSlayerWeight(TalismanSlayerName attr)
		{
			if (attr == TalismanSlayerName.None)
			{
				return 0;
			}

			return IsSuper(attr) ? 1.3 : 1.1;
		}
Пример #32
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
                case 12:
                    {
                        #region Runic Reforging
                        m_ReforgedPrefix = (ReforgedPrefix)reader.ReadInt();
                        m_ReforgedSuffix = (ReforgedSuffix)reader.ReadInt();
                        m_ItemPower = (ItemPower)reader.ReadInt();
                        m_BlockRepair = reader.ReadBool();
                        #endregion

                        #region Stygian Abyss
                        m_DImodded = reader.ReadBool();
                        m_SearingWeapon = reader.ReadBool();
                        goto case 11;
                    }
				case 11:
					{
						m_TimesImbued = reader.ReadInt();
                        #endregion

                        goto case 10;
					}
				case 10:
					{
						m_BlessedBy = reader.ReadMobile();
						m_EngravedText = reader.ReadString();
						m_Slayer3 = (TalismanSlayerName)reader.ReadInt();

						SetFlag flags = (SetFlag)reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SetFlag.Attributes))
						{
							m_SetAttributes = new AosAttributes(this, reader);
						}
						else
						{
							m_SetAttributes = new AosAttributes(this);
						}

						if (GetSaveFlag(flags, SetFlag.WeaponAttributes))
						{
							m_SetSelfRepair = (new AosWeaponAttributes(this, reader)).SelfRepair;
						}

						if (GetSaveFlag(flags, SetFlag.SkillBonuses))
						{
							m_SetSkillBonuses = new AosSkillBonuses(this, reader);
						}
						else
						{
							m_SetSkillBonuses = new AosSkillBonuses(this);
						}

						if (GetSaveFlag(flags, SetFlag.Hue))
						{
							m_SetHue = reader.ReadInt();
						}

						if (GetSaveFlag(flags, SetFlag.LastEquipped))
						{
							m_LastEquipped = reader.ReadBool();
						}

						if (GetSaveFlag(flags, SetFlag.SetEquipped))
						{
							m_SetEquipped = reader.ReadBool();
						}

						if (GetSaveFlag(flags, SetFlag.SetSelfRepair))
						{
							m_SetSelfRepair = reader.ReadEncodedInt();
						}

						goto case 5;
					}
				case 9:
				case 8:
				case 7:
				case 6:
				case 5:
					{
						SaveFlag flags = (SaveFlag)reader.ReadInt();

						if (GetSaveFlag(flags, SaveFlag.DamageLevel))
						{
							m_DamageLevel = (WeaponDamageLevel)reader.ReadInt();

							if (m_DamageLevel > WeaponDamageLevel.Vanq)
							{
								m_DamageLevel = WeaponDamageLevel.Ruin;
							}
						}

						if (GetSaveFlag(flags, SaveFlag.AccuracyLevel))
						{
							m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt();

							if (m_AccuracyLevel > WeaponAccuracyLevel.Supremely)
							{
								m_AccuracyLevel = WeaponAccuracyLevel.Accurate;
							}
						}

						if (GetSaveFlag(flags, SaveFlag.DurabilityLevel))
						{
							m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt();

							if (m_DurabilityLevel > WeaponDurabilityLevel.Indestructible)
							{
								m_DurabilityLevel = WeaponDurabilityLevel.Durable;
							}
						}

						if (GetSaveFlag(flags, SaveFlag.Quality))
						{
							m_Quality = (WeaponQuality)reader.ReadInt();
						}
						else
						{
							m_Quality = WeaponQuality.Regular;
						}

						if (GetSaveFlag(flags, SaveFlag.Hits))
						{
							m_Hits = reader.ReadInt();
						}

						if (GetSaveFlag(flags, SaveFlag.MaxHits))
						{
							m_MaxHits = reader.ReadInt();
						}

						if (GetSaveFlag(flags, SaveFlag.Slayer))
						{
							m_Slayer = (SlayerName)reader.ReadInt();
						}

						if (GetSaveFlag(flags, SaveFlag.Poison))
						{
							m_Poison = Poison.Deserialize(reader);
						}

						if (GetSaveFlag(flags, SaveFlag.PoisonCharges))
						{
							m_PoisonCharges = reader.ReadInt();
						}

						if (GetSaveFlag(flags, SaveFlag.Crafter))
						{
							m_Crafter = reader.ReadMobile();
						}

						if (GetSaveFlag(flags, SaveFlag.Identified))
						{
							m_Identified = (version >= 6 || reader.ReadBool());
						}

						if (GetSaveFlag(flags, SaveFlag.StrReq))
						{
							m_StrReq = reader.ReadInt();
						}
						else
						{
							m_StrReq = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.DexReq))
						{
							m_DexReq = reader.ReadInt();
						}
						else
						{
							m_DexReq = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.IntReq))
						{
							m_IntReq = reader.ReadInt();
						}
						else
						{
							m_IntReq = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.MinDamage))
						{
							m_MinDamage = reader.ReadInt();
						}
						else
						{
							m_MinDamage = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.MaxDamage))
						{
							m_MaxDamage = reader.ReadInt();
						}
						else
						{
							m_MaxDamage = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.HitSound))
						{
							m_HitSound = reader.ReadInt();
						}
						else
						{
							m_HitSound = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.MissSound))
						{
							m_MissSound = reader.ReadInt();
						}
						else
						{
							m_MissSound = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.Speed))
						{
							if (version < 9)
							{
								m_Speed = reader.ReadInt();
							}
							else
							{
								m_Speed = reader.ReadFloat();
							}
						}
						else
						{
							m_Speed = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.MaxRange))
						{
							m_MaxRange = reader.ReadInt();
						}
						else
						{
							m_MaxRange = -1;
						}

						if (GetSaveFlag(flags, SaveFlag.Skill))
						{
							m_Skill = (SkillName)reader.ReadInt();
						}
						else
						{
							m_Skill = (SkillName)(-1);
						}

						if (GetSaveFlag(flags, SaveFlag.Type))
						{
							m_Type = (WeaponType)reader.ReadInt();
						}
						else
						{
							m_Type = (WeaponType)(-1);
						}

						if (GetSaveFlag(flags, SaveFlag.Animation))
						{
							m_Animation = (WeaponAnimation)reader.ReadInt();
						}
						else
						{
							m_Animation = (WeaponAnimation)(-1);
						}

						if (GetSaveFlag(flags, SaveFlag.Resource))
						{
							m_Resource = (CraftResource)reader.ReadInt();
						}
						else
						{
							m_Resource = CraftResource.Iron;
						}

						if (GetSaveFlag(flags, SaveFlag.xAttributes))
						{
							m_AosAttributes = new AosAttributes(this, reader);
						}
						else
						{
							m_AosAttributes = new AosAttributes(this);
						}

						if (GetSaveFlag(flags, SaveFlag.xWeaponAttributes))
						{
							m_AosWeaponAttributes = new AosWeaponAttributes(this, reader);
						}
						else
						{
							m_AosWeaponAttributes = new AosWeaponAttributes(this);
						}

						if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && Parent is Mobile)
						{
							m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5);
							((Mobile)Parent).AddSkillMod(m_SkillMod);
						}

						if (version < 7 && m_AosWeaponAttributes.MageWeapon != 0)
						{
							m_AosWeaponAttributes.MageWeapon = 30 - m_AosWeaponAttributes.MageWeapon;
						}

						if (Core.AOS && m_AosWeaponAttributes.MageWeapon != 0 && m_AosWeaponAttributes.MageWeapon != 30 &&
							Parent is Mobile)
						{
							m_MageMod = new DefaultSkillMod(SkillName.Magery, true, -30 + m_AosWeaponAttributes.MageWeapon);
							((Mobile)Parent).AddSkillMod(m_MageMod);
						}

						if (GetSaveFlag(flags, SaveFlag.PlayerConstructed))
						{
							m_PlayerConstructed = true;
						}

						if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
						{
							m_AosSkillBonuses = new AosSkillBonuses(this, reader);
						}
						else
						{
							m_AosSkillBonuses = new AosSkillBonuses(this);
						}

						if (GetSaveFlag(flags, SaveFlag.Slayer2))
						{
							m_Slayer2 = (SlayerName)reader.ReadInt();
						}

						if (GetSaveFlag(flags, SaveFlag.ElementalDamages))
						{
							m_AosElementDamages = new AosElementAttributes(this, reader);
						}
						else
						{
							m_AosElementDamages = new AosElementAttributes(this);
						}

						if (GetSaveFlag(flags, SaveFlag.EngravedText))
						{
							m_EngravedText = reader.ReadString();
						}

						#region Stygian Abyss
						if (version > 9 && GetSaveFlag(flags, SaveFlag.xAbsorptionAttributes))
						{
							m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this, reader);
						}
						else
						{
							m_SAAbsorptionAttributes = new SAAbsorptionAttributes(this);
						}
						#endregion

						break;
					}
				case 4:
					{
						m_Slayer = (SlayerName)reader.ReadInt();

						goto case 3;
					}
				case 3:
					{
						m_StrReq = reader.ReadInt();
						m_DexReq = reader.ReadInt();
						m_IntReq = reader.ReadInt();

						goto case 2;
					}
				case 2:
					{
						m_Identified = reader.ReadBool();

						goto case 1;
					}
				case 1:
					{
						m_MaxRange = reader.ReadInt();

						goto case 0;
					}
				case 0:
					{
						if (version == 0)
						{
							m_MaxRange = 1; // default
						}

						if (version < 5)
						{
							m_Resource = CraftResource.Iron;
							m_AosAttributes = new AosAttributes(this);
							m_AosWeaponAttributes = new AosWeaponAttributes(this);
							m_AosElementDamages = new AosElementAttributes(this);
							m_AosSkillBonuses = new AosSkillBonuses(this);
						}

						m_MinDamage = reader.ReadInt();
						m_MaxDamage = reader.ReadInt();

						m_Speed = reader.ReadInt();

						m_HitSound = reader.ReadInt();
						m_MissSound = reader.ReadInt();

						m_Skill = (SkillName)reader.ReadInt();
						m_Type = (WeaponType)reader.ReadInt();
						m_Animation = (WeaponAnimation)reader.ReadInt();
						m_DamageLevel = (WeaponDamageLevel)reader.ReadInt();
						m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt();
						m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt();
						m_Quality = (WeaponQuality)reader.ReadInt();

						m_Crafter = reader.ReadMobile();

						m_Poison = Poison.Deserialize(reader);
						m_PoisonCharges = reader.ReadInt();

						if (m_StrReq == OldStrengthReq)
						{
							m_StrReq = -1;
						}

						if (m_DexReq == OldDexterityReq)
						{
							m_DexReq = -1;
						}

						if (m_IntReq == OldIntelligenceReq)
						{
							m_IntReq = -1;
						}

						if (m_MinDamage == OldMinDamage)
						{
							m_MinDamage = -1;
						}

						if (m_MaxDamage == OldMaxDamage)
						{
							m_MaxDamage = -1;
						}

						if (m_HitSound == OldHitSound)
						{
							m_HitSound = -1;
						}

						if (m_MissSound == OldMissSound)
						{
							m_MissSound = -1;
						}

						if (m_Speed == OldSpeed)
						{
							m_Speed = -1;
						}

						if (m_MaxRange == OldMaxRange)
						{
							m_MaxRange = -1;
						}

						if (m_Skill == OldSkill)
						{
							m_Skill = (SkillName)(-1);
						}

						if (m_Type == OldType)
						{
							m_Type = (WeaponType)(-1);
						}

						if (m_Animation == OldAnimation)
						{
							m_Animation = (WeaponAnimation)(-1);
						}

						if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && Parent is Mobile)
						{
							m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5);
							((Mobile)Parent).AddSkillMod(m_SkillMod);
						}

						break;
					}
			}

			#region Mondain's Legacy Sets
			if (m_SetAttributes == null)
			{
				m_SetAttributes = new AosAttributes(this);
			}

			if (m_SetSkillBonuses == null)
			{
				m_SetSkillBonuses = new AosSkillBonuses(this);
			}
			#endregion

			if (Core.AOS && Parent is Mobile)
			{
				m_AosSkillBonuses.AddTo((Mobile)Parent);
			}

			int strBonus = m_AosAttributes.BonusStr;
			int dexBonus = m_AosAttributes.BonusDex;
			int intBonus = m_AosAttributes.BonusInt;

			if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0))
			{
				Mobile m = (Mobile)Parent;

				string modName = Serial.ToString();

				if (strBonus != 0)
				{
					m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
				}

				if (dexBonus != 0)
				{
					m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
				}

				if (intBonus != 0)
				{
					m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
				}
			}

			if (Parent is Mobile)
			{
				((Mobile)Parent).CheckStatTimers();
			}

			if (m_Hits <= 0 && m_MaxHits <= 0)
			{
				m_Hits = m_MaxHits = Utility.RandomMinMax(InitMinHits, InitMaxHits);
			}

			if (version < 6)
			{
				m_PlayerConstructed = true; // we don't know, so, assume it's crafted
			}
		}
Пример #33
0
        public static int GetModForAttribute(TalismanSlayerName attr)
        {
            foreach (KeyValuePair<int, ImbuingDefinition> kvp in m_Table)
            {
                int mod = kvp.Key;
                ImbuingDefinition def = kvp.Value;

                if (def.Attribute is TalismanSlayerName && (TalismanSlayerName)def.Attribute == attr)
                    return mod;
            }

            return -1;
        }