/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\events and scenarios\misc\Halloween Event\Halloween Items\HelDragon.cs
Lines of code: 131
***********************************************************/


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

namespace Server.Mobiles
{
	[CorpseName( "a hel dragon corpse" )]
	public class HelDragon : BaseCreature
	{
		[Constructable]
		public HelDragon () : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "a hel dragon";
			Body = 46;
			BaseSoundID = 362;
			Hue = 1150;

			SetStr( 2096, 2185 );
			SetDex( 86, 175 );
			SetInt( 775, 800 );

			SetHits( 1000, 1200 );

			SetDamage( 25, 30 );

			SetDamageType( ResistanceType.Physical, 50 );
			SetDamageType( ResistanceType.Cold, 50 );

			SetResistance( ResistanceType.Physical, 50, 60 );
			SetResistance( ResistanceType.Fire, 20, 30 );
			SetResistance( ResistanceType.Cold, 500, 600 );
			SetResistance( ResistanceType.Poison, 50, 60 );
			SetResistance( ResistanceType.Energy, 30, 40 );
			

			SetSkill( SkillName.EvalInt, 100.0, 110.0 );
			SetSkill( SkillName.Magery, 100.0, 110.0 );
			SetSkill( SkillName.Meditation, 52.5, 75.0 );
			SetSkill( SkillName.MagicResist, 100.5, 150.0 );
			SetSkill( SkillName.Tactics, 97.6, 100.0 );
			SetSkill( SkillName.Wrestling, 97.6, 100.0 );

			Fame = 30000;
			Karma = -30000;

			VirtualArmor = 70;	
			
			for (int i = 0; i < 5; i++)
			{
				PackItem( new HalloweenPumpkin() );
				PackItem( new HalloweenBlood() );
				PackItem( new RandomTalisman());
			}
			
			PackItem( new HalloweenDeadTree() );
			PackItem( new HalloweenDeadTree() );		
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 10 );
			AddLoot( LootPack.SuperBoss, 3 );
			AddLoot( LootPack.Gems, 12 );
		}

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

		public override int GetHurtSound()
		{
			return 0x2D1;
		}
		
		public override bool NoFlee { get { return true; } }
		public override bool AutoDispel{ get{ return true; } }
		public override double AutoDispelChance{ get{ return 0.7; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool BardImmune{ get{ return true; } }
		public override bool ReacquireOnMovement{ get{ return true; } }
		public override HideType HideType{ get{ return HideType.Barbed; } }
		public override int Hides{ get{ return 120; } }
		public override int Meat{ get{ return 19; } }
		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
		public override Poison HitPoison{ get{ return Utility.RandomBool() ? Poison.Regular : Poison.Greater; } }
		public override int TreasureMapLevel{ get{ return 6; } }
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
		
			if (0.05 >= Utility.RandomDouble())
				SummonWhirlwind( attacker );
				
			if (0.1 >= Utility.RandomDouble())
				WhirlingBlow();
				
			if (attacker!=null && 0.1 >= Utility.RandomDouble())	
				this.Location = attacker.Location;
				
			base.OnDamage(amount, attacker, willKill );			
		}
		
		public void SummonWhirlwind( Mobile attacker )
		{
			if(attacker==null)return;
			
			Mobile spawn;
		
			spawn = new HelWhirlwind();
			spawn.MoveToWorld( this.Location, this.Map );	
			spawn.Combatant = attacker;
		}
		
		public void WhirlingBlow()
		{
			ArrayList list = new ArrayList();

			foreach ( Mobile m in this.GetMobilesInRange( 20 ) )
			{
				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 );
			}

			for(int i=0;i<list.Count;i++)
			{
			Mobile m = (Mobile)list[i];
				DoHarmful( m );
				
				m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 );
				m.PlaySound( 0x1FB );
				m.PlaySound( 0x10B );
				m.SendMessage( "The power of the whirling winds tears through your flesh!" );

				int toharm = Utility.RandomMinMax( 85, 100 );
				AOS.Damage(m, this, toharm, 0, 0, 100, 0, 0 );
			}
		}

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