/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:12pm
Filepath: scripts\events and scenarios\Halloween2011\Bosses\Sorceress of the Night\SorceressOfTheNight.cs
Lines of code: 271

Description: 

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


using System; 
using Server;
using Server.Items;
using Server.Targeting;
using Server.Network;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Server.Mobiles 
{ 
	[CorpseName( "a sorceress' corpse" )] 
	public class SorceressOfTheNight : BaseCreature 
	{ 
	
		private bool m_Mist;
		private DateTime MembraneTimer;
		private DateTime DelayTimer;//
		private int spawntype = 0;
		
		Random MembraneFuse = new Random(); 
	
	
		public static void GiveReward(Mobile boss)
		{
			ArrayList toGive = new ArrayList();
			List<DamageStore> rights = BaseCreature.GetLootingRights( boss.DamageEntries, boss.HitsMax );

			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];
				if ( ds.m_HasRight )	toGive.Add( ds.m_Mobile );
			}
			if ( rights.Count == 0 )return;	
			
			for(int i=0;i<rights.Count;i++)
			{
				Mobile m = rights[i].m_Mobile;			
				PlayerMobile pm = m as PlayerMobile;	
	
				Item gift = new BlackToadstool();	
						
				if(0.6 >= Utility.RandomDouble())
				{
					if(0.75 >= Utility.RandomDouble()) {
						gift = new BlackToadstool();	
						m.SendMessage(200,"You receive a gift: Black Toadstools");
					}
					else if (0.15 >= Utility.RandomDouble()) {
						gift = new GreenToadstool();
						m.SendMessage(200,"You receive a gift: Green Toadstools");
					}
					else if (0.10 >= Utility.RandomDouble()) {
						gift = new RedToadstool();
						m.SendMessage(200,"You receive a gift: Red Toadstools");
					}
					m.GiveItem(gift);			
				}
				else if(0.2 >= Utility.RandomDouble())
				{
					gift = new PigmentBottle(1163, "Halloween Purple", 5);	
					m.SendMessage(200,"You receive a gift: Halloween Purple Dye");
					m.GiveItem(gift);				
				}
				else if(0.15 >= Utility.RandomDouble())
				{
				
					if(0.5 >= Utility.RandomDouble()) {
						gift = new RuinedTapestry();	
						m.SendMessage(200,"You receive a gift: Ruined Tapestry");
					}						
					else if (0.25 >= Utility.RandomDouble()) {
						gift = new PumpkinScareCrow();
						m.SendMessage(200,"You receive a gift: Pumpkin Scarecrow");
					}
					else {
						gift = new PlatinumToken();	
						m.SendMessage(200,"You receive a gift: Platinum Token");
					}
					m.GiveItem(gift);
				}
				else if(0.05 >= Utility.RandomDouble())
				{
					gift = new ConjurersSandals();
					m.SendMessage(200,"You receive a gift: Conjurer's Sandals");
					m.GiveItem(gift);
				}
				else
				{
					gift = new BlackToadstool();	
					m.SendMessage(200,"You receive a gift: Black Toadstools");
					m.GiveItem(gift);
				}	
			}
		}	

		public override void OnDeath( Container c )
		{
			base.OnDeath( c );
			GiveReward(this);	
		}
	
		[Constructable] 
		public SorceressOfTheNight() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 ) 
		{ 
			Name = "Sorceress Of The Night";
			Hue = 0;
			Female = true;
			Body = 0x191;
			HairItemID = 8253;
			HairHue = 1150;

			SetStr( 586, 785 );
			SetDex( 177, 255 );
			SetInt( 351, 450 );
			
			SetMana( 1000, 1500);

			SetHits( 5000, 5000 );

			SetDamage( 13, 19 );

			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 80, 90 );
			SetResistance( ResistanceType.Fire, 20, 30 );
			SetResistance( ResistanceType.Cold, 90, 100 );
			SetResistance( ResistanceType.Poison, 30, 40 );
			SetResistance( ResistanceType.Energy, 80, 90 );

			SetSkill( SkillName.Anatomy, 50.1, 75.0 );
			SetSkill( SkillName.EvalInt, 99.1, 100 );
			SetSkill( SkillName.Magery, 99.1, 100.0 );
			SetSkill( SkillName.Meditation, 90.1, 100.0 );
			SetSkill( SkillName.MagicResist, 90.1, 100.0 );
			SetSkill( SkillName.Tactics, 90.1, 100.0 );
			SetSkill( SkillName.Swords, 97.6, 100.0 );

			Fame = 20000;
			Karma = -20000;

			Item EyeGlasses = new EyeGlasses();
			EyeGlasses.Movable = false;
			EyeGlasses.Hue = 1150;
			AddItem( EyeGlasses );
			
			Item Necklace = new Necklace();
			Necklace.Movable = false;
			Necklace.Hue = 1150;
			AddItem( Necklace );
			
			Item FemaleStuddedChest = new FemaleStuddedChest();
			FemaleStuddedChest.Movable = false;
			FemaleStuddedChest.Hue = 1175;
			AddItem( FemaleStuddedChest );
			
			Item GoldBracelet = new GoldBracelet();
			GoldBracelet.Movable = false;
			GoldBracelet.Hue = 1163;
			AddItem( GoldBracelet );
			
			Item Cloak = new Cloak();
			Cloak.Movable = false;
			Cloak.Hue = 1163;
			AddItem( Cloak );
			
			Item Sandals = new Sandals();
			Sandals.Movable = false;
			Sandals.Hue = 1175;
			AddItem( Sandals );
			
			Item blade = new RuneBlade();
			blade.Movable = false;
			blade.Hue = 1150;
			AddItem( blade );
		}

		public override int TreasureMapLevel{ get{ return Core.AOS ? 6 : 0; } }
		public override bool CantbeSupreme { get { return true;} }
		public override bool CantbeParagon { get { return true;} }	
		public override bool AlwaysMurderer{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool NoFlee { get { return true; } }				

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Rich, 7 );
			AddLoot( LootPack.SuperBoss, 7 );	
		}
		
		public override void OnThink()
		{
		
			Mobile spawn;
		
			if (this.Hits <= 3000 && spawntype == 0)
			{
				spawntype += 1;
				this.Say( "*Strange figures form out of the mist*" );
				
				for(int i=0;i<4;i++)
				{
				spawn = new LadyOfTheMist();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}				


			}
			else if (this.Hits <= 1500 && spawntype == 1)
			{
				spawntype += 1;
				this.Say( "*Strange figures form out of the mist*" );

				for(int i=0;i<6;i++)
				{
				spawn = new LadyOfTheMist();
				SetTempSummon(this,spawn);
				spawn.MoveToWorld( this.Location, this.Map );
				}	

			}
		
			if ( this.Alive && this!=null && m_Mist == true && (MembraneTimer < DateTime.Now) ) {
				PublicOverheadMessage( MessageType.Regular, 0x3B2, true, "*The mist subsides*" );
				DelayTimer=DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(45, 120));
				m_Mist = false;
			}	
			else if ( this.Alive && this!=null && m_Mist == true ) {
				this.FixedParticles( 0x373A, 1, 15, 9913, 1153, 7, EffectLayer.Head );
			}
			
			if ( this.Alive && this!=null && m_Mist == true) 
			{
				List<Mobile> todamage = new List<Mobile>();
				
				foreach ( Mobile m in this.GetMobilesInRange( 9 ) )
				{
					if (!( m==null || !m.Alive || m == this || !CanBeHarmful( m ) || !ShouldHarm( m )))
					{
						todamage.Add(m);
					}
				}				
				
				
				for(int i=0;i<todamage.Count;i++)
				{
					Mobile m = (Mobile)todamage[i];
			
					if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) )
					{
						AOS.Damage( m, this, 2 * (20 - (int)this.GetDistanceToSqrt(m)), 0, 0, 50, 0, 50 );
						m.Stam -= Utility.Random( 5, 15 );
						m.Mana -= Utility.Random( 5, 15 );
						m.FixedParticles( 0x374A, 1, 15, 5054, 1153, 7, EffectLayer.Head );
						m.SendMessage("The deadly mist is draining you!");
					}
					else if ( m.Player && m.Alive && m != null )
					{
				
						Item scroll = m.Backpack.FindItemByType(typeof(SorceressOfTheNightHintScroll));
			
						if (scroll != null) {
							AOS.Damage( m, this, 2 * (12 - (int)this.GetDistanceToSqrt(m)), 0, 0, 50, 0, 50 );
							m.Stam -= Utility.Random( 1, 10 );
							m.Mana -= Utility.Random( 1, 10 );
							m.FixedParticles( 0x374A, 1, 15, 5054, 1153, 7, EffectLayer.Head );
							m.SendMessage("The deadly mist is draining you! Your scroll reduces some of the damage");
						}
						else {
							AOS.Damage( m, this, 2 * (20 - (int)this.GetDistanceToSqrt(m)), 0, 0, 50, 0, 50 );
							m.Stam -= Utility.Random( 5, 15 );
							m.Mana -= Utility.Random( 5, 15 );
							m.FixedParticles( 0x374A, 1, 15, 5054, 1153, 7, EffectLayer.Head );
							m.SendMessage("The deadly mist is draining you!");
						}
					}
				}
			}
			
			if (0.2 >= Utility.RandomDouble() && 0.2 >= Utility.RandomDouble() && m_Mist == false && (DelayTimer < DateTime.Now))
			{
				PublicOverheadMessage( MessageType.Regular, 0x3B2, true, "*A strange mist forms*" );
				m_Mist = true;
				MembraneTimer=DateTime.Now + TimeSpan.FromSeconds(MembraneFuse.Next( 10, 45 ));
			}	
			
			base.OnThink();	
		}

		public override void OnGaveMeleeAttack( Mobile defender )
		{
			base.OnGaveMeleeAttack( defender );

			defender.Stam -= Utility.Random( 1, 10 );
			defender.Mana -= Utility.Random( 1, 10 );
		}

		public override void OnGotMeleeAttack( Mobile attacker )
		{
			base.OnGotMeleeAttack( attacker );

			attacker.Stam -= Utility.Random( 1, 10 );
			attacker.Mana -= Utility.Random( 1, 10 );
		}

		public SorceressOfTheNight( Serial serial ) : base( serial ) 
		{ 
		} 

		public override void Serialize( GenericWriter writer ) 
		{ 
			base.Serialize( writer ); 
			writer.Write( (int) 0 ); 
			writer.Write(spawntype);
		} 

		public override void Deserialize( GenericReader reader ) 
		{ 
			base.Deserialize( reader ); 
			int version = reader.ReadInt(); 
			spawntype = reader.ReadInt();
		} 
	}
}