context: // Nerun's Distro changes at lines 52-4; 2316-328.
  using System;
  using System.Collections.Generic;
  using Server.Regions;
  using Server.Targeting;
  using Server.Network;
  using Server.Multis;
  using Server.Spells;
  using Server.Misc;
  using Server.Items;
  using Server.ContextMenus;
  using Server.Engines.Quests;
  using Server.Engines.PartySystem;
  using Server.Factions;
  using Server.SkillHandlers;
  using Server.Spells.Bushido;
  using Server.Spells.Spellweaving;
  using Server.Spells.Necromancy;
  
  namespace Server.Mobiles
  {
  	#region Enums
  	/// <summary>
  	/// Summary description for MobileAI.
  	/// </summary>
  	///
  	public enum FightMode
  	{
  		None,			// Never focus on others
  		Aggressor,		// Only attack aggressors
  		Strongest,		// Attack the strongest
  		Weakest,		// Attack the weakest
  		Closest, 		// Attack the closest
  		Evil			// Only attack aggressor -or- negative karma
  	}
  
  	public enum OrderType
  	{
  		None,			//When no order, let's roam
  		Come,			//"(All/Name) come"  Summons all or one pet to your location.
  		Drop,			//"(Name) drop"  Drops its loot to the ground (if it carries any).
  		Follow,			//"(Name) follow"  Follows targeted being.
  						//"(All/Name) follow me"  Makes all or one pet follow you.
  		Friend,			//"(Name) friend"  Allows targeted player to confirm resurrection.
  		Unfriend,		// Remove a friend
  		Guard,			//"(Name) guard"  Makes the specified pet guard you. Pets can only guard their owner.
  						//"(All/Name) guard me"  Makes all or one pet guard you.
  		Attack,			//"(All/Name) kill",
  						//"(All/Name) attack"  All or the specified pet(s) currently under your control attack the target.
  		Patrol,			//"(Name) patrol"  Roves between two or more guarded targets.
  		Release,		//"(Name) release"  Releases pet back into the wild (removes "tame" status).
  // >>> [1st change of 2]
  		Dismiss,		//"(Name) dismiss"  Dismiss hireling (removes "tame" status).
  // end 1st
  		Stay,			//"(All/Name) stay" All or the specified pet(s) will stop and stay in current spot.
  		Stop,			//"(All/Name) stop Cancels any current orders to attack, guard or follow.
  		Transfer		//"(Name) transfer" Transfers complete ownership to targeted player.
  	}
  
  	[Flags]
  	public enum FoodType
  	{
  		None			= 0x0000,
  		Meat			= 0x0001,
  		FruitsAndVegies	= 0x0002,
  		GrainsAndHay	= 0x0004,
  		Fish			= 0x0008,
  		Eggs			= 0x0010,
  		Gold			= 0x0020
  	}
  
  	[Flags]
  	public enum PackInstinct
  	{
  		None			= 0x0000,
  		Canine			= 0x0001,
  		Ostard			= 0x0002,
  		Feline			= 0x0004,
  		Arachnid		= 0x0008,
  		Daemon			= 0x0010,
  		Bear			= 0x0020,
  		Equine			= 0x0040,
  		Bull			= 0x0080
  	}
  
  	public enum ScaleType
  	{
  		Red,
  		Yellow,
  		Black,
  		Green,
  		White,
  		Blue,
  		All
  	}
  
  	public enum MeatType
  	{
  		Ribs,
  		Bird,
  		LambLeg
  	}
  
  	public enum HideType
  	{
  		Regular,
  		Spined,
  		Horned,
  		Barbed
  	}
  
  	#endregion
  
  	public class DamageStore : IComparable
  	{
  		public Mobile m_Mobile;
  		public int m_Damage;
  		public bool m_HasRight;
  
  		public DamageStore( Mobile m, int damage )
  		{
  			m_Mobile = m;
  			m_Damage = damage;
  		}
  
  		public int CompareTo( object obj )
  		{
  			DamageStore ds = (DamageStore)obj;
  
  			return ds.m_Damage - m_Damage;
  		}
  	}
  
  	[AttributeUsage( AttributeTargets.Class )]
  	public class FriendlyNameAttribute : Attribute
  	{
  		//future use: Talisman 'Protection/Bonus vs. Specific Creature
  		private TextDefinition m_FriendlyName;
  
  		public TextDefinition FriendlyName
  		{
  			get
  			{
  				return m_FriendlyName;
  			}
  		}
  
  		public FriendlyNameAttribute( TextDefinition friendlyName )
  		{
  			m_FriendlyName = friendlyName;
  		}
  
  		public static TextDefinition GetFriendlyNameFor( Type t )
  		{
  			if( t.IsDefined( typeof( FriendlyNameAttribute ), false ) )
  			{
  				object[] objs = t.GetCustomAttributes( typeof( FriendlyNameAttribute ), false );
  
  				if( objs != null && objs.Length > 0 )
  				{
  					FriendlyNameAttribute friendly = objs[0] as FriendlyNameAttribute;
  
  					return friendly.FriendlyName;
  				}
  			}
  
  			return t.Name;
  		}
  	}
  
  	public partial class BaseCreature : Mobile, IHonorTarget
  	{
  		public const int MaxLoyalty = 100;
  
  		#region Var declarations
  		private BaseAI	m_AI;					// THE AI
  
  		private AIType	m_CurrentAI;			// The current AI
  		private AIType	m_DefaultAI;			// The default AI
  
  		private Mobile	m_FocusMob;				// Use focus mob instead of combatant, maybe we don't whan to fight
  		private FightMode m_FightMode;			// The style the mob uses
  
  		private int		m_iRangePerception;		// The view area
  		private int		m_iRangeFight;			// The fight distance
  
  		private bool	m_bDebugAI;				// Show debug AI messages
  
  		private int		m_iTeam;				// Monster Team
  
  		private double	m_dActiveSpeed;			// Timer speed when active
  		private double	m_dPassiveSpeed;		// Timer speed when not active
  		private double	m_dCurrentSpeed;		// The current speed, lets say it could be changed by something;
  
  		private Point3D m_pHome;				// The home position of the creature, used by some AI
  		private int		m_iRangeHome = 10;		// The home range of the creature
  
  		List<Type>		m_arSpellAttack;		// List of attack spell/power
  		List<Type>		m_arSpellDefense;		// List of defensive spell/power
  
  		private bool		m_bControlled;		// Is controlled
  		private Mobile		m_ControlMaster;	// My master
  		private Mobile		m_ControlTarget;	// My target mobile
  		private Point3D		m_ControlDest;		// My target destination (patrol)
  		private OrderType	m_ControlOrder;		// My order
  
  		private int			m_Loyalty;
  
  		private double		m_dMinTameSkill;
  		private bool		m_bTamable;
  
  		private bool		m_bSummoned = false;
  		private DateTime	m_SummonEnd;
  		private int			m_iControlSlots = 1;
  
  		private bool		m_bBardProvoked = false;
  		private bool		m_bBardPacified = false;
  		private Mobile		m_bBardMaster = null;
  		private Mobile		m_bBardTarget = null;
  		private DateTime	m_timeBardEnd;
  		private WayPoint	m_CurrentWayPoint = null;
  		private IPoint2D	m_TargetLocation = null;
  
  		private Mobile		m_SummonMaster;
  
  		private int			m_HitsMax = -1;
  		private	int			m_StamMax = -1;
  		private int			m_ManaMax = -1;
  		private int			m_DamageMin = -1;
  		private int			m_DamageMax = -1;
  
  		private int			m_PhysicalResistance, m_PhysicalDamage = 100;
  		private int			m_FireResistance, m_FireDamage;
  		private int			m_ColdResistance, m_ColdDamage;
  		private int			m_PoisonResistance, m_PoisonDamage;
  		private int			m_EnergyResistance, m_EnergyDamage;
  		private int			m_ChaosDamage;
  		private int			m_DirectDamage;
  
  		private List<Mobile> m_Owners;
  		private List<Mobile> m_Friends;
  
  		private bool		m_IsStabled;
  		private Mobile		m_StabledBy;
  
  		private bool		m_HasGeneratedLoot; // have we generated our loot yet?
  
  		private bool		m_Paragon;
  
  		private bool		m_IsPrisoner;
  
  		private string		m_CorpseNameOverride;
  		#endregion
  
  		public virtual InhumanSpeech SpeechType{ get{ return null; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public string CorpseNameOverride
  		{
  			get { return m_CorpseNameOverride; }
  			set { m_CorpseNameOverride = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
  		public bool IsStabled
  		{
  			get{ return m_IsStabled; }
  			set
  			{
  				m_IsStabled = value;
  				if ( m_IsStabled )
  					StopDeleteTimer();
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
  		public Mobile StabledBy
  		{
  			get { return m_StabledBy; }
  			set { m_StabledBy = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsPrisoner
  		{
  			get{ return m_IsPrisoner; }
  			set{ m_IsPrisoner = value; }
  		}
  
  		protected DateTime SummonEnd
  		{
  			get { return m_SummonEnd; }
  			set { m_SummonEnd = value; }
  		}
  
  		public virtual Faction FactionAllegiance{ get{ return null; } }
  		public virtual int FactionSilverWorth{ get{ return 30; } }
  
  		#region Bonding
  		public const bool BondingEnabled = true;
  
  		public virtual bool IsBondable{ get{ return ( BondingEnabled && !Summoned ); } }
  		public virtual TimeSpan BondingDelay{ get{ return TimeSpan.FromDays( 7.0 ); } }
  		public virtual TimeSpan BondingAbandonDelay{ get{ return TimeSpan.FromDays( 1.0 ); } }
  
  		public override bool CanRegenHits{ get{ return !m_IsDeadPet && base.CanRegenHits; } }
  		public override bool CanRegenStam{ get{ return !m_IsDeadPet && base.CanRegenStam; } }
  		public override bool CanRegenMana{ get{ return !m_IsDeadPet && base.CanRegenMana; } }
  
  		public override bool IsDeadBondedPet{ get{ return m_IsDeadPet; } }
  
  		private bool m_IsBonded;
  		private bool m_IsDeadPet;
  		private DateTime m_BondingBegin;
  		private DateTime m_OwnerAbandonTime;
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public Mobile LastOwner
  		{
  			get
  			{
  				if ( m_Owners == null || m_Owners.Count == 0 )
  					return null;
  
  				return m_Owners[m_Owners.Count - 1];
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsBonded
  		{
  			get{ return m_IsBonded; }
  			set{ m_IsBonded = value; InvalidateProperties(); }
  		}
  
  		public bool IsDeadPet
  		{
  			get{ return m_IsDeadPet; }
  			set{ m_IsDeadPet = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public DateTime BondingBegin
  		{
  			get{ return m_BondingBegin; }
  			set{ m_BondingBegin = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public DateTime OwnerAbandonTime
  		{
  			get{ return m_OwnerAbandonTime; }
  			set{ m_OwnerAbandonTime = value; }
  		}
  		#endregion
  
  		#region Delete Previously Tamed Timer
  		private DeleteTimer		m_DeleteTimer;
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public TimeSpan DeleteTimeLeft
  		{
  			get
  			{
  				if ( m_DeleteTimer != null && m_DeleteTimer.Running )
  					return m_DeleteTimer.Next - DateTime.Now;
  
  				return TimeSpan.Zero;
  			}
  		}
  
  		private class DeleteTimer : Timer
  		{
  			private Mobile m;
  
  			public DeleteTimer( Mobile creature, TimeSpan delay ) : base( delay )
  			{
  				m = creature;
  				Priority = TimerPriority.OneMinute;
  			}
  
  			protected override void OnTick()
  			{
  				m.Delete();
  			}
  		}
  
  		public void BeginDeleteTimer()
  		{
  			if ( !(this is BaseEscortable) && !Summoned && !Deleted && !IsStabled )
  			{
  				StopDeleteTimer();
  				m_DeleteTimer = new DeleteTimer( this, TimeSpan.FromDays( 3.0 ) );
  				m_DeleteTimer.Start();
  			}
  		}
  
  		public void StopDeleteTimer()
  		{
  			if ( m_DeleteTimer != null )
  			{
  				m_DeleteTimer.Stop();
  				m_DeleteTimer = null;
  			}
  		}
  
  		#endregion
  
  		public virtual double WeaponAbilityChance{ get{ return 0.4; } }
  
  		public virtual WeaponAbility GetWeaponAbility()
  		{
  			return null;
  		}
  
  		#region Elemental Resistance/Damage
  
  		public override int BasePhysicalResistance{ get{ return m_PhysicalResistance; } }
  		public override int BaseFireResistance{ get{ return m_FireResistance; } }
  		public override int BaseColdResistance{ get{ return m_ColdResistance; } }
  		public override int BasePoisonResistance{ get{ return m_PoisonResistance; } }
  		public override int BaseEnergyResistance{ get{ return m_EnergyResistance; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int PhysicalResistanceSeed{ get{ return m_PhysicalResistance; } set{ m_PhysicalResistance = value; UpdateResistances(); } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int FireResistSeed{ get{ return m_FireResistance; } set{ m_FireResistance = value; UpdateResistances(); } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int ColdResistSeed{ get{ return m_ColdResistance; } set{ m_ColdResistance = value; UpdateResistances(); } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int PoisonResistSeed{ get{ return m_PoisonResistance; } set{ m_PoisonResistance = value; UpdateResistances(); } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int EnergyResistSeed{ get{ return m_EnergyResistance; } set{ m_EnergyResistance = value; UpdateResistances(); } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int PhysicalDamage{ get{ return m_PhysicalDamage; } set{ m_PhysicalDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int FireDamage{ get{ return m_FireDamage; } set{ m_FireDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int ColdDamage{ get{ return m_ColdDamage; } set{ m_ColdDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int PoisonDamage{ get{ return m_PoisonDamage; } set{ m_PoisonDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int EnergyDamage{ get{ return m_EnergyDamage; } set{ m_EnergyDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int ChaosDamage{ get{ return m_ChaosDamage; } set{ m_ChaosDamage = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int DirectDamage{ get{ return m_DirectDamage; } set{ m_DirectDamage = value; } }
  
  		#endregion
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsParagon
  		{
  			get{ return m_Paragon; }
  			set
  			{
  				if ( m_Paragon == value )
  					return;
  				else if ( value )
  					Paragon.Convert( this );
  				else
  					Paragon.UnConvert( this );
  
  				m_Paragon = value;
  
  				InvalidateProperties();
  			}
  		}
  
  		public virtual FoodType FavoriteFood{ get{ return FoodType.Meat; } }
  		public virtual PackInstinct PackInstinct{ get{ return PackInstinct.None; } }
  
  		public List<Mobile> Owners { get { return m_Owners; } }
  
  		public virtual bool AllowMaleTamer{ get{ return true; } }
  		public virtual bool AllowFemaleTamer{ get{ return true; } }
  		public virtual bool SubdueBeforeTame{ get{ return false; } }
  		public virtual bool StatLossAfterTame{ get{ return SubdueBeforeTame; } }
  		public virtual bool ReduceSpeedWithDamage{ get{ return true; } }
  		public virtual bool IsSubdued{ get{ return SubdueBeforeTame && ( Hits < ( HitsMax / 10 ) ); } }
  
  		public virtual bool Commandable{ get{ return true; } }
  
  		public virtual Poison HitPoison{ get{ return null; } }
  		public virtual double HitPoisonChance{ get{ return 0.5; } }
  		public virtual Poison PoisonImmune{ get{ return null; } }
  
  		public virtual bool BardImmune{ get{ return false; } }
  		public virtual bool Unprovokable{ get{ return BardImmune || m_IsDeadPet; } }
  		public virtual bool Uncalmable{ get{ return BardImmune || m_IsDeadPet; } }
  		public virtual bool AreaPeaceImmune { get { return BardImmune || m_IsDeadPet; } }
  
  		public virtual bool BleedImmune{ get{ return false; } }
  		public virtual double BonusPetDamageScalar{ get{ return 1.0; } }
  
  		public virtual bool DeathAdderCharmable{ get{ return false; } }
  
  		//TODO: Find the pub 31 tweaks to the DispelDifficulty and apply them of course.
  		public virtual double DispelDifficulty{ get{ return 0.0; } } // at this skill level we dispel 50% chance
  		public virtual double DispelFocus{ get{ return 20.0; } } // at difficulty - focus we have 0%, at difficulty + focus we have 100%
  		public virtual bool DisplayWeight{ get{ return Backpack is StrongBackpack; } }
  
  		#region Breath ability, like dragon fire breath
  		private DateTime m_NextBreathTime;
  
  		// Must be overriden in subclass to enable
  		public virtual bool HasBreath{ get{ return false; } }
  
  		// Base damage given is: CurrentHitPoints * BreathDamageScalar
  		public virtual double BreathDamageScalar{ get{ return (Core.AOS ? 0.16 : 0.05); } }
  
  		// Min/max seconds until next breath
  		public virtual double BreathMinDelay{ get{ return 30.0; } }
  		public virtual double BreathMaxDelay{ get{ return 45.0; } }
  
  		// Creature stops moving for 1.0 seconds while breathing
  		public virtual double BreathStallTime{ get{ return 1.0; } }
  
  		// Effect is sent 1.3 seconds after BreathAngerSound and BreathAngerAnimation is played
  		public virtual double BreathEffectDelay{ get{ return 1.3; } }
  
  		// Damage is given 1.0 seconds after effect is sent
  		public virtual double BreathDamageDelay{ get{ return 1.0; } }
  
  		public virtual int BreathRange{ get{ return RangePerception; } }
  
  		// Damage types
  		public virtual int BreathChaosDamage{ get { return 0; } }
  		public virtual int BreathPhysicalDamage{ get{ return 0; } }
  		public virtual int BreathFireDamage{ get{ return 100; } }
  		public virtual int BreathColdDamage{ get{ return 0; } }
  		public virtual int BreathPoisonDamage{ get{ return 0; } }
  		public virtual int BreathEnergyDamage{ get{ return 0; } }
  
  		// Is immune to breath damages
  		public virtual bool BreathImmune{ get{ return false; } }
  
  		// Effect details and sound
  		public virtual int BreathEffectItemID{ get{ return 0x36D4; } }
  		public virtual int BreathEffectSpeed{ get{ return 5; } }
  		public virtual int BreathEffectDuration{ get{ return 0; } }
  		public virtual bool BreathEffectExplodes{ get{ return false; } }
  		public virtual bool BreathEffectFixedDir{ get{ return false; } }
  		public virtual int BreathEffectHue{ get{ return 0; } }
  		public virtual int BreathEffectRenderMode{ get{ return 0; } }
  
  		public virtual int BreathEffectSound{ get{ return 0x227; } }
  
  		// Anger sound/animations
  		public virtual int BreathAngerSound{ get{ return GetAngerSound(); } }
  		public virtual int BreathAngerAnimation{ get{ return 12; } }
  
  		public virtual void BreathStart( Mobile target )
  		{
  			BreathStallMovement();
  			BreathPlayAngerSound();
  			BreathPlayAngerAnimation();
  
  			this.Direction = this.GetDirectionTo( target );
  
  			Timer.DelayCall( TimeSpan.FromSeconds( BreathEffectDelay ), new TimerStateCallback( BreathEffect_Callback ), target );
  		}
  
  		public virtual void BreathStallMovement()
  		{
  			if ( m_AI != null )
  				m_AI.NextMove = DateTime.Now + TimeSpan.FromSeconds( BreathStallTime );
  		}
  
  		public virtual void BreathPlayAngerSound()
  		{
  			PlaySound( BreathAngerSound );
  		}
  
  		public virtual void BreathPlayAngerAnimation()
  		{
  			Animate( BreathAngerAnimation, 5, 1, true, false, 0 );
  		}
  
  		public virtual void BreathEffect_Callback( object state )
  		{
  			Mobile target = (Mobile)state;
  
  			if ( !target.Alive || !CanBeHarmful( target ) )
  				return;
  
  			BreathPlayEffectSound();
  			BreathPlayEffect( target );
  
  			Timer.DelayCall( TimeSpan.FromSeconds( BreathDamageDelay ), new TimerStateCallback( BreathDamage_Callback ), target );
  		}
  
  		public virtual void BreathPlayEffectSound()
  		{
  			PlaySound( BreathEffectSound );
  		}
  
  		public virtual void BreathPlayEffect( Mobile target )
  		{
  			Effects.SendMovingEffect( this, target, BreathEffectItemID,
  				BreathEffectSpeed, BreathEffectDuration, BreathEffectFixedDir,
  				BreathEffectExplodes, BreathEffectHue, BreathEffectRenderMode );
  		}
  
  		public virtual void BreathDamage_Callback( object state )
  		{
  			Mobile target = (Mobile)state;
  
  			if ( target is BaseCreature && ((BaseCreature)target).BreathImmune )
  				return;
  
  			if ( CanBeHarmful( target ) )
  			{
  				DoHarmful( target );
  				BreathDealDamage( target );
  			}
  		}
  
  		public virtual void BreathDealDamage( Mobile target )
  		{
  			if( !Evasion.CheckSpellEvasion( target ) )
  			{
  				int physDamage = BreathPhysicalDamage;
  				int fireDamage = BreathFireDamage;
  				int coldDamage = BreathColdDamage;
  				int poisDamage = BreathPoisonDamage;
  				int nrgyDamage = BreathEnergyDamage;
  
  				if( BreathChaosDamage > 0 )
  				{
  					switch( Utility.Random( 5 ))
  					{
  						case 0: physDamage += BreathChaosDamage; break;
  						case 1: fireDamage += BreathChaosDamage; break;
  						case 2: coldDamage += BreathChaosDamage; break;
  						case 3: poisDamage += BreathChaosDamage; break;
  						case 4: nrgyDamage += BreathChaosDamage; break;
  					}
  				}
  
  				if( physDamage == 0 && fireDamage == 0 && coldDamage == 0 && poisDamage == 0 && nrgyDamage == 0 )
  				{
  					target.Damage( BreathComputeDamage(), this );// Unresistable damage even in AOS
  				}
  				else
  				{
  					AOS.Damage( target, this, BreathComputeDamage(), physDamage, fireDamage, coldDamage, poisDamage, nrgyDamage );
  				}
  			}
  		}
  
  		public virtual int BreathComputeDamage()
  		{
  			int damage = (int)(Hits * BreathDamageScalar);
  
  			if ( IsParagon )
  				damage = (int)(damage / Paragon.HitsBuff);
  
  			if ( damage > 200 )
  				damage = 200;
  
  			return damage;
  		}
  
  		#endregion
  
  		public virtual bool CanFly { get { return false; } }
  
  		#region Spill Acid
  
  		public void SpillAcid( int Amount )
  		{
  			SpillAcid( null, Amount );
  		}
  
  		public void SpillAcid( Mobile target, int Amount )
  		{
  			if ( (target != null && target.Map == null) || this.Map == null )
  				return;
  
  			for ( int i = 0; i < Amount; ++i )
  			{
  				Point3D loc = this.Location;
  				Map map = this.Map;
  				Item acid = NewHarmfulItem();
  
  				if ( target != null && target.Map != null && Amount == 1 )
  				{
  					loc = target.Location;
  					map = target.Map;
  				}
  				else
  				{
  					bool validLocation = false;
  					for ( int j = 0; !validLocation && j < 10; ++j )
  					{
  						loc = new Point3D(
  							loc.X+(Utility.Random(0,3)-2),
  							loc.Y+(Utility.Random(0,3)-2),
  							loc.Z );
  						loc.Z = map.GetAverageZ( loc.X, loc.Y );
  						validLocation = map.CanFit( loc, 16, false, false ) ;
  					}
  				}
  				acid.MoveToWorld( loc, map );
  			}
  		}
  
  		/*
  			Solen Style, override me for other mobiles/items:
  			kappa+acidslime, grizzles+whatever, etc.
  		*/
  
  		public virtual Item NewHarmfulItem()
  		{
  			return new PoolOfAcid( TimeSpan.FromSeconds(10), 30, 30 );
  		}
  
  		#endregion
  
  		#region Flee!!!
  		public virtual bool CanFlee{ get{ return !m_Paragon; } }
  
  		private DateTime m_EndFlee;
  
  		public DateTime EndFleeTime
  		{
  			get{ return m_EndFlee; }
  			set{ m_EndFlee = value; }
  		}
  
  		public virtual void StopFlee()
  		{
  			m_EndFlee = DateTime.MinValue;
  		}
  
  		public virtual bool CheckFlee()
  		{
  			if ( m_EndFlee == DateTime.MinValue )
  				return false;
  
  			if ( DateTime.Now >= m_EndFlee )
  			{
  				StopFlee();
  				return false;
  			}
  
  			return true;
  		}
  
  		public virtual void BeginFlee( TimeSpan maxDuration )
  		{
  			m_EndFlee = DateTime.Now + maxDuration;
  		}
  
  		#endregion
  
  		public BaseAI AIObject{ get{ return m_AI; } }
  
  		public const int MaxOwners = 5;
  
  		public virtual OppositionGroup OppositionGroup
  		{
  			get{ return null; }
  		}
  
  		#region Friends
  		public List<Mobile> Friends { get { return m_Friends; } }
  
  		public virtual bool AllowNewPetFriend
  		{
  			get{ return ( m_Friends == null || m_Friends.Count < 5 ); }
  		}
  
  		public virtual bool IsPetFriend( Mobile m )
  		{
  			return ( m_Friends != null && m_Friends.Contains( m ) );
  		}
  
  		public virtual void AddPetFriend( Mobile m )
  		{
  			if ( m_Friends == null )
  				m_Friends = new List<Mobile>();
  
  			m_Friends.Add( m );
  		}
  
  		public virtual void RemovePetFriend( Mobile m )
  		{
  			if ( m_Friends != null )
  				m_Friends.Remove( m );
  		}
  
  		public virtual bool IsFriend( Mobile m )
  		{
  			OppositionGroup g = this.OppositionGroup;
  
  			if ( g != null && g.IsEnemy( this, m ) )
  				return false;
  
  			if ( !(m is BaseCreature) )
  				return false;
  
  			BaseCreature c = (BaseCreature)m;
  
  			return ( m_iTeam == c.m_iTeam && ( (m_bSummoned || m_bControlled) == (c.m_bSummoned || c.m_bControlled) )/* && c.Combatant != this */);
  		}
  
  		#endregion
  
  		#region Allegiance
  		public virtual Ethics.Ethic EthicAllegiance { get { return null; } }
  
  		public enum Allegiance
  		{
  			None,
  			Ally,
  			Enemy
  		}
  
  		public virtual Allegiance GetFactionAllegiance( Mobile mob )
  		{
  			if ( mob == null || mob.Map != Faction.Facet || FactionAllegiance == null )
  				return Allegiance.None;
  
  			Faction fac = Faction.Find( mob, true );
  
  			if ( fac == null )
  				return Allegiance.None;
  
  			return ( fac == FactionAllegiance ? Allegiance.Ally : Allegiance.Enemy );
  		}
  
  		public virtual Allegiance GetEthicAllegiance( Mobile mob )
  		{
  			if ( mob == null || mob.Map != Faction.Facet || EthicAllegiance == null )
  				return Allegiance.None;
  
  			Ethics.Ethic ethic = Ethics.Ethic.Find( mob, true );
  
  			if ( ethic == null )
  				return Allegiance.None;
  
  			return ( ethic == EthicAllegiance ? Allegiance.Ally : Allegiance.Enemy );
  		}
  
  		#endregion
  
  		public virtual bool IsEnemy( Mobile m )
  		{
  			OppositionGroup g = this.OppositionGroup;
  
  			if ( g != null && g.IsEnemy( this, m ) )
  				return true;
  
  			if ( m is BaseGuard )
  				return false;
  
  			if ( GetFactionAllegiance( m ) == Allegiance.Ally )
  				return false;
  
  			Ethics.Ethic ourEthic = EthicAllegiance;
  			Ethics.Player pl = Ethics.Player.Find( m, true );
  
  			if ( pl != null && pl.IsShielded && ( ourEthic == null || ourEthic == pl.Ethic ) )
  				return false;
  
  			if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
  				return true;
  
  			if( TransformationSpellHelper.UnderTransformation( m, typeof( EtherealVoyageSpell ) ) )
  				return false;
  
  			if ( m is PlayerMobile && ( (PlayerMobile)m ).HonorActive )
  				return false;
  
  			BaseCreature c = (BaseCreature)m;
  
  			if ( ( FightMode == FightMode.Evil && m.Karma < 0 ) || ( c.FightMode == FightMode.Evil && Karma < 0 ) )
  				return true;
  
  			return ( m_iTeam != c.m_iTeam || ( (m_bSummoned || m_bControlled) != (c.m_bSummoned || c.m_bControlled ) )/* || c.Combatant == this*/ );
  		}
  
  		public override string ApplyNameSuffix( string suffix )
  		{
  			if ( IsParagon && !GivesMLMinorArtifact )
  			{
  				if ( suffix.Length == 0 )
  					suffix = "(Paragon)";
  				else
  					suffix = String.Concat( suffix, " (Paragon)" );
  			}
  
  			return base.ApplyNameSuffix( suffix );
  		}
  
  		public virtual bool CheckControlChance( Mobile m )
  		{
  			if ( GetControlChance( m ) > Utility.RandomDouble() )
  			{
  				Loyalty += 1;
  				return true;
  			}
  
  			PlaySound( GetAngerSound() );
  
  			if ( Body.IsAnimal )
  				Animate( 10, 5, 1, true, false, 0 );
  			else if ( Body.IsMonster )
  				Animate( 18, 5, 1, true, false, 0 );
  
  			Loyalty -= 3;
  			return false;
  		}
  
  		public virtual bool CanBeControlledBy( Mobile m )
  		{
  			return ( GetControlChance( m ) > 0.0 );
  		}
  
  		public double GetControlChance( Mobile m )
  		{
  			return GetControlChance( m, false );
  		}
  
  		public virtual double GetControlChance( Mobile m, bool useBaseSkill )
  		{
  			if ( m_dMinTameSkill <= 29.1 || m_bSummoned || m.AccessLevel >= AccessLevel.GameMaster )
  				return 1.0;
  
  			double dMinTameSkill = m_dMinTameSkill;
  
  			if ( dMinTameSkill > -24.9 && Server.SkillHandlers.AnimalTaming.CheckMastery( m, this ) )
  				dMinTameSkill = -24.9;
  
  			int taming = (int)((useBaseSkill ? m.Skills[SkillName.AnimalTaming].Base : m.Skills[SkillName.AnimalTaming].Value ) * 10);
  			int lore = (int)((useBaseSkill ? m.Skills[SkillName.AnimalLore].Base : m.Skills[SkillName.AnimalLore].Value )* 10);
  			int bonus = 0, chance = 700;
  
  			if( Core.ML )
  			{
  				int SkillBonus = taming - (int)(dMinTameSkill * 10);
  				int LoreBonus = lore - (int)(dMinTameSkill * 10);
  
  				int SkillMod = 6, LoreMod = 6;
  
  				if( SkillBonus < 0 )
  					SkillMod = 28;
  				if( LoreBonus < 0 )
  					LoreMod = 14;
  
  				SkillBonus *= SkillMod;
  				LoreBonus *= LoreMod;
  
  				bonus = (SkillBonus + LoreBonus ) / 2;
  			}
  			else
  			{
  				int difficulty = (int)(dMinTameSkill * 10);
  				int weighted = ((taming * 4) + lore) / 5;
  				bonus = weighted - difficulty;
  
  				if ( bonus <= 0 )
  					bonus *= 14;
  				else
  					bonus *= 6;
  			}
  
  			chance += bonus;
  
  			if ( chance >= 0 && chance < 200 )
  				chance = 200;
  			else if ( chance > 990 )
  				chance = 990;
  
  			chance -= (MaxLoyalty - m_Loyalty) * 10;
  
  			return ( (double)chance / 1000 );
  		}
  
  		private static Type[] m_AnimateDeadTypes = new Type[]
  			{
  				typeof( MoundOfMaggots ), typeof( HellSteed ), typeof( SkeletalMount ),
  				typeof( WailingBanshee ), typeof( Wraith ), typeof( SkeletalDragon ),
  				typeof( LichLord ), typeof( FleshGolem ), typeof( Lich ),
  				typeof( SkeletalKnight ), typeof( BoneKnight ), typeof( Mummy ),
  				typeof( SkeletalMage ), typeof( BoneMagi ), typeof( PatchworkSkeleton )
  			};
  
  		public virtual bool IsAnimatedDead
  		{
  			get
  			{
  				if ( !Summoned )
  					return false;
  
  				Type type = this.GetType();
  
  				bool contains = false;
  
  				for ( int i = 0; !contains && i < m_AnimateDeadTypes.Length; ++i )
  					contains = ( type == m_AnimateDeadTypes[i] );
  
  				return contains;
  			}
  		}
  
  		public virtual bool IsNecroFamiliar
  		{
  			get
  			{
  				if ( !Summoned )
  					return false;
  
  				if ( m_ControlMaster != null && SummonFamiliarSpell.Table.Contains( m_ControlMaster ) )
  					return SummonFamiliarSpell.Table[ m_ControlMaster ] == this;
  
  				return false;
  			}
  		}
  
  		public override void Damage( int amount, Mobile from )
  		{
  			int oldHits = this.Hits;
  
  			if ( Core.AOS && !this.Summoned && this.Controlled && 0.2 > Utility.RandomDouble() )
  				amount = (int)(amount * BonusPetDamageScalar);
  
  			if ( Spells.Necromancy.EvilOmenSpell.TryEndEffect( this ) )
  				amount = (int)(amount * 1.25);
  
  			Mobile oath = Spells.Necromancy.BloodOathSpell.GetBloodOath( from );
  
  			if ( oath == this )
  			{
  				amount = (int)(amount * 1.1);
  				from.Damage( amount, from );
  			}
  
  			base.Damage( amount, from );
  
  			if ( SubdueBeforeTame && !Controlled )
  			{
  				if ( (oldHits > (this.HitsMax / 10)) && (this.Hits <= (this.HitsMax / 10)) )
  					PublicOverheadMessage( MessageType.Regular, 0x3B2, false, "* The creature has been beaten into subjugation! *" );
  			}
  		}
  
  		public virtual bool DeleteCorpseOnDeath
  		{
  			get
  			{
  				return !Core.AOS && m_bSummoned;
  			}
  		}
  
  		public override void SetLocation( Point3D newLocation, bool isTeleport )
  		{
  			base.SetLocation( newLocation, isTeleport );
  
  			if ( isTeleport && m_AI != null )
  				m_AI.OnTeleported();
  		}
  
  		public override void OnBeforeSpawn( Point3D location, Map m )
  		{
  			if ( Paragon.CheckConvert( this, location, m ) )
  				IsParagon = true;
  
  			base.OnBeforeSpawn( location, m );
  		}
  
  		public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
  		{
  			if ( !Alive || IsDeadPet )
  				return ApplyPoisonResult.Immune;
  
  			if ( Spells.Necromancy.EvilOmenSpell.TryEndEffect( this ) )
  				poison = PoisonImpl.IncreaseLevel( poison );
  
  			ApplyPoisonResult result = base.ApplyPoison( from, poison );
  
  			if ( from != null && result == ApplyPoisonResult.Poisoned && PoisonTimer is PoisonImpl.PoisonTimer )
  				(PoisonTimer as PoisonImpl.PoisonTimer).From = from;
  
  			return result;
  		}
  
  		public override bool CheckPoisonImmunity( Mobile from, Poison poison )
  		{
  			if ( base.CheckPoisonImmunity( from, poison ) )
  				return true;
  
  			Poison p = PoisonImmune;
  
  			if ( m_Paragon )
  				p = PoisonImpl.IncreaseLevel( p );
  
  			return ( p != null && p.Level >= poison.Level );
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int Loyalty
  		{
  			get
  			{
  				return m_Loyalty;
  			}
  			set
  			{
  				m_Loyalty = Math.Min( Math.Max( value, 0 ), MaxLoyalty );
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public WayPoint CurrentWayPoint
  		{
  			get
  			{
  				return m_CurrentWayPoint;
  			}
  			set
  			{
  				m_CurrentWayPoint = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public IPoint2D TargetLocation
  		{
  			get
  			{
  				return m_TargetLocation;
  			}
  			set
  			{
  				m_TargetLocation = value;
  			}
  		}
  
  		public virtual Mobile ConstantFocus{ get{ return null; } }
  
  		public virtual bool DisallowAllMoves
  		{
  			get
  			{
  				return false;
  			}
  		}
  
  		public virtual bool InitialInnocent
  		{
  			get
  			{
  				return false;
  			}
  		}
  
  		public virtual bool AlwaysMurderer
  		{
  			get
  			{
  				return false;
  			}
  		}
  
  		public virtual bool AlwaysAttackable
  		{
  			get
  			{
  				return false;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public virtual int DamageMin{ get{ return m_DamageMin; } set{ m_DamageMin = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public virtual int DamageMax{ get{ return m_DamageMax; } set{ m_DamageMax = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public override int HitsMax
  		{
  			get
  			{
  				if ( m_HitsMax > 0 ) {
  					int value = m_HitsMax + GetStatOffset( StatType.Str );
  
  					if( value < 1 )
  						value = 1;
  					else if( value > 65000 )
  						value = 65000;
  
  					return value;
  				}
  
  				return Str;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int HitsMaxSeed
  		{
  			get{ return m_HitsMax; }
  			set{ m_HitsMax = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public override int StamMax
  		{
  			get
  			{
  				if ( m_StamMax > 0 ) {
  					int value = m_StamMax + GetStatOffset( StatType.Dex );
  
  					if( value < 1 )
  						value = 1;
  					else if( value > 65000 )
  						value = 65000;
  
  					return value;
  				}
  
  				return Dex;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int StamMaxSeed
  		{
  			get{ return m_StamMax; }
  			set{ m_StamMax = value; }
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public override int ManaMax
  		{
  			get
  			{
  				if ( m_ManaMax > 0 ) {
  					int value = m_ManaMax + GetStatOffset( StatType.Int );
  
  					if( value < 1 )
  						value = 1;
  					else if( value > 65000 )
  						value = 65000;
  
  					return value;
  				}
  
  				return Int;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int ManaMaxSeed
  		{
  			get{ return m_ManaMax; }
  			set{ m_ManaMax = value; }
  		}
  
  		public virtual bool CanOpenDoors
  		{
  			get
  			{
  				return !this.Body.IsAnimal && !this.Body.IsSea;
  			}
  		}
  
  		public virtual bool CanMoveOverObstacles
  		{
  			get
  			{
  				return Core.AOS || this.Body.IsMonster;
  			}
  		}
  
  		public virtual bool CanDestroyObstacles
  		{
  			get
  			{
  				// to enable breaking of furniture, 'return CanMoveOverObstacles;'
  				return false;
  			}
  		}
  
  		public void Unpacify()
  		{
  			BardEndTime = DateTime.Now;
  			BardPacified = false;
  		}
  
  		private HonorContext m_ReceivedHonorContext;
  
  		public HonorContext ReceivedHonorContext{ get{ return m_ReceivedHonorContext; } set{ m_ReceivedHonorContext = value; } }
  
  		/*
  
  		Seems this actually was removed on OSI somewhere between the original bug report and now.
  		We will call it ML, until we can get better information. I suspect it was on the OSI TC when
  		originally it taken out of RunUO, and not implmented on OSIs production shards until more 
  		recently.  Either way, this is, or was, accurate OSI behavior, and just entirely 
  		removing it was incorrect.  OSI followers were distracted by being attacked well into
  		AoS, at very least.
  
  		*/
  
  		public virtual bool CanBeDistracted { get { return !Core.ML ; } }
  
  		public virtual void CheckDistracted( Mobile from )
  		{
  			if( Utility.RandomDouble() < .10 )
  			{
  				ControlTarget = from;
  				ControlOrder = OrderType.Attack;
  				Combatant = from;
  				Warmode = true;
  			}
  		}
  
  		public override void OnDamage( int amount, Mobile from, bool willKill )
  		{
  			if ( BardPacified && (HitsMax - Hits) * 0.001 > Utility.RandomDouble() )
  				Unpacify();
  
  			int disruptThreshold;
  			//NPCs can use bandages too!
  			if( !Core.AOS )
  				disruptThreshold = 0;
  			else if( from != null && from.Player )
  				disruptThreshold = 18;
  			else
  				disruptThreshold = 25;
  
  			if( amount > disruptThreshold )
  			{
  				BandageContext c = BandageContext.GetContext( this );
  
  				if( c != null )
  					c.Slip();
  			}
  
  			if( Confidence.IsRegenerating( this ) )
  				Confidence.StopRegenerating( this );
  
  			WeightOverloading.FatigueOnDamage( this, amount );
  
  			InhumanSpeech speechType = this.SpeechType;
  
  			if ( speechType != null && !willKill )
  				speechType.OnDamage( this, amount );
  
  			if ( m_ReceivedHonorContext != null )
  				m_ReceivedHonorContext.OnTargetDamaged( from, amount );
  
  			if( !willKill )
  			{
  				if( CanBeDistracted && ControlOrder == OrderType.Follow )
  				{
  					CheckDistracted( from );
  				}
  			}
  			else if( from is PlayerMobile )
  			{
  				Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( ( ( PlayerMobile )from ).RecoverAmmo ) );
  			}
  
  			base.OnDamage( amount, from, willKill );
  		}
  
  		public virtual void OnDamagedBySpell( Mobile from )
  		{
  			if( CanBeDistracted && ControlOrder == OrderType.Follow )
  			{
  				CheckDistracted( from );
  			}
  		}
  
  		public virtual void OnHarmfulSpell( Mobile from )
  		{
  		}
  
  		#region Alter[...]Damage From/To
  
  		public virtual void AlterDamageScalarFrom( Mobile caster, ref double scalar )
  		{
  		}
  
  		public virtual void AlterDamageScalarTo( Mobile target, ref double scalar )
  		{
  		}
  
  		public virtual void AlterSpellDamageFrom( Mobile from, ref int damage )
  		{
  		}
  
  		public virtual void AlterSpellDamageTo( Mobile to, ref int damage )
  		{
  		}
  
  		public virtual void AlterMeleeDamageFrom( Mobile from, ref int damage )
  		{
  			#region Mondain's Legacy
  			if ( from != null && from.Talisman is BaseTalisman )
  			{
  				BaseTalisman talisman = (BaseTalisman)from.Talisman;
  
  				if ( talisman.Killer != null && talisman.Killer.Type != null )
  				{
  					Type type = talisman.Killer.Type;
  
  					if ( type.IsAssignableFrom( GetType() ) )
  						damage = (int)( damage * ( 1 + (double)talisman.Killer.Amount / 100 ) );
  				}
  			}
  			#endregion
  		}
  
  		public virtual void AlterMeleeDamageTo( Mobile to, ref int damage )
  		{
  		}
  
  		#endregion
  
  		public virtual void CheckReflect( Mobile caster, ref bool reflect )
  		{
  		}
  
  		public virtual void OnCarve( Mobile from, Corpse corpse, Item with )
  		{
  			int feathers = Feathers;
  			int wool = Wool;
  			int meat = Meat;
  			int hides = Hides;
  			int scales = Scales;
  
  			if ( ( feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0 ) || Summoned || IsBonded || corpse.Animated )
  			{
  				if ( corpse.Animated )
  					corpse.SendLocalizedMessageTo( from, 500464 ); // Use this on corpses to carve away meat and hide
  				else
  					from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
  			}
  			else
  			{
  				if ( Core.ML && from.Race == Race.Human )
  					hides = (int)Math.Ceiling( hides * 1.1 ); // 10% bonus only applies to hides, ore & logs
  
  				if ( corpse.Map == Map.Felucca )
  				{
  					feathers *= 2;
  					wool *= 2;
  					hides *= 2;
  
  					if (Core.ML)
  					{
  						meat *= 2;
  						scales *= 2;
  					}
  				}
  
  				new Blood( 0x122D ).MoveToWorld( corpse.Location, corpse.Map );
  
  				if ( feathers != 0 )
  				{
  					corpse.AddCarvedItem( new Feather( feathers ), from );
  					from.SendLocalizedMessage( 500479 ); // You pluck the bird. The feathers are now on the corpse.
  				}
  
  				if ( wool != 0 )
  				{
  					corpse.AddCarvedItem( new TaintedWool( wool ), from );
  					from.SendLocalizedMessage( 500483 ); // You shear it, and the wool is now on the corpse.
  				}
  
  				if ( meat != 0 )
  				{
  					if ( MeatType == MeatType.Ribs )
  						corpse.AddCarvedItem( new RawRibs( meat ), from );
  					else if ( MeatType == MeatType.Bird )
  						corpse.AddCarvedItem( new RawBird( meat ), from );
  					else if ( MeatType == MeatType.LambLeg )
  						corpse.AddCarvedItem( new RawLambLeg( meat ), from );
  
  					from.SendLocalizedMessage( 500467 ); // You carve some meat, which remains on the corpse.
  				}
  
  				if ( hides != 0 )
  				{
  					Item holding = from.Weapon as Item;
  
  					if ( Core.AOS && ( holding is SkinningKnife /* TODO: || holding is ButcherWarCleaver || with is ButcherWarCleaver */ ) )
  					{
  						Item leather = null;
  
  						switch ( HideType )
  						{
  							case HideType.Regular: leather = new Leather( hides ); break;
  							case HideType.Spined: leather = new SpinedLeather( hides ); break;
  							case HideType.Horned: leather = new HornedLeather( hides ); break;
  							case HideType.Barbed: leather = new BarbedLeather( hides ); break;
  						}
  
  						if ( leather != null )
  						{
  							if ( !from.PlaceInBackpack( leather ) )
  							{
  								corpse.DropItem( leather );
  								from.SendLocalizedMessage( 500471 ); // You skin it, and the hides are now in the corpse.
  							}
  							else
  							{
  								from.SendLocalizedMessage( 1073555 ); // You skin it and place the cut-up hides in your backpack.
  							}
  						}
  					}
  					else
  					{
  						if ( HideType == HideType.Regular )
  							corpse.DropItem( new Hides( hides ) );
  						else if ( HideType == HideType.Spined )
  							corpse.DropItem( new SpinedHides( hides ) );
  						else if ( HideType == HideType.Horned )
  							corpse.DropItem( new HornedHides( hides ) );
  						else if ( HideType == HideType.Barbed )
  							corpse.DropItem( new BarbedHides( hides ) );
  
  						from.SendLocalizedMessage( 500471 ); // You skin it, and the hides are now in the corpse.
  					}
  				}
  
  				if ( scales != 0 )
  				{
  					ScaleType sc = this.ScaleType;
  
  					switch ( sc )
  					{
  						case ScaleType.Red:     corpse.AddCarvedItem( new RedScales( scales ), from ); break;
  						case ScaleType.Yellow:  corpse.AddCarvedItem( new YellowScales( scales ), from ); break;
  						case ScaleType.Black:   corpse.AddCarvedItem( new BlackScales( scales ), from ); break;
  						case ScaleType.Green:   corpse.AddCarvedItem( new GreenScales( scales ), from ); break;
  						case ScaleType.White:   corpse.AddCarvedItem( new WhiteScales( scales ), from ); break;
  						case ScaleType.Blue:    corpse.AddCarvedItem( new BlueScales( scales ), from ); break;
  						case ScaleType.All:
  						{
  							corpse.AddCarvedItem( new RedScales( scales ), from );
  							corpse.AddCarvedItem( new YellowScales( scales ), from );
  							corpse.AddCarvedItem( new BlackScales( scales ), from );
  							corpse.AddCarvedItem( new GreenScales( scales ), from );
  							corpse.AddCarvedItem( new WhiteScales( scales ), from );
  							corpse.AddCarvedItem( new BlueScales( scales ), from );
  							break;
  						}
  					}
  
  					from.SendMessage( "You cut away some scales, but they remain on the corpse." );
  				}
  
  				corpse.Carved = true;
  
  				if ( corpse.IsCriminalAction( from ) )
  					from.CriminalAction( true );
  			}
  		}
  
  		public const int DefaultRangePerception = 16;
  		public const int OldRangePerception = 10;
  
  		public BaseCreature(AIType ai,
  			FightMode mode,
  			int iRangePerception,
  			int iRangeFight,
  			double dActiveSpeed,
  			double dPassiveSpeed)
  		{
  			if ( iRangePerception == OldRangePerception )
  				iRangePerception = DefaultRangePerception;
  
  			m_Loyalty = MaxLoyalty; // Wonderfully Happy
  
  			m_CurrentAI = ai;
  			m_DefaultAI = ai;
  
  			m_iRangePerception = iRangePerception;
  			m_iRangeFight = iRangeFight;
  
  			m_FightMode = mode;
  
  			m_iTeam = 0;
  
  			SpeedInfo.GetSpeeds( this, ref dActiveSpeed, ref dPassiveSpeed );
  
  			m_dActiveSpeed = dActiveSpeed;
  			m_dPassiveSpeed = dPassiveSpeed;
  			m_dCurrentSpeed = dPassiveSpeed;
  
  			m_bDebugAI = false;
  
  			m_arSpellAttack = new List<Type>();
  			m_arSpellDefense = new List<Type>();
  
  			m_bControlled = false;
  			m_ControlMaster = null;
  			m_ControlTarget = null;
  			m_ControlOrder = OrderType.None;
  
  			m_bTamable = false;
  
  			m_Owners = new List<Mobile>();
  
  			m_NextReacquireTime = DateTime.Now + ReacquireDelay;
  
  			ChangeAIType(AI);
  
  			InhumanSpeech speechType = this.SpeechType;
  
  			if ( speechType != null )
  				speechType.OnConstruct( this );
  
  			GenerateLoot( true );
  		}
  
  		public BaseCreature( Serial serial ) : base( serial )
  		{
  			m_arSpellAttack = new List<Type>();
  			m_arSpellDefense = new List<Type>();
  
  			m_bDebugAI = false;
  		}
  
  		public override void Serialize( GenericWriter writer )
  		{
  			base.Serialize( writer );
  
  			writer.Write( (int) 18 ); // version
  
  			writer.Write( (int)m_CurrentAI );
  			writer.Write( (int)m_DefaultAI );
  
  			writer.Write( (int)m_iRangePerception );
  			writer.Write( (int)m_iRangeFight );
  
  			writer.Write( (int)m_iTeam );
  
  			writer.Write( (double)m_dActiveSpeed );
  			writer.Write( (double)m_dPassiveSpeed );
  			writer.Write( (double)m_dCurrentSpeed );
  
  			writer.Write( (int) m_pHome.X );
  			writer.Write( (int) m_pHome.Y );
  			writer.Write( (int) m_pHome.Z );
  
  			// Version 1
  			writer.Write( (int) m_iRangeHome );
  
  			int i=0;
  
  			writer.Write( (int) m_arSpellAttack.Count );
  			for ( i=0; i< m_arSpellAttack.Count; i++ )
  			{
  				writer.Write( m_arSpellAttack[i].ToString() );
  			}
  
  			writer.Write( (int) m_arSpellDefense.Count );
  			for ( i=0; i< m_arSpellDefense.Count; i++ )
  			{
  				writer.Write( m_arSpellDefense[i].ToString() );
  			}
  
  			// Version 2
  			writer.Write( (int) m_FightMode );
  
  			writer.Write( (bool) m_bControlled );
  			writer.Write( (Mobile) m_ControlMaster );
  			writer.Write( (Mobile) m_ControlTarget );
  			writer.Write( (Point3D) m_ControlDest );
  			writer.Write( (int) m_ControlOrder );
  			writer.Write( (double) m_dMinTameSkill );
  			// Removed in version 9
  			//writer.Write( (double) m_dMaxTameSkill );
  			writer.Write( (bool) m_bTamable );
  			writer.Write( (bool) m_bSummoned );
  
  			if ( m_bSummoned )
  				writer.WriteDeltaTime( m_SummonEnd );
  
  			writer.Write( (int) m_iControlSlots );
  
  			// Version 3
  			writer.Write( (int)m_Loyalty );
  
  			// Version 4
  			writer.Write( m_CurrentWayPoint );
  
  			// Verison 5
  			writer.Write( m_SummonMaster );
  
  			// Version 6
  			writer.Write( (int) m_HitsMax );
  			writer.Write( (int) m_StamMax );
  			writer.Write( (int) m_ManaMax );
  			writer.Write( (int) m_DamageMin );
  			writer.Write( (int) m_DamageMax );
  
  			// Version 7
  			writer.Write( (int) m_PhysicalResistance );
  			writer.Write( (int) m_PhysicalDamage );
  
  			writer.Write( (int) m_FireResistance );
  			writer.Write( (int) m_FireDamage );
  
  			writer.Write( (int) m_ColdResistance );
  			writer.Write( (int) m_ColdDamage );
  
  			writer.Write( (int) m_PoisonResistance );
  			writer.Write( (int) m_PoisonDamage );
  
  			writer.Write( (int) m_EnergyResistance );
  			writer.Write( (int) m_EnergyDamage );
  
  			// Version 8
  			writer.Write( m_Owners, true );
  
  			// Version 10
  			writer.Write( (bool) m_IsDeadPet );
  			writer.Write( (bool) m_IsBonded );
  			writer.Write( (DateTime) m_BondingBegin );
  			writer.Write( (DateTime) m_OwnerAbandonTime );
  
  			// Version 11
  			writer.Write( (bool) m_HasGeneratedLoot );
  
  			// Version 12
  			writer.Write( (bool) m_Paragon );
  
  			// Version 13
  			writer.Write( (bool) ( m_Friends != null && m_Friends.Count > 0 ) );
  
  			if ( m_Friends != null && m_Friends.Count > 0 )
  				writer.Write( m_Friends, true );
  
  			// Version 14
  			writer.Write( (bool)m_RemoveIfUntamed );
  			writer.Write( (int)m_RemoveStep );
  
  			// Version 17
  			if ( IsStabled || ( Controlled && ControlMaster != null ) )
  				writer.Write( TimeSpan.Zero );
  			else
  				writer.Write( DeleteTimeLeft );
  
  			// Version 18
  			writer.Write( m_CorpseNameOverride );
  		}
  
  		private static double[] m_StandardActiveSpeeds = new double[]
  			{
  				0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8
  			};
  
  		private static double[] m_StandardPassiveSpeeds = new double[]
  			{
  				0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0
  			};
  
  		public override void Deserialize( GenericReader reader )
  		{
  			base.Deserialize( reader );
  
  			int version = reader.ReadInt();
  
  			m_CurrentAI = (AIType)reader.ReadInt();
  			m_DefaultAI = (AIType)reader.ReadInt();
  
  			m_iRangePerception = reader.ReadInt();
  			m_iRangeFight = reader.ReadInt();
  
  			m_iTeam = reader.ReadInt();
  
  			m_dActiveSpeed = reader.ReadDouble();
  			m_dPassiveSpeed = reader.ReadDouble();
  			m_dCurrentSpeed = reader.ReadDouble();
  
  			if ( m_iRangePerception == OldRangePerception )
  				m_iRangePerception = DefaultRangePerception;
  
  			m_pHome.X = reader.ReadInt();
  			m_pHome.Y = reader.ReadInt();
  			m_pHome.Z = reader.ReadInt();
  
  			if ( version >= 1 )
  			{
  				m_iRangeHome = reader.ReadInt();
  
  				int i, iCount;
  
  				iCount = reader.ReadInt();
  				for ( i=0; i< iCount; i++ )
  				{
  					string str = reader.ReadString();
  					Type type = Type.GetType( str );
  
  					if ( type != null )
  					{
  						m_arSpellAttack.Add( type );
  					}
  				}
  
  				iCount = reader.ReadInt();
  				for ( i=0; i< iCount; i++ )
  				{
  					string str = reader.ReadString();
  					Type type = Type.GetType( str );
  
  					if ( type != null )
  					{
  						m_arSpellDefense.Add( type );
  					}
  				}
  			}
  			else
  			{
  				m_iRangeHome = 0;
  			}
  
  			if ( version >= 2 )
  			{
  				m_FightMode = ( FightMode )reader.ReadInt();
  
  				m_bControlled = reader.ReadBool();
  				m_ControlMaster = reader.ReadMobile();
  				m_ControlTarget = reader.ReadMobile();
  				m_ControlDest = reader.ReadPoint3D();
  				m_ControlOrder = (OrderType) reader.ReadInt();
  
  				m_dMinTameSkill = reader.ReadDouble();
  
  				if ( version < 9 )
  					reader.ReadDouble();
  
  				m_bTamable = reader.ReadBool();
  				m_bSummoned = reader.ReadBool();
  
  				if ( m_bSummoned )
  				{
  					m_SummonEnd = reader.ReadDeltaTime();
  					new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
  				}
  
  				m_iControlSlots = reader.ReadInt();
  			}
  			else
  			{
  				m_FightMode = FightMode.Closest;
  
  				m_bControlled = false;
  				m_ControlMaster = null;
  				m_ControlTarget = null;
  				m_ControlOrder = OrderType.None;
  			}
  
  			if ( version >= 3 )
  				m_Loyalty = reader.ReadInt();
  			else
  				m_Loyalty = MaxLoyalty; // Wonderfully Happy
  
  			if ( version >= 4 )
  				m_CurrentWayPoint = reader.ReadItem() as WayPoint;
  
  			if ( version >= 5 )
  				m_SummonMaster = reader.ReadMobile();
  
  			if ( version >= 6 )
  			{
  				m_HitsMax = reader.ReadInt();
  				m_StamMax = reader.ReadInt();
  				m_ManaMax = reader.ReadInt();
  				m_DamageMin = reader.ReadInt();
  				m_DamageMax = reader.ReadInt();
  			}
  
  			if ( version >= 7 )
  			{
  				m_PhysicalResistance = reader.ReadInt();
  				m_PhysicalDamage = reader.ReadInt();
  
  				m_FireResistance = reader.ReadInt();
  				m_FireDamage = reader.ReadInt();
  
  				m_ColdResistance = reader.ReadInt();
  				m_ColdDamage = reader.ReadInt();
  
  				m_PoisonResistance = reader.ReadInt();
  				m_PoisonDamage = reader.ReadInt();
  
  				m_EnergyResistance = reader.ReadInt();
  				m_EnergyDamage = reader.ReadInt();
  			}
  
  			if ( version >= 8 )
  				m_Owners = reader.ReadStrongMobileList();
  			else
  				m_Owners = new List<Mobile>();
  
  			if ( version >= 10 )
  			{
  				m_IsDeadPet = reader.ReadBool();
  				m_IsBonded = reader.ReadBool();
  				m_BondingBegin = reader.ReadDateTime();
  				m_OwnerAbandonTime = reader.ReadDateTime();
  			}
  
  			if ( version >= 11 )
  				m_HasGeneratedLoot = reader.ReadBool();
  			else
  				m_HasGeneratedLoot = true;
  
  			if ( version >= 12 )
  				m_Paragon = reader.ReadBool();
  			else
  				m_Paragon = false;
  
  			if ( version >= 13 && reader.ReadBool() )
  				m_Friends = reader.ReadStrongMobileList();
  			else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
  				++m_ControlOrder;
  
  			if ( version < 16 && Loyalty != MaxLoyalty )
  				Loyalty *= 10;
  
  			double activeSpeed = m_dActiveSpeed;
  			double passiveSpeed = m_dPassiveSpeed;
  
  			SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );
  
  			bool isStandardActive = false;
  			for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
  				isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );
  
  			bool isStandardPassive = false;
  			for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
  				isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );
  
  			if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
  				m_dCurrentSpeed = activeSpeed;
  			else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
  				m_dCurrentSpeed = passiveSpeed;
  
  			if ( isStandardActive && !m_Paragon )
  				m_dActiveSpeed = activeSpeed;
  
  			if ( isStandardPassive && !m_Paragon )
  				m_dPassiveSpeed = passiveSpeed;
  
  			if ( version >= 14 )
  			{
  				m_RemoveIfUntamed = reader.ReadBool();
  				m_RemoveStep = reader.ReadInt();
  			}
  
  			TimeSpan deleteTime = TimeSpan.Zero;
  
  			if ( version >= 17 )
  				deleteTime = reader.ReadTimeSpan();
  
  			if ( deleteTime > TimeSpan.Zero || LastOwner != null && !Controlled && !IsStabled )
  			{
  				if ( deleteTime == TimeSpan.Zero )
  					deleteTime = TimeSpan.FromDays( 3.0 );
  
  				m_DeleteTimer = new DeleteTimer( this, deleteTime );
  				m_DeleteTimer.Start();
  			}
  
  			if ( version >= 18 )
  				m_CorpseNameOverride = reader.ReadString();
  
  			if( version <= 14 && m_Paragon && Hue == 0x31 )
  			{
  				Hue = Paragon.Hue; //Paragon hue fixed, should now be 0x501.
  			}
  
  			CheckStatTimers();
  
  			ChangeAIType(m_CurrentAI);
  
  			AddFollowers();
  
  			if ( IsAnimatedDead )
  				Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );
  		}
  
  		public virtual bool IsHumanInTown()
  		{
  			return ( Body.IsHuman && Region.IsPartOf( typeof( Regions.GuardedRegion ) ) );
  		}
  
  		public virtual bool CheckGold( Mobile from, Item dropped )
  		{
  			if ( dropped is Gold )
  				return OnGoldGiven( from, (Gold)dropped );
  
  			return false;
  		}
  
  		public virtual bool OnGoldGiven( Mobile from, Gold dropped )
  		{
  			if ( CheckTeachingMatch( from ) )
  			{
  				if ( Teach( m_Teaching, from, dropped.Amount, true ) )
  				{
  					dropped.Delete();
  					return true;
  				}
  			}
  			else if ( IsHumanInTown() )
  			{
  				Direction = GetDirectionTo( from );
  
  				int oldSpeechHue = this.SpeechHue;
  
  				this.SpeechHue = 0x23F;
  				SayTo( from, "Thou art giving me gold?" );
  
  				if ( dropped.Amount >= 400 )
  					SayTo( from, "'Tis a noble gift." );
  				else
  					SayTo( from, "Money is always welcome." );
  
  				this.SpeechHue = 0x3B2;
  				SayTo( from, 501548 ); // I thank thee.
  
  				this.SpeechHue = oldSpeechHue;
  
  				dropped.Delete();
  				return true;
  			}
  
  			return false;
  		}
  
  		public override bool ShouldCheckStatTimers{ get{ return false; } }
  
  		#region Food
  		private static Type[] m_Eggs = new Type[]
  			{
  				typeof( FriedEggs ), typeof( Eggs )
  			};
  
  		private static Type[] m_Fish = new Type[]
  			{
  				typeof( FishSteak ), typeof( RawFishSteak )
  			};
  
  		private static Type[] m_GrainsAndHay = new Type[]
  			{
  				typeof( BreadLoaf ), typeof( FrenchBread ), typeof( SheafOfHay )
  			};
  
  		private static Type[] m_Meat = new Type[]
  			{
  				/* Cooked */
  				typeof( Bacon ), typeof( CookedBird ), typeof( Sausage ),
  				typeof( Ham ), typeof( Ribs ), typeof( LambLeg ),
  				typeof( ChickenLeg ),
  
  				/* Uncooked */
  				typeof( RawBird ), typeof( RawRibs ), typeof( RawLambLeg ),
  				typeof( RawChickenLeg ),
  
  				/* Body Parts */
  				typeof( Head ), typeof( LeftArm ), typeof( LeftLeg ),
  				typeof( Torso ), typeof( RightArm ), typeof( RightLeg )
  			};
  
  		private static Type[] m_FruitsAndVegies = new Type[]
  			{
  				typeof( HoneydewMelon ), typeof( YellowGourd ), typeof( GreenGourd ),
  				typeof( Banana ), typeof( Bananas ), typeof( Lemon ), typeof( Lime ),
  				typeof( Dates ), typeof( Grapes ), typeof( Peach ), typeof( Pear ),
  				typeof( Apple ), typeof( Watermelon ), typeof( Squash ),
  				typeof( Cantaloupe ), typeof( Carrot ), typeof( Cabbage ),
  				typeof( Onion ), typeof( Lettuce ), typeof( Pumpkin )
  			};
  
  		private static Type[] m_Gold = new Type[]
  			{
  				// white wyrms eat gold..
  				typeof( Gold )
  			};
  
  		public virtual bool CheckFoodPreference( Item f )
  		{
  			if ( CheckFoodPreference( f, FoodType.Eggs, m_Eggs ) )
  				return true;
  
  			if ( CheckFoodPreference( f, FoodType.Fish, m_Fish ) )
  				return true;
  
  			if ( CheckFoodPreference( f, FoodType.GrainsAndHay, m_GrainsAndHay ) )
  				return true;
  
  			if ( CheckFoodPreference( f, FoodType.Meat, m_Meat ) )
  				return true;
  
  			if ( CheckFoodPreference( f, FoodType.FruitsAndVegies, m_FruitsAndVegies ) )
  				return true;
  
  			if ( CheckFoodPreference( f, FoodType.Gold, m_Gold ) )
  				return true;
  
  			return false;
  		}
  
  		public virtual bool CheckFoodPreference( Item fed, FoodType type, Type[] types )
  		{
  			if ( (FavoriteFood & type) == 0 )
  				return false;
  
  			Type fedType = fed.GetType();
  			bool contains = false;
  
  			for ( int i = 0; !contains && i < types.Length; ++i )
  				contains = ( fedType == types[i] );
  
  			return contains;
  		}
  
  		public virtual bool CheckFeed( Mobile from, Item dropped )
  		{
  			if ( !IsDeadPet && Controlled && ( ControlMaster == from || IsPetFriend( from ) ) )
  			{
  				Item f = dropped;
  
  				if ( CheckFoodPreference( f ) )
  				{
  					int amount = f.Amount;
  
  					if ( amount > 0 )
  					{
  						int stamGain;
  
  						if ( f is Gold )
  							stamGain = amount - 50;
  						else
  							stamGain = (amount * 15) - 50;
  
  						if ( stamGain > 0 )
  							Stam += stamGain;
  
  						if ( Core.SE )
  						{
  							if ( m_Loyalty < MaxLoyalty )
  							{
  								m_Loyalty = MaxLoyalty;
  							}
  						}
  						else
  						{
  							for ( int i = 0; i < amount; ++i )
  							{
  								if ( m_Loyalty < MaxLoyalty && 0.5 >= Utility.RandomDouble() )
  								{
  									m_Loyalty += 10;
  								}
  							}
  						}
  
  						/* if ( happier )*/	// looks like in OSI pets say they are happier even if they are at maximum loyalty
  							SayTo( from, 502060 ); // Your pet looks happier.
  
  						if ( Body.IsAnimal )
  							Animate( 3, 5, 1, true, false, 0 );
  						else if ( Body.IsMonster )
  							Animate( 17, 5, 1, true, false, 0 );
  
  						if ( IsBondable && !IsBonded )
  						{
  							Mobile master = m_ControlMaster;
  
  							if ( master != null && master == from )	//So friends can't start the bonding process
  							{
  								if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Base >= m_dMinTameSkill || OverrideBondingReqs() || (Core.ML && master.Skills[SkillName.AnimalTaming].Value >= m_dMinTameSkill) )
  								{
  									if ( BondingBegin == DateTime.MinValue )
  									{
  										BondingBegin = DateTime.Now;
  									}
  									else if ( (BondingBegin + BondingDelay) <= DateTime.Now )
  									{
  										IsBonded = true;
  										BondingBegin = DateTime.MinValue;
  										from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
  									}
  								}
  								else if( Core.ML )
  								{
  									from.SendLocalizedMessage( 1075268 ); // Your pet cannot form a bond with you until your animal taming ability has risen.
  								}
  							}
  						}
  
  						dropped.Delete();
  						return true;
  					}
  				}
  			}
  
  			return false;
  		}
  
  		#endregion
  
  		public virtual bool OverrideBondingReqs()
  		{
  			return false;
  		}
  
  		public virtual bool CanAngerOnTame{ get{ return false; } }
  
  		#region OnAction[...]
  
  		public virtual void OnActionWander()
  		{
  		}
  
  		public virtual void OnActionCombat()
  		{
  		}
  
  		public virtual void OnActionGuard()
  		{
  		}
  
  		public virtual void OnActionFlee()
  		{
  		}
  
  		public virtual void OnActionInteract()
  		{
  		}
  
  		public virtual void OnActionBackoff()
  		{
  		}
  
  		#endregion
  
  		public override bool OnDragDrop( Mobile from, Item dropped )
  		{
  			if ( CheckFeed( from, dropped ) )
  				return true;
  			else if ( CheckGold( from, dropped ) )
  				return true;
  
  			return base.OnDragDrop( from, dropped );
  		}
  
  		protected virtual BaseAI ForcedAI { get { return null; } }
  
  		public  void ChangeAIType( AIType NewAI )
  		{
  			if ( m_AI != null )
  				m_AI.m_Timer.Stop();
  
  			if( ForcedAI != null )
  			{
  				m_AI = ForcedAI;
  				return;
  			}
  
  			m_AI = null;
  
  			switch ( NewAI )
  			{
  				case AIType.AI_Melee:
  					m_AI = new MeleeAI(this);
  					break;
  				case AIType.AI_Animal:
  					m_AI = new AnimalAI(this);
  					break;
  				case AIType.AI_Berserk:
  					m_AI = new BerserkAI(this);
  					break;
  				case AIType.AI_Archer:
  					m_AI = new ArcherAI(this);
  					break;
  				case AIType.AI_Healer:
  					m_AI = new HealerAI(this);
  					break;
  				case AIType.AI_Vendor:
  					m_AI = new VendorAI(this);
  					break;
  				case AIType.AI_Mage:
  					m_AI = new MageAI(this);
  					break;
  				case AIType.AI_Predator:
  					//m_AI = new PredatorAI(this);
  					m_AI = new MeleeAI(this);
  					break;
  				case AIType.AI_Thief:
  					m_AI = new ThiefAI(this);
  					break;
  // >>> [2nd change of 2]
  // ERICA'S ORC SCOUT and NINJA
  				case AIType.AI_OrcScout:
  					m_AI = new OrcScoutAI(this);			         
  				        break;
  				case AIType.AI_Ninja:
  					m_AI = new NinjaAI(this);
  					break;
  // PAPPA SMURF's Spellbinder
  				case AIType.AI_Spellbinder:
  					m_AI = new SpellbinderAI(this);
  					break;
                  case AIType.AI_NecroMage:
                      m_AI = new NecroMageAI(this);
                      break;
  // end 2nd
  			}
  		}
  
  		public void ChangeAIToDefault()
  		{
  			ChangeAIType(m_DefaultAI);
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public AIType AI
  		{
  			get
  			{
  				return m_CurrentAI;
  			}
  			set
  			{
  				m_CurrentAI = value;
  
  				if (m_CurrentAI == AIType.AI_Use_Default)
  				{
  					m_CurrentAI = m_DefaultAI;
  				}
  
  				ChangeAIType(m_CurrentAI);
  			}
  		}
  
  		[CommandProperty( AccessLevel.Administrator )]
  		public bool Debug
  		{
  			get
  			{
  				return m_bDebugAI;
  			}
  			set
  			{
  				m_bDebugAI = value;
  			}
  		}
  
  
gt: 		[CommandProperty( AccessLevel.GameMaster )]