예제 #1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                from.SendLocalizedMessage(503248);                  //Your godly powers allow you to place this vendor whereever you wish.

                Mobile v = new PlayerVendor(from, BaseHouse.FindHouseAt(from));
                v.Direction = from.Direction & Direction.Mask;
                v.MoveToWorld(from.Location, from.Map);

                v.SayTo(from, 503246);                   // Ah! it feels good to be working again.

                this.Delete();
            }
            else
            {
                //find the house there at
                BaseHouse house = BaseHouse.FindHouseAt(from);

                // wea: allow placement within tents
                if (house == null)
                {
                    if (from.Region != null)
                    {
                        // is there a tent belonging to the person's account here though?
                        if (from.Region is HouseRegion)
                        {
                            HouseRegion hr = (HouseRegion)from.Region;

                            if ((hr.House is Tent || hr.House is SiegeTent) && hr.House.Owner.Account == from.Account)
                            {
                                house = ((HouseRegion)from.Region).House;
                            }
                        }
                    }
                }

                if (house == null)
                {
                    from.SendLocalizedMessage(503240);                      //Vendors can only be placed in houses.
                }
                else if (!house.IsFriend(from))
                {
                    from.SendLocalizedMessage(503242);                       //You must ask the owner of this house to make you a friend in order to place this vendor here,
                }
                else if (!house.Public)
                {
                    from.SendLocalizedMessage(503241);                      //You cannot place this vendor.  Make sure the building is public and you have not reached your vendor limit.
                }
                else if (!house.CanPlaceNewVendor())
                {
                    from.SendLocalizedMessage(503241);                       // You cannot place this vendor or barkeep.  Make sure the house is public or a shop and has sufficient storage available.
                }
                //else if (house.FindTownshipNPC() != null)
                else if (house.CanPlacePlayerVendorInThisTownshipHouse() == false)
                {
                    from.SendMessage("You cannot place a vendor in a house with the township NPCs present.");
                }
                else
                {
                    Mobile v = new PlayerVendor(from, house);
                    v.Direction = from.Direction & Direction.Mask;
                    v.MoveToWorld(from.Location, from.Map);

                    v.SayTo(from, 503246);                     // Ah! it feels good to be working again.

                    this.Delete();
                }
            }
        }