Пример #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (targeted == m_KeyRing)
                {
                    number = -1;
                    //remove keys from keyring
                    Item[] keys = m_KeyRing.FindItemsByType(typeof(Key));
                    foreach (Item i in keys)
                    {
                        if (i is Key)                          //doublecheck!
                        {
                            if (from is PlayerMobile)
                            {
                                Container b = ((PlayerMobile)from).Backpack;
                                if (b != null)
                                {
                                    b.DropItem(i);
                                    i.Movable = true;
                                }
                            }
                        }
                    }
                    m_KeyRing.UpdateItemID();
                    from.SendMessage("You remove all the keys.");
                }
                else if (targeted is ILockable)
                {
                    number = -1;

                    ILockable o = (ILockable)targeted;

                    if (m_KeyRing.IsKeyOnRing(o.KeyValue) && o.KeyValue != 0)
                    {
                        if (o is BaseDoor && !((BaseDoor)o).UseLocks())
                        {
                            number = 501668;                             // This key doesn't seem to unlock that.
                        }
                        else if (o is BaseDoor && !(m_KeyRing.IsChildOf(from.Backpack)))
                        {
                            from.SendLocalizedMessage(1042001);                               // That must be in your pack for you to use it.
                        }
                        else
                        {
                            if (o is BaseHouseDoor)
                            {
                                BaseHouse home;
                                home = ((BaseHouseDoor)o).FindHouse();

                                /*if (home.Public == true)
                                 * {
                                 *      if (o.Locked != true)
                                 *      from.SendMessage("You cannot lock a public house.");
                                 *      o.Locked = false;
                                 *      return;
                                 * }*/
                            }

                            o.Locked = !o.Locked;

                            if (o is LockableContainer)
                            {
                                LockableContainer cont = (LockableContainer)o;

                                if (cont.TinkerMadeTrap)
                                {
                                    if (cont.TrapType != TrapType.None)
                                    {
                                        if (cont.TrapEnabled)
                                        {
                                            from.SendMessage("You leave the trap enabled.");
                                        }
                                        else
                                        {
                                            from.SendMessage("You leave the trap disabled.");
                                        }
                                    }
                                }

                                if (cont.LockLevel == -255)
                                {
                                    cont.LockLevel = cont.RequiredSkill - 10;
                                }
                            }

                            if (targeted is Item)
                            {
                                Item item = (Item)targeted;

                                if (o.Locked)
                                {
                                    item.SendLocalizedMessageTo(from, 1048000);
                                }
                                else
                                {
                                    item.SendLocalizedMessageTo(from, 1048001);
                                }
                            }
                        }
                    }
                    else
                    {
                        number = 501668;                         // This key doesn't seem to unlock that.
                    }
                }
                else
                {
                    number = 501666;                     // You can't unlock that!
                }

                if (number != -1)
                {
                    from.SendLocalizedMessage(number);
                }
            }
Пример #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_KeyRing.Deleted || !m_KeyRing.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1042001);                     // That must be in your pack for you to use it.
                    return;
                }

                int number;

                if (targeted == m_KeyRing)
                {
                    number = -1;
                    //remove keys from keyring
                    List <Key> list = new List <Key>(m_KeyRing.Keys);
                    foreach (Key i in list)
                    {
                        if (i is Key)
                        {
                            if (from is PlayerMobile)
                            {
                                Container b = ((PlayerMobile)from).Backpack;
                                if (b != null)
                                {
                                    if (m_KeyRing.Keys.Contains(i))
                                    {
                                        m_KeyRing.Keys.Remove(i);
                                    }
                                    b.DropItem(i);
                                }
                            }
                        }
                    }
                    m_KeyRing.UpdateItemID();
                    from.SendMessage("You remove all the keys.");
                }
                else if (targeted is ILockable)
                {
                    number = -1;
                    ILockable o = (ILockable)targeted;

                    if (m_KeyRing.IsKeyOnRing(o.KeyValue) && o.KeyValue != 0)
                    {
                        if (o is BaseDoor && !((BaseDoor)o).UseLocks())
                        {
                            //number = 501668;	// This key doesn't seem to unlock that.
                            number = 1008140;                                   // You do not have a key for that.
                        }
                        else
                        {
                            #region PUBLIC HOUSE (disabled)

                            /*if (o is BaseHouseDoor)
                             * {
                             *      BaseHouse home;
                             *      home = ((BaseHouseDoor)o).FindHouse();
                             *      if (home.Public == true)
                             *      {
                             *              if (o.Locked != true)
                             *              from.SendMessage("You cannot lock a public house.");
                             *              o.Locked = false;
                             *              return;
                             *      }
                             * }*/
                            #endregion

                            o.Locked = !o.Locked;

                            if (o is LockableContainer)
                            {
                                LockableContainer cont = (LockableContainer)o;

                                if (Core.Publish < 4 || Core.UOAI || Core.UOAR)
                                {                                       // old-school traps (< publish 4)
                                    if (cont.TrapEnabled)
                                    {
                                        from.SendMessage("You leave the trap enabled.");
                                    }
                                    else
                                    {                                           // only give a message if trapped (even if it's disabled.)
                                        if (cont.TrapType != TrapType.None)
                                        {
                                            from.SendMessage("You leave the trap disabled.");
                                        }
                                    }
                                }
                                else
                                {                                       // new-style traps (>= publish 4)
                                    if (cont.TrapType != TrapType.None)
                                    {
                                        if (cont.Locked)
                                        {
                                            if (Core.NewStyleTinkerTrap)                                                // last person to lock trap is 'owner'
                                            {
                                                cont.Owner = from;
                                            }

                                            cont.TrapEnabled = true;
                                            (o as LockableContainer).SendLocalizedMessageTo(from, 501673);                                             // You re-enable the trap.
                                        }
                                        else
                                        {
                                            cont.TrapEnabled = false;
                                            (o as LockableContainer).SendLocalizedMessageTo(from, 501672);                                             // You disable the trap temporarily.  Lock it again to re-enable it.
                                        }
                                    }
                                }

                                if (cont.LockLevel == -255)
                                {
                                    cont.LockLevel = cont.RequiredSkill - 10;
                                }
                            }

                            if (targeted is Item)
                            {
                                Item item = (Item)targeted;

                                if (o.Locked)
                                {
                                    item.SendLocalizedMessageTo(from, 1048000);
                                }
                                else
                                {
                                    item.SendLocalizedMessageTo(from, 1048001);
                                }
                            }
                        }
                    }
                    else
                    {
                        //number = 501668;	// This key doesn't seem to unlock that.
                        number = 1008140;                               // You do not have a key for that.
                    }
                }
                else
                {
                    number = 501666;                     // You can't unlock that!
                }

                if (number != -1)
                {
                    from.SendLocalizedMessage(number);
                }
            }