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!

BaseQuest System

Broadside

Wanderer
One Error is all i get. Anyone know what i have to do i cannot figure it out.

-Error: Scripts\Engines\Quests\Ambitious Quest\Misc\BagSending.cs: CS0101: (line 9, column 17) The namespace 'Server.Items' already contains a definition for 'BagofSending' :(
 

Phantom

Knight
Broadside said:
One Error is all i get. Anyone know what i have to do i cannot figure it out.

-Error: Scripts\Engines\Quests\Ambitious Quest\Misc\BagSending.cs: CS0101: (line 9, column 17) The namespace 'Server.Items' already contains a definition for 'BagofSending' :(

You already have a class called BagofSending either rename it or get rid of your old one.

You do know this system is not supported right, considering the current version of RunUO has a quest system already by default.

So this script is utterly pointless and only fools would use it?
 

Phantom

Knight
Broadside said:
I have RunUO 1.0 And there is no quests in it at all? Anyways my server is screwed i tried to say to hell with it and dump the quest files interupting it but the errors keep adding up. Is there a upgrade to RunUO i do not know about? If so can i Upgrade my server and players will still have all their stuff including house, players, account etc. etc. :confused: Oh Yes I am new at this but am good at catchin on to stuff but damn this has got me stumped.

I don't know what to say the Beta 36 and rc0 had the quest system.

Of course we only support rc0
 

Broadside

Wanderer
I had to delete alot and change a bunch but managed to get my server back and running. I am pumped for this script to work but not sure i am ready to wrestle this one...
 

jfy260336

Wanderer
help for PlayerMobile.cs

Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.net scripts...no files found.
Scripts: Verifying...done (1566 items, 426 mobiles)
World: Loading...An error was encountered while loading a saved object
- Type: Server.Mobiles.AntLion
- Serial: 0x000062B6
Delete the object? (y/n)
y
Delete all objects of that type? (y/n)
y
After pressing return an exception will be thrown and the server will terminate

Error:
System.Exception: Load failed (items=False, mobiles=True, guilds=False, regions=
False, type=Server.Mobiles.AntLion, serial=0x000062B6) ---> System.Exception: **
*** Bad serialize on Server.Mobiles.AntLion *****
at Server.World.Load()
--- **************** ---
at Server.World.Load()
at Server.ScriptCompiler.Compile(Boolean debug)
at Server.Core.Main(String[] args)
This exception is fatal, press return to exit

MY PLAYERMOBILE.CS

Code:
using System;
using System;
using System.Collections;
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.Seventh;
using Server.Targeting;
using Server.Engines.Quests;

namespace Server.Mobiles
{
	[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
	}

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

		public enum SolenFriend 
		{ 
			None, Black, Red 
		}

	public class PlayerMobile : Mobile
	{
		// --- Start Quest Property --- //

		private BaseQuest m_CurrentQuest;
		public DateTime m_QuestRestartTime;
		private SolenFriend m_SolenFriend = SolenFriend.None;

		// --- Stop Quest Property --- //

			// --- Start Quest Property Method --- //

		public BaseQuest CurrentQuest
		{
			get { return m_CurrentQuest; }
			set { m_CurrentQuest = value; }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool CanStartNewQuest
		{
			get
			{
				if ( DateTime.Now > m_QuestRestartTime && Quest == null )
					return true;
				else
					return false;
			}
		}

		[CommandProperty( AccessLevel.GameMaster )] 
		public SolenFriend SolenFriendship 
		{ 
			get { return m_SolenFriend; } 
			set { m_SolenFriend = value; } 
		}

		// --- Stop Quest Property Method --- //	
		
		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;

		[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 TimeSpan NpcGuildGameTime
		{
			get{ return m_NpcGuildGameTime; }
			set{ m_NpcGuildGameTime = value; }
		}

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

		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;

			return max;
		}

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

			SacrificeVirtue.CheckAtrophy( from );
			JusticeVirtue.CheckAtrophy( from );
			CompassionVirtue.CheckAtrophy( 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;

				ArrayList items = this.Items;

				if ( items == null )
					return;

				bool moved = false;

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

				Mobile from = this;

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

					Item item = (Item)items[i];

					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;

						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.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
						{
							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;
						}
					}
				}

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

		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 client from house
				 */

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

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

				from.MoveToWorld( context.Foundation.BanLocation, context.Foundation.Map );
			}

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

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

			Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

			base.RevealingAction();
		}

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

			InvalidateMyRunUO();
		}

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

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

			InvalidateMyRunUO();
		}

		public override int HitsMax
		{
			get
			{
				int strBase;
				int strOffs = GetStatOffset( StatType.Str );

				if ( Core.AOS )
				{
					strBase = this.Str;
					strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
				}
				else
				{
					strBase = this.RawStr;
				}

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

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

		public override int ManaMax
		{
			get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
		}

		public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				Gump[] gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Length; ++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 );

			if ( !base.Move( d ) )
				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 );

			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 override bool AllowSkillUse( SkillName skill )
		{
			return DesignContext.Check( this );
		}

		private bool m_LastProtectedMessage;
		private int m_NextProtectionCheck = 10;

		public virtual void RecheckTownProtection()
		{
			m_NextProtectionCheck = 10;

			Regions.GuardedRegion reg = this.Region as 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 )
		{
			base.SetLocation( loc, isTeleport );

			if ( isTeleport || --m_NextProtectionCheck == 0 )
				RecheckTownProtection();
		}

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

			if ( from == this )
			{
				if ( m_Quest != null )
					m_Quest.GetContextMenuEntries( list );
					
				//added for basequest
				
				if( m_CurrentQuest != null )
				{
					if( !m_CurrentQuest.Deleted )
					{
						list.Add( new QuestLogEntry( from, m_CurrentQuest ) );
						list.Add( new QuestConversationEntry ( from, m_CurrentQuest ) );
						list.Add( new CancelQuestEntry( from, m_CurrentQuest ) );
					}
				}

				//end of added basequest	

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

				// TODO: Toggle champ titles

				BaseHouse house = BaseHouse.FindHouseAt( this );

				if ( house != null && house.IsAosRules )
					list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );

				if ( m_JusticeProtectors.Count > 0 )
					list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
			}
		}

// --- Start Quest Context Menu's --- //

		private class QuestLogEntry : Server.ContextMenus.ContextMenuEntry
		{
			private BaseQuest m_Quest;
			private Mobile m_From;

			public QuestLogEntry( Mobile from, BaseQuest quest ) : base( 6154 )
			{
				m_Quest = quest;
				m_From = from;
			}

			public override void OnClick()
			{
				m_From.SendGump( new Server.Gumps.QuestLogGump( m_Quest ) );
			}
		}

		private class CancelQuestEntry : Server.ContextMenus.ContextMenuEntry
		{
			private BaseQuest m_Quest;
			private Mobile m_From;

			public CancelQuestEntry( Mobile from, BaseQuest quest ) : base( 6155 )
			{
				m_Quest = quest;
				m_From = from;
			}

			public override void OnClick()
			{
				m_From.SendGump( new Server.Gumps.CancelQuestGump( m_Quest ) );
			}
		}

		private class QuestConversationEntry : Server.ContextMenus.ContextMenuEntry
		{
			private BaseQuest m_Quest;
			private Mobile m_From;

			public QuestConversationEntry( Mobile from, BaseQuest quest ) : base( 6156 )
			{
				m_Quest = quest;
				m_From = from;
			}

			public override void OnClick()
			{
				m_From.SendGump( new Server.Gumps.StartQuestGump( m_Quest ) );
			}
		}

