/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\Mobiles\Monsters\SE\YomotsuPriest.cs
Lines of code: 221
***********************************************************/


using System;
using Server;
using System.Collections;
using Server.Items;
using Server.Targeting;
using Server.Spells;
using Server.Spells.Seventh;
using Server.Spells.Fifth;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Spellweaving;
using Server.Engines.CannedEvil;

namespace Server.Mobiles
{
	[CorpseName( "a glowing yomotsu corpse" )]
	public class YomotsuPriest : BaseCreature
	{
		public override WeaponAbility GetWeaponAbility()
		{
			return WeaponAbility.DoubleStrike;
		}
		
		private static DateTime lastmorph;

		[Constructable]
		public YomotsuPriest() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "a yomotsu priest";
			Body = 253;
			BaseSoundID = 0x452;

			SetStr( 486, 530 );
			SetDex( 101, 115 );
			SetInt( 601, 670 );

			SetHits( 486, 530 );

			SetDamage( 8, 10 );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 65, 85 );
			SetResistance( ResistanceType.Fire, 30, 50 );
			SetResistance( ResistanceType.Cold, 45, 65 );
			SetResistance( ResistanceType.Poison, 35, 55 );
			SetResistance( ResistanceType.Energy, 25, 50 );

			SetSkill( SkillName.EvalInt, 92.6, 107.5 );
			SetSkill( SkillName.Magery, 105.1, 115.0 );
			SetSkill( SkillName.Meditation, 100.1, 110.0 );
			SetSkill( SkillName.MagicResist, 112.6, 122.5 );
			SetSkill( SkillName.Tactics, 55.1, 105.0 );
			SetSkill( SkillName.Wrestling, 47.6, 57.5 );

			Fame = 9000;
			Karma = -9000;


			PackItem( new GreenGourd() );
			PackItem( new ExecutionersAxe() );

			switch ( Utility.Random( 3 ) )
			{
				case 0: PackItem( new LongPants() ); break;
				case 1: PackItem( new ShortPants() ); break;
			}

			switch ( Utility.Random( 6 ) )
			{
				case 0: PackItem( new Shoes() ); break;
				case 1: PackItem( new Sandals() ); break;
				case 2: PackItem( new Boots() ); break;
				case 3: PackItem( new ThighBoots() ); break;
			}

			if ( Utility.RandomDouble() < .25 ) PackItem( Engines.Plants.Seed.RandomBonsaiSeed() );
		}

		public override FoodType FavoriteFood{ get{ return FoodType.Fish; } }

		public override int Meat{ get{ return 1; } }



		public override void GenerateLoot()
		{
			AddLoot( LootPack.FilthyRich );
			AddLoot( LootPack.Rich );
			AddLoot( LootPack.Gems, 4);
		}

		public override bool CanRummageCorpses{ get{ return true; } }

		public override void OnThink ()
		{
			if ( !IsBodyMod && 0.001 > Utility.RandomDouble() && this.Alive && (lastmorph+TimeSpan.FromMinutes(5))<DateTime.Now ) 
					Polymorph( this );
		}
		
		public void Polymorph( Mobile m )
		{
			if ( !m.CanBeginAction( typeof( PolymorphSpell ) ) || !m.CanBeginAction( typeof( IncognitoSpell ) ) || m.IsBodyMod )
				return;

			IMount mount = m.Mount;

			if ( mount != null )
				mount.Rider = null;

			if ( m.Mounted )
				return;

			if ( m.BeginAction( typeof( PolymorphSpell ) ) )
			{
			
				Item disarm = m.FindItemOnLayer( Layer.OneHanded );

				if ( disarm != null && disarm.Movable )
					m.AddToBackpack( disarm );

				disarm = m.FindItemOnLayer( Layer.TwoHanded );

				if ( disarm != null && disarm.Movable )
					m.AddToBackpack( disarm );
					
				switch ( Utility.Random( 14 ) )
				{
					default:
					case 0: 
						m.NameMod = "a yomotsu warrior";
						m.BodyMod = 245;
						break;
					case 1: 
						m.NameMod = "a deathwatch beetle";
						m.BodyMod = 242; 
						break;
					case 2:
						m.NameMod = "a fan dancer";
						m.BodyMod = 247;
						break;
					case 3: 
						m.NameMod = "a kappa";
						m.BodyMod = 240;
						break;
					case 4: 
						m.NameMod = "a kaze kemono";
						m.BodyMod = 196;
						break;
					case 5: 
						m.NameMod = "a lady of the snow";
						m.BodyMod = 252;
						break;
					case 6: 
						m.NameMod = "an oni";
						m.BodyMod = 241;
						break;
					case 7: 
						m.NameMod = "a Rai-Ju";
						m.BodyMod = 199;
						break;
					case 8:
						m.NameMod = "a Revenant Lion";
						m.BodyMod = 251;
						break;
					case 9: 
						m.NameMod = "a rune beetle";
						m.BodyMod = 244;
						break;
					case 10: 
						m.NameMod = "a tsuki wolf";
						m.BodyMod = 250;
						break;
					case 11: 
						m.NameMod = "a yamandon";
						m.BodyMod = 249;
						break;
					case 12:
						m.NameMod = "a yomotsu elder";
						m.BodyMod = 255;
						break;
					case 13: 
						m.NameMod = "a bake kitsune";
						m.BodyMod = 246;
						break;
				}

				m.HueMod = 0;

				new ExpirePolymorphTimer( m ).Start();
			}
		}

		private class ExpirePolymorphTimer : Timer
		{
			private Mobile m_Owner;

			public ExpirePolymorphTimer( Mobile owner ) : base( TimeSpan.FromMinutes( 5.0 ) )
			{
				m_Owner = owner;

				Priority = TimerPriority.OneSecond;
			}

			protected override void OnTick()
			{
				if ( !m_Owner.CanBeginAction( typeof( PolymorphSpell ) ) )
				{
					m_Owner.BodyMod = 0;
					m_Owner.HueMod = -1;
					m_Owner.NameMod = null;
					lastmorph = DateTime.Now;
					m_Owner.EndAction( typeof( PolymorphSpell ) );
				}
			}
		}

		public override void OnGaveMeleeAttack( Mobile defender )
 		{
			base.OnGaveMeleeAttack( defender );

			if ( 0.1 > Utility.RandomDouble() )
			{
				/* Maniacal laugh
				 * Cliloc: 1070840
				 * Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(884 715, 10)" ToLocation: "(884 715, 10)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
				 * Paralyzes for 4 seconds, or until hit
				 */
				 
				defender.PlaySound( 0x204 );
				defender.PlaySound( 1321 );

				defender.FixedEffect( 0x37B9, 10, 5 );
				defender.SendLocalizedMessage( 1070840 ); // You are frozen as the creature laughs maniacally.

				defender.Paralyze( TimeSpan.FromSeconds( 4.0 ) );
			}
		}

		public YomotsuPriest( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
		}
		
		public override int GetIdleSound()
		{
			return 0x42A;
		}

		public override int GetAttackSound()
		{
			return 0x435;
		}

		public override int GetHurtSound()
		{
			return 0x436;
		}

		public override int GetDeathSound()
		{
			return 0x43A;
		}
	}
}
