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


using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Engines.CannedEvil;

namespace Server.Mobiles
{
	[CorpseName( "a dragoon corpse" )]
	public class ChaosDragoonElite : BaseCreature
	{
		public override bool ClickTitle{ get{ return false; } }
		private DateTime lastability;
		private CraftResource res;
		
		public override bool AlwaysMurderer{ get{ return true; } }		
		public override bool CantDismount { get {return true; } }		

		[Constructable]
		public ChaosDragoonElite() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Hue = Utility.RandomSkinHue();
			Name = "a chaos dragoon elite";
			Body = (( this.Female = Utility.RandomBool() ) ? Body = 0x191 : Body = 0x190);
			
			Hue = Utility.RandomSkinHue();

			SetStr( 276, 350 );
			SetDex( 86, 95 );
			SetInt( 126, 150 );
			
			SetHits( 276, 350 );
			SetStam( 86, 95 );
			SetMana( 126, 150 );

			SetDamage( 24, 26 );
			
			SetDamageType( ResistanceType.Chaos, 100 );

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

			SetSkill( SkillName.Tactics, 87.6, 97.5 );
			SetSkill( SkillName.MagicResist, 87.6, 97.5 );
			SetSkill( SkillName.Anatomy, 87.6, 97.5 );
			SetSkill( SkillName.Swords, 92.6, 150.5 );
			SetSkill( SkillName.Magery, 80.1, 90.0 );
			SetSkill( SkillName.EvalInt, 80.1, 90.0 );
			SetSkill( SkillName.Meditation, 80.1, 90.0 );

			Fame = 8000;
			Karma = -8000;
			
			switch ( Utility.Random( 6 ) )
			{
				case 0: res = CraftResource.BlackScales; PackItem( new BlackScales (2) ); break;
				case 1: res = CraftResource.RedScales; PackItem( new RedScales (2) ); break;
				case 2: res = CraftResource.BlueScales; PackItem( new BlueScales (2) ); break;
				case 3: res = CraftResource.YellowScales; PackItem( new YellowScales (2) ); break;
				case 4: res = CraftResource.GreenScales; PackItem( new GreenScales (2) ); break;
				case 5: res = CraftResource.WhiteScales; PackItem( new WhiteScales (2) ); break;
			}
			
			DragonHelm helm = new DragonHelm();
			helm.Resource = res;
			AddItem( helm );
			helm.Movable = false;
			
			DragonGloves gloves = new DragonGloves();
			gloves.Resource = res;
			AddItem( gloves );
			gloves.Movable = false;
			
			DragonArms arms = new DragonArms();
			arms.Resource = res;
			AddItem( arms );
			arms.Movable = false;
			
			DragonChest chest = new DragonChest();
			chest.Resource = res;
			AddItem( chest );
			chest.Movable = false;
			
			DragonLegs legs = new DragonLegs();
			legs.Resource = res;
			AddItem( legs );
			legs.Movable = false;
			
			ThighBoots boots = new ThighBoots();
			boots.Hue=1;
			AddItem( boots );
			boots.Movable = false;
			
			ChaosShield shield = new ChaosShield();
			AddItem( shield );
			shield.Movable = false;
			
			Broadsword wep = new Broadsword();
			AddItem( wep );
			wep.Movable = false;

			Utility.AssignRandomHair( this );

			SwampDragon mount = new SwampDragon();
			mount.HasBarding = true;
			mount.Hue = 2101;
			mount.Rider = this;
			lastability = DateTime.Now;
		}

		public override void OnThink ()
		{
			if ( this.Hits < this.HitsMax && this.Mounted && 0.04 > Utility.RandomDouble() && (lastability+TimeSpan.FromSeconds(15))<DateTime.Now) 
					StompAttack();
					
			base.OnThink();	
		}
		
		public override bool OnBeforeDeath()
		{
			IMount mount = this.Mount;

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

			if ( mount is Mobile )
				((Mobile)mount).Delete();

			return base.OnBeforeDeath();
		}
	
		public static readonly TimeSpan DefenderRemountDelay = TimeSpan.FromSeconds( 10.0 );
		
		public void StompAttack()
		{
			ArrayList list = new ArrayList();

			foreach ( Mobile m in this.GetMobilesInRange( 6 ) )
			{
				if ( m == this || !CanBeHarmful( m ) || !ShouldHarm( m ))
					continue;

				if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) )
					list.Add( m );
				else if ( m.Player )
					list.Add( m );
			}

			foreach ( Mobile m in list )
			{
				DoHarmful( m );

				m.SendMessage( "The swamp dragon shakes the earth with a powerful stomp" );
				if (m.Mounted)	
				{
					m.Dismount();
					
					m.SendLocalizedMessage( 1060083 ); // You fall off of your mount and take damage!

					m.PlaySound( 0x140 );
					m.FixedParticles( 0x3728, 10, 15, 9955, EffectLayer.Waist );

					AOS.Damage( m, this, Utility.RandomMinMax( 15, 25 ), 100, 0, 0, 0, 0 );
					BaseMount.SetMountPrevention( m, BlockMountType.Dazed, DefenderRemountDelay );
				}
				else {
					m.PlaySound( 0x204 );
					m.SendLocalizedMessage( 1060164 ); // The attack has temporarily paralyzed you
					m.Paralyze( TimeSpan.FromSeconds( 5.0 ) );
				}
			}
			lastability=DateTime.Now;
		}
		
		public override void OnDeath( Container c )
 		{
			base.OnDeath( c );
 		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich );
			AddLoot( LootPack.Gems, 1 ); 
		}

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