Add() public static method

public static Add ( Item item, Server.Mobile thief, Server.Mobile victim ) : void
item Item
thief Server.Mobile
victim Server.Mobile
return void
示例#1
0
            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 is Mobile)
                    {
                        Mobile mobRoot = (Mobile)root;

                        string message = String.Format("Vous appercevez un personnage tenter d'en voler un autre.");

                        from.RevealingAction();

                        from.NonlocalOverheadMessage(MessageType.Emote, 0, true, message);

                        /*foreach ( NetState ns in m_Thief.GetClientsInRange( 8 ) )
                         * {
                         *      if ( ns.Mobile != m_Thief )
                         *              ns.Mobile.SendMessage( message );
                         * }*/
                    }
                }

                CommandLogging.WriteLine(from, "{4} {2} à voler {0} appartenant à {1} en étant {3}",
                                         target, root, stolen != null ? "réussit" : "échoue", from.Hidden ? "caché" : "à découvert", from);
            }
示例#2
0
文件: Stealing.cs 项目: twlizer/runuo
                protected override void OnTarget(Mobile from, object target)
                {
                    //target
                    //m_Thief
                    Item unstolen = null;

                    if (!(target is Mobile))
                    {
                        m_Thief.SendMessage("You can only reverse pickpocket creatures");
                    }
                    else
                    {
                        unstolen = TryUnstealItem((Mobile)target);
                    }
                    if (unstolen != null)
                    {
                        if (!(unstolen is Container || unstolen.Stackable))
                        { // do not return stolen containers or stackable items
                            StolenItem.Add(unstolen, m_Thief as Mobile, target as Mobile);
                        }
                    }
                    if (m_Caught)
                    {
                        Mobile mobRoot = (Mobile)target;

                        if (!IsInGuild(mobRoot) && IsInnocentTo(m_Thief, mobRoot))
                        {
                            m_Thief.CriminalAction(false);
                        }

                        string message = String.Format("You notice {0} trying to reverse pickpocket {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 (target is Corpse && ((Corpse)target).IsCriminalAction(m_Thief))
                    {
                        m_Thief.CriminalAction(false);
                    }

                    if (target is Mobile && ((Mobile)target).Player && m_Thief is PlayerMobile && IsInnocentTo(m_Thief, (Mobile)target) && !IsInGuild((Mobile)target))
                    {
                        PlayerMobile pm = (PlayerMobile)m_Thief;

                        pm.PermaFlags.Add((Mobile)target);
                        pm.Delta(MobileDelta.Noto);
                    }
                }
示例#3
0
            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);
                }
            }
示例#4
0
文件: Stealing.cs 项目: favesc/ServUO
            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);
                    }

                    #region Monster Stealables
                    if (target is BaseCreature && from is PlayerMobile)
                    {
                        Server.Engines.CreatureStealing.StealingHandler.HandleSteal(target as BaseCreature, from as PlayerMobile);
                    }
                    #endregion
                }
                else
                {
                    m_Thief.SendLocalizedMessage(502710);                     // You can't steal that!
                }

                if (stolen != null)
                {
                    if (stolen is AddonComponent)
                    {
                        BaseAddon addon = ((AddonComponent)stolen).Addon as BaseAddon;
                        from.AddToBackpack(addon.Deed);
                        addon.Delete();
                    }
                    else
                    {
                        from.AddToBackpack(stolen);
                    }

                    if (!(stolen is Container || stolen.Stackable))
                    {
                        // do not return stolen containers or stackable items
                        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);
                }
            }
