RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Challenge System 1.1.1

noob2

Wanderer
Challenge System 1.1.1

This is the challenge system but it does not have any complicated edits in pm serilization it uses flags i have not made a new score board yet but plan on doing so as far as i know this has no bugs

for this you can use the old gumps or you can use keywords "I challenge Thee" and "As a Team we challenge Thee"

it will change the map as its supose to and it will put you back where you started and yes it works in any facet

This script was originaly made by Clarke76 sorry i didn't say so ealier

there are 2 small edits to the player mobile you can possible mess it up like you can the complicate serilization.

Add these flags:

Code:
		isinchal	= 0x00100001,
		canbechal	= 0x00100002,
		TempMount	= 0x00100003

Under
Code:
private int m_Profession;

add

Code:
		private int m_Profession;
		private bool isinchal = false;
		private bool canbechal = true;
		private BaseMount m_TempMount;
		
		[CommandProperty( AccessLevel.GameMaster ) ]
		public BaseMount TempMount
		{
			get { return m_TempMount; }
			set { m_TempMount = value; }
		}
		
		[CommandProperty(AccessLevel.Counselor)]
		public bool IsInChallenge
		{
			get{return isinchal;}
			set{isinchal = value;}
		}
		
		[CommandProperty(AccessLevel.Counselor)]
		public bool CanBeChallenged
		{
			get{return canbechal;}
			set{canbechal = value;}
		}


Bugs Fixed:

-You are no longer a Criminal when a dual ends

-The System sets your map to the location of the Arena Properly rather then placing you in a black area on the map

-You are returned to the location that you were at before the dual when it is finished

-The system now toggles your War Mode status before and after a dual so that a dual can begin immediatly after it has started


Addons:

You can now use keywords to start a dual

Future Edits:

-Accept and Decline challenge with keywords similar to party system

-Challengable Mobiles

-Working Score Board

-Annoucer Mobile

-Arenas


and much much more...
 

Attachments

  • Challenge Game 1.1.1.rar
    12.4 KB · Views: 458

Dave1969

Wanderer
Arte Gordon have done and perfected this system awhile ago.

Arte Gordon have done and perfected this system awhile ago. Why bother
 

noob2

Wanderer
and this is why the bugs still remain in the files of other posts?

Edit:
I am almost done with challengable mobiles its just taking a bit to adjust the system to none player mobiles
 

Jeff

Lord
cmon guys give the guy a break, he didnt say he made it, he said it was the challenge system with his fixes. noob2, good job, hope you can make this system into something cool, at least someone is working on it.
 

Asmir3

Sorceror
I hope I was not rude. I just answer someone question and yes this is pretty kool system keep it up :cool:
Sorious said:
cmon guys give the guy a break, he didnt say he made it, he said it was the challenge system with his fixes. noob2, good job, hope you can make this system into something cool, at least someone is working on it.
 

noob2

Wanderer
thanks anyways i am having problems making challengable mobiles work me and my friend worked on it all last night and the server crashes after it says GO GO GO its something in the fight timer according to the crash logs heres the 3 files we edited


ChallengeStone.cs

Code:
using System;
using Server;
using System.Collections;
using Server.Scripts.Commands;
using Server.Targeting;
using Server.Mobiles;
using Server.Gumps; 
using Server.Items;
using Server.Challenge;
using Server.Spells;
using Server.Spells.Second;
using Server.Spells.Third;

namespace Server.Challenge
{
	public class Challenge 
	{
		private static ArrayList worldStones = new ArrayList();

		public static void Initialize() 
		{
			Server.Commands.Register( "Challenge", AccessLevel.Administrator, new CommandEventHandler( Challenge_OnCommand ) );
			Configure();
		}

		public static void Configure()
		{
			EventSink.WorldLoad+= new WorldLoadEventHandler(onLoad);
		}

		public static ArrayList WorldStones
		{			
			get { return worldStones; }
			set { worldStones = value;  }				   
		}
		public static void onLoad() 
		{
			foreach ( Mobile mob in World.Mobiles.Values ) 
			{ 
				if ( mob is PlayerMobile ) 
				{ 
					PlayerMobile pm = (PlayerMobile)mob;
					if( pm.IsInChallenge )
					{
						pm.IsInChallenge = false;
						int kills = 0;
						
						if( pm.FindItemOnLayer( Layer.Ring ) is ChallengeRing )
						{
							pm.FindItemOnLayer( Layer.Ring ).Delete();
							ChallengeRing ring = pm.FindItemOnLayer(Layer.Ring )as ChallengeRing;
							kills = ring.Kills;
						}
						
						if( kills >= 5 )
							pm.LogoutLocation = new Point3D( 2623, 2120, 10 );
						else
							pm.LogoutLocation = new Point3D( 1522, 1757, 28 );
						
						if( pm.TempMount != null )
						{
							pm.TempMount.Rider = pm;
							pm.TempMount = null;
						}
					}
				} 
			}
			foreach ( Item item in World.Items.Values ) 
			{ 
				if (item is ChallengeStone) 
				{ 
					WorldStones.Add(item);
				} 
			} 
		}		

		[Usage( "Challenge" )] 
		[Description( "Initiates Challenge Game!" )] 
		public static void Challenge_OnCommand( CommandEventArgs e ) 
		{    
			Mobile from = e.Mobile;

			from.CloseGump( typeof( BeginGump ) );
			from.SendGump( new BeginGump( (PlayerMobile)from, WorldStones ) );

			return;
		}
	}
} 

namespace Server.Items
{ 
	public enum ChallengeGameType 
	{ 
		OnePlayerTeam, TwoPlayerTeam
	}

	[Serializable()] 
	public class ChallengeStone : Item 
	{ 
		public bool m_Active;
		public Point3D m_ChallengerPointDest;
		public Point3D m_OpponentPointDest;
		public Point3D m_ChallengerExitPointDest;
		public Point3D m_OpponentExitPointDest;
		public Map m_MapDest;
		private Mobile m_OpponentMobile;
		private Mobile m_ChallengerMobile;
		private ChallengeGameType m_Game = ChallengeGameType.OnePlayerTeam;
		private ArrayList m_ChallengePlayers = new ArrayList();
		private ArrayList m_OpponentPlayers = new ArrayList();
		private ArrayList m_ChallengerDead = new ArrayList();
		private ArrayList m_OpponentDead = new ArrayList();
		private int dualLength = 30;

		public ArrayList ChallengeTeam{ get{ return m_ChallengePlayers; } }
		public ArrayList OpponentTeam{ get{ return m_OpponentPlayers; } }
		public ArrayList ChallengerDead{ get{ return m_ChallengerDead; } }
		public ArrayList OpponentDead{ get{ return m_OpponentDead; }}

		[CommandProperty( AccessLevel.GameMaster )] 
		public int DualLength 
		{ 
			get { return dualLength; } 
			set { dualLength = value; } 
		}
		[CommandProperty( AccessLevel.GameMaster )] 
		public ChallengeGameType Game 
		{ 
			get { return m_Game; } 
			set { m_Game = value; } 
		} 

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Active
		{
			get { return m_Active; }
			set 
			{
				m_Active = value; InvalidateProperties();
				if ( m_Active == true )
					Name = "Challenge Stone[Not in use]" ;
				if ( m_Active == false )
					Name = "Challenge Stone[In use]" ;
			}
			
		}
		   	   
		[CommandProperty( AccessLevel.GameMaster )]
		public Point3D ChallengerPointDest
		{
			get { return m_ChallengerPointDest; }
			set { m_ChallengerPointDest = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Point3D OpponentPointDest
		{
			get { return m_OpponentPointDest; }
			set { m_OpponentPointDest = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Map MapDest
		{
			get { return m_MapDest; }
			set { m_MapDest = value; }
		}

		[Constructable]
		public ChallengeStone() : this( new Point3D( 0, 0, 0 ), new Point3D( 0, 0, 0 ), new Point3D( 0, 0, 0 ), new Point3D( 0, 0, 0 ), null, false )
		{
		}

		[Constructable]
		public ChallengeStone( Point3D challengerpointDest, Point3D opponentpointDest, Point3D challengerexit, Point3D opponentexit, Map mapDest, bool creatures ) : base( 0xED4 )
		{
			Movable = false; 
			Hue = 0; 
			Name = "a Ladder Dueling stone"; 

			Active = true;
			m_ChallengerPointDest = challengerpointDest;
			m_OpponentPointDest = opponentpointDest;
			m_ChallengerExitPointDest = challengerexit;
			m_OpponentExitPointDest = opponentexit;
			m_MapDest = mapDest;
			m_ChallengePlayers = new ArrayList();
			m_OpponentPlayers = new ArrayList();
			m_ChallengerDead = new ArrayList();
			m_OpponentDead = new ArrayList();
			Challenge.Challenge.WorldStones.Add( this );
		}
		public override void OnSingleClick( Mobile from )
		{
			if ( Active == true )
			{
				LabelTo( from, Name );
				LabelTo( from, "Not in use" );
			}
			if ( Active == false )
			{
				LabelTo( from, Name );
				LabelTo( from, "In Use" );
			}
		}

		public void AddChallengePlayer( PlayerMobile player)
		{ 
			ChallengeTeam.Add(player);
		}
		public void AddOpponentPlayer( PlayerMobile player)
		{ 
			OpponentTeam.Add(player);
		}
		public void AddOpponentMobile( Mobile mobile)
		{ 
			OpponentTeam.Add(mobile);
		}
		public void RemoveChallengePlayer( PlayerMobile player)
		{ 
			ChallengeTeam.Remove(player); 
		}
		public void RemoveOpponentPlayer( PlayerMobile player)
		{ 
			OpponentTeam.Remove(player); 
		}
		public void AddChallengerDead( PlayerMobile player )
		{
			ChallengerDead.Add(player);
		}
		public void AddOpponentDead( PlayerMobile player )
		{
			OpponentDead.Add(player);
		}
		public void ClearAll()
		{
			Active = true;
			foreach ( PlayerMobile opponent in OpponentTeam )
			{
				opponent.IsInChallenge = false;
			}
			foreach( PlayerMobile challenger in ChallengeTeam )
			{
				challenger.IsInChallenge = false;
			}
			ChallengeTeam.Clear();
			ChallengerDead.Clear();
			OpponentTeam.Clear();
			OpponentDead.Clear();
		}  
	
		public override void OnDelete()
		{
			base.OnDelete ();
			if( Challenge.Challenge.WorldStones.Contains( this ))
			{
				Challenge.Challenge.WorldStones.Remove( this );
			}
		}

		public override void OnDoubleClick( Mobile from ) 
		{
			if( Active )
			{
				PlayerMobile pm = from as PlayerMobile;
				Active = false;
				pm.IsInChallenge = true;

				from.Hidden = false;
				this.ChallengeTeam.Add( pm );
				from.Target = new ChallengeTarget( pm,this, 0 );

				if( m_Game == ChallengeGameType.TwoPlayerTeam )
					from.SendMessage( 33, "Please Choose Your Partner " );
				else
					from.SendMessage( 33, "Please Choose Your Opponent " );	
			}

		}
		public void makeready(Mobile who)    
		{	
			PlayerMobile c = (PlayerMobile) who;
			if( !who.Alive )
				who.Resurrect();
			
			Container bp = c.Backpack;
			Container bankbag = new Bag();
			bankbag.Hue = 63;
			BankBox bank = c.BankBox;
			Item oncurs = c.Holding;
						
			if(oncurs != null)
				bp.DropItem(oncurs);
						
			c.SendMessage( "You have 10 seconds until the duel begins" );
			c.SendMessage( 63, "After one of you dies, both of you will be teleported out" );
						
			c.Criminal = true;
			c.CurePoison(c);
	
			c.Blessed = true;
			c.Frozen = true;

			c.Hits = c.HitsMax;
			c.Mana = c.ManaMax;
			c.Stam = c.StamMax;
			
			c.StatMods.Clear();

			if(bp != null)
			{
				Item toDisarm = c.FindItemOnLayer( Layer.OneHanded );
				
				if ( toDisarm == null || !toDisarm.Movable )
					toDisarm = c.FindItemOnLayer( Layer.TwoHanded );
				
				if (toDisarm != null)
					bp.DropItem(toDisarm);

				if ( c.Mount != null )
				{
					IMount mount = c.Mount;	
					mount.Rider = null;
					if( mount is BaseMount )
					{
						BaseMount oldMount = (BaseMount)mount;	
						oldMount.Map = Map.Internal;
						c.TempMount = oldMount;
					}
				}
				
				while((BasePotion)bp.FindItemByType(typeof(BasePotion)) != null)
				{
					BasePotion potion = (BasePotion)bp.FindItemByType(typeof(BasePotion)); 
					bankbag.DropItem(potion);
				}
				while((EtherealMount)bp.FindItemByType(typeof(EtherealMount)) != null)
				{
					EtherealMount mount = (EtherealMount)bp.FindItemByType(typeof(EtherealMount)); 
					bankbag.DropItem(mount);
				}
				/*Item[] weps = bp.FindItemsByType( typeof( BaseWeapon ) ); 
				for ( int i = 0; i < weps.Length; ++i ) 
				{ 
					Item item = (Item)weps[i];
					BaseWeapon weapon = item as BaseWeapon;
					if( weapon.DamageLevel > WeaponDamageLevel.Regular ) 
								bankbag.DropItem( item );
				}*/
				if( bankbag.Items.Count > 0 )
					bank.DropItem(bankbag);
				else
					bankbag.Delete();
			} 
		}
		public void TimerStart()
		{
			new InternalTimer( this ).Start();
		}
		public class InternalTimer : Timer 
		{  
			private int m_Count = 10;
			private ChallengeStone m_Item;
			private ArrayList m_Players = new ArrayList();
			private DateTime dualstart;
			
			public InternalTimer( ChallengeStone item ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
			{
				m_Item = item;
				m_Players.AddRange( item.ChallengeTeam );
				m_Players.AddRange( item.OpponentTeam );
			} 
			
			public void nocheat(Mobile who)    
			{
				Targeting.Target.Cancel( who );
				who.MagicDamageAbsorb = 0;
				who.MeleeDamageAbsorb = 0;
				ProtectionSpell.Registry.Remove( who );
				DefensiveSpell.Nullify( who );
			}
			protected override void OnTick() 
			{  
				m_Count--; 
                		
				if ( (m_Count % 5) == 0 && m_Count > 10)
				{	
					foreach ( Mobile pm in m_Players )
						pm.SendMessage( "{0} seconds until the duel begins.", m_Count );
				}
				else if(m_Count <= 10 && m_Count > 0)
				{
					foreach ( Mobile pm in m_Players )
						pm.SendMessage( "{0}", m_Count );
				}
				else if ( m_Count == 0 ) 
				{
					foreach ( Mobile pm in m_Players )
					{
						nocheat((Mobile)pm);
						pm.Frozen = false;
						pm.Blessed = false;
						pm.Warmode = true;
						ChallengeRing ring = new ChallengeRing( m_Item, m_Players );
						pm.EquipItem( ring );
						pm.SendMessage( 43, "GO GO GO GO GO GO GO GO GO GO!" );
					}
					new FightTimer( m_Item, m_Players ).Start();
					Stop();
				} 
			}			
		}
		public class FightTimer : Timer 
		{  
			private double m_Count;
			private int m_Seconds;
			private ChallengeStone m_Item;
			private ArrayList m_Players;
				
			public FightTimer( ChallengeStone item, ArrayList players ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ))
			{	
				m_Item = item;
				m_Players = players;
				m_Count = item.DualLength;
				m_Seconds = item.DualLength * 60;
			} 
		
			public void attrib(Mobile who)
			{

				 PlayerMobile m = who as PlayerMobile;
			 	
				RemoveRing(m);
				m.Aggressed.Clear();
				m.Aggressors.Clear();
				if(!who.Alive)
					who.Resurrect();

				if(m.TempMount != null)
				{
					m.TempMount.Rider = m;
					m.TempMount = null;
				}			 	
				m.Criminal = false;
				m.Warmode = false;
				m.PlaySound( 0x214 );
				m.FixedEffect( 0x376A, 10, 16 );
				m.Hits = 125;
				m.Mana = 125;
				m.Stam = 125;					
			}
			public void RemoveRing( PlayerMobile m )
			{
				ChallengeRing ring =  new ChallengeRing();

				foreach( Item item in m.Items )
				{
					if( item is ChallengeRing )
						ring = item as ChallengeRing;
				}
				if( ring != null )
					ring.Delete();
			}
			public void winner(PlayerMobile winner)
			{
				winner.BankBox.Open();
				winner.SendMessage( 43, "Congratulations on winning the duel!!");
				winner.SendMessage( 43, "Don't forget to retreive your items from the bank!!");
				//winner.Wins += 1;
			}

			public void loser(PlayerMobile loser)
			{
				loser.BankBox.Open();
				loser.SendMessage( 43, "Somebody get owned?");
				loser.SendMessage( 43, "Don't forget to retreive your items from the bank!!");
				//loser.Loses += 1;
			}
			protected override void OnTick() 
			{ 
				m_Seconds--;
				m_Count = (m_Seconds / 60);

				if ( (m_Count % 5) == 0 && m_Count <= 30 && (double)m_Count == (double)m_Seconds/60)
				{	
					foreach ( Mobile pm in m_Players )
						pm.SendMessage( "The Duel will end in {0} minutes ", m_Count );	
				}
				else if ( m_Count == 1 && (double)m_Count == (double)m_Seconds/60 )
				{	
					foreach ( Mobile pm in m_Players )
						pm.SendMessage( "1 minute left" );
				}
				else if ( m_Seconds <= 10 )
				{	
					foreach ( Mobile pm in m_Players )
						pm.SendMessage( "{0}", m_Seconds );
				}
				else if ( m_Count == 0 )
				{	
					foreach ( Mobile pm in m_Players )
					{
						pm.SendMessage( 43, "You failed to kill your opponent. The game is ending..." );
						pm.SendMessage( 43, "Don't forget to retreive your items from the bank!!");
						attrib( pm as Mobile );
					}

					foreach( Mobile challenger in m_Item.ChallengeTeam )
						challenger.Location = m_Item.m_ChallengerExitPointDest;
						
					foreach (Mobile opponent in m_Item.OpponentTeam )
						opponent.Location = m_Item.m_OpponentExitPointDest;		

					m_Item.ClearAll();
					Stop();
				}
				foreach( PlayerMobile challenger in m_Item.ChallengeTeam )
				{
					if ( !challenger.Alive )
					{
						if ( !m_Item.ChallengerDead.Contains( challenger ))
							m_Item.AddChallengerDead( challenger );
					}
				}		
				foreach (PlayerMobile opponent in m_Item.OpponentTeam )
				{
					if ( !opponent.Alive )
					{
						if ( !m_Item.OpponentDead.Contains( opponent ))
							m_Item.AddOpponentDead( opponent );
					}
				}
				if ( m_Item.ChallengerDead.Count == m_Item.ChallengeTeam.Count || m_Item.OpponentDead.Count == m_Item.OpponentTeam.Count )
				{
					foreach ( PlayerMobile pm in m_Players )
					{
						attrib( pm as Mobile );
					}					 
					foreach( PlayerMobile challenger in m_Item.ChallengeTeam )
					{
						if( challenger.NetState != null )
							challenger.Location = m_Item.m_ChallengerExitPointDest;
						else
							challenger.LogoutLocation = m_Item.m_ChallengerExitPointDest;
					}                                         
					foreach (PlayerMobile opponent in m_Item.OpponentTeam )
					{
						if( opponent.NetState != null )
							opponent.Location = m_Item.m_OpponentExitPointDest;
						else
							opponent.LogoutLocation = m_Item.m_OpponentExitPointDest;
					}						
					if(m_Item.ChallengerDead.Count == m_Item.ChallengeTeam.Count && m_Item.OpponentDead.Count == m_Item.OpponentTeam.Count)
					{
						foreach( PlayerMobile challenger in m_Item.ChallengeTeam )
							challenger.SendMessage( 63, "Neither side lost, due to all fighters being dead.." );
					    
						foreach (PlayerMobile opponent in m_Item.OpponentTeam )
							opponent.SendMessage( 63, "Neither side lost, due to all fighters being dead.." );
					}					    
					if(m_Item.ChallengerDead.Count == m_Item.ChallengeTeam.Count)
					{
						foreach (PlayerMobile opponent in m_Item.OpponentTeam )
							winner(opponent);
						foreach( PlayerMobile challenger in m_Item.ChallengeTeam )
							loser(challenger);
					}
					if(m_Item.OpponentDead.Count == m_Item.OpponentTeam.Count)
					{
						foreach( PlayerMobile challenger in m_Item.ChallengeTeam )
							winner(challenger);
						foreach (PlayerMobile opponent in m_Item.OpponentTeam )
							loser(opponent);
					}					  
					m_Item.ClearAll();
					Stop();
				}
			}
		}
		public ChallengeStone( Serial serial ) : base( serial ) 
		{ 
		} 

		public override void Serialize( GenericWriter writer ) 
		{ 
			base.Serialize( writer ); 

			writer.Write( (int) 3 );// version

			writer.Write( (int)dualLength);
			writer.Write( (int)m_Game );
			writer.Write( m_ChallengerExitPointDest );
			writer.Write( m_OpponentExitPointDest );
			writer.Write( true );
			writer.Write( m_ChallengerPointDest );
			writer.Write( m_OpponentPointDest );
			writer.Write( m_MapDest );
		} 

		public override void Deserialize( GenericReader reader ) 
		{ 
			base.Deserialize( reader ); 

			int version = reader.ReadInt();
 
			switch ( version )
			{	  
				case 3:
				{
					dualLength = reader.ReadInt();
					goto case 2;
				}
				case 2:
				{
					m_Game = (ChallengeGameType)reader.ReadInt();
					goto case 1;
				}			  

				case 1:
				{
					m_ChallengerExitPointDest = reader.ReadPoint3D();
					m_OpponentExitPointDest = reader.ReadPoint3D();
					goto case 0;
				}
			  
				case 0:
				{
					m_Active = reader.ReadBool();
					m_ChallengerPointDest = reader.ReadPoint3D();
					m_OpponentPointDest = reader.ReadPoint3D();
					m_MapDest = reader.ReadMap();
					break;
				}
			}
		}
	} 
}

ChallengeTarget.cs

Code:
using System;
using System.Collections;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Multis;
using Server.Mobiles;
using Server.Gumps;

namespace Server.Items
{
	public class ChallengeTarget : Target
	{
		private PlayerMobile pm;
		private ChallengeStone m_Item;
		private const string ChallengeeFormat = "{0} is challenging me!";
		private const string TeamFormat = "{0} is selecting me to be a teammate!";
		private int i;

		public ChallengeTarget( PlayerMobile from, ChallengeStone item, int count ) :  base ( 100, false, TargetFlags.None )
		{
			pm = from;
			m_Item = item;
			i = count;			
		}
					
		protected override void OnCantSeeTarget (Mobile from, object target )
		{m_Item.ClearAll();}

		protected override void OnTargetCancel(Mobile from, TargetCancelType Overriden)
		{m_Item.ClearAll();}

		protected override void OnTargetDeleted (Mobile from, object target )
		{m_Item.ClearAll();}

		protected override void OnTargetNotAccessible(Mobile from, object target )
		{m_Item.ClearAll();}

		protected override void OnTargetOutOfLOS(Mobile from, object target )
		{m_Item.ClearAll();}

		protected override void OnTargetOutOfRange(Mobile from, object target )
		{m_Item.ClearAll();}

		protected override void OnTargetUntargetable(Mobile from, object target )
		{m_Item.ClearAll();}		

		protected override void OnTarget( Mobile from, object target )
		{	
			if( m_Item.ChallengeTeam.Contains(target))
			{
				from.SendMessage( "You can't add someone already on your team" );
				from.Target = new ChallengeTarget( pm, m_Item, i );
			}
			else if( m_Item.OpponentTeam.Contains(target))
			{
				from.SendMessage( "You can't challenge someone already on the opposing team" );
				from.Target = new ChallengeTarget( pm, m_Item, i );
			}
			else if( !(target is Mobile) )
			{
				from.SendMessage( "You can't target that" );
				from.Target = new ChallengeTarget( pm, m_Item, i );
			}
			else if ( target is Mobile )
			{	
				if( (target is PlayerMobile) )							
				{
					PlayerMobile m = (PlayerMobile)target;
	
					if ( m.Young == true )
						{
						from.SendMessage( 33, "You can not challenge someone who is young, select again!" );
						m.SendMessage( 33, "The ladder system is not usable by characters who are young!" );
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else if ( m.Frozen == true )
					{
						from.SendMessage( 33, "That player is frozen, select again!" );
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else if( m.Hits != m.HitsMax )
					{
						from.SendMessage( 33, "Player's health must be full in order to be challenged, select again!");
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else if ( m.IsInChallenge )
					{
						from.SendMessage( 33, "That player is currently being invited into a challenge, select again!" );
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else if ( !m.CanBeChallenged )
					{
						from.SendMessage( 33, "That player is currently not accepting challenge invitations, select again!" );
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else
					{
						if( m_Item.Game == ChallengeGameType.OnePlayerTeam )
						{
							m_Item.AddOpponentPlayer( m );
							m.IsInChallenge = true;
							m.PublicOverheadMessage(MessageType.Regular, 1153, true, String.Format( ChallengeeFormat, from.Name ) );
							m.SendGump( new FinalGump( pm, m, m_Item ));
						}
						else if( m_Item.Game == ChallengeGameType.TwoPlayerTeam )
						{
							m.IsInChallenge = true;
						
							if(i < 2)
							{
								if(i == 0)
								{
									m_Item.ChallengeTeam.Add( m );
									m.PublicOverheadMessage(MessageType.Regular, 1153, true, String.Format( TeamFormat, from.Name ) );
								}
								if(i == 1)
								{
									m_Item.OpponentTeam.Add( m ); 
									m.PublicOverheadMessage(MessageType.Regular, 1153, true, String.Format( ChallengeeFormat, from.Name ) );
								}
								i++; 
								m.SendGump(new PartnerGump( pm, m_Item, i, m ));
							}
							else if( i == 2 )
							{
								m_Item.OpponentTeam.Add( m );
								m.PublicOverheadMessage(MessageType.Regular, 1153, true, String.Format( ChallengeeFormat, from.Name ) );
								m.SendGump( new FinalGump( pm, m, m_Item ) );
								i = 0;
							}
						}						
					}	
				}		
				else if( (target is BaseCreature) )							
				{
					BaseCreature opp = (BaseCreature)target;			
					if(opp.Challange != true) 
					{
						from.SendMessage( "The mobile refuses your challange" );
						from.Target = new ChallengeTarget( pm, m_Item, i );
					}
					else
					{
						m_Item.AddOpponentMobile( opp );

						m_Item.m_ChallengerExitPointDest = from.Location;
						m_Item.m_OpponentExitPointDest = opp.Location;

						Mobile fighters = pm as Mobile;
						from.SendMessage( 63, "The Challenge is accepted. Let the duel begin!" );
						m_Item.makeready( fighters );

						Point3D temp1 = m_Item.m_ChallengerPointDest;
						Point3D temp2 = m_Item.m_OpponentPointDest;

						from.Location = temp1; 
						temp1 = new Point3D((temp1.X + 1),temp1.Y,temp1.Z);

						opp.Location = temp2;
						temp2 = new Point3D((temp2.X - 1),temp2.Y,temp2.Z);

						m_Item.TimerStart();	
					}
				}
			}
		}
	}
}

BaseCreature.cs My friend spelled challange wrong but thats ok i'll fix it later he spelled it as challange lol

Code:
using System;
using System.Collections;
using Server;
using Server.Regions;
using Server.Targeting;
using Server.Network;
using Server.Spells;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
using Server.ContextMenus;
using Server.Engines.Quests;
using Server.Factions;
using Server.Spells.Ninjitsu;
using Server.Spells.Bushido;
using Server.Engines.CannedEvil;

namespace Server.Mobiles
{
	/// <summary>
	/// Summary description for MobileAI.
	/// </summary>
	/// 
	public enum FightMode
	{
		None, // Never focus on others
		Agressor, // Only attack agressors
		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). 
		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.  
		Transfert //"(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
	}

	public enum ScaleType
	{
		Red,
		Yellow,
		Black,
		Green,
		White,
		Blue,
		All
	}

	public enum MeatType
	{
		Ribs,
		Bird,
		LambLeg
	}

	public enum HideType
	{
		Regular,
		Spined,
		Horned,
		Barbed
	}

	public enum PetLoyalty
	{
		None,
		Confused,
		ExtremelyUnhappy,
		RatherUnhappy,
		Unhappy,
		SomewhatContent,
		Content,
		Happy,
		RatherHappy,
		VeryHappy,
		ExtremelyHappy,
		WonderfullyHappy
	}

	public class DamageStore : IComparable
	{
		public Mobile m_Mobile;
		public int m_Damage;
		public bool m_HasRight;
		public double m_DamagePercent;

		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;
		}
	}

	public class BaseCreature : Mobile
	{
		private bool m_Challange;
		
		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 ArrayList m_arSpellAttack; // List of attack spell/power
		private ArrayList m_arSpellDefense; // Liste of defensive spell/power

		private bool m_bControled; // Is controled
		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 ArrayList m_Owners;
		private ArrayList 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 double m_Valor_Award_Per_Monster = 0.1;

		private int m_SpawnLevel;

		private ChampionSpawnType m_ChampionType;

		public virtual InhumanSpeech SpeechType { get { return null; } }

		public bool IsStabled { get { return m_IsStabled; } set { m_IsStabled = 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 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; } }

		private PlayerMobile m_HonorOpponent;

		public PlayerMobile HonorOpponent { get { return m_HonorOpponent; } set { m_HonorOpponent = value; } }
		#endregion

		public virtual double WeaponAbilityChance { get { return 0.4; } }

		public virtual WeaponAbility GetWeaponAbility()
		{
			return null;
		}

		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 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; } }

		public virtual FoodType FavoriteFood { get { return FoodType.Meat; } }

		public virtual PackInstinct PackInstinct { get { return PackInstinct.None; } }

		public ArrayList 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 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 DeathAdderCharmable { get { return false; } }

		public virtual bool BleedImmune { 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 double BardingDifficulty
		{
			get
			{
				Mobile m = this as Mobile;

				Lute lute = new Lute();

				double diff = 0;

				if ( m != null )
				{
					diff = lute.GetDifficultyFor( m );
				}

				lute.Delete();

				return diff;
			}
		}

		#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 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.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 ( CanBeHarmful( target ) )
			{
				DoHarmful( target );
				BreathDealDamage( target );
			}
		}

		public virtual void BreathDealDamage( Mobile target )
		{
			if ( Spells.Bushido.Evasion.UnderEffect( 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()
		{
			return (int) (Hits*BreathDamageScalar);
		}
		#endregion

		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;
		}

		public BaseAI AIObject { get { return m_AI; } }

		public const int MaxOwners = 5;

		public virtual OppositionGroup OppositionGroup { get { return null; } }

		public ArrayList 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 ArrayList( 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_bControled) == (c.m_bSummoned || c.m_bControled)));
		}

		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 ( !Controled && (HonorVirtue.UnderHonorEmbrace( m ) || BaseMaskOfDeathPotion.UnderEffect( m )) )
			{
				return false;
			}

			if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
			{
				return true;
			}

			BaseCreature c = (BaseCreature) m;

			return (m_iTeam != c.m_iTeam || ((m_bSummoned || m_bControled) != (c.m_bSummoned || c.m_bControled)));
		}

		public override string ApplyNameSuffix( string suffix )
		{
			if ( IsParagon )
			{
				if ( suffix.Length == 0 )
				{
					suffix = "(Paragon)";
				}
				else
				{
					suffix = String.Concat( suffix, " (Paragon)" );
				}
			}

			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;
			}

			PlaySound( GetAngerSound() );

			if ( Body.IsAnimal )
			{
				Animate( 10, 5, 1, true, false, 0 );
			}
			else if ( Body.IsMonster )
			{
				Animate( 18, 5, 1, true, false, 0 );
			}

			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;
			}

			if ( this is Hiryu || this is LesserHiryu )
			{
				if ( !SamuraiSpell.CheckExpansion( m ) )
				{
					m.SendLocalizedMessage( 1070697 ); // You must upgrade to the Samurai Empire expansion in order to control this creature.

					return 0;
				}
			}

			double dMinTameSkill = m_dMinTameSkill;

			if ( dMinTameSkill > -24.9 && Server.SkillHandlers.AnimalTaming.CheckMastery( m, this ) )
			{
				dMinTameSkill = -24.9;
			}

			int taming = (int) (m.Skills[ SkillName.AnimalTaming ].Value*10);
			int lore = (int) (m.Skills[ SkillName.AnimalLore ].Value*10);
			int difficulty = (int) (dMinTameSkill*10);
			int weighted = ((taming*4) + lore)/5;
			int bonus = weighted - difficulty;
			int chance;

			if ( bonus <= 0 )
			{
				chance = 700 + (bonus*14);
			}
			else
			{
				chance = 700 + (bonus*6);
			}

			if ( chance >= 0 && chance < 200 )
			{
				chance = 200;
			}
			else if ( chance > 990 )
			{
				chance = 990;
			}

			int loyaltyValue = 1;

			if ( m_Loyalty > PetLoyalty.Confused )
			{
				loyaltyValue = (int) (m_Loyalty - PetLoyalty.Confused)*10;
			}

			chance -= (100 - loyaltyValue)*10;

			return ((double) chance/10);
		}

		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;

			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( 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 && !Controled )
			{
				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 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 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;
		}

		public override void OnDamage( int amount, Mobile from, bool willKill )
		{
			if ( BardPacified && (HitsMax - Hits)*0.001 > Utility.RandomDouble() )
			{
				Unpacify();
			}

			WeightOverloading.FatigueOnDamage( this, amount );

			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null && !willKill )
			{
				speechType.OnDamage( this, amount );
			}

			base.OnDamage( amount, from, willKill );
		}

