/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Mar-09-2012 08:19:35pm
Filepath: scripts\Mobiles\custom mobiles - to sort\ML Named\Swoop.cs
Lines of code: 118

Description: 

***********************************************************/


using System;
using Server;
using Server.Items;
using System.Collections;

namespace Server.Mobiles
{
	[CorpseName( "a swoop corpse" )]
	public class Swoop : BaseCreature
	{
	
		public override WeaponAbility GetWeaponAbility()
		{
			switch ( Utility.Random( 2 ) )
			{
				default:
				case 0: return WeaponAbility.ArmorIgnore;
				case 1: return WeaponAbility.CrushingBlow;
			}
		}
		
		[Constructable]
		public Swoop () : base( AIType.AI_Melee, FightMode.Closest, 18, 1, 0.2, 0.4  )
		{
			Name = "Swoop";
			Hue = 222;
			Body = 5;
			BaseSoundID = 0x2EE;			
			
			SetStr( 139, 196 );
			SetDex( 428, 489 );
			SetInt( 84, 129 );

			SetHits( 1200, 1430 );

			SetDamage( 20, 30 );

			SetDamageType( ResistanceType.Physical, 100);

			SetResistance( ResistanceType.Physical, 70);
			SetResistance( ResistanceType.Fire, 35, 40 );
			SetResistance( ResistanceType.Cold, 43, 50 );
			SetResistance( ResistanceType.Poison, 23, 43 );
			SetResistance( ResistanceType.Energy, 25, 45 );

			SetSkill( SkillName.Anatomy, 45.6, 62.4 );
			SetSkill( SkillName.Meditation, 30.6, 60.3 );
			SetSkill( SkillName.MagicResist, 99.1, 104.3 );
			SetSkill( SkillName.Tactics, 97.8, 109.2 );
			SetSkill( SkillName.Wrestling, 90.2, 114.0 );

			Fame = 5000;
			Karma = -5000;

			VirtualArmor = 36;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 2 );
			AddLoot( LootPack.FilthyRich );
		}
		
		public override bool IsMLBoss { get { return true;} }
		public override int TreasureMapLevel{ get{ return 6; } }
		public override double MLChestChance{ get{ return 0.05; } }
		
		public override bool Unprovokable{ get{ return true; } }
		public override bool IsMLCreature { get { return true;} }
		public override int Meat{ get{ return 6; } }
		public override MeatType MeatType{ get{ return MeatType.Bird; } }
		public override int Feathers{ get{ return 72; } }
 
		public override void OnGaveMeleeAttack( Mobile defender )
		{
			base.OnGaveMeleeAttack( defender );

			if ( 0.2 > Utility.RandomDouble() )
			{
				ExpireTimer timer = (ExpireTimer)m_Table[defender];

				if ( timer != null )
				{
					timer.DoExpire();
					defender.SendMessage("Swoop lands another blow in your weakened state"); 
				}
				else
					defender.SendMessage("Swoop's talons reduce your physical resistance");

				int effect = -(defender.PhysicalResistance * 15 / 100);

				ResistanceMod mod = new ResistanceMod( ResistanceType.Physical, effect );

				defender.FixedEffect( 0x37B9, 10, 5 );
				defender.AddResistanceMod( mod );

				timer = new ExpireTimer( defender, mod, TimeSpan.FromSeconds( 5.0 ) );
				timer.Start();
				m_Table[defender] = timer;
			}
		}

		private static Hashtable m_Table = new Hashtable();

		private class ExpireTimer : Timer
		{
			private Mobile m_Mobile;
			private ResistanceMod m_Mod;

			public ExpireTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
			{
				m_Mobile = m;
				m_Mod = mod;
				Priority = TimerPriority.TwoFiftyMS;
			}

			public void DoExpire()
			{
				m_Mobile.RemoveResistanceMod( m_Mod );
				Stop();
				m_Table.Remove( m_Mobile );
			}

			protected override void OnTick()
			{
				m_Mobile.SendLocalizedMessage( 1070838 ); // Your resistance to physical attacks has returned.
				DoExpire();
			}
		}
		
		public Swoop( 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();

		}
	}
}