using System; 
using Server;
using Server.Items;

namespace Server.Mobiles 
{ 
	public class MindFlayer : BaseCreature 
	{ 
		[Constructable] 
		public MindFlayer() : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 ) 
		{ 
			Name = "a mindflayer";
			Body = 132;
			BaseSoundID = 0x605;
			AnimationMod = 4;
			Clan = Clan.Wizard;

			SetStr( 81, 105 );
			SetDex( 191, 215 );
			SetInt( 126, 150 );

			SetHits( 49, 63 );

			SetDamage( 5, 10 );

			SetSkill( SkillName.Concentration, 80.2, 100.0 );
			SetSkill( SkillName.Magery, 95.1, 100.0 );
			SetSkill( SkillName.Meditation, 27.5, 50.0 );
			SetSkill( SkillName.MagicResist, 77.5, 100.0 );
			SetSkill( SkillName.Tactics, 65.0, 87.5 );
			SetSkill( SkillName.HandToHand, 20.3, 80.0 );

			Fame = 10500;
			Karma = -10500;

			VirtualArmor = 16;
			PackReg( 23 );
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Average );
			AddLoot( LootPack.Meager );
			AddLoot( LootPack.MedScrolls, 2 );
		}

		public void DrainBrain( Mobile m )
		{
			if ( m.Mana > 0 )
			{
				DoHarmful( m );
				m.SendMessage( "The creature feeds on your mind!" );
				int toDrain = Utility.RandomMinMax( 2, 10 );
				m.PlaySound( 0x386 );
				Mana += toDrain;
				m.Mana -= toDrain;
			}
		}

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

		public override void OnGotMeleeAttack( Mobile attacker )
		{
			base.OnGotMeleeAttack( attacker );
			DrainBrain( attacker );
		}

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

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