Esempio n. 1
0
        public static bool CheckPlacement(Mobile from, Point3D p, int multiId, Point3D offset)
        {
            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - offset.X, p.Y - offset.Y, p.Z - offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, multiId, center, out toMove);

            if (res == HousePlacementResult.Valid)
            {
                return(true);
            }
            else if (res == HousePlacementResult.BadItem || res == HousePlacementResult.BadLand || res == HousePlacementResult.BadStatic || res == HousePlacementResult.BadRegionHidden)
            {
                from.SendLocalizedMessage(1043287);                   // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                return(false);
            }
            else if (res == HousePlacementResult.NoSurface)
            {
                from.SendMessage("The house could not be created here.  Part of the foundation would not be on any surface.");
                return(false);
            }
            else if (res == HousePlacementResult.BadRegion)
            {
                from.SendLocalizedMessage(501265);                   // Housing cannot be created in this area.
                return(false);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        private void PlacementWarning_Callback(Mobile from, bool okay, object state)
        {
            PreviewHouse prevHouse = (PreviewHouse)state;

            if (Deleted || !okay || !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType(typeof(HouseDeed)) == null)
            {
                prevHouse.Delete();
                return;
            }
            ;



            if (prevHouse.Deleted)
            {
                /* Too much time has passed and the test house you created has been deleted.
                 * Please try again!
                 */
                from.SendGump(new NoticeGump(1060637, 30720, 1060647, 32512, 320, 180, null, null));

                return;
            }

            Point3D center = prevHouse.Location;
            Map     map    = prevHouse.Map;

            prevHouse.Delete();

            ArrayList            toMove;
            HousePlacementResult res   = HousePlacement.Check(from, m_MultiID, center, out toMove);
            BaseHouse            house = GetHouse(from);

            house.MoveToWorld(center, from.Map);
            Delete();

            for (int i = 0; i < toMove.Count; ++i)
            {
                object o = toMove[i];

                if (o is Mobile)
                {
                    ((Mobile)o).Location = house.BanLocation;
                }
                else if (o is Item)
                {
                    ((Item)o).Location = house.BanLocation;
                }
            }
        }
        public bool OnPlacement(Mobile from, Point3D p)
        {
            if (!from.CheckAlive())
            {
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
                {
                    from.SendLocalizedMessage(501271);                               // You already own a house, you may not place another!
                }
                else
                {
                    from.SendLocalizedMessage(1011576);                               // This is a valid location.

                    PreviewHouse prev = new PreviewHouse(m_MultiID);

                    MultiComponentList mcl = prev.Components;

                    Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z);

                    for (int i = 0; i < mcl.List.Length; ++i)
                    {
                        MultiTileEntry entry = mcl.List[i];

                        int itemID = entry.m_ItemID & 0x3FFF;

                        if (itemID >= 0xBA3 && itemID <= 0xC0E)
                        {
                            banLoc = new Point3D(center.X + entry.m_OffsetX, center.Y + entry.m_OffsetY, center.Z);
                            break;
                        }
                    }

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = banLoc;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = banLoc;
                        }
                    }

                    prev.MoveToWorld(center, from.Map);

                    /* You are about to place a new house.
                     * Placing this house will condemn any and all of your other houses that you may have.
                     * All of your houses on all shards will be affected.
                     *
                     * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week.
                     *
                     * Once you accept these terms, these effects cannot be reversed.
                     * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed.
                     *
                     * If you are absolutely certain you wish to proceed, click the button next to OKAY below.
                     * If you do not wish to trade for this house, click CANCEL.
                     */
                    from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, new WarningGumpCallback(PlacementWarning_Callback), prev));

                    return(true);
                }

                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                           // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                           // Housing cannot be created in this area.
                break;
            }
            }

            return(false);
        }
        public void PlacementWarning_Callback(Mobile from, bool okay, object state)
        {
            if (!from.CheckAlive())
            {
                return;
            }

            PreviewHouse prevHouse = (PreviewHouse)state;

            if (!okay)
            {
                prevHouse.Delete();
                return;
            }

            if (prevHouse.Deleted)
            {
                /* Too much time has passed and the test house you created has been deleted.
                 * Please try again!
                 */
                from.SendGump(new NoticeGump(1060637, 30720, 1060647, 32512, 320, 180, null, null));

                return;
            }

            Point3D center = prevHouse.Location;

            prevHouse.Delete();

            ArrayList toMove;
            //Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z );
            HousePlacementResult res = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
                {
                    from.SendLocalizedMessage(501271);                               // You already own a house, you may not place another!
                }
                else
                {
                    BaseHouse house = ConstructHouse(from);

                    if (house == null)
                    {
                        return;
                    }

                    house.Price = m_Cost;

                    if (Banker.Withdraw(from, m_Cost))
                    {
                        from.SendLocalizedMessage(1060398, m_Cost.ToString());                                   // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                    }
                    else
                    {
                        house.RemoveKeys(from);
                        house.Delete();
                        from.SendLocalizedMessage(1060646);                                   // You do not have the funds available in your bank box to purchase this house.  Try placing a smaller house, or adding gold or checks to your bank box.
                        return;
                    }

                    house.MoveToWorld(center, from.Map);

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }
                }

                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                           // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                           // Housing cannot be created in this area.
                break;
            }
            }
        }