示例#5
0
文件: Stealing.cs 项目: ygtkms/ServUO
            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)
                {
                    var bc = target as BaseCreature;
                    root = target;

                    if (bc != null && from is PlayerMobile)
                    {
                        if (bc.Controlled || bc.Summoned)
                        {
                            from.SendLocalizedMessage(502708); //You can't steal from this.
                        }
                        if (bc.HasBeenStolen)
                        {
                            from.SendLocalizedMessage(1094948); //That creature has already been stolen from.  There is nothing left to steal.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1010579); // You reach into the backpack... and try to take something.

                            Engines.CreatureStealing.StealingHandler.HandleSteal(bc, (PlayerMobile)from, ref stolen);

                            if (stolen == null)
                            {
                                if (!bc.StealPackGenerated)
                                {
                                    bc.GenerateLoot(LootStage.Stolen);
                                }

                                StealRandom((Mobile)target, ref caught, ref stolen);
                            }
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1010579); // You reach into the backpack... and try to take something.
                        StealRandom((Mobile)target, ref caught, ref stolen);
                    }
                }
                else
                {
                    m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                }

                if (stolen != null)
                {
                    if (stolen is AddonComponent)
                    {
                        BaseAddon addon = ((AddonComponent)stolen).Addon;
                        from.AddToBackpack(addon.Deed);
                        addon.Delete();
                    }
                    else
                    {
                        from.AddToBackpack(stolen);
                    }

                    if (!(stolen is Container || stolen.Stackable))
                    {
                        // do not return stolen containers or stackable items
                        StolenItem.Add(stolen, m_Thief, root as Mobile);
                    }

                    if (target is BaseCreature)
                    {
                        ((BaseCreature)target).HasBeenStolen = true;
                    }
                }

                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);
                }
            }
