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

Description: 

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


using System;
using Server;
using Server.Items;

namespace Server.Mobiles
{
	[CorpseName( "a miasma corpse" )]
	public class Miasma : BaseCreature
	{
		public override WeaponAbility GetWeaponAbility()
		{
			return WeaponAbility.MortalStrike;
		}

		[Constructable]
		public Miasma() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.15, 0.18  )
		{
			Name = "Miasma";
			Body = 48;
			Hue = 975;
			BaseSoundID = 397;

			SetStr( 172, 877 );
			SetDex( 102, 442 );
			SetInt( 151, 296 );

			SetStam( 102, 442 );
			SetMana( 151, 296 );
			SetHits( 600, 1940 );

			SetDamage( 22, 28 );

			SetDamageType( ResistanceType.Physical, 60 );
			SetDamageType( ResistanceType.Poison, 40 );

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

			SetSkill( SkillName.Anatomy, 78.3, 84.3 );
			SetSkill( SkillName.Poisoning, 117.2, 122.6 );
			SetSkill( SkillName.Meditation, 65.1, 80.0 );
			SetSkill( SkillName.MagicResist, 86.3, 90.3 );
			SetSkill( SkillName.Tactics, 104.6, 109.2 );
			SetSkill( SkillName.Wrestling, 112.0, 121.0 );
			SetSkill( SkillName.DetectHidden, 112.0, 121.0 );

			Fame = 11000;
			Karma = -11000;

			VirtualArmor = 50;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 2 );
			AddLoot( LootPack.FilthyRich );
		}
		
		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 AutoDispel{ get{ return true; } }
		public override double AutoDispelChance{ get{ return 0.4; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
		public override Poison HitPoison{ get{ return Poison.Lethal; } }
		public override double HitPoisonChance{ get{ return 0.4; } }
		public override bool IsMLCreature { get { return true;} }
		
		public override void OnThink()
		{
			if (this.Combatant != null)
			{
				Mobile target = this.Combatant; 
		
				if (this.InLOS( target ) && !target.InRange( this, 7 ) && target != null && 0.3 > Utility.RandomDouble() && 0.3 > Utility.RandomDouble())
				{	
					this.Location = target.Location;
					target = this.Combatant; 
				}
			}
		
			base.OnThink( );	
		}
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
			if(attacker!=null && attacker is BaseCreature && 0.1 >= Utility.RandomDouble())
			{
				if(((BaseCreature)attacker).ControlMaster!=null)
				{
					Combatant=((BaseCreature)attacker).ControlMaster;
				}
				else if(((BaseCreature)attacker).SummonMaster!=null)
				{
					Combatant=((BaseCreature)attacker).SummonMaster;
				}
			}	
				
			base.OnDamage(amount, attacker, willKill );			
		}
 
		public Miasma( 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();
		}
	}
}