Esempio n. 5
0
        // called by all house deeds but tents, they have their own implementation
        public virtual void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                 // That must be in your pack for you to use it.
                return;
            }

            if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
            {
                // wea: modified to ignore *siege* tents

                int       i       = 0;
                ArrayList ahouses = new ArrayList();
                ahouses = BaseHouse.GetAccountHouses(from);

                if (ahouses != null)
                {
                    foreach (object o in ahouses)
                    {
                        if (!(o is SiegeTent))
                        {
                            i++;
                        }
                    }

                    if (i > 0)
                    {
                        from.SendLocalizedMessage(501271);                         // You already own a house or a regular tent, you may not place another!
                        return;
                    }
                }
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                BaseHouse house = GetHouse(from);
                house.MoveToWorld(center, from.Map);
                Delete();

                for (int i = 0; i < toMove.Count; ++i)
                {
                    object o = toMove[i];

                    if (o is Tent)
                    {
                        (o as Tent).Annex(house);
                    }
                    else if (o is Mobile)
                    {
                        ((Mobile)o).Location = house.BanLocation;
                    }
                    else if (o is Item)
                    {
                        ((Item)o).Location = house.BanLocation;
                    }
                }

                break;
            }

            case HousePlacementResult.TentRegion:
            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            {
                from.SendLocalizedMessage(1043287);                                 // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.NoSurface:
            {
                from.SendMessage("The house could not be created here.  Part of the foundation would not be on any surface.");
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                                 // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTownship:
            {
                from.SendMessage("You are not authorized to build in this township.");
                break;
            }
            }
        }
Esempio n. 6
0
    // Override basic deed OnPlacement() so that tent specific text is used and a non tent multi id
    // based house placement check is performed

    // Also checks for account tents as opposed to houses

    public override void OnPlacement(Mobile from, Point3D p)
    {
        if (Deleted)
        {
            return;
        }

        if (!IsChildOf(from.Backpack))
        {
            from.SendLocalizedMessage(1042001);               // That must be in your pack for you to use it.
        }
        else if (from.AccessLevel < AccessLevel.GameMaster && HasAccountSiegeTent(from))
        {
            from.SendMessage("You already own a siege tent, you may not place another!");
        }
        else
        {
            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, 0x64, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                BaseHouse house = GetHouse(from);
                house.MoveToWorld(center, from.Map);
                house.Public = true;

                Delete();

                for (int i = 0; i < toMove.Count; ++i)
                {
                    object o = toMove[i];

                    if (o is Mobile)
                    {
                        ((Mobile)o).Location = house.BanLocation;
                    }
                    else if (o is Item)
                    {
                        ((Item)o).Location = house.BanLocation;
                    }
                }

                from.SendGump(new TentPlaceGump(from, house));
                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            {
                from.SendMessage("The siege tent could not be created here, Either something is blocking the house, or the house would not be on valid terrain.");
                break;
            }

            case HousePlacementResult.NoSurface:
            {
                from.SendMessage("The siege tent could not be created here.  Part of the foundation would not be on any surface.");
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendMessage("Siege tents cannot be placed in this area.");
                break;
            }

            case HousePlacementResult.BadRegionTownship:
            {
                from.SendMessage("You are not authorized to build in this township.");
                break;
            }
            }
        }
    }
Esempio n. 7
0
        public bool OnPlacement(Mobile from, Point3D p)
        {
            if (!from.CheckAlive())
            {
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                from.SendLocalizedMessage(1011576);                           // This is a valid location.
                BaseHouse house = ConstructHouse(from);

                if (house == null)
                {
                    return(false);
                }

                house.Price = m_Cost;

                if (Banker.Withdraw(from, m_Cost))
                {
                    from.SendLocalizedMessage(1060398, m_Cost.ToString());                               // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                }
                else
                {
                    house.RemoveKeys(from);
                    house.Delete();
                    from.SendLocalizedMessage(1060646);                               // You do not have the funds available in your bank box to purchase this house.  Try placing a smaller house, or adding gold or checks to your bank box.
                    return(false);
                }

                house.MoveToWorld(center, from.Map);

                for (int i = 0; i < toMove.Count; ++i)
                {
                    object o = toMove[i];

                    if (o is Mobile)
                    {
                        ((Mobile)o).Location = house.BanLocation;
                    }
                    else if (o is Item)
                    {
                        ((Item)o).Location = house.BanLocation;
                    }
                }


                return(true);
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                           // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                           // Housing cannot be created in this area.
                break;
            }
            }

            return(false);
        }
Esempio n. 8
0
        public void PlacementWarning_Callback(Mobile from, bool okay, object state)
        {
            if (!from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType(typeof(HousePlacementTool)) == null)
            {
                return;
            }

            PreviewHouse prevHouse = (PreviewHouse)state;

            if (!okay)
            {
                prevHouse.Delete();
                return;
            }

            if (prevHouse.Deleted)
            {
                /* Too much time has passed and the test house you created has been deleted.
                 * Please try again!
                 */
                from.SendGump(new NoticeGump(1060637, 30720, 1060647, 32512, 320, 180, null, null));

                return;
            }

            Point3D center = prevHouse.Location;
            Map     map    = prevHouse.Map;

            prevHouse.Delete();

            //Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z );
            HousePlacementResult res = HousePlacement.Check(from, m_MultiID, center, out ArrayList toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasReachedHouseLimit(from))
                {
                    from.SendLocalizedMessage(501271);                                     // You already own a house, you may not place another!
                }
                else
                {
                    BaseHouse house = ConstructHouse(from);

                    if (house == null)
                    {
                        return;
                    }

                    house.Price = m_Cost;

                    if (from.AccessLevel >= AccessLevel.GameMaster)
                    {
                        from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.", m_Cost.ToString());
                    }
                    else
                    {
                        if (Banker.Withdraw(from, m_Cost))
                        {
                            from.SendLocalizedMessage(1060398, m_Cost.ToString());                                             // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                        }
                        else
                        {
                            house.RemoveKeys(from);
                            house.Delete();
                            from.SendLocalizedMessage(1060646);                                             // You do not have the funds available in your bank box to purchase this house.  Try placing a smaller house, or adding gold or checks to your bank box.
                            return;
                        }
                    }

                    house.MoveToWorld(center, from.Map);

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }
                }

                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                                 // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                                 // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);                                 // Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }

            case HousePlacementResult.BadRegionRaffle:
            {
                from.SendLocalizedMessage(1150493);                                 // You must have a deed for this plot of land in order to build here.
                break;
            }

            case HousePlacementResult.InvalidCastleKeep:
            {
                from.SendLocalizedMessage(1061122);                                 // Castles and keeps cannot be created here.
                break;
            }
            }
        }