示例#6
0
文件: Stealing.cs 项目: twlizer/runuo
                private Item TryUnstealItem(Mobile target)
                {
                    m_Thief.RevealingAction();
                    Item unstolen = null;

                    if (!IsEmptyHanded(m_Thief))
                    {
                        m_Thief.SendLocalizedMessage(1005584); // Both hands must be free to steal.
                    }
                    else if (m_Thief.Region.IsPartOf(typeof(Engines.ConPVP.SafeZone)))
                    {
                        m_Thief.SendMessage("You may not steal in this area.");
                    }
                    else if (target.Player && !IsInGuild(m_Thief))
                    {
                        m_Thief.SendLocalizedMessage(1005596); // You must be in the thieves guild to steal from other players.
                    }
                    else if (SuspendOnMurder && target.Player && IsInGuild(m_Thief) && m_Thief.Kills > 0)
                    {
                        m_Thief.SendLocalizedMessage(502706); // You are currently suspended from the thieves guild.
                    }
                    else if (target is BaseVendor && ((BaseVendor)target).IsInvulnerable)
                    {
                        m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers.
                    }
                    else if (target is PlayerVendor)
                    {
                        m_Thief.SendLocalizedMessage(502709); // You can't steal from vendors.
                    }
                    else if (!m_Thief.CanSee(target))
                    {
                        m_Thief.SendLocalizedMessage(500237); // Target can not be seen.
                    }
                    else if (m_Thief.Backpack == null || !target.Backpack.CheckHold(target, m_toUnsteal, false, true))
                    {
                        m_Thief.SendMessage("Their backpack can't hold anything else"); // Your backpack can't hold anything else.
                    }
                    else if (m_toUnsteal is Sigil)
                    {
                        m_Thief.SendMessage("You can't unsteal a sigil!");
                    }
                    else if (m_toUnsteal.Parent == null || !m_toUnsteal.Movable)
                    {
                        m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                    }
                    else if (m_toUnsteal.LootType == LootType.Newbied || m_toUnsteal.CheckBlessed(m_Thief))
                    {
                        m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                    }
                    else if (Core.AOS && m_toUnsteal is Container)
                    {
                        m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                    }
                    else if (!m_Thief.InRange(target.Location, 1))
                    {
                        m_Thief.SendMessage("You must be next to a target to reverse pickpocket them."); // You must be standing next to an item to steal it.
                    }
                    else if (target == m_Thief)
                    {
                        m_Thief.SendLocalizedMessage(502704); // You catch yourself red-handed.
                    }
                    else if (target.AccessLevel > AccessLevel.Player)
                    {
                        m_Thief.SendLocalizedMessage(502710); // You can't steal that!
                    }
                    else if (!m_Thief.CanBeHarmful((Mobile)target))
                    {
                    }
                    else
                    {
                        double w = m_toUnsteal.Weight + m_toUnsteal.TotalWeight;

                        if (w > 10)
                        {
                            m_Thief.SendMessage("That is too heavy to steal.");
                        }
                        else
                        {
                            if (m_toUnsteal.Stackable && m_toUnsteal.Amount > 1)
                            {
                                int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / m_toUnsteal.Weight);

                                if (maxAmount < 1)
                                {
                                    maxAmount = 1;
                                }
                                else if (maxAmount > m_toUnsteal.Amount)
                                {
                                    maxAmount = m_toUnsteal.Amount;
                                }

                                int amount = Utility.RandomMinMax(1, maxAmount);

                                if (amount >= m_toUnsteal.Amount)
                                {
                                    int pileWeight = (int)Math.Ceiling(m_toUnsteal.Weight * m_toUnsteal.Amount);
                                    pileWeight *= 10;

                                    if (m_Thief.CheckTargetSkill(SkillName.Stealing, m_toUnsteal, pileWeight - 22.5, pileWeight + 27.5))
                                    {
                                        if (m_toUnsteal.Insured)
                                        {
                                            m_toUnsteal.Insured = false;
                                        }
                                        unstolen = m_toUnsteal;
                                    }
                                }
                                else
                                {
                                    int pileWeight = (int)Math.Ceiling(m_toUnsteal.Weight * amount);
                                    pileWeight *= 10;

                                    if (m_Thief.CheckTargetSkill(SkillName.Stealing, m_toUnsteal, pileWeight - 22.5, pileWeight + 27.5))
                                    {
                                        unstolen = Mobile.LiftItemDupe(m_toUnsteal, m_toUnsteal.Amount - amount);

                                        if (unstolen == null)
                                        {
                                            unstolen = m_toUnsteal;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                int iw = (int)Math.Ceiling(w);
                                iw *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, m_toUnsteal, iw - 22.5, iw + 27.5))
                                {
                                    if (m_toUnsteal.Insured)
                                    {
                                        m_toUnsteal.Insured = false;
                                    }
                                }
                                unstolen = m_toUnsteal;
                            }

                            if (unstolen != null)
                            {
                                m_Thief.SendMessage("You successfully reverse pickpocket the item.");
                                target.AddToBackpack(unstolen);

                                if (!(unstolen is Container || unstolen.Stackable))
                                { // do not return stolen containers or stackable items
                                    StolenItem.Add(unstolen, target, m_Thief as Mobile);
                                }
                            }
                            else
                            {
                                m_Thief.SendMessage("You fail to reverse pickpocket the item.");
                            }
                        }
                        m_Caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150));
                    }
                    return(unstolen);
                }
示例#7
0
文件: Stealing.cs 项目: twlizer/runuo
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                Item stolen = null;

                object root = null;

                if (target is Item)
                {
                    root = ((Item)target).RootParent;
                    if (root != from)//Change to if (true) if this script f***s up
                    {
                        stolen = TryStealItem((Item)target);
                    }
                    else
                    {
                        m_Thief.SendMessage("Who would you like to reverse pickpocket?");
                        m_Thief.Target = new Stealing.StealingTarget.UnstealingTarget(m_Thief, (Item)target);
                    }
                }
                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]);
                    }
                }
                else
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }

                if (stolen != null)
                {
                    from.AddToBackpack(stolen);

                    if (!(stolen is Container || stolen.Stackable))                           // do not return stolen containers or stackable items
                    {
                        StolenItem.Add(stolen, m_Thief, root as Mobile);
                    }
                }

                if (m_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);
                }
            }