// --- Stop Quest Context Menu's --- //

		private void CancelProtection()
		{
			for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
			{
				Mobile prot = (Mobile)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();
		}

		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 )
				return false;

			if ( item is Spellbook || item is Runebook || item is PotionKeg )
				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;

			SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
			AutoRenewInsurance = false;
		}

		// TODO: Champ titles, toggle

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

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

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

		protected override void OnMapChange( Map oldMap )
		{
			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 OnDamage( int amount, Mobile from, bool willKill )
		{
			if ( amount > (Core.AOS ? 25 : 0) )
			{
				BandageContext c = BandageContext.GetContext( this );

				if ( c != null )
					c.Slip();
			}

			WeightOverloading.FatigueOnDamage( this, amount );

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

		public static int ComputeSkillTotal( Mobile m )
		{
			int total = 0;

			for ( int i = 0; i < m.Skills.Length; ++i )
				total += m.Skills[i].BaseFixedPoint;

			return ( total / 10 );
		}

		public override void Resurrect()
		{
			bool wasAlive = this.Alive;

			base.Resurrect();

			if ( this.Alive && !wasAlive )
			{
				Item deathRobe = new DeathRobe();

				if ( !EquipItem( deathRobe ) )
					deathRobe.Delete();
			}
		}

		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 != null && !m_InsuranceAward.Player )
				m_InsuranceAward = null;

			if ( m_InsuranceAward is PlayerMobile )
				((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

			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;

			return base.GetParentMoveResultFor( item );
		}

		public override DeathMoveResult GetInventoryMoveResultFor( Item item )
		{
			if ( CheckInsuranceOnDeath( item ) )
				return DeathMoveResult.MoveToBackpack;

			return base.GetInventoryMoveResultFor( item );
		}

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

			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 != null && m.Player )
				{
					bool gainedPath = false;

					int theirTotal = ComputeSkillTotal( m );
					int ourTotal = ComputeSkillTotal( this );

					int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);

					if ( pointsToGain < 1 )
						pointsToGain = 1;
					else if ( pointsToGain > 4 )
						pointsToGain = 4;

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

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

		private ArrayList m_PermaFlags;
		private ArrayList 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{}
			}
		}

		public DateTime LastEscortTime
		{
			get{ return m_LastEscortTime; }
			set{ m_LastEscortTime = value; }
		}

		public PlayerMobile()
		{
			m_VisList = new ArrayList();
			m_PermaFlags = new ArrayList();
			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 ArrayList();

			InvalidateMyRunUO();
		}

		public override bool MutateSpeech( ArrayList hears, ref string text, ref object context )
		{
			if ( Alive )
				return false;

			if ( Core.AOS )
			{
				for ( int i = 0; i < hears.Count; ++i )
				{
					object o = hears[i];

					if ( o != this && o is Mobile && ((Mobile)o).Skills[SkillName.SpiritSpeak].Value >= 100.0 )
						return false;
				}
			}

			return base.MutateSpeech( hears, ref text, ref context );
		}

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

		public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
		{
			if ( !Alive )
				return ApplyPoisonResult.Immune;

			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
				return base.ApplyPoison( from, PoisonImpl.IncreaseLevel( poison ) );

			return base.ApplyPoison( from, poison );
		}

		public PlayerMobile( Serial s ) : base( s )
		{
			m_VisList = new ArrayList();
			m_AntiMacroTable = new Hashtable();
			InvalidateMyRunUO();
		}

		public ArrayList VisibilityList
		{
			get{ return m_VisList; }
		}

		public ArrayList 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 )
				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 )
		{
		// --- Start Quest Deserialization --- //

		m_SolenFriend = (SolenFriend)reader.ReadInt();
		m_CurrentQuest = (BaseQuest) reader.ReadItem();

		// --- Stop Quest Deserialization --- //
			
			base.Deserialize( reader );
			int version = reader.ReadInt();

			switch ( version )
			{
				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 ArrayList();

						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 )
					{
						ArrayList payed = reader.ReadItemList();

						for ( int i = 0; i < payed.Count; ++i )
							((Item)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.ReadMobileList();
					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.ReadMobileList();
					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;
				}
			}

			if ( m_PermaFlags == null )
				m_PermaFlags = new ArrayList();

			if ( m_JusticeProtectors == null )
				m_JusticeProtectors = new ArrayList();

			if ( m_BOBFilter == null )
				m_BOBFilter = new Engines.BulkOrders.BOBFilter();

			ArrayList list = this.Stabled;

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

				if ( bc != null )
					bc.IsStabled = true;
			}
		}
		
		public override void Serialize( GenericWriter writer )
		{
		// --- Start Quest Serialization --- //

		writer.Write( (int)m_SolenFriend );
		writer.Write( m_CurrentQuest );

		// --- Stop Quest Serialization --- //
			
			//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;
			}

			base.Serialize( writer );
			
			writer.Write( (int) 17 ); // version

			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 = (QuestRestartInfo)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.WriteMobileList( m_PermaFlags, true );

			writer.Write( NextTailorBulkOrder );

			writer.Write( NextSmithBulkOrder );

			writer.WriteDeltaTime( m_LastJusticeLoss );
			writer.WriteMobileList( 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 void ResetKillTime()
		{
			m_ShortTermElapse = this.GameTime + TimeSpan.FromHours( 8 );
			m_LongTermElapse = this.GameTime + TimeSpan.FromHours( 40 );
		}

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

		#region Quest stuff
		private QuestSystem m_Quest;
		private ArrayList m_DoneQuests;

		public QuestSystem Quest
		{
			get{ return m_Quest; }
			set{ m_Quest = value; }
		}

		public ArrayList DoneQuests
		{
			get{ return m_DoneQuests; }
			set{ m_DoneQuests = 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 )
		{
			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 )
		{
			InvalidateMyRunUO();
		}

		public override void OnAccessLevelChanged( AccessLevel oldLevel )
		{
			InvalidateMyRunUO();
		}

		public override void OnRawStatChange( StatType stat, int oldValue )
		{
			InvalidateMyRunUO();
		}

		public override void OnDelete()
		{
			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.GameMaster ); } }

		public virtual TimeSpan ComputeMovementSpeed( Direction dir )
		{
			if ( (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
				return TimeSpan.Zero;

			bool running = ( (dir & Direction.Running) != 0 );

			bool onHorse = ( this.Mount != null );

			if ( onHorse )
				return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );

			return ( running ? TimeSpan.FromSeconds( 0.2 ) : TimeSpan.FromSeconds( 0.4 ) );
		}

		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 Item CreateHair( bool hair, int id, int hue )
		{
			if ( hair )
				return Server.Items.Hair.CreateByID( id, hue );
			else
				return Server.Items.Beard.CreateByID( id, hue );
		}

		private void InternalRestoreHair( bool hair, ref int id, ref int hue )
		{
			if ( id == -1 )
				return;

			Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

			if ( item != null )
				item.Delete();

			if ( id != 0 )
				AddItem( CreateHair( hair, id, hue ) );

			id = -1;
			hue = 0;
		}

		private void InternalChangeHair( bool hair, int id, ref int storeID, ref int storeHue )
		{
			Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

			if ( item != null )
			{
				if ( storeID == -1 )
				{
					storeID = item.ItemID;
					storeHue = item.Hue;
				}

				item.Delete();
			}
			else if ( storeID == -1 )
			{
				storeID = 0;
				storeHue = 0;
			}

			if ( id == 0 )
				return;

			AddItem( CreateHair( hair, id, 0 ) );
		}
		#endregion

		#region Virtue stuff
		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 ArrayList m_JusticeProtectors;

		public DateTime LastJusticeLoss{ get{ return m_LastJusticeLoss; } set{ m_LastJusticeLoss = value; } }
		public ArrayList 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; } }
		#endregion
	}
}
 

Lorryn

Wanderer
I have a slight problem here

Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\AA_Custom\SolenHiveStudyQuest\Naturalist.cs: CS0117: (line 135
, column 91) 'Server.Engines.Plants.PlantHueInfo' does not contain a definition
for 'RandomRare'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.


I am using the Naturalist.cs included in package at 1st post.
Clean test shard install, this system is first custom done to it.

L.
 

blain

Wanderer
dunno what ive done

guess ive done something wrong here are my alterations to the playermobile.cs .. some help would be great .. cheers


Scripts: Compiling C# scripts...failed (46 errors, 0 warnings)
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1513: (line 80, column 4) } expe
cted
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 93, column 4) Invali
d token 'switch' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 93, column 27) Inval
id token '(' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 95, column 34) Inval
id token ';' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 96, column 32) Inval
id token ';' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 97, column 33) Inval
id token ';' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1519: (line 98, column 36) Inval
id token ';' in class, struct, or interface member declaration
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 102, column 17) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 107, column 17) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 112, column 17) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 117, column 17) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 122, column 17) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 159, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 160, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 161, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 162, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 176, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 181, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 186, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1518: (line 191, column 10) Expe
cted class, delegate, enum, interface, or struct
- Error: Scripts\Engines\Plants\PlantHue.cs: CS1022: (line 195, column 2) Type
or namespace definition, or end-of-file expected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1513: (line 884, column 6) } expect
ed
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 945, column 5) Invalid
token 'if' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 945, column 16) Invalid
token '&&' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 945, column 36) Invalid
token ')' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 947, column 14) Invalid
token '(' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 947, column 20) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1031: (line 947, column 35) Type ex
pected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 947, column 45) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1001: (line 947, column 82) Identif
ier expected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1002: (line 947, column 84) ; expec
ted
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 949, column 30) Invalid
token ')' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 950, column 15) Invalid
token '(' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 950, column 21) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1031: (line 950, column 36) Type ex
pected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 950, column 46) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1001: (line 950, column 93) Identif
ier expected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1002: (line 950, column 95) ; expec
ted
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1519: (line 952, column 15) Invalid
token '(' in class, struct, or interface member declaration
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 952, column 21) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1031: (line 952, column 36) Type ex
pected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1520: (line 952, column 46) Class,
struct, or interface method must have a return type
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1001: (line 952, column 91) Identif
ier expected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1002: (line 952, column 93) ; expec
ted
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0116: (line 957, column 5) A namesp
ace does not directly contain members such as fields or methods
- Error: Scripts\Mobiles\PlayerMobile.cs: CS1022: (line 965, column 3) Type or
namespace definition, or end-of-file expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.


Player Mobile

using System;
using System.Collections;
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.Seventh;
using Server.Targeting;
using Server.Engines.Quests;

