protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item )
{
Item item = (Item)targeted;
if ( item.QuestItem )
{
from.SendLocalizedMessage( 1151836 ); // You may not dye toggled quest items.
}
else if ( item is IDyable && m_Tub.AllowDyables )
{
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
from.SendLocalizedMessage( 500446 ); // That is too far away.
else if ( item.Parent is Mobile )
from.SendLocalizedMessage( 500861 ); // Can't Dye clothing that is being worn.
else if ( ((IDyable)item).Dye( from, m_Tub ) )
from.PlaySound( 0x23E );
}
else if ( (FurnitureAttribute.Check( item ) || (item is PotionKeg)) && m_Tub.AllowFurniture )
{
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else
{
bool okay = ( item.IsChildOf( from.Backpack ) );
if ( !okay )
{
if ( item.Parent == null )
{
BaseHouse house = BaseHouse.FindHouseAt( item );
if ( house == null || ( !house.IsLockedDown( item ) && !house.IsSecure( item ) ) )
from.SendLocalizedMessage( 501022 ); // Furniture must be locked down to paint it.
else if ( !house.IsCoOwner( from ) )
from.SendLocalizedMessage( 501023 ); // You must be the owner to use this item.
else
okay = true;
}
else
{
from.SendLocalizedMessage( 1048135 ); // The furniture must be in your backpack to be painted.
}
}
if ( okay )
{
item.Hue = m_Tub.DyedHue;
from.PlaySound( 0x23E );
}
}
}
else if ( (item is Runebook || item is RecallRune ) && m_Tub.AllowRunebooks )
{
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if ( !item.Movable )
{
from.SendLocalizedMessage( 1049776 ); // You cannot dye runes or runebooks that are locked down.
}
else
{
item.Hue = m_Tub.DyedHue;
from.PlaySound( 0x23E );
}
}
else if ( item is MonsterStatuette && m_Tub.AllowStatuettes )
{
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if ( !item.Movable )
{
from.SendLocalizedMessage( 1049779 ); // You cannot dye statuettes that are locked down.
}
else
{
item.Hue = m_Tub.DyedHue;
from.PlaySound( 0x23E );
}
}
else if ( (item is BaseArmor && (((BaseArmor)item).MaterialType == ArmorMaterialType.Leather || ((BaseArmor)item).MaterialType == ArmorMaterialType.Studded) ) && m_Tub.AllowLeather )
{
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if ( !item.Movable )
{
from.SendLocalizedMessage( 1042419 ); // You may not dye leather items which are locked down.
}
else if ( item.Parent is Mobile )
{
from.SendLocalizedMessage( 500861 ); // Can't Dye clothing that is being worn.
}
else
{
item.Hue = m_Tub.DyedHue;
from.PlaySound( 0x23E );
}
}
else
{
from.SendLocalizedMessage( m_Tub.FailMessage );
}
}
else
{
from.SendLocalizedMessage( m_Tub.FailMessage );
}
}
}