示例#8
0
            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;

                    if (m_Thief.Map != Map.Felucca && root is BaseCreature && ((BaseCreature)root).ControlMaster != null)
                    {
                        m_Thief.SendLocalizedMessage(1005597);                           // The creature blocks your attempt to steal.
                    }
                    else
                    {
                        stolen = TryStealItem((Item)target, ref caught);
                    }
                }
                else if (target is Mobile)
                {
                    Container pack = ((Mobile)target).Backpack;

                    if (m_Thief.Map != Map.Felucca && target is BaseCreature && ((BaseCreature)target).ControlMaster != null)
                    {
                        m_Thief.SendLocalizedMessage(1005597);                           // The creature blocks your attempt to steal.
                    }
                    else if (pack != null && pack.Items.Count > 0)
                    {
                        from.SendLocalizedMessage(1010579);                           // You reach into the backpack... and try to take something.

                        int randomIndex = Utility.Random(pack.Items.Count);

                        root   = target;
                        stolen = TryStealItem((Item)pack.Items[randomIndex], ref caught);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1010578);                           // You reach into the backpack... but find it's empty.
                    }
                }
                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 (GameClient ns in m_Thief.GetClientsInRange(8))
                        {
                            if (ns != m_Thief.Client)
                            {
                                ns.Mobile.SendMessage(message);
                            }
                        }
                    }
                }
                else if (root is Corpse && ((Corpse)root).IsCriminalAction(m_Thief))
                {
                    m_Thief.CriminalAction(false);
                }

                if (root is Mobile && ((Mobile)root).IsPlayer && 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);
                }
            }
示例#9
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                Item   stolenItem = null;
                object root       = null;

                Mobile mobileTarget = root as Mobile;

                bool turnPermaGrey = false;
                bool caught        = false;

                int amountStolen = 0;

                //Stealing Attempt
                if (target is Item)
                {
                    root       = ((Item)target).RootParent;
                    stolenItem = TryStealItem((Item)target, ref amountStolen);
                }

                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;
                        stolenItem = TryStealItem(pack.Items[randomIndex], ref amountStolen);
                    }
                }

                else
                {
                    from.SendLocalizedMessage(502710); // You can't steal that!
                }
                //Successful Steal Attempt
                if (stolenItem != null)
                {
                    //See if Nearby Mobiles Notice
                    IPooledEnumerable nearbyMobiles = from.Map.GetMobilesInRange(from.Location, NoticeRange);

                    foreach (Mobile mobile in nearbyMobiles)
                    {
                        double noticeChance = 0;

                        if (mobile == from)
                        {
                            continue;
                        }
                        if (!mobile.Alive)
                        {
                            continue;
                        }

                        if (mobile is PlayerMobile)
                        {
                            if (from.Map.InLOS(from.Location, mobile.Location))
                            {
                                noticeChance += PlayerNoticeChance;
                            }

                            else
                            {
                                noticeChance += PlayerNoticeChance * LOSBlockedCatchScalar;
                            }

                            if (Utility.RandomDouble() <= noticeChance && mobileTarget != null)
                            {
                                mobile.SendMessage("You notice " + from.Name + " trying to steal from " + mobileTarget.Name + ".");

                                caught = true;
                            }

                            continue;
                        }

                        BaseCreature bc_Creature = mobile as BaseCreature;

                        if (bc_Creature != null && mobile.Body.IsHuman)
                        {
                            if (from.Map.InLOS(from.Location, mobile.Location))
                            {
                                noticeChance += MobileNoticeChance;
                            }

                            else
                            {
                                noticeChance += MobileNoticeChance * LOSBlockedCatchScalar;
                            }

                            if (Utility.RandomDouble() <= noticeChance && mobileTarget != null)
                            {
                                caught = true;
                            }

                            continue;
                        }
                    }

                    nearbyMobiles.Free();

                    //Resolve
                    if (caught)
                    {
                        if (root == null)
                        {
                            from.CriminalAction(false);
                        }

                        else if (root is Corpse && ((Corpse)root).IsCriminalAction(from))
                        {
                            from.CriminalAction(false);
                        }

                        else if (root is Mobile)
                        {
                            Mobile mobRoot = (Mobile)root;

                            if (!IsInGuild(mobRoot) && IsInnocentTo(from, mobRoot))
                            {
                                from.CriminalAction(false);
                            }
                        }
                    }

                    else if (root is Corpse && ((Corpse)root).IsCriminalAction(from))
                    {
                        from.CriminalAction(false);
                    }

                    //Flagging and Permagrey
                    if (root is Mobile && ((Mobile)root).Player && from is PlayerMobile && IsInnocentTo(from, (Mobile)root) && !IsInGuild((Mobile)root) && turnPermaGrey)
                    {
                        PlayerMobile pm = (PlayerMobile)from;

                        pm.PermaFlags.Add((Mobile)root);
                        pm.Delta(MobileDelta.Noto);
                    }

                    //Move Item: Delay to Allow for Guard Whacking Preventing Theft
                    Timer.DelayCall(TimeSpan.FromSeconds(.1), delegate
                    {
                        if (!SpecialAbilities.Exists(from))
                        {
                            return;
                        }
                        if (from.Backpack == null)
                        {
                            return;
                        }
                        if (stolenItem == null)
                        {
                            return;
                        }
                        if (stolenItem.Deleted)
                        {
                            return;
                        }

                        if (stolenItem.Stackable && stolenItem.Amount > 1)
                        {
                            if (amountStolen >= stolenItem.Amount)
                            {
                                from.AddToBackpack(stolenItem);

                                if (!(stolenItem is Container || stolenItem.Stackable))
                                {
                                    StolenItem.Add(stolenItem, from, root as Mobile);
                                }

                                from.SendMessage("You successfully steal the item.");
                            }

                            else
                            {
                                Item newItem = Mobile.LiftItemDupe(stolenItem, stolenItem.Amount - amountStolen);

                                from.AddToBackpack(newItem);

                                if (!(newItem is Container || newItem.Stackable))
                                {
                                    StolenItem.Add(newItem, from, root as Mobile);
                                }

                                from.SendMessage("You successfully steal the item.");
                            }
                        }

                        else
                        {
                            from.AddToBackpack(stolenItem);

                            if (!(stolenItem is Container || stolenItem.Stackable))
                            {
                                StolenItem.Add(stolenItem, from, root as Mobile);
                            }

                            from.SendMessage("You successfully steal the item.");
                        }
                    });
                }

                else
                {
                    from.SendMessage("You fail in your stealing attempt.");
                }
            }
