private Item TryStealItem( Item toSteal, ref bool caught )
{
Item stolen = null;
object root = toSteal.RootParent;
if ( !IsEmptyHanded( m_Thief ) )
{
m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
}
else if ( root is Mobile && ((Mobile)root).Player && !IsInGuild( m_Thief ) )
{
m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players.
}
else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 )
{
m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild.
}
else if ( root is BaseVendor && ((BaseVendor)root).IsInvulnerable )
{
m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
}
else if ( root is PlayerVendor )
{
m_Thief.SendLocalizedMessage( 502709 ); // You can't steal from vendors.
}
else if ( !m_Thief.CanSee( toSteal ) )
{
m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, toSteal, false, true ) )
{
m_Thief.SendLocalizedMessage( 1048147 ); // Your backpack can't hold anything else.
}
else if ( toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
{
m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
}
else if ( toSteal.Parent is Mobile )
{
m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
}
else if ( root == m_Thief )
{
m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
}
else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
{
}
else if ( root is Corpse )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else
{
double w = toSteal.Weight + toSteal.TotalWeight;
if ( w > 10 )
{
m_Thief.SendMessage( "That is too heavy to steal." );
}
else
{
if ( toSteal.Stackable && toSteal.Amount > 1 )
{
int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
if ( maxAmount < 1 )
maxAmount = 1;
else if ( maxAmount > toSteal.Amount )
maxAmount = toSteal.Amount;
int amount = Utility.RandomMinMax( 1, maxAmount );
if ( amount >= toSteal.Amount )
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
stolen = toSteal;
}
else
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
{
stolen = Mobile.LiftItemDupe( toSteal, toSteal.Amount - amount );
if ( stolen == null )
stolen = toSteal;
}
}
}
else
{
int iw = (int)Math.Ceiling( w );
iw *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
stolen = toSteal;
}
if ( stolen != null )
{
m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
}
else
{
m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
}
caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
}
}
return stolen;
}