/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Mar-16-2011 07:06:14pm
Filepath: scripts\_custom\items\misc\staff\gmhat.cs
Lines of code: 104

Description: 

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


using Server;
using System;

namespace Server.Items
{
	
	public class gmhat : WizardsHat
	{
		AccessLevel m_orgaccess=AccessLevel.Player;	
		bool m_active=false;
		Mobile m_owner;
		
		
		[CommandProperty( AccessLevel.Owner )] 
		public bool isactive
		{
			get { return m_active; }
			set 
			{ 
				m_active = value;	Modify();
			}
		}

		[CommandProperty( AccessLevel.Owner )] 
		public AccessLevel originalaccesslevel
		{
			get { return m_orgaccess; }
			set 
			{ 
				m_orgaccess = value;	Modify();			
			}
		}		
		
		[CommandProperty( AccessLevel.Owner )] 
		public Mobile Owner
		{
			get { return m_owner; }
			set 
			{ 
				m_owner = value;	Modify();			
			}
		}			
		

		[Constructable]
		public gmhat() : base()
		{
		Name="GM Hat";
		LootType = LootType.Blessed;
		Hue=1169;

		Attributes.BonusHits= 100;
		Attributes.BonusStam= 100;
		Attributes.BonusMana= 100;

		Attributes.RegenHits= 100;
		Attributes.RegenStam= 100;
		Attributes.RegenMana= 100;
		Attributes.LowerRegCost=100;
		
		ClothingAttributes.SelfRepair=10;
		
		Attributes.CastRecovery=6;
		Attributes.CastSpeed=4;

		Resistances.Physical = 90;	
		Resistances.Fire = 90;	
		Resistances.Poison = 90;	
		Resistances.Cold = 90;
		Resistances.Energy = 90;		
		}
		
		
		public override void OnDoubleClick( Mobile from )
		{
			if(ParentEntity!=from && !IsChildOf( from.Backpack ))
			{
				from.SendMessage("You must equip or put this in your backpack in order to use");
				return;
			}

			if(Owner==null && from.AccessLevel>AccessLevel.Player)Owner=from;
			
			if(from!=Owner)
			{
				from.SendMessage("This is not yours and you cannot use it!");
				return;
			}
			
		
			if(!isactive)
			{
				originalaccesslevel=from.AccessLevel;
				from.AccessLevel=AccessLevel.Player;	
				isactive=true;
			}
			else
			{
				from.AccessLevel=originalaccesslevel;
				isactive=false;	
			}
		
		}
		

		

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

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 1 );
			
			writer.Write( (bool) m_active );		
			writer.Write( (byte) m_orgaccess );	
			writer.Write( (Mobile) m_owner );
		}
		
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			
			m_active = reader.ReadBool();	
			m_orgaccess = (AccessLevel) reader.ReadByte();
			
			if(version>=1)m_owner=reader.ReadMobile();
    	}
	}
	
}