Exemple #1
0
        private static void OnSingleClick(NetState state, PacketReader pvSrc)
        {
            if (state == null || pvSrc == null)
            {
                return;
            }

            PlayerMobile viewer = null;
            PlayerMobile target = null;
            TitleDisplay?d      = null;

            if (CMOptions.ModuleEnabled && state.Mobile is PlayerMobile)
            {
                viewer = (PlayerMobile)state.Mobile;

                int pos = pvSrc.Seek(0, SeekOrigin.Current);

                pvSrc.Seek(1, SeekOrigin.Begin);

                Serial s = pvSrc.ReadInt32();

                pvSrc.Seek(pos, SeekOrigin.Begin);

                if (s.IsMobile)
                {
                    target = World.FindMobile(s) as PlayerMobile;

                    if (target != null && viewer.CanSee(target) && Utility.InUpdateRange(viewer, target))
                    {
                        Title t;

                        if (GetTitle(target, out t) && t != null)
                        {
                            d = t.Display;
                        }
                    }
                }
            }

            var battle = AutoPvP.FindBattle(target) as UOF_PvPBattle;

            if (d != null && d.Value == TitleDisplay.BeforeName && (battle == null || !battle.IncognitoMode))
            {
                DisplayTitle(viewer, target);
            }

            if (LookReqParent != null)
            {
                LookReqParent.OnReceive(state, pvSrc);
            }
            else
            {
                PacketHandlers.LookReq(state, pvSrc);
            }

            if (d != null && d.Value == TitleDisplay.AfterName && (battle == null || !battle.IncognitoMode))
            {
                DisplayTitle(viewer, target);
            }
        }
Exemple #2
0
            private Item TryStealItem(Item toSteal, object root, int difficulty, ref bool ok, ref bool caught)
            {
                Item stolen = null;

                //if ( toSteal is KeyRing )
                //	toSteal.Weight = toSteal.TotalWeight = 1;

                if (root is BaseVendor || root is PlayerVendor)
                {
                    m_Thief.SendLocalizedMessage(1005598);                       // You can't steal from shopkeepers.
                }
                else if (!m_Thief.CanSee(toSteal) || (root != null && !m_Thief.CanSee(root)))
                {
                    m_Thief.SendLocalizedMessage(500237);                       // Target can not be seen.
                }
                else if (!toSteal.Movable || 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.CanBeHarmful((Mobile)root)))
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else
                {
                    for (Item p = toSteal.Parent as Item; p != null; p = p.Parent as Item)
                    {
                        if (p is LockableContainer && ((LockableContainer)p).Locked)
                        {
                            m_Thief.SendAsciiMessage("That is not accessable.");
                            return(null);
                        }
                    }

                    if (toSteal.Weight + toSteal.TotalWeight > 10)
                    {
                        m_Thief.SendAsciiMessage("That is too heavy to steal from someone's backpack.");
                    }
                    else
                    {
                        ok = true;

                        double w = toSteal.PileWeight + toSteal.TotalWeight;
                        double check;
                        if (w >= 10)
                        {
                            check  = 10 * 3.0 * difficulty + 10.0;
                            caught = CheckDetect((10 * 5.0 * difficulty) / (m_Thief.Skills.Stealing.Value + 100.0), root as Mobile);
                        }
                        else
                        {
                            check = w * 3.0 * difficulty + 10.0;
                            if (toSteal is Key || toSteal is Multis.Deeds.HouseDeed || toSteal is KeyRing)
                            {
                                w += 5;
                            }
                            caught = CheckDetect((w * 5.0 * difficulty) / (m_Thief.Skills.Stealing.Value + 100.0), root as Mobile);
                        }

                        if (m_Thief.CheckSkill(SkillName.Stealing, check - 25, check + 25))
                        {
                            m_Thief.SendLocalizedMessage(502724);                               // You succesfully steal the item.
                            if (toSteal.Stackable && toSteal.Amount > 1)
                            {
                                int amount;

                                /*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;
                                 * amount = Utility.Random( maxAmount ) + 1;*/

                                amount = Utility.Random(10) + 1;

                                if (amount > w)
                                {
                                    amount = toSteal.Amount;
                                }
                                else
                                {
                                    amount = (toSteal.Amount * amount) / (toSteal.PileWeight + toSteal.TotalWeight);
                                }

                                if (amount < 1)
                                {
                                    amount = 1;
                                }

                                if (amount >= toSteal.Amount)
                                {
                                    stolen = toSteal;
                                }
                                else
                                {
                                    stolen          = toSteal.Dupe(amount);
                                    toSteal.Amount -= amount;
                                }
                            }
                            else
                            {
                                stolen = toSteal;
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(502723);                               // You fail to steal the item.
                        }
                    }
                }

                return(stolen);
            }