Esempio n. 9
0
        public bool OnPlacement(Mobile from, HouseSurveyTool tool, Point3D p)
        {
            if (!from.CheckAlive() || from.Backpack == null || tool == null || tool.UsesRemaining == 0 || !tool.IsChildOf(from.Backpack))
            {
                return(false);
            }

            if (SurveyPreviewHouse.PreviewHouseList.Contains(from))
            {
                from.SendMessage("You are already previewing a potential house location.");
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                from.SendMessage("This is valid terrain to place a house.");                           // This is a valid location.

                SurveyPreviewHouse prev = new SurveyPreviewHouse(m_MultiID, from);

                MultiComponentList mcl = prev.Components;

                prev.MoveToWorld(center, from.Map);

                string message = "You have found valid terrain to place a house.  This preview will stay visible for 20 seconds.<BR><BR>Press OKAY to stop previewing this house.";

                from.SendGump(new NoticeGump(1060635, 30720, message, 0xFFC000, 420, 280, new NoticeGumpCallback(SurveyNotice_Callback), prev));

                return(true);
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                           // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                           // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);                           //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }
            }

            return(false);
        }
Esempio n. 10
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                from.SendAsciiMessage("That must be in your pack for you to use it.");
            }
            else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
            {
                from.SendAsciiMessage("You already own a house, you may not place another!");
            }
            else
            {
                ArrayList            toMove;
                Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
                HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

                switch (res)
                {
                case HousePlacementResult.Valid:
                {
                    BaseHouse house = GetHouse(from);
                    house.MoveToWorld(center, from.Map);
                    Delete();

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }

                    break;
                }

                case HousePlacementResult.BadItem:
                case HousePlacementResult.BadLand:
                case HousePlacementResult.BadStatic:
                case HousePlacementResult.BadRegionHidden:
                {
                    from.SendAsciiMessage("The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain.");
                    break;
                }

                case HousePlacementResult.NoSurface:
                {
                    from.SendAsciiMessage("The house could not be created here. Part of the foundation would not be on any surface.");
                    break;
                }

                case HousePlacementResult.BadRegion:
                {
                    from.SendAsciiMessage("Housing cannot be created in this area.");
                    break;
                }
                }
            }
        }
Esempio n. 11
0
        public bool OnPlacement(Mobile from, Point3D p)
        {
            if (!from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType(typeof(HousePlacementTool)) == null)
            {
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                from.SendLocalizedMessage(1011576);         // This is a valid location.

                PreviewHouse prev = new PreviewHouse(m_MultiID);

                MultiComponentList mcl = prev.Components;

                Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z);

                for (int i = 0; i < mcl.List.Length; ++i)
                {
                    MultiTileEntry entry = mcl.List[i];

                    int itemID = entry.m_ItemID;

                    if (itemID >= 0xBA3 && itemID <= 0xC0E)
                    {
                        banLoc = new Point3D(center.X + entry.m_OffsetX, center.Y + entry.m_OffsetY, center.Z);
                        break;
                    }
                }

                for (int i = 0; i < toMove.Count; ++i)
                {
                    object o = toMove[i];

                    if (o is Mobile)
                    {
                        ((Mobile)o).Location = banLoc;
                    }
                    else if (o is Item)
                    {
                        ((Item)o).Location = banLoc;
                    }
                }

                prev.MoveToWorld(center, from.Map);

                /* You are about to place a new house.
                 * Placing this house will condemn any and all of your other houses that you may have.
                 * All of your houses on all shards will be affected.
                 *
                 * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week.
                 *
                 * Once you accept these terms, these effects cannot be reversed.
                 * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed.
                 *
                 * If you are absolutely certain you wish to proceed, click the button next to OKAY below.
                 * If you do not wish to trade for this house, click CANCEL.
                 */
                from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, new WarningGumpCallback(PlacementWarning_Callback), prev));

                return(true);
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);         // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);         // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);         //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }

            case HousePlacementResult.BadRegionRaffle:
            {
                from.SendLocalizedMessage(1150493);         // You must have a deed for this plot of land in order to build here.
                break;
            }

            case HousePlacementResult.InvalidCastleKeep:
            {
                from.SendLocalizedMessage(1061122);         // Castles and keeps cannot be created here.
                break;
            }

            case HousePlacementResult.NoQueenLoyalty:
            {
                from.SendLocalizedMessage(1113707, "10000");         // You must have at lease ~1_MIN~ loyalty to the Gargoyle Queen to place a house in Ter Mur.
                break;
            }
            }

            return(false);
        }
