示例#1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_KeyRing.Deleted || !m_KeyRing.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1060640);                       // The item must be in your backpack to use it.
                    return;
                }

                if (m_KeyRing == targeted)
                {
                    m_KeyRing.Open(from);
                    from.SendLocalizedMessage(501685);                       // You open the keyring.
                }
                else if (targeted is ILockable)
                {
                    ILockable o = (ILockable)targeted;

                    foreach (Key key in m_KeyRing.Keys)
                    {
                        if (key.UseOn(from, o))
                        {
                            return;
                        }
                    }

                    from.SendLocalizedMessage(1008140);                       // You do not have a key for that.
                }
                else
                {
                    from.SendLocalizedMessage(501666);                       // You can't unlock that!
                }
            }
示例#2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_KeyRing.Deleted || !m_KeyRing.IsChildOf(from.Backpack))
                {
                    //from.SendLocalizedMessage( 1060640 ); // The item must be in your backpack to use it.
                    from.SendAsciiMessage("The item must be in your backpack to use it.");
                    return;
                }

                if (m_KeyRing == targeted)
                {
                    m_KeyRing.Open(from);
                    //from.SendLocalizedMessage( 501685 ); // You open the keyring.
                    //from.SendAsciiMessage("You open the keyring.");
                }
                else if (targeted is ILockable)
                {
                    ILockable o = (ILockable)targeted;

                    foreach (Key key in m_KeyRing.Keys)
                    {
                        if (key.UseOn(from, o))
                        {
                            return;
                        }
                    }

                    //from.SendLocalizedMessage( 1008140 ); // You do not have a key for that.
                    from.SendAsciiMessage("You do not have a key for that.");
                }
                else if (targeted is HouseSign)
                {
                    HouseSign sign = (HouseSign)targeted;

                    foreach (Key key in m_KeyRing.Keys)
                    {
                        if (key.KeyValue == sign.keyValue)
                        {
                            from.SendAsciiMessage("What dost thou wish the sign to say?");
                            from.Prompt = new HouseRenamePrompt(sign.Owner);
                            return;
                        }
                    }
                    //from.SendLocalizedMessage(1008140); // You do not have a key for that.
                    from.SendAsciiMessage("You do not have a key for that.");
                }
                else
                {
                    from.SendLocalizedMessage(501666);                       // You can't unlock that!
                    from.SendAsciiMessage("You can't unlock that!");
                }
            }
示例#3
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);
                }
            }
示例#4
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);
                }
            }
示例#5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_KeyRing.Deleted || !m_KeyRing.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1060640); // The item must be in your backpack to use it.
                    return;
                }
                if (m_KeyRing == targeted)
                {
                    m_KeyRing.Open(from);
                    from.SendLocalizedMessage(501685); // You open the keyring.
                }
                else if (!from.InRange(targeted, 3) || !from.InLOS(targeted))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                }
                else if (targeted is Item)
                {
                    Item   target     = (Item)targeted;
                    Region itemRegion = Region.Find(target.Location, target.Map);
                    string message    = "That does not have a lock.";

                    foreach (Key key in m_KeyRing.Keys)
                    {
                        if (target is ILockable)
                        {
                            if (key.UseOn(from, (ILockable)target))
                            {
                                message = null;
                                break;
                            }

                            message = "The key does not fit that lock.";
                            continue;
                        }
                        if (itemRegion is Regions.HouseRegion)
                        {
                            Multis.BaseHouse house = ((Regions.HouseRegion)itemRegion).House;

                            if (house == null || !from.Alive || house.Deleted)
                            {
                                continue;
                            }
                            if (target.RootParent != null)
                            {
                                message = "You can not lock that down";
                                continue;
                            }
                            if (house.HouseKeyVal != key.KeyValue)
                            {
                                message = "You must use the house key to lock down or unlock items.";
                                continue;
                            }
                            if (!target.Movable && !house.IsLockedDown(target))
                            {
                                message = "You can't unlock that!";
                                continue;
                            }
                            if (key.OnHouseItemTarget(from, target, ((Regions.HouseRegion)itemRegion).House))
                            {
                                message = null;
                                break;
                            }
                        }
                    }

                    if (message != null)
                    {
                        from.SendAsciiMessage(message);
                    }
                }
                else
                {
                    from.SendAsciiMessage("You can't use a key on that!");
                }
            }