/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\mobiles\FrostBeetle.cs
Lines of code: 141
***********************************************************/


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

namespace Server.Mobiles
{
	[CorpseName( "a frost beetle corpse" )]
	public class FrostBeetle : BaseMount
	{
		
		public bool tamed = false;
		public override bool SubdueBeforeTame{ get{ return true; } } 
		public override bool StatLossAfterTame{ get{ return true; } }

		public override TimeSpan MountAbilityDelay { get { return TimeSpan.FromMinutes( 1.5 ); } }

		public override bool DoMountAbility( int damage, Mobile attacker )
		{
			if( Rider == null || attacker == null )	//sanity
				return false;
				
			if ( 0.4 >= Utility.RandomDouble() && Rider.Map == attacker.Map && Rider.InRange( attacker, 18 ) )
			{
				attacker.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 );
				attacker.Damage( Utility.RandomMinMax( 20, 40 ), this, false );	

				Rider.SendMessage("Your beetle defends you against your foe with a blast of cold");	
				Rider.FixedParticles( 0, 0, 0, 0x13A7, EffectLayer.Waist );
				Rider.PlaySound( 0x21D );	
				return true;
			}

			return false;
		}

		[Constructable]
		public FrostBeetle() : this( "a frost beetle" )
		{
		}

		[Constructable]
		public FrostBeetle( string name ) : base( "a frost beetle", 0xA9, 0x3E95, AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			SetStr( 270, 310 );
			SetDex( 82, 116 );
			SetInt( 489, 524 );

			SetHits( 360, 415 );

			SetDamage( 7, 20 );

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

			SetResistance( ResistanceType.Physical, 40, 55 );
			SetResistance( ResistanceType.Fire, 10, 18 );
			SetResistance( ResistanceType.Cold, 70, 80 );
			SetResistance( ResistanceType.Poison, 30, 45 );
			SetResistance( ResistanceType.Energy, 30, 50 );

			SetSkill( SkillName.MagicResist, 90.0 );
			SetSkill( SkillName.Tactics, 100.0 );
			SetSkill( SkillName.Wrestling, 100.0 );

			Fame = 5000;
			Karma = -5000;

			Tamable = true;
			ControlSlots = 3;
			MinTameSkill = 95.9;

			PackItem( new SpidersSilk( Utility.RandomMinMax( 16, 25 ) ) );
			PackItem( new ValoriteIngot( 2 ) );

			Hue = 1154;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Rich );
			AddLoot( LootPack.LowScrolls );
			AddLoot( LootPack.Potions );
		}
		
		public override int GetAngerSound()
		{
			return 0x21D;
		}

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

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

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

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

		public override int Meat{ get{ return 16; } }
		public override FoodType FavoriteFood{ get{ return FoodType.Meat; } }

		public override double GetControlChance( Mobile m )
		{
			return 1.0;
		}
		
		public void IceAura()
		{
			ArrayList list = new ArrayList();
			
			foreach ( Mobile m in this.GetMobilesInRange( 5 ) )
			{
				if ( this != m && this.InLOS( m ) && this.ShouldHarm( m ) )
					list.Add( m );
			}

			foreach ( Mobile m in list )
			{
				DoHarmful( m );
				
				m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 );
				m.PlaySound( 0x1FB );
				m.PlaySound( 0x10B );
				m.SendMessage( "You are hit with intense cold" );

				int toharm = Utility.RandomMinMax( 20, 40 );
				AOS.Damage(m, this, toharm, 0, 0, 100, 0, 0 );
			}
		}
		
		public override void OnGaveMeleeAttack( Mobile defender )
		{
			base.OnGaveMeleeAttack( defender );

			if ( 0.4 >= Utility.RandomDouble() )
				IceAura();
		}
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
			if ( 0.4 >= Utility.RandomDouble() )
				IceAura();
			
			base.OnDamage(amount, attacker, willKill);	
		}
		
		public FrostBeetle( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 1 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if ( version == 0 )
				AI = AIType.AI_Super;
		}
	}
}