/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Mar-09-2012 08:19:35pm
Filepath: scripts\Mobiles\custom mobiles - to sort\ML Named\Saliva.cs
Lines of code: 144

Description: 

***********************************************************/


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

namespace Server.Mobiles
{
	[CorpseName( "a saliva corpse" )]
	public class Saliva : BaseCreature
	{
		[Constructable]
		public Saliva() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "Saliva";
			Body = 30;
			Hue = 286;
			BaseSoundID = 402;

			SetStr( 141, 206 );
			SetDex( 124, 222 );
			SetInt( 84, 94 );

			SetHits( 487, 842 );
			SetStam( 123, 222 );
			SetMana( 118, 127 );

			SetDamage( 15, 17 );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 40, 48 );
			SetResistance( ResistanceType.Fire, 30, 36 );
			SetResistance( ResistanceType.Cold, 30, 36 );
			SetResistance( ResistanceType.Poison, 35, 40 );
			SetResistance( ResistanceType.Energy, 25, 30 );

			SetSkill( SkillName.MagicResist, 84.1, 96.0 );
			SetSkill( SkillName.Tactics, 129.9, 142.0 );
			SetSkill( SkillName.Wrestling, 106.8, 128.8 );

			Fame = 8500;
			Karma = -8500;

			VirtualArmor = 32;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich );
			AddLoot( LootPack.FilthyRich, 2 );
			AddLoot( LootPack.Gems, 6 );
			
		}
public override void OnDeath( Container c )
{
	if ( Utility.Random( 4 ) == 0 )
	{
		Item item;

		switch ( Utility.Random( 1 ))
		{
                        default:
			case 1: item = new SalivasFeather(); break;
					}

		c.DropItem( item );
	}

	base.OnDeath( c );
}
		public override int GetAttackSound()
		{
			return 916;
		}

		public override int GetAngerSound()
		{
			return 916;
		}

		public override int GetDeathSound()
		{
			return 917;
		}

		public override int GetHurtSound()
		{
			return 919;
		}

		public override int GetIdleSound()
		{
			return 918;
		}

		public override bool IsMLBoss { get { return true;} }
		public override int TreasureMapLevel{ get{ return 6; } }
		public override double MLChestChance{ get{ return 0.05; } }
		
		public override bool CanRummageCorpses { get { return true; } }
		public override int Meat { get { return 4; } }
		public override MeatType MeatType { get { return MeatType.Bird; } }
		public override int Feathers { get { return 50; } }
		public override bool IsMLCreature { get { return true;} }
		
		public override void OnGaveMeleeAttack( Mobile defender )
		{
			base.OnGaveMeleeAttack( defender );

			if ( 0.2 > Utility.RandomDouble() )
			{
				ExpireTimer timer = (ExpireTimer)m_Table[defender];

				if ( timer != null )
				{
					timer.DoExpire();
					defender.SendMessage("Saliva lands another blow in your weakened state"); 
				}
				else
					defender.SendMessage("Saliva's talons reduce your energy resistance");

				int effect = -(defender.EnergyResistance * 20 / 100);

				ResistanceMod mod = new ResistanceMod( ResistanceType.Energy, effect );

				defender.FixedEffect( 0x37B9, 10, 5 );
				defender.AddResistanceMod( mod );

				timer = new ExpireTimer( defender, mod, TimeSpan.FromSeconds( 5.0 ) );
				timer.Start();
				m_Table[defender] = timer;
			}
		}

		private static Hashtable m_Table = new Hashtable();

		private class ExpireTimer : Timer
		{
			private Mobile m_Mobile;
			private ResistanceMod m_Mod;

			public ExpireTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
			{
				m_Mobile = m;
				m_Mod = mod;
				Priority = TimerPriority.TwoFiftyMS;
			}

			public void DoExpire()
			{
				m_Mobile.RemoveResistanceMod( m_Mod );
				Stop();
				m_Table.Remove( m_Mobile );
			}

			protected override void OnTick()
			{
				m_Mobile.SendMessage("Your resistance to energy attacks has returned"); 
				DoExpire();
			}
		}
		
		
		


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