Esempio n. 12
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove, bool east_facing_door)
        {
            toMove = new ArrayList();

            //Basic Limitations

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center))
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar/T2A
            }
            if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E))
            {
                return(HousePlacementResult.InvalidCastleKeep);
            }

            NoHousingRegion noHousingRegion = (NoHousingRegion)Region.Find(center, map).GetRegion(typeof(NoHousingRegion));

            if (noHousingRegion != null)
            {
                return(HousePlacementResult.BadRegion);
            }

            //Tile-Specific Limitations

            /* Placement Rules:
             *          1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             *          2) No impassable object or land tile may come in direct contact with any part of the house.
             *          3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             *          4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             *          5) No foundation tile may reside over terrain which is viewed as a road.
             */

            HousePlacementResult firstBadResult      = HousePlacementResult.Valid;
            List <Point2D>       m_BlockedTiles      = new List <Point2D>();
            List <Point2D>       m_BadProximityTiles = new List <Point2D>();
            Point2D badTile;

            MultiComponentList mcl = MultiData.GetComponents(multiID);

            //AOS House With Stairs
            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);
            }

            //Northwest Corner of House
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            List <Item>    items = new List <Item>();
            List <Mobile>  mobiles = new List <Mobile>();
            List <Point2D> yard = new List <Point2D>(), borders = new List <Point2D>();

            for (int x = 0; x < mcl.Width; ++x)
            {
                for (int y = 0; y < mcl.Height; ++y)
                {
                    int tileX = start.X + x;
                    int tileY = start.Y + y;

                    StaticTile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;
                    }

                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);
                    Region  reg       = Region.Find(testPoint, map);

                    if (!reg.AllowHousing(from, testPoint))                         // Cannot place houses in dungeons, towns, treasure map areas etc
                    {
                        if (reg.IsPartOf(typeof(HouseRegion)))
                        {
                            if (firstBadResult == HousePlacementResult.Valid)
                            {
                                firstBadResult = HousePlacementResult.BadRegionExistingHouse;
                            }

                            badTile = new Point2D(tileX, tileY);

                            if (!m_BadProximityTiles.Contains(badTile))
                            {
                                m_BadProximityTiles.Add(badTile);
                            }
                        }

                        else
                        {
                            if (reg.IsPartOf(typeof(TempNoHousingRegion)))
                            {
                                return(HousePlacementResult.BadRegionTemp);
                            }

                            if (reg.IsPartOf(typeof(TreasureRegion)))
                            {
                                return(HousePlacementResult.BadRegionHidden);
                            }

                            if (reg.IsPartOf(typeof(HouseRaffleRegion)))
                            {
                                return(HousePlacementResult.BadRegionRaffle);
                            }

                            return(HousePlacementResult.BadRegion);
                        }
                    }

                    LandTile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int      landID   = landTile.ID & TileData.MaxLandValue;

                    StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    Sector sector = map.GetSector(tileX, tileY);

                    items.Clear();

                    for (int i = 0; i < sector.Items.Count; ++i)
                    {
                        Item item = sector.Items[i];

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    for (int i = 0; i < sector.Mobiles.Count; ++i)
                    {
                        Mobile m = sector.Mobiles[i];

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    for (int i = 0; i < addTiles.Length; ++i)
                    {
                        StaticTile addTile = addTiles[i];

                        if (addTile.ID == 0x1)                           //Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        //Broke Rule 2
                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            if (firstBadResult == HousePlacementResult.Valid)
                            {
                                firstBadResult = HousePlacementResult.BadLand;
                            }

                            badTile = new Point2D(tileX, tileY);

                            if (!m_BlockedTiles.Contains(badTile))
                            {
                                m_BlockedTiles.Add(badTile);
                            }
                        }

                        if (isFoundation && ((TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            StaticTile oldTile = oldTiles[j];
                            ItemData   id      = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue];

                            //Rules 2 Broken
                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                if (firstBadResult == HousePlacementResult.Valid)
                                {
                                    firstBadResult = HousePlacementResult.BadStatic;
                                }

                                badTile = new Point2D(tileX, tileY);

                                if (!m_BlockedTiles.Contains(badTile))
                                {
                                    m_BlockedTiles.Add(badTile);
                                }
                            }
                        }

                        for (int j = 0; j < items.Count; ++j)
                        {
                            Item     item = items[j];
                            ItemData id   = item.ItemData;

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }

                                //Broke Rule 2
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    if (firstBadResult == HousePlacementResult.Valid)
                                    {
                                        firstBadResult = HousePlacementResult.BadItem;
                                    }

                                    badTile = new Point2D(tileX, tileY);

                                    if (!m_BlockedTiles.Contains(badTile))
                                    {
                                        m_BlockedTiles.Add(badTile);
                                    }
                                }
                            }
                        }

                        //Broke Rule 4
                        if (isFoundation && !hasSurface)
                        {
                            if (firstBadResult == HousePlacementResult.Valid)
                            {
                                firstBadResult = HousePlacementResult.NoSurface;
                            }

                            badTile = new Point2D(tileX, tileY);

                            if (!m_BlockedTiles.Contains(badTile))
                            {
                                m_BlockedTiles.Add(badTile);
                            }
                        }

                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        //Broke Rule 5
                        if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1])
                        {
                            if (firstBadResult == HousePlacementResult.Valid)
                            {
                                firstBadResult = HousePlacementResult.BadLand;
                            }

                            badTile = new Point2D(tileX, tileY);

                            if (!m_BlockedTiles.Contains(badTile))
                            {
                                m_BlockedTiles.Add(badTile);
                            }
                        }
                    }

                    if (hasFoundation || east_facing_door)
                    {
                        int x_expanse = east_facing_door ? YardSize : SideyardSize;
                        int y_expanse = east_facing_door ? YardSize : YardSize;

                        for (int xOffset = -x_expanse; xOffset <= x_expanse; ++xOffset)
                        {
                            for (int yOffset = -y_expanse; yOffset <= y_expanse; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    StaticTile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool         shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        StaticTile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = borders[i];

                LandTile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int      landID   = landTile.ID & TileData.MaxLandValue;

                //Broke Rule
                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    if (firstBadResult == HousePlacementResult.Valid)
                    {
                        firstBadResult = HousePlacementResult.BadLand;
                    }

                    badTile = new Point2D(borderPoint.X, borderPoint.Y);

                    if (!m_BlockedTiles.Contains(badTile))
                    {
                        m_BlockedTiles.Add(badTile);
                    }
                }

                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    //Broke Rule 5
                    if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1])
                    {
                        if (firstBadResult == HousePlacementResult.Valid)
                        {
                            firstBadResult = HousePlacementResult.BadLand;
                        }

                        badTile = new Point2D(borderPoint.X, borderPoint.Y);

                        if (!m_BlockedTiles.Contains(badTile))
                        {
                            m_BlockedTiles.Add(badTile);
                        }
                    }
                }

                StaticTile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    StaticTile tile = tiles[j];
                    ItemData   id   = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

                    //Broke Rule 1
                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        if (firstBadResult == HousePlacementResult.Valid)
                        {
                            firstBadResult = HousePlacementResult.BadStatic;
                        }

                        badTile = new Point2D(borderPoint.X, borderPoint.Y);

                        if (!m_BlockedTiles.Contains(badTile))
                        {
                            m_BlockedTiles.Add(badTile);
                        }
                    }
                }

                Sector      sector      = map.GetSector(borderPoint.X, borderPoint.Y);
                List <Item> sectorItems = sector.Items;

                for (int j = 0; j < sectorItems.Count; ++j)
                {
                    Item item = sectorItems[j];

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    //Broke Rule 1
                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        if (firstBadResult == HousePlacementResult.Valid)
                        {
                            firstBadResult = HousePlacementResult.BadItem;
                        }

                        badTile = new Point2D(borderPoint.X, borderPoint.Y);

                        if (!m_BlockedTiles.Contains(badTile))
                        {
                            m_BlockedTiles.Add(badTile);
                        }
                    }
                }
            }

            List <Sector>    sectors = new List <Sector>();
            List <BaseHouse> houses  = new List <BaseHouse>();

            for (int i = 0; i < yard.Count; i++)
            {
                Sector sector = map.GetSector(yard[i]);

                if (!sectors.Contains(sector))
                {
                    sectors.Add(sector);

                    if (sector.Multis != null)
                    {
                        for (int j = 0; j < sector.Multis.Count; j++)
                        {
                            if (sector.Multis[j] is BaseHouse)
                            {
                                BaseHouse house = (BaseHouse)sector.Multis[j];

                                if (!houses.Contains(house))
                                {
                                    houses.Add(house);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                foreach (BaseHouse b in houses)
                {
                    //Broke Rule 3
                    if (b.Contains(yard[i]))
                    {
                        if (firstBadResult != HousePlacementResult.Valid)
                        {
                            firstBadResult = HousePlacementResult.BadStatic;
                        }

                        badTile = yard[i];

                        if (!m_BadProximityTiles.Contains(badTile) && !m_BlockedTiles.Contains(badTile))
                        {
                            m_BadProximityTiles.Add(badTile);
                        }
                    }
                }
            }

            if (firstBadResult != HousePlacementResult.Valid)
            {
                ShowBlockingTiles(from, m_BlockedTiles, m_BadProximityTiles, from.Map);

                return(firstBadResult);
            }

            return(HousePlacementResult.Valid);
        }
Esempio n. 13
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
            else
            {
                ArrayList            toMove;
                Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
                HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove, HasEastFacingDoor());

                switch (res)
                {
                case HousePlacementResult.Valid:
                {
                    if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
                    {
                        from.SendLocalizedMessage(501271);     // You already own a house, you may not place another!
                        return;
                    }

                    BaseHouse house = GetHouse(from);

                    //For Custom house, drop z-level by -8 <--- May need to revise after we add more custom houses
                    if (house is SmallStoneTempleHouse || house is MagistrateHouse || house is SandstoneSpaHouse || house is ArbiterEstate)
                    {
                        center.Z -= 8;
                    }

                    house.MoveToWorld(center, from.Map);
                    Delete();

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }

                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }

                    break;
                }

                case HousePlacementResult.BadRegionExistingHouse:
                {
                    from.SendMessage(149, "A house already exists at that location.");
                    break;
                }

                case HousePlacementResult.BadRegionHidden:
                {
                    from.SendMessage(149, "That location does not allow housing.");
                    break;
                }

                case HousePlacementResult.BadItem:
                case HousePlacementResult.BadLand:
                case HousePlacementResult.BadStatic:
                {
                    from.SendMessage(149, "House placement failed: White fire indicates tiles blocked by terrain and Blue fire indicates tiles violating housing proximity limits.");
                    //from.SendLocalizedMessage(1043287); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                    break;
                }

                case HousePlacementResult.NoSurface:
                {
                    from.SendMessage(149, "House placement failed: White fire indicates tiles blocked by terrain and Blue fire indicates tiles violating housing proximity limits.");
                    //from.SendMessage("The house could not be created here.  Part of the foundation would not be on any surface.");
                    break;
                }

                case HousePlacementResult.BadRegion:
                {
                    from.SendLocalizedMessage(501265);     // Housing cannot be created in this area.
                    break;
                }

                case HousePlacementResult.BadRegionTemp:
                {
                    from.SendLocalizedMessage(501270);     //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                    break;
                }

                case HousePlacementResult.BadRegionRaffle:
                {
                    from.SendLocalizedMessage(1150493);     // You must have a deed for this plot of land in order to build here.
                    break;
                }
                }
            }
        }
