context: using System;
  using System.Text;
  using System.Collections;
  using Server.Network;
  using Server.Targeting;
  using Server.Mobiles;
  using Server.Spells;
  using Server.Spells.Necromancy;
  using Server.Factions;
  using Server.Engines.Craft;
  
  namespace Server.Items
  {
  	public abstract class BaseWeapon : Item, IWeapon, IFactionItem, ICraftable
  	{
  		#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
  
  
  
  		/* 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
  		 */
  
  		// Instance values. These values must are unique to each weapon.
  		private WeaponDamageLevel m_DamageLevel;
  		private WeaponAccuracyLevel m_AccuracyLevel;
  		private WeaponDurabilityLevel m_DurabilityLevel;
  		private WeaponQuality 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 SkillMod m_SkillMod, m_MageMod;
  		private CraftResource m_Resource;
  		private bool m_PlayerConstructed;
  
  		private bool m_Cursed; // Is this weapon cursed via Curse Weapon necromancer spell? Temporary; not serialized.
  		private bool m_Consecrated; // Is this weapon blessed via Consecrate Weapon paladin ability? Temporary; not serialized.
  
  		private AosAttributes m_AosAttributes;
  		private AosWeaponAttributes m_AosWeaponAttributes;
  		private AosSkillBonuses m_AosSkillBonuses;
  
  		// 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 int m_Speed;
  		private int m_MaxRange;
  		private SkillName m_Skill;
  		private WeaponType m_Type;
  		private WeaponAnimation m_Animation;
  
  		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 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 override int PhysicalResistance {
  			get {
  				return m_AosWeaponAttributes == null
  					? 0 : m_AosWeaponAttributes.ResistPhysicalBonus;
  			}
  		}
  		public override int FireResistance {
  			get {
  				return m_AosWeaponAttributes == null
  					? 0 : m_AosWeaponAttributes.ResistFireBonus;
  			}
  		}
  		public override int ColdResistance {
  			get {
  				return m_AosWeaponAttributes == null
  					? 0 : m_AosWeaponAttributes.ResistColdBonus;
  			}
  		}
  		public override int PoisonResistance {
  			get {
  				return m_AosWeaponAttributes == null
  					? 0 : m_AosWeaponAttributes.ResistPoisonBonus;
  			}
  		}
  		public override int EnergyResistance {
  			get {
  				return m_AosWeaponAttributes == null
  					? 0 : m_AosWeaponAttributes.ResistEnergyBonus;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public AosAttributes Attributes
  		{
  			get{
  				if (m_AosAttributes == null)
  					m_AosAttributes = new AosAttributes(this);
  				return m_AosAttributes;
  			}
  			set{}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public AosWeaponAttributes WeaponAttributes
  		{
  			get {
  				if (m_AosWeaponAttributes == null)
  					m_AosWeaponAttributes = new AosWeaponAttributes(this);
  				return m_AosWeaponAttributes;
  			}
  			set{}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public AosSkillBonuses SkillBonuses
  		{
  			get{ return m_AosSkillBonuses; }
  			set{}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool Cursed
  		{
  			get{ return m_Cursed; }
  			set{ m_Cursed = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool Consecrated
  		{
  			get{ return m_Consecrated; }
  			set{ m_Consecrated = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool Identified
  		{
  			get{ return m_Identified; }
  			set{ m_Identified = value; InvalidateProperties(); }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int Hits
  		{
  			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 MaxHits
  		{
  			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 WeaponQuality Quality
  		{
  			get{ return m_Quality; }
  			set{ UnscaleDurability(); m_Quality = value; ScaleDurability(); 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 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 ); }
  
gt: 			set{ m_HitSound = value; }