using System; using Server; using Server.Targeting; namespace Server.Items { public class RareClothingDye : Item { private int m_DyeHue; [CommandProperty( AccessLevel.GameMaster )] public int DyeHue { get { return m_DyeHue; } set { m_DyeHue = value; InvalidateProperties(); } } [Constructable] public RareClothingDye() : this( Utility.RandomList( 1, 1150, 1154, 1157, 1161, 1166, 1175, 1254 ) ) { } [Constructable] public RareClothingDye( int hue ) : base( 0xE27 ) // Round bottle graphic { Weight = 1.0; m_DyeHue = hue; Hue = m_DyeHue; Name = "a vial of rare clothing dye"; } public override void OnDoubleClick( Mobile from ) { if ( !IsChildOf( from.Backpack ) ) { from.SendLocalizedMessage( 1042001 ); return; } from.SendMessage( "Target the piece of clothing you wish to magically dye." ); from.Target = new InternalTarget( this ); } private class InternalTarget : Target { private RareClothingDye m_Dye; public InternalTarget( RareClothingDye dye ) : base( 1, false, TargetFlags.None ) { m_Dye = dye; } protected override void OnTarget( Mobile from, object targeted ) { if ( m_Dye.Deleted ) return; if ( !m_Dye.IsChildOf( from.Backpack ) ) { from.SendLocalizedMessage( 1042001 ); return; } if ( targeted is BaseClothing ) { BaseClothing clothing = (BaseClothing)targeted; // Ensure the player actually owns the item they are trying to dye if ( !clothing.IsChildOf( from.Backpack ) && clothing.Parent != from ) { from.SendMessage( 33, "You must be holding or wearing that item to dye it." ); return; } clothing.Hue = m_Dye.DyeHue; from.PlaySound( 0x23E ); from.SendMessage( 63, "The magical dye seeps into the fabric, altering its color completely." ); m_Dye.Delete(); } else { from.SendMessage( 33, "This magical dye will only adhere to fabrics and clothing." ); } } } public RareClothingDye( Serial serial ) : base( serial ) { } public override void Serialize( GenericWriter writer ) { base.Serialize( writer ); writer.Write( (int) 0 ); // version writer.Write( (int) m_DyeHue ); } public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); m_DyeHue = reader.ReadInt(); } } }