protected override void OnTarget( Mobile from, object target )
{
from.RevealingAction();
Item stolen = null;
object root = null;
bool caught = false;
if ( target is Item )
{
root = ((Item)target).RootParent;
stolen = TryStealItem( (Item)target, ref caught );
}
else if ( target is Mobile )
{
Container pack = ((Mobile)target).Backpack;
if ( pack != null && pack.Items.Count > 0 )
{
int randomIndex = Utility.Random( pack.Items.Count );
root = target;
stolen = TryStealItem( pack.Items[randomIndex], ref caught );
}
}
else
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
if ( stolen != null )
{
from.AddToBackpack( stolen );
StolenItem.Add( stolen, m_Thief, root as Mobile );
}
if ( caught )
{
if ( root == null )
{
m_Thief.CriminalAction( false );
}
else if ( root is Corpse && ((Corpse)root).IsCriminalAction( m_Thief ) )
{
m_Thief.CriminalAction( false );
}
else if ( root is Mobile )
{
Mobile mobRoot = (Mobile)root;
if ( !IsInGuild( mobRoot ) && IsInnocentTo( m_Thief, mobRoot ) )
m_Thief.CriminalAction( false );
string message = String.Format( "You notice {0} trying to steal from {1}.", m_Thief.Name, mobRoot.Name );
foreach ( NetState ns in m_Thief.GetClientsInRange( 8 ) )
{
if ( ns.Mobile != m_Thief )
ns.Mobile.SendMessage( message );
}
}
}
else if ( root is Corpse && ((Corpse)root).IsCriminalAction( m_Thief ) )
{
m_Thief.CriminalAction( false );
}
if ( root is Mobile && ((Mobile)root).Player && m_Thief is PlayerMobile && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( (Mobile)root ) )
{
PlayerMobile pm = (PlayerMobile)m_Thief;
pm.PermaFlags.Add( (Mobile)root );
pm.Delta( MobileDelta.Noto );
}
}
}