/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\leviathan artifacts\PirateCoffin.cs
Lines of code: 72
***********************************************************/


using System;
using Server;
using Server.Multis;
using Server.Items;
using Server.Mobiles;

//using System.Collections;
//using System.Collections.Generic;
//using Server.Targeting;
//using Server.ContextMenus;
//using Server.Network;
//using Server.Regions;

namespace Server.Items
{
	public class PirateCoffin : Item
	{
		 
		public static string Pirate;
		public bool IsSpawned = false;  
		 
		[Constructable]
		public PirateCoffin() : base( 16142 )
		{
			switch ( Utility.Random( 8 ) )
			{
				default:
				case 0: Pirate = "Pirate Pete's"; break;
				case 1: Pirate = "Greybeard's"; break;
				case 2: Pirate = "Scimitar Sam's"; break;
				case 3: Pirate = "Swashbucket Fred's"; break;
				case 4: Pirate = "Trecherous Tim's"; break;
				case 5: Pirate = "Vile Vic's"; break;
				case 6: Pirate = "Jealous Jack's"; break;
				case 7: Pirate = "Wanted Will's"; break;
			}
		
			Hue = 2406; 		
			Name = Pirate + " Coffin"; 
			Weight = 10.0;
		}
		
		public bool IsOwner( Mobile mob )
		{
			BaseHouse house = BaseHouse.FindHouseAt( this );

			return ( house != null && house.IsOwner( mob ) );
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( !this.IsLockedDown )
				from.SendLocalizedMessage( 502693 ); // Remember, this only works when locked down.
			else if (!from.InRange( this, 2 ))
				from.SendMessage( "You are too far away" );
			else if (!IsSpawned)
			{
				IsSpawned = true;
				BaseCreature spawn = new PirateGhost(); 
			
				spawn.SetControlMaster( from );
				spawn.SummonMaster = from;
				spawn.MoveToWorld( from.Location, from.Map );
				spawn.FixedParticles( 0x3709, 1, 30, 9904, 1108, 6, EffectLayer.RightFoot );
				spawn.PlaySound( 0x1BB );
				Timer.DelayCall( TimeSpan.FromSeconds( 7.0 ), new TimerCallback( ResetSpawn ) );
			}
		}
		
		public void ResetSpawn( )
		{
			IsSpawned = false; 
		}

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

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
	}
}