namespace Server.Mobiles
{
[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
}

public enum SolenFriend
{
None, Black, Red
}

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

public class PlayerMobile : Mobile
{
// --- Start Quest Property --- //

private BaseQuest m_CurrentQuest;
public DateTime m_QuestRestartTime;
private SolenFriend m_SolenFriend = SolenFriend.None;

// --- Stop Quest Property --- //

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;


// --- Start Quest Property Method --- //

public BaseQuest CurrentQuest
{
get { return m_CurrentQuest; }
set { m_CurrentQuest = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public bool CanStartNewQuest
{
get
{
if ( DateTime.Now > m_QuestRestartTime && Quest == null )
return true;
else
return false;
}
}

[CommandProperty( AccessLevel.GameMaster )]
public SolenFriend SolenFriendship
{
get { return m_SolenFriend; }
set { m_SolenFriend = value; }
}

// --- Stop Quest Property Method --- //

[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 TimeSpan NpcGuildGameTime
{
get{ return m_NpcGuildGameTime; }
set{ m_NpcGuildGameTime = value; }
}

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

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;

return max;
}

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

SacrificeVirtue.CheckAtrophy( from );
JusticeVirtue.CheckAtrophy( from );
CompassionVirtue.CheckAtrophy( 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;

ArrayList items = this.Items;

if ( items == null )
return;

bool moved = false;

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

Mobile from = this;

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

Item item = (Item)items;

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;

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.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
{
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;
}
}
}

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

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 client from house
*/

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

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

from.MoveToWorld( context.Foundation.BanLocation, context.Foundation.Map );
}

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

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

Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

base.RevealingAction();
}

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

InvalidateMyRunUO();
}

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

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

InvalidateMyRunUO();
}

public override int HitsMax
{
get
{
int strBase;
int strOffs = GetStatOffset( StatType.Str );

if ( Core.AOS )
{
strBase = this.Str;
strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
}
else
{
strBase = this.RawStr;
}

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

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

public override int ManaMax
{
get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
}

public override bool Move( Direction d )
{
NetState ns = this.NetState;

if ( ns != null )
{
Gump[] gumps = ns.Gumps;

for ( int i = 0; i < gumps.Length; ++i )
{
if ( gumps is ResurrectGump )
{
if ( Alive )
{
CloseGump( typeof( ResurrectGump ) );
}
else
{
SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
return false;
}
}
}
}

TimeSpan speed = ComputeMovementSpeed( d );

if ( !base.Move( d ) )
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 );

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 override bool AllowSkillUse( SkillName skill )
{
return DesignContext.Check( this );
}

private bool m_LastProtectedMessage;
private int m_NextProtectionCheck = 10;

public virtual void RecheckTownProtection()
{
m_NextProtectionCheck = 10;

Regions.GuardedRegion reg = this.Region as 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 )
{
base.SetLocation( loc, isTeleport );

if ( isTeleport || --m_NextProtectionCheck == 0 )
RecheckTownProtection();
}

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

if ( from == this )
{
if ( m_Quest != null )
m_Quest.GetContextMenuEntries( list );

//added for basequest

if( m_CurrentQuest != null )
{
if( !m_CurrentQuest.Deleted )
{
list.Add( new QuestLogEntry( from, m_CurrentQuest ) );
list.Add( new QuestConversationEntry ( from, m_CurrentQuest ) );
list.Add( new CancelQuestEntry( from, m_CurrentQuest ) );
}
}

//end of added basequest


// --- Start Quest Context Menu's --- //

private class QuestLogEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public QuestLogEntry( Mobile from, BaseQuest quest ) : base( 6154 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.QuestLogGump( m_Quest ) );
}
}

private class CancelQuestEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public CancelQuestEntry( Mobile from, BaseQuest quest ) : base( 6155 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.CancelQuestGump( m_Quest ) );
}
}

private class QuestConversationEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public QuestConversationEntry( Mobile from, BaseQuest quest ) : base( 6156 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.StartQuestGump( m_Quest ) );
}
}

// --- Stop Quest Context Menu's --- //


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

// TODO: Toggle champ titles

BaseHouse house = BaseHouse.FindHouseAt( this );

if ( house != null && house.IsAosRules )
list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );

if ( m_JusticeProtectors.Count > 0 )
list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
}
}

private void CancelProtection()
{
for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
{
Mobile prot = (Mobile)m_JusticeProtectors;

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

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 )
return false;

if ( item is Spellbook || item is Runebook || item is PotionKeg )
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;

SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
AutoRenewInsurance = false;
}

// TODO: Champ titles, toggle

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

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

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

protected override void OnMapChange( Map oldMap )
{
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 OnDamage( int amount, Mobile from, bool willKill )
{
if ( amount > (Core.AOS ? 25 : 0) )
{
BandageContext c = BandageContext.GetContext( this );

if ( c != null )
c.Slip();
}

if (this.Combatant == null || !this.Combatant.Alive || !this.Combatant.InRange( this, 3 ))

this.Combatant = from;

WeightOverloading.FatigueOnDamage( this, amount );

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

public static int ComputeSkillTotal( Mobile m )
{
int total = 0;

for ( int i = 0; i < m.Skills.Length; ++i )
total += m.Skills.BaseFixedPoint;

return ( total / 10 );
}

public override void Resurrect()
{
bool wasAlive = this.Alive;

base.Resurrect();

if ( this.Alive && !wasAlive )
{
Item deathRobe = new DeathRobe();

if ( !EquipItem( deathRobe ) )
deathRobe.Delete();
}
}

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 != null && !m_InsuranceAward.Player )
m_InsuranceAward = null;

if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

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;

return base.GetParentMoveResultFor( item );
}

public override DeathMoveResult GetInventoryMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;

return base.GetInventoryMoveResultFor( item );
}

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

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 != null && m.Player )
{
bool gainedPath = false;

int theirTotal = ComputeSkillTotal( m );
int ourTotal = ComputeSkillTotal( this );

int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);

if ( pointsToGain < 1 )
pointsToGain = 1;
else if ( pointsToGain > 4 )
pointsToGain = 4;

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

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

private ArrayList m_PermaFlags;
private ArrayList 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{}
}
}

public DateTime LastEscortTime
{
get{ return m_LastEscortTime; }
set{ m_LastEscortTime = value; }
}

public PlayerMobile()
{
m_VisList = new ArrayList();
m_PermaFlags = new ArrayList();
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 ArrayList();

InvalidateMyRunUO();
}

public override bool MutateSpeech( ArrayList hears, ref string text, ref object context )
{
if ( Alive )
return false;

if ( Core.AOS )
{
for ( int i = 0; i < hears.Count; ++i )
{
object o = hears;

if ( o != this && o is Mobile && ((Mobile)o).Skills[SkillName.SpiritSpeak].Value >= 100.0 )
return false;
}
}

return base.MutateSpeech( hears, ref text, ref context );
}

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

public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
{
if ( !Alive )
return ApplyPoisonResult.Immune;

if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
return base.ApplyPoison( from, PoisonImpl.IncreaseLevel( poison ) );

return base.ApplyPoison( from, poison );
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
InvalidateMyRunUO();
}

public ArrayList VisibilityList
{
get{ return m_VisList; }
}

public ArrayList 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 )
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 18: // changed how DoneQuests is serialized

// --- Start Quest Deserialization --- //
m_SolenFriend = (SolenFriend)reader.ReadInt();
m_CurrentQuest = (BaseQuest) reader.ReadItem();
// --- Stop Quest Deserialization --- //

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

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 )
{
ArrayList payed = reader.ReadItemList();

for ( int i = 0; i < payed.Count; ++i )
((Item)payed).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.ReadMobileList();
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.ReadMobileList();
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;
}
}

if ( m_PermaFlags == null )
m_PermaFlags = new ArrayList();

if ( m_JusticeProtectors == null )
m_JusticeProtectors = new ArrayList();

if ( m_BOBFilter == null )
m_BOBFilter = new Engines.BulkOrders.BOBFilter();

ArrayList list = this.Stabled;

for ( int i = 0; i < list.Count; ++i )
{
BaseCreature bc = list as BaseCreature;

if ( bc != null )
bc.IsStabled = true;
}
}

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

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

base.Serialize( writer );

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


// --- Start Quest Serialization --- //

writer.Write( (int)m_SolenFriend );
writer.Write( m_CurrentQuest );

// --- Stop Quest Serialization --- //


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 = (QuestRestartInfo)m_DoneQuests;

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.WriteMobileList( m_PermaFlags, true );

writer.Write( NextTailorBulkOrder );

writer.Write( NextSmithBulkOrder );

