/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\special\DeceitBrazier.cs
Lines of code: 102
***********************************************************/


using System;
using Server;
using Server.Multis;
using Server.Items;
using Server.Mobiles;
using System.Collections;
using Server.Network;
using Server.Spells;
using Server.Targeting;

namespace Server.Items
{

	public class DeceitBrazier : Item
	{
		public bool UseDelay = false; 
		public override int LabelNumber{ get{ return 1017090; } } // Magic Brazier
		private Type[] m_SpawnTypes = new Type[]
			{
				typeof( Bogle ), typeof( BoneKnight ), typeof( EarthElemental ),
				typeof( Ettin ), typeof( GazerLarva ), typeof( Ghoul ),
				typeof( Golem ), typeof( HeadlessOne ), typeof( Mummy ),
				typeof( Ogre ), typeof( OgreLord ), typeof( RottingCorpse ),
				typeof( Sewerrat ), typeof( Skeleton ), typeof( Slime ),
				typeof( Zombie ), typeof( AirElemental ), typeof( DreadSpider ),
				typeof( Efreet ), typeof( Lich ), typeof( Nightmare ),
				typeof( PoisonElemental ), typeof( GiantBlackWidow ), typeof( SilverSerpent ),
				typeof( ToxicElemental ), typeof( Alligator ), typeof( BloodElemental ),
				typeof( BoneMagi ), typeof( Cyclops ), typeof( Daemon ),
				typeof( DireWolf ), typeof( Dragon ), typeof( Drake ),
				typeof( ElderGazer ), typeof( FireElemental ), typeof( FireGargoyle ),
				typeof( FireSteed ), typeof( Gargoyle ), typeof( Gazer ),
				typeof( GiantRat ), typeof( GiantSerpent ), typeof( GiantSpider ),
				typeof( Harpy ), typeof( HellHound ), typeof( Imp ),
				typeof( PredatorHellCat ), typeof( LavaLizard ), typeof( LavaSerpent ),
				typeof( LavaSnake ), typeof( Lizardman ), typeof( Mongbat ),
				typeof( StrongMongbat ), typeof( Orc ), typeof( OrcBomber ),
				typeof( OrcBrute ), typeof( OrcCaptain ), typeof( OrcishLord ),
				typeof( OrcishMage ), typeof( Ratman ), typeof( RatmanArcher ),
				typeof( RatmanMage ), typeof( Scorpion ), typeof( Shade ),
				typeof( SkeletalMage ), typeof( HellCat ), typeof( Snake ),
				typeof( Spectre ), typeof( StoneGargoyle ), typeof( StoneHarpy ),
				typeof( Titan ), typeof( Troll ), typeof( Wraith ), typeof( Wyvern ),
				typeof( LichLord ), typeof( SkeletalKnight )
			};
		 
		[Constructable]
		public DeceitBrazier() : base( 3633 )
		{		
			Movable = false; 
			Weight = 10.0;
		}
		
		public override bool HandlesOnMovement{ get{ return true; } }		
		
		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			if ( m.Player && Utility.InRange( m.Location, Location, 5 ) && !Utility.InRange( oldLocation, Location, 5 ) )
				PublicOverheadMessage( MessageType.Regular, 0x3B2, 500761 );
		}		

		public override void OnDoubleClick( Mobile from )
		{
			if (UseDelay)
			{
				from.SendLocalizedMessage(500759); //The brazier fizzes and pops, but nothing seems to happen.
				this.PlaySound( 92 );
			}
			else if (!from.InRange( this, 1 ))
			{
				from.SendLocalizedMessage(500295); //You are too far away to do that.
			}
			else if (!UseDelay && from.InRange( this, 1 ))
			{
				UseDelay= true;
				
				Mobile summon = Activator.CreateInstance( m_SpawnTypes[Utility.Random(m_SpawnTypes.Length)] ) as Mobile;
				summon.MoveToWorld( this.Location, this.Map );	
				summon.Paralyze( TimeSpan.FromSeconds( 2 ) );	
								
				summon.FixedParticles( 0x3709, 1, 30, 9904, 1108, 6, EffectLayer.RightFoot );
				this.PlaySound( 0x107 );
				this.PlaySound( 80 );
			
				Timer.DelayCall( TimeSpan.FromMinutes( 10.0 ), new TimerCallback( ResetDelay ) );	
			}		
			else
			{
				from.SendLocalizedMessage(500759); //The brazier fizzes and pops, but nothing seems to happen.
				this.PlaySound( 92 );
			}
		}
		
		public void ResetDelay( )
		{
			UseDelay = false; 
		}

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