示例#10
0
            protected override void OnTick()
            {
                Item   stolen = null;
                object root   = toSteal.RootParent;

                if (!TryStealItem(toSteal, root, m_Thief))
                {
                    if (m_Thief is PlayerMobile)
                    {
                        ((PlayerMobile)m_Thief).EndPlayerAction();
                    }

                    return;
                }

                if (toSteal.Stackable && toSteal.Amount > 1)
                {
                    int maxAmount;

                    if (toSteal.Weight == 0)
                    {
                        maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / 0.1);
                    }
                    else
                    {
                        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);

                    int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
                    pileWeight *= 10;

                    if (pileWeight == 0)
                    {
                        pileWeight = 1;
                    }

                    double minSkill = -(m_Thief.Skills[SkillName.Stealing].Value / 2) + 50;
                    double maxSkill = 100 + (pileWeight * 3);

                    if (amount >= toSteal.Amount)
                    {
                        if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, minSkill, maxSkill))
                        {
                            stolen = toSteal;
                        }
                    }
                    else
                    {
                        if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, minSkill, maxSkill))
                        {
                            stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount);

                            if (stolen == null)
                            {
                                stolen = toSteal;
                            }
                        }
                    }
                }
                else
                {
                    double w = toSteal.Weight + toSteal.TotalWeight;

                    int iw = (int)Math.Ceiling(w);
                    iw *= 10;

                    double minSkill = -(m_Thief.Skills[SkillName.Stealing].Value / 2) + 50;
                    double maxSkill = 100 + (iw * 3);

                    if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, minSkill, maxSkill))
                    {
                        stolen = toSteal;
                    }
                }

                bool caught;

                if (root is Mobile)
                {
                    Mobile mobRoot = (Mobile)root;
                    caught = ((m_Thief.Skills[SkillName.Stealing].Value + (m_Thief.Dex - mobRoot.Dex) / 3.0) < Utility.Random(150));
                }
                else
                {
                    caught = ((m_Thief.Skills[SkillName.Stealing].Value + (m_Thief.Dex - 100) / 3.0) < Utility.Random(150));
                }

                if (stolen != null)
                {
                    // ARTEGORDONMOD
                    // set the taken flag to trigger release from any controlling spawner
                    ItemFlags.SetTaken(stolen, true);
                    // clear the stealable flag so that the item can only be stolen once if it is later locked down.
                    ItemFlags.SetStealable(stolen, false);
                    // release it if it was locked down
                    stolen.Movable = true;

                    m_Thief.AddToBackpack(stolen);
                    StolenItem.Add(stolen, m_Thief, root as Mobile);

                    m_Thief.SendLocalizedMessage(502724); // You succesfully steal the item.
                }
                else
                {
                    m_Thief.SendLocalizedMessage(502723); // You fail to steal the item.
                }

                if (caught)
                {
                    if (root == null)
                    {
                        m_Thief.CriminalAction(true);
                    }
                    else if (root is Corpse && ((Corpse)root).IsCriminalAction(m_Thief))
                    {
                        m_Thief.CriminalAction(true);
                    }
                    else if (root is Mobile)
                    {
                        Mobile mobRoot = (Mobile)root;

                        if (!IsInGuild(mobRoot) && IsInnocentTo(m_Thief, mobRoot))
                        {
                            m_Thief.CriminalAction(true);
                        }

                        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 == mobRoot)
                            {
                                ns.Mobile.SendAsciiMessage("You notice {0} trying to steal from you.", m_Thief.Name);
                            }

                            else if (ns.Mobile != m_Thief)
                            {
                                ns.Mobile.SendMessage(message);
                            }
                        }
                    }
                }

                /*
                 * else if (root is Corpse && ((Corpse)root).IsCriminalAction(m_Thief))
                 * {
                 *  m_Thief.CriminalAction(true);
                 * }*/

                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);
                }

                if (m_Thief is PlayerMobile)
                {
                    ((PlayerMobile)m_Thief).EndPlayerAction();
                }
            }
