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

Description: 

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


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

namespace Server.Mobiles
{
	[CorpseName( "a skeletal corpse" )]
	public class MasterTheophilus : BaseCreature
	{
		private ArrayList spawns = new ArrayList();
	
		[Constructable]
		public MasterTheophilus() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 )
		{
			Name = "Master Theophilus";
			Body = 125;
			BaseSoundID = 412;
			Hue = 0; 

			SetStr( 161, 189 );
			SetDex( 262, 301 );
			SetInt( 414, 448 );

			SetStam( 262, 301 );
			SetMana( 414, 448 );
			SetHits( 828, 874 );

			SetDamage( 15, 25 );//was 7,15

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 55, 60 );
			SetResistance( ResistanceType.Fire, 52, 60 );
			SetResistance( ResistanceType.Cold, 52, 60 );
			SetResistance( ResistanceType.Poison, 51, 58 );
			SetResistance( ResistanceType.Energy, 51, 60 );

			SetSkill( SkillName.EvalInt, 122.0, 134.5 );
			SetSkill( SkillName.Meditation, 130.6, 133.3 );
			SetSkill( SkillName.Necromancy, 70.0, 80.5 );
			SetSkill( SkillName.SpiritSpeak, 100.6, 110.3 );
			SetSkill( SkillName.Magery, 138.8, 140.2 );
			SetSkill( SkillName.MagicResist, 129.2, 130.9 );
			SetSkill( SkillName.Tactics, 113.6, 118.5 );
			SetSkill( SkillName.Wrestling, 67.6, 104.2 );

			Fame = 9500;
			Karma = -9500;

			VirtualArmor = 38;

			PackReg( 3 );
			PackNecroReg( 3, 10 );

 }
		public override void GenerateLoot()
		{
			AddLoot( LootPack.AosUltraRich );
			AddLoot( LootPack.AosSuperBoss,3 );
			AddLoot( LootPack.HighScrolls );
			AddLoot( LootPack.Potions );
		}

		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 Poison PoisonImmune { get { return Poison.Greater; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool BleedImmune { get { return true; } }
		public override bool IsMLCreature { get { return true;} }
 
		public MasterTheophilus( Serial serial ) : base( serial )
		{
		}
		
		
		public override void OnDeath( Container c )
		{
			if ( Utility.Random( 4 ) == 0 )
			{
				Item item;

				switch ( Utility.Random( 5 ))
				{
		                        default:
					case 0: item = new CohennNote1(); break;
					case 1: item = new CohennNote2(); break;
					case 2: item = new CohennNote3(); break;
					case 3: item = new CohennNote4(); break;
					case 4: item = new CohennNote5(); break;
				}
				
				c.DropItem( item );
			}
			else if(0.1>Utility.RandomDouble())c.DropItem(new MiscNote());
			

			base.OnDeath( c );
		}
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{

			if ( attacker!=null && attacker != this && GetLiveSpawns() < 4 && 0.25 > Utility.RandomDouble())
			{
				Mobile spawn;
			
				if (GetLiveSpawns()==3)
				{
					spawn = new Wraith();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);				
					attacker.SendMessage( "Master Theophilus summons a group of followers" );
					spawn.Combatant = attacker;
				}
				else if (GetLiveSpawns()==2)
				{
					spawn = new Spectre();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);		
					spawn = new Bogle();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);			
					attacker.SendMessage( "Master Theophilus summons a group of followers" );
					spawn.Combatant = attacker;
				}
				else if (GetLiveSpawns()==1)
				{
					spawn = new Wraith();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);		
					spawn = new Spectre();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);		
					spawn = new Bogle();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);		
					attacker.SendMessage( "Master Theophilus summons a group of followers" );
					spawn.Combatant = attacker;
				}
				else if (GetLiveSpawns()==0)
				{
					spawn = new Bogle();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);
					spawn = new Wraith();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);	
					spawn = new Spectre();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);	
					spawn = new Wraith();
					spawn.MoveToWorld( this.Location, this.Map );
					spawns.Add(spawn);		
					attacker.SendMessage( "Master Theophilus summons a group of followers" );
					spawn.Combatant = attacker;
				}
			}

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

		private int GetLiveSpawns()
		{
		int live=0;
				for( int i = 0; i < spawns.Count; ++i )
                {
                Mobile m = spawns[i] as Mobile;

                if( m == null || m.Deleted || !m.Alive)continue;
				live++;							
                }
				
		return live;
		}

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