context: using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Linq;
  using Server.ContextMenus;
  using Server.Engines.CannedEvil;
  using Server.Engines.Housing.Regions;
  using Server.Engines.Loyalty;
  using Server.Engines.MiniChamps;
  using Server.Engines.Quests;
  using Server.Events;
  using Server.Factions;
  using Server.Items;
  using Server.Misc;
  using Server.Network;
  using Server.Prompts;
  using Server.Regions;
  using Server.Spells;
  using Server.Spells.Bushido;
  using Server.Spells.Spellweaving;
  using Server.Targeting;
  
  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
  		Good			// Only attack aggressor -or- positive 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).
  		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
  	{
  		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,
  		Boura = 0x0100,
  		Raptor = 0x0200
  	}
  
  	public enum ScaleType
  	{
  		Red,
  		Yellow,
  		Black,
  		Green,
  		White,
  		Blue,
  		All
  	}
  
  	public enum MeatType
  	{
  		Ribs,
  		Bird,
  		LambLeg,
  		Rotworm
  	}
  
  	public enum HideType
  	{
  		Regular,
  		Spined,
  		Horned,
  		Barbed
  	}
  
  	public enum FurType
  	{
  		Green,
  		Red,
  		Yellow,
  		DarkGreen
  	}
  
  	public enum PetLoyalty
  	{
  		None,
  		Confused,
  		ExtremelyUnhappy,
  		RatherUnhappy,
  		Unhappy,
  		SomewhatContent,
  		Content,
  		Happy,
  		RatherHappy,
  		VeryHappy,
  		ExtremelyHappy,
  		WonderfullyHappy
  	}
  	#endregion
  
  	#region Events
  	public delegate void LootGeneratedEventHandler( BaseCreature bc, LootGeneratedEventArgs args );
  
  	public class LootGeneratedEventArgs : EventArgs
  	{
  		public LootGeneratedEventArgs()
  		{
  		}
  	}
  	#endregion
  
  	public class DamageStore : IComparable
  	{
  		public Mobile Mobile;
  		public int Damage;
  		public bool HasRight;
  		public double DamagePercent;
  
  		public DamageStore( Mobile m, int damage )
  		{
  			Mobile = m;
  			Damage = damage;
  		}
  
  		public int CompareTo( object obj )
  		{
  			DamageStore ds = (DamageStore) obj;
  
  			return ds.Damage - Damage;
  		}
  	}
  
  	public class BaseCreature : Mobile, IHonorTarget
  	{
  		#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
  
  		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 PetLoyalty 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 Point2D m_TargetLocation = Point2D.Zero;
  
  		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 List<Mobile> m_Owners;
  		private List<Mobile> m_Friends;
  
  		private bool m_IsStabled;
  
  		private bool m_HasGeneratedLoot; // have we generated our loot yet?
  
  		private bool m_Paragon;
  
  		private bool m_IsChampionMonster;
  		private int m_SpawnLevel;
  		private ChampionSpawnType m_ChampionType;
  
  		private bool m_IsMinichampMonster;
  		private MiniChampType m_MinichampType;
  
  		private bool m_StolenFrom;
  
  		private DateTime m_NextTastyTreat;
  		private DateTime m_NextArmorEssence;
  		#endregion
  
  		public virtual InhumanSpeech SpeechType { get { return null; } }
  
  		public bool IsStabled
  		{
  			get { return m_IsStabled; }
  			set { m_IsStabled = 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 && !IsGolem ); } }
  		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 DateTime m_NextPBlow;
  
  		public DateTime NextPBlow
  		{
  			get { return m_NextPBlow; }
  			set { m_NextPBlow = value; }
  		}
  
  		private DateTime m_NextDisarm;
  
  		public DateTime NextDisarm
  		{
  			get { return m_NextDisarm; }
  			set { m_NextDisarm = value; }
  		}
  
  		private bool m_IsBonded;
  		private bool m_IsDeadPet;
  		private DateTime m_BondingBegin;
  		private DateTime m_OwnerAbandonTime;
  
  		private bool m_IsGolem;
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsGolem
  		{
  			get { return m_IsGolem; }
  			set { m_IsGolem = value; InvalidateProperties(); }
  		}
  
  		[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
  
  		public virtual double WeaponAbilityChance { get { return 0.4; } }
  
  		public virtual WeaponAbility GetWeaponAbility()
  		{
  			return null;
  		}
  
  		public virtual double SpecialAbilityChance { get { return 0.2; } }
  
  		public virtual SpecialAbility GetSpecialAbility()
  		{
  			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; } }
  
  		#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();
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsChampionMonster { get { return m_IsChampionMonster; } set { m_IsChampionMonster = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int SpawnLevel { get { return m_SpawnLevel; } set { m_SpawnLevel = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public ChampionSpawnType ChampionType { get { return m_ChampionType; } set { m_ChampionType = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool IsMinichampMonster { get { return m_IsMinichampMonster; } set { m_IsMinichampMonster = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public MiniChampType MinichampType { get { return m_MinichampType; } set { m_MinichampType = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool StolenFrom { get { return m_StolenFrom; } set { m_StolenFrom = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public DateTime NextTastyTreat { get { return m_NextTastyTreat; } set { m_NextTastyTreat = value; } }
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public DateTime NextArmorEssence { get { return m_NextArmorEssence; } set { m_NextArmorEssence = value; } }
  
  		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 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 BleedImmune { get { return false; } }
  		public virtual bool DeathAdderCharmable { get { return false; } }
  
  		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 LoyaltyGroup LoyaltyGroupEnemy { get { return LoyaltyGroup.GargoyleQueen; } }
  		public virtual int LoyaltyPointsAward { get { return 0; } }
  
  		public virtual bool InstantCast { get { return false; } }
  		public virtual double ChangeCombatantChance { get { return 0.0; } }
  
  		#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 0.16; } }
  
  		// Min/max seconds until next breath
  		public virtual double BreathMinDelay { get { return 10.0; } }
  		public virtual double BreathMaxDelay { get { return 15.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 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; } }
  
  		// 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.UtcNow + 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 ( CanBeHarmful( target ) )
  			{
  				DoHarmful( target );
  				BreathDealDamage( target );
  			}
  		}
  
  		public virtual void BreathDealDamage( Mobile target )
  		{
  			if ( Spells.Bushido.Evasion.IsEvading( target ) )
  				return;
  
  			int physDamage = BreathPhysicalDamage;
  			int fireDamage = BreathFireDamage;
  			int coldDamage = BreathColdDamage;
  			int poisDamage = BreathPoisonDamage;
  			int nrgyDamage = BreathEnergyDamage;
  
  			if ( physDamage == 0 && fireDamage == 0 && coldDamage == 0 && poisDamage == 0 && nrgyDamage == 0 )
  			{ // Unresistable damage even in AOS
  				target.Damage( BreathComputeDamage(), this );
  			}
  			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 );
  
  			return damage;
  		}
  		#endregion
  
  		#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 );
  			}
  		}
  
  		/// <summary>
  		/// Solen Style, override me for other mobiles/items:
  		/// kappa+acidslime, grizzles+whatever, etc.
  		/// </summary>
  		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.UtcNow >= m_EndFlee )
  			{
  				StopFlee();
  				return false;
  			}
  
  			return true;
  		}
  
  		public virtual void BeginFlee( TimeSpan maxDuration )
  		{
  			m_EndFlee = DateTime.UtcNow + 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>( 8 );
  
  			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 ) ) );
  		}
  		#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;
  
  			Faction ourFaction = FactionAllegiance;
  
  			if ( ourFaction != null && Map == Faction.Facet )
  			{
  				Faction theirFaction = Faction.Find( m, true );
  
  				if ( theirFaction == ourFaction )
  					return false;
  			}
  
  			if ( m is PlayerMobile )
  			{
  				PlayerMobile pm = (PlayerMobile) m;
  
  				if ( pm.Combatant != null && pm.KRStartingQuestStep == 24 )
  					return true;
  
  				if ( pm.KRStartingQuestStep > 0 )
  					return false;
  			}
  
  			if ( !Controlled && BaseMaskOfDeathPotion.UnderEffect( m ) )
  				return false;
  
  			if ( EtherealVoyageSpell.UnderEffect( m ) )
  				return false;
  
  			if ( !( m is BaseCreature ) )
  				return true;
  
  			if ( m is PlayerMobile && ( (PlayerMobile) m ).HonorActive )
  				return false;
  
  			BaseCreature c = (BaseCreature) m;
  
  			return ( m_iTeam != c.m_iTeam || ( ( m_bSummoned || m_bControlled ) != ( c.m_bSummoned || c.m_bControlled ) ) );
  		}
  
  		public override bool IsGoodAligned()
  		{
  			if ( Controlled && ControlMaster != null )
  				return ControlMaster.IsGoodAligned();
  
  			return base.IsGoodAligned();
  		}
  
  		public override string ApplyNameSuffix( string suffix )
  		{
  			if ( IsParagon )
  			{
  				if ( suffix.Length == 0 )
  					suffix = "(Paragon)";
  				else
  					suffix = String.Concat( suffix, " (Paragon)" );
  			}
  
  			#region Factions
  			if ( this.Map == Faction.Facet )
  			{
  				Faction faction = Faction.Find( this, inherit: true, creatureAllegiances: true );
  
  				if ( faction != null )
  				{
  					string adjunct = String.Format( "[{0}]", faction.Definition.Abbreviation );
  					if ( suffix.Length == 0 )
  						suffix = adjunct;
  					else
  						suffix = String.Concat( suffix, " ", adjunct );
  				}
  			}
  			#endregion
  
  			return base.ApplyNameSuffix( suffix );
  		}
  
  		public virtual bool CheckControlChance( Mobile m )
  		{
  			return CheckControlChance( m, 0.0 );
  		}
  
  		public virtual bool CheckControlChance( Mobile m, double offset )
  		{
  			double v = GetControlChance( m ) + offset;
  
  			if ( v > Utility.RandomDouble() )
  				return true;
  
  			if ( Body.IsAnimal )
  				Animate( 10, 5, 1, true, false, 0 );
  			else if ( Body.IsMonster )
  				Animate( 18, 5, 1, true, false, 0 );
  
  			if ( ( IsBonded ? 0.25 : 0.5 ) > Utility.RandomDouble() )
  				--Loyalty;
  
  			if ( Loyalty == PetLoyalty.Confused )
  			{
  				Say( 1043270, Name ); // * ~1_NAME~ looks around desperately *
  				PlaySound( GetIdleSound() );
  			}
  			else if ( Loyalty == PetLoyalty.None )
  			{
  				Say( 1043255, Name ); // ~1_NAME~ appears to have decided that is better off without a master!
  				Loyalty = PetLoyalty.WonderfullyHappy;
  				IsBonded = false;
  				BondingBegin = DateTime.MinValue;
  				OwnerAbandonTime = DateTime.MinValue;
  				ControlTarget = null;
  				AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers)
  				RemoveOnSave = true;
  			}
  			else
  			{
  				PlaySound( GetAngerSound() );
  			}
  
  			return false;
  		}
  
  		public virtual bool CanBeControlledBy( Mobile m )
  		{
  			return ( GetControlChance( m ) > 0.0 );
  		}
  
  		public virtual double GetControlChance( Mobile m )
  		{
  			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 tamingModifier = 6;
  			int loreModifier = 6;
  
  			double tamingBonus, loreBonus;
  
  			if ( ( tamingBonus = ( m.Skills[SkillName.AnimalTaming].Value - dMinTameSkill ) ) < 0 )
  				tamingModifier = 28;
  
  			if ( ( loreBonus = ( m.Skills[SkillName.AnimalLore].Value - dMinTameSkill ) ) < 0 )
  				loreModifier = 14;
  
  			tamingBonus *= tamingModifier;
  			loreBonus *= loreModifier;
  
  			double skillBonus = ( tamingBonus + loreBonus ) / 2;
  
  			double chance = ( 70 + skillBonus ) / 100;
  
  			if ( chance >= 0 && chance < 0.2 )
  				chance = 0.2;
  			else if ( chance > 0.99 )
  				chance = 0.99;
  
  			return chance;
  		}
  
  		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 override void Damage( int amount, Mobile from )
  		{
  			int oldHits = this.Hits;
  
  			base.Damage( amount, from );
  
  			if ( SubdueBeforeTame && !Controlled )
  			{
  				if ( ( oldHits > ( this.HitsMax / 10 ) ) && ( this.Hits <= ( this.HitsMax / 10 ) ) )
  					PublicOverheadMessage( MessageType.Regular, 0x3B2, true, "* The creature has been beaten into subjugation! *" );
  			}
  		}
  
  		public virtual bool DeleteCorpseOnDeath { get { return false; } }
  
  		public override void SetLocation( Point3D newLocation, bool isTeleport )
  		{
  			base.SetLocation( newLocation, isTeleport );
  
  			if ( isTeleport && m_AI != null )
  				m_AI.OnTeleported();
  		}
  
  		public void CheckParagon()
  		{
  			if ( Paragon.CheckConvert( this ) )
  				IsParagon = true;
  		}
  
  		public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
  		{
  			if ( !Alive || IsDeadPet )
  				return ApplyPoisonResult.Immune;
  
  			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
  				return base.ApplyPoison( from, PoisonImpl.IncreaseLevel( poison ) );
  
  			return base.ApplyPoison( from, poison );
  		}
  
  		public override bool CheckPoisonImmunity( Mobile from, Poison poison )
  		{
  			if ( base.CheckPoisonImmunity( from, poison ) )
  				return true;
  
  			Poison p = this.PoisonImmune;
  
  			return ( p != null && p.Level >= poison.Level );
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public PetLoyalty Loyalty
  		{
  			get
  			{
  				return m_Loyalty;
  			}
  			set
  			{
  				m_Loyalty = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public WayPoint CurrentWayPoint
  		{
  			get
  			{
  				return m_CurrentWayPoint;
  			}
  			set
  			{
  				m_CurrentWayPoint = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public Point2D 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 )
  					return m_HitsMax;
  
  				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 )
  					return m_StamMax;
  
  				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 )
  					return m_ManaMax;
  
  				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 true; } }
  
  		public virtual bool CanDestroyObstacles
  		{
  			get
  			{
  				// to enable breaking of furniture, 'return CanMoveOverObstacles;'
  				return false;
  			}
  		}
  
  		public void Unpacify()
  		{
  			BardEndTime = DateTime.UtcNow;
  			BardPacified = false;
  		}
  
  		private HonorContext m_ReceivedHonorContext;
  
  		public HonorContext ReceivedHonorContext { get { return m_ReceivedHonorContext; } set { m_ReceivedHonorContext = value; } }
  
  		public override void OnDamage( int amount, Mobile from, bool willKill )
  		{
  			if ( BardPacified && ( HitsMax - Hits ) * 0.001 > Utility.RandomDouble() )
  				Unpacify();
  
  			if ( BaseExplodingTarPotion.IsSlept( this ) )
  				BaseExplodingTarPotion.RemoveEffect( this );
  
  			int disruptThreshold;
  
  			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 );
  
  			base.OnDamage( amount, from, willKill );
  		}
  
  		public virtual void OnDamagedBySpell( 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 )
  		{
  		}
  
  		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, bool butcher )
  		{
  			int feathers = Feathers;
  			int wool = Wool;
  			int meat = Meat;
  			int hides = Hides;
  			int scales = Scales;
  			int blood = Blood;
  			int fur = Fur;
  
  			if ( ( feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0 && blood == 0 && fur == 0 ) || Summoned || IsBonded )
  			{
  				from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
  			}
  			else
  			{
  				if ( 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;
  					meat *= 2;
  					hides *= 2;
  					scales *= 2;
  					blood *= 2;
  					fur *= 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 Wool( 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 );
  					else if ( MeatType == MeatType.Rotworm )
  						corpse.AddCarvedItem( new RawRotwormMeat( meat ), from );
  
  					from.SendLocalizedMessage( 500467 ); // You carve some meat, which remains on the corpse.
  				}
  
  				if ( hides != 0 )
  				{
  					if ( butcher )
  					{
  						Item item = null;
  
  						if ( HideType == HideType.Regular )
  							item = new Leather( hides );
  						else if ( HideType == HideType.Spined )
  							item = new SpinedLeather( hides );
  						else if ( HideType == HideType.Horned )
  							item = new HornedLeather( hides );
  						else if ( HideType == HideType.Barbed )
  							item = new BarbedLeather( hides );
  
  						if ( item != null )
  						{
  							if ( from.AddToBackpack( item ) )
  							{
  								from.SendLocalizedMessage( 1073555 ); // You skin it and place the cut-up hides in your backpack.
  							}
  							else
  							{
  								corpse.AddCarvedItem( item, from );
  								from.SendLocalizedMessage( 500471 ); // You skin it, and the hides are now in the corpse.
  							}
  						}
  					}
  					else
  					{
  						if ( HideType == HideType.Regular )
  							corpse.AddCarvedItem( new Hides( hides ), from );
  						else if ( HideType == HideType.Spined )
  							corpse.AddCarvedItem( new SpinedHides( hides ), from );
  						else if ( HideType == HideType.Horned )
  							corpse.AddCarvedItem( new HornedHides( hides ), from );
  						else if ( HideType == HideType.Barbed )
  							corpse.AddCarvedItem( new BarbedHides( hides ), from );
  
  						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.SendLocalizedMessage( 1079284 ); // You cut away some scales, but they remain on the corpse.
  				}
  
  				if ( blood != 0 )
  				{
  					corpse.AddCarvedItem( new DragonsBlood( blood ), from );
  					from.SendLocalizedMessage( 1094946 ); // Some blood is left on the corpse.
  				}
  
  				if ( fur != 0 )
  				{
  					if ( FurType == FurType.Green )
  						corpse.AddCarvedItem( new GreenFur( fur ), from );
  					else if ( FurType == FurType.Red )
  						corpse.AddCarvedItem( new RedFur( fur ), from );
  					else if ( FurType == FurType.Yellow )
  						corpse.AddCarvedItem( new YellowFur( fur ), from );
  					else if ( FurType == FurType.DarkGreen )
  						corpse.AddCarvedItem( new DarkGreenFur( fur ), from );
  
  					from.SendLocalizedMessage( 1112765 ); // You shear it, and the fur is now 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 = PetLoyalty.WonderfullyHappy;
  
  			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_bControlled = false;
  			m_ControlMaster = null;
  			m_ControlTarget = null;
  			m_ControlOrder = OrderType.None;
  
  			m_bTamable = false;
  
  			m_Owners = new List<Mobile>();
  
  			m_NextReacquireTime = DateTime.UtcNow + ReacquireDelay;
  
  			ChangeAIType( AI );
  
  			InhumanSpeech speechType = this.SpeechType;
  
  			if ( speechType != null )
  				speechType.OnConstruct( this );
  
  			GenerateLoot( true );
  
  			Timer.DelayCall( TimeSpan.FromSeconds( 0.01 ), new TimerCallback( CheckParagon ) );
  		}
  
  		public BaseCreature( Serial serial )
  			: base( serial )
  		{
  			m_bDebugAI = false;
  		}
  
  		public override void Serialize( GenericWriter writer )
  		{
  			base.Serialize( writer );
  
  			writer.Write( (int) 25 ); // 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 );
  
  			// 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 );
  			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.WriteMobileList( 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 );
  			writer.Write( (bool) m_IsChampionMonster );
  
  			// Version 13
  			writer.Write( (bool) ( m_Friends != null && m_Friends.Count > 0 ) );
  
  			if ( m_Friends != null && m_Friends.Count > 0 )
  				writer.WriteMobileList( m_Friends, true );
  
  			// Version 14
  			writer.Write( (int) m_SpawnLevel );
  
  			// Version 15
  			writer.Write( (int) m_ChampionType );
  
  			// Version 17
  			writer.Write( (bool) m_StolenFrom );
  
  			// Version 18
  			writer.Write( (int) m_RummagedItems.Count );
  
  			foreach ( KeyValuePair<Item, Mobile> kvp in m_RummagedItems )
  			{
  				writer.Write( kvp.Key );
  				writer.Write( kvp.Value );
  			}
  
  			// Version 20
  			writer.Write( (bool) m_IsMinichampMonster );
  			writer.Write( (int) m_MinichampType );
  
  			// Version 21
  			writer.Write( (DateTime) m_NextTastyTreat );
  
  			// Version 22
  			writer.Write( (bool) m_Petrified );
  
  			if ( m_Petrified )
  			{
  				writer.Write( (int) m_StatueAnimation );
  				writer.Write( (int) m_StatueFrames );
  			}
  
  			// Version 23
  			writer.Write( (DateTime) m_NextArmorEssence );
  
  			// Version 24
  			writer.Write( (bool) m_IsGolem );
  		}
  
  		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();
  
  			if ( version >= 16 && version <= 18 )
  				reader.ReadItem(); // spawner
  
  			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();
  
  			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_dActiveSpeed = activeSpeed;
  			}
  
  			if ( isStandardPassive )
  			{
  				m_dPassiveSpeed = passiveSpeed;
  			}
  
  			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();
  
  				if ( version < 25 )
  				{
  					int i, iCount;
  
  					iCount = reader.ReadInt();
  					for ( i = 0; i < iCount; i++ )
  						reader.ReadString();
  
  					iCount = reader.ReadInt();
  					for ( i = 0; i < iCount; i++ )
  						reader.ReadString();
  				}
  			}
  			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.UtcNow ).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 = (PetLoyalty) reader.ReadInt();
  			else
  				m_Loyalty = PetLoyalty.WonderfullyHappy;
  
  			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();
  				m_IsChampionMonster = reader.ReadBool();
  			}
  			else
  			{
  				m_Paragon = false;
  				m_IsChampionMonster = false;
  			}
  
  			if ( version >= 13 && reader.ReadBool() )
  				m_Friends = reader.ReadStrongMobileList();
  			else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
  				++m_ControlOrder;
  
  			if ( version >= 14 )
  				m_SpawnLevel = reader.ReadInt();
  			else
  				m_SpawnLevel = 0;
  
  			if ( version >= 15 )
  				m_ChampionType = (ChampionSpawnType) reader.ReadInt();
  
  			if ( version >= 17 )
  				m_StolenFrom = reader.ReadBool();
  
  			if ( version >= 18 )
  			{
  				int count = reader.ReadInt();
  
  				for ( int i = 0; i < count; i++ )
  				{
  					Item rummaged = reader.ReadItem();
  					Mobile owner = reader.ReadMobile();
  
  					if ( rummaged != null && owner != null )
  						m_RummagedItems.Add( rummaged, owner );
  				}
  			}
  
  			if ( version >= 20 )
  			{
  				m_IsMinichampMonster = reader.ReadBool();
  				m_MinichampType = (MiniChampType) reader.ReadInt();
  			}
  
  			if ( version >= 21 )
  			{
  				m_NextTastyTreat = reader.ReadDateTime();
  			}
  
  			if ( version >= 22 )
  			{
  				m_Petrified = reader.ReadBool();
  
  				if ( m_Petrified )
  				{
  					m_StatueAnimation = reader.ReadInt();
  					m_StatueFrames = reader.ReadInt();
  
  					Frozen = true;
  					HueMod = 2401;
  				}
  			}
  
  			if ( version >= 23 )
  			{
  				m_NextArmorEssence = reader.ReadDateTime();
  			}
  
  			if ( version >= 24 )
  			{
  				m_IsGolem = reader.ReadBool();
  			}
  			else
  			{
  				m_IsGolem = this is Golem;
  			}
  
  			CheckStatTimers();
  
  			ChangeAIType( m_CurrentAI );
  
  			AddFollowers();
  
  			if ( IsAnimatedDead )
  				Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );
  
  			if ( Controlled )
  				Skills.Cap = 15000;
  		}
  
  		public virtual bool IsHumanInTown()
  		{
  			return ( Body.IsHuman && Region.IsPartOf<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 = this.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 ) ) && ( dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg || dropped is IPetBooster ) )
  			{
  				Item f = dropped;
  
  				if ( dropped is IPetBooster )
  				{
  					IPetBooster pb = dropped as IPetBooster;
  
  					return pb.OnUsed( from, this );
  				}
  				else if ( CheckFoodPreference( f ) )
  				{
  					int amount = f.Amount;
  
  					if ( amount > 0 )
  					{
  						bool happier = false;
  
  						int stamGain;
  
  						if ( f is Gold )
  							stamGain = amount - 50;
  						else
  							stamGain = ( amount * 15 ) - 50;
  
  						if ( stamGain > 0 )
  							Stam += stamGain;
  
  						if ( m_Loyalty != PetLoyalty.WonderfullyHappy )
  						{
  							m_Loyalty = PetLoyalty.WonderfullyHappy;
  							happier = true;
  						}
  
  						#region PetBondingGate
  						if ( TestCenter.Enabled )
  						{
  							if ( !IsBonded )
  							{
  								var overPetBondingGate = from.GetItemsInRange( 5 ).OfType<PetBondingGate>()
  									.Any( pbg => pbg.Location == from.Location && pbg.Location == Location );
  
  								if ( overPetBondingGate )
  								{
  									IsBonded = true;
  									BondingBegin = DateTime.MinValue;
  									from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
  								}
  							}
  						}
  						#endregion
  
  						if ( happier )
  							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 || this is SwampDragon || this is Ridgeback || this is SavageRidgeback || this is FireBeetle || this is LesserHiryu || this is IronBeetle )
  								{
  									if ( BondingBegin == DateTime.MinValue )
  									{
  										BondingBegin = DateTime.UtcNow;
  									}
  									else if ( ( BondingBegin + BondingDelay ) <= DateTime.UtcNow )
  									{
  										IsBonded = true;
  										BondingBegin = DateTime.MinValue;
  										from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
  									}
  								}
  								else
  								{
  									from.SendLocalizedMessage( 1075268 ); // Your pet cannot form a bond with you until your animal taming ability has risen.
  								}
  							}
  						}
  
  						dropped.Delete();
  						return true;
  					}
  				}
  				else if ( !( dropped is Gold ) )
  				{
  					SayTo( from, 1043257 ); // The animal shies away.
  				}
  			}
  
  			return false;
  		}
  
  		#endregion
  
  		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 virtual void ChangeAIType( AIType NewAI )
  		{
  			if ( m_AI != null )
  				m_AI.m_Timer.Stop();
  
  			if ( ForcedAI != null )
  			{
  				m_AI = ForcedAI;
  				return;
  			}
  
  			m_AI = null;
  
  			if ( this is BaseFactionGuard )
  			{
  				m_AI = new FactionGuardAI( (BaseFactionGuard) this );
  				return;
  			}
  
  			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_Arcanist:
  					m_AI = new ArcanistAI( this );
  					break;
  				case AIType.AI_Predator:
  					m_AI = new MeleeAI( this );
  					break;
  				case AIType.AI_Thief:
  					m_AI = new ThiefAI( this );
  					break;
  				case AIType.AI_Ninja:
  					m_AI = new NinjaAI( this );
  					break;
  				case AIType.AI_Samurai:
  					m_AI = new SamuraiAI( this );
  					break;
  				case AIType.AI_ChampionMelee:
  					m_AI = new ChampionMeleeAI( this );
  					break;
  				case AIType.AI_BoneDemon:
  					m_AI = new BoneDemonAI( this );
  					break;
  				case AIType.AI_BossMelee:
  					m_AI = new BossMeleeAI( this );
  					break;
  				case AIType.AI_Necromancer:
  					m_AI = new NecromancerAI( this );
  					break;
  				case AIType.AI_Mephitis:
  					m_AI = new MephitisAI( this );
  					break;
  				case AIType.AI_OrcScout:
  					m_AI = new OrcScoutAI( this );
  					break;
  				case AIType.AI_Mystic:
  					m_AI = new MysticAI( this );
  					break;
  				case AIType.AI_Ambusher:
  					m_AI = new AmbusherAI( this );
  					break;
  				case AIType.AI_WeakMage:
  					m_AI = new WeakMageAI( this );
  					break;
  			}
  		}
  
  		public virtual 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;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int Team
  		{
  			get
  			{
  				return m_iTeam;
  			}
  			set
  			{
  				m_iTeam = value;
  
  				OnTeamChange();
  			}
  		}
  
  		public virtual void OnTeamChange()
  		{
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public Mobile FocusMob
  		{
  			get
  			{
  				return m_FocusMob;
  			}
  			set
  			{
  				m_FocusMob = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public FightMode FightMode
  		{
  			get
  			{
  				return m_FightMode;
  			}
  			set
  			{
  				m_FightMode = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int RangePerception
  		{
  			get
  			{
  				return m_iRangePerception;
  			}
  			set
  			{
  				m_iRangePerception = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int RangeFight
  		{
  			get
  			{
  				return m_iRangeFight;
  			}
  			set
  			{
  				m_iRangeFight = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public int RangeHome
  		{
  			get
  			{
  				return m_iRangeHome;
  			}
  			set
  			{
  				m_iRangeHome = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public double ActiveSpeed
  		{
  			get
  			{
  				return m_dActiveSpeed;
  			}
  			set
  			{
  				m_dActiveSpeed = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public double PassiveSpeed
  		{
  			get
  			{
  				return m_dPassiveSpeed;
  			}
  			set
  			{
  				m_dPassiveSpeed = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public double CurrentSpeed
  		{
  			get
  			{
  				return m_dCurrentSpeed;
  			}
  			set
  			{
  				if ( m_dCurrentSpeed != value )
  				{
  					m_dCurrentSpeed = value;
  
  					if ( m_AI != null )
  						m_AI.OnCurrentSpeedChanged();
  				}
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public Point3D Home
  		{
  			get
  			{
  				return m_pHome;
  			}
  			set
  			{
  				m_pHome = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.GameMaster )]
  		public bool Controlled
  		{
  			get
  			{
  				return m_bControlled;
  			}
  			set
  			{
  				if ( m_bControlled == value )
  					return;
  
  				m_bControlled = value;
  
gt: 				Delta( MobileDelta.Noto );