示例#11
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                if (m_Thief.IsYoung())
                {
                    m_Thief.SendMessage(54, "You may not steal from players or NPCs as a young player.");
                    return;
                }

                Item   stolen = null;
                object root   = null;
                bool   caught = false;

                var entity = target as IEntity;

                if (XmlScript.HasTrigger(entity, TriggerName.onTargeted) &&
                    UberScriptTriggers.Trigger(
                        entity,
                        from,
                        TriggerName.onTargeted,
                        null,
                        null,
                        null,
                        0,
                        null,
                        SkillName.Stealing,
                        from.Skills[SkillName.Stealing].Value))
                {
                    return;
                }

                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)
                    {
                        var 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 && root != m_Thief)
                {
                    Item item = m_Thief.FindItemOnLayer(Layer.Helm);

                    if (item is OrcishKinMask)
                    {
                        if (root is Orc || root is OrcBomber || root is OrcBrute || root is OrcishMage || root is OrcishLord ||
                            root is OrcishMineOverseer || root is OrcLeader || root is OrcMineBomber || root is OrcMiner)
                        {
                            item.Delete();
                            m_Thief.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head);
                            m_Thief.PlaySound(0x307);
                        }
                    }

                    if (((Mobile)root).Player && m_Thief is PlayerMobile && IsInnocentTo(m_Thief, (Mobile)root) &&
                        !IsInGuild((Mobile)root))
                    {
                        var pm = (PlayerMobile)m_Thief;

                        pm.PermaFlags.Add((Mobile)root);
                        pm.Delta(MobileDelta.Noto);
                    }
                }
            }