/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:13pm
Filepath: scripts\events and scenarios\Halloween2011\Bosses\Deranged Witch\DerangedWitch.cs
Lines of code: 189

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 witch's corpse" )] 
	public class DerangedWitch : BaseCreature 
	{ 
		private bool m_Reflect;
		private DateTime MembraneTimer;
		private DateTime DelayTimer;//
		
		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(1155, "Halloween Green", 5);	
					m.SendMessage(200,"You receive a gift: Halloween Green Dye");
					m.GiveItem(gift);				
				}
				else if(0.15 >= Utility.RandomDouble())
				{
				
					if(0.5 >= Utility.RandomDouble()) {
						gift = new BlackCatStatuette();	
						m.SendMessage(200,"You receive a gift: Black Cat Statuette");
					}						
					else if (0.25 >= Utility.RandomDouble()) {
						gift = new HalloweenGhoulStatuette();
						m.SendMessage(200,"You receive a gift: Halloween Ghoul Statuette");
					}
					else {
						gift = new PlatinumToken();	
						m.SendMessage(200,"You receive a gift: Platinum Token");
					}
					m.GiveItem(gift);
				}
				else if(0.05 >= Utility.RandomDouble())
				{
					gift = new ConjurersGrimoire();
					m.SendMessage(200,"You receive a gift: Conjurer's Grimoire");
					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 DerangedWitch() : base( AIType.AI_Super, FightMode.Closest, 10, 1, 0.2, 0.4 ) 
		{ 
			Title = "the Deranged Witch";
			Name = "Ethel";
			Hue = 0x83EA;
			Female = true;
			Body = 0x191;
			HairItemID = 0x203C;
			HairHue = 1167;

			SetStr( 81, 105 );
			SetDex( 98, 128 );
			SetInt( 400, 450 );
			SetMana( 1000, 1000 );

			SetHits( 5000, 5000 );

			SetDamage( 10, 15 );

			SetDamageType( ResistanceType.Physical, 100 );

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

			SetSkill( SkillName.EvalInt, 60.2, 100.0 );
			SetSkill( SkillName.Magery, 110.0, 120.0 );
			SetSkill( SkillName.Meditation, 50.5, 100.0 );
			SetSkill( SkillName.MagicResist, 77.5, 100.0 );
			SetSkill( SkillName.Tactics, 65.0, 87.5 );
			SetSkill( SkillName.Macing, 80.3, 105.0 );

			Fame = 15000;
			Karma = -15000;
			
			AddItem( new Robe( 0x1 ) );
			AddItem( new Sandals() );
			AddItem( new WizardsHat( 0x1 ) );
			AddItem( new GoldBracelet() );

			Item staff = new GnarledStaff();
			staff.Movable = false;
			AddItem( staff );
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.Rich, 7 );
			AddLoot( LootPack.SuperBoss, 7 );	
		}

		public override bool CanRummageCorpses{ get{ return true; } }
		public override int TreasureMapLevel{ get{ return Core.AOS ? 6 : 0; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool CantbeSupreme { get { return true;} }
		public override bool CantbeParagon { get { return true;} }	
		public override bool AlwaysMurderer{ get{ return true; } }
		
		public override void OnDamage( int amount, Mobile attacker, bool willKill ) 
		{
			if(attacker!=null && m_Reflect == true)
			{
			
				Item scroll = attacker.Backpack.FindItemByType(typeof(DerangedWitchHint));
				int ReflectedDMG;
			
				if (scroll != null) {
					ReflectedDMG = (int)amount;
					attacker.SendMessage("Your attack has been reflected. Your scroll reduces the power of the attack.");
				}
				else {
					ReflectedDMG = (int)amount * Utility.RandomMinMax(1, 3);
					attacker.SendMessage("Your attack has been reflected back to you with immense force!");
				}

				AOS.Damage( attacker, this, ReflectedDMG, true, 0, 0, 0, 0, 0,0,100,false );
			}
			base.OnDamage(amount, attacker, willKill);	
		}
		
		public override void OnThink ()
		{
			if ( this.Alive && this!=null && m_Reflect == true && (MembraneTimer < DateTime.Now) ) {
				PublicOverheadMessage( MessageType.Regular, 0x3B2, true, "*Reflect spell ends*" );
				DelayTimer=DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(45, 120));
				m_Reflect = false;
			}	
			else if ( this.Alive && this!=null && m_Reflect == true ) {
				this.FixedParticles( 0x373A, 1, 15, 9913, 39, 7, EffectLayer.Head );
			}
			
			if (0.2 >= Utility.RandomDouble() && 0.2 >= Utility.RandomDouble() && m_Reflect == false && (DelayTimer < DateTime.Now))
			{
				PublicOverheadMessage( MessageType.Regular, 0x3B2, true, "*Casts reflect*" );
				m_Reflect = true;
				MembraneTimer=DateTime.Now + TimeSpan.FromSeconds(MembraneFuse.Next( 5, 30 ));
			}	
			
			base.OnThink();	
		}

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