/**********************************************************
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\Uncommon\OrbOfElements.cs
Lines of code: 121
***********************************************************/


using System;
using Server;
using Server.Targeting;

namespace Server.Items
{

	public class OrbOfElements : Item
	{
		public int dmg1; 
			
		[Constructable]
		public OrbOfElements() : base( 3629 )
		{
			Name = "Orb of Elements";
			Weight = 1.0;

			//Pick a random elemental damage (Stored in numbers right now)

				switch ( Utility.Random( 6 ) )
				{
					default:
					case 0: dmg1 = 0; Hue = 996; break;
					case 1: dmg1 = 1; Hue = 1359; break;
					case 2: dmg1 = 2; Hue = 1153; break;
					case 3: dmg1 = 3; Hue = 75; break;
					case 4: dmg1 = 4; Hue = 326; break;
					case 5: dmg1 = 5; Hue = 32; break;
				}		
		}
		
		
		
		private void GetDmgString(ref string prop1)
		{
						//Stores a string according to the 2 elemental damage variables. This is used to inform the player
						//which damages the item contains (Phys/Fire or Cold/Poison, etc)
						switch ( dmg1 )
						{
							default:
							case 0: prop1 = "Physical";break;
							case 1: prop1 = "Fire";break;
							case 2: prop1 = "Cold";break;
							case 3: prop1 = "Poison";break;
							case 4: prop1 = "Energy";break;
							case 5: prop1 = "Chaos";break;
						}
		}
		
		
		
		
		

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

			string prop1="a";
			GetDmgString(ref prop1);			
			
			list.Add(1060658,"Masterpiece Bonus to Damage \t{0}", "100% " + prop1 + " (10 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 OrbOfElements m_OrbOfElements;

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

					if ( wp.IsChildOf( from.Backpack ) && m_OrbOfElements.IsChildOf( from.Backpack ) && wp.MasterPiecePoints >= 10 )
					{
					
						//Wipe the previous Elemental Damages so it can be replaced with the new ones
						wp.AosElementDamages.Physical=0;
						wp.AosElementDamages.Fire=0;
						wp.AosElementDamages.Cold=0;
						wp.AosElementDamages.Poison=0;
						wp.AosElementDamages.Energy=0;
						wp.AosElementDamages.Chaos=0;			
					
					
						//Assign the 2 new Elemental Damages to the weapon
						switch (m_OrbOfElements.dmg1 )
						{
							default:
							case 0: wp.AosElementDamages.Physical = 100;break;
							case 1: wp.AosElementDamages.Fire = 100;break;
							case 2: wp.AosElementDamages.Cold = 100;break;
							case 3: wp.AosElementDamages.Poison = 100;break;
							case 4: wp.AosElementDamages.Energy = 100;break;
							case 5: wp.AosElementDamages.Chaos = 100;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 -= 10;
						
						string prop1="a";
						m_OrbOfElements.GetDmgString(ref prop1);
						
						from.SendMessage( "Your weapon will now inflict "+ prop1 + " damage" );
						m_OrbOfElements.Consume();
					}
					else if (wp.MasterPiecePoints <= 9)
						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();			
		}
	}
}ÿ