Exemple #3
0
        public static void PushNotoriety(Mobile from, Mobile to, bool aggressor)
        {
            BaseCreature bc_From = from as BaseCreature;
            PlayerMobile pm_From = from as PlayerMobile;

            BaseCreature bc_To = to as BaseCreature;
            PlayerMobile pm_To = to as PlayerMobile;

            PlayerMobile pm_First  = null;
            PlayerMobile pm_Second = null;

            if (from == null || to == null)
            {
                return;
            }

            if (pm_From != null)
            {
                pm_First = pm_From;
            }

            if (bc_From != null)
            {
                if (bc_From.Controlled && bc_From.ControlMaster is PlayerMobile)
                {
                    pm_First = bc_From.ControlMaster as PlayerMobile;
                }
            }

            if (pm_To != null)
            {
                pm_Second = pm_To;
            }

            if (bc_To != null)
            {
                if (bc_To.Controlled && bc_To.ControlMaster is PlayerMobile)
                {
                    pm_Second = bc_To.ControlMaster as PlayerMobile;
                }
            }

            //First Player is Online
            if (pm_First != null)
            {
                if (pm_First.NetState != null)
                {
                    List <Mobile> m_Viewables = new List <Mobile>();

                    if (pm_First.AllFollowers.Count > 0)
                    {
                        foreach (Mobile follower in pm_First.AllFollowers)
                        {
                            if (follower != null)
                            {
                                m_Viewables.Add(follower);
                            }
                        }
                    }

                    if (pm_Second != null)
                    {
                        m_Viewables.Add(pm_Second);

                        if (pm_Second.AllFollowers.Count > 0)
                        {
                            foreach (Mobile follower in pm_Second.AllFollowers)
                            {
                                if (follower != null)
                                {
                                    m_Viewables.Add(follower);
                                }
                            }
                        }
                    }

                    if (bc_To != null)
                    {
                        m_Viewables.Add(bc_To);
                    }

                    //Update Data for All Things Viewable By This Player
                    foreach (Mobile mobile in m_Viewables)
                    {
                        if (mobile != null)
                        {
                            if (pm_First.CanSee(mobile))
                            {
                                pm_First.NetState.Send(MobileIncoming.Create(pm_First.NetState, pm_First, mobile));
                            }
                        }
                    }
                }
            }

            //Second Player is Online:
            if (pm_Second != null && pm_Second != pm_First)
            {
                if (pm_Second.NetState != null)
                {
                    List <Mobile> m_Viewables = new List <Mobile>();

                    if (pm_Second.AllFollowers.Count > 0)
                    {
                        foreach (Mobile follower in pm_Second.AllFollowers)
                        {
                            if (follower != null)
                            {
                                m_Viewables.Add(follower);
                            }
                        }
                    }

                    if (pm_First != null)
                    {
                        m_Viewables.Add(pm_First);

                        if (pm_First.AllFollowers.Count > 0)
                        {
                            foreach (Mobile follower in pm_First.AllFollowers)
                            {
                                if (follower != null)
                                {
                                    m_Viewables.Add(follower);
                                }
                            }
                        }
                    }

                    if (bc_From != null)
                    {
                        m_Viewables.Add(bc_From);
                    }

                    //Update Data for All Things Viewable By This Player
                    foreach (Mobile mobile in m_Viewables)
                    {
                        if (mobile != null)
                        {
                            if (pm_Second.CanSee(mobile))
                            {
                                pm_Second.NetState.Send(MobileIncoming.Create(pm_Second.NetState, pm_Second, mobile));
                            }
                        }
                    }
                }
            }
        }