예제 #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Key.Deleted || !m_Key.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(501661); // That key is unreachable.
                    return;
                }
                if (targeted == m_Key)
                {
                    from.SendLocalizedMessage(501665); // Enter a description for this key.
                    from.Prompt = new RenamePrompt(m_Key);
                }
                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);

                    if (itemRegion is Regions.HouseRegion)
                    {
                        BaseHouse house = ((Regions.HouseRegion)itemRegion).House;

                        if (house == null || !from.Alive || house.Deleted)
                        {
                            return;
                        }
                        if (house.HouseKeyVal == m_Key.KeyValue)
                        {
                            if (target.RootParent != null)
                            {
                                from.SendAsciiMessage("You can not lock that down");
                                return;
                            }
                            if (target is BaseDoor)
                            {
                                if (m_Key.UseOn(from, (ILockable)targeted))
                                {
                                    return;
                                }

                                from.SendAsciiMessage("The key does not fit that lock");
                                return;
                            }
                            if (!target.Movable && !house.IsLockedDown(target))
                            {
                                from.SendAsciiMessage("You can't unlock that!");
                                return;
                            }
                            if (m_Key.OnHouseItemTarget(from, target, ((Regions.HouseRegion)itemRegion).House))
                            {
                                return;
                            }
                        }
                    }
                    if (target is ILockable)
                    {
                        if (m_Key.UseOn(from, (ILockable)target))
                        {
                            return;
                        }

                        from.SendAsciiMessage("The key does not fit that lock");
                        return;
                    }
                    if (itemRegion is Regions.HouseRegion)
                    {
                        from.SendAsciiMessage(((Regions.HouseRegion)itemRegion).House != null ? "You must use the house key to lock down or unlock items." : "That does not have a lock.");
                        return;
                    }
                }
                else
                {
                    from.SendAsciiMessage("You can't use a key on that!");
                }

                /*
                 * if (targeted is ILockable && m_Key.UseOn(from, (ILockable)targeted))
                 *      number = -1;
                 *  else
                 *  {
                 *      Item target = (Item)targeted;
                 *      BaseHouse house = BaseHouse.FindHouseAt(from);
                 *
                 *      if (target.RootParent == null)
                 *      {
                 *          if (house != null )
                 *          {
                 *              m_Key.OnHouseItemTarget(from, target, house);
                 *              return;
                 *          }
                 *      }
                 *
                 *      from.SendAsciiMessage("That does not have a lock.");
                 *      number = -1;
                 *  }
                 * }
                 * else
                 * {
                 *  number = 501666; // You can't unlock that!
                 * }
                 * if (number != -1)
                 *  from.SendLocalizedMessage(number);*/
            }