Esempio n. 14
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                   // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            ArrayList items = new ArrayList(), mobiles = new ArrayList();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            ArrayList yard = new ArrayList(), borders = new ArrayList();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             */

            for (int x = 0; x < mcl.Width; ++x)
            {
                for (int y = 0; y < mcl.Height; ++y)
                {
                    int tileX = start.X + x;
                    int tileY = start.Y + y;

                    Tile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    HousePlacementResult RegionCheck = HousePlacementRegionCheck(from, map, testPoint);
                    if (RegionCheck != HousePlacementResult.Valid)
                    {
                        return(RegionCheck);
                    }

                    Tile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int  landID   = landTile.ID & 0x3FFF;

                    Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    Sector sector = map.GetSector(tileX, tileY);

                    items.Clear();

                    foreach (Item item in sector.Items.Values)
                    {
                        if (item == null)
                        {
                            continue;
                        }

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    foreach (Mobile m in sector.Mobiles.Values)
                    {
                        if (m == null)
                        {
                            continue;
                        }

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    for (int i = 0; i < addTiles.Length; ++i)
                    {
                        Tile addTile = addTiles[i];

                        if (addTile.ID == 0x4001)                           // Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            return(HousePlacementResult.BadLand);                            // Broke rule #2
                        }
                        if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            Tile     oldTile = oldTiles[j];
                            ItemData id      = TileData.ItemTable[oldTile.ID & 0x3FFF];

                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                return(HousePlacementResult.BadStatic);                                // Broke rule #2
                            }
                            else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z)
                            {
                                hasSurface = true;
                            }
                        }

                        for (int j = 0; j < items.Count; ++j)
                        {
                            Item     item = (Item)items[j];
                            ItemData id   = item.ItemData;

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    return(HousePlacementResult.BadItem);                                    // Broke rule #2
                                }
                            }
                            else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z)
                            {
                                hasSurface = true;
                            }
                        }

                        if (isFoundation && !hasSurface)
                        {
                            return(HousePlacementResult.NoSurface);                            // Broke rule #4
                        }
                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = (Mobile)mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if ((landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) && (ExceptionTiles(landID) == false))
                        {
                            //Console.WriteLine(landID.ToString());
                            return(HousePlacementResult.BadLand);                            // Broke rule #5
                        }
                    }

                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    Tile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool   shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        Tile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = (Point2D)borders[i];

                Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int  landID   = landTile.ID & 0x3FFF;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if ((landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) && (ExceptionTiles(landID) == false))
                    {
                        //Console.WriteLine(landID.ToString());
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }

                Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    Tile     tile = tiles[j];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #1
                    }
                }

                Sector sector = map.GetSector(borderPoint.X, borderPoint.Y);

                foreach (Item item in sector.Items.Values)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem);                        // Broke rule #1
                    }
                }
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                Point2D yardPoint = (Point2D)yard[i];

                IPooledEnumerable eable = map.GetMultiTilesAt(yardPoint.X, yardPoint.Y);

                foreach (Tile[] tile in eable)
                {
                    for (int j = 0; j < tile.Length; ++j)
                    {
                        if ((TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0)
                        {
                            eable.Free();
                            return(HousePlacementResult.BadStatic);                            // Broke rule #3
                        }
                    }
                }

                eable.Free();
            }

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }
Esempio n. 15
0
        public bool Validate(Mobile from)
        {
            // original region "name" checks.
            if (from.Region.Name == "Cove" || from.Region.Name == "Britain" ||                //towns
                from.Region.Name == "Jhelom" || from.Region.Name == "Minoc" ||                //towns
                from.Region.Name == "Haven" || from.Region.Name == "Trinsic" ||               //towns
                from.Region.Name == "Vesper" || from.Region.Name == "Yew" ||                  //towns
                from.Region.Name == "Wind" || from.Region.Name == "Serpent's Hold" ||         //towns
                from.Region.Name == "Skara Brae" || from.Region.Name == "Nujel'm" ||          //towns
                from.Region.Name == "Moonglow" || from.Region.Name == "Magincia" ||           //towns
                from.Region.Name == "Delucia" || from.Region.Name == "Papua" ||               //towns
                from.Region.Name == "Buccaneer's Den" || from.Region.Name == "Ocllo" ||       //towns
                from.Region.Name == "Gargoyle City" || from.Region.Name == "Mistas" ||        //towns
                from.Region.Name == "Montor" || from.Region.Name == "Alexandretta's Bowl" ||  //towns
                from.Region.Name == "Lenmir Anfinmotas" || from.Region.Name == "Reg Volon" || //towns
                from.Region.Name == "Bet-Lem Reg" || from.Region.Name == "Lake Shire" ||      //towns
                from.Region.Name == "Ancient Citadel" || from.Region.Name == "Luna" ||        //towns
                from.Region.Name == "Umbra" ||                                                //towns

                from.Region.Name == "Moongates" ||

                from.Region.Name == "Covetous" || from.Region.Name == "Deceit" ||                   //dungeons
                from.Region.Name == "Despise" || from.Region.Name == "Destard" ||                   //dungeons
                from.Region.Name == "Hythloth" || from.Region.Name == "Shame" ||                    //dungeons
                from.Region.Name == "Wrong" || from.Region.Name == "Terathan Keep" ||               //dungeons
                from.Region.Name == "Fire" || from.Region.Name == "Ice" ||                          //dungeons
                from.Region.Name == "Rock Dungeon" || from.Region.Name == "Spider Cave" ||          //dungeons
                from.Region.Name == "Spectre Dungeon" || from.Region.Name == "Blood Dungeon" ||     //dungeons
                from.Region.Name == "Wisp Dungeon" || from.Region.Name == "Ankh Dungeon" ||         //dungeons
                from.Region.Name == "Exodus Dungeon" || from.Region.Name == "Sorcerer's Dungeon" || //dungeons
                from.Region.Name == "Ancient Lair" || from.Region.Name == "Doom" ||                 //dungeons

                from.Region.Name == "Britain Graveyard" || from.Region.Name == "Wrong Entrance" ||
                from.Region.Name == "Covetous Entrance" || from.Region.Name == "Despise Entrance" ||
                from.Region.Name == "Despise Passage" || from.Region.Name == "Jhelom Islands" ||
                from.Region.Name == "Haven Island" || from.Region.Name == "Crystal Cave Entrance" ||
                from.Region.Name == "Protected Island" || from.Region.Name == "Jail")
            {
                return(false);
            }



            if (from.Map == Map.Trammel)                // Retelling - no placement in "trammel"
            {
                return(false);
            }

            // house multis: 0x1404 is a narrow but wide lot
            // house multis: 0x1420  bigger overall, square shaped.

            ArrayList            toMove;
            HousePlacementResult res = HousePlacement.Check(from, 0x1404, from.Location, out toMove, false);

            if (res != HousePlacementResult.Valid)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 16
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
            {
                from.SendLocalizedMessage(501271);                   // You already own a house, you may not place another!
            }
            else
            {
                ArrayList            toMove;
                Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
                HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

                switch (res)
                {
                case HousePlacementResult.Valid:
                {
                    BaseHouse house = GetHouse(from);
                    house.MoveToWorld(center, from.Map);
                    Delete();

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }

                    break;
                }

                case HousePlacementResult.BadItem:
                case HousePlacementResult.BadLand:
                case HousePlacementResult.BadStatic:
                case HousePlacementResult.BadRegionHidden:
                {
                    from.SendLocalizedMessage(1043287);                               // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                    break;
                }

                case HousePlacementResult.NoSurface:
                {
                    from.SendMessage("The house could not be created here.  Part of the foundation would not be on any surface.");
                    break;
                }

                case HousePlacementResult.BadRegion:
                {
                    from.SendLocalizedMessage(501265);                               // Housing cannot be created in this area.
                    break;
                }

                case HousePlacementResult.BadRegionTemp:
                {
                    from.SendLocalizedMessage(501270);     //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                    break;
                }

                case HousePlacementResult.BadRegionRaffle:
                {
                    from.SendLocalizedMessage(1150493);     // You must have a deed for this plot of land in order to build here.
                    break;
                }
                }
            }
        }
