context: using System;
  using System.IO;
  using System.Collections;
  using System.Collections.Generic;
  using Server.Items;
  using Server.Gumps;
  
  namespace Server.Mobiles
  {
  	public class TownCrierb : BaseCreature
  	{
  		private static string path = "Data/news.txt";
  
  		private int m_Count;
  		private Timer m_Timer;
  		private bool m_StoneActive;
  		private bool m_Custom;
  		private bool m_Active;
  		private bool m_Random;
  		private TimeSpan m_Delay;
  		private TownCrierStone m_Stone;
  
  		[CommandProperty( AccessLevel.Seer )]
  		public TimeSpan Delay{ get{ return m_Delay; } set{ m_Delay = value; } }
  
  		[CommandProperty( AccessLevel.Seer )]
  		public TownCrierStone Stone
  		{
  			get{ return m_Stone; }
  			set
  			{
  				m_Stone = value;
  
  				TownCrierStone stone = m_Stone as TownCrierStone;
  
  				if ( stone != null )
  				{
  					this.StoneActive = stone.Active;
  					TownCrierb m_Crier = this as TownCrierb;
  					stone.Registry.Add( m_Crier );
  				}
  			}
  		}
  
  		[CommandProperty( AccessLevel.Seer )]
  		public bool Custom
  		{
  			get{ return m_Custom; }
  			set
  			{
  				m_Custom = value;
  				this.OnActivate();
  			}
  		}
  
  		[CommandProperty( AccessLevel.Seer )]
  		public bool Active
  		{
  			get
  			{
  				if ( !this.Custom )
  				{
  					m_Active = false;
  					return m_Active;
  				}
  				else
  				{
  					return m_Active;
  				}
  			}
  			set
  			{
  				m_Active = value;
  				this.OnActivate();
  			}
  		}
  
  		[CommandProperty( AccessLevel.Seer )]
  		public bool Random
  		{
  			get
  			{
  				if ( !this.Custom )
  				{
  					m_Random = false;
  					return m_Random;
  				}
  				else
  				{
  					return m_Random;
  				}
  			}
  			set { m_Random = value; }
  		}
  
  		public int Count{ get{ return m_Count; } set{ m_Count = value; } }
  
  		public bool StoneActive
  		{
  			get{ return m_StoneActive; }
  			set
  			{
  				m_StoneActive = value;
  				this.OnActivate();
  			}
  		}
  
  		[Constructable]
  		public TownCrierb() : base( AIType.AI_Thief, FightMode.None, 10, 1, 0.8, 1.6 )
  		{
  			InitStats( 100, 100, 25 );
  
  			Title = "the town crier";
  			Name = NameList.RandomName( "female" );
  			Female = true;
  			Body = 0x191;
  			Hue = Utility.RandomSkinHue();
  			NameHue = 0x35;
  			m_Stone = null;
  			m_StoneActive = false;
  			m_Active = false;
  			m_Custom = false;
  			m_Random = false;
  			m_Delay = new TimeSpan( 0, 0, 10 );
  			this.Blessed = true;
  
  			AddItem( new FancyShirt( Utility.RandomBlueHue() ) );
  
  			Item skirt;
  
  			switch ( Utility.Random( 2 ) )
  			{
  				case 0: skirt = new Skirt(); break;
  				default: case 1: skirt = new Kilt(); break;
  			}
  
  			skirt.Hue = Utility.RandomGreenHue();
  
  			AddItem( skirt );
  
  			AddItem( new FeatheredHat( Utility.RandomGreenHue() ) );
  
  			Item boots;
  
  			switch ( Utility.Random( 2 ) )
  			{
  				case 0: boots = new Boots(); break;
  				default: case 1: boots = new ThighBoots(); break;
  			}
  
  			AddItem( boots );
  
  			HairItemID = 0x203C;   // Long hair
              HairHue = 1175;
  		}
  
  		public override void OnDoubleClick( Mobile from )
  		{
  			if ( from.AccessLevel >= AccessLevel.Seer )
  				from.SendGump( new TownCrierbGump( null, this ) );
  			else
  				base.OnDoubleClick( from );
  		}
        
  		public override void OnDelete()
  		{
  			TownCrierStone stone = m_Stone as TownCrierStone;
  			if ( stone != null )
  			{
  				TownCrierb m_Crier = this as TownCrierb;
  				stone.Registry.Remove( m_Crier );
  			}
  			base.OnDelete();
  		}
  
  		public override void OnSpeech( SpeechEventArgs args )
  		{
  			if( args.Mobile.InRange( this, 4 ))
  			{
  				if ( args.Speech.ToLower().IndexOf( "news" ) >= 0 )
  				{
  					string message = SpamMessage( this );
  					this.Say( message );
  				}
  			}
  		}
  
  		public virtual void OnActivate()
  		{
  			TownCrierStone stone = Stone as TownCrierStone;
  			TimeSpan delay;
  
  			if ( m_Timer != null )
  			{
  				m_Timer.Stop();
  				m_Timer = null;
  			}
  
  			if ( m_Timer == null )
  			{
  				if ( !Custom && (stone != null) && stone.Active )
  				{
  					delay = stone.Delay;
  
gt: 					m_Timer = new SpamTimer( this, delay );