/**********************************************************
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\Putrefier.cs
Lines of code: 117

Description: 

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


using System;
using Server;
using Server.Items;
using Server.Spells.Necromancy;
using System.Collections;
using Server.Network;
using Server.Targeting;
using Server.Mobiles;

namespace Server.Mobiles
{
	[CorpseName( "a putrefier corpse" )]
	public class Putrefier : BaseCreature
	{
		private DateTime lastability;
		
		[Constructable]
		public Putrefier() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "Putrefier";
			Body = 40;
			Hue = 263;
			BaseSoundID = 357;

			SetStr( 1035 , 1340 );
			SetDex( 306 , 369 );
			SetInt( 233 , 321 );

			SetHits( 3614, 3858 );
			SetStam( 306, 369 );
			SetMana( 233, 321 );

			SetDamage( 32, 47 );

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

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

			SetSkill( SkillName.Anatomy, 30.1, 60.0 );
			SetSkill( SkillName.EvalInt, 108.1, 130.0 );
			SetSkill( SkillName.Magery, 114.6, 120.0 );
			SetSkill( SkillName.Necromancy, 60.0, 80.0 );
			SetSkill( SkillName.SpiritSpeak, 60.0, 80.0 );
			SetSkill( SkillName.Meditation, 30.1, 60.0 );
			SetSkill( SkillName.MagicResist, 120.6, 180.0 );
			SetSkill( SkillName.Tactics, 108.1, 120.0 );
			SetSkill( SkillName.Wrestling, 108.1, 120.0 );

			Fame = 30000;
			Karma = -30000;

			VirtualArmor = 90;
			lastability = DateTime.Now;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 4 );
			PackSWScroll(5);
		}

		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 Poison PoisonImmune { get { return Poison.Lethal; } }
		public override int Meat { get { return 1; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool IsMLCreature { get { return true;} }
 
		public override void OnDamage( int amount, Mobile attacker, bool willKill )
		{
			if( attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.5 > Utility.RandomDouble() )
			{
				GasAttack( attacker );
			}	
			else if(attacker != null && (!(attacker.Weapon is BaseRanged)) && attacker.Alive && !attacker.InRange( this, 3 ) && 0.3 > Utility.RandomDouble())
			{
				GasAttack( attacker );
			}	
			else if (0.1 > Utility.RandomDouble() && attacker != null)
			{
				GasAttack( attacker );
			}	

			base.OnDamage( amount, attacker, willKill );
		}

		private void GasAttack( Mobile attacker )
		{
			this.Animate( 10, 4, 1, true, false, 0 );

			ArrayList targets = new ArrayList();

			foreach ( Mobile m in attacker.GetMobilesInRange( 14 ) )
			{
				if ( m == attacker || this.ShouldHarm(m))
					targets.Add( m );
			}
			for ( int i = 0; i < targets.Count; ++i )
			{
				Mobile m = (Mobile)targets[i];
				
				DoHarmful( m );

				AOS.Damage( m, this, Utility.RandomMinMax( 25, 50 ), true, 0, 0, 0, 100, 0 );

				m.FixedParticles( 0x36BD, 1, 10, 0x1F78, 0xA6, 0, (EffectLayer)255 );
				m.ApplyPoison( this, Poison.Lethal );
			}
		}

		public override void OnDeath( Container c )
		{
			if ( Utility.Random( 4 ) == 2 )c.DropItem(new PutrefierSpleen() );
			

			base.OnDeath( c );
		}

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