Esempio n. 17
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove, bool tent)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                 // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            ArrayList items = new ArrayList(), mobiles = new ArrayList();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            ArrayList yard = new ArrayList(), borders = new ArrayList();

            // This is also a storage lists. It holds the addons for tents as we will want to exclude them
            ArrayList TentComponents = new ArrayList();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             * 6) Tried to place a tent but the area ws not clear of other retions
             * 7) if we are placing a house and there is a tent there at that we do not own, fail
             * 8) tried to place a non-tent and the area wasn't a valid region
             */

            for (int x = 0; x < mcl.Width; ++x)
            {
                for (int y = 0; y < mcl.Height; ++y)
                {
                    int tileX = start.X + x;
                    int tileY = start.Y + y;

                    Tile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    // okay, we have a house tile at this point, is there anything there to block us?
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    #region REGION_CHECK
                    // maybe this point is in a region that doesn't allow housing?
                    Region region = null;
                    HousePlacementResult RegionCheck = HousePlacementRegionCheck(from, map, testPoint, out region);

                    // if we are placing a tent, the area must be clear of everything including other tents
                    if (tent == true)
                    {                           // if we are placing a tent and the region is not cool, fail
                        if (RegionCheck != HousePlacementResult.Valid)
                        {
                            return(RegionCheck);                            // Broke rule #6
                        }
                    }
                    if (TentComponents != null && TentComponents.Count > 0)
                    {                           // if we are placing a house and there is a tent there at that we do not own, fail
                        foreach (BaseHouse bx in TentComponents)
                        {                       // disabled annex() in tent.cs until better understood
                            if (bx != null && bx.Owner != from)
                            {
                                return(RegionCheck);                                // Broke rule #7
                            }
                        }
                    }
                    else
                    {                           // if we are placing a house, the area better either be clear or a tent
                        if (RegionCheck != HousePlacementResult.Valid && RegionCheck != HousePlacementResult.TentRegion)
                        {
                            return(RegionCheck);                            // Broke rule #7
                        }
                        ////
                        // save the list of all the addon components from the tent as we will want to exclude them from further tests
                        if (RegionCheck == HousePlacementResult.TentRegion && region != null)
                        {
                            BaseHouse house = (region as HouseRegion).House;
                            if (house is Tent == true)
                            {
                                // we will move this house after house is placed
                                if (toMove.Contains(house) == false)
                                {
                                    toMove.Add(house);
                                }

                                if (TentComponents.Contains(house) == false)
                                {
                                    TentComponents.Add(house);
                                }

                                if (TentComponents.Contains((house as Tent).TentPack) == false)
                                {
                                    TentComponents.Add((house as Tent).TentPack);
                                }

                                if (TentComponents.Contains((house as Tent).TentBed) == false)
                                {
                                    TentComponents.Add((house as Tent).TentBed);
                                }

                                if (house.Addons != null)
                                {
                                    for (int ix = 0; ix < house.Addons.Count; ix++)
                                    {
                                        if (house.Addons[ix] != null)
                                        {
                                            Server.Items.BaseAddon ba = house.Addons[ix] as Server.Items.BaseAddon;
                                            for (int jx = 0; jx < ba.Components.Count; jx++)
                                            {
                                                if (TentComponents.Contains(ba.Components[jx]) == false)
                                                {
                                                    TentComponents.Add(ba.Components[jx]);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // otherwise, all is a go!
                    #endregion REGION_CHECK

                    // look at the land tiles (water etc.)
                    Tile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int  landID   = landTile.ID & 0x3FFF;

                    Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    // get the sector of this tile
                    Sector sector = map.GetSector(tileX, tileY);

                    #region ITEMS_MOBILES
                    // collect the items in this sector at this location
                    items.Clear();
                    foreach (Item item in sector.Items.Values)
                    {
                        if (item == null)
                        {
                            continue;
                        }

                        if (item.X == tileX && item.Y == tileY)
                        {
                            if (SpecialItemExclusion(item) == false)
                            {
                                if (TentComponents.Contains(item) == false)
                                {
                                    items.Add(item);
                                }
                            }
                        }
                    }

                    // collect the mobiles in this sector at this location
                    mobiles.Clear();
                    foreach (Mobile m in sector.Mobiles.Values)
                    {
                        if (m == null)
                        {
                            continue;
                        }

                        if (m.X == tileX && m.Y == tileY)
                        {
                            if (SpecialMobileExclusion(m) == false)
                            {
                                mobiles.Add(m);
                            }
                        }
                    }
                    #endregion ITEMS_MOBILES

                    #region LAND_TILES
                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    if (addTiles != null)
                    {
                        for (int i = 0; i < addTiles.Length; ++i)
                        {
                            Tile addTile = addTiles[i];

                            if (addTile.ID == 0x4001)                             // Nodraw
                            {
                                continue;
                            }

                            TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags;

                            bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                            bool hasSurface   = false;

                            if (isFoundation)
                            {
                                hasFoundation = true;
                            }

                            int addTileZ   = center.Z + addTile.Z;
                            int addTileTop = addTileZ + addTile.Height;

                            if ((addTileFlags & TileFlag.Surface) != 0)
                            {
                                addTileTop += 16;
                            }

                            if (addTileTop > landStartZ && landAvgZ > addTileZ)
                            {
                                return(HousePlacementResult.BadLand);                                // Broke rule #2
                            }
                            if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                            {
                                hasSurface = true;
                            }

                            for (int j = 0; j < oldTiles.Length; ++j)
                            {
                                Tile     oldTile = oldTiles[j];
                                ItemData id      = TileData.ItemTable[oldTile.ID & 0x3FFF];

                                if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                                {
                                    return(HousePlacementResult.BadStatic);                                    // Broke rule #2
                                }
                                else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z)
                                {
                                    hasSurface = true;
                                }
                            }

                            for (int j = 0; j < items.Count; ++j)
                            {
                                Item     item = (Item)items[j];
                                ItemData id   = item.ItemData;

                                if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                                {
                                    if (item.Movable)
                                    {
                                        toMove.Add(item);
                                    }
                                    else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                    {
                                        return(HousePlacementResult.BadItem);                                        // Broke rule #2
                                    }
                                }
                                else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z)
                                {
                                    hasSurface = true;
                                }
                            }

                            if (isFoundation && !hasSurface)
                            {
                                return(HousePlacementResult.NoSurface);                                // Broke rule #4
                            }
                            for (int j = 0; j < mobiles.Count; ++j)
                            {
                                Mobile m = (Mobile)mobiles[j];

                                if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                                {
                                    toMove.Add(m);
                                }
                            }
                        }
                    }
                    #endregion LAND_TILES

                    #region ROAD_TILES
                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if ((landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) && (ExceptionTiles(landID) == false))
                        {
                            //Console.WriteLine(landID.ToString());
                            return(HousePlacementResult.BadLand);                            // Broke rule #5
                        }
                    }
                    #endregion ROAD_TILES

                    #region YARD_CHECK
                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    Tile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool   shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        Tile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                    #endregion YARD_CHECK
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = (Point2D)borders[i];

                Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int  landID   = landTile.ID & 0x3FFF;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                #region ROAD_TILES
                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if ((landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) && (ExceptionTiles(landID) == false))
                    {
                        //Console.WriteLine(landID.ToString());
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }
                #endregion ROAD_TILES

                Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    Tile     tile = tiles[j];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #1
                    }
                }

                Sector sector = map.GetSector(borderPoint.X, borderPoint.Y);

                #region IMPASSABLE_TILE
                foreach (Item item in sector.Items.Values)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    // Adam: ignore these tent components
                    if (TentComponents.Contains(item) == true)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem);                        // Broke rule #1
                    }
                }
                #endregion IMPASSABLE_TILE
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                Point2D yardPoint = (Point2D)yard[i];

                IPooledEnumerable eable = map.GetMultiTilesAt(yardPoint.X, yardPoint.Y);

                foreach (Tile[] tile in eable)
                {
                    for (int j = 0; j < tile.Length; ++j)
                    {
                        if ((TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0)
                        {
                            eable.Free();
                            return(HousePlacementResult.BadStatic);                            // Broke rule #3
                        }
                    }
                }

                eable.Free();
            }

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }