/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-26-2009 12:30:00am
Filepath: scripts\_custom\mobiles\Faleryn.cs
Lines of code: 85
***********************************************************/


using System;
using Server;
using Server.Items;

namespace Server.Mobiles
{
	[CorpseName( "a faleryn corpse" )]
	public class Faleryn : BaseCreature
	{
		private int splitsleft=2;
		
		
		[Constructable]
		public Faleryn() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "a faleryn";
			Body = 47;
			Hue = 2406;
			BaseSoundID = 442;

			SetStr( 66, 215 );
			SetDex( 66, 75 );
			SetInt( 101, 250 );

			SetHits( 80, 156 );

			SetDamage( 11, 14 );

			SetDamageType( ResistanceType.Physical, 20 );
			SetDamageType( ResistanceType.Poison, 80 );

			SetResistance( ResistanceType.Physical, 35, 45 );
			SetResistance( ResistanceType.Fire, 20, 30 );
			SetResistance( ResistanceType.Cold, 20, 40 );
			SetResistance( ResistanceType.Poison, 60, 80 );
			SetResistance( ResistanceType.Energy, 30, 40 );

			SetSkill( SkillName.EvalInt, 90.1, 100.0 );
			SetSkill( SkillName.Magery, 90.1, 100.0 );
			SetSkill( SkillName.Necromancy, 100.0, 120.0 );
			SetSkill( SkillName.SpiritSpeak, 100.1, 120.0 );
			SetSkill( SkillName.MagicResist, 100.1, 125.0 );
			SetSkill( SkillName.Tactics, 45.1, 60.0 );
			SetSkill( SkillName.Wrestling, 50.1, 60.0 );

			Fame = 4500;
			Karma = -5500;

			VirtualArmor = 40;

			PackItem( new Log( 15 ) );
			PackItem( new MandrakeRoot( 5 ) );
			PackItem( new NoxCrystal( 5 ) );
		}
		
		public override void OnGotMeleeAttack( Mobile attacker )
		{
		Map map = attacker.Map;
		if(map==null)return;
		
		if (splitsleft>0 && attacker.InRange( this, 2 ) && 0.2 > Utility.RandomDouble())
		{
			
			int x = this.X + Utility.RandomMinMax( -3, 3 );
			int y = this.Y + Utility.RandomMinMax( -3, 3 );
			int z = this.Z;
			if ( map.CanSpawnMobile( new Point3D( x, y, z) ) )
			{
				Faleryn spawn = new Faleryn();
				
				splitsleft--;
				spawn.splitsleft=Math.Max(0,(splitsleft-(1+(Utility.Random(1)))));
				spawn.Team=Team;
				spawn.SetHits( HitsMax/3, HitsMax/2 );
				
				attacker.SendMessage( "The limb you sliced off becomes another faleryn" );
				spawn.MoveToWorld( new Point3D( x, y, z ), Map );
				spawn.Combatant = attacker;
			}	
		}
		}

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

		public override Poison PoisonImmune{ get{ return Poison.Deadly; } }
		public override int TreasureMapLevel{ get{ return 2; } }

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