/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\engines\ML Peerless + misc areas\demitel\Dark Palace\Mobiles\BloodVampire.cs
Lines of code: 203
***********************************************************/


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

//Ability breakdown
//Bleed immune
//Poison immune
//Vampiric bite (Bleed attack)
//All melee damage it does heals it
//Chance to reflect spells
//Dark aura (Drains area)
//Drains archers if they attack from afar
//Casts necromancy
//On death, turns into a BloodVampire bat

namespace Server.Mobiles
{
	[CorpseName( "a vampiric corpse" )]
	public class BloodVampire : BaseCreature
	{
	private bool m_BatForm;
		public override WeaponAbility GetWeaponAbility()
		{
			return WeaponAbility.BleedAttack;
		}

		[Constructable]
		public BloodVampire() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = NameList.RandomName( "Vampire" );
			Body = 400;
			Hue = 33918;
			HairHue = 33;

			SetStr( 198, 287 );
			SetDex( 404, 626 );
			SetInt( 300, 400 );

			SetHits( 680, 800 );

			SetDamage( 11, 22 );

			SetDamageType( ResistanceType.Physical, 75 );
			SetDamageType( ResistanceType.Cold, 25 );

			SetResistance( ResistanceType.Physical, 60 );
			SetResistance( ResistanceType.Fire, 40, 50 );
			SetResistance( ResistanceType.Cold, 80 );
			SetResistance( ResistanceType.Poison, 80 );
			SetResistance( ResistanceType.Energy, 40, 50 );

			SetSkill( SkillName.EvalInt, 70, 90 );
			SetSkill( SkillName.Magery, 90, 110 );
			SetSkill( SkillName.Meditation, 100.1, 101.0 );
			SetSkill( SkillName.Poisoning, 100.1, 101.0 );
			SetSkill( SkillName.MagicResist, 175.2, 200.0 );
			SetSkill( SkillName.Necromancy, 100, 110.0 );
			SetSkill( SkillName.SpiritSpeak,90, 100.0 );
			SetSkill( SkillName.Tactics, 115.0 );
			SetSkill( SkillName.Wrestling, 115.0 );

			Fame = 20000;
			Karma = -50000;

			VirtualArmor = 60;
			
			Item shroud = new HoodedShroudOfShadows();
			shroud.Movable = false;
			shroud.Hue = 1157;
			AddItem( shroud );

			Necklace necklace = new Necklace();
			necklace.Hue = 33;
			AddItem( necklace );

			Cloak cloak = new Cloak();
			cloak.Hue = 1157;
			AddItem( cloak );

			HalfApron apron = new HalfApron();
			apron.Hue = 1194;
			AddItem( apron );

			Sandals sandals = new Sandals();
			sandals.Hue = 1194;
			AddItem( sandals );
		}
		
		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 3 );
			AddLoot( LootPack.MedScrolls, 6 );
			PackNecroReg( 40, 212 );
		}

		public override int GetIdleSound()
		{
			return 0x19D;
		}

		public override int GetAngerSound()
		{
			return 0x175;
		}

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

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

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

		public override bool Unprovokable{ get{ return true; } }
		public override bool BleedImmune{ get{ return true; } }
		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
		public override bool ReacquireOnMovement{ get{ return true; } }
		public override int TreasureMapLevel{ get{ return 5; } }
		public override bool AlwaysMurderer{ get{ return true; } }

		public void DarkAura()
		{
			ArrayList list = new ArrayList();

			foreach ( Mobile m in this.GetMobilesInRange( 15 ) )
			{
				if ( m == this || !CanBeHarmful( 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 );
				this.FixedParticles( 0x375A, 1, 17, 9919, 67, 7, EffectLayer.Waist );
				m.FixedParticles( 0x375A, 1, 17, 9919, 0x96C, 7, EffectLayer.Waist );
				m.FixedParticles( 0x3728, 1, 13, 9502, 0x96C, 7, (EffectLayer)255 );
				m.PlaySound( 0x20D );

				m.SendMessage( "The vampire drains the life out of you!" );

				int toDrain = Utility.RandomMinMax( 30, 50 );

				Hits += toDrain * 2;
				m.Damage( toDrain, this );
			}
		}
		
		public override void OnDamagedBySpell(Mobile attacker)
		{
			if ( 0.1 >= Utility.RandomDouble() && 0.3 >= Utility.RandomDouble() )
				DarkAura();
		}

		public override void OnGaveMeleeAttack( Mobile defender)
		{
			base.OnGaveMeleeAttack( defender );
			
			int meleehit = Utility.RandomMinMax( 10, 35 ); //Drain hit
			Hits += meleehit; 

			if ( 0.1 >= Utility.RandomDouble() && 0.3 >= Utility.RandomDouble() )
				DarkAura();
		}

		public override void OnGotMeleeAttack( Mobile attacker )
		{
			base.OnGotMeleeAttack( attacker );
			
			if ( 0.3 > Utility.RandomDouble() && !attacker.InRange( this, 3 ) ) //Ranged attackers get solo drained
			{
			attacker.FixedParticles( 0x375A, 1, 17, 9919, 0x96C, 7, EffectLayer.Waist );
			attacker.FixedParticles( 0x3728, 1, 13, 9502, 0x96C, 7, (EffectLayer)255 );
			attacker.PlaySound( 0x20D );
			int toDrain = Utility.RandomMinMax( 30, 50 );

			Hits += toDrain;
			attacker.Damage( toDrain, this );
			}
			
			if ( 0.1 >= Utility.RandomDouble() && 0.3 >= Utility.RandomDouble() )
				DarkAura();
		}
		
		public override bool OnBeforeDeath()
		{
			if (!m_BatForm)
			{
				Morph();
				return false;
			}
			else
			{
				Effects.SendLocationEffect( Location, Map, 0x3709, 30, 10, 67, 0 );
				Body = 400;
				Hue = 33918; 
				GenerateLoot ();
				return true;
			}
		}	
		
		public void Morph() //Second form, BloodVampire bat
		{

			m_BatForm = true;
			
			Effects.SendLocationEffect( Location, Map, 0x3709, 30, 10, 67, 0 );
			
			Name = "a vampire bat";
			Title = "";
			Body = 317;
			Hue = 1644;
			BaseSoundID = 0x270;

			SetStr( 120 );
			SetDex( 480 );
			SetInt( 100 );

			SetHits( 290 );
			SetStam( 480 );
			SetMana( 20 );

			SetDamage( 5, 10 );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 10, 15 );
			SetResistance( ResistanceType.Fire, 10, 15 );
			SetResistance( ResistanceType.Cold, 10, 15 );
			SetResistance( ResistanceType.Poison, 10, 15 );
			SetResistance( ResistanceType.Energy, 10, 15 );

			SetSkill( SkillName.Wrestling, 95.1, 100.0 );
			SetSkill( SkillName.Tactics, 50.0 );
		}
		
		public BloodVampire( 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();
		}
	}
}