context: #region References
  using System;
  using System.Collections.Generic;
  using System.Linq;
  
  using Server.ContextMenus;
  using Server.Engines.Craft;
  using Server.Engines.XmlSpawner2;
  using Server.Ethics;
  using Server.Factions;
  using Server.Mobiles;
  using Server.Network;
  using Server.Services.Virtues;
  using Server.SkillHandlers;
  using Server.Spells;
  using Server.Spells.Bushido;
  using Server.Spells.Chivalry;
  using Server.Spells.Necromancy;
  using Server.Spells.Ninjitsu;
  using Server.Spells.Sixth;
  using Server.Spells.Spellweaving;
  using Server.Spells.SkillMasteries;
  #endregion
  
  namespace Server.Items
  {
  	public interface ISlayer
  	{
  		SlayerName Slayer { get; set; }
  		SlayerName Slayer2 { get; set; }
  	}
  
      public abstract class BaseWeapon : Item, IWeapon, IFactionItem, IUsesRemaining, ICraftable, ISlayer, IDurability, ISetItem, IVvVItem, IOwnerRestricted, IResource
  	{
  		private string m_EngravedText;
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public string EngravedText
  		{
  			get { return m_EngravedText; }
  			set
  			{
  				m_EngravedText = value;
  				InvalidateProperties();
  			}
  		}
  
  		#region Factions
  		private FactionItem m_FactionState;
  
  		public FactionItem FactionItemState
  		{
  			get { return m_FactionState; }
  			set
  			{
  				m_FactionState = value;
  
  				if (m_FactionState == null)
  				{
  					Hue = CraftResources.GetHue(Resource);
  				}
  
  				LootType = (m_FactionState == null ? LootType.Regular : LootType.Blessed);
  			}
  		}
  		#endregion
  
          #region IUsesRemaining members
          private int m_UsesRemaining;
          private bool m_ShowUsesRemaining;
          
          [CommandProperty(AccessLevel.GameMaster)]
          public int UsesRemaining { get { return m_UsesRemaining; } set { m_UsesRemaining = value; InvalidateProperties(); } }
  
          public bool ShowUsesRemaining { get { return m_ShowUsesRemaining; } set { m_ShowUsesRemaining = value; InvalidateProperties(); } }
          
          public void ScaleUses()
          {
              m_UsesRemaining = (m_UsesRemaining * GetUsesScalar()) / 100;
              InvalidateProperties();
          }
  
          public void UnscaleUses()
          {
              m_UsesRemaining = (m_UsesRemaining * 100) / GetUsesScalar();
          }
  
          public int GetUsesScalar()
          {
              if (m_Quality == ItemQuality.Exceptional)
                  return 200;
  
              return 100;
          }
          #endregion
          
          private bool _VvVItem;
          private Mobile _Owner;
          private string _OwnerName;
  
          [CommandProperty(AccessLevel.GameMaster)]
          public bool IsVvVItem
          {
              get { return _VvVItem; }
              set { _VvVItem = value; InvalidateProperties(); }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public Mobile Owner
          {
              get { return _Owner; }
              set { _Owner = value; if (_Owner != null) _OwnerName = _Owner.Name; InvalidateProperties(); }
          }
  
          public virtual string OwnerName
          {
              get { return _OwnerName; }
              set { _OwnerName = value; InvalidateProperties(); }
          }
  
  		/* Weapon internals work differently now (Mar 13 2003)
          *
          * The attributes defined below default to -1.
          * If the value is -1, the corresponding virtual 'Aos/Old' property is used.
          * If not, the attribute value itself is used. Here's the list:
          *  - MinDamage
          *  - MaxDamage
          *  - Speed
          *  - HitSound
          *  - MissSound
          *  - StrRequirement, DexRequirement, IntRequirement
          *  - WeaponType
          *  - WeaponAnimation
          *  - MaxRange
          */
  
  		#region Var declarations
  		// Instance values. These values are unique to each weapon.
  		private WeaponDamageLevel m_DamageLevel;
  		private WeaponAccuracyLevel m_AccuracyLevel;
  		private WeaponDurabilityLevel m_DurabilityLevel;
  		private ItemQuality m_Quality;
  		private Mobile m_Crafter;
  		private Poison m_Poison;
  		private int m_PoisonCharges;
  		private bool m_Identified;
  		private int m_Hits;
  		private int m_MaxHits;
  		private SlayerName m_Slayer;
  		private SlayerName m_Slayer2;
  
  		#region Mondain's Legacy
  		private TalismanSlayerName m_Slayer3;
  		#endregion
  
  		private SkillMod m_SkillMod, m_MageMod, m_MysticMod;
  		private CraftResource m_Resource;
  		private bool m_PlayerConstructed;
  
          private bool m_Altered;
  
          private AosAttributes m_AosAttributes;
  		private AosWeaponAttributes m_AosWeaponAttributes;
  		private AosSkillBonuses m_AosSkillBonuses;
  		private AosElementAttributes m_AosElementDamages;
  		private SAAbsorptionAttributes m_SAAbsorptionAttributes;
          private NegativeAttributes m_NegativeAttributes;
          private ExtendedWeaponAttributes m_ExtendedWeaponAttributes;
  
  		// Overridable values. These values are provided to override the defaults which get defined in the individual weapon scripts.
  		private int m_StrReq, m_DexReq, m_IntReq;
  		private int m_MinDamage, m_MaxDamage;
  		private int m_HitSound, m_MissSound;
  		private float m_Speed;
  		private int m_MaxRange;
  		private SkillName m_Skill;
  		private WeaponType m_Type;
  		private WeaponAnimation m_Animation;
  
          #region Stygian Abyss
          private int m_TimesImbued;
          private bool m_IsImbued;
          private bool m_DImodded;
          #endregion
  
          #region High Seas
          private bool m_SearingWeapon;
          #endregion
  
          #region Runic Reforging
          private ItemPower m_ItemPower;
          private ReforgedPrefix m_ReforgedPrefix;
          private ReforgedSuffix m_ReforgedSuffix;
          #endregion
          #endregion
  
          #region Virtual Properties
          public virtual WeaponAbility PrimaryAbility { get { return null; } }
  		public virtual WeaponAbility SecondaryAbility { get { return null; } }
  
  		public virtual int DefMaxRange { get { return 1; } }
  		public virtual int DefHitSound { get { return 0; } }
  		public virtual int DefMissSound { get { return 0; } }
  		public virtual SkillName DefSkill { get { return SkillName.Swords; } }
  		public virtual WeaponType DefType { get { return WeaponType.Slashing; } }
  		public virtual WeaponAnimation DefAnimation { get { return WeaponAnimation.Slash1H; } }
  
  		public virtual int AosStrengthReq { get { return 0; } }
  		public virtual int AosDexterityReq { get { return 0; } }
  		public virtual int AosIntelligenceReq { get { return 0; } }
  		public virtual int AosMinDamage { get { return 0; } }
  		public virtual int AosMaxDamage { get { return 0; } }
  		public virtual int AosSpeed { get { return 0; } }
  		public virtual float MlSpeed { get { return 0.0f; } }
  		public virtual int AosMaxRange { get { return DefMaxRange; } }
  		public virtual int AosHitSound { get { return DefHitSound; } }
  		public virtual int AosMissSound { get { return DefMissSound; } }
  		public virtual SkillName AosSkill { get { return DefSkill; } }
  		public virtual WeaponType AosType { get { return DefType; } }
  		public virtual WeaponAnimation AosAnimation { get { return DefAnimation; } }
  
  		public virtual int OldStrengthReq { get { return 0; } }
  		public virtual int OldDexterityReq { get { return 0; } }
  		public virtual int OldIntelligenceReq { get { return 0; } }
  		public virtual int OldMinDamage { get { return 0; } }
  		public virtual int OldMaxDamage { get { return 0; } }
  		public virtual int OldSpeed { get { return 0; } }
  		public virtual int OldMaxRange { get { return DefMaxRange; } }
  		public virtual int OldHitSound { get { return DefHitSound; } }
  		public virtual int OldMissSound { get { return DefMissSound; } }
  		public virtual SkillName OldSkill { get { return DefSkill; } }
  		public virtual WeaponType OldType { get { return DefType; } }
  		public virtual WeaponAnimation OldAnimation { get { return DefAnimation; } }
  
  		public virtual int InitMinHits { get { return 0; } }
  		public virtual int InitMaxHits { get { return 0; } }
  
          public virtual bool CanFortify { get { return !IsImbued && NegativeAttributes.Antique < 4; } }
          public virtual bool CanRepair { get { return m_NegativeAttributes.NoRepair == 0; } }
  		public virtual bool CanAlter { get { return true; } }
  
  		public override int PhysicalResistance { get { return m_AosWeaponAttributes.ResistPhysicalBonus; } }
  		public override int FireResistance { get { return m_AosWeaponAttributes.ResistFireBonus; } }
  		public override int ColdResistance { get { return m_AosWeaponAttributes.ResistColdBonus; } }
  		public override int PoisonResistance { get { return m_AosWeaponAttributes.ResistPoisonBonus; } }
  		public override int EnergyResistance { get { return m_AosWeaponAttributes.ResistEnergyBonus; } }
  
  		public virtual SkillName AccuracySkill { get { return SkillName.Tactics; } }
  
          public override double DefaultWeight
          {
              get
              {
                  if (NegativeAttributes == null || NegativeAttributes.Unwieldly == 0)
                      return base.DefaultWeight;
  
                  return 50;
              }
          }
  
  		#region Personal Bless Deed
  		private Mobile m_BlessedBy;
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public Mobile BlessedBy
  		{
  			get { return m_BlessedBy; }
  			set
  			{
  				m_BlessedBy = value;
  				InvalidateProperties();
  			}
  		}
  
  		private class UnBlessEntry : ContextMenuEntry
  		{
  			private readonly Mobile m_From;
  			private readonly BaseWeapon m_Weapon; // BaseArmor, BaseWeapon or BaseClothing
  
  			public UnBlessEntry(Mobile from, BaseWeapon weapon)
  				: base(6208, -1)
  			{
  				m_From = from;
  				m_Weapon = weapon;
  			}
  
  			public override void OnClick()
  			{
  				m_Weapon.BlessedFor = null;
  				m_Weapon.BlessedBy = null;
  
  				Container pack = m_From.Backpack;
  
  				if (pack != null)
  				{
  					pack.DropItem(new PersonalBlessDeed(m_From));
  					m_From.SendLocalizedMessage(1062200); // A personal bless deed has been placed in your backpack.
  				}
  			}
  		}
  		#endregion
  
  		#endregion
  
  		#region Getters & Setters
  		[CommandProperty(AccessLevel.GameMaster)]
  		public AosAttributes Attributes { get { return m_AosAttributes; } set { } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public AosWeaponAttributes WeaponAttributes { get { return m_AosWeaponAttributes; } set { } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public AosSkillBonuses SkillBonuses { get { return m_AosSkillBonuses; } set { } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public AosElementAttributes AosElementDamages { get { return m_AosElementDamages; } set { } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public SAAbsorptionAttributes AbsorptionAttributes { get { return m_SAAbsorptionAttributes; } set { } }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public NegativeAttributes NegativeAttributes { get { return m_NegativeAttributes; } set { } }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public ExtendedWeaponAttributes ExtendedWeaponAttributes { get { return m_ExtendedWeaponAttributes; } set { } }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public ConsecratedWeaponContext ConsecratedContext { get; set; }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public bool Identified
  		{
  			get { return m_Identified; }
  			set
  			{
  				m_Identified = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int HitPoints
  		{
  			get { return m_Hits; }
  			set
  			{
  				if (m_Hits == value)
  				{
  					return;
  				}
  
  				if (value > m_MaxHits)
  				{
  					value = m_MaxHits;
  				}
  
  				m_Hits = value;
  
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int MaxHitPoints
  		{
  			get { return m_MaxHits; }
  			set
  			{
  				m_MaxHits = value;
  
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int PoisonCharges
  		{
  			get { return m_PoisonCharges; }
  			set
  			{
  				m_PoisonCharges = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public Poison Poison
  		{
  			get { return m_Poison; }
  			set
  			{
  				m_Poison = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public ItemQuality Quality
  		{
  			get { return m_Quality; }
  			set
  			{
  				UnscaleDurability();
                  UnscaleUses();
  				m_Quality = value;
  				ScaleDurability();
                  ScaleUses();
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public Mobile Crafter
  		{
  			get { return m_Crafter; }
  			set
  			{
  				m_Crafter = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public SlayerName Slayer
  		{
  			get { return m_Slayer; }
  			set
  			{
  				m_Slayer = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public SlayerName Slayer2
  		{
  			get { return m_Slayer2; }
  			set
  			{
  				m_Slayer2 = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public TalismanSlayerName Slayer3
  		{
  			get { return m_Slayer3; }
  			set
  			{
  				m_Slayer3 = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public CraftResource Resource
  		{
  			get { return m_Resource; }
  			set
  			{
  				UnscaleDurability();
  				m_Resource = value;
  				Hue = CraftResources.GetHue(m_Resource);
  				InvalidateProperties();
  				ScaleDurability();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public WeaponDamageLevel DamageLevel
  		{
  			get { return m_DamageLevel; }
  			set
  			{
  				m_DamageLevel = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public WeaponDurabilityLevel DurabilityLevel
  		{
  			get { return m_DurabilityLevel; }
  			set
  			{
  				UnscaleDurability();
  				m_DurabilityLevel = value;
  				InvalidateProperties();
  				ScaleDurability();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public bool PlayerConstructed { get { return m_PlayerConstructed; } set { m_PlayerConstructed = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int MaxRange
  		{
  			get { return (m_MaxRange == -1 ? Core.AOS ? AosMaxRange : OldMaxRange : m_MaxRange); }
  			set
  			{
  				m_MaxRange = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public WeaponAnimation Animation { get { return (m_Animation == (WeaponAnimation)(-1) ? Core.AOS ? AosAnimation : OldAnimation : m_Animation); } set { m_Animation = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public WeaponType Type { get { return (m_Type == (WeaponType)(-1) ? Core.AOS ? AosType : OldType : m_Type); } set { m_Type = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public SkillName Skill
  		{
  			get { return (m_Skill == (SkillName)(-1) ? Core.AOS ? AosSkill : OldSkill : m_Skill); }
  			set
  			{
  				m_Skill = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int HitSound { get { return (m_HitSound == -1 ? Core.AOS ? AosHitSound : OldHitSound : m_HitSound); } set { m_HitSound = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int MissSound { get { return (m_MissSound == -1 ? Core.AOS ? AosMissSound : OldMissSound : m_MissSound); } set { m_MissSound = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int MinDamage
  		{
  			get { return (m_MinDamage == -1 ? Core.AOS ? AosMinDamage : OldMinDamage : m_MinDamage); }
  			set
  			{
  				m_MinDamage = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int MaxDamage
  		{
  			get { return (m_MaxDamage == -1 ? Core.AOS ? AosMaxDamage : OldMaxDamage : m_MaxDamage); }
  			set
  			{
  				m_MaxDamage = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public float Speed
  		{
  			get
  			{
  				if (m_Speed != -1)
  				{
  					return m_Speed;
  				}
  
  				if (Core.ML)
  				{
  					return MlSpeed;
  				}
  				else if (Core.AOS)
  				{
  					return AosSpeed;
  				}
  
  				return OldSpeed;
  			}
  			set
  			{
  				m_Speed = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int StrRequirement
  		{
              get 
              {
                  if (m_NegativeAttributes.Massive > 0)
                  {
                      return 125;
                  }
  
                  return m_StrReq == -1 ? Core.AOS ? AosStrengthReq : OldStrengthReq : m_StrReq;
              }
  			set
  			{
  				m_StrReq = value;
  				InvalidateProperties();
  			}
  		}
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int DexRequirement { get { return (m_DexReq == -1 ? Core.AOS ? AosDexterityReq : OldDexterityReq : m_DexReq); } set { m_DexReq = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public int IntRequirement { get { return (m_IntReq == -1 ? Core.AOS ? AosIntelligenceReq : OldIntelligenceReq : m_IntReq); } set { m_IntReq = value; } }
  
  		[CommandProperty(AccessLevel.GameMaster)]
  		public WeaponAccuracyLevel AccuracyLevel
  		{
  			get { return m_AccuracyLevel; }
  			set
  			{
  				if (m_AccuracyLevel != value)
  				{
  					m_AccuracyLevel = value;
  
  					if (UseSkillMod)
  					{
  						if (m_AccuracyLevel == WeaponAccuracyLevel.Regular)
  						{
  							if (m_SkillMod != null)
  							{
  								m_SkillMod.Remove();
  							}
  
  							m_SkillMod = null;
  						}
  						else if (m_SkillMod == null && Parent is Mobile)
  						{
  							m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5);
  							((Mobile)Parent).AddSkillMod(m_SkillMod);
  						}
  						else if (m_SkillMod != null)
  						{
  							m_SkillMod.Value = (int)m_AccuracyLevel * 5;
  						}
  					}
  
  					InvalidateProperties();
  				}
  			}
  		}
  
          public Mobile FocusWeilder { get; set; }
          public Mobile EnchantedWeilder { get; set; }
  
          #region Stygian Abyss
          [CommandProperty(AccessLevel.GameMaster)]
          public int TimesImbued
          {
              get { return m_TimesImbued; }
              set { m_TimesImbued = value; }
          }
  
          [CommandProperty(AccessLevel.GameMaster)]
          public bool IsImbued
          {
              get
              {
                  if (TimesImbued >= 1 && !m_IsImbued)
                      m_IsImbued = true;
  
                  return m_IsImbued;
              }
              set
              {
                  if (TimesImbued >= 1)
                      m_IsImbued = true;
                  else
  
gt:                     m_IsImbued = value; InvalidateProperties();