/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\resources\Masterpiece Resources\Ultra Rare\TotemOfExtinction.cs
Lines of code: 119
***********************************************************/


using System;
using Server;
using Server.Targeting;

namespace Server.Items
{

	public class TotemOfExtinction : Item
	{
		public int dmg1; 
			
		[Constructable]
		public TotemOfExtinction() : base( 8707 )
		{
			Name = "Totem Of Extinction";
			Hue = 1324;
			Weight = 1.0;

			//Pick a random slayer (Stored in numbers right now)

			switch ( Utility.Random( 7 ) )
			{
				default:
				case 0: dmg1 = 0;break;
				case 1: dmg1 = 1;break;
				case 2: dmg1 = 2;break;
				case 3: dmg1 = 3;break;
				case 4: dmg1 = 4;break;
				case 5: dmg1 = 5;break;
				case 6: dmg1 = 6;break;	
			}			
		}
		
		
		
		private void GetDmgString(ref string prop1)
		{
			//Stores a string according to the slayer damage variable. This is used to inform the player
			//which slayer the item contains (gargoyle, elemental, etc)
			switch ( dmg1 )
			{
				default:
				case 0: prop1 = "Undead";break;
				case 1: prop1 = "Fey";break;
				case 2: prop1 = "Elemental";break;
				case 3: prop1 = "Daemon";break;
				case 4: prop1 = "Arachnid";break;
				case 5: prop1 = "Reptile";break;
				case 6: prop1 = "Repond";break;
			}
		}

		public TotemOfExtinction( Serial serial ) : base( serial )
		{
		}
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

			string prop1="a";
			GetDmgString(ref prop1);			
			
			list.Add(1060658,"Masterpiece Bonus \t{0}", prop1 + " Slayer" + " (15 Points)");
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1060640 );
			}
			else
			{
				from.Target = new WeaponTarget( this );
				from.SendMessage( "Empower which weapon?" );
			}					
		}
		
		private class WeaponTarget : Target
		{
			private TotemOfExtinction m_TotemOfExtinction;

			public WeaponTarget( TotemOfExtinction powder ) : base( 2, false, TargetFlags.None )
			{
				m_TotemOfExtinction = powder;
			}
			
			protected override void OnTarget( Mobile from, object targeted ) 
			{ 
				if ( targeted is BaseWeapon )
				{
					BaseWeapon wp = (BaseWeapon)targeted;

					if ( wp.IsChildOf( from.Backpack ) && m_TotemOfExtinction.IsChildOf( from.Backpack ) && wp.MasterPiecePoints >= 15 )
					{
						//Assign the new slayer to the weapon
						switch (m_TotemOfExtinction.dmg1 )
						{
							default:
							case 0: wp.Slayer2 = SlayerName.Silver; break;
							case 1: wp.Slayer2 = SlayerName.Fey; break;
							case 2: wp.Slayer2 = SlayerName.ElementalBan; break;
							case 3: wp.Slayer2 = SlayerName.Exorcism; break;
							case 4: wp.Slayer2 = SlayerName.ArachnidDoom; break;
							case 5: wp.Slayer2 = SlayerName.ReptilianDeath; break;
							case 6: wp.Slayer2 = SlayerName.Repond; break;
						}	
				
						from.FixedParticles( 0x37C4, 1, 8, 9916, 90, 3, EffectLayer.Head );
						from.FixedParticles( 0x37C4, 1, 8, 9502, 90, 4, EffectLayer.Head );
						from.PlaySound( 0x210 );
						from.FixedParticles( 0x373A, 1, 17, 9903, 90, 4, EffectLayer.Head );
						from.PlaySound( 0x244 );
						wp.MasterPiecePoints -= 15;
						
						string prop1="a";
						m_TotemOfExtinction.GetDmgString(ref prop1);
						
						from.SendMessage( "Your weapon now has the ability to slay "+ prop1);
						m_TotemOfExtinction.Consume();
					}
					else if (wp.MasterPiecePoints <= 14)
						from.SendMessage( "You either don't have enough points or the item is not a Masterpiece" );
				}
				else
					from.SendMessage( "That cannot be empowered" );
			}
		}

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

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