		public virtual void OnDamagedBySpell( Mobile from )
		{
		}

		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 )
		{
		}

		public virtual void CheckReflect( Mobile caster, ref bool reflect )
		{
		}

		public virtual void OnCarve( Mobile from, Corpse corpse )
		{
			ArrayList list = GetLootingRights( this.DamageEntries, this.HitsMax );

			bool can_carve = false;

			for ( int i = 0; i < list.Count; i++ )
			{
				DamageStore ds = list[ i ] as DamageStore;

				if ( ds.m_Mobile == from )
				{
					can_carve = true;
				}
			}

			if ( !can_carve )
			{
				return;
			}

			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 )
			{
				from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
			}
			else
			{
				if ( corpse.Map == Map.Felucca )
				{
					feathers *= 2;
					wool *= 2;
					hides *= 2;
				}

				new Blood( 0x122D ).MoveToWorld( corpse.Location, corpse.Map );

				if ( feathers != 0 )
				{
					Feather f = new Feather( feathers );
					f.Keeper = from;
					corpse.DropItem( f );
					from.SendLocalizedMessage( 500479 ); // You pluck the bird. The feathers are now on the corpse.
				}

				if ( wool != 0 )
				{
					Wool w = new Wool( wool );
					w.Keeper = from;
					corpse.DropItem( w );
					from.SendLocalizedMessage( 500483 ); // You shear it, and the wool is now on the corpse.
				}

				if ( meat != 0 )
				{
					if ( MeatType == MeatType.Ribs )
					{
						RawRibs rr = new RawRibs( meat );
						rr.Keeper = from;
						corpse.DropItem( rr );
					}
					else if ( MeatType == MeatType.Bird )
					{
						RawBird rb = new RawBird( meat );
						rb.Keeper = from;
						corpse.DropItem( rb );
					}
					else if ( MeatType == MeatType.LambLeg )
					{
						RawLambLeg rll = new RawLambLeg( meat );
						rll.Keeper = from;
						corpse.DropItem( rll );
					}

					from.SendLocalizedMessage( 500467 ); // You carve some meat, which remains on the corpse.
				}

				if ( hides != 0 )
				{
					if ( HideType == HideType.Regular )
					{
						Hides h = new Hides( hides );
						h.Keeper = from;
						corpse.DropItem( h );
					}
					else if ( HideType == HideType.Spined )
					{
						SpinedHides sh = new SpinedHides( hides );
						sh.Keeper = from;
						corpse.DropItem( sh );
					}
					else if ( HideType == HideType.Horned )
					{
						HornedHides hh = new HornedHides( hides );
						hh.Keeper = from;
						corpse.DropItem( hh );
					}
					else if ( HideType == HideType.Barbed )
					{
						BarbedHides bh = new BarbedHides( hides );
						bh.Keeper = from;
						corpse.DropItem( bh );
					}

					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:
							{
								RedScales rs = new RedScales( scales );
								rs.Keeper = from;
								corpse.DropItem( rs );
								break;
							}
						case ScaleType.Yellow:
							{
								YellowScales ys = new YellowScales( scales );
								ys.Keeper = from;
								corpse.DropItem( ys );
								break;
							}
						case ScaleType.Black:
							{
								BlackScales bs = new BlackScales( scales );
								bs.Keeper = from;
								corpse.DropItem( bs );
								break;
							}
						case ScaleType.Green:
							{
								GreenScales gs = new GreenScales( scales );
								gs.Keeper = from;
								corpse.DropItem( gs );
								break;
							}
						case ScaleType.White:
							{
								WhiteScales ws = new WhiteScales( scales );
								ws.Keeper = from;
								corpse.DropItem( ws );
								break;
							}
						case ScaleType.Blue:
							{
								BlueScales bls = new BlueScales( scales );
								bls.Keeper = from;
								corpse.DropItem( bls );
								break;
							}
						case ScaleType.All:
							{
								RedScales rs = new RedScales( scales );
								rs.Keeper = from;
								corpse.DropItem( rs );

								YellowScales ys = new YellowScales( scales );
								ys.Keeper = from;
								corpse.DropItem( ys );

								BlackScales bs = new BlackScales( scales );
								bs.Keeper = from;
								corpse.DropItem( bs );

								GreenScales gs = new GreenScales( scales );
								gs.Keeper = from;
								corpse.DropItem( gs );

								WhiteScales ws = new WhiteScales( scales );
								ws.Keeper = from;
								corpse.DropItem( ws );

								BlueScales bls = new BlueScales( scales );
								bls.Keeper = from;
								corpse.DropItem( bls );

								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_Challange = false;

			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_arSpellAttack = new ArrayList();
			m_arSpellDefense = new ArrayList();

			m_bControled = false;
			m_ControlMaster = null;
			m_ControlTarget = null;
			m_ControlOrder = OrderType.None;

			m_bTamable = false;

			m_Owners = new ArrayList();

			m_NextReaquireTime = DateTime.Now + ReaquireDelay;

			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_arSpellAttack = new ArrayList();
			m_arSpellDefense = new ArrayList();

			m_bDebugAI = false;
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 16 ); // 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_bControled );
			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.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 16
			writer.Write( (bool) m_Challange );
		}

		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();

			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();

				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_bControled = 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_bControled = 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.ReadMobileList();
			}
			else
			{
				m_Owners = new ArrayList();
			}

			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.ReadMobileList();
			}
			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 >= 16 )
			{
			m_Challange = reader.ReadBool();
			}

			CheckStatTimers();

			ChangeAIType( m_CurrentAI );

			AddFollowers();

			if ( IsAnimatedDead )
			{
				Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );
			}

			if ( Controled )
			{
				Skills.Cap = 15000;
			}
		}

		public virtual bool IsHumanInTown()
		{
			return (Body.IsHuman && Region is 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; } }

		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 )};

		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 && Controled && (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) )
			{
				Item f = dropped;

				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;
						}

						for ( int i = 0; i < amount; ++i )
						{
							if ( m_Loyalty < PetLoyalty.WonderfullyHappy && 0.5 >= Utility.RandomDouble() )
							{
								++m_Loyalty;
								happier = true;
							}
						}

						#region PetBondingGate
						if ( TestCenter.Enabled )
						{
							IPooledEnumerable inRange = from.Map.GetItemsInRange( from.Location, 5 );

							foreach ( Item trg in inRange )
							{
								PetBondingGate pbg = trg as PetBondingGate;

								if ( pbg != null && pbg.Location == from.Location && pbg.Location == Location && !IsBonded )
								{
									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 )
							{
								if ( m_dMinTameSkill <= 29.1 || master.Skills[ SkillName.AnimalTaming ].Value >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback || this is FireBeetle || this is LesserHiryu )
								{
									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!
									}
								}
							}
						}

						dropped.Delete();
						return true;
					}
				}
			}

			return false;
		}

		public virtual void OnActionWander()
		{
		}

		public virtual void OnActionCombat()
		{
		}

		public virtual void OnActionGuard()
		{
		}

		public virtual void OnActionFlee()
		{
		}

		public virtual void OnActionInteract()
		{
		}

		public virtual void OnActionBackoff()
		{
		}

		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 );
		}

		public virtual void ChangeAIType( AIType NewAI )
		{
			if ( m_AI != null )
			{
				m_AI.m_Timer.Stop();
			}

			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_Predator:
					//m_AI = new PredatorAI(this);
					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_AbysmalHorror:
					m_AI = new AbysmalHorrorAI( 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_DemonKnight:
					m_AI = new DemonKnightAI( this );
					break;
				case AIType.AI_Impaler:
					m_AI = new ImpalerAI( this );
					break;
				case AIType.AI_Mephitis:
					m_AI = new MephitisAI( this );
					break;
				case AIType.AI_OrcScout:
					m_AI = new OrcScoutAI( 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 Controled
		{
			get { return m_bControled; }
			set
			{
				if ( m_bControled == value )
				{
					return;
				}

				m_bControled = value;
				Delta( MobileDelta.Noto );

				InvalidateProperties();
			}
		}

		public override void RevealingAction()
		{
			Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

			base.RevealingAction();
		}

		public void RemoveFollowers()
		{
			if ( m_ControlMaster != null )
			{
				m_ControlMaster.Followers -= ControlSlots;
			}
			else if ( m_SummonMaster != null )
			{
				m_SummonMaster.Followers -= ControlSlots;
			}

			if ( m_ControlMaster != null && m_ControlMaster.Followers < 0 )
			{
				m_ControlMaster.Followers = 0;
			}

			if ( m_SummonMaster != null && m_SummonMaster.Followers < 0 )
			{
				m_SummonMaster.Followers = 0;
			}
		}

		public void AddFollowers()
		{
			if ( m_ControlMaster != null )
			{
				m_ControlMaster.Followers += ControlSlots;
			}
			else if ( m_SummonMaster != null )
			{
				m_SummonMaster.Followers += ControlSlots;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile ControlMaster
		{
			get { return m_ControlMaster; }
			set
			{
				if ( m_ControlMaster == value )
				{
					return;
				}

				RemoveFollowers();
				m_ControlMaster = value;
				AddFollowers();

				Delta( MobileDelta.Noto );
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile SummonMaster
		{
			get { return m_SummonMaster; }
			set
			{
				if ( m_SummonMaster == value )
				{
					return;
				}

				RemoveFollowers();
				m_SummonMaster = value;
				AddFollowers();

				Delta( MobileDelta.Noto );
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile ControlTarget { get { return m_ControlTarget; } set { m_ControlTarget = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public Point3D ControlDest { get { return m_ControlDest; } set { m_ControlDest = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public OrderType ControlOrder
		{
			get { return m_ControlOrder; }
			set
			{
				m_ControlOrder = value;

				if ( m_AI != null )
				{
					m_AI.OnCurrentOrderChanged();
				}
			}
		}
		
		[CommandProperty( AccessLevel.GameMaster )]
		public bool Challange { get { return m_Challange; } set { m_Challange = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public bool BardProvoked { get { return m_bBardProvoked; } set { m_bBardProvoked = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public bool BardPacified { get { return m_bBardPacified; } set { m_bBardPacified = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile BardMaster { get { return m_bBardMaster; } set { m_bBardMaster = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile BardTarget { get { return m_bBardTarget; } set { m_bBardTarget = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public DateTime BardEndTime { get { return m_timeBardEnd; } set { m_timeBardEnd = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public double MinTameSkill { get { return m_dMinTameSkill; } set { m_dMinTameSkill = value; } }

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Tamable { get { return m_bTamable && !m_Paragon; } set { m_bTamable = value; } }

		[CommandProperty( AccessLevel.Administrator )]
		public bool Summoned
		{
			get { return m_bSummoned; }
			set
			{
				if ( m_bSummoned == value )
				{
					return;
				}

				m_NextReaquireTime = DateTime.Now;

				m_bSummoned = value;
				Delta( MobileDelta.Noto );

				InvalidateProperties();
			}
		}

		[CommandProperty( AccessLevel.Administrator )]
		public int ControlSlots { get { return m_iControlSlots; } set { m_iControlSlots = value; } }

		public virtual bool NoHouseRestrictions { get { return false; } }

		public virtual bool IsHouseSummonable { get { return false; } }

		public virtual int Feathers { get { return 0; } }

		public virtual int Wool { get { return 0; } }

		public virtual MeatType MeatType { get { return MeatType.Ribs; } }

		public virtual int Meat { get { return 0; } }

		public virtual int Hides { get { return 0; } }

		public virtual HideType HideType { get { return HideType.Regular; } }

		public virtual int Scales { get { return 0; } }

		public virtual ScaleType ScaleType { get { return ScaleType.Red; } }

		public virtual bool AutoDispel { get { return false; } }

		public virtual bool IsScaryToPets { get { return false; } }

		public virtual bool IsScaredOfScaryThings { get { return true; } }

		public virtual bool CanRummageCorpses { get { return false; } }

		public virtual void OnGotMeleeAttack( Mobile attacker )
		{
			if ( AutoDispel && attacker is BaseCreature && ((BaseCreature) attacker).Summoned && !((BaseCreature) attacker).IsAnimatedDead )
			{
				// Creatures with auto-dispel now only have a 10% chance
				// to dispel when hit by a summon, instead of a 100% chance. 
				// Barracoon is excepted from this and maintains his 100% dispel chance.

				double chance = 0.1;

				if ( this is Barracoon )
				{
					chance = 1.0;
				}

				if ( chance >= Utility.RandomDouble() )
				{
					Dispel( attacker );
				}
			}

			try
			{
				PlayerMobile c = attacker as PlayerMobile;

				if ( c != null && c.Location == c.SpotHonor && c.HonorOpponent != null && c.HonorOpponent == this )
				{
					Item item = c.FindItemOnLayer( Layer.TwoHanded );

					if ( item != null && item is BaseRanged )
					{
						c.IsHonorPenalty = true;

						return;
					}
				}

				if ( HonorOpponent != null && HonorOpponent != c )
				{
					return;
				}
			} 
			catch
			{
			}
		}

		public virtual void Dispel( Mobile m )
		{
			Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
			Effects.PlaySound( m, m.Map, 0x201 );

			m.Delete();
		}

		public virtual bool DeleteOnRelease { get { return m_bSummoned; } }

		public virtual void OnGaveMeleeAttack( Mobile defender )
		{
			Poison p = HitPoison;

			if ( m_Paragon )
			{
				p = PoisonImpl.IncreaseLevel( p );
			}

			if ( p != null && HitPoisonChance >= Utility.RandomDouble() )
			{
				defender.ApplyPoison( this, p );
			}

			if ( AutoDispel && defender is BaseCreature && ((BaseCreature) defender).Summoned && !((BaseCreature) defender).IsAnimatedDead )
			{
				Dispel( defender );
			}
		}

		public override void OnAfterDelete()
		{
			if ( m_AI != null )
			{
				if ( m_AI.m_Timer != null )
				{
					m_AI.m_Timer.Stop();
				}

				m_AI = null;
			}

			FocusMob = null;

			if ( IsAnimatedDead )
			{
				Spells.Necromancy.AnimateDeadSpell.Unregister( m_SummonMaster, this );
			}

			base.OnAfterDelete();
		}

		public void DebugSay( string text )
		{
			if ( m_bDebugAI )
			{
				this.PublicOverheadMessage( MessageType.Regular, 41, false, text );
			}
		}

		public void DebugSay( string format, params object[] args )
		{
			if ( m_bDebugAI )
			{
				this.PublicOverheadMessage( MessageType.Regular, 41, false, String.Format( format, args ) );
			}
		}

		/*
		 * Will need to be givent a better name
		 * 
		 * This function can be overriden.. so a "Strongest" mobile, can have a different definition depending
		 * on who check for value
		 * -Could add a FightMode.Prefered
		 * 
		 */

		public virtual double GetValueFrom( Mobile m, FightMode acqType, bool bPlayerOnly )
		{
			if ( (bPlayerOnly && m.Player) || !bPlayerOnly )
			{
				switch ( acqType )
				{
					case FightMode.Strongest:
						return (m.Skills[ SkillName.Tactics ].Value + m.Str); //returns strongest mobile

					case FightMode.Weakest:
						return -m.Hits; // returns weakest mobile

					default:
						return -GetDistanceToSqrt( m ); // returns closest mobile
				}
			}
			else
			{
				return double.MinValue;
			}
		}

		// Turn, - for let, + for right
		// Basic for now, need works
		public virtual void Turn( int iTurnSteps )
		{
			int v = (int) Direction;

			Direction = (Direction) ((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80));
		}

		public virtual void TurnInternal( int iTurnSteps )
		{
			int v = (int) Direction;

			SetDirection( (Direction) ((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80)) );
		}

		public bool IsHurt()
		{
			return (Hits != HitsMax);
		}

		public double GetHomeDistance()
		{
			return GetDistanceToSqrt( m_pHome );
		}

		public virtual int GetTeamSize( int iRange )
		{
			int iCount = 0;

			foreach ( Mobile m in this.GetMobilesInRange( iRange ) )
			{
				if ( m is BaseCreature )
				{
					if ( ((BaseCreature) m).Team == Team )
					{
						if ( !m.Deleted )
						{
							if ( m != this )
							{
								if ( CanSee( m ) )
								{
									iCount++;
								}
							}
						}
					}
				}
			}

			return iCount;
		}

		// Do my combatant is attaking me??
		public bool IsCombatantAnAgressor()
		{
			if ( Combatant != null )
			{
				if ( Combatant.Combatant == this )
				{
					return true;
				}
			}
			return false;
		}

		private class TameEntry : ContextMenuEntry
		{
			private BaseCreature m_Mobile;

			public TameEntry( Mobile from, BaseCreature creature ) : base( 6130, 6 )
			{
				m_Mobile = creature;

				Enabled = Enabled && (from.Female ? creature.AllowFemaleTamer : creature.AllowMaleTamer);
			}

			public override void OnClick()
			{
				if ( !Owner.From.CheckAlive() )
				{
					return;
				}

				Owner.From.TargetLocked = true;
				SkillHandlers.AnimalTaming.DisableMessage = true;

				if ( Owner.From.UseSkill( SkillName.AnimalTaming ) )
				{
					Owner.From.Target.Invoke( Owner.From, m_Mobile );
				}

				SkillHandlers.AnimalTaming.DisableMessage = false;
				Owner.From.TargetLocked = false;
			}
		}

		public virtual bool CanTeach { get { return false; } }

		public virtual bool CheckTeach( SkillName skill, Mobile from )
		{
			if ( !CanTeach )
			{
				return false;
			}

			if ( skill == SkillName.Stealth && from.Skills[ SkillName.Hiding ].Base < 80.0 )
			{
				return false;
			}

			if ( skill == SkillName.RemoveTrap && (from.Skills[ SkillName.Lockpicking ].Base < 50.0 || from.Skills[ SkillName.DetectHidden ].Base < 50.0) )
			{
				return false;
			}

			if ( !Core.AOS && (skill == SkillName.Focus || skill == SkillName.Chivalry || skill == SkillName.Necromancy) )
			{
				return false;
			}

			return true;
		}

		public enum TeachResult
		{
			Success,
			Failure,
			KnowsMoreThanMe,
			KnowsWhatIKnow,
			SkillNotRaisable,
			NotEnoughFreePoints
		}

		public virtual TeachResult CheckTeachSkills( SkillName skill, Mobile m, int maxPointsToLearn, ref int pointsToLearn, bool doTeach )
		{
			if ( !CheckTeach( skill, m ) || !m.CheckAlive() )
			{
				return TeachResult.Failure;
			}

			Skill ourSkill = Skills[ skill ];
			Skill theirSkill = m.Skills[ skill ];

			if ( ourSkill == null || theirSkill == null )
			{
				return TeachResult.Failure;
			}

			int baseToSet = ourSkill.BaseFixedPoint/3;

			if ( baseToSet > 420 )
			{
				baseToSet = 420;
			}
			else if ( baseToSet < 200 )
			{
				return TeachResult.Failure;
			}

			if ( baseToSet > theirSkill.CapFixedPoint )
			{
				baseToSet = theirSkill.CapFixedPoint;
			}

			pointsToLearn = baseToSet - theirSkill.BaseFixedPoint;

			if ( maxPointsToLearn > 0 && pointsToLearn > maxPointsToLearn )
			{
				pointsToLearn = maxPointsToLearn;
				baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
			}

			if ( pointsToLearn < 0 )
			{
				return TeachResult.KnowsMoreThanMe;
			}

			if ( pointsToLearn == 0 )
			{
				return TeachResult.KnowsWhatIKnow;
			}

			if ( theirSkill.Lock != SkillLock.Up )
			{
				return TeachResult.SkillNotRaisable;
			}

			int freePoints = m.Skills.Cap - m.Skills.Total;
			int freeablePoints = 0;

			if ( freePoints < 0 )
			{
				freePoints = 0;
			}

			for ( int i = 0; (freePoints + freeablePoints) < pointsToLearn && i < m.Skills.Length; ++i )
			{
				Skill sk = m.Skills[ i ];

				if ( sk == theirSkill || sk.Lock != SkillLock.Down )
				{
					continue;
				}

				freeablePoints += sk.BaseFixedPoint;
			}

			if ( (freePoints + freeablePoints) == 0 )
			{
				return TeachResult.NotEnoughFreePoints;
			}

			if ( (freePoints + freeablePoints) < pointsToLearn )
			{
				pointsToLearn = freePoints + freeablePoints;
				baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
			}

			if ( doTeach )
			{
				int need = pointsToLearn - freePoints;

				for ( int i = 0; need > 0 && i < m.Skills.Length; ++i )
				{
					Skill sk = m.Skills[ i ];

					if ( sk == theirSkill || sk.Lock != SkillLock.Down )
					{
						continue;
					}

					if ( sk.BaseFixedPoint < need )
					{
						need -= sk.BaseFixedPoint;
						sk.BaseFixedPoint = 0;
					}
					else
					{
						sk.BaseFixedPoint -= need;
						need = 0;
					}
				}

				/* Sanity check */
				if ( baseToSet > theirSkill.CapFixedPoint || (m.Skills.Total - theirSkill.BaseFixedPoint + baseToSet) > m.Skills.Cap )
				{
					return TeachResult.NotEnoughFreePoints;
				}

				theirSkill.BaseFixedPoint = baseToSet;
			}

			return TeachResult.Success;
		}

		public virtual bool CheckTeachingMatch( Mobile m )
		{
			if ( m_Teaching == (SkillName) (-1) )
			{
				return false;
			}

			if ( m is PlayerMobile )
			{
				return (((PlayerMobile) m).Learning == m_Teaching);
			}

			return true;
		}

		private SkillName m_Teaching = (SkillName) (-1);

		public virtual bool Teach( SkillName skill, Mobile m, int maxPointsToLearn, bool doTeach )
		{
			int pointsToLearn = 0;
			TeachResult res = CheckTeachSkills( skill, m, maxPointsToLearn, ref pointsToLearn, doTeach );

			switch ( res )
			{
				case TeachResult.KnowsMoreThanMe:
					{
						Say( 501508 ); // I cannot teach thee, for thou knowest more than I!
						break;
					}
				case TeachResult.KnowsWhatIKnow:
					{
						Say( 501509 ); // I cannot teach thee, for thou knowest all I can teach!
						break;
					}
				case TeachResult.NotEnoughFreePoints:
				case TeachResult.SkillNotRaisable:
					{
						// Make sure this skill is marked to raise. If you are near the skill cap (700 points) you may need to lose some points in another skill first.
						m.SendLocalizedMessage( 501510, "", 0x22 );
						break;
					}
				case TeachResult.Success:
					{
						if ( doTeach )
						{
							Say( 501539 ); // Let me show thee something of how this is done.
							m.SendLocalizedMessage( 501540 ); // Your skill level increases.

							m_Teaching = (SkillName) (-1);

							if ( m is PlayerMobile )
							{
								((PlayerMobile) m).Learning = (SkillName) (-1);
							}
						}
						else
						{
							// I will teach thee all I know, if paid the amount in full.  The price is:
							Say( 1019077, AffixType.Append, String.Format( " {0}", pointsToLearn ), "" );
							Say( 1043108 ); // For less I shall teach thee less.

							m_Teaching = skill;

							if ( m is PlayerMobile )
							{
								((PlayerMobile) m).Learning = skill;
							}
						}

						return true;
					}
			}

			return false;
		}

		public override void AggressiveAction( Mobile aggressor, bool criminal )
		{
			base.AggressiveAction( aggressor, criminal );

			if ( m_AI != null )
			{
				m_AI.OnAggressiveAction( aggressor );
			}

			PlayerMobile pm = aggressor as PlayerMobile;

			if ( pm != null )
			{
				QuestSystem qs = pm.Quest;

				if ( qs != null )
				{
					qs.OnAttack( this );
				}
			}

			if ( pm != null && pm.HonorOpponent != null && pm.HonorOpponent == this )
			{
				pm.IsHonorPenalty = true;
			}

			StopFlee();

			ForceReaquire();

			OrderType ct = m_ControlOrder;

			if ( aggressor.ChangingCombatant && (m_bControled || m_bSummoned) && (ct == OrderType.Come || ct == OrderType.Stay || ct == OrderType.Stop || ct == OrderType.None || ct == OrderType.Follow) )
			{
				ControlTarget = aggressor;
				ControlOrder = OrderType.Attack;
			}
			else if ( Combatant == null && !m_bBardPacified )
			{
				Warmode = true;
				Combatant = aggressor;
			}
		}

		public override bool OnMoveOver( Mobile m )
		{
			if ( m is BaseCreature && !((BaseCreature) m).Controled )
			{
				return false;
			}

			return base.OnMoveOver( m );
		}

		public virtual void AddCustomContextEntries( Mobile from, ArrayList list )
		{
		}

		public override void GetContextMenuEntries( Mobile from, ArrayList list )
		{
			base.GetContextMenuEntries( from, list );

			if ( m_AI != null && Commandable )
			{
				m_AI.GetContextMenuEntries( from, list );
			}

			if ( m_bTamable && !m_bControled && from.Alive )
			{
				list.Add( new TameEntry( from, this ) );
			}

			AddCustomContextEntries( from, list );

			if ( CanTeach && from.Alive )
			{
				Skills ourSkills = this.Skills;
				Skills theirSkills = from.Skills;

				for ( int i = 0; i < ourSkills.Length && i < theirSkills.Length; ++i )
				{
					Skill skill = ourSkills[ i ];
					Skill theirSkill = theirSkills[ i ];

					if ( skill != null && theirSkill != null && skill.Base >= 60.0 && CheckTeach( skill.SkillName, from ) )
					{
						double toTeach = skill.Base/3.0;

						if ( toTeach > 42.0 )
						{
							toTeach = 42.0;
						}

						list.Add( new TeachEntry( (SkillName) i, this, from, (toTeach > theirSkill.Base) ) );
					}
				}
			}
		}

		public override bool HandlesOnSpeech( Mobile from )
		{
			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null && (speechType.Flags & IHSFlags.OnSpeech) != 0 && from.InRange( this, 3 ) )
			{
				return true;
			}

			return (m_AI != null && m_AI.HandlesOnSpeech( from ) && from.InRange( this, m_iRangePerception ));
		}

		public override void OnSpeech( SpeechEventArgs e )
		{
			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null && speechType.OnSpeech( this, e.Mobile, e.Speech ) )
			{
				e.Handled = true;
			}
			else if ( !e.Handled && m_AI != null && e.Mobile.InRange( this, m_iRangePerception ) )
			{
				m_AI.OnSpeech( e );
			}
		}

		public override bool IsHarmfulCriminal( Mobile target )
		{
			if ( (Controled && target == m_ControlMaster) || (Summoned && target == m_SummonMaster) )
			{
				return false;
			}

			if ( target is BaseCreature && ((BaseCreature) target).InitialInnocent && !((BaseCreature) target).Controled )
			{
				return false;
			}

			if ( target is PlayerMobile && ((PlayerMobile) target).PermaFlags.Count > 0 )
			{
				return false;
			}

			return base.IsHarmfulCriminal( target );
		}

		public override void CriminalAction( bool message )
		{
			base.CriminalAction( message );

			if ( (Controled || Summoned) )
			{
				if ( m_ControlMaster != null && m_ControlMaster.Player )
				{
					m_ControlMaster.CriminalAction( false );
				}
				else if ( m_SummonMaster != null && m_SummonMaster.Player )
				{
					m_SummonMaster.CriminalAction( false );
				}
			}
		}

		public override void DoHarmful( Mobile target, bool indirect )
		{
			base.DoHarmful( target, indirect );

			if ( target == this || target == m_ControlMaster || target == m_SummonMaster || (!Controled && !Summoned) )
			{
				return;
			}

			ArrayList list = this.Aggressors;

			for ( int i = 0; i < list.Count; ++i )
			{
				AggressorInfo ai = (AggressorInfo) list[ i ];

				if ( ai.Attacker == target )
				{
					return;
				}
			}

			list = this.Aggressed;

			for ( int i = 0; i < list.Count; ++i )
			{
				AggressorInfo ai = (AggressorInfo) list[ i ];

				if ( ai.Defender == target )
				{
					if ( m_ControlMaster != null && m_ControlMaster.Player && m_ControlMaster.CanBeHarmful( target, false ) )
					{
						m_ControlMaster.DoHarmful( target, true );
					}
					else if ( m_SummonMaster != null && m_SummonMaster.Player && m_SummonMaster.CanBeHarmful( target, false ) )
					{
						m_SummonMaster.DoHarmful( target, true );
					}

					return;
				}
			}
		}

		private static Mobile m_NoDupeGuards;

		public void ReleaseGuardDupeLock()
		{
			m_NoDupeGuards = null;
		}

		public void ReleaseGuardLock()
		{
			EndAction( typeof( GuardedRegion ) );
		}

		private DateTime m_IdleReleaseTime;

		public virtual bool CheckIdle()
		{
			if ( Combatant != null )
			{
				return false; // in combat.. not idling
			}

			if ( m_IdleReleaseTime > DateTime.MinValue )
			{
				// idling...

				if ( DateTime.Now >= m_IdleReleaseTime )
				{
					m_IdleReleaseTime = DateTime.MinValue;
					return false; // idle is over
				}

				return true; // still idling
			}

			if ( 95 > Utility.Random( 100 ) )
			{
				return false; // not idling, but don't want to enter idle state
			}

			m_IdleReleaseTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 15, 25 ) );

			if ( Body.IsHuman )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0:
						Animate( 5, 5, 1, true, true, 1 );
						break;
					case 1:
						Animate( 6, 5, 1, true, false, 1 );
						break;
				}
			}
			else if ( Body.IsAnimal )
			{
				switch ( Utility.Random( 3 ) )
				{
					case 0:
						Animate( 3, 3, 1, true, false, 1 );
						break;
					case 1:
						Animate( 9, 5, 1, true, false, 1 );
						break;
					case 2:
						Animate( 10, 5, 1, true, false, 1 );
						break;
				}
			}
			else if ( Body.IsMonster )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0:
						Animate( 17, 5, 1, true, false, 1 );
						break;
					case 1:
						Animate( 18, 5, 1, true, false, 1 );
						break;
				}
			}

			PlaySound( GetIdleSound() );
			return true; // entered idle state
		}

		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			base.OnMovement( m, oldLocation );

			if ( ReaquireOnMovement || m_Paragon )
			{
				ForceReaquire();
			}

			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null )
			{
				speechType.OnMovement( this, m, oldLocation );
			}

			/* Begin notice sound */
			if ( (!m.Hidden || m.AccessLevel == AccessLevel.Player) && m.Player && m_FightMode != FightMode.Agressor && m_FightMode != FightMode.None && Combatant == null && !Controled && !Summoned )
			{
				// If this creature defends itself but doesn't actively attack (animal) or
				// doesn't fight at all (vendor) then no notice sounds are played..
				// So, players are only notified of agressive monsters

				// Monsters that are currently fighting are ignored

				// Controled or summoned creatures are ignored

				if ( InRange( m.Location, 18 ) && !InRange( oldLocation, 18 ) )
				{
					if ( Body.IsMonster )
					{
						Animate( 11, 5, 1, true, false, 1 );
					}

					PlaySound( GetAngerSound() );
				}
			}
			/* End notice sound */

			if ( m_NoDupeGuards == m )
			{
				return;
			}

			if ( !Body.IsHuman || Kills >= 5 || AlwaysMurderer || AlwaysAttackable || m.Kills < 5 || !m.InRange( Location, 12 ) || !m.Alive )
			{
				return;
			}

			Region reg = this.Region;

			if ( reg is GuardedRegion )
			{
				GuardedRegion guardedRegion = (GuardedRegion) reg;

				if ( !guardedRegion.IsDisabled() && guardedRegion.IsGuardCandidate( m ) && BeginAction( typeof( GuardedRegion ) ) )
				{
					Say( 1013037 + Utility.Random( 16 ) );
					guardedRegion.CallGuards( this.Location );

					Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), new TimerCallback( ReleaseGuardLock ) );

					m_NoDupeGuards = m;
					Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ReleaseGuardDupeLock ) );
				}
			}
		}


		public void AddSpellAttack( Type type )
		{
			m_arSpellAttack.Add( type );
		}

		public void AddSpellDefense( Type type )
		{
			m_arSpellDefense.Add( type );
		}

		public Spell GetAttackSpellRandom()
		{
			if ( m_arSpellAttack.Count > 0 )
			{
				Type type = (Type) m_arSpellAttack[ Utility.Random( m_arSpellAttack.Count ) ];

				object[] args = {this, null};
				return Activator.CreateInstance( type, args ) as Spell;
			}
			else
			{
				return null;
			}
		}

		public Spell GetDefenseSpellRandom()
		{
			if ( m_arSpellDefense.Count > 0 )
			{
				Type type = (Type) m_arSpellDefense[ Utility.Random( m_arSpellDefense.Count ) ];

				object[] args = {this, null};
				return Activator.CreateInstance( type, args ) as Spell;
			}
			else
			{
				return null;
			}
		}

		public Spell GetSpellSpecific( Type type )
		{
			int i;

			for ( i = 0; i < m_arSpellAttack.Count; i++ )
			{
				if ( m_arSpellAttack[ i ] == type )
				{
					object[] args = {this, null};
					return Activator.CreateInstance( type, args ) as Spell;
				}
			}

			for ( i = 0; i < m_arSpellDefense.Count; i++ )
			{
				if ( m_arSpellDefense[ i ] == type )
				{
					object[] args = {this, null};
					return Activator.CreateInstance( type, args ) as Spell;
				}
			}

			return null;
		}

		public void SetDamage( int val )
		{
			m_DamageMin = val;
			m_DamageMax = val;
		}

		public void SetDamage( int min, int max )
		{
			m_DamageMin = min;
			m_DamageMax = max;
		}

		public void SetHits( int val )
		{
			if ( val < 1000 && !Core.AOS )
			{
				val = (val*100)/60;
			}

			m_HitsMax = val;
			Hits = HitsMax;
		}

		public void SetHits( int min, int max )
		{
			if ( min < 1000 && !Core.AOS )
			{
				min = (min*100)/60;
				max = (max*100)/60;
			}

			m_HitsMax = Utility.RandomMinMax( min, max );
			Hits = HitsMax;
		}

		public void SetStam( int val )
		{
			m_StamMax = val;
			Stam = StamMax;
		}

		public void SetStam( int min, int max )
		{
			m_StamMax = Utility.RandomMinMax( min, max );
			Stam = StamMax;
		}

		public void SetMana( int val )
		{
			m_ManaMax = val;
			Mana = ManaMax;
		}

		public void SetMana( int min, int max )
		{
			m_ManaMax = Utility.RandomMinMax( min, max );
			Mana = ManaMax;
		}

		public void SetStr( int val )
		{
			RawStr = val;
			Hits = HitsMax;
		}

		public void SetStr( int min, int max )
		{
			RawStr = Utility.RandomMinMax( min, max );
			Hits = HitsMax;
		}

		public void SetDex( int val )
		{
			RawDex = val;
			Stam = StamMax;
		}

		public void SetDex( int min, int max )
		{
			RawDex = Utility.RandomMinMax( min, max );
			Stam = StamMax;
		}

		public void SetInt( int val )
		{
			RawInt = val;
			Mana = ManaMax;
		}

		public void SetInt( int min, int max )
		{
			RawInt = Utility.RandomMinMax( min, max );
			Mana = ManaMax;
		}

		public void SetDamageType( ResistanceType type, int min, int max )
		{
			SetDamageType( type, Utility.RandomMinMax( min, max ) );
		}

		public void SetDamageType( ResistanceType type, int val )
		{
			switch ( type )
			{
				case ResistanceType.Physical:
					m_PhysicalDamage = val;
					break;
				case ResistanceType.Fire:
					m_FireDamage = val;
					break;
				case ResistanceType.Cold:
					m_ColdDamage = val;
					break;
				case ResistanceType.Poison:
					m_PoisonDamage = val;
					break;
				case ResistanceType.Energy:
					m_EnergyDamage = val;
					break;
			}
		}

		public void SetResistance( ResistanceType type, int min, int max )
		{
			SetResistance( type, Utility.RandomMinMax( min, max ) );
		}

		public void SetResistance( ResistanceType type, int val )
		{
			switch ( type )
			{
				case ResistanceType.Physical:
					m_PhysicalResistance = val;
					break;
				case ResistanceType.Fire:
					m_FireResistance = val;
					break;
				case ResistanceType.Cold:
					m_ColdResistance = val;
					break;
				case ResistanceType.Poison:
					m_PoisonResistance = val;
					break;
				case ResistanceType.Energy:
					m_EnergyResistance = val;
					break;
			}

			UpdateResistances();
		}

		public void SetSkill( SkillName name, double val )
		{
			Skills[ name ].BaseFixedPoint = (int) (val*10);
		}

		public void SetSkill( SkillName name, double min, double max )
		{
			int minFixed = (int) (min*10);
			int maxFixed = (int) (max*10);

			Skills[ name ].BaseFixedPoint = Utility.RandomMinMax( minFixed, maxFixed );
		}

		public void SetFameLevel( int level )
		{
			switch ( level )
			{
				case 1:
					Fame = Utility.RandomMinMax( 0, 1249 );
					break;
				case 2:
					Fame = Utility.RandomMinMax( 1250, 2499 );
					break;
				case 3:
					Fame = Utility.RandomMinMax( 2500, 4999 );
					break;
				case 4:
					Fame = Utility.RandomMinMax( 5000, 9999 );
					break;
				case 5:
					Fame = Utility.RandomMinMax( 10000, 10000 );
					break;
			}
		}

		public void SetKarmaLevel( int level )
		{
			switch ( level )
			{
				case 0:
					Karma = -Utility.RandomMinMax( 0, 624 );
					break;
				case 1:
					Karma = -Utility.RandomMinMax( 625, 1249 );
					break;
				case 2:
					Karma = -Utility.RandomMinMax( 1250, 2499 );
					break;
				case 3:
					Karma = -Utility.RandomMinMax( 2500, 4999 );
					break;
				case 4:
					Karma = -Utility.RandomMinMax( 5000, 9999 );
					break;
				case 5:
					Karma = -Utility.RandomMinMax( 10000, 10000 );
					break;
			}
		}

		public static void Cap( ref int val, int min, int max )
		{
			if ( val < min )
			{
				val = min;
			}
			else if ( val > max )
			{
				val = max;
			}
		}

		public void PackPotion()
		{
			PackItem( Loot.RandomPotion() );
		}

		public void PackNecroScroll( int index )
		{
			if ( !Core.AOS || 0.05 <= Utility.RandomDouble() )
			{
				return;
			}

			PackItem( Loot.Construct( Loot.NecromancyScrollTypes, index ) );
		}

		public void PackScroll( int minCircle, int maxCircle )
		{
			PackScroll( Utility.RandomMinMax( minCircle, maxCircle ) );
		}

		public void PackScroll( int circle )
		{
			int min = (circle - 1)*8;

			PackItem( Loot.RandomScroll( min, min + 7, SpellbookType.Regular ) );
		}

		public void PackMagicItems( int minLevel, int maxLevel )
		{
			PackMagicItems( minLevel, maxLevel, 0.30, 0.15 );
		}

		public void PackMagicItems( int minLevel, int maxLevel, double armorChance, double weaponChance )
		{
			if ( !PackArmor( minLevel, maxLevel, armorChance ) )
			{
				PackWeapon( minLevel, maxLevel, weaponChance );
			}
		}

		protected bool m_Spawning;
		protected int m_KillersLuck;

		public virtual void GenerateLoot( bool spawning )
		{
			m_Spawning = spawning;

			if ( !spawning )
			{
				m_KillersLuck = LootPack.GetLuckChanceForKiller( this );
			}

			GenerateLoot();

			m_Spawning = false;
			m_KillersLuck = 0;
		}

		public virtual void GenerateLoot()
		{
		}

		public bool CanAdd = true;

		public LootPack IncreaseLoot( LootPack pack )
		{
			LootPack packs = pack;

			if ( pack == LootPack.Poor )
			{
				packs = LootPack.Meager;
			}

			if ( pack == LootPack.Meager )
			{
				packs = LootPack.Average;
			}

			if ( pack == LootPack.Average )
			{
				packs = LootPack.Rich;
			}

			if ( pack == LootPack.Rich )
			{
				packs = LootPack.FilthyRich;
			}

			if ( pack == LootPack.FilthyRich )
			{
				packs = LootPack.UltraRich;
			}

			if ( pack == LootPack.UltraRich )
			{
				packs = LootPack.SuperBoss;
			}

			return packs;
		}

		public virtual void AddLoot( LootPack pack, int amount )
		{
			CanAdd = false;

			for ( int i = 0; i < amount; ++i )
			{
				AddLoot( pack );
			}

			if ( IsParagon )
			{
				AddLoot( IncreaseLoot( pack ) );
			}
		}

		public virtual void AddLoot( LootPack pack )
		{
			if ( Summoned )
			{
				return;
			}

			ArrayList list = GetLootingRights( this.DamageEntries, this.HitsMax );

			Container backpack = Backpack;

			if ( backpack == null )
			{
				backpack = new Backpack();

				backpack.Movable = false;

				AddItem( backpack );
			}

			if ( IsParagon && CanAdd )
			{
				LootPack pack1 = IncreaseLoot( pack );

				pack1.Generate( this, backpack, m_Spawning, m_KillersLuck, list );
			}

			pack.Generate( this, backpack, m_Spawning, m_KillersLuck, list );
		}

		public bool PackArmor( int minLevel, int maxLevel )
		{
			return PackArmor( minLevel, maxLevel, 1.0 );
		}

		public bool PackArmor( int minLevel, int maxLevel, double chance )
		{
			if ( chance <= Utility.RandomDouble() )
			{
				return false;
			}

			Cap( ref minLevel, 0, 5 );
			Cap( ref maxLevel, 0, 5 );

			if ( Core.AOS )
			{
				Map map = this.Map;

				Item item = (map == Map.Tokuno) ? Loot.RandomSEArmorOrShieldOrJewelry() : Loot.RandomArmorOrShieldOrJewelry();

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

				int attributeCount, min, max;
				GetRandomAOSStats( minLevel, maxLevel, out attributeCount, out min, out max );

				if ( item is BaseArmor )
				{
					BaseRunicTool.ApplyAttributesTo( (BaseArmor) item, attributeCount, min, max );
				}
				else if ( item is BaseJewel )
				{
					BaseRunicTool.ApplyAttributesTo( (BaseJewel) item, attributeCount, min, max );
				}

				PackItem( item );
			}
			else
			{
				Map map = this.Map;

				BaseArmor armor = (map == Map.Tokuno) ? Loot.RandomSEArmorOrShield() : Loot.RandomArmorOrShield();

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

				armor.ProtectionLevel = (ArmorProtectionLevel) RandomMinMaxScaled( minLevel, maxLevel );
				armor.Durability = (ArmorDurabilityLevel) RandomMinMaxScaled( minLevel, maxLevel );

				PackItem( armor );
			}

			return true;
		}

		public static void GetRandomAOSStats( int minLevel, int maxLevel, out int attributeCount, out int min, out int max )
		{
			int v = RandomMinMaxScaled( minLevel, maxLevel );

			if ( v >= 5 )
			{
				attributeCount = Utility.RandomMinMax( 2, 6 );
				min = 20;
				max = 70;
			}
			else if ( v == 4 )
			{
				attributeCount = Utility.RandomMinMax( 2, 4 );
				min = 20;
				max = 50;
			}
			else if ( v == 3 )
			{
				attributeCount = Utility.RandomMinMax( 2, 3 );
				min = 20;
				max = 40;
			}
			else if ( v == 2 )
			{
				attributeCount = Utility.RandomMinMax( 1, 2 );
				min = 10;
				max = 30;
			}
			else
			{
				attributeCount = 1;
				min = 10;
				max = 20;
			}
		}

		public static int RandomMinMaxScaled( int min, int max )
		{
			if ( min == max )
			{
				return min;
			}

			if ( min > max )
			{
				int hold = min;
				min = max;
				max = hold;
			}

			/* Example:
			 *    min: 1
			 *    max: 5
			 *  count: 5
			 * 
			 * total = (5*5) + (4*4) + (3*3) + (2*2) + (1*1) = 25 + 16 + 9 + 4 + 1 = 55
			 * 
			 * chance for min+0 : 25/55 : 45.45%
			 * chance for min+1 : 16/55 : 29.09%
			 * chance for min+2 :  9/55 : 16.36%
			 * chance for min+3 :  4/55 :  7.27%
			 * chance for min+4 :  1/55 :  1.81%
			 */

			int count = max - min + 1;
			int total = 0, toAdd = count;

			for ( int i = 0; i < count; ++i, --toAdd )
			{
				total += toAdd*toAdd;
			}

			int rand = Utility.Random( total );
			toAdd = count;

			int val = min;

			for ( int i = 0; i < count; ++i, --toAdd, ++val )
			{
				rand -= toAdd*toAdd;

				if ( rand < 0 )
				{
					break;
				}
			}

			return val;
		}

		public bool PackSlayer()
		{
			return PackSlayer( 0.05 );
		}

		public bool PackSlayer( double chance )
		{
			if ( chance <= Utility.RandomDouble() )
			{
				return false;
			}

			if ( Utility.RandomBool() )
			{
				Map map = this.Map;
				BaseInstrument instrument = (map == Map.Tokuno) ? Loot.RandomSEInstrument() : Loot.RandomInstrument();

				if ( instrument != null )
				{
					instrument.Slayer = SlayerGroup.GetLootSlayerType( GetType() );
					PackItem( instrument );
				}
			}
			else if ( !Core.AOS )
			{
				Map map = this.Map;

				BaseWeapon weapon = (map == Map.Tokuno) ? Loot.RandomSEWeapon() : Loot.RandomWeapon();

				if ( weapon != null )
				{
					weapon.Slayer = SlayerGroup.GetLootSlayerType( GetType() );
					PackItem( weapon );
				}
			}

			return true;
		}

		public bool PackWeapon( int minLevel, int maxLevel )
		{
			return PackWeapon( minLevel, maxLevel, 1.0 );
		}

		public bool PackWeapon( int minLevel, int maxLevel, double chance )
		{
			if ( chance <= Utility.RandomDouble() )
			{
				return false;
			}

			Cap( ref minLevel, 0, 5 );
			Cap( ref maxLevel, 0, 5 );

			if ( Core.AOS )
			{
				Map map = this.Map;

				Item item = (map == Map.Tokuno) ? Loot.RandomSEWeaponOrJewelry() : Loot.RandomWeaponOrJewelry();

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

				int attributeCount, min, max;
				GetRandomAOSStats( minLevel, maxLevel, out attributeCount, out min, out max );

				if ( item is BaseWeapon )
				{
					BaseRunicTool.ApplyAttributesTo( (BaseWeapon) item, attributeCount, min, max );
				}
				else if ( item is BaseJewel )
				{
					BaseRunicTool.ApplyAttributesTo( (BaseJewel) item, attributeCount, min, max );
				}

				PackItem( item );
			}
			else
			{
				Map map = this.Map;

				BaseWeapon weapon = (map == Map.Tokuno) ? Loot.RandomSEWeapon() : Loot.RandomWeapon();

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

				if ( 0.05 > Utility.RandomDouble() )
				{
					weapon.Slayer = SlayerName.Silver;
				}

				weapon.DamageLevel = (WeaponDamageLevel) RandomMinMaxScaled( minLevel, maxLevel );
				weapon.AccuracyLevel = (WeaponAccuracyLevel) RandomMinMaxScaled( minLevel, maxLevel );
				weapon.DurabilityLevel = (WeaponDurabilityLevel) RandomMinMaxScaled( minLevel, maxLevel );

				PackItem( weapon );
			}

			return true;
		}

		public void PackGold( int amount )
		{
			if ( amount > 0 )
			{
				PackItem( new Gold( amount ) );
			}
		}

		public void PackGold( int min, int max )
		{
			PackGold( Utility.RandomMinMax( min, max ) );
		}

		public void PackStatue( int min, int max )
		{
			PackStatue( Utility.RandomMinMax( min, max ) );
		}

		public void PackStatue( int amount )
		{
			for ( int i = 0; i < amount; ++i )
			{
				PackStatue();
			}
		}

		public void PackStatue()
		{
			PackItem( Loot.RandomStatue() );
		}

		public void PackGem()
		{
			PackGem( 1 );
		}

		public void PackGem( int min, int max )
		{
			PackGem( Utility.RandomMinMax( min, max ) );
		}

		public void PackGem( int amount )
		{
			if ( amount <= 0 )
			{
				return;
			}

			Item gem = Loot.RandomGem();

			gem.Amount = amount;

			PackItem( gem );
		}

		public void PackNecroReg( int min, int max )
		{
			PackNecroReg( Utility.RandomMinMax( min, max ) );
		}

		public void PackNecroReg( int amount )
		{
			for ( int i = 0; i < amount; ++i )
			{
				PackNecroReg();
			}
		}

		public void PackNecroReg()
		{
			if ( !Core.AOS )
			{
				return;
			}

			PackItem( Loot.RandomNecromancyReagent() );
		}

		public void PackReg( int min, int max )
		{
			PackReg( Utility.RandomMinMax( min, max ) );
		}

		public void PackReg( int amount )
		{
			if ( amount <= 0 )
			{
				return;
			}

			Item reg = Loot.RandomReagent();

			reg.Amount = amount;

			PackItem( reg );
		}

		public void PackItem( Item item )
		{
			if ( Summoned || item == null )
			{
				if ( item != null )
				{
					item.Delete();
				}

				return;
			}

			Container pack = Backpack;

			if ( pack == null )
			{
				pack = new Backpack();

				pack.Movable = false;

				AddItem( pack );
			}

			if ( !item.Stackable || !pack.TryDropItem( this, item, false ) ) // try stack
			{
				pack.DropItem( item ); // failed, drop it anyway
			}
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( from.AccessLevel >= AccessLevel.GameMaster && !Body.IsHuman )
			{
				Container pack = this.Backpack;

				if ( pack != null )
				{
					pack.DisplayTo( from );
				}
			}

			if ( this.DeathAdderCharmable && from.CanBeHarmful( this, false ) )
			{
				DeathAdder da = Spells.Necromancy.SummonFamiliarSpell.Table[ from ] as DeathAdder;

				if ( da != null && !da.Deleted )
				{
					from.SendAsciiMessage( "You charm the snake.  Select a target to attack." );
					from.Target = new DeathAdderCharmTarget( this );
				}
			}

			base.OnDoubleClick( from );
		}

		private class DeathAdderCharmTarget : Target
		{
			private BaseCreature m_Charmed;

			public DeathAdderCharmTarget( BaseCreature charmed ) : base( -1, false, TargetFlags.Harmful )
			{
				m_Charmed = charmed;
			}

			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( !m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful( m_Charmed, false ) )
				{
					return;
				}

				DeathAdder da = Spells.Necromancy.SummonFamiliarSpell.Table[ from ] as DeathAdder;
				if ( da == null || da.Deleted )
				{
					return;
				}

				Mobile targ = targeted as Mobile;
				if ( targ == null || !from.CanBeHarmful( targ, false ) )
				{
					return;
				}

				from.RevealingAction();
				from.DoHarmful( targ, true );

				m_Charmed.Combatant = targ;

				if ( m_Charmed.AIObject != null )
				{
					m_Charmed.AIObject.Action = ActionType.Combat;
				}
			}
		}

		public override void AddNameProperties( ObjectPropertyList list )
		{
			base.AddNameProperties( list );

			if ( Controled && Commandable )
			{
				if ( Summoned )
				{
					list.Add( 1049646 ); // (summoned)
				}
				else if ( IsBonded )
				{
					list.Add( 1049608 ); // (bonded)
				}

				if ( Controled && !Summoned )
				{
					list.Add( 502006 ); // (tame)
				}
			}
		}

		public override void OnSingleClick( Mobile from )
		{
			if ( Controled && Commandable )
			{
				int number;

				if ( Summoned )
				{
					number = 1049646; // (summoned)
				}
				else if ( IsBonded )
				{
					number = 1049608; // (bonded)
				}
				else
				{
					number = 502006; // (tame)
				}

				PrivateOverheadMessage( MessageType.Regular, 0x3B2, number, from.NetState );
			}

			base.OnSingleClick( from );
		}

		public virtual double TreasureMapChance { get { return TreasureMap.LootChance; } }

		public virtual int TreasureMapLevel { get { return -1; } }

		public bool CheckItem( Item item, Type[] types )
		{
			Type t = item.GetType();

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

				if ( type == t )
				{
					return false;
				}
			}

			return true;
		}

		public override bool OnBeforeDeath()
		{
			int treasureLevel = TreasureMapLevel;

			if ( treasureLevel == 1 && this.Map == Map.Trammel && TreasureMap.IsInHavenIsland( this ) )
			{
				Mobile killer = this.LastKiller;

				if ( killer is BaseCreature )
				{
					killer = ((BaseCreature) killer).GetMaster();
				}

				if ( killer is PlayerMobile && ((PlayerMobile) killer).Young )
				{
					treasureLevel = 0;
				}
			}

			if ( !Summoned && !NoKillAwards && !IsBonded && treasureLevel >= 0 )
			{
				if ( m_Paragon && Paragon.ChestChance > Utility.RandomDouble() )
				{
					PackItem( new ParagonChest( this.Name, treasureLevel ) );
				}
				else if ( (Map == Map.Felucca || Map == Map.Trammel) && TreasureMap.LootChance >= Utility.RandomDouble() )
				{
					PackItem( new TreasureMap( treasureLevel, Map ) );
				}
			}

			if ( !Summoned && !NoKillAwards && !m_HasGeneratedLoot )
			{
				m_HasGeneratedLoot = true;
				GenerateLoot( false );
			}

			if ( !NoKillAwards && Region.Name == "Doom" && !(this is DarkGuardian) )
			{
				int bones = Engines.Quests.Doom.TheSummoningQuest.GetDaemonBonesFor( this );

				if ( bones > 0 )
				{
					PackItem( new DaemonBone( bones ) );
				}
			}

			if ( IsAnimatedDead )
			{
				Effects.SendLocationEffect( Location, Map, 0x3728, 13, 1, 0x461, 4 );
			}

			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null )
			{
				speechType.OnDeath( this );
			}

			return base.OnBeforeDeath();
		}

		public void DivideGold( int amount, ArrayList rights )
		{
			for ( int i = 0; i < rights.Count; i++ )
			{
				DamageStore ds = (DamageStore) rights[ i ];

				Item item = Activator.CreateInstance( typeof( Gold ) ) as Item;

				item.Amount = amount;

				item.Keeper = ds.m_Mobile;

				if ( Corpse != null )
				{
					if ( item.Keeper != null )
					{
						Corpse.DropItem( item );
					}
					else
					{
						item.Keeper = this;
						item.Delete();
					}
				}
			}
		}

		public void DivideItems( Container cont, ArrayList rights )
		{
			ArrayList unstackable_items = new ArrayList();
			ArrayList stackable_items = new ArrayList();

			Item gold = null;

			for ( int i = 0; i < cont.Items.Count; i++ )
			{
				Item item = cont.Items[ i ] as Item;

				if ( item != null && item.Keeper == null )
				{
					if ( item.Stackable )
					{
						if ( item is Gold )
						{
							gold = item;
						}
						else
						{
							stackable_items.Add( item );
						}
					}
					else
					{
						unstackable_items.Add( item );
					}
				}
			}

			int totalItems = unstackable_items.Count;

			int amount = 0;

			for ( int i = 0; i < rights.Count; i++ )
			{
				DamageStore ds = (DamageStore) rights[ i ];

				if ( ds != null )
				{
					amount = (int) (ds.m_DamagePercent*totalItems);
				}

				if ( amount < 1 )
				{
					amount = 1;
				}

				for ( int j = 0; j < unstackable_items.Count; j++ )
				{
					Item unstackable_item = unstackable_items[ j ] as Item;

					if ( unstackable_item != null && unstackable_item.Keeper == null && amount > 0 && totalItems > 0 && amount <= totalItems )
					{
						if ( 0.03 > Utility.RandomDouble() )
						{
							// chance that player can not receive item
							// TODO: chance value verify
							unstackable_item.Keeper = this;
							unstackable_item.Delete();
						}
						else
						{
							unstackable_item.Keeper = ds.m_Mobile;
						}

						amount--;
					}
				}
			}

			totalItems = stackable_items.Count;

			amount = 0;

			for ( int k = 0; k < rights.Count; k++ )
			{
				DamageStore ds = (DamageStore) rights[ k ];

				for ( int l = 0; l < stackable_items.Count; l++ )
				{
					Item stackable_item = stackable_items[ l ] as Item;

					if ( stackable_item != null )
					{
						amount = (int) (stackable_item.Amount/rights.Count);

						if ( amount < 1 )
						{
							amount = 1;
						}

						if ( stackable_item.Keeper == null && amount > 0 && totalItems > 0 && amount <= totalItems )
						{
							Item stack_item = Activator.CreateInstance( stackable_item.GetType() ) as Item;

							stack_item.Amount = amount;

							if ( ds != null )
							{
								stack_item.Keeper = ds.m_Mobile;
							}

							stackable_item.Amount -= amount;

							if ( stackable_item.Amount < 1 )
							{
								stackable_item.Delete();
							}

							if ( Corpse != null )
							{
								Corpse.DropItem( stack_item );
							}
						}
					}
				}
			}

			if ( gold != null )
			{
				amount = 0;

				if ( rights.Count > 0 )
				{
					amount = (int) (gold.Amount/rights.Count);
				}

				if ( amount < 1 )
				{
					amount = 1;
				}

				DivideGold( amount, rights );

				gold.Delete();
			}
		}

		private bool m_NoKillAwards;

		public bool NoKillAwards { get { return m_NoKillAwards; } set { m_NoKillAwards = value; } }

		public int ComputeBonusDamage( ArrayList list, Mobile m )
		{
			int bonus = 0;

			for ( int i = list.Count - 1; i >= 0; --i )
			{
				DamageEntry de = (DamageEntry) list[ i ];

				if ( de.Damager == m || !(de.Damager is BaseCreature) )
				{
					continue;
				}

				BaseCreature bc = (BaseCreature) de.Damager;
				Mobile master = null;

				master = bc.GetMaster();

				if ( master == m )
				{
					bonus += de.DamageGiven;
				}
			}

			return bonus;
		}

		public Mobile GetMaster()
		{
			if ( Controled && ControlMaster != null )
			{
				return ControlMaster;
			}
			else if ( Summoned && SummonMaster != null )
			{
				return SummonMaster;
			}

			return null;
		}

		private class FKEntry
		{
			public Mobile m_Mobile;
			public int m_Damage;

			public FKEntry( Mobile m, int damage )
			{
				m_Mobile = m;
				m_Damage = damage;
			}
		}

		public static ArrayList GetLootingRights( ArrayList damageEntries, int hitsMax )
		{
			ArrayList rights = new ArrayList();

			for ( int i = damageEntries.Count - 1; i >= 0; --i )
			{
				if ( i >= damageEntries.Count )
				{
					continue;
				}

				DamageEntry de = (DamageEntry) damageEntries[ i ];

				if ( de.HasExpired )
				{
					damageEntries.RemoveAt( i );
					continue;
				}

				int damage = de.DamageGiven;

				ArrayList respList = de.Responsible;

				if ( respList != null )
				{
					for ( int j = 0; j < respList.Count; ++j )
					{
						DamageEntry subEntry = (DamageEntry) respList[ j ];
						Mobile master = subEntry.Damager;

						if ( master == null || master.Deleted || !master.Player )
						{
							continue;
						}

						bool needNewSubEntry = true;

						for ( int k = 0; needNewSubEntry && k < rights.Count; ++k )
						{
							DamageStore ds = (DamageStore) rights[ k ];

							if ( ds.m_Mobile == master )
							{
								ds.m_Damage += subEntry.DamageGiven;
								needNewSubEntry = false;
							}
						}

						if ( needNewSubEntry )
						{
							rights.Add( new DamageStore( master, subEntry.DamageGiven ) );
						}

						damage -= subEntry.DamageGiven;
					}
				}

				Mobile m = de.Damager;

				if ( m == null || m.Deleted || !m.Player )
				{
					continue;
				}

				if ( damage <= 0 )
				{
					continue;
				}

				bool needNewEntry = true;

				for ( int j = 0; needNewEntry && j < rights.Count; ++j )
				{
					DamageStore ds = (DamageStore) rights[ j ];

					if ( ds.m_Mobile == m )
					{
						ds.m_Damage += damage;
						needNewEntry = false;
					}
				}

				if ( needNewEntry )
				{
					rights.Add( new DamageStore( m, damage ) );
				}
			}

			if ( rights.Count > 0 )
			{
				if ( rights.Count > 1 )
				{
					rights.Sort();
				}

				int topDamage = ((DamageStore) rights[ 0 ]).m_Damage;
				int minDamage;

				if ( hitsMax >= 3000 )
				{
					minDamage = topDamage/16;
				}
				else if ( hitsMax >= 1000 )
				{
					minDamage = topDamage/8;
				}
				else if ( hitsMax >= 200 )
				{
					minDamage = topDamage/4;
				}
				else
				{
					minDamage = topDamage/2;
				}

				int totalDamage = 0;

				for ( int i = 0; i < rights.Count; ++i )
				{
					DamageStore ds = (DamageStore) rights[ i ];

					totalDamage += ds.m_Damage;
				}

				for ( int i = 0; i < rights.Count; ++i )
				{
					DamageStore ds = (DamageStore) rights[ i ];

					ds.m_HasRight = (ds.m_Damage >= minDamage);

					if ( totalDamage != 0 )
					{
						ds.m_DamagePercent = (double) ((double) ds.m_Damage/(double) totalDamage);
					}
				}
			}

			return rights;
		}

		public virtual void OnKilledBy( Mobile mob )
		{
			if ( m_Paragon && Paragon.CheckArtifactChance( mob, this ) )
			{
				Paragon.GiveArtifactTo( mob );
			}

			if ( TokunoTreasures.Enabled && TokunoTreasures.CheckArtifactChance( mob, this ) )
			{
				TokunoTreasures.GiveArtifactTo( mob );
			}
		}

		public void CalculateTitlesScore( PlayerMobile pm, int m_SpawnLevel, int type )
		{
			double value = pm.ChampionTiers[ type ];

			if ( (m_SpawnLevel >= 1 && m_SpawnLevel <= 2 && value >= 0 && value + m_SpawnLevel < 10) || (m_SpawnLevel >= 3 && m_SpawnLevel <= 4 && value >= 10 && value + m_SpawnLevel < 20) )
			{
				// TODO: verify
				pm.ChampionTiers[ type ] += ((double) m_SpawnLevel/500);
			}
		}

		public override void OnDeath( Container c )
		{
			MeerMage.StopEffect( this, false );

			if ( IsBonded )
			{
				int sound = this.GetDeathSound();

				if ( sound >= 0 )
				{
					Effects.PlaySound( this, this.Map, sound );
				}

				Warmode = false;

				Poison = null;
				Combatant = null;

				Hits = 0;
				Stam = 0;
				Mana = 0;

				IsDeadPet = true;
				ControlTarget = ControlMaster;
				ControlOrder = OrderType.Follow;

				ProcessDeltaQueue();
				SendIncomingPacket();
				SendIncomingPacket();

				ArrayList aggressors = this.Aggressors;

				for ( int i = 0; i < aggressors.Count; ++i )
				{
					AggressorInfo info = (AggressorInfo) aggressors[ i ];

					if ( info.Attacker.Combatant == this )
					{
						info.Attacker.Combatant = null;
					}
				}

				ArrayList aggressed = this.Aggressed;

				for ( int i = 0; i < aggressed.Count; ++i )
				{
					AggressorInfo info = (AggressorInfo) aggressed[ i ];

					if ( info.Defender.Combatant == this )
					{
						info.Defender.Combatant = null;
					}
				}

				Mobile owner = this.ControlMaster;

				if ( owner == null || owner.Deleted || owner.Map != this.Map || !owner.InRange( this, 12 ) || !this.CanSee( owner ) || !this.InLOS( owner ) )
				{
					if ( this.OwnerAbandonTime == DateTime.MinValue )
					{
						this.OwnerAbandonTime = DateTime.Now;
					}
				}
				else
				{
					this.OwnerAbandonTime = DateTime.MinValue;
				}

				CheckStatTimers();
			}
			else
			{
				if ( !Summoned && !m_NoKillAwards )
				{
					int totalFame = Fame/100;
					int totalKarma = -Karma/100;

					ArrayList list = GetLootingRights( this.DamageEntries, this.HitsMax );

					bool givenQuestKill = false;
					bool givenFactionKill = false;

					for ( int i = 0; i < list.Count; ++i )
					{
						DamageStore ds = (DamageStore) list[ i ];

						if ( !ds.m_HasRight )
						{
							continue;
						}

						Titles.AwardFame( ds.m_Mobile, totalFame, true );
						Titles.AwardKarma( ds.m_Mobile, totalKarma, true );

						OnKilledBy( ds.m_Mobile );

						if ( !givenFactionKill )
						{
							givenFactionKill = true;
							Faction.HandleDeath( this, ds.m_Mobile );
						}

						if ( givenQuestKill )
						{
							continue;
						}

						PlayerMobile pm = ds.m_Mobile as PlayerMobile;

						if ( pm != null )
						{
							QuestSystem qs = pm.Quest;

							if ( qs != null )
							{
								qs.OnKill( this, c );
								givenQuestKill = true;
							}

							if ( pm.HonorOpponent != null && pm.HonorOpponent == this && HonorOpponent != null && HonorOpponent == pm )
							{
								double points = (double) (Fame/4000);

								if ( pm.IsHonorPenalty )
								{
									points /= 2.0;
								}

								int p = (int) Math.Round( points );

								bool gainedPath = false;

								if ( VirtueHelper.Award( pm, VirtueName.Honor, p, ref gainedPath ) )
								{
									if ( gainedPath )
									{
										pm.SendLocalizedMessage( 1063226 ); // You have gained a path in Honor!
									} 
									else
									{
										pm.SendLocalizedMessage( 1063225 ); // You have gained in Honor.
									} 
								}
							}

							if ( IsChampionMonster )
							{
								#region Valor
								int level = pm.Virtues.GetValue( (int) VirtueName.Valor );

								if ( level >= 0 && level <= 19 )
								{
									m_Valor_Award_Per_Monster = 0.1; // seekers have 1 valor point for 10 kills
								} 
								else if ( level >= 20 && level <= 29 )
								{
									m_Valor_Award_Per_Monster = 0.0666666; // followers have 1 valor point for 15 kills
								} 
								else if ( level >= 30 )
								{
									m_Valor_Award_Per_Monster = 0.04; // knights have 1 valor point for 25 kills
								} 

								pm.ValorGain += m_Valor_Award_Per_Monster;

								pm.SendLocalizedMessage( 1054030 ); // You have gained in Valor!						    

								if ( pm.ValorGain >= 1 )
								{
									pm.ValorGain -= 1;

									bool path = false;

									VirtueHelper.Award( pm, VirtueName.Valor, 1, ref path );
								}
								#endregion 

								#region Champion Monster Titles
								int type = -1;

								switch ( m_ChampionType )
								{
									case ChampionSpawnType.ColdBlood:
										type = 0;
										break;
									case ChampionSpawnType.ForestLord:
										type = 1;
										break;
									case ChampionSpawnType.Arachnid:
										type = 2;
										break;
									case ChampionSpawnType.Abyss:
										type = 3;
										break;
									case ChampionSpawnType.VerminHorde:
										type = 4;
										break;
									case ChampionSpawnType.UnholyTerror:
										type = 5;
										break;
									case ChampionSpawnType.SleepingDragon:
										type = 6;
										break;
								}

								CalculateTitlesScore( pm, m_SpawnLevel, type );
								#endregion
							}
						}
					}
				}

				base.OnDeath( c );

				if ( DeleteCorpseOnDeath )
				{
					c.Delete();
				}
			}

			try
			{
				ArrayList rights = GetLootingRights( this.DamageEntries, this.HitsMax );

				if ( Corpse != null )
				{
					DivideItems( Corpse, rights );

					for ( int i = 0; i < Corpse.Items.Count; i++ )
					{
						Item item = Corpse.Items[ i ] as Item;

						DamageStore ds = rights[ 0 ] as DamageStore;

						if ( item != null && item.Keeper == null && ds != null )
						{
							item.Keeper = ds.m_Mobile;
						}
					}

					KeeperTimer timer = new KeeperTimer( Corpse );

					timer.Start();
				}
			} 
			catch
			{
			}
		}

		public class KeeperTimer : Timer
		{
			public Container m_Cont;

			public KeeperTimer( Container cont ) : base( TimeSpan.FromMinutes( 3.0 ) )
			{
				m_Cont = cont;
			}

			protected override void OnTick()
			{
				if ( m_Cont != null )
				{
					for ( int i = 0; i < m_Cont.Items.Count; i++ )
					{
						Item item = m_Cont.Items[ i ] as Item;

						if ( item != null && item.Keeper != null )
						{
							item.Keeper = null;
						}
					}
				}
			}
		}

		/* To save on cpu usage, RunUO creatures only reaquire creatures under the following circumstances:
		 *  - 10 seconds have elapsed since the last time it tried
		 *  - The creature was attacked
		 *  - Some creatures, like dragons, will reaquire when they see someone move
		 * 
		 * This functionality appears to be implemented on OSI as well
		 */

		private DateTime m_NextReaquireTime;

		public DateTime NextReaquireTime { get { return m_NextReaquireTime; } set { m_NextReaquireTime = value; } }

		public virtual TimeSpan ReaquireDelay { get { return TimeSpan.FromSeconds( 10.0 ); } }

		public virtual bool ReaquireOnMovement { get { return false; } }

		public void ForceReaquire()
		{
			m_NextReaquireTime = DateTime.MinValue;
		}

		public override void OnDelete()
		{
			SetControlMaster( null );
			SummonMaster = null;

			base.OnDelete();
		}

		public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )
		{
			if ( target is BaseFactionGuard )
			{
				return false;
			}

			if ( (target is BaseVendor && ((BaseVendor) target).IsInvulnerable) || target is PlayerVendor || target is TownCrier )
			{
				if ( message )
				{
					if ( target.Title == null )
					{
						SendMessage( "{0} the vendor cannot be harmed.", target.Name );
					}
					else
					{
						SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title );
					}
				}

				return false;
			}

			return base.CanBeHarmful( target, message, ignoreOurBlessedness );
		}

		public override bool CanBeRenamedBy( Mobile from )
		{
			bool ret = base.CanBeRenamedBy( from );

			if ( Controled && from == ControlMaster )
			{
				ret = true;
			}

			return ret;
		}

		public bool SetControlMaster( Mobile m )
		{
			if ( m == null )
			{
				ControlMaster = null;
				Controled = false;
				ControlTarget = null;
				ControlOrder = OrderType.None;
				Guild = null;

				Delta( MobileDelta.Noto );
			}
			else
			{
				if ( m.Followers + ControlSlots > m.FollowersMax )
				{
					m.SendLocalizedMessage( 1049607 ); // You have too many followers to control that creature.
					return false;
				}

				CurrentWayPoint = null; //so tamed animals don't try to go back

				ControlMaster = m;
				Controled = true;
				ControlTarget = null;
				ControlOrder = OrderType.Come;
				Guild = null;

				Delta( MobileDelta.Noto );
			}

			return true;
		}

		private static bool m_Summoning;

		public static bool Summoning { get { return m_Summoning; } set { m_Summoning = value; } }

		public static bool Summon( BaseCreature creature, Mobile caster, Point3D p, int sound, TimeSpan duration )
		{
			return Summon( creature, true, caster, p, sound, duration );
		}

		public static bool Summon( BaseCreature creature, bool controled, Mobile caster, Point3D p, int sound, TimeSpan duration )
		{
			if ( caster.Followers + creature.ControlSlots > caster.FollowersMax )
			{
				caster.SendLocalizedMessage( 1049645 ); // You have too many followers to summon that creature.
				creature.Delete();
				return false;
			}

			m_Summoning = true;

			if ( controled )
			{
				creature.SetControlMaster( caster );
			}

			creature.RangeHome = 10;
			creature.Summoned = true;

			creature.SummonMaster = caster;

			Container pack = creature.Backpack;

			if ( pack != null )
			{
				for ( int i = pack.Items.Count - 1; i >= 0; --i )
				{
					if ( i >= pack.Items.Count )
					{
						continue;
					}

					((Item) pack.Items[ i ]).Delete();
				}
			}

			new UnsummonTimer( caster, creature, duration ).Start();
			creature.m_SummonEnd = DateTime.Now + duration;

			creature.MoveToWorld( p, caster.Map );

			Effects.PlaySound( p, creature.Map, sound );

			if ( creature is EnergyVortex || creature is BladeSpirits )
			{
				SpellHelper.CheckSummonLimits( creature );
			}

			m_Summoning = false;

			return true;
		}

		private static bool EnableRummaging = true;

		private const double ChanceToRummage = 0.5; // 50%

		private const double MinutesToNextRummageMin = 1.0;
		private const double MinutesToNextRummageMax = 4.0;

		private const double MinutesToNextChanceMin = 0.25;
		private const double MinutesToNextChanceMax = 0.75;

		private DateTime m_NextRummageTime;

		public virtual void OnThink()
		{
			if ( EnableRummaging && CanRummageCorpses && !Summoned && !Controled && DateTime.Now >= m_NextRummageTime )
			{
				double min, max;

				if ( ChanceToRummage > Utility.RandomDouble() && Rummage() )
				{
					min = MinutesToNextRummageMin;
					max = MinutesToNextRummageMax;
				}
				else
				{
					min = MinutesToNextChanceMin;
					max = MinutesToNextChanceMax;
				}

				double delay = min + (Utility.RandomDouble()*(max - min));
				m_NextRummageTime = DateTime.Now + TimeSpan.FromMinutes( delay );
			}

			if ( HasBreath && !Summoned && DateTime.Now >= m_NextBreathTime ) // tested: controled dragons do breath fire, what about summoned skeletal dragons?
			{
				Mobile target = this.Combatant;

				if ( target != null && target.Alive && !target.IsDeadBondedPet && CanBeHarmful( target ) && target.Map == this.Map && !IsDeadBondedPet && target.InRange( this, BreathRange ) && InLOS( target ) && !BardPacified )
				{
					BreathStart( target );
				}

				m_NextBreathTime = DateTime.Now + TimeSpan.FromSeconds( BreathMinDelay + (Utility.RandomDouble()*BreathMaxDelay) );
			}
		}

		public virtual bool Rummage()
		{
			Corpse toRummage = null;

			foreach ( Item item in this.GetItemsInRange( 2 ) )
			{
				if ( item is Corpse && item.Items.Count > 0 )
				{
					toRummage = (Corpse) item;
					break;
				}
			}

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

			Container pack = this.Backpack;

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

			ArrayList items = toRummage.Items;

			bool rejected;
			LRReason reason;

			for ( int i = 0; i < items.Count; ++i )
			{
				Item item = (Item) items[ Utility.Random( items.Count ) ];

				Lift( item, item.Amount, out rejected, out reason );

				if ( !rejected && Drop( this, new Point3D( -1, -1, 0 ) ) )
				{
					if ( toRummage.Owner != null && toRummage.Owner.Player )
					{
						item.Keeper = toRummage.Owner;
					}

					// *rummages through a corpse and takes an item*
					PublicOverheadMessage( MessageType.Emote, 0x3B2, 1008086 );
					return true;
				}
			}

			return false;
		}

		public void Pacify( Mobile master, DateTime endtime )
		{
			BardPacified = true;
			BardEndTime = endtime;
		}

		public override Mobile GetDamageMaster( Mobile damagee )
		{
			if ( m_bBardProvoked && damagee == m_bBardTarget )
			{
				return m_bBardMaster;
			}
			else if ( m_bControled && m_ControlMaster != null )
			{
				return m_ControlMaster;
			}
			else if ( m_bSummoned && m_SummonMaster != null )
			{
				return m_SummonMaster;
			}

			return base.GetDamageMaster( damagee );
		}

		public void Provoke( Mobile master, Mobile target, bool bSuccess )
		{
			BardProvoked = true;

			this.PublicOverheadMessage( MessageType.Emote, EmoteHue, false, "*looks furious*" );

			if ( bSuccess )
			{
				PlaySound( GetIdleSound() );

				BardMaster = master;
				BardTarget = target;
				Combatant = target;
				BardEndTime = DateTime.Now + TimeSpan.FromSeconds( 30.0 );

				if ( target is BaseCreature )
				{
					BaseCreature t = (BaseCreature) target;

					t.BardProvoked = true;

					t.BardMaster = master;
					t.BardTarget = this;
					t.Combatant = this;
					t.BardEndTime = DateTime.Now + TimeSpan.FromSeconds( 30.0 );
				}
			}
			else
			{
				PlaySound( GetAngerSound() );

				BardMaster = master;
				BardTarget = target;
			}
		}

		public bool FindMyName( string str, bool bWithAll )
		{
			int i, j;

			string name = this.Name;

			if ( name == null || str.Length < name.Length )
			{
				return false;
			}

			string[] wordsString = str.Split( ' ' );
			string[] wordsName = name.Split( ' ' );

			for ( j = 0; j < wordsName.Length; j++ )
			{
				string wordName = wordsName[ j ];

				bool bFound = false;
				for ( i = 0; i < wordsString.Length; i++ )
				{
					string word = wordsString[ i ];

					if ( Insensitive.Equals( word, wordName ) )
					{
						bFound = true;
					}

					if ( bWithAll && Insensitive.Equals( word, "all" ) )
					{
						return true;
					}
				}

				if ( !bFound )
				{
					return false;
				}
			}

			return true;
		}

		public static void TeleportPets( Mobile master, Point3D loc, Map map )
		{
			TeleportPets( master, loc, map, false );
		}

		public static void TeleportPets( Mobile master, Point3D loc, Map map, bool onlyBonded )
		{
			ArrayList move = new ArrayList();

			foreach ( Mobile m in master.GetMobilesInRange( 3 ) )
			{
				if ( m is BaseCreature )
				{
					BaseCreature pet = (BaseCreature) m;

					if ( pet is Clone && ((Clone) pet).Owner == master )
					{
						move.Add( pet );
					}

					if ( pet.Controled && pet.ControlMaster == master )
					{
						if ( !onlyBonded || pet.IsBonded )
						{
							if ( pet.ControlOrder == OrderType.Guard || pet.ControlOrder == OrderType.Follow || pet.ControlOrder == OrderType.Come )
							{
								move.Add( pet );
							}
						}
					}
				}
			}

			foreach ( Mobile m in move )
			{
				m.MoveToWorld( loc, map );
			}
		}

		public virtual void ResurrectPet()
		{
			if ( !IsDeadPet )
			{
				return;
			}

			OnBeforeResurrect();

			Poison = null;

			Warmode = false;

			Hits = 10;
			Stam = StamMax;
			Mana = 0;

			ProcessDeltaQueue();

			IsDeadPet = false;

			Effects.SendPacket( Location, Map, new BondedStatus( 0, this.Serial, 0 ) );

			this.SendIncomingPacket();
			this.SendIncomingPacket();

			OnAfterResurrect();

			Mobile owner = this.ControlMaster;

			if ( owner == null || owner.Deleted || owner.Map != this.Map || !owner.InRange( this, 12 ) || !this.CanSee( owner ) || !this.InLOS( owner ) )
			{
				if ( this.OwnerAbandonTime == DateTime.MinValue )
				{
					this.OwnerAbandonTime = DateTime.Now;
				}
			}
			else
			{
				this.OwnerAbandonTime = DateTime.MinValue;
			}

			CheckStatTimers();
		}

		public override bool CanBeDamaged()
		{
			if ( IsDeadPet )
			{
				return false;
			}

			return base.CanBeDamaged();
		}

		public virtual bool PlayerRangeSensitive { get { return true; } }

		public override void OnSectorDeactivate()
		{
			if ( PlayerRangeSensitive && m_AI != null && !Controled )
			{
				m_AI.Deactivate();
			}

			base.OnSectorDeactivate();
		}

		public override void OnSectorActivate()
		{
			if ( PlayerRangeSensitive && m_AI != null && !Controled )
			{
				m_AI.Activate();
			}

			base.OnSectorActivate();
		}

		// used for deleting creatures in houses
		private int m_RemoveStep;

		[CommandProperty( AccessLevel.GameMaster )]
		public int RemoveStep { get { return m_RemoveStep; } set { m_RemoveStep = value; } }
	}

	public class LoyaltyTimer : Timer
	{
		private static TimeSpan InternalDelay = TimeSpan.FromMinutes( 5.0 );

		public static void Initialize()
		{
			new LoyaltyTimer().Start();
		}

		public LoyaltyTimer() : base( InternalDelay, InternalDelay )
		{
			m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours( 1.0 );
			Priority = TimerPriority.FiveSeconds;
		}

		private DateTime m_NextHourlyCheck;

		protected override void OnTick()
		{
			bool hasHourElapsed = (DateTime.Now >= m_NextHourlyCheck);

			if ( hasHourElapsed )
			{
				m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours( 1.0 );
			}

			ArrayList toRelease = new ArrayList();

			// added array for wild creatures in house regions to be removed
			ArrayList toRemove = new ArrayList();

			foreach ( Mobile m in World.Mobiles.Values )
			{
				if ( m is BaseMount && ((BaseMount) m).Rider != null )
				{
					((BaseCreature) m).OwnerAbandonTime = DateTime.MinValue;
					continue;
				}

				if ( m is BaseCreature )
				{
					BaseCreature c = (BaseCreature) m;

					if ( c.IsDeadPet )
					{
						Mobile owner = c.ControlMaster;

						if ( owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange( c, 12 ) || !c.CanSee( owner ) || !c.InLOS( owner ) )
						{
							if ( c.OwnerAbandonTime == DateTime.MinValue )
							{
								c.OwnerAbandonTime = DateTime.Now;
							}
							else if ( (c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.Now )
							{
								toRemove.Add( c );
							}
						}
						else
						{
							c.OwnerAbandonTime = DateTime.MinValue;
						}
					}
					else if ( c.Controled && c.Commandable && c.Loyalty > PetLoyalty.None && c.Map != Map.Internal )
					{
						Mobile owner = c.ControlMaster;

						// changed loyalty decrement
						if ( hasHourElapsed )
						{
							--c.Loyalty;

							if ( c.Loyalty == PetLoyalty.Confused )
							{
								c.Say( 1043270, c.Name ); // * ~1_NAME~ looks around desperately *
								c.PlaySound( c.GetIdleSound() );
							}
						}

						c.OwnerAbandonTime = DateTime.MinValue;

						if ( c.Loyalty == PetLoyalty.None )
						{
							toRelease.Add( c );
						}
					}

					// added lines to check if a wild creature in a house region has to be removed or not
					if ( !c.Controled && c.Region is HouseRegion && c.CanBeDamaged() )
					{
						c.RemoveStep++;

						if ( c.RemoveStep >= 20 )
						{
							toRemove.Add( c );
						}
					}
					else
					{
						c.RemoveStep = 0;
					}
				}
			}

			foreach ( BaseCreature c in toRelease )
			{
				c.Say( 1043255, c.Name ); // ~1_NAME~ appears to have decided that is better off without a master!
				c.Loyalty = PetLoyalty.WonderfullyHappy;
				c.IsBonded = false;
				c.BondingBegin = DateTime.MinValue;
				c.OwnerAbandonTime = DateTime.MinValue;
				c.ControlTarget = null;
				//c.ControlOrder = OrderType.Release;
				c.AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers)
			}

			// added code to handle removing of wild creatures in house regions
			foreach ( BaseCreature c in toRemove )
			{
				c.Delete();
			}
		}
	}
}
 

Jeff

Lord
prolly part of it is cause of this under attrib
Code:
public void attrib(Mobile who)
			{

				 PlayerMobile m = who as PlayerMobile;

if its a mobile and not a player, it cant be a player
 

noob2

Wanderer
yeh i tried messing with that making the PlayerMobiles into Mobiles in the script don't work doesn't seem to work
 

Jeff

Lord
noob2 said:
yeh i tried messing with that making the PlayerMobiles into Mobiles in the script don't work doesn't seem to work
it will work, but not the other way around if the mobile is not a player.
 

erni23

Wanderer
public void attrib(Mobile who)
{

PlayerMobile m = who as PlayerMobile;


where add it ? i change playermobile.cs exacly like in readme.txt but dont work:(
dont have any compile errors but when write i challenge thee nothing happend:(
sorry for my english:)
 

noob2

Wanderer
erni23 said:
public void attrib(Mobile who)
{

PlayerMobile m = who as PlayerMobile;


where add it ? i change playermobile.cs exacly like in readme.txt but dont work:(
dont have any compile errors but when write i challenge thee nothing happend:(
sorry for my english:)


You need to add a challenge stone and props it make an arena and then you can set it as a 1vs1 or 2vs2 arena then it will work

as far as i know you can make an arena in any facet but i suggest making it in felucca in green acres i'll post an arena addon for you guys
 
Code:
RunUO - [www.runuo.com] Version 2.0, Build 2357.32527
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (2 errors, 0 warnings)
Errors:
 + Customs/My shit/Challenge Game 1.1.1/ChallengeStone.cs:
    CS0234: Line 4: The type or namespace name 'Scripts' does not exist in the n
amespace 'Server' (are you missing an assembly reference?)
    CS0246: Line 79: The type or namespace name 'CommandEventArgs' could not be
found (are you missing a using directive or an assembly reference?)
 + Customs/My shit/PlayerMobile.cs:
    CS0102: Line 104: The type 'Server.Mobiles.PlayerMobile' already contains a
definition for 'm_Profession'
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.


Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Misc;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Engines.Help;
using Server.ContextMenus;
using Server.Network;
using Server.Spells;
using Server.Spells.Fifth;
using Server.Spells.Sixth;
using Server.Spells.Seventh;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Bushido;
using Server.Targeting;
using Server.Engines.Quests;
using Server.Factions;
using Server.Regions;
using Server.Accounting;
using Server.Engines.CannedEvil;
using Server.Engines.Craft;

namespace Server.Mobiles
{
	#region Enums
	[Flags]
	public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
	{
		None				= 0x00000000,
		Glassblowing		= 0x00000001,
		Masonry				= 0x00000002,
		SandMining			= 0x00000004,
		StoneMining			= 0x00000008,
		ToggleMiningStone	= 0x00000010,
		KarmaLocked			= 0x00000020,
		AutoRenewInsurance	= 0x00000040,
		UseOwnFilter		= 0x00000080,
		PublicMyRunUO		= 0x00000100,
		PagingSquelched		= 0x00000200,
		Young				= 0x00000400,
		AcceptGuildInvites	= 0x00000800,
		DisplayChampionTitle= 0x00001000,
		isinchal		= 0x00100001,
		canbechal		= 0x00100002,
		TempMount		= 0x00100003
	}

	public enum NpcGuild
	{
		None,
		MagesGuild,
		WarriorsGuild,
		ThievesGuild,
		RangersGuild,
		HealersGuild,
		MinersGuild,
		MerchantsGuild,
		TinkersGuild,
		TailorsGuild,
		FishermensGuild,
		BardsGuild,
		BlacksmithsGuild
	}

	public enum SolenFriendship
	{
		None,
		Red,
		Black
	}
	#endregion

	public class PlayerMobile : Mobile, IHonorTarget
	{
		private class CountAndTimeStamp
		{
			private int m_Count;
			private DateTime m_Stamp;

			public CountAndTimeStamp()
			{
			}

			public DateTime TimeStamp { get{ return m_Stamp; } }
			public int Count 
			{ 
				get { return m_Count; } 
				set	{ m_Count = value; m_Stamp = DateTime.Now; } 
			}
		}

		private DesignContext m_DesignContext;

		private NpcGuild m_NpcGuild;
		private DateTime m_NpcGuildJoinTime;
		private TimeSpan m_NpcGuildGameTime;
		private PlayerFlag m_Flags;
		private int m_StepsTaken;
		private int m_Profession;
private int m_Profession;
		private bool isinchal = false;
		private bool canbechal = true;
		private BaseMount m_TempMount;
		
		[CommandProperty( AccessLevel.GameMaster ) ]
		public BaseMount TempMount
		{
			get { return m_TempMount; }
			set { m_TempMount = value; }
		}
		
		[CommandProperty(AccessLevel.Counselor)]
		public bool IsInChallenge
		{
			get{return isinchal;}
			set{isinchal = value;}
		}
		
		[CommandProperty(AccessLevel.Counselor)]
		public bool CanBeChallenged
		{
			get{return canbechal;}
			set{canbechal = value;}
		}

		private DateTime m_LastOnline;
		private Server.Guilds.RankDefinition m_GuildRank;

		private int m_GuildMessageHue, m_AllianceMessageHue;

		[CommandProperty( AccessLevel.Counselor, AccessLevel.Owner )]
		public new Account Account
		{
			get { return base.Account as Account; }
			set { base.Account = value; }
		}

		#region Getters & Setters
		public Server.Guilds.RankDefinition GuildRank
		{
			get
			{
				if( this.AccessLevel >= AccessLevel.GameMaster )
					return Server.Guilds.RankDefinition.Leader;
				else
					return m_GuildRank; 
			}
			set{ m_GuildRank = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int GuildMessageHue
		{
			get{ return m_GuildMessageHue; }
			set{ m_GuildMessageHue = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int AllianceMessageHue
		{
			get { return m_AllianceMessageHue; }
			set { m_AllianceMessageHue = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int Profession
		{
			get{ return m_Profession; }
			set{ m_Profession = value; }
		}

		public int StepsTaken
		{
			get{ return m_StepsTaken; }
			set{ m_StepsTaken = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public NpcGuild NpcGuild
		{
			get{ return m_NpcGuild; }
			set{ m_NpcGuild = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public DateTime NpcGuildJoinTime
		{
			get{ return m_NpcGuildJoinTime; }
			set{ m_NpcGuildJoinTime = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public DateTime LastOnline
		{
			get{ return m_LastOnline; }
			set{ m_LastOnline = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public TimeSpan NpcGuildGameTime
		{
			get{ return m_NpcGuildGameTime; }
			set{ m_NpcGuildGameTime = value; }
		}

		private int m_ToTItemsTurnedIn;

		[CommandProperty( AccessLevel.GameMaster )]
		public int ToTItemsTurnedIn
		{
			get { return m_ToTItemsTurnedIn; }
			set { m_ToTItemsTurnedIn = value; }
		}

		private int m_ToTTotalMonsterFame;

		[CommandProperty( AccessLevel.GameMaster )]
		public int ToTTotalMonsterFame
		{
			get { return m_ToTTotalMonsterFame; }
			set { m_ToTTotalMonsterFame = value; }
		}

		#endregion

		#region PlayerFlags
		public PlayerFlag Flags
		{
			get{ return m_Flags; }
			set{ m_Flags = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool PagingSquelched
		{
			get{ return GetFlag( PlayerFlag.PagingSquelched ); }
			set{ SetFlag( PlayerFlag.PagingSquelched, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Glassblowing
		{
			get{ return GetFlag( PlayerFlag.Glassblowing ); }
			set{ SetFlag( PlayerFlag.Glassblowing, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Masonry
		{
			get{ return GetFlag( PlayerFlag.Masonry ); }
			set{ SetFlag( PlayerFlag.Masonry, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool SandMining
		{
			get{ return GetFlag( PlayerFlag.SandMining ); }
			set{ SetFlag( PlayerFlag.SandMining, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool StoneMining
		{
			get{ return GetFlag( PlayerFlag.StoneMining ); }
			set{ SetFlag( PlayerFlag.StoneMining, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool ToggleMiningStone
		{
			get{ return GetFlag( PlayerFlag.ToggleMiningStone ); }
			set{ SetFlag( PlayerFlag.ToggleMiningStone, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool KarmaLocked
		{
			get{ return GetFlag( PlayerFlag.KarmaLocked ); }
			set{ SetFlag( PlayerFlag.KarmaLocked, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool AutoRenewInsurance
		{
			get{ return GetFlag( PlayerFlag.AutoRenewInsurance ); }
			set{ SetFlag( PlayerFlag.AutoRenewInsurance, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool UseOwnFilter
		{
			get{ return GetFlag( PlayerFlag.UseOwnFilter ); }
			set{ SetFlag( PlayerFlag.UseOwnFilter, value ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool PublicMyRunUO
		{
			get{ return GetFlag( PlayerFlag.PublicMyRunUO ); }
			set{ SetFlag( PlayerFlag.PublicMyRunUO, value ); InvalidateMyRunUO(); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool AcceptGuildInvites
		{
			get{ return GetFlag( PlayerFlag.AcceptGuildInvites ); }
			set{ SetFlag( PlayerFlag.AcceptGuildInvites, value ); }
		}
		#endregion


		public static Direction GetDirection4( Point3D from, Point3D to )
		{
			int dx = from.X - to.X;
			int dy = from.Y - to.Y;

			int rx = dx - dy;
			int ry = dx + dy;

			Direction ret;

			if ( rx >= 0 && ry >= 0 )
				ret = Direction.West;
			else if ( rx >= 0 && ry < 0 )
				ret = Direction.South;
			else if ( rx < 0 && ry < 0 )
				ret = Direction.East;
			else
				ret = Direction.North;

			return ret;
		}

		public override bool OnDroppedItemToWorld( Item item, Point3D location )
		{
			if ( !base.OnDroppedItemToWorld( item, location ) )
				return false;

			BounceInfo bi = item.GetBounce();

			if ( bi != null )
			{
				Type type = item.GetType();

				if ( type.IsDefined( typeof( FurnitureAttribute ), true ) || type.IsDefined( typeof( DynamicFlipingAttribute ), true ) )
				{
					object[] objs = type.GetCustomAttributes( typeof( FlipableAttribute ), true );

					if ( objs != null && objs.Length > 0 )
					{
						FlipableAttribute fp = objs[0] as FlipableAttribute;

						if ( fp != null )
						{
							int[] itemIDs = fp.ItemIDs;

							Point3D oldWorldLoc = bi.m_WorldLoc;
							Point3D newWorldLoc = location;

							if ( oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y )
							{
								Direction dir = GetDirection4( oldWorldLoc, newWorldLoc );

								if ( itemIDs.Length == 2 )
								{
									switch ( dir )
									{
										case Direction.North:
										case Direction.South: item.ItemID = itemIDs[0]; break;
										case Direction.East:
										case Direction.West: item.ItemID = itemIDs[1]; break;
									}
								}
								else if ( itemIDs.Length == 4 )
								{
									switch ( dir )
									{
										case Direction.South: item.ItemID = itemIDs[0]; break;
										case Direction.East: item.ItemID = itemIDs[1]; break;
										case Direction.North: item.ItemID = itemIDs[2]; break;
										case Direction.West: item.ItemID = itemIDs[3]; break;
									}
								}
							}
						}
					}
				}
			}

			return true;
		}

		public bool GetFlag( PlayerFlag flag )
		{
			return ( (m_Flags & flag) != 0 );
		}

		public void SetFlag( PlayerFlag flag, bool value )
		{
			if ( value )
				m_Flags |= flag;
			else
				m_Flags &= ~flag;
		}

		public DesignContext DesignContext
		{
			get{ return m_DesignContext; }
			set{ m_DesignContext = value; }
		}

		public static void Initialize()
		{
			if ( FastwalkPrevention )
			{
				PacketHandler ph = PacketHandlers.GetHandler( 0x02 );

				ph.ThrottleCallback = new ThrottlePacketCallback( MovementThrottle_Callback );
			}

			EventSink.Login += new LoginEventHandler( OnLogin );
			EventSink.Logout += new LogoutEventHandler( OnLogout );
			EventSink.Connected += new ConnectedEventHandler( EventSink_Connected );
			EventSink.Disconnected += new DisconnectedEventHandler( EventSink_Disconnected );
		}

		public override void OnSkillInvalidated( Skill skill )
		{
			if ( Core.AOS && skill.SkillName == SkillName.MagicResist )
				UpdateResistances();
		}

		public override int GetMaxResistance( ResistanceType type )
		{
			int max = base.GetMaxResistance( type );

			if ( type != ResistanceType.Physical && 60 < max && Spells.Fourth.CurseSpell.UnderEffect( this ) )
				max = 60;

			if( Core.ML && this.Race == Race.Elf && type == ResistanceType.Energy )
				max += 5; //Intended to go after the 60 max from curse

			return max;
		}

		protected override void OnRaceChange( Race oldRace )
		{
			ValidateEquipment();
			UpdateResistances();
		}

		public override int MaxWeight { get { return (((Core.ML && this.Race == Race.Human) ? 100 : 40) + (int)(3.5 * this.Str)); } }

		private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;

		public override void OnNetStateChanged()
		{
			m_LastGlobalLight = -1;
			m_LastPersonalLight = -1;
		}

		public override void ComputeBaseLightLevels( out int global, out int personal )
		{
			global = LightCycle.ComputeLevelFor( this );

			if ( this.LightLevel < 21 && AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 )
				personal = 21;
			else
				personal = this.LightLevel;
		}

		public override void CheckLightLevels( bool forceResend )
		{
			NetState ns = this.NetState;

			if ( ns == null )
				return;

			int global, personal;

			ComputeLightLevels( out global, out personal );

			if ( !forceResend )
				forceResend = ( global != m_LastGlobalLight || personal != m_LastPersonalLight );

			if ( !forceResend )
				return;

			m_LastGlobalLight = global;
			m_LastPersonalLight = personal;

			ns.Send( GlobalLightLevel.Instantiate( global ) );
			ns.Send( new PersonalLightLevel( this, personal ) );
		}

		public override int GetMinResistance( ResistanceType type )
		{
			int magicResist = (int)(Skills[SkillName.MagicResist].Value * 10);
			int min = int.MinValue;

			if ( magicResist >= 1000 )
				min = 40 + ((magicResist - 1000) / 50);
			else if ( magicResist >= 400 )
				min = (magicResist - 400) / 15;

			if ( min > MaxPlayerResistance )
				min = MaxPlayerResistance;

			int baseMin = base.GetMinResistance( type );

			if ( min < baseMin )
				min = baseMin;

			return min;
		}

		private static void OnLogin( LoginEventArgs e )
		{
			Mobile from = e.Mobile;

			CheckAtrophies( from );

			if ( AccountHandler.LockdownLevel > AccessLevel.Player )
			{
				string notice;

				Accounting.Account acct = from.Account as Accounting.Account;

				if ( acct == null || !acct.HasAccess( from.NetState ) )
				{
					if ( from.AccessLevel == AccessLevel.Player )
						notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
					else
						notice = "The server is currently under lockdown. You do not have sufficient access level to connect.";

					Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( Disconnect ), from );
				}
				else if ( from.AccessLevel >= AccessLevel.Administrator )
				{
					notice = "The server is currently under lockdown. As you are an administrator, you may change this from the [Admin gump.";
				}
				else
				{
					notice = "The server is currently under lockdown. You have sufficient access level to connect.";
				}

				from.SendGump( new NoticeGump( 1060637, 30720, notice, 0xFFC000, 300, 140, null, null ) );
			}
		}

		private bool m_NoDeltaRecursion;

		public void ValidateEquipment()
		{
			if ( m_NoDeltaRecursion || Map == null || Map == Map.Internal )
				return;

			if ( this.Items == null )
				return;

			m_NoDeltaRecursion = true;
			Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ValidateEquipment_Sandbox ) );
		}

		private void ValidateEquipment_Sandbox()
		{
			try
			{
				if ( Map == null || Map == Map.Internal )
					return;

				List<Item> items = this.Items;

				if ( items == null )
					return;

				bool moved = false;

				int str = this.Str;
				int dex = this.Dex;
				int intel = this.Int;

				#region Factions
				int factionItemCount = 0;
				#endregion

				Mobile from = this;

				#region Ethics
				Ethics.Ethic ethic = Ethics.Ethic.Find( from );
				#endregion

				for ( int i = items.Count - 1; i >= 0; --i )
				{
					if ( i >= items.Count )
						continue;

					Item item = items[i];

					#region Ethics
					if ( ( item.SavedFlags & 0x100 ) != 0 )
					{
						if ( item.Hue != Ethics.Ethic.Hero.Definition.PrimaryHue )
						{
							item.SavedFlags &= ~0x100;
						}
						else if ( ethic != Ethics.Ethic.Hero )
						{
							from.AddToBackpack( item );
							moved = true;
							continue;
						}
					}
					else if ( ( item.SavedFlags & 0x200 ) != 0 )
					{
						if ( item.Hue != Ethics.Ethic.Evil.Definition.PrimaryHue )
						{
							item.SavedFlags &= ~0x200;
						}
						else if ( ethic != Ethics.Ethic.Evil )
						{
							from.AddToBackpack( item );
							moved = true;
							continue;
						}
					}
					#endregion

					if ( item is BaseWeapon )
					{
						BaseWeapon weapon = (BaseWeapon)item;

						bool drop = false;

						if( dex < weapon.DexRequirement )
							drop = true;
						else if( str < AOS.Scale( weapon.StrRequirement, 100 - weapon.GetLowerStatReq() ) )
							drop = true;
						else if( intel < weapon.IntRequirement )
							drop = true;
						else if( weapon.RequiredRace != null && weapon.RequiredRace != this.Race )
							drop = true;

						if ( drop )
						{
							string name = weapon.Name;

							if ( name == null )
								name = String.Format( "#{0}", weapon.LabelNumber );

							from.SendLocalizedMessage( 1062001, name ); // You can no longer wield your ~1_WEAPON~
							from.AddToBackpack( weapon );
							moved = true;
						}
					}
					else if ( item is BaseArmor )
					{
						BaseArmor armor = (BaseArmor)item;

						bool drop = false;

						if ( !armor.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if ( !armor.AllowFemaleWearer && from.Female && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if( armor.RequiredRace != null && armor.RequiredRace != this.Race )
						{
							drop = true;
						}
						else
						{
							int strBonus = armor.ComputeStatBonus( StatType.Str ), strReq = armor.ComputeStatReq( StatType.Str );
							int dexBonus = armor.ComputeStatBonus( StatType.Dex ), dexReq = armor.ComputeStatReq( StatType.Dex );
							int intBonus = armor.ComputeStatBonus( StatType.Int ), intReq = armor.ComputeStatReq( StatType.Int );

							if( dex < dexReq || (dex + dexBonus) < 1 )
								drop = true;
							else if( str < strReq || (str + strBonus) < 1 )
								drop = true;
							else if( intel < intReq || (intel + intBonus) < 1 )
								drop = true;
						}

						if ( drop )
						{
							string name = armor.Name;

							if ( name == null )
								name = String.Format( "#{0}", armor.LabelNumber );

							if ( armor is BaseShield )
								from.SendLocalizedMessage( 1062003, name ); // You can no longer equip your ~1_SHIELD~
							else
								from.SendLocalizedMessage( 1062002, name ); // You can no longer wear your ~1_ARMOR~

							from.AddToBackpack( armor );
							moved = true;
						}
					}
					else if ( item is BaseClothing )
					{
						BaseClothing clothing = (BaseClothing)item;

						bool drop = false;

						if ( !clothing.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if ( !clothing.AllowFemaleWearer && from.Female && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if( clothing.RequiredRace != null && clothing.RequiredRace != this.Race )
						{
							drop = true;
						}
						else
						{
							int strBonus = clothing.ComputeStatBonus( StatType.Str );
							int strReq = clothing.ComputeStatReq( StatType.Str );

							if( str < strReq || (str + strBonus) < 1 )
								drop = true;
						}

						if ( drop )
						{
							string name = clothing.Name;

							if ( name == null )
								name = String.Format( "#{0}", clothing.LabelNumber );

							from.SendLocalizedMessage( 1062002, name ); // You can no longer wear your ~1_ARMOR~

							from.AddToBackpack( clothing );
							moved = true;
						}
					}

					FactionItem factionItem = FactionItem.Find( item );

					if ( factionItem != null )
					{
						bool drop = false;

						Faction ourFaction = Faction.Find( this );

						if ( ourFaction == null || ourFaction != factionItem.Faction )
							drop = true;
						else if ( ++factionItemCount > FactionItem.GetMaxWearables( this ) )
							drop = true;

						if ( drop )
						{
							from.AddToBackpack( item );
							moved = true;
						}
					}
				}

				if ( moved )
					from.SendLocalizedMessage( 500647 ); // Some equipment has been moved to your backpack.
			}
			catch ( Exception e )
			{
				Console.WriteLine( e );
			}
			finally
			{
				m_NoDeltaRecursion = false;
			}
		}

		public override void Delta( MobileDelta flag )
		{
			base.Delta( flag );

			if ( (flag & MobileDelta.Stat) != 0 )
				ValidateEquipment();

			if ( (flag & (MobileDelta.Name | MobileDelta.Hue)) != 0 )
				InvalidateMyRunUO();
		}

		private static void Disconnect( object state )
		{
			NetState ns = ((Mobile)state).NetState;

			if ( ns != null )
				ns.Dispose();
		}

		private static void OnLogout( LogoutEventArgs e )
		{
		}

		private static void EventSink_Connected( ConnectedEventArgs e )
		{
			PlayerMobile pm = e.Mobile as PlayerMobile;

			if ( pm != null )
			{
				pm.m_SessionStart = DateTime.Now;

				if ( pm.m_Quest != null )
					pm.m_Quest.StartTimer();

				pm.BedrollLogout = false;
				pm.LastOnline = DateTime.Now;
			}

			Timer.DelayCall( TimeSpan.Zero, new TimerStateCallback( ClearSpecialMovesCallback ), e.Mobile );
		}

		private static void ClearSpecialMovesCallback( object state )
		{
			Mobile from = (Mobile)state;

			SpecialMove.ClearAllMoves( from );
		}

		private static void EventSink_Disconnected( DisconnectedEventArgs e )
		{
			Mobile from = e.Mobile;
			DesignContext context = DesignContext.Find( from );

			if ( context != null )
			{
				/* Client disconnected
				 *  - Remove design context
				 *  - Eject all from house
				 *  - Restore relocated entities
				 */

				// Remove design context
				DesignContext.Remove( from );

				// Eject all from house
				from.RevealingAction();

				foreach ( Item item in context.Foundation.GetItems() )
					item.Location = context.Foundation.BanLocation;

				foreach ( Mobile mobile in context.Foundation.GetMobiles() )
					mobile.Location = context.Foundation.BanLocation;

				// Restore relocated entities
				context.Foundation.RestoreRelocatedEntities();
			}

			PlayerMobile pm = e.Mobile as PlayerMobile;

			if ( pm != null )
			{
				pm.m_GameTime += (DateTime.Now - pm.m_SessionStart);

				if ( pm.m_Quest != null )
					pm.m_Quest.StopTimer();

				pm.m_SpeechLog = null;
				pm.LastOnline = DateTime.Now;
			}
		}

		public override void RevealingAction()
		{
			if ( m_DesignContext != null )
				return;

			Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

			base.RevealingAction();
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override bool Hidden
		{
			get
			{
				return base.Hidden;
			}
			set
			{
				base.Hidden = value;

				RemoveBuff( BuffIcon.Invisibility );	//Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set

				if( !Hidden )
				{
					RemoveBuff( BuffIcon.HidingAndOrStealth );
				}
				else// if( !InvisibilitySpell.HasTimer( this ) )
				{
					BuffInfo.AddBuff( this, new BuffInfo( BuffIcon.HidingAndOrStealth, 1075655 ) );	//Hidden/Stealthing & You Are Hidden
				}
			}
		}

		public override void OnSubItemAdded( Item item )
		{
			if ( AccessLevel < AccessLevel.GameMaster && item.IsChildOf( this.Backpack ) )
			{
				int maxWeight = WeightOverloading.GetMaxWeight( this );
				int curWeight = Mobile.BodyWeight + this.TotalWeight;

				if ( curWeight > maxWeight )
					this.SendLocalizedMessage( 1019035, true, String.Format( " : {0} / {1}", curWeight, maxWeight ) );
			}
		}

		public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )
		{
			if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
				return false;

			if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier )
			{
				if ( message )
				{
					if ( target.Title == null )
						SendMessage( "{0} the vendor cannot be harmed.", target.Name );
					else
						SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title );
				}

				return false;
			}

			return base.CanBeHarmful( target, message, ignoreOurBlessedness );
		}

		public override bool CanBeBeneficial( Mobile target, bool message, bool allowDead )
		{
			if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
				return false;

			return base.CanBeBeneficial( target, message, allowDead );
		}

		public override bool CheckContextMenuDisplay( IEntity target )
		{
			return ( m_DesignContext == null );
		}

		public override void OnItemAdded( Item item )
		{
			base.OnItemAdded( item );

			if ( item is BaseArmor || item is BaseWeapon )
			{
				Hits=Hits; Stam=Stam; Mana=Mana;
			}

			if ( this.NetState != null )
				CheckLightLevels( false );

			InvalidateMyRunUO();
		}

		public override void OnItemRemoved( Item item )
		{
			base.OnItemRemoved( item );

			if ( item is BaseArmor || item is BaseWeapon )
			{
				Hits=Hits; Stam=Stam; Mana=Mana;
			}

			if ( this.NetState != null )
				CheckLightLevels( false );

			InvalidateMyRunUO();
		}

		public override double ArmorRating
		{
			get
			{
				//BaseArmor ar;
				double rating = 0.0;

				AddArmorRating( ref rating, NeckArmor );
				AddArmorRating( ref rating, HandArmor );
				AddArmorRating( ref rating, HeadArmor );
				AddArmorRating( ref rating, ArmsArmor );
				AddArmorRating( ref rating, LegsArmor );
				AddArmorRating( ref rating, ChestArmor );
				AddArmorRating( ref rating, ShieldArmor );

				return VirtualArmor + VirtualArmorMod + rating;
			}
		}

		private void AddArmorRating( ref double rating, Item armor )
		{
			BaseArmor ar = armor as BaseArmor;

			if( ar != null && ( !Core.AOS || ar.ArmorAttributes.MageArmor == 0 ))
				rating += ar.ArmorRatingScaled;
		}

		#region [Stats]Max
		[CommandProperty( AccessLevel.GameMaster )]
		public override int HitsMax
		{
			get
			{
				int strBase;
				int strOffs = GetStatOffset( StatType.Str );

				if ( Core.AOS )
				{
					strBase = this.Str;	//this.Str already includes GetStatOffset/str
					strOffs = AosAttributes.GetValue( this, AosAttribute.BonusHits );

					if ( AnimalForm.UnderTransformation( this, typeof( BakeKitsune ) ) || AnimalForm.UnderTransformation( this, typeof( GreyWolf ) ) )
						strOffs += 20;
				}
				else
				{
					strBase = this.RawStr;
				}

				return (strBase / 2) + 50 + strOffs;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override int StamMax
		{
			get{ return base.StamMax + AosAttributes.GetValue( this, AosAttribute.BonusStam ); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override int ManaMax
		{
			get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ) + ((Core.ML && Race == Race.Elf) ? 20 : 0); }
		}
		#endregion

		#region Stat Getters/Setters

		[CommandProperty( AccessLevel.GameMaster )]
		public override int Str
		{
			get
			{
				if( Core.ML && this.AccessLevel == AccessLevel.Player )
					return Math.Min( base.Str, 150 );

				return base.Str;
			}
			set
			{
				base.Str = value;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override int Int
		{
			get
			{
				if( Core.ML && this.AccessLevel == AccessLevel.Player )
					return Math.Min( base.Int, 150 );

				return base.Int;
			}
			set
			{
				base.Int = value;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override int Dex
		{
			get
			{
				if( Core.ML && this.AccessLevel == AccessLevel.Player )
					return Math.Min( base.Dex, 150 );

				return base.Dex;
			}
			set
			{
				base.Dex = value;
			}
		}

		#endregion

		public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				List<Gump> gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Count; ++i )
				{
					if ( gumps[i] is ResurrectGump )
					{
						if ( Alive )
						{
							CloseGump( typeof( ResurrectGump ) );
						}
						else
						{
							SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
							return false;
						}
					}
				}
			}

			TimeSpan speed = ComputeMovementSpeed( d );

			bool res;

			if ( !Alive )
				Server.Movement.MovementImpl.IgnoreMovableImpassables = true;

			res = base.Move( d );

			Server.Movement.MovementImpl.IgnoreMovableImpassables = false;

			if ( !res )
				return false;

			m_NextMovementTime += speed;

			return true;
		}

		public override bool CheckMovement( Direction d, out int newZ )
		{
			DesignContext context = m_DesignContext;

			if ( context == null )
				return base.CheckMovement( d, out newZ );

			HouseFoundation foundation = context.Foundation;

			newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level, context.Foundation );

			int newX = this.X, newY = this.Y;
			Movement.Movement.Offset( d, ref newX, ref newY );

			int startX = foundation.X + foundation.Components.Min.X + 1;
			int startY = foundation.Y + foundation.Components.Min.Y + 1;
			int endX = startX + foundation.Components.Width - 1;
			int endY = startY + foundation.Components.Height - 2;

			return ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map );
		}

		public override bool AllowItemUse( Item item )
		{
			return DesignContext.Check( this );
		}

		public SkillName[] AnimalFormRestrictedSkills{ get{ return m_AnimalFormRestrictedSkills; } }

		private SkillName[] m_AnimalFormRestrictedSkills = new SkillName[]
		{
			SkillName.ArmsLore,	SkillName.Begging, SkillName.Discordance, SkillName.Forensics,
			SkillName.Inscribe, SkillName.ItemID, SkillName.Meditation, SkillName.Peacemaking,
			SkillName.Provocation, SkillName.RemoveTrap, SkillName.SpiritSpeak, SkillName.Stealing,	
			SkillName.TasteID
		};

		public override bool AllowSkillUse( SkillName skill )
		{
			if ( AnimalForm.UnderTransformation( this ) )
			{
				for( int i = 0; i < m_AnimalFormRestrictedSkills.Length; i++ )
				{
					if( m_AnimalFormRestrictedSkills[i] == skill )
					{
						SendLocalizedMessage( 1070771 ); // You cannot use that skill in this form.
						return false;
					}
				}
			}

			return DesignContext.Check( this );
		}

		private bool m_LastProtectedMessage;
		private int m_NextProtectionCheck = 10;

		public virtual void RecheckTownProtection()
		{
			m_NextProtectionCheck = 10;

			Regions.GuardedRegion reg = (Regions.GuardedRegion) this.Region.GetRegion( typeof( Regions.GuardedRegion ) );
			bool isProtected = ( reg != null && !reg.IsDisabled() );

			if ( isProtected != m_LastProtectedMessage )
			{
				if ( isProtected )
					SendLocalizedMessage( 500112 ); // You are now under the protection of the town guards.
				else
					SendLocalizedMessage( 500113 ); // You have left the protection of the town guards.

				m_LastProtectedMessage = isProtected;
			}
		}

		public override void MoveToWorld( Point3D loc, Map map )
		{
			base.MoveToWorld( loc, map );

			RecheckTownProtection();
		}

		public override void SetLocation( Point3D loc, bool isTeleport )
		{
			if ( !isTeleport && AccessLevel == AccessLevel.Player )
			{
				// moving, not teleporting
				int zDrop = ( this.Location.Z - loc.Z );

				if ( zDrop > 20 ) // we fell more than one story
					Hits -= ((zDrop / 20) * 10) - 5; // deal some damage; does not kill, disrupt, etc
			}

			base.SetLocation( loc, isTeleport );

			if ( isTeleport || --m_NextProtectionCheck == 0 )
				RecheckTownProtection();
		}

		public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
		{
			base.GetContextMenuEntries( from, list );

			if ( from == this )
			{
				if ( m_Quest != null )
					m_Quest.GetContextMenuEntries( list );

				if ( Alive && InsuranceEnabled )
				{
					list.Add( new CallbackEntry( 6201, new ContextCallback( ToggleItemInsurance ) ) );

					if ( AutoRenewInsurance )
						list.Add( new CallbackEntry( 6202, new ContextCallback( CancelRenewInventoryInsurance ) ) );
					else
						list.Add( new CallbackEntry( 6200, new ContextCallback( AutoRenewInventoryInsurance ) ) );
				}

				BaseHouse house = BaseHouse.FindHouseAt( this );

				if ( house != null )
				{
					if ( Alive && house.InternalizedVendors.Count > 0 && house.IsOwner( this ) )
						list.Add( new CallbackEntry( 6204, new ContextCallback( GetVendor ) ) );

					if ( house.IsAosRules )
						list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );
				}

				if ( m_JusticeProtectors.Count > 0 )
					list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );

				if( Alive )
					list.Add( new CallbackEntry( 6210, new ContextCallback( ToggleChampionTitleDisplay ) ) );
			}
		}

		private void CancelProtection()
		{
			for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
			{
				Mobile prot = m_JusticeProtectors[i];

				string args = String.Format( "{0}\t{1}", this.Name, prot.Name );

				prot.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
				this.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
			}

			m_JusticeProtectors.Clear();
		}

		#region Insurance

		private void ToggleItemInsurance()
		{
			if ( !CheckAlive() )
				return;

			BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
			SendLocalizedMessage( 1060868 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
		}

		private bool CanInsure( Item item )
		{
			if ( item is Container || item is BagOfSending || item is KeyRing )
				return false;

			if ( (item is Spellbook && item.LootType == LootType.Blessed)|| item is Runebook || item is PotionKeg || item is Sigil )
				return false;

			if ( item.Stackable )
				return false;

			if ( item.LootType == LootType.Cursed )
				return false;

			if ( item.ItemID == 0x204E ) // death shroud
				return false;

			return true;
		}

		private void ToggleItemInsurance_Callback( Mobile from, object obj )
		{
			if ( !CheckAlive() )
				return;

			Item item = obj as Item;

			if ( item == null || !item.IsChildOf( this ) )
			{
				BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
				SendLocalizedMessage( 1060871, "", 0x23 ); // You can only insure items that you have equipped or that are in your backpack
			}
			else if ( item.Insured )
			{
				item.Insured = false;

				SendLocalizedMessage( 1060874, "", 0x35 ); // You cancel the insurance on the item

				BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
				SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
			}
			else if ( !CanInsure( item ) )
			{
				BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
				SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
			}
			else if ( item.LootType == LootType.Blessed || item.LootType == LootType.Newbied || item.BlessedFor == from )
			{
				BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
				SendLocalizedMessage( 1060870, "", 0x23 ); // That item is blessed and does not need to be insured
				SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
			}
			else
			{
				if ( !item.PayedInsurance )
				{
					if ( Banker.Withdraw( from, 600 ) )
					{
						SendLocalizedMessage( 1060398, "600" ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
						item.PayedInsurance = true;
					}
					else
					{
						SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
						return;
					}
				}

				item.Insured = true;

				SendLocalizedMessage( 1060873, "", 0x23 ); // You have insured the item

				BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
				SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
			}
		}

		private void AutoRenewInventoryInsurance()
		{
			if ( !CheckAlive() )
				return;

			SendLocalizedMessage( 1060881, "", 0x23 ); // You have selected to automatically reinsure all insured items upon death
			AutoRenewInsurance = true;
		}

		private void CancelRenewInventoryInsurance()
		{
			if ( !CheckAlive() )
				return;

			if( Core.SE )
			{
				if( !HasGump( typeof( CancelRenewInventoryInsuranceGump ) ) )
					SendGump( new CancelRenewInventoryInsuranceGump( this ) );
			}
			else
			{
				SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
				AutoRenewInsurance = false;
			}
		}

		private class CancelRenewInventoryInsuranceGump : Gump
		{
			private PlayerMobile m_Player;

			public CancelRenewInventoryInsuranceGump( PlayerMobile player ) : base( 250, 200 )
			{
				m_Player = player;

				AddBackground( 0, 0, 240, 142, 0x13BE );
				AddImageTiled( 6, 6, 228, 100, 0xA40 );
				AddImageTiled( 6, 116, 228, 20, 0xA40 );
				AddAlphaRegion( 6, 6, 228, 142 );

				AddHtmlLocalized( 8, 8, 228, 100, 1071021, 0x7FFF, false, false ); // You are about to disable inventory insurance auto-renewal.

				AddButton( 6, 116, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 40, 118, 450, 20, 1060051, 0x7FFF, false, false ); // CANCEL

				AddButton( 114, 116, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 148, 118, 450, 20, 1071022, 0x7FFF, false, false ); // DISABLE IT!
			}

			public override void OnResponse( NetState sender, RelayInfo info )
			{
				if ( !m_Player.CheckAlive() )
					return;

				if ( info.ButtonID == 1 )
				{
					m_Player.SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
					m_Player.AutoRenewInsurance = false;
				}
				else
				{
					m_Player.SendLocalizedMessage( 1042021 ); // Cancelled.
				}
			}
		}
		#endregion

		private void GetVendor()
		{
			BaseHouse house = BaseHouse.FindHouseAt( this );

			if ( CheckAlive() && house != null && house.IsOwner( this ) && house.InternalizedVendors.Count > 0 )
			{
				CloseGump( typeof( ReclaimVendorGump ) );
				SendGump( new ReclaimVendorGump( house ) );
			}
		}

		private void LeaveHouse()
		{
			BaseHouse house = BaseHouse.FindHouseAt( this );

			if ( house != null )
				this.Location = house.BanLocation;
		}

		private delegate void ContextCallback();

		private class CallbackEntry : ContextMenuEntry
		{
			private ContextCallback m_Callback;

			public CallbackEntry( int number, ContextCallback callback ) : this( number, -1, callback )
			{
			}

			public CallbackEntry( int number, int range, ContextCallback callback ) : base( number, range )
			{
				m_Callback = callback;
			}

			public override void OnClick()
			{
				if ( m_Callback != null )
					m_Callback();
			}
		}

		public override void DisruptiveAction()
		{
			if( Meditating )
			{
				RemoveBuff( BuffIcon.ActiveMeditation );
			}

			base.DisruptiveAction();
		}
		public override void OnDoubleClick( Mobile from )
		{
			if ( this == from && !Warmode )
			{
				IMount mount = Mount;

				if ( mount != null && !DesignContext.Check( this ) )
					return;
			}

			base.OnDoubleClick( from );
		}

		public override void DisplayPaperdollTo( Mobile to )
		{
			if ( DesignContext.Check( this ) )
				base.DisplayPaperdollTo( to );
		}

		private static bool m_NoRecursion;

		public override bool CheckEquip( Item item )
		{
			if ( !base.CheckEquip( item ) )
				return false;

			#region Factions
			FactionItem factionItem = FactionItem.Find( item );

			if ( factionItem != null )
			{
				Faction faction = Faction.Find( this );

				if ( faction == null )
				{
					SendLocalizedMessage( 1010371 ); // You cannot equip a faction item!
					return false;
				}
				else if ( faction != factionItem.Faction )
				{
					SendLocalizedMessage( 1010372 ); // You cannot equip an opposing faction's item!
					return false;
				}
				else
				{
					int maxWearables = FactionItem.GetMaxWearables( this );

					for ( int i = 0; i < Items.Count; ++i )
					{
						Item equiped = Items[i];

						if ( item != equiped && FactionItem.Find( equiped ) != null )
						{
							if ( --maxWearables == 0 )
							{
								SendLocalizedMessage( 1010373 ); // You do not have enough rank to equip more faction items!
								return false;
							}
						}
					}
				}
			}
			#endregion

			if ( this.AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && this.HasTrade )
			{
				BounceInfo bounce = item.GetBounce();

				if ( bounce != null )
				{
					if ( bounce.m_Parent is Item )
					{
						Item parent = (Item) bounce.m_Parent;

						if ( parent == this.Backpack || parent.IsChildOf( this.Backpack ) )
							return true;
					}
					else if ( bounce.m_Parent == this )
					{
						return true;
					}
				}

				SendLocalizedMessage( 1004042 ); // You can only equip what you are already carrying while you have a trade pending.
				return false;
			}

			return true;
		}

		public override bool CheckTrade( Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, int plusItems, int plusWeight )
		{
			int msgNum = 0;

			if ( cont == null )
			{
				if ( to.Holding != null )
					msgNum = 1062727; // You cannot trade with someone who is dragging something.
				else if ( this.HasTrade )
					msgNum = 1062781; // You are already trading with someone else!
				else if ( to.HasTrade )
					msgNum = 1062779; // That person is already involved in a trade
			}

			if ( msgNum == 0 )
			{
				if ( cont != null )
				{
					plusItems += cont.TotalItems;
					plusWeight += cont.TotalWeight;
				}

				if ( this.Backpack == null || !this.Backpack.CheckHold( this, item, false, checkItems, plusItems, plusWeight ) )
					msgNum = 1004040; // You would not be able to hold this if the trade failed.
				else if ( to.Backpack == null || !to.Backpack.CheckHold( to, item, false, checkItems, plusItems, plusWeight ) )
					msgNum = 1004039; // The recipient of this trade would not be able to carry this.
				else
					msgNum = CheckContentForTrade( item );
			}

			if ( msgNum != 0 )
			{
				if ( message )
					this.SendLocalizedMessage( msgNum );

				return false;
			}

			return true;
		}

		private static int CheckContentForTrade( Item item )
		{
			if ( item is TrapableContainer && ((TrapableContainer)item).TrapType != TrapType.None )
				return 1004044; // You may not trade trapped items.

			if ( SkillHandlers.StolenItem.IsStolen( item ) )
				return 1004043; // You may not trade recently stolen items.

			if ( item is Container )
			{
				foreach ( Item subItem in item.Items )
				{
					int msg = CheckContentForTrade( subItem );

					if ( msg != 0 )
						return msg;
				}
			}

			return 0;
		}

		public override bool CheckNonlocalDrop( Mobile from, Item item, Item target )
		{
			if ( !base.CheckNonlocalDrop( from, item, target ) )
				return false;

			if ( from.AccessLevel >= AccessLevel.GameMaster )
				return true;

			Container pack = this.Backpack;
			if ( from == this && this.HasTrade && ( target == pack || target.IsChildOf( pack ) ) )
			{
				BounceInfo bounce = item.GetBounce();

				if ( bounce != null && bounce.m_Parent is Item )
				{
					Item parent = (Item) bounce.m_Parent;

					if ( parent == pack || parent.IsChildOf( pack ) )
						return true;
				}

				SendLocalizedMessage( 1004041 ); // You can't do that while you have a trade pending.
				return false;
			}

			return true;
		}

		protected override void OnLocationChange( Point3D oldLocation )
		{
			CheckLightLevels( false );

			DesignContext context = m_DesignContext;

			if ( context == null || m_NoRecursion )
				return;

			m_NoRecursion = true;

			HouseFoundation foundation = context.Foundation;

			int newX = this.X, newY = this.Y;
			int newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level, context.Foundation );

			int startX = foundation.X + foundation.Components.Min.X + 1;
			int startY = foundation.Y + foundation.Components.Min.Y + 1;
			int endX = startX + foundation.Components.Width - 1;
			int endY = startY + foundation.Components.Height - 2;

			if ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map )
			{
				if ( Z != newZ )
					Location = new Point3D( X, Y, newZ );

				m_NoRecursion = false;
				return;
			}

			Location = new Point3D( foundation.X, foundation.Y, newZ );
			Map = foundation.Map;

			m_NoRecursion = false;
		}

		public override bool OnMoveOver( Mobile m )
		{
			if ( m is BaseCreature && !((BaseCreature)m).Controlled )
				return false;

			return base.OnMoveOver( m );
		}

		public override bool CheckShove( Mobile shoved )
		{
			if( TransformationSpell.UnderTransformation( this, typeof( WraithFormSpell ) ) )
				return true;
			else
				return base.CheckShove( shoved );
		}


		protected override void OnMapChange( Map oldMap )
		{
			if ( (Map != Faction.Facet && oldMap == Faction.Facet) || (Map == Faction.Facet && oldMap != Faction.Facet) )
				InvalidateProperties();

			DesignContext context = m_DesignContext;

			if ( context == null || m_NoRecursion )
				return;

			m_NoRecursion = true;

			HouseFoundation foundation = context.Foundation;

			if ( Map != foundation.Map )
				Map = foundation.Map;

			m_NoRecursion = false;
		}

		public override void OnBeneficialAction( Mobile target, bool isCriminal )
		{
			if ( m_SentHonorContext != null )
				m_SentHonorContext.OnSourceBeneficialAction( target );

			base.OnBeneficialAction( target, isCriminal );
		}

		public override void OnDamage( int amount, Mobile from, bool willKill )
		{
			int disruptThreshold;

			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 );

			if ( m_ReceivedHonorContext != null )
				m_ReceivedHonorContext.OnTargetDamaged( from, amount );
			if ( m_SentHonorContext != null )
				m_SentHonorContext.OnSourceDamaged( from, amount );

			base.OnDamage( amount, from, willKill );
		}

		public override void Resurrect()
		{
			bool wasAlive = this.Alive;

			base.Resurrect();

			if ( this.Alive && !wasAlive )
			{
				Item deathRobe = new DeathRobe();

				if ( !EquipItem( deathRobe ) )
					deathRobe.Delete();
			}
		}

		public override double RacialSkillBonus
		{
			get
			{
				if( Core.ML && this.Race == Race.Human )
					return 20.0;

				return 0;
			}
		}

		private Mobile m_InsuranceAward;
		private int m_InsuranceCost;
		private int m_InsuranceBonus;

		public override bool OnBeforeDeath()
		{
			m_InsuranceCost = 0;
			m_InsuranceAward = base.FindMostRecentDamager( false );

			if ( m_InsuranceAward is BaseCreature )
			{
				Mobile master = ((BaseCreature)m_InsuranceAward).GetMaster();

				if ( master != null )
					m_InsuranceAward = master;
			}

			if ( m_InsuranceAward != null && (!m_InsuranceAward.Player || m_InsuranceAward == this) )
				m_InsuranceAward = null;

			if ( m_InsuranceAward is PlayerMobile )
				((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

			if ( m_ReceivedHonorContext != null )
				m_ReceivedHonorContext.OnTargetKilled();
			if ( m_SentHonorContext != null )
				m_SentHonorContext.OnSourceKilled();

			return base.OnBeforeDeath();
		}

		private bool CheckInsuranceOnDeath( Item item )
		{
			if ( InsuranceEnabled && item.Insured )
			{
				if ( AutoRenewInsurance )
				{
					int cost = ( m_InsuranceAward == null ? 600 : 300 );

					if ( Banker.Withdraw( this, cost ) )
					{
						m_InsuranceCost += cost;
						item.PayedInsurance = true;
					}
					else
					{
						SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
						item.PayedInsurance = false;
						item.Insured = false;
					}
				}
				else
				{
					item.PayedInsurance = false;
					item.Insured = false;
				}

				if ( m_InsuranceAward != null )
				{
					if ( Banker.Deposit( m_InsuranceAward, 300 ) )
					{
						if ( m_InsuranceAward is PlayerMobile )
							((PlayerMobile)m_InsuranceAward).m_InsuranceBonus += 300;
					}
				}

				return true;
			}

			return false;
		}

		public override DeathMoveResult GetParentMoveResultFor( Item item )
		{
			if ( CheckInsuranceOnDeath( item ) )
				return DeathMoveResult.MoveToBackpack;

			DeathMoveResult res = base.GetParentMoveResultFor( item );

			if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
				res = DeathMoveResult.MoveToBackpack;

			return res;
		}

		public override DeathMoveResult GetInventoryMoveResultFor( Item item )
		{
			if ( CheckInsuranceOnDeath( item ) )
				return DeathMoveResult.MoveToBackpack;

			DeathMoveResult res = base.GetInventoryMoveResultFor( item );

			if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
				res = DeathMoveResult.MoveToBackpack;

			return res;
		}

		public override void OnDeath( Container c )
		{
			base.OnDeath( c );

			HueMod = -1;
			NameMod = null;
			SavagePaintExpiration = TimeSpan.Zero;

			SetHairMods( -1, -1 );

			PolymorphSpell.StopTimer( this );
			IncognitoSpell.StopTimer( this );
			DisguiseGump.StopTimer( this );

			EndAction( typeof( PolymorphSpell ) );
			EndAction( typeof( IncognitoSpell ) );

			MeerMage.StopEffect( this, false );

			SkillHandlers.StolenItem.ReturnOnDeath( this, c );

			if ( m_PermaFlags.Count > 0 )
			{
				m_PermaFlags.Clear();

				if ( c is Corpse )
					((Corpse)c).Criminal = true;

				if ( SkillHandlers.Stealing.ClassicMode )
					Criminal = true;
			}

			if ( this.Kills >= 5 && DateTime.Now >= m_NextJustAward )
			{
				Mobile m = FindMostRecentDamager( false );

				if( m is BaseCreature )
					m = ((BaseCreature)m).GetMaster();

				if ( m != null && m is PlayerMobile && m != this )
				{
					bool gainedPath = false;

					int pointsToGain = 0;

					pointsToGain += (int) Math.Sqrt( this.GameTime.TotalSeconds * 4 );
					pointsToGain *= 5;
					pointsToGain += (int) Math.Pow( this.Skills.Total / 250, 2 );

					if ( VirtueHelper.Award( m, VirtueName.Justice, pointsToGain, ref gainedPath ) )
					{
						if ( gainedPath )
							m.SendLocalizedMessage( 1049367 ); // You have gained a path in Justice!
						else
							m.SendLocalizedMessage( 1049363 ); // You have gained in Justice.

						m.FixedParticles( 0x375A, 9, 20, 5027, EffectLayer.Waist );
						m.PlaySound( 0x1F7 );

						m_NextJustAward = DateTime.Now + TimeSpan.FromMinutes( pointsToGain / 3 );
					}
				}
			}

			if ( m_InsuranceCost > 0 )
				SendLocalizedMessage( 1060398, m_InsuranceCost.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.

			if ( m_InsuranceAward is PlayerMobile )
			{
				PlayerMobile pm = (PlayerMobile)m_InsuranceAward;

				if ( pm.m_InsuranceBonus > 0 )
					pm.SendLocalizedMessage( 1060397, pm.m_InsuranceBonus.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
			}

			Mobile killer = this.FindMostRecentDamager( true );

			if ( killer is BaseCreature )
			{
				BaseCreature bc = (BaseCreature)killer;

				Mobile master = bc.GetMaster();
				if( master != null )
					killer = master;
			}

			if ( this.Young )
			{
				if ( YoungDeathTeleport() )
					Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerCallback( SendYoungDeathNotice ) );
			}

			Faction.HandleDeath( this, killer );

			Server.Guilds.Guild.HandleDeath( this, killer );

			if( m_BuffTable != null )
			{
				List<BuffInfo> list = new List<BuffInfo>();

				foreach( BuffInfo buff in m_BuffTable.Values )
				{
					if( !buff.RetainThroughDeath )
					{
						list.Add( buff );
					}
				}

				for( int i = 0; i < list.Count; i++ )
				{
					RemoveBuff( list[i] );
				}
			}
		}

		private List<Mobile> m_PermaFlags;
		private List<Mobile> m_VisList;
		private Hashtable m_AntiMacroTable;
		private TimeSpan m_GameTime;
		private TimeSpan m_ShortTermElapse;
		private TimeSpan m_LongTermElapse;
		private DateTime m_SessionStart;
		private DateTime m_LastEscortTime;
		private DateTime m_NextSmithBulkOrder;
		private DateTime m_NextTailorBulkOrder;
		private DateTime m_SavagePaintExpiration;
		private SkillName m_Learning = (SkillName)(-1);

		public SkillName Learning
		{
			get{ return m_Learning; }
			set{ m_Learning = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public TimeSpan SavagePaintExpiration
		{
			get
			{
				TimeSpan ts = m_SavagePaintExpiration - DateTime.Now;

				if ( ts < TimeSpan.Zero )
					ts = TimeSpan.Zero;

				return ts;
			}
			set
			{
				m_SavagePaintExpiration = DateTime.Now + value;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public TimeSpan NextSmithBulkOrder
		{
			get
			{
				TimeSpan ts = m_NextSmithBulkOrder - DateTime.Now;

				if ( ts < TimeSpan.Zero )
					ts = TimeSpan.Zero;

				return ts;
			}
			set
			{
				try{ m_NextSmithBulkOrder = DateTime.Now + value; }
				catch{}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public TimeSpan NextTailorBulkOrder
		{
			get
			{
				TimeSpan ts = m_NextTailorBulkOrder - DateTime.Now;

				if ( ts < TimeSpan.Zero )
					ts = TimeSpan.Zero;

				return ts;
			}
			set
			{
				try{ m_NextTailorBulkOrder = DateTime.Now + value; }
				catch{}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public DateTime LastEscortTime
		{
			get{ return m_LastEscortTime; }
			set{ m_LastEscortTime = value; }
		}

		public PlayerMobile()
		{
			m_VisList = new List<Mobile>();
			m_PermaFlags = new List<Mobile>();
			m_AntiMacroTable = new Hashtable();

			m_BOBFilter = new Engines.BulkOrders.BOBFilter();

			m_GameTime = TimeSpan.Zero;
			m_ShortTermElapse = TimeSpan.FromHours( 8.0 );
			m_LongTermElapse = TimeSpan.FromHours( 40.0 );

			m_JusticeProtectors = new List<Mobile>();
			m_GuildRank = Guilds.RankDefinition.Lowest;

			m_ChampionTitles = new ChampionTitleInfo();

			InvalidateMyRunUO();
		}

		public override bool MutateSpeech( List<Mobile> hears, ref string text, ref object context )
		{
			if ( Alive )
				return false;

			if ( Core.AOS )
			{
				for ( int i = 0; i < hears.Count; ++i )
				{
					Mobile m = hears[i];

					if ( m != this && m.Skills[SkillName.SpiritSpeak].Value >= 100.0 )
						return false;
				}
			}

			return base.MutateSpeech( hears, ref text, ref context );
		}

		public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
		{
			if( Guilds.Guild.NewGuildSystem && (type == MessageType.Guild || type == MessageType.Alliance) )
			{
				Guilds.Guild g = this.Guild as Guilds.Guild;
				if( g == null )
				{
					SendLocalizedMessage( 1063142 ); // You are not in a guild!
				}
				else if( type == MessageType.Alliance )
				{
					if( g.Alliance != null && g.Alliance.IsMember( g ) )
					{
						//g.Alliance.AllianceTextMessage( hue, "[Alliance][{0}]: {1}", this.Name, text );
						g.Alliance.AllianceChat( this, text );
						SendToStaffMessage( this, "[Alliance]: {0}", this.Name, text );

						m_AllianceMessageHue = hue;
					}
					else
					{
						SendLocalizedMessage( 1071020 ); // You are not in an alliance!
					}
				}
				else	//Type == MessageType.Guild
				{
					m_GuildMessageHue = hue;

					g.GuildChat( this, text );
					SendToStaffMessage( this, "[Guild]: {0}", text );
				}
			}
			else
			{
				base.DoSpeech( text, keywords, type, hue );
			}
		}

		private static void SendToStaffMessage( Mobile from, string text )
		{
			Packet p = null;

			foreach( NetState ns in from.GetClientsInRange( 8 ) )
			{
				Mobile mob = ns.Mobile;

				if( mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel )
				{
					if( p == null )
						p = Packet.Acquire( new UnicodeMessage( from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, text ) );

					ns.Send( p );
				}
			}

			Packet.Release( p );
		}
		private static void SendToStaffMessage( Mobile from, string format, params object[] args )
		{
			SendToStaffMessage( from, String.Format( format, args ) );
		}

		public override void Damage( int amount, Mobile from )
		{
			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( 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 );
		}

		#region Poison
		public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
		{
			if ( !Alive )
				return ApplyPoisonResult.Immune;

			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( 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 ( this.Young )
				return true;

			return base.CheckPoisonImmunity( from, poison );
		}

		public override void OnPoisonImmunity( Mobile from, Poison poison )
		{
			if ( this.Young )
				SendLocalizedMessage( 502808 ); // You would have been poisoned, were you not new to the land of Britannia. Be careful in the future.
			else
				base.OnPoisonImmunity( from, poison );
		}
		#endregion

		public PlayerMobile( Serial s ) : base( s )
		{
			m_VisList = new List<Mobile>();
			m_AntiMacroTable = new Hashtable();
			InvalidateMyRunUO();
		}

		public List<Mobile> VisibilityList
		{
			get{ return m_VisList; }
		}

		public List<Mobile> PermaFlags
		{
			get{ return m_PermaFlags; }
		}

		public override int Luck{ get{ return AosAttributes.GetValue( this, AosAttribute.Luck ); } }

		public override bool IsHarmfulCriminal( Mobile target )
		{
			if ( SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).m_PermaFlags.Count > 0 )
			{
				int noto = Notoriety.Compute( this, target );

				if ( noto == Notoriety.Innocent )
					target.Delta( MobileDelta.Noto );

				return false;
			}

			if ( target is BaseCreature && ((BaseCreature)target).InitialInnocent && !((BaseCreature)target).Controlled )
				return false;

			return base.IsHarmfulCriminal( target );
		}

		public bool AntiMacroCheck( Skill skill, object obj )
		{
			if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
				return true;

			Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
			if ( tbl == null )
				m_AntiMacroTable[skill] = tbl = new Hashtable();

			CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
			if ( count != null )
			{
				if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
				{
					count.Count = 1;
					return true;
				}
				else
				{
					++count.Count;
					if ( count.Count <= SkillCheck.Allowance )
						return true;
					else
						return false;
				}
			}
			else
			{
				tbl[obj] = count = new CountAndTimeStamp();
				count.Count = 1;

				return true;
			}
		}

		private void RevertHair()
		{
			SetHairMods( -1, -1 );
		}

		private Engines.BulkOrders.BOBFilter m_BOBFilter;

		public Engines.BulkOrders.BOBFilter BOBFilter
		{
			get{ return m_BOBFilter; }
		}



		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			switch ( version )
			{
				case 25:
				{
					int recipeCount = reader.ReadInt();

					if( recipeCount > 0 )
					{
						m_AcquiredRecipes = new Dictionary<int, bool>();

						for( int i = 0; i < recipeCount; i++ )
						{
							int r = reader.ReadInt();
							if( reader.ReadBool() )	//Don't add in recipies which we haven't gotten or have been removed
								m_AcquiredRecipes.Add( r, true );
						}
					}
					goto case 24;
				}
				case 24:
				{
					m_LastHonorLoss = reader.ReadDeltaTime();
					goto case 23;
				}
				case 23:
				{
					m_ChampionTitles = new ChampionTitleInfo( reader );
					goto case 22;
				}
				case 22:
				{
					m_LastValorLoss = reader.ReadDateTime();
					goto case 21;
				}
				case 21:
				{
					m_ToTItemsTurnedIn = reader.ReadEncodedInt();
					m_ToTTotalMonsterFame = reader.ReadInt();
					goto case 20;
				}
				case 20:
				{
					m_AllianceMessageHue = reader.ReadEncodedInt();
					m_GuildMessageHue = reader.ReadEncodedInt();

					goto case 19;
				}
				case 19:
				{
					int rank = reader.ReadEncodedInt();
					int maxRank = Guilds.RankDefinition.Ranks.Length -1;
					if( rank > maxRank )
						rank = maxRank;

					m_GuildRank = Guilds.RankDefinition.Ranks[rank];
					m_LastOnline = reader.ReadDateTime();
					goto case 18;
				}
				case 18:
				{
					m_SolenFriendship = (SolenFriendship) reader.ReadEncodedInt();

					goto case 17;
				}
				case 17: // changed how DoneQuests is serialized
				case 16:
				{
					m_Quest = QuestSerializer.DeserializeQuest( reader );

					if ( m_Quest != null )
						m_Quest.From = this;

					int count = reader.ReadEncodedInt();

					if ( count > 0 )
					{
						m_DoneQuests = new List<QuestRestartInfo>();

						for ( int i = 0; i < count; ++i )
						{
							Type questType = QuestSerializer.ReadType( QuestSystem.QuestTypes, reader );
							DateTime restartTime;

							if ( version < 17 )
								restartTime = DateTime.MaxValue;
							else
								restartTime = reader.ReadDateTime();

							m_DoneQuests.Add( new QuestRestartInfo( questType, restartTime ) );
						}
					}

					m_Profession = reader.ReadEncodedInt();
					goto case 15;
				}
				case 15:
				{
					m_LastCompassionLoss = reader.ReadDeltaTime();
					goto case 14;
				}
				case 14:
				{
					m_CompassionGains = reader.ReadEncodedInt();

					if ( m_CompassionGains > 0 )
						m_NextCompassionDay = reader.ReadDeltaTime();

					goto case 13;
				}
				case 13: // just removed m_PayedInsurance list
				case 12:
				{
					m_BOBFilter = new Engines.BulkOrders.BOBFilter( reader );
					goto case 11;
				}
				case 11:
				{
					if ( version < 13 )
					{
						List<Item> payed = reader.ReadStrongItemList();

						for ( int i = 0; i < payed.Count; ++i )
							payed[i].PayedInsurance = true;
					}

					goto case 10;
				}
				case 10:
				{
					if ( reader.ReadBool() )
					{
						m_HairModID = reader.ReadInt();
						m_HairModHue = reader.ReadInt();
						m_BeardModID = reader.ReadInt();
						m_BeardModHue = reader.ReadInt();

						// We cannot call SetHairMods( -1, -1 ) here because the items have not yet loaded
						Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RevertHair ) );
					}

					goto case 9;
				}
				case 9:
				{
					SavagePaintExpiration = reader.ReadTimeSpan();

					if ( SavagePaintExpiration > TimeSpan.Zero )
					{
						BodyMod = ( Female ? 184 : 183 );
						HueMod = 0;
					}

					goto case 8;
				}
				case 8:
				{
					m_NpcGuild = (NpcGuild)reader.ReadInt();
					m_NpcGuildJoinTime = reader.ReadDateTime();
					m_NpcGuildGameTime = reader.ReadTimeSpan();
					goto case 7;
				}
				case 7:
				{
					m_PermaFlags = reader.ReadStrongMobileList();
					goto case 6;
				}
				case 6:
				{
					NextTailorBulkOrder = reader.ReadTimeSpan();
					goto case 5;
				}
				case 5:
				{
					NextSmithBulkOrder = reader.ReadTimeSpan();
					goto case 4;
				}
				case 4:
				{
					m_LastJusticeLoss = reader.ReadDeltaTime();
					m_JusticeProtectors = reader.ReadStrongMobileList();
					goto case 3;
				}
				case 3:
				{
					m_LastSacrificeGain = reader.ReadDeltaTime();
					m_LastSacrificeLoss = reader.ReadDeltaTime();
					m_AvailableResurrects = reader.ReadInt();
					goto case 2;
				}
				case 2:
				{
					m_Flags = (PlayerFlag)reader.ReadInt();
					goto case 1;
				}
				case 1:
				{
					m_LongTermElapse = reader.ReadTimeSpan();
					m_ShortTermElapse = reader.ReadTimeSpan();
					m_GameTime = reader.ReadTimeSpan();
					goto case 0;
				}
				case 0:
				{
					break;
				}
			}

			// Professions weren't verified on 1.0 RC0
			if ( !CharacterCreation.VerifyProfession( m_Profession ) )
				m_Profession = 0;

			if ( m_PermaFlags == null )
				m_PermaFlags = new List<Mobile>();

			if ( m_JusticeProtectors == null )
				m_JusticeProtectors = new List<Mobile>();

			if ( m_BOBFilter == null )
				m_BOBFilter = new Engines.BulkOrders.BOBFilter();

			if( m_GuildRank == null )
				m_GuildRank = Guilds.RankDefinition.Member;	//Default to member if going from older verstion to new version (only time it should be null)

			if( m_LastOnline == DateTime.MinValue && Account != null )
				m_LastOnline = ((Account)Account).LastLogin;

			if( m_ChampionTitles == null )
				m_ChampionTitles = new ChampionTitleInfo();

			List<Mobile> list = this.Stabled;

			for ( int i = 0; i < list.Count; ++i )
			{
				BaseCreature bc = list[i] as BaseCreature;

				if ( bc != null )
					bc.IsStabled = true;
			}

			CheckAtrophies( this );


			if( Hidden )	//Hiding is the only buff where it has an effect that's serialized.
				AddBuff( new BuffInfo( BuffIcon.HidingAndOrStealth, 1075655 ) );
		}
		
		public override void Serialize( GenericWriter writer )
		{
			//cleanup our anti-macro table 
			foreach ( Hashtable t in m_AntiMacroTable.Values )
			{
				ArrayList remove = new ArrayList();
				foreach ( CountAndTimeStamp time in t.Values )
				{
					if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
						remove.Add( time );
				}

				for (int i=0;i<remove.Count;++i)
					t.Remove( remove[i] );
			}

			//decay our kills
			if ( m_ShortTermElapse < this.GameTime )
			{
				m_ShortTermElapse += TimeSpan.FromHours( 8 );
				if ( ShortTermMurders > 0 )
					--ShortTermMurders;
			}

			if ( m_LongTermElapse < this.GameTime )
			{
				m_LongTermElapse += TimeSpan.FromHours( 40 );
				if ( Kills > 0 )
					--Kills;
			}

			CheckAtrophies( this );

			base.Serialize( writer );
			
			writer.Write( (int) 25 ); // version

			if( m_AcquiredRecipes == null )
			{
				writer.Write( (int)0 );
			}
			else
			{
				writer.Write( m_AcquiredRecipes.Count );

				foreach( KeyValuePair<int, bool> kvp in m_AcquiredRecipes )
				{
					writer.Write( kvp.Key );
					writer.Write( kvp.Value );
				}
			}

			writer.WriteDeltaTime( m_LastHonorLoss );

			ChampionTitleInfo.Serialize( writer, m_ChampionTitles );

			writer.Write( m_LastValorLoss );
			writer.WriteEncodedInt( m_ToTItemsTurnedIn );
			writer.Write( m_ToTTotalMonsterFame );	//This ain't going to be a small #.

			writer.WriteEncodedInt( m_AllianceMessageHue );
			writer.WriteEncodedInt( m_GuildMessageHue );

			writer.WriteEncodedInt( m_GuildRank.Rank );
			writer.Write( m_LastOnline );

			writer.WriteEncodedInt( (int) m_SolenFriendship );

			QuestSerializer.Serialize( m_Quest, writer );

			if ( m_DoneQuests == null )
			{
				writer.WriteEncodedInt( (int) 0 );
			}
			else
			{
				writer.WriteEncodedInt( (int) m_DoneQuests.Count );

				for ( int i = 0; i < m_DoneQuests.Count; ++i )
				{
					QuestRestartInfo restartInfo = m_DoneQuests[i];

					QuestSerializer.Write( (Type) restartInfo.QuestType, QuestSystem.QuestTypes, writer );
					writer.Write( (DateTime) restartInfo.RestartTime );
				}
			}

			writer.WriteEncodedInt( (int) m_Profession );

			writer.WriteDeltaTime( m_LastCompassionLoss );

			writer.WriteEncodedInt( m_CompassionGains );

			if ( m_CompassionGains > 0 )
				writer.WriteDeltaTime( m_NextCompassionDay );

			m_BOBFilter.Serialize( writer );

			bool useMods = ( m_HairModID != -1 || m_BeardModID != -1 );

			writer.Write( useMods );

			if ( useMods )
			{
				writer.Write( (int) m_HairModID );
				writer.Write( (int) m_HairModHue );
				writer.Write( (int) m_BeardModID );
				writer.Write( (int) m_BeardModHue );
			}

			writer.Write( SavagePaintExpiration );

			writer.Write( (int) m_NpcGuild );
			writer.Write( (DateTime) m_NpcGuildJoinTime );
			writer.Write( (TimeSpan) m_NpcGuildGameTime );

			writer.Write( m_PermaFlags, true );

			writer.Write( NextTailorBulkOrder );

			writer.Write( NextSmithBulkOrder );

			writer.WriteDeltaTime( m_LastJusticeLoss );
			writer.Write( m_JusticeProtectors, true );

			writer.WriteDeltaTime( m_LastSacrificeGain );
			writer.WriteDeltaTime( m_LastSacrificeLoss );
			writer.Write( m_AvailableResurrects );

			writer.Write( (int) m_Flags );

			writer.Write( m_LongTermElapse );
			writer.Write( m_ShortTermElapse );
			writer.Write( this.GameTime );
		}



		public static void CheckAtrophies( Mobile m )
		{
			SacrificeVirtue.CheckAtrophy( m );
			JusticeVirtue.CheckAtrophy( m );
			CompassionVirtue.CheckAtrophy( m );
			ValorVirtue.CheckAtrophy( m );
			HonorVirtue.CheckAtrophy( m );

			if( m is PlayerMobile )
				ChampionTitleInfo.CheckAtrophy( (PlayerMobile)m );
		}

		public void ResetKillTime()
		{
			m_ShortTermElapse = this.GameTime + TimeSpan.FromHours( 8 );
			m_LongTermElapse = this.GameTime + TimeSpan.FromHours( 40 );
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public DateTime SessionStart
		{
			get{ return m_SessionStart; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public TimeSpan GameTime
		{
			get
			{
				if ( NetState != null )
					return m_GameTime + (DateTime.Now - m_SessionStart);
				else
					return m_GameTime;
			}
		}

		public override bool CanSee( Mobile m )
		{
			if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
				return true;

			return base.CanSee( m );
		}

		public override bool CanSee( Item item )
		{
			if ( m_DesignContext != null && m_DesignContext.Foundation.IsHiddenToCustomizer( item ) )
				return false;

			return base.CanSee( item );
		}

		public override void OnAfterDelete()
		{
			base.OnAfterDelete();

			Faction faction = Faction.Find( this );

			if ( faction != null )
				faction.RemoveMember( this );

			BaseHouse.HandleDeletion( this );
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

			if ( Map == Faction.Facet )
			{
				PlayerState pl = PlayerState.Find( this );

				if ( pl != null )
				{
					Faction faction = pl.Faction;

					if ( faction.Commander == this )
						list.Add( 1042733, faction.Definition.PropName ); // Commanding Lord of the ~1_FACTION_NAME~
					else if ( pl.Sheriff != null )
						list.Add( 1042734, "{0}\t{1}", pl.Sheriff.Definition.FriendlyName, faction.Definition.PropName ); // The Sheriff of  ~1_CITY~, ~2_FACTION_NAME~
					else if ( pl.Finance != null )
						list.Add( 1042735, "{0}\t{1}", pl.Finance.Definition.FriendlyName, faction.Definition.PropName ); // The Finance Minister of ~1_CITY~, ~2_FACTION_NAME~
					else if ( pl.MerchantTitle != MerchantTitle.None )
						list.Add( 1060776, "{0}\t{1}", MerchantTitles.GetInfo( pl.MerchantTitle ).Title, faction.Definition.PropName ); // ~1_val~, ~2_val~
					else
						list.Add( 1060776, "{0}\t{1}", pl.Rank.Title, faction.Definition.PropName ); // ~1_val~, ~2_val~
				}
			}
		}

		public override void OnSingleClick( Mobile from )
		{
			if ( Map == Faction.Facet )
			{
				PlayerState pl = PlayerState.Find( this );

				if ( pl != null )
				{
					string text;
					bool ascii = false;

					Faction faction = pl.Faction;

					if ( faction.Commander == this )
						text = String.Concat( this.Female ? "(Commanding Lady of the " : "(Commanding Lord of the ", faction.Definition.FriendlyName, ")" );
					else if ( pl.Sheriff != null )
						text = String.Concat( "(The Sheriff of ", pl.Sheriff.Definition.FriendlyName, ", ", faction.Definition.FriendlyName, ")" );
					else if ( pl.Finance != null )
						text = String.Concat( "(The Finance Minister of ", pl.Finance.Definition.FriendlyName, ", ", faction.Definition.FriendlyName, ")" );
					else
					{
						ascii = true;

						if ( pl.MerchantTitle != MerchantTitle.None )
							text = String.Concat( "(", MerchantTitles.GetInfo( pl.MerchantTitle ).Title.String, ", ", faction.Definition.FriendlyName, ")" );
						else
							text = String.Concat( "(", pl.Rank.Title.String, ", ", faction.Definition.FriendlyName, ")" );
					}

					int hue = ( Faction.Find( from ) == faction ? 98 : 38 );

					PrivateOverheadMessage( MessageType.Label, hue, ascii, text, from.NetState );
				}
			}

			base.OnSingleClick( from );
		}

		protected override bool OnMove( Direction d )
		{
			if( !Core.SE )
				return base.OnMove( d );

			if( AccessLevel != AccessLevel.Player )
				return true;

			if( Hidden && DesignContext.Find( this ) == null )	//Hidden & NOT customizing a house
			{
				if( !Mounted && Skills.Stealth.Value >= 25.0 )
				{
					bool running = (d & Direction.Running) != 0;

					if( running )
					{
						if( (AllowedStealthSteps -= 2) <= 0 )
							RevealingAction();
					}
					else if( AllowedStealthSteps-- <= 0 )
					{
						Server.SkillHandlers.Stealth.OnUse( this );
					}			
				}
				else
				{
					RevealingAction();
				}
			}

			return true;
		}

		private bool m_BedrollLogout;

		public bool BedrollLogout
		{
			get{ return m_BedrollLogout; }
			set{ m_BedrollLogout = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public override bool Paralyzed
		{
			get
			{
				return base.Paralyzed;
			}
			set
			{
				base.Paralyzed = value;

				if( value )
					AddBuff( new BuffInfo( BuffIcon.Paralyze, 1075827 ) );	//Paralyze/You are frozen and can not move
				else
					RemoveBuff( BuffIcon.Paralyze );
			}
		}

		#region Ethics
		private Ethics.Player m_EthicPlayer;

		[CommandProperty( AccessLevel.GameMaster )]
		public Ethics.Player EthicPlayer
		{
			get { return m_EthicPlayer; }
			set { m_EthicPlayer = value; }
		}
		#endregion

		#region Factions
		private PlayerState m_FactionPlayerState;

		public PlayerState FactionPlayerState
		{
			get{ return m_FactionPlayerState; }
			set{ m_FactionPlayerState = value; }
		}
		#endregion

		#region Quests
		private QuestSystem m_Quest;
		private List<QuestRestartInfo> m_DoneQuests;
		private SolenFriendship m_SolenFriendship;

		public QuestSystem Quest
		{
			get{ return m_Quest; }
			set{ m_Quest = value; }
		}

		public List<QuestRestartInfo> DoneQuests
		{
			get{ return m_DoneQuests; }
			set{ m_DoneQuests = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public SolenFriendship SolenFriendship
		{
			get{ return m_SolenFriendship; }
			set{ m_SolenFriendship = value; }
		}
		#endregion

		#region MyRunUO Invalidation
		private bool m_ChangedMyRunUO;

		public bool ChangedMyRunUO
		{
			get{ return m_ChangedMyRunUO; }
			set{ m_ChangedMyRunUO = value; }
		}

		public void InvalidateMyRunUO()
		{
			if ( !Deleted && !m_ChangedMyRunUO )
			{
				m_ChangedMyRunUO = true;
				Engines.MyRunUO.MyRunUO.QueueMobileUpdate( this );
			}
		}

		public override void OnKillsChange( int oldValue )
		{
			if ( this.Young && this.Kills > oldValue )
			{
				Account acc = this.Account as Account;

				if ( acc != null )
					acc.RemoveYoungStatus( 0 );
			}

			InvalidateMyRunUO();
		}

		public override void OnGenderChanged( bool oldFemale )
		{
			InvalidateMyRunUO();
		}

		public override void OnGuildChange( Server.Guilds.BaseGuild oldGuild )
		{
			InvalidateMyRunUO();
		}

		public override void OnGuildTitleChange( string oldTitle )
		{
			InvalidateMyRunUO();
		}

		public override void OnKarmaChange( int oldValue )
		{
			InvalidateMyRunUO();
		}

		public override void OnFameChange( int oldValue )
		{
			InvalidateMyRunUO();
		}

		public override void OnSkillChange( SkillName skill, double oldBase )
		{
			if ( this.Young && this.SkillsTotal >= 4500 )
			{
				Account acc = this.Account as Account;

				if ( acc != null )
					acc.RemoveYoungStatus( 1019036 ); // You have successfully obtained a respectable skill level, and have outgrown your status as a young player!
			}

			InvalidateMyRunUO();
		}

		public override void OnAccessLevelChanged( AccessLevel oldLevel )
		{
			InvalidateMyRunUO();
		}

		public override void OnRawStatChange( StatType stat, int oldValue )
		{
			InvalidateMyRunUO();
		}

		public override void OnDelete()
		{
			if ( m_ReceivedHonorContext != null )
				m_ReceivedHonorContext.Cancel();
			if ( m_SentHonorContext != null )
				m_SentHonorContext.Cancel();

			InvalidateMyRunUO();
		}
		#endregion

		#region Fastwalk Prevention
		private static bool FastwalkPrevention = true; // Is fastwalk prevention enabled?
		private static TimeSpan FastwalkThreshold = TimeSpan.FromSeconds( 0.4 ); // Fastwalk prevention will become active after 0.4 seconds

		private DateTime m_NextMovementTime;

		public virtual bool UsesFastwalkPrevention{ get{ return ( AccessLevel < AccessLevel.Counselor ); } }

		public override TimeSpan ComputeMovementSpeed( Direction dir, bool checkTurning )
		{
			if ( checkTurning && (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
				return TimeSpan.FromSeconds( 0.1 );	// We are NOT actually moving (just a direction change)

			bool running = ( (dir & Direction.Running) != 0 );

			bool onHorse = ( this.Mount != null );

			AnimalFormContext context = AnimalForm.GetContext( this );

			if ( onHorse || (context != null && context.SpeedBoost) )
				return ( running ? Mobile.RunMount : Mobile.WalkMount );

			return ( running ? Mobile.RunFoot : Mobile.WalkFoot );
		}

		public static bool MovementThrottle_Callback( NetState ns )
		{
			PlayerMobile pm = ns.Mobile as PlayerMobile;

			if ( pm == null || !pm.UsesFastwalkPrevention )
				return true;

			if ( pm.m_NextMovementTime == DateTime.MinValue )
			{
				// has not yet moved
				pm.m_NextMovementTime = DateTime.Now;
				return true;
			}

			TimeSpan ts = pm.m_NextMovementTime - DateTime.Now;

			if ( ts < TimeSpan.Zero )
			{
				// been a while since we've last moved
				pm.m_NextMovementTime = DateTime.Now;
				return true;
			}

			return ( ts < FastwalkThreshold );
		}
		#endregion

		#region Enemy of One
		private Type m_EnemyOfOneType;
		private bool m_WaitingForEnemy;

		public Type EnemyOfOneType
		{
			get{ return m_EnemyOfOneType; }
			set
			{
				Type oldType = m_EnemyOfOneType;
				Type newType = value;

				if ( oldType == newType )
					return;

				m_EnemyOfOneType = value;

				DeltaEnemies( oldType, newType );
			}
		}

		public bool WaitingForEnemy
		{
			get{ return m_WaitingForEnemy; }
			set{ m_WaitingForEnemy = value; }
		}

		private void DeltaEnemies( Type oldType, Type newType )
		{
			foreach ( Mobile m in this.GetMobilesInRange( 18 ) )
			{
				Type t = m.GetType();

				if ( t == oldType || t == newType )
					Send( new MobileMoving( m, Notoriety.Compute( this, m ) ) );
			}
		}
		#endregion

		#region Hair and beard mods
		private int m_HairModID = -1, m_HairModHue;
		private int m_BeardModID = -1, m_BeardModHue;

		public void SetHairMods( int hairID, int beardID )
		{
			if ( hairID == -1 )
				InternalRestoreHair( true, ref m_HairModID, ref m_HairModHue );
			else if ( hairID != -2 )
				InternalChangeHair( true, hairID, ref m_HairModID, ref m_HairModHue );

			if ( beardID == -1 )
				InternalRestoreHair( false, ref m_BeardModID, ref m_BeardModHue );
			else if ( beardID != -2 )
				InternalChangeHair( false, beardID, ref m_BeardModID, ref m_BeardModHue );
		}

		private void CreateHair( bool hair, int id, int hue )
		{
			if( hair )
			{
				//TODO Verification?
				HairItemID = id;
				HairHue = hue;
			}
			else
			{
				FacialHairItemID = id;
				FacialHairHue = hue;
			}
		}

		private void InternalRestoreHair( bool hair, ref int id, ref int hue )
		{
			if ( id == -1 )
				return;

			if ( hair )
				HairItemID = 0;
			else
				FacialHairItemID = 0;

			//if( id != 0 )
			CreateHair( hair, id, hue );

			id = -1;
			hue = 0;
		}

		private void InternalChangeHair( bool hair, int id, ref int storeID, ref int storeHue )
		{
    		if ( storeID == -1 )
    		{
        		storeID = hair ? HairItemID : FacialHairItemID;
        		storeHue = hair ? HairHue : FacialHairHue;
    		}
    		CreateHair( hair, id, 0 );
		}
		#endregion

		#region Virtues
		private DateTime m_LastSacrificeGain;
		private DateTime m_LastSacrificeLoss;
		private int m_AvailableResurrects;

		public DateTime LastSacrificeGain{ get{ return m_LastSacrificeGain; } set{ m_LastSacrificeGain = value; } }
		public DateTime LastSacrificeLoss{ get{ return m_LastSacrificeLoss; } set{ m_LastSacrificeLoss = value; } }
		public int AvailableResurrects{ get{ return m_AvailableResurrects; } set{ m_AvailableResurrects = value; } }

		private DateTime m_NextJustAward;
		private DateTime m_LastJusticeLoss;
		private List<Mobile> m_JusticeProtectors;

		public DateTime LastJusticeLoss{ get{ return m_LastJusticeLoss; } set{ m_LastJusticeLoss = value; } }
		public List<Mobile> JusticeProtectors { get { return m_JusticeProtectors; } set { m_JusticeProtectors = value; } }

		private DateTime m_LastCompassionLoss;
		private DateTime m_NextCompassionDay;
		private int m_CompassionGains;

		public DateTime LastCompassionLoss{ get{ return m_LastCompassionLoss; } set{ m_LastCompassionLoss = value; } }
		public DateTime NextCompassionDay{ get{ return m_NextCompassionDay; } set{ m_NextCompassionDay = value; } }
		public int CompassionGains{ get{ return m_CompassionGains; } set{ m_CompassionGains = value; } }

		private DateTime m_LastValorLoss;

		public DateTime LastValorLoss { get { return m_LastValorLoss; } set { m_LastValorLoss = value; } }

		private DateTime m_LastHonorLoss;
		private DateTime m_LastHonorUse;
		private bool m_HonorActive;
		private HonorContext m_ReceivedHonorContext;
		private HonorContext m_SentHonorContext;

		public DateTime LastHonorLoss{ get{ return m_LastHonorLoss; } set{ m_LastHonorLoss = value; } }
		public DateTime LastHonorUse{ get{ return m_LastHonorUse; } set{ m_LastHonorUse = value; } }
		public bool HonorActive{ get{ return m_HonorActive; } set{ m_HonorActive = value; } }
		public HonorContext ReceivedHonorContext{ get{ return m_ReceivedHonorContext; } set{ m_ReceivedHonorContext = value; } }
		public HonorContext SentHonorContext{ get{ return m_SentHonorContext; } set{ m_SentHonorContext = value; } }
		#endregion

		#region Young system
		[CommandProperty( AccessLevel.GameMaster )]
		public bool Young
		{
			get{ return GetFlag( PlayerFlag.Young ); }
			set{ SetFlag( PlayerFlag.Young, value ); InvalidateProperties(); }
		}

		public override string ApplyNameSuffix( string suffix )
		{
			if ( Young )
			{
				if ( suffix.Length == 0 )
					suffix = "(Young)";
				else
					suffix = String.Concat( suffix, " (Young)" );
			}

			#region Ethics
			if ( m_EthicPlayer != null )
			{
				if ( suffix.Length == 0 )
					suffix = m_EthicPlayer.Ethic.Definition.Adjunct.String;
				else
					suffix = String.Concat( suffix, " ", m_EthicPlayer.Ethic.Definition.Adjunct.String );
			}
			#endregion

			return base.ApplyNameSuffix( suffix );
		}


		public override TimeSpan GetLogoutDelay()
		{
			if ( Young || BedrollLogout || TestCenter.Enabled )
				return TimeSpan.Zero;

			return base.GetLogoutDelay();
		}

		private DateTime m_LastYoungMessage = DateTime.MinValue;

		public bool CheckYoungProtection( Mobile from )
		{
			if ( !this.Young )
				return false;

			if ( Region.IsPartOf( typeof( DungeonRegion ) ) )
				return false;

			if( from is BaseCreature && ((BaseCreature)from).IgnoreYoungProtection )
				return false;

			if ( this.Quest != null && this.Quest.IgnoreYoungProtection( from ) )
				return false;

			if ( DateTime.Now - m_LastYoungMessage > TimeSpan.FromMinutes( 1.0 ) )
			{
				m_LastYoungMessage = DateTime.Now;
				SendLocalizedMessage( 1019067 ); // A monster looks at you menacingly but does not attack.  You would be under attack now if not for your status as a new citizen of Britannia.
			}

			return true;
		}

		private DateTime m_LastYoungHeal = DateTime.MinValue;

		public bool CheckYoungHealTime()
		{
			if ( DateTime.Now - m_LastYoungHeal > TimeSpan.FromMinutes( 5.0 ) )
			{
				m_LastYoungHeal = DateTime.Now;
				return true;
			}

			return false;
		}

		private static Point3D[] m_TrammelDeathDestinations = new Point3D[]
			{
				new Point3D( 1481, 1612, 20 ),
				new Point3D( 2708, 2153,  0 ),
				new Point3D( 2249, 1230,  0 ),
				new Point3D( 5197, 3994, 37 ),
				new Point3D( 1412, 3793,  0 ),
				new Point3D( 3688, 2232, 20 ),
				new Point3D( 2578,  604,  0 ),
				new Point3D( 4397, 1089,  0 ),
				new Point3D( 5741, 3218, -2 ),
				new Point3D( 2996, 3441, 15 ),
				new Point3D(  624, 2225,  0 ),
				new Point3D( 1916, 2814,  0 ),
				new Point3D( 2929,  854,  0 ),
				new Point3D(  545,  967,  0 ),
				new Point3D( 3665, 2587,  0 )
			};

		private static Point3D[] m_IlshenarDeathDestinations = new Point3D[]
			{
				new Point3D( 1216,  468, -13 ),
				new Point3D(  723, 1367, -60 ),
				new Point3D(  745,  725, -28 ),
				new Point3D(  281, 1017,   0 ),
				new Point3D(  986, 1011, -32 ),
				new Point3D( 1175, 1287, -30 ),
				new Point3D( 1533, 1341,  -3 ),
				new Point3D(  529,  217, -44 ),
				new Point3D( 1722,  219,  96 )
			};

		private static Point3D[] m_MalasDeathDestinations = new Point3D[]
			{
				new Point3D( 2079, 1376, -70 ),
				new Point3D(  944,  519, -71 )
			};

		private static Point3D[] m_TokunoDeathDestinations = new Point3D[]
			{
				new Point3D( 1166,  801, 27 ),
				new Point3D(  782, 1228, 25 ),
				new Point3D(  268,  624, 15 )
			};

		public bool YoungDeathTeleport()
		{
			if ( this.Region.IsPartOf( typeof( Jail ) )
				|| this.Region.IsPartOf( "Samurai start location" )
				|| this.Region.IsPartOf( "Ninja start location" )
				|| this.Region.IsPartOf( "Ninja cave" ) )
				return false;

			Point3D loc;
			Map map;

			DungeonRegion dungeon = (DungeonRegion) this.Region.GetRegion( typeof( DungeonRegion ) );
			if ( dungeon != null && dungeon.EntranceLocation != Point3D.Zero )
			{
				loc = dungeon.EntranceLocation;
				map = dungeon.EntranceMap;
			}
			else
			{
				loc = this.Location;
				map = this.Map;
			}

			Point3D[] list;

			if ( map == Map.Trammel )
				list = m_TrammelDeathDestinations;
			else if ( map == Map.Ilshenar )
				list = m_IlshenarDeathDestinations;
			else if ( map == Map.Malas )
				list = m_MalasDeathDestinations;
			else if ( map == Map.Tokuno )
				list = m_TokunoDeathDestinations;
			else
				return false;

			Point3D dest = Point3D.Zero;
			int sqDistance = int.MaxValue;

			for ( int i = 0; i < list.Length; i++ )
			{
				Point3D curDest = list[i];

				int width = loc.X - curDest.X;
				int height = loc.Y - curDest.Y;
				int curSqDistance = width * width + height * height;

				if ( curSqDistance < sqDistance )
				{
					dest = curDest;
					sqDistance = curSqDistance;
				}
			}

			this.MoveToWorld( dest, map );
			return true;
		}

		private void SendYoungDeathNotice()
		{
			this.SendGump( new YoungDeathNotice() );
		}
		#endregion

		#region Speech log
		private SpeechLog m_SpeechLog;

		public SpeechLog SpeechLog{ get{ return m_SpeechLog; } }

		public override void OnSpeech( SpeechEventArgs e )
		{
			if ( SpeechLog.Enabled && this.NetState != null )
			{
				if ( m_SpeechLog == null )
					m_SpeechLog = new SpeechLog();

				m_SpeechLog.Add( e.Mobile, e.Speech );
			}
		}
		#endregion

		#region Champion Titles
		[CommandProperty( AccessLevel.GameMaster )]
		public bool DisplayChampionTitle
		{
			get { return GetFlag( PlayerFlag.DisplayChampionTitle ); }
			set { SetFlag( PlayerFlag.DisplayChampionTitle, value ); }
		}

		private ChampionTitleInfo m_ChampionTitles;

		[CommandProperty( AccessLevel.GameMaster )]
		public ChampionTitleInfo ChampionTitles { get { return m_ChampionTitles; } set { } }

		private void ToggleChampionTitleDisplay()
		{
			if( !CheckAlive() )
				return;

			if( DisplayChampionTitle )
				SendLocalizedMessage( 1062419, "", 0x23 ); // You have chosen to hide your monster kill title.
			else
				SendLocalizedMessage( 1062418, "", 0x23 ); // You have chosen to display your monster kill title.

			DisplayChampionTitle = !DisplayChampionTitle;
		}

		[PropertyObject]
		public class ChampionTitleInfo
		{
			public static TimeSpan LossDelay = TimeSpan.FromDays( 1.0 );
			public const int LossAmount = 90;

			private class TitleInfo
			{
				private int m_Value;
				private DateTime m_LastDecay;

				public int Value { get { return m_Value; } set { m_Value = value; } }
				public DateTime LastDecay { get { return m_LastDecay; } set { m_LastDecay = value; } }

				public TitleInfo()
				{
				}

				public TitleInfo( GenericReader reader )
				{
					int version = reader.ReadEncodedInt();

					switch( version )
					{
						case 0:
						{
							m_Value = reader.ReadEncodedInt();
							m_LastDecay = reader.ReadDateTime();
							break;
						}
					}
				}

				public static void Serialize( GenericWriter writer, TitleInfo info )
				{
					writer.WriteEncodedInt( (int)0 ); // version

					writer.WriteEncodedInt( info.m_Value );
					writer.Write( info.m_LastDecay );
				}

			}
			private TitleInfo[] m_Values;

			private int m_Harrower;	//Harrower titles do NOT decay


			public int GetValue( ChampionSpawnType type )
			{
				return GetValue( (int)type );
			}

			public void SetValue( ChampionSpawnType type, int value )
			{
				SetValue( (int)type, value );
			}

			public void Award( ChampionSpawnType type, int value )
			{
				Award( (int)type, value );
			}

			public int GetValue( int index )
			{
				if( m_Values == null || index < 0 || index >= m_Values.Length )
					return 0;

				if( m_Values[index] == null )
					m_Values[index] = new TitleInfo();

				return m_Values[index].Value;
			}

			public DateTime GetLastDecay( int index )
			{
				if( m_Values == null || index < 0 || index >= m_Values.Length )
					return DateTime.MinValue;

				if( m_Values[index] == null )
					m_Values[index] = new TitleInfo();

				return m_Values[index].LastDecay;
			}

			public void SetValue( int index, int value )
			{
				if( m_Values == null )
					m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

				if( value < 0 )
					value = 0;

				if( index < 0 || index >= m_Values.Length )
					return;

				if( m_Values[index] == null )
					m_Values[index] = new TitleInfo();

				m_Values[index].Value = value;
			}

			public void Award( int index, int value )
			{
				if( m_Values == null )
					m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

				if( index < 0 || index >= m_Values.Length || value <= 0 )
					return;

				if( m_Values[index] == null )
					m_Values[index] = new TitleInfo();

				m_Values[index].Value += value;
			}

			public void Atrophy( int index, int value )
			{
				if( m_Values == null )
					m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

				if( index < 0 || index >= m_Values.Length || value <= 0 )
					return;

				if( m_Values[index] == null )
					m_Values[index] = new TitleInfo();

				int before = m_Values[index].Value;

				if( (m_Values[index].Value - value) < 0 )
					m_Values[index].Value = 0;
				else
					m_Values[index].Value -= value;

				if( before != m_Values[index].Value )
					m_Values[index].LastDecay = DateTime.Now;
			}

			public override string ToString()
			{
				return "...";
			}

			[CommandProperty( AccessLevel.GameMaster )]
			public int Abyss { get { return GetValue( ChampionSpawnType.Abyss ); } set { SetValue( ChampionSpawnType.Abyss, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int Arachnid { get { return GetValue( ChampionSpawnType.Arachnid ); } set { SetValue( ChampionSpawnType.Arachnid, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int ColdBlood { get { return GetValue( ChampionSpawnType.ColdBlood ); } set { SetValue( ChampionSpawnType.ColdBlood, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int ForestLord { get { return GetValue( ChampionSpawnType.ForestLord ); } set { SetValue( ChampionSpawnType.ForestLord, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int SleepingDragon { get { return GetValue( ChampionSpawnType.SleepingDragon ); } set { SetValue( ChampionSpawnType.SleepingDragon, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int UnholyTerror { get { return GetValue( ChampionSpawnType.UnholyTerror ); } set { SetValue( ChampionSpawnType.UnholyTerror, value ); } }

			[CommandProperty( AccessLevel.GameMaster )]
			public int VerminHorde { get { return GetValue( ChampionSpawnType.VerminHorde ); } set { SetValue( ChampionSpawnType.VerminHorde, value ); } }
			
			[CommandProperty( AccessLevel.GameMaster )]
			public int Harrower { get { return m_Harrower; } set { m_Harrower = value; } }

			public ChampionTitleInfo()
			{
			}

			public ChampionTitleInfo( GenericReader reader )
			{
				int version = reader.ReadEncodedInt();

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

						int length = reader.ReadEncodedInt();
						m_Values = new TitleInfo[length];

						for( int i = 0; i < length; i++ )
						{
							m_Values[i] = new TitleInfo( reader );
						}

						if( m_Values.Length != ChampionSpawnInfo.Table.Length )
						{
							TitleInfo[] oldValues = m_Values;
							m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

							for( int i = 0; i < m_Values.Length && i < oldValues.Length; i++ )
							{
								m_Values[i] = oldValues[i];
							}
						}
						break;
					}
				}
			}

			public static void Serialize( GenericWriter writer, ChampionTitleInfo titles )
			{
				writer.WriteEncodedInt( (int)0 ); // version

				writer.WriteEncodedInt( titles.m_Harrower );

				int length = titles.m_Values.Length;
				writer.WriteEncodedInt( length );

				for( int i = 0; i < length; i++ )
				{
					if( titles.m_Values[i] == null )
						titles.m_Values[i] = new TitleInfo();

					TitleInfo.Serialize( writer, titles.m_Values[i] );
				}
			}

			public static void CheckAtrophy( PlayerMobile pm )
			{
				ChampionTitleInfo t = pm.m_ChampionTitles;
				if( t == null )
					return;

				if( t.m_Values == null )
					t.m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

				for( int i = 0; i < t.m_Values.Length; i++ )
				{
					if( (t.GetLastDecay( i ) + LossDelay) < DateTime.Now )
					{
						t.Atrophy( i, LossAmount );
					}
				}
			}

			public static void AwardHarrowerTitle( PlayerMobile pm )	//Called when killing a harrower.  Will give a minimum of 1 point.
			{
				ChampionTitleInfo t = pm.m_ChampionTitles;
				if( t == null )
					return;

				if( t.m_Values == null )
					t.m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length];

				int count = 1;

				for( int i = 0; i < t.m_Values.Length; i++ )
				{
					if( t.m_Values[i].Value > 900 )
						count++;
				}

				t.m_Harrower = Math.Max( count, t.m_Harrower );	//Harrower titles never decay.
			}
		}
		#endregion

		#region Recipes

		private Dictionary<int, bool> m_AcquiredRecipes;
		
		public virtual bool HasRecipe( Recipe r )
		{
			if( r == null ) 
				return false;

			return HasRecipe( r.ID );
		}

		public virtual bool HasRecipe( int recipeID )
		{
			if( m_AcquiredRecipes != null && m_AcquiredRecipes.ContainsKey( recipeID ) )
				return m_AcquiredRecipes[recipeID];

			return false;
		}

		public virtual void AcquireRecipe( int recipeID )
		{
			if( m_AcquiredRecipes == null )
				m_AcquiredRecipes = new Dictionary<int, bool>();

			m_AcquiredRecipes.Add( recipeID, true );
		}

		public virtual void AcquireRecipe( Recipe r )
		{
			if( r != null )
				AcquireRecipe( r.ID );
		}

		public virtual void ResetRecipes()
		{
			m_AcquiredRecipes = null;
		}
	
		[CommandProperty( AccessLevel.GameMaster )]
		public int KnownRecipes
		{
			get 
			{
				if( m_AcquiredRecipes == null )
					return 0;

				return m_AcquiredRecipes.Count;
			}
		}
	

		#endregion

		#region Buff Icons

		public void ResendBuffs()
		{
			if( !BuffInfo.Enabled || m_BuffTable == null )
				return;

			NetState state = this.NetState;

			if( state != null && state.Version >= BuffInfo.RequiredClient )
			{
				foreach( BuffInfo info in m_BuffTable.Values )
				{
					state.Send( new AddBuffPacket( this, info ) );
				}
			}
		}

		private Dictionary<BuffIcon, BuffInfo> m_BuffTable;

		public void AddBuff( BuffInfo b )
		{
			if( !BuffInfo.Enabled || b == null )
				return;

			RemoveBuff( b );	//Check & subsequently remove the old one.

			if( m_BuffTable == null )
				m_BuffTable = new Dictionary<BuffIcon, BuffInfo>();

			m_BuffTable.Add( b.ID, b );

			NetState state = this.NetState;

			if( state != null && state.Version >= BuffInfo.RequiredClient )
			{
				state.Send( new AddBuffPacket( this, b ) );
			}
		}

		public void RemoveBuff( BuffInfo b )
		{
			if( b == null )
				return;

			RemoveBuff( b.ID );
		}

		public void RemoveBuff( BuffIcon b )
		{
			if( m_BuffTable == null || !m_BuffTable.ContainsKey( b ) )
				return;

			BuffInfo info = m_BuffTable[b];

			if( info.Timer != null && info.Timer.Running )
				info.Timer.Stop();

			m_BuffTable.Remove( b );

			NetState state = this.NetState;

			if( state != null && state.Version >= BuffInfo.RequiredClient )
			{
				state.Send( new RemoveBuffPacket( this, b ) );
			}

			if( m_BuffTable.Count <= 0 )
				m_BuffTable = null;
		}
		#endregion
	}
}
 

soccerty629

Wanderer
can some one help me with this please?

I am getting this error can some one help me plplease
RunUO - [www.runuo.com] Version 2.0, Build 2357.32527
Core: Running on .NET Framework Version 2.0.50727
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
+ Custom/Challenge Game 1.1.1/ChallengeStone.cs:
CS0234: Line 4: The type or namespace name 'Scripts' does not exist in the n
amespace 'Server' (are you missing an assembly reference?)
CS0246: Line 79: The type or namespace name 'CommandEventArgs' could not be
found (are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.:confused: :(
 

vash88

Wanderer
errors with ChallengeStone.cs

hey when i put this script in it gives me these errors can some on e help me with this please?:confused:
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
+ Custom/Challenge Game 1.1.1/ChallengeStone.cs:
CS0234: Line 4: The type or namespace name 'Scripts' does not exist in the n
amespace 'Server' (are you missing an assembly reference?)
CS0246: Line 79: The type or namespace name 'CommandEventArgs' could not be
found (are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Top