/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: http://www.uovalor.com
Last modified by Death on Feb-15-2011 07:49:54pm
Filepath: scripts\_custom\events and scenarios\Slime Event 2011\Quest Giver\LydiaTheSlimeResearcher.cs
Lines of code: 176
***********************************************************/


using System;
using Server;
using Server.ContextMenus;
using Server.Accounting;
using Server.Gumps;
using Server.Items;
using Server.Menus;
using Server.Menus.Questions;
using Server.Mobiles;
using Server.Network;
using Server.Prompts;
using Server.Regions;
using Server.Misc;
using System.Collections;
using System.Collections.Generic;

namespace Server.Mobiles
{
	[CorpseName( "The corpse of poor Lydia" )]
	public class LydiaTheSlimeResearcher : BaseCreature
	{
		public override bool ClickTitle{ get { return false; } }
		
		public virtual int AutoTalkRange{ get{ return -1; } }
		public virtual int AutoSpeakRange{ get{ return 10; } }		
		public virtual TimeSpan SpeakDelay{ get{ return TimeSpan.FromSeconds( 10 ); } }
		
		private DateTime m_Spoken;	
                
		[Constructable]
		public LydiaTheSlimeResearcher() : base(AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4)
		{
			Name = "Lydia the Slime Researcher";
			HairItemID = 12239;
			HairHue = 1165;
            VirtualArmor = 50;
			Blessed = true;
			
			//SpeechHue = Utility.RandomDyedHue();
			Race=Race.Elf;
			Body = 0x25E;
			Female = true;
			Hue = 33768;

			Robe robe = new Robe();
			robe.Hue=1153;
			AddItem(robe);
			
			Sandals shoes = new Sandals();
			shoes.Hue=1165;
			AddItem(shoes);					
		}
		
		public LydiaTheSlimeResearcher( Serial serial ) : base( serial )
		{
		}
		
		public virtual void Advertise()
		{
			Say("Aha! You look like you're ready for action! Care to help me out?");
		}
		
		public virtual void GiveHint()
		{
		
			switch (Utility.RandomMinMax( 0, 6 ))
			{
				case 0: 
				Say("Try approaching villagers and other people in different facets. They might know where to find acid slimes");  break;
				case 1: 
				Say("The acid slime spawning time is strange. It seems as though once one is killed, it will take about a day or so for another to appear"); break;
				case 2: 
				Say("I've only seen a few acid slimes before so be sure to check each facet. My research indicates there are 5 acid slimes per facet"); break;
				case 3: 
				Say("Some of the slimes are a bit devious and rare. My research indicates that there are 10 common, 5 uncommon and 10 rare slime hues"); break;
				case 4: 
				Say("I have no doubt that people have seen these acid slimes. With so many villagers I assume at least 25 have witnessed an acid slime before"); break;
				case 5: 
				Say("Be careful when damaging the slime's membrane. Some of that pigmented blood may permanently dye your weapon or spellbook"); break;
				case 6: 
				Say("Each person who contributes enough damage to the kill will be able to fill 1 empty slime basin. Make sure you're close enough once it dies, the pigmented blood disolves quickly"); break;
			}
		}
		
		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			if ( m.Alive && !m.Hidden && m is PlayerMobile )
			{
				PlayerMobile pm = (PlayerMobile)m;

				int range = AutoTalkRange;
					
				range = AutoSpeakRange;
				
				if ( range >= 0 && InRange( m, range ) && !InRange( oldLocation, range ) && DateTime.Now >= m_Spoken + SpeakDelay )
				{
					//if ( Utility.Random( 100 ) < 50 ) {
						if ( m.Alive && m is PlayerMobile ) {
							PlayerMobile mobile = (PlayerMobile)m;
							
							Item basin = mobile.Backpack.FindItemByType(typeof(EmptySlimeBasin));
							if (basin == null)
							{
								Advertise();
							}
							else
							{
								GiveHint();
							}
						}	
					//}
					m_Spoken = DateTime.Now;
				}
			}
		}
		
		public override void OnDoubleClick( Mobile m )
		{
			if ( m.Alive && m is PlayerMobile ) {
				PlayerMobile mobile = (PlayerMobile)m;
							
				Item basin = mobile.Backpack.FindItemByType(typeof(FullSlimeBasin));
				if (basin == null)
				{
					mobile.SendGump(new LydiaTheSlimeResearcherQuestGump(mobile));
				}
				else
				{
					mobile.SendMessage("Thank you! Here's your reward as promised. Speak to me again if you are venturing out for more slimes.");
					
					FullSlimeBasin thisbasin = (FullSlimeBasin)basin;

					//Item am = new PigmentBottle(basin.Hue, "A slimy pigment", 3);		
					Item am = new PigmentBottle(thisbasin.Hue, thisbasin.colorname, 3);						
					Container pack = mobile.Backpack;

					if ( pack == null || !pack.TryDropItem( mobile, am, false )) {
						mobile.SendMessage("As your pack is full, an item has been placed in your bank box");
						mobile.BankBox.DropItem( am );		
						basin.Delete();						
					}
					else {
						mobile.SendMessage("An item has been placed in your backpack");
						basin.Delete();
					}
				}
			}				
		}

		public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list ) 
	    { 
			base.GetContextMenuEntries( from, list ); 
			list.Add( new LydiaTheSlimeResearcherEntry( from, this ) ); 
	    } 

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

		public class LydiaTheSlimeResearcherEntry : ContextMenuEntry
		{
			private Mobile m_Mobile;
			private Mobile m_Giver;
			
			public LydiaTheSlimeResearcherEntry( Mobile from, Mobile giver ) : base( 6146, 3 )
			{
				m_Mobile = from;
				m_Giver = giver;
			}

			public override void OnClick()
            {
                
				PlayerMobile mobile = (PlayerMobile)m_Mobile;
				
				if ( mobile.Alive && mobile is PlayerMobile ) {
							
					Item basin = mobile.Backpack.FindItemByType(typeof(FullSlimeBasin));
					if (basin == null)
					{
						mobile.SendGump(new LydiaTheSlimeResearcherQuestGump(mobile));
					}
					else
					{
						mobile.SendMessage("Thank you! Here's your reward as promised. Speak to me again if you are venturing out for more slimes.");

						Item am = new PigmentBottle(basin.Hue, "A slimy pigment", 3);	
						//Item am = new PigmentBottle(basin.Hue, basin.Name, 3);						
						Container pack = mobile.Backpack;

						if ( pack == null || !pack.TryDropItem( mobile, am, false )) {
							mobile.SendMessage("As your pack is full, an item has been placed in your bank box");
							mobile.BankBox.DropItem( am );		
							basin.Delete();						
						}
						else {
							mobile.SendMessage("An item has been placed in your backpack");
							basin.Delete();
						}
					}
				}
            }			
        }
	}	
}