writer.WriteDeltaTime( m_LastJusticeLoss );
writer.WriteMobileList( 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 void ResetKillTime()
{
m_ShortTermElapse = this.GameTime + TimeSpan.FromHours( 8 );
m_LongTermElapse = this.GameTime + TimeSpan.FromHours( 40 );
}

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

#region Quest stuff
private QuestSystem m_Quest;
private ArrayList m_DoneQuests;

public QuestSystem Quest
{
get{ return m_Quest; }
set{ m_Quest = value; }
}

public ArrayList DoneQuests
{
get{ return m_DoneQuests; }
set{ m_DoneQuests = 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 )
{
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 )
{
InvalidateMyRunUO();
}

public override void OnAccessLevelChanged( AccessLevel oldLevel )
{
InvalidateMyRunUO();
}

public override void OnRawStatChange( StatType stat, int oldValue )
{
InvalidateMyRunUO();
}

public override void OnDelete()
{
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.GameMaster ); } }

public virtual TimeSpan ComputeMovementSpeed( Direction dir )
{
if ( (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
return TimeSpan.Zero;

bool running = ( (dir & Direction.Running) != 0 );

bool onHorse = ( this.Mount != null );

if ( onHorse )
return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );

return ( running ? TimeSpan.FromSeconds( 0.2 ) : TimeSpan.FromSeconds( 0.4 ) );
}

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 Item CreateHair( bool hair, int id, int hue )
{
if ( hair )
return Server.Items.Hair.CreateByID( id, hue );
else
return Server.Items.Beard.CreateByID( id, hue );
}

private void InternalRestoreHair( bool hair, ref int id, ref int hue )
{
if ( id == -1 )
return;

Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

if ( item != null )
item.Delete();

if ( id != 0 )
AddItem( CreateHair( hair, id, hue ) );

id = -1;
hue = 0;
}

private void InternalChangeHair( bool hair, int id, ref int storeID, ref int storeHue )
{
Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

if ( item != null )
{
if ( storeID == -1 )
{
storeID = item.ItemID;
storeHue = item.Hue;
}

item.Delete();
}
else if ( storeID == -1 )
{
storeID = 0;
storeHue = 0;
}

if ( id == 0 )
return;

AddItem( CreateHair( hair, id, 0 ) );
}
#endregion

#region Virtue stuff
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 ArrayList m_JusticeProtectors;

public DateTime LastJusticeLoss{ get{ return m_LastJusticeLoss; } set{ m_LastJusticeLoss = value; } }
public ArrayList 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; } }
#endregion
}
}
 

Lorryn

Wanderer
Is usually easier if you post script using the CODE tabs

I compared your PM to mine and changed a few things, give it a go.

Code:
using System;
using System.Collections;
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.Seventh;
using Server.Targeting;
using Server.Engines.Quests;

namespace Server.Mobiles
{
[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
}

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

		public enum SolenFriend 
		{ 
			None, Black, Red 
		}

public class PlayerMobile : Mobile
{
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; } 
}
}

		// --- Start Quest Property --- //

		private BaseQuest m_CurrentQuest;
		public DateTime m_QuestRestartTime;
		private SolenFriend m_SolenFriend = SolenFriend.None;

		// --- Stop Quest Property --- //

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;

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

// --- Start Quest Property Method --- //

public BaseQuest CurrentQuest
{
get { return m_CurrentQuest; }
set { m_CurrentQuest = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public bool CanStartNewQuest
{
get
{
if ( DateTime.Now > m_QuestRestartTime && Quest == null )
return true;
else
return false;
}
}

[CommandProperty( AccessLevel.GameMaster )] 
public SolenFriend SolenFriendship 
{ 
get { return m_SolenFriend; } 
set { m_SolenFriend = value; } 
}

// --- Stop Quest Property Method --- // 

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 TimeSpan NpcGuildGameTime
{
get{ return m_NpcGuildGameTime; }
set{ m_NpcGuildGameTime = value; }
}

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

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;

return max;
}

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

SacrificeVirtue.CheckAtrophy( from );
JusticeVirtue.CheckAtrophy( from );
CompassionVirtue.CheckAtrophy( 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;

ArrayList items = this.Items;

if ( items == null )
return;

bool moved = false;

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

Mobile from = this;

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

Item item = (Item)items[i];

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;

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.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
{
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;
}
}
}

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

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 client from house
*/

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

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

from.MoveToWorld( context.Foundation.BanLocation, context.Foundation.Map );
}

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

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

Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

base.RevealingAction();
}

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

InvalidateMyRunUO();
}

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

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

InvalidateMyRunUO();
}

public override int HitsMax
{
get
{
int strBase;
int strOffs = GetStatOffset( StatType.Str );

if ( Core.AOS )
{
strBase = this.Str;
strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
}
else
{
strBase = this.RawStr;
}

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

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

public override int ManaMax
{
get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
}

public override bool Move( Direction d )
{
NetState ns = this.NetState;

if ( ns != null )
{
Gump[] gumps = ns.Gumps;

for ( int i = 0; i < gumps.Length; ++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 );

if ( !base.Move( d ) )
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 );

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 override bool AllowSkillUse( SkillName skill )
{
return DesignContext.Check( this );
}

private bool m_LastProtectedMessage;
private int m_NextProtectionCheck = 10;

public virtual void RecheckTownProtection()
{
m_NextProtectionCheck = 10;

Regions.GuardedRegion reg = this.Region as 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 )
{
base.SetLocation( loc, isTeleport );

if ( isTeleport || --m_NextProtectionCheck == 0 )
RecheckTownProtection();
}

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

if ( from == this )
{
if ( m_Quest != null )
m_Quest.GetContextMenuEntries( list );

//added for basequest

if( m_CurrentQuest != null )
{
if( !m_CurrentQuest.Deleted )
{
list.Add( new QuestLogEntry( from, m_CurrentQuest ) );
list.Add( new QuestConversationEntry ( from, m_CurrentQuest ) );
list.Add( new CancelQuestEntry( from, m_CurrentQuest ) );
}
}

//end of added basequest


// --- Start Quest Context Menu's --- //

private class QuestLogEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public QuestLogEntry( Mobile from, BaseQuest quest ) : base( 6154 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.QuestLogGump( m_Quest ) );
}
}

private class CancelQuestEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public CancelQuestEntry( Mobile from, BaseQuest quest ) : base( 6155 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.CancelQuestGump( m_Quest ) );
}
}

private class QuestConversationEntry : Server.ContextMenus.ContextMenuEntry
{
private BaseQuest m_Quest;
private Mobile m_From;

public QuestConversationEntry( Mobile from, BaseQuest quest ) : base( 6156 )
{
m_Quest = quest;
m_From = from;
}

public override void OnClick()
{
m_From.SendGump( new Server.Gumps.StartQuestGump( m_Quest ) );
}
}

// --- Stop Quest Context Menu's --- //


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

// TODO: Toggle champ titles

BaseHouse house = BaseHouse.FindHouseAt( this );

if ( house != null && house.IsAosRules )
list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );

if ( m_JusticeProtectors.Count > 0 )
list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
}
}

private void CancelProtection()
{
for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
{
Mobile prot = (Mobile)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();
}

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 )
return false;

if ( item is Spellbook || item is Runebook || item is PotionKeg )
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;

SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
AutoRenewInsurance = false;
}

// TODO: Champ titles, toggle

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

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

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

protected override void OnMapChange( Map oldMap )
{
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 OnDamage( int amount, Mobile from, bool willKill )
{
if ( amount > (Core.AOS ? 25 : 0) )
{
BandageContext c = BandageContext.GetContext( this );

if ( c != null )
c.Slip();
}

if (this.Combatant == null || !this.Combatant.Alive || !this.Combatant.InRange( this, 3 )) 

this.Combatant = from;

WeightOverloading.FatigueOnDamage( this, amount );

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

public static int ComputeSkillTotal( Mobile m )
{
int total = 0;

for ( int i = 0; i < m.Skills.Length; ++i )
total += m.Skills[i].BaseFixedPoint;

return ( total / 10 );
}

public override void Resurrect()
{
bool wasAlive = this.Alive;

base.Resurrect();

if ( this.Alive && !wasAlive )
{
Item deathRobe = new DeathRobe();

if ( !EquipItem( deathRobe ) )
deathRobe.Delete();
}
}

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 != null && !m_InsuranceAward.Player )
m_InsuranceAward = null;

if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

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;

return base.GetParentMoveResultFor( item );
}

public override DeathMoveResult GetInventoryMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;

return base.GetInventoryMoveResultFor( item );
}

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

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 != null && m.Player )
{
bool gainedPath = false;

int theirTotal = ComputeSkillTotal( m );
int ourTotal = ComputeSkillTotal( this );

int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);

if ( pointsToGain < 1 )
pointsToGain = 1;
else if ( pointsToGain > 4 )
pointsToGain = 4;

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

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

private ArrayList m_PermaFlags;
private ArrayList 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{}
}
}

public DateTime LastEscortTime
{
get{ return m_LastEscortTime; }
set{ m_LastEscortTime = value; }
}

public PlayerMobile()
{
m_VisList = new ArrayList();
m_PermaFlags = new ArrayList();
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 ArrayList();

InvalidateMyRunUO();
}

public override bool MutateSpeech( ArrayList hears, ref string text, ref object context )
{
if ( Alive )
return false;

if ( Core.AOS )
{
for ( int i = 0; i < hears.Count; ++i )
{
object o = hears[i];

if ( o != this && o is Mobile && ((Mobile)o).Skills[SkillName.SpiritSpeak].Value >= 100.0 )
return false;
}
}

return base.MutateSpeech( hears, ref text, ref context );
}

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

public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
{
if ( !Alive )
return ApplyPoisonResult.Immune;

if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
return base.ApplyPoison( from, PoisonImpl.IncreaseLevel( poison ) );

return base.ApplyPoison( from, poison );
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
InvalidateMyRunUO();
}

public ArrayList VisibilityList
{
get{ return m_VisList; }
}

public ArrayList 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 )
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 18:
				{
					m_SolenFriend = (SolenFriend)reader.ReadInt();
					m_CurrentQuest = (BaseQuest) reader.ReadItem();
					goto case 16;
				}

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

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 )
{
ArrayList payed = reader.ReadItemList();

for ( int i = 0; i < payed.Count; ++i )
((Item)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.ReadMobileList();
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.ReadMobileList();
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;
}
}

if ( m_PermaFlags == null )
m_PermaFlags = new ArrayList();

if ( m_JusticeProtectors == null )
m_JusticeProtectors = new ArrayList();

if ( m_BOBFilter == null )
m_BOBFilter = new Engines.BulkOrders.BOBFilter();

ArrayList list = this.Stabled;

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

if ( bc != null )
bc.IsStabled = true;
}
}

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

base.Serialize( writer );

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

// --- Start Quest Serialization --- //

writer.Write( (int)m_SolenFriend );
writer.Write( m_CurrentQuest );

// --- Stop Quest Serialization --- //

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 = (QuestRestartInfo)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.WriteMobileList( m_PermaFlags, true );

writer.Write( NextTailorBulkOrder );

writer.Write( NextSmithBulkOrder );

writer.WriteDeltaTime( m_LastJusticeLoss );
writer.WriteMobileList( 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 void ResetKillTime()
{
m_ShortTermElapse = this.GameTime + TimeSpan.FromHours( 8 );
m_LongTermElapse = this.GameTime + TimeSpan.FromHours( 40 );
}

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

#region Quest stuff
private QuestSystem m_Quest;
private ArrayList m_DoneQuests;

public QuestSystem Quest
{
get{ return m_Quest; }
set{ m_Quest = value; }
}

public ArrayList DoneQuests
{
get{ return m_DoneQuests; }
set{ m_DoneQuests = 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 )
{
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 )
{
InvalidateMyRunUO();
}

public override void OnAccessLevelChanged( AccessLevel oldLevel )
{
InvalidateMyRunUO();
}

public override void OnRawStatChange( StatType stat, int oldValue )
{
InvalidateMyRunUO();
}

public override void OnDelete()
{
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.GameMaster ); } }

public virtual TimeSpan ComputeMovementSpeed( Direction dir )
{
if ( (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
return TimeSpan.Zero;

bool running = ( (dir & Direction.Running) != 0 );

bool onHorse = ( this.Mount != null );

if ( onHorse )
return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );

return ( running ? TimeSpan.FromSeconds( 0.2 ) : TimeSpan.FromSeconds( 0.4 ) );
}

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 Item CreateHair( bool hair, int id, int hue )
{
if ( hair )
return Server.Items.Hair.CreateByID( id, hue );
else
return Server.Items.Beard.CreateByID( id, hue );
}

private void InternalRestoreHair( bool hair, ref int id, ref int hue )
{
if ( id == -1 )
return;

Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

if ( item != null )
item.Delete();

if ( id != 0 )
AddItem( CreateHair( hair, id, hue ) );

id = -1;
hue = 0;
}

private void InternalChangeHair( bool hair, int id, ref int storeID, ref int storeHue )
{
Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

if ( item != null )
{
if ( storeID == -1 )
{
storeID = item.ItemID;
storeHue = item.Hue;
}

item.Delete();
}
else if ( storeID == -1 )
{
storeID = 0;
storeHue = 0;
}

if ( id == 0 )
return;

AddItem( CreateHair( hair, id, 0 ) );
}
#endregion

#region Virtue stuff
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 ArrayList m_JusticeProtectors;

public DateTime LastJusticeLoss{ get{ return m_LastJusticeLoss; } set{ m_LastJusticeLoss = value; } }
public ArrayList 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; } }
#endregion
}
}
 

blain

Wanderer
ive still got errors have i dont something wrong with my planthue.cs?

using System;
using System.Collections;
using Server;

namespace Server.Engines.Plants
{
[Flags]
public enum PlantHue
{
Plain = 0x1 | Crossable,

Red = 0x2 | Crossable,
Blue = 0x4 | Crossable,
Yellow = 0x8 | Crossable,

BrightRed = Red | Bright,
BrightBlue = Blue | Bright,
BrightYellow = Yellow | Bright,

Purple = Red | Blue,
Green = Blue | Yellow,
Orange = Red | Yellow,

BrightPurple = Purple | Bright,
BrightGreen = Green | Bright,
BrightOrange = Orange | Bright,

Black = 0x10,
White = 0x20,
Pink = 0x40,
Magenta = 0x80,
Aqua = 0x100,
FireRed = 0x200,

None = 0,
Crossable = 0x4000000,
Bright = 0x8000000
}

public class PlantHueInfo
{
private static Hashtable m_Table;

static PlantHueInfo()
{
m_Table = new Hashtable();

m_Table[PlantHue.Plain] = new PlantHueInfo( 0, 1060813, PlantHue.Plain, 0x835 );
m_Table[PlantHue.Red] = new PlantHueInfo( 0x66D, 1060814, PlantHue.Red, 0x24 );
m_Table[PlantHue.Blue] = new PlantHueInfo( 0x53D, 1060815, PlantHue.Blue, 0x6 );
m_Table[PlantHue.Yellow] = new PlantHueInfo( 0x8A5, 1060818, PlantHue.Yellow, 0x38 );
m_Table[PlantHue.BrightRed] = new PlantHueInfo( 0x21, 1060814, PlantHue.BrightRed, 0x21 );
m_Table[PlantHue.BrightBlue] = new PlantHueInfo( 0x5, 1060815, PlantHue.BrightBlue, 0x6 );
m_Table[PlantHue.BrightYellow] = new PlantHueInfo( 0x38, 1060818, PlantHue.BrightYellow, 0x35 );
m_Table[PlantHue.Purple] = new PlantHueInfo( 0xD, 1060816, PlantHue.Purple, 0x10 );
m_Table[PlantHue.Green] = new PlantHueInfo( 0x59B, 1060819, PlantHue.Green, 0x42 );
m_Table[PlantHue.Orange] = new PlantHueInfo( 0x46F, 1060817, PlantHue.Orange, 0x2E );
m_Table[PlantHue.BrightPurple] = new PlantHueInfo( 0x10, 1060816, PlantHue.BrightPurple, 0xD );
m_Table[PlantHue.BrightGreen] = new PlantHueInfo( 0x42, 1060819, PlantHue.BrightGreen, 0x3F );
m_Table[PlantHue.BrightOrange] = new PlantHueInfo( 0x2B, 1060817, PlantHue.BrightOrange, 0x2B );
m_Table[PlantHue.Black] = new PlantHueInfo( 0x455, 1060820, PlantHue.Black, 0 );
m_Table[PlantHue.White] = new PlantHueInfo( 0x481, 1060821, PlantHue.White, 0x481 );
m_Table[PlantHue.Pink] = new PlantHueInfo( 0x48E, 1061854, PlantHue.Pink );
m_Table[PlantHue.Magenta] = new PlantHueInfo( 0x486, 1061852, PlantHue.Magenta );
m_Table[PlantHue.Aqua] = new PlantHueInfo( 0x495, 1061853, PlantHue.Aqua );
m_Table[PlantHue.FireRed] = new PlantHueInfo( 0x489, 1061855, PlantHue.FireRed );
}

public static PlantHueInfo GetInfo( PlantHue plantHue )
{
PlantHueInfo info = m_Table[plantHue] as PlantHueInfo;

if ( info != null )
return info;
else
return (PlantHueInfo)m_Table[PlantHue.Plain];
}

public static PlantHue RandomFirstGeneration()
{


public static PlantHue RandomRare()
{
switch ( Utility.Random( 3 ) )
{
case 0: return PlantHue.Aqua;
case 1: return PlantHue.Pink;
default: return PlantHue.Magenta;
}
}

switch ( Utility.Random( 4 ) )
{
case 0: return PlantHue.Plain;
case 1: return PlantHue.Red;
case 2: return PlantHue.Blue;
default: return PlantHue.Yellow;
}
}

public static bool IsCrossable( PlantHue plantHue )
{
return (plantHue & PlantHue.Crossable) != PlantHue.None;
}

public static bool IsBright( PlantHue plantHue )
{
return (plantHue & PlantHue.Bright) != PlantHue.None;
}

public static PlantHue GetNotBright( PlantHue plantHue )
{
return plantHue & ~PlantHue.Bright;
}

public static bool IsPrimary( PlantHue plantHue )
{
return plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow;
}

public static PlantHue Cross( PlantHue first, PlantHue second )
{
if ( !IsCrossable( first ) || !IsCrossable( second ) )
return PlantHue.None;

if ( Utility.RandomDouble() < 0.01 )
return Utility.RandomBool() ? PlantHue.Black : PlantHue.White;

if ( first == PlantHue.Plain || second == PlantHue.Plain )
return PlantHue.Plain;

PlantHue notBrightFirst = GetNotBright( first );
PlantHue notBrightSecond = GetNotBright( second );

if ( notBrightFirst == notBrightSecond )
return first | PlantHue.Bright;

bool firstPrimary = IsPrimary( notBrightFirst );
bool secondPrimary = IsPrimary( notBrightSecond );

if ( firstPrimary && secondPrimary )
return notBrightFirst | notBrightSecond;

if ( firstPrimary && !secondPrimary )
return notBrightFirst;

if ( !firstPrimary && secondPrimary )
return notBrightSecond;

return notBrightFirst & notBrightSecond;
}

private int m_Hue;
private int m_Name;
private PlantHue m_PlantHue;
private int m_GumpHue;

public int Hue { get { return m_Hue; } }
public int Name { get { return m_Name; } }
public PlantHue PlantHue { get { return m_PlantHue; } }
public int GumpHue { get { return m_GumpHue; } }

private PlantHueInfo( int hue, int name, PlantHue plantHue ) : this( hue, name, plantHue, hue )
{
}

private PlantHueInfo( int hue, int name, PlantHue plantHue, int gumpHue )
{
m_Hue = hue;
m_Name = name;
m_PlantHue = plantHue;
m_GumpHue = gumpHue;
}

public bool IsCrossable()
{
return IsCrossable( m_PlantHue );
}

public bool IsBright()
{
return IsBright( m_PlantHue );
}

public PlantHue GetNotBright()
{
return GetNotBright( m_PlantHue );
}

public bool IsPrimary()
{
return IsPrimary( m_PlantHue );
}
}
}


here are my errors again

Scripts: Compiling C# scripts...failed (46 errors, 0 warnings)
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1513: (line 80, column 4) } e
xpected
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 93, column 4) Inv
alid token 'switch' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 93, column 27) In
valid token '(' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 95, column 34) In
valid token ';' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 96, column 32) In
valid token ';' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 97, column 33) In
valid token ';' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1519: (line 98, column 36) In
valid token ';' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 102, column 17) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 107, column 17) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 112, column 17) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 117, column 17) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 122, column 17) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 159, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 160, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 161, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 162, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 176, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 181, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 186, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1518: (line 191, column 10) E
xpected class, delegate, enum, interface, or struct
- Error: Scripts\Custom\base quest\PlantHue.cs: CS1022: (line 195, column 2) Ty
pe or namespace definition, or end-of-file expected
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1513: (line 883, column 2
) } expected
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 944, column 1
) Invalid token 'if' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 944, column 1
2) Invalid token '&&' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 944, column 3
2) Invalid token ')' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 946, column 9
) Invalid token '(' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1520: (line 946, column 1
5) Class, struct, or interface method must have a return type
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1031: (line 946, column 3
0) Type expected
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1520: (line 946, column 4
0) Class, struct, or interface method must have a return type
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1001: (line 946, column 7
7) Identifier expected
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1002: (line 946, column 7
9) ; expected
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 948, column 2
5) Invalid token ')' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1519: (line 949, column 9
) Invalid token '(' in class, struct, or interface member declaration
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1520: (line 949, column 1
5) Class, struct, or interface method must have a return type
- Error: Scripts\Custom\base quest\PlayerMobile.cs: CS1031: (line 949, column 3
0) Type expected
 
J

Jimbot

Guest
Help!

every time i restart it wants me to delete playermobile heres my player mobile script befor i edited it

Code:
using System;
using System.Collections;
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.Seventh;
using Server.Targeting;
using Server.Engines.Quests;

namespace Server.Mobiles
{
	[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
	}

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

	public class PlayerMobile : Mobile
	{
		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;

		[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 TimeSpan NpcGuildGameTime
		{
			get{ return m_NpcGuildGameTime; }
			set{ m_NpcGuildGameTime = value; }
		}

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

		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;

			return max;
		}

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

	PlayerMobile pm = from as PlayerMobile;

	if ( pm.m_IgnoreList == null ) 
		pm.m_IgnoreList = new ArrayList();

	SacrificeVirtue.CheckAtrophy( from );
	JusticeVirtue.CheckAtrophy( from );
	CompassionVirtue.CheckAtrophy( 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;

				ArrayList items = this.Items;

				if ( items == null )
					return;

				bool moved = false;

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

				Mobile from = this;

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

					Item item = (Item)items[i];

					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;

						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.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
						{
							drop = true;
						}
						else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
						{
							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;
						}
					}
				}

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

		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 client from house
				 */

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

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

				from.MoveToWorld( context.Foundation.BanLocation, context.Foundation.Map );
			}

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

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

			Spells.Sixth.InvisibilitySpell.RemoveTimer( this );

			base.RevealingAction();
		}

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

			InvalidateMyRunUO();
		}

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

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

			InvalidateMyRunUO();
		}

		public override int HitsMax
		{
			get
			{
				int strBase;
				int strOffs = GetStatOffset( StatType.Str );

				if ( Core.AOS )
				{
					strBase = this.Str;
					strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
				}
				else
				{
					strBase = this.RawStr;
				}

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

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

		public override int ManaMax
		{
			get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
		}

		public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				Gump[] gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Length; ++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 );

			if ( !base.Move( d ) )
				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 );

			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 override bool AllowSkillUse( SkillName skill )
		{
			return DesignContext.Check( this );
		}

		private bool m_LastProtectedMessage;
		private int m_NextProtectionCheck = 10;

		public virtual void RecheckTownProtection()
		{
			m_NextProtectionCheck = 10;

			Regions.GuardedRegion reg = this.Region as 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 )
		{
			base.SetLocation( loc, isTeleport );

			if ( isTeleport || --m_NextProtectionCheck == 0 )
				RecheckTownProtection();
		}

		public override void GetContextMenuEntries( Mobile from, ArrayList 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 ) ) );
				}

				// TODO: Toggle champ titles

				BaseHouse house = BaseHouse.FindHouseAt( this );

				if ( house != null && house.IsAosRules )
					list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );

				if ( m_JusticeProtectors.Count > 0 )
					list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
			}
		}

		private void CancelProtection()
		{
			for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
			{
				Mobile prot = (Mobile)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();
		}

		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 )
				return false;

			if ( item is Spellbook || item is Runebook || item is PotionKeg )
				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;

			SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
			AutoRenewInsurance = false;
		}

		// TODO: Champ titles, toggle

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

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

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

		protected override void OnMapChange( Map oldMap )
		{
			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 OnDamage( int amount, Mobile from, bool willKill )
		{
			if ( amount > (Core.AOS ? 25 : 0) )
			{
				BandageContext c = BandageContext.GetContext( this );

				if ( c != null )
					c.Slip();
			}

			WeightOverloading.FatigueOnDamage( this, amount );

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

		public static int ComputeSkillTotal( Mobile m )
		{
			int total = 0;

			for ( int i = 0; i < m.Skills.Length; ++i )
				total += m.Skills[i].BaseFixedPoint;

			return ( total / 10 );
		}

		public override void Resurrect()
		{
			bool wasAlive = this.Alive;

			base.Resurrect();

			if ( this.Alive && !wasAlive )
			{
				Item deathRobe = new DeathRobe();

				if ( !EquipItem( deathRobe ) )
					deathRobe.Delete();
			}
		}

		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 != null && !m_InsuranceAward.Player )
				m_InsuranceAward = null;

			if ( m_InsuranceAward is PlayerMobile )
				((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;

			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;

			return base.GetParentMoveResultFor( item );
		}

		public override DeathMoveResult GetInventoryMoveResultFor( Item item )
		{
			if ( CheckInsuranceOnDeath( item ) )
				return DeathMoveResult.MoveToBackpack;

			return base.GetInventoryMoveResultFor( item );
		}

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

			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 != null && m.Player )
				{
					bool gainedPath = false;

					int theirTotal = ComputeSkillTotal( m );
					int ourTotal = ComputeSkillTotal( this );

					int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);

					if ( pointsToGain < 1 )
						pointsToGain = 1;
					else if ( pointsToGain > 4 )
						pointsToGain = 4;

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

			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.
			}
		}
public bool Onshow;
private ArrayList m_IgnoreList;

private ArrayList m_PermaFlags;
private ArrayList 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{}
			}
		}

		public DateTime LastEscortTime
		{
			get{ return m_LastEscortTime; }
			set{ m_LastEscortTime = value; }
		}

		public PlayerMobile()
		{
			m_VisList = new ArrayList();
			m_PermaFlags = new ArrayList();
			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 ArrayList();

			InvalidateMyRunUO();
		}

		public override bool MutateSpeech( ArrayList hears, ref string text, ref object context )
		{
			if ( Alive )
				return false;

			if ( Core.AOS )
			{
				for ( int i = 0; i < hears.Count; ++i )
				{
					object o = hears[i];

					if ( o != this && o is Mobile && ((Mobile)o).Skills[SkillName.SpiritSpeak].Value >= 100.0 )
						return false;
				}
			}

			return base.MutateSpeech( hears, ref text, ref context );
		}

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

		public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
		{
			if ( !Alive )
				return ApplyPoisonResult.Immune;

			if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
				return base.ApplyPoison( from, PoisonImpl.IncreaseLevel( poison ) );

			return base.ApplyPoison( from, poison );
		}

		public PlayerMobile( Serial s ) : base( s )
{
	m_IgnoreList = new ArrayList();
	m_VisList = new ArrayList();
	m_AntiMacroTable = new Hashtable();
	InvalidateMyRunUO();
}
public ArrayList IgnoreList
{
	get
	{
		return m_IgnoreList;
	}
}
		public ArrayList VisibilityList
		{
			get{ return m_VisList; }
		}

		public ArrayList 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 )
				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 18:
{
Onshow = reader.ReadBool();
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 ArrayList();

						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 )
					{
						ArrayList payed = reader.ReadItemList();

						for ( int i = 0; i < payed.Count; ++i )
							((Item)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.ReadMobileList();
					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.ReadMobileList();
					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;
	}
			}
if ( m_IgnoreList == null ) 
	m_IgnoreList = new ArrayList();

if ( m_PermaFlags == null )
	m_PermaFlags = new ArrayList();

			if ( m_JusticeProtectors == null )
				m_JusticeProtectors = new ArrayList();

			if ( m_BOBFilter == null )
				m_BOBFilter = new Engines.BulkOrders.BOBFilter();

			ArrayList list = this.Stabled;

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

				if ( bc != null )
					bc.IsStabled = true;
			}
		}
		
		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;
			}

			base.Serialize( writer );
			
			writer.Write( (int) 18 ); // version

            writer.Write( (bool) Onshow );

			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 = (QuestRestartInfo)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.WriteMobileList( m_PermaFlags, true );

			writer.Write( NextTailorBulkOrder );

			writer.Write( NextSmithBulkOrder );

			writer.WriteDeltaTime( m_LastJusticeLoss );
			writer.WriteMobileList( 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 void ResetKillTime()
		{
			m_ShortTermElapse = this.GameTime + TimeSpan.FromHours( 8 );
			m_LongTermElapse = this.GameTime + TimeSpan.FromHours( 40 );
		}

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

		#region Quest stuff
		private QuestSystem m_Quest;
		private ArrayList m_DoneQuests;

		public QuestSystem Quest
		{
			get{ return m_Quest; }
			set{ m_Quest = value; }
		}

		public ArrayList DoneQuests
		{
			get{ return m_DoneQuests; }
			set{ m_DoneQuests = 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 )
		{
			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 )
		{
			InvalidateMyRunUO();
		}

		public override void OnAccessLevelChanged( AccessLevel oldLevel )
		{
			InvalidateMyRunUO();
		}

		public override void OnRawStatChange( StatType stat, int oldValue )
		{
			InvalidateMyRunUO();
		}

		public override void OnDelete()
		{
			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.GameMaster ); } }

		public virtual TimeSpan ComputeMovementSpeed( Direction dir )
		{
			if ( (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
				return TimeSpan.Zero;

			bool running = ( (dir & Direction.Running) != 0 );

			bool onHorse = ( this.Mount != null );

			if ( onHorse )
				return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );

			return ( running ? TimeSpan.FromSeconds( 0.2 ) : TimeSpan.FromSeconds( 0.4 ) );
		}

		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 Item CreateHair( bool hair, int id, int hue )
		{
			if ( hair )
				return Server.Items.Hair.CreateByID( id, hue );
			else
				return Server.Items.Beard.CreateByID( id, hue );
		}

		private void InternalRestoreHair( bool hair, ref int id, ref int hue )
		{
			if ( id == -1 )
				return;

			Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

			if ( item != null )
				item.Delete();

			if ( id != 0 )
				AddItem( CreateHair( hair, id, hue ) );

			id = -1;
			hue = 0;
		}

		private void InternalChangeHair( bool hair, int id, ref int storeID, ref int storeHue )
		{
			Item item = FindItemOnLayer( hair ? Layer.Hair : Layer.FacialHair );

			if ( item != null )
			{
				if ( storeID == -1 )
				{
					storeID = item.ItemID;
					storeHue = item.Hue;
				}

				item.Delete();
			}
			else if ( storeID == -1 )
			{
				storeID = 0;
				storeHue = 0;
			}

			if ( id == 0 )
				return;

			AddItem( CreateHair( hair, id, 0 ) );
		}
		#endregion

		#region Virtue stuff
		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 ArrayList m_JusticeProtectors;

		public DateTime LastJusticeLoss{ get{ return m_LastJusticeLoss; } set{ m_LastJusticeLoss = value; } }
		public ArrayList 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; } }
		#endregion
	}
}
 
Umm

for some reason i cannot seem to find other scripts other then the latest 25 i need to find alot more custom scripts to add to my shard i need to find good ones that is anyone no where i can find a bunch?
 
Code:
using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Items;
using Server.Network;

namespace Server.SkillHandlers
{
	 public class Stealing
	 {
		  public static void Initialize()
		  {
			   SkillInfo.Table[33].Callback = new SkillUseCallback( OnUse );
		  }

		  public static readonly bool ClassicMode = false;
		  public static readonly bool SuspendOnMurder = false;

		  public static bool IsInGuild( Mobile m )
		  {
			   return ( m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild );
		  }

		  public static bool IsInnocentTo( Mobile from, Mobile to )
		  {
		 	   return ( Notoriety.Compute( from, (Mobile)to ) == Notoriety.Innocent );
		  }

		  private class StealingTarget : Target
		  {
			   private Mobile m_Thief;

			   public StealingTarget( Mobile thief ) : base ( 1, false, TargetFlags.None )
			   {
				    m_Thief = thief;

				    AllowNonlocal = true;
			   }

			   private Item TryStealItem( Item toSteal, ref bool caught )
			   {
				    Item stolen = null;

				    object root = toSteal.RootParent;

				    if ( !IsEmptyHanded( m_Thief ) )
				    {
					     m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
				    }
				    else if ( root is Mobile && ((Mobile)root).Player && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( m_Thief ) )
				    {
					     m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players.
				    }
				    else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 )
				    {
					     m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild.
				    }
				    else if ( root is BaseVendor && ((BaseVendor)root).IsInvulnerable )
				    {
					     m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
				    }
				    else if ( root is PlayerVendor )
				    {
					     m_Thief.SendLocalizedMessage( 502709 ); // You can't steal from vendors.
				    }
				    else if ( !m_Thief.CanSee( toSteal ) )
				    {
					     m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
				    }
				    else if ( toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
				    {
					     m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				    }
				    else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
				    {
					     m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
				    }
				    else if ( toSteal.Parent is Mobile )
				    {
					     m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
				    }
				    else if ( root == m_Thief )
				    {
					     m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
				    }
				    else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
				    {
					     m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				    }
				    else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
				    {
				    }
				    else
				    {
					     double w = toSteal.Weight + toSteal.TotalWeight;

					     if ( w > 10 )
					     {
						      m_Thief.SendMessage( "That is too heavy to steal." );
					     }
					     else
					     {
						      if ( toSteal.Stackable && toSteal.Amount > 1 )
						      {
							       int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

							       if ( maxAmount < 1 )
								        maxAmount = 1;
							       else if ( maxAmount > toSteal.Amount )
								        maxAmount = toSteal.Amount;

							       int amount = Utility.RandomMinMax( 1, maxAmount );

							       if ( amount >= toSteal.Amount )
							       {
								        int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
								        pileWeight *= 10;

								        if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
									         stolen = toSteal;
							       }
							       else
							       {
								        int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
								        pileWeight *= 10;

								        if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
								        {
									         stolen = toSteal.Dupe( amount );
									         toSteal.Amount -= amount;
								        }
							       }
						      }
						      else
						      {
							       int iw = (int)Math.Ceiling( w );
							       iw *= 10;

							       if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
								        stolen = toSteal;
						      }

						      if ( stolen != null )
							       m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
						      else
							       m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.

						      caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
					    }
				   }

				   return stolen;
			  }

			  protected override void OnTarget( Mobile from, object target )
			  {
				   from.RevealingAction();

				   Item stolen = null;
				   object root = null;
				   bool caught = false;

				   if ( target is Item )
				   {
					    root = ((Item)target).RootParent;
					    stolen = TryStealItem( (Item)target, ref caught );
				   } 
				   else if ( target is Mobile )
				   {
                                             PlayerMobile theif = from as PlayerMobile;

					     if( theif.SolenFriendship == SolenFriend.Red )
					     {
						      if( target is RedSolenQueen || target is RedSolenWarrior || target is RedSolenWorker || target is RedSolenInfiltratorQueen || target is RedSolenInfiltratorWarrior )
							       theif.SolenFriendship = SolenFriend.None;
					     }

					     if( theif.SolenFriendship == SolenFriend.Black )
					     {
						      if( target is BlackSolenQueen || target is BlackSolenWarrior || target is BlackSolenWorker || target is BlackSolenInfiltratorQueen || target is BlackSolenInfiltratorWarrior )
							       theif.SolenFriendship = SolenFriend.None;
					     }

					     Container pack = ((Mobile)target).Backpack;

					     if ( pack != null && pack.Items.Count > 0 )
					     {
						      int randomIndex = Utility.Random( pack.Items.Count );

						      root = target;
						      stolen = TryStealItem( (Item) pack.Items[randomIndex], ref caught );
					     }
				    } 
				    else 
				    {
					     m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				    }

				    if ( stolen != null )
					from.AddToBackpack( stolen );

				    if ( caught )
				    {
					     if ( root == null )
					     {
						      m_Thief.CriminalAction( false );
					     }
					     else if ( root is Corpse && ((Corpse)root).IsCriminalAction( m_Thief ) )
					     {
						      m_Thief.CriminalAction( false );
					     }
					     else if ( root is Mobile )
					     {
						      Mobile mobRoot = (Mobile)root;

						      if ( !IsInGuild( mobRoot ) && IsInnocentTo( m_Thief, mobRoot ) )
							       m_Thief.CriminalAction( false );

						      string message = String.Format( "You notice {0} trying to steal from {1}.", m_Thief.Name, mobRoot.Name );

						      foreach ( NetState ns in m_Thief.GetClientsInRange( 8 ) )
						      {
							       if ( ns != m_Thief.NetState )
								        ns.Mobile.SendMessage( message );
						      }
					     }
				    }
				    else if ( root is Corpse && ((Corpse)root).IsCriminalAction( m_Thief ) )
				    {
					     m_Thief.CriminalAction( false );
				    }

				    if ( root is Mobile && ((Mobile)root).Player && m_Thief is PlayerMobile && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( (Mobile)root ) )
				    {
					     PlayerMobile pm = (PlayerMobile)m_Thief;

					     pm.PermaFlags.Add( (Mobile)root );
					     pm.Delta( MobileDelta.Noto );
				    }
			   }
		  }

		  public static bool IsEmptyHanded( Mobile from )
		  {
			   if ( from.FindItemOnLayer( Layer.OneHanded ) != null )
				    return false;

			   if ( from.FindItemOnLayer( Layer.TwoHanded ) != null )
				    return false;

			   return true;
		  }

		  public static TimeSpan OnUse( Mobile m )
		  {
			   if ( !IsEmptyHanded( m ) )
			   {
				    m.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
			   }
			   else
			   {
				    m.Target = new Stealing.StealingTarget( m );
				    m.RevealingAction();

				    m.SendLocalizedMessage( 502698 ); // Which item do you want to steal?
			   }

			   return TimeSpan.FromSeconds( 10.0 );
		  }
	  }

}





error report ...as follows...

Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Skills\Stealing.cs: CS0101: (line 10, column 16) The namespace
'Server.SkillHandlers' already contains a definition for 'Stealing'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.


i have mended a few other errors through trial and error and help with templates i have seen on this and othe pages.. the script i have above is as the one i have followed further up the page and now i have this error report.... would you be kind enough to explain where it is wrong and what i can do to rectify it please
 

flashgordon

Wanderer
You have 2 copies of your stealing.cs file. That is what your error means.

Code:
'Server.SkillHandlers' already contains a definition for 'Stealing'

When you get an error that says you already have a definition for XXXXXX, it is telling you that you have multiple files of the name XXXXX.
 

Santaria

Wanderer
Christmas Quest

Everything about the script and all the parts work fine. With one exception of course or I wouldnt be posting. In my santa.cs, listed below, you see the override OnSpeech part.... When my players greet santa, he does not respond. When they say gift, he does not respond. Using my Admin character I get the appropriate responses as listed in this script.

Code:
using System; 
using System.IO; 
using System.Collections; 
using Server.Items;
using Server.Misc; 
using Server.Gumps;
using Server.ContextMenus;
using Server.Mobiles;
using Server.Accounting;

namespace Server.Mobiles 
{ 
	public class Santa : BaseCreature 
	{  

		[Constructable] 
		public Santa() : base(AIType.AI_Thief, FightMode.None, 10, 1, 0.8, 2.6 ) 
		{ 
			InitStats( 100, 100, 100 ); 

			Name = "Santa Claus"; 
			Female = false; 
			Body = 0x190; 
			Hue = Utility.RandomSkinHue(); 
			NameHue = 0x35;  
			Blessed = true;
			AddItem( new FancyShirt( 0x85 ) ); 
			AddItem( new LongPants( 0x85 ) );
			AddItem( new Boots() ); 

			Item hair = new Item( 0x203C );  
			hair.Layer = Layer.Hair; 
			hair.Movable = false; 
			AddItem( hair );
			Item beard = new Item(  0x203E );
			beard.Layer = Layer.FacialHair;
			beard.Movable = false;
			AddItem( beard );
		} 
      
		public Santa( Serial serial ) : base( serial ) 
		{ 
		} 

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

			writer.Write( (int) 0 ); // version 
		} 

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

			int version = reader.ReadInt(); 
		}

		public override void GetContextMenuEntries( Mobile from, ArrayList list ) 
		{ 
			base.GetContextMenuEntries( from, list ); 
			list.Add( new SantaEntry( from ) ); 
		}

		public override void OnSpeech( SpeechEventArgs args ) 
		{
			Mobile m = args.Mobile;
			Account acct=(Account)m.Account;
			bool Xmas = Convert.ToBoolean( acct.GetTag("Xmas") );

			
			if( args.Mobile.InRange( this, 4 ))
			{ 
				if (( args.Speech.ToLower().IndexOf( "gift" ) >= 0 ) ||  ( args.Speech.ToLower().IndexOf( "present" ) >= 0 ))
				{ 
					if( !Xmas )
					{
						XmasBag xbag = new XmasBag( 1 );
						this.Say( "Here are your christmas gifts!    Ho Ho Ho! Merry Christmas!" );
						acct.SetTag( "Xmas", "true" );
						if ( !m.AddToBackpack( xbag ) )
							xbag.Delete();
					}
					
					else 
					{
						this.Say ( "You have already recieved your gifts {0}, You will have to wait till next year! Ho Ho Ho!", m.Name );
					}
				}
				else 
				{
					this.Say ( "Greetings {0}, Merry Christmas! Ho Ho Ho!", m.Name );
				}
			}  
			
		}
		public class SantaEntry : ContextMenuEntry
		{
			private Mobile m_Mobile;

			public SantaEntry( Mobile from ) : base( 6146, 3 )
			{
				m_Mobile = from;
			}
          
			public override void OnClick()
			{
				PlayerMobile mobile = (PlayerMobile) m_Mobile;
				Account acct=(Account)mobile.Account;
				bool ChristmasQuest = Convert.ToBoolean( acct.GetTag("ChristmasQuest") );
				
				if( !( m_Mobile is PlayerMobile ) )
					return;
				if( ChristmasQuest )
				{
					mobile.SendMessage ( "You have rescued Santa's Reindeer and were rewarded, You did a fantastic job.. Thank You Again {0}.", mobile.Name );
					return;
				}

				if( mobile.CurrentQuest == null )
				{
					if( mobile.CanStartNewQuest )
					{
						if ( ! mobile.HasGump( typeof( OfferQuestGump ) ) )
						{
							mobile.CurrentQuest = new ChristmasQuest( mobile );
							mobile.SendGump( new OfferQuestGump( mobile.CurrentQuest ) );
						}
					}
					else
					{
						mobile.SendGump( new RestingQuestGump() );
					}
				}
				else if( mobile.CurrentQuest is ChristmasQuest )
				{
					ChristmasQuest quest = (ChristmasQuest) mobile.CurrentQuest;
						
					if( quest.Completed )
					{
						if( quest.CanRecieveItem( mobile, new SantasElixer() ) )
						{
							mobile.PlaySound( 1073 );
							acct.SetTag( "ChristmasQuest", "true" );
							mobile.SendGump( new FinishQuestGump( quest ) );
						}
						else
						{
							mobile.SendGump( new OverLoadedGump( quest ) );
						}
					}
					else
					{
						mobile.PlaySound( 1090 );
						mobile.SendGump( new QuestInProgressGump( mobile.CurrentQuest ) );
					}
				}
				else
				{
					mobile.SendGump( new OccupiedQuestGump( "<i>Santa looks up with desperate eyes...</i><BR><BR>You seem to be a bit busy at the moment, please come back and see me when you have more time. I have some trouble and if i dont get help christmas may be ruined this year." ) );
				}
			}
		}
	} 
}

Any insight into what I have screwed up would be most helpful. Thank you in advance!
 
Top