Inheritance: Server.Items.BaseMulti
Beispiel #1
1
        public VendorInventory( BaseHouse house, GenericReader reader )
        {
            m_House = house;

            int version = reader.ReadEncodedInt();

            m_Owner = reader.ReadMobile();
            m_VendorName = reader.ReadString();
            m_ShopName = reader.ReadString();

            m_Items = reader.ReadStrongItemList();
            m_Gold = reader.ReadInt();

            m_ExpireTime = reader.ReadDeltaTime();

            if ( m_Items.Count == 0 && m_Gold == 0 )
            {
                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) );
            }
            else
            {
                TimeSpan delay = m_ExpireTime - DateTime.UtcNow;
                m_ExpireTimer = new ExpireTimer( this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero );
                m_ExpireTimer.Start();
            }
        }
Beispiel #2
1
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				{
					m_House = reader.ReadItem() as BaseHouse;
					goto case 0;
				}
				case 0:
				{
					m_Description = reader.ReadString();
					m_Marked = reader.ReadBool();
					m_Target = reader.ReadPoint3D();
					m_TargetMap = reader.ReadMap();

					CalculateHue();

					break;
				}
			}
		}
        public bool ValidatePlacement(Point3D loc)
        {
            Map map = m_From.Map;
            if (map == null)
                return false;
            
            m_House = BaseHouse.FindHouseAt(m_From.Location, map, 20);
            if (m_House == null || !m_House.IsOwner(m_From))
            {
                m_From.SendMessage("You must be standing in your house to place this");
                return false;
            }

            if (loc.Y > m_From.Location.Y + YardSettings.Front || loc.Y < m_From.Location.Y - YardSettings.Back)
            {
                m_From.SendMessage("This is outside of your yard. Please re-try the placement");
                return false;
            }

            if (loc.X > m_From.Location.X + YardSettings.Right || loc.X < m_From.Location.X - YardSettings.Left)
            {
                m_From.SendMessage("This is outside of your yard. Please re-try the placement");
                return false;
            }
            return true;
        }
Beispiel #4
0
		public TentPackGump( Mobile mobile, BaseHouse house ) : base( 110, 100 )
		{
			m_Mobile = mobile;
			m_House = house;

			mobile.CloseGump( typeof( TentPackGump ) );

			Closable = false;

			AddPage( 0 );

			AddBackground( 0, 0, 420, 280, 5054 );

			AddImageTiled( 10, 10, 400, 20, 2624 );
			AddAlphaRegion( 10, 10, 400, 20 );

			AddHtmlLocalized( 10, 10, 400, 20, 1060635, 30720, false, false ); // <CENTER>WARNING</CENTER>

			AddImageTiled( 10, 40, 400, 200, 2624 );
			AddAlphaRegion( 10, 40, 400, 200 );
			AddHtml( 10, 40, 400, 200, string.Format( "You are about to pack up your tent.\nYou will place the tent back in its tent bag.\nThe tent will remain behind and can be freely picked up by anyone.\nOnce the tent has been put away, anyone can attempt to place a new house or tent on the vacant land.\n	Are you sure you wish to continue?" ), false, true );

			AddImageTiled( 10, 250, 400, 20, 2624 );
			AddAlphaRegion( 10, 250, 400, 20 );

			AddButton( 10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 40, 250, 170, 20, 1011036, 32767, false, false ); // OKAY

			AddButton( 210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 240, 250, 170, 20, 1011012, 32767, false, false ); // CANCEL
		}
        /*public static void Initialize()
        {
            EventSink.Login += new LoginEventHandler( OnLogin );
        }

        public static void OnLogin( LoginEventArgs e )
        {
            BaseHouse house = BaseHouse.FindHouseAt( e.Mobile );

            if ( house != null && !house.Public && !house.IsFriend( e.Mobile ) )
                e.Mobile.Location = house.BanLocation;
        }*/
        public HouseRegion( BaseHouse house )
            : base(null, house.Map, HousePriority, GetArea( house ))
        {
            m_House = house;
            Point3D ban = house.RelativeBanLocation;
            this.GoLocation = new Point3D( house.X + ban.X, house.Y + ban.Y, house.Z + ban.Z );
        }
Beispiel #6
0
 public HouseSign(BaseHouse owner)
     : base(0xBD2)
 {
     this.m_Owner = owner;
     this.m_OrgOwner = this.m_Owner.Owner;
     this.Movable = false;
 }
		public VendorInventory(BaseHouse house, GenericReader reader)
		{
			House = house;

			reader.ReadEncodedInt();

			Owner = reader.ReadMobile();
			VendorName = reader.ReadString();
			ShopName = reader.ReadString();

			Items = reader.ReadStrongItemList();
			Currency = reader.ReadInt();

			ExpireTime = reader.ReadDeltaTime();

			if (Items.Count == 0 && Currency == 0)
			{
				Timer.DelayCall(TimeSpan.Zero, Delete);
			}
			else
			{
				TimeSpan delay = ExpireTime - DateTime.UtcNow;

				m_ExpireTimer = new ExpireTimer(this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero);
				m_ExpireTimer.Start();
			}
		}
Beispiel #8
0
        public PlayerVendor( Mobile owner, BaseHouse house )
        {
            Owner = owner;
            House = house;

            if ( BaseHouse.NewVendorSystem )
            {
                m_BankAccount = 0;
                m_HoldGold = 4;
            }
            else
            {
                m_BankAccount = 1000;
                m_HoldGold = 0;
            }

            ShopName = "Shop Not Yet Named";

            m_SellItems = new Hashtable();

            CantWalk = true;

            InitStats( 75, 75, 75 );
            InitBody();
            InitOutfit();

            TimeSpan delay = PayTimer.GetInterval();

            m_PayTimer = new PayTimer( this, delay );
            m_PayTimer.Start();

            m_NextPayTime = DateTime.Now + delay;
        }
Beispiel #9
0
        private void Replace()
        {
            Container c = Parent as Container;

            if (c != null)
            {
                var deed = new DragonHeadAddonDeed();
                c.DropItem(deed);
            }
            else if (Parent == null)
            {
                Server.Multis.BaseHouse house = Server.Multis.BaseHouse.FindHouseAt(this);

                var deed = new DragonHeadAddonDeed();
                deed.MoveToWorld(Location, Map);

                deed.IsLockedDown = IsLockedDown;
                deed.IsSecure     = IsSecure;
                deed.Movable      = Movable;

                if (house != null && house.LockDowns.ContainsKey(this))
                {
                    house.LockDowns.Remove(this);
                    house.LockDowns.Add(deed, house.Owner);
                }
                else if (house != null && house.IsSecure(this))
                {
                    house.ReleaseSecure(house.Owner, this);
                    house.AddSecure(house.Owner, deed);
                }
            }

            Delete();
        }
Beispiel #10
0
		public StrongBox( Mobile owner, BaseHouse house ) : base( 0xE80 )
		{
			m_Owner = owner;
			m_House = house;

			MaxItems = 25;
		}
        public static bool CheckAccess( BaseHouse house, Mobile from )
        {
            if ( house.Public || !house.IsAosRules )
                return !house.IsBanned( from );

            return house.HasAccess( from );
        }
Beispiel #12
0
 public EjectPlayerEntry(Mobile from, Mobile target)
     : base(6206, 12)
 {
     this.m_From = from;
     this.m_Target = target;
     this.m_TargetHouse = BaseHouse.FindHouseAt(this.m_Target);
 }
        public VendorInventoryGump(BaseHouse house, Mobile from)
            : base(50, 50)
        {
            m_House = house;
            m_Inventories = new ArrayList(house.VendorInventories);

            AddBackground(0, 0, 420, 50 + 20 * m_Inventories.Count, 0x13BE);

            AddImageTiled(10, 10, 400, 20, 0xA40);
            AddHtmlLocalized(15, 10, 200, 20, 1062435, 0x7FFF, false, false); // Reclaim Vendor Inventory
            AddHtmlLocalized(330, 10, 50, 20, 1062465, 0x7FFF, false, false); // Expires

            AddImageTiled(10, 40, 400, 20 * m_Inventories.Count, 0xA40);

            for (int i = 0; i < m_Inventories.Count; i++)
            {
                VendorInventory inventory = (VendorInventory)m_Inventories[i];

                int y = 40 + 20 * i;

                if (inventory.Owner == from)
                    AddButton(10, y, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0);

                AddLabel(45, y, 0x481, String.Format("{0} ({1})", inventory.ShopName, inventory.VendorName));

                TimeSpan expire = inventory.ExpireTime - DateTime.UtcNow;
                int hours = (int)expire.TotalHours;

                AddLabel(320, y, 0x481, hours.ToString());
                AddHtmlLocalized(350, y, 50, 20, 1062466, 0x7FFF, false, false); // hour(s)
            }
        }
 public HouseRegion( BaseHouse house )
     : base("", "", house.Map)
 {
     Priority = Region.HousePriority;
     LoadFromXml = false;
     m_House = house;
 }
Beispiel #15
0
 public HouseSign( BaseHouse owner )
     : base(0xBD2)
 {
     m_Owner = owner;
     m_OrgOwner = m_Owner.Owner;
     Movable = false;
 }
		public MovingCrate( BaseHouse house ) : base( 0xE3D )
		{
			Hue = 0x8A5;
			Movable = false;

			m_House = house;
		}
        public HouseRemoveGump(int number, ArrayList list, BaseHouse house, bool accountOf)
            : base(20, 30)
        {
            if (house.Deleted)
                return;

            this.m_House = house;
            this.m_List = list;
            this.m_Number = number;
            this.m_AccountOf = accountOf;

            this.AddPage(0);

            this.AddBackground(0, 0, 420, 430, 5054);
            this.AddBackground(10, 10, 400, 410, 3000);

            this.AddButton(20, 388, 4005, 4007, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(55, 388, 300, 20, 1011104, false, false); // Return to previous menu

            this.AddButton(20, 365, 4005, 4007, 1, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(55, 365, 300, 20, 1011270, false, false); // Remove now!

            this.AddHtmlLocalized(20, 20, 350, 20, number, false, false);

            if (list != null)
            {
                this.m_Copy = new ArrayList(list);

                for (int i = 0; i < list.Count; ++i)
                {
                    if ((i % 15) == 0)
                    {
                        if (i != 0)
                        {
                            // Next button
                            this.AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, (i / 15) + 1);
                        }

                        this.AddPage((i / 15) + 1);

                        if (i != 0)
                        {
                            // Previous button
                            this.AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15);
                        }
                    }

                    Mobile m = (Mobile)list[i];

                    string name;

                    if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0)
                        continue;

                    this.AddCheck(34, 52 + ((i % 15) * 20), 0xD2, 0xD3, false, i);
                    this.AddLabel(55, 52 + ((i % 15) * 20), 0, accountOf && m.Player && m.Account != null ? String.Format("Account of {0}", name) : name);
                }
            }
        }
        public static bool HasContract( BaseHouse house )
        {
            foreach( Item item in TownHouseSign.AllSigns )
                if ( item is RentalContract && house == ((RentalContract)item).ParentHouse )
                    return true;

            return false;
        }
Beispiel #19
0
        public MovingCrate(BaseHouse house)
            : base(0xE3D)
        {
            this.Hue = 0x8A5;
            this.Movable = false;

            this.m_House = house;
        }
Beispiel #20
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_House = reader.ReadItem() as BaseHouse;
        }
Beispiel #21
0
 public HouseSign(BaseHouse owner, uint keyValue, bool TowerCastle)
     : base(0xBD0)
 {
     m_Owner = owner;
     m_OrgOwner = m_Owner.Owner;
     m_KeyOwner = keyValue;
     Movable = false;
 }
Beispiel #22
0
 public HouseSign(BaseHouse owner, uint keyValue)
     : base(0xBD2)
 {
     m_Owner = owner;
     m_OrgOwner = m_Owner.Owner;
     m_KeyOwner = keyValue;
     Movable = false;
 }
		public static AddonFitResult CouldFit( Point3D p, Map map, Mobile from, ref BaseHouse house )
		{
			if ( !map.CanFit( p.X, p.Y, p.Z, 20, false, true, true ) )
				return AddonFitResult.Blocked;
			else if ( !BaseAddon.CheckHouse( from, p, map, 20, ref house ) )
				return AddonFitResult.NotInHouse;
			else
				return CheckDoors( p, 20, house );
		}
Beispiel #24
0
		public AttendantHerald() : base( "the Herald" )
		{
			m_Announcement = m_Announcements[ 0 ];
			m_Greeting = m_Greetings[ 0 ];

			m_NextYell = DateTime.Now;
			m_House = null;
			m_Location = Point3D.Zero;
		}
Beispiel #25
0
 public HouseSign( BaseHouse owner )
     : base(0xBD2)
 {
     m_Owner = owner;
     m_OrgOwner = m_Owner.Owner;
     Name = "a house sign";
     Movable = false;
     m_HouseDecay = DateTime.Now + HouseLifeSpan;
 }
        public static int AllRentalSecures( BaseHouse house )
        {
            int count = 0;

            foreach( TownHouseSign sign in TownHouseSign.AllSigns )
                if ( sign is RentalContract && ((RentalContract)sign).ParentHouse == house )
                    count+=sign.Secures;

            return count;
        }
Beispiel #27
0
        public static void Replace(Item item1, Item item2)
        {
            Timer.DelayCall <Item, Item>(TimeSpan.FromSeconds(1), (oldItem, newItem) =>
            {
                var parent = oldItem.Parent;

                if (parent == null)
                {
                    Multis.BaseHouse house = Multis.BaseHouse.FindHouseAt(oldItem);

                    newItem.MoveToWorld(oldItem.Location, oldItem.Map);

                    newItem.IsLockedDown = oldItem.IsLockedDown;
                    newItem.IsSecure     = oldItem.IsSecure;
                    newItem.Movable      = oldItem.Movable;

                    if (house != null && house.LockDowns.ContainsKey(oldItem))
                    {
                        house.LockDowns.Remove(oldItem);
                        house.LockDowns.Add(newItem, house.Owner);
                    }
                    else if (house != null && house.IsSecure(oldItem))
                    {
                        house.ReleaseSecure(house.Owner, oldItem);
                        house.AddSecure(house.Owner, newItem);
                    }

                    oldItem.Delete();
                }
                else
                {
                    newItem.Movable = oldItem.Movable;

                    if (parent is Container)
                    {
                        oldItem.Delete();
                        ((Container)parent).DropItem(newItem);
                    }
                    else if (parent is Mobile)
                    {
                        oldItem.Delete();
                        ((Mobile)parent).AddItem(newItem);
                    }
                    else
                    {
                        newItem.Delete();
                        oldItem.Delete();

                        Console.WriteLine("Item replacement failed: {0}", newItem.GetType());
                    }
                }
            }, item1, item2);
        }
Beispiel #28
0
		public NoHousingItem( BaseHouse house ) : base( 0x2FD5 )
		{
			m_Timer = new NoHousingDelayTimer( this );
			m_Timer.Start();

			m_Area = house.Region.Area;
			m_Region = new SimpleNoHousingRegion( house.Region.Map, m_Area );
			m_Region.Register();

			Visible = false;
			Movable = false;
		}
		public HouseDemolishGump(Mobile mobile, BaseHouse house)
			: base(110, 100)
		{
			m_Mobile = mobile;
			m_House = house;

			mobile.CloseGump(typeof(HouseDemolishGump));

			Closable = false;

			AddPage(0);

			AddBackground(0, 0, 420, 280, 5054);

			AddImageTiled(10, 10, 400, 20, 2624);
			AddAlphaRegion(10, 10, 400, 20);

			AddHtmlLocalized(10, 10, 400, 20, 1060635, 30720, false, false); // <CENTER>WARNING</CENTER>

			AddImageTiled(10, 40, 400, 200, 2624);
			AddAlphaRegion(10, 40, 400, 200);

			//AddHtmlLocalized( 10, 40, 400, 200, 1061795, 32512, false, true );
			/* You are about to demolish your house.
																				* You will be refunded the house's value directly to your bank box.
																				* All items in the house will remain behind and can be freely picked up by anyone.
																				* Once the house is demolished, anyone can attempt to place a new house on the vacant land.
																				* This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you).
																				* Are you sure you wish to continue?
																				*/
			AddHtml(
				10,
				40,
				400,
				200,
				@"WARNING! If your house is a Classic House, a deed will be placed in your bank. If it is a custom house, you will be given a check for a FRACTION of the buying cost back.

Deeds on UO Forever are worth FAR less than the buying price to real estate broker NPCs.  If you want to sell it for a decent price, you may be able to sell to other players.

All items in the house will remain behind and can be freely picked up by anyone.  Once the house is demolished, anyone can attempt to place a new house on the vacant land.  Are you sure you wish to continue?",
				false,
				true);

			AddImageTiled(10, 250, 400, 20, 2624);
			AddAlphaRegion(10, 250, 400, 20);

			AddButton(10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0);
			AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767, false, false); // OKAY

			AddButton(210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0);
			AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767, false, false); // CANCEL
		}
Beispiel #30
0
		public RentedVendor( Mobile owner, BaseHouse house, VendorRentalDuration duration, int rentalPrice, bool landlordRenew, int rentalGold ) : base( owner, house )
		{
			m_RentalDuration = duration;
			m_RentalPrice = m_RenewalPrice = rentalPrice;
			m_LandlordRenew = landlordRenew;
			m_RenterRenew = false;

			m_RentalGold = rentalGold;

			m_RentalExpireTime = DateTime.Now + duration.Duration;
			m_RentalExpireTimer = new RentalExpireTimer( this, duration.Duration );
			m_RentalExpireTimer.Start();
		}
Beispiel #31
0
        public VendorInventory( BaseHouse house, Mobile owner, string vendorName, string shopName )
        {
            m_House = house;
            m_Owner = owner;
            m_VendorName = vendorName;
            m_ShopName = shopName;

            m_Items = new List<Item>();

            m_ExpireTime = DateTime.UtcNow + GracePeriod;
            m_ExpireTimer = new ExpireTimer( this, GracePeriod );
            m_ExpireTimer.Start();
        }
        public PlayerVendor( Mobile owner, BaseHouse house, GovernmentEntity government)
        {
            Owner = owner;
            House = house;
            Government = government;
            if (Government != null && !Government.Deleted)
                if(!Government.Employees.Contains(this))
                    Government.Employees.Add(this);

            if ( BaseHouse.NewVendorSystem )
            {
                if (Government != null)
                {
                    m_BankAccount = 0;
                    m_HoldCopper = Wages;
                }
                else
                {
                    m_BankAccount = 0;
                    m_HoldCopper = 4;
                }
            }
            else
            {
                m_BankAccount = 1000;
                m_HoldCopper = 0;
            }

            ShopName = "Shop Not Yet Named";

            m_SellItems = new Hashtable();

            CantWalk = true;

            if ( !Core.AOS )
                NameHue = 0x35;

            InitStats( 75, 75, 75 );
            InitBody();
            InitOutfit();
            RawStr = 100;
            RawDex = 100;
            RawStam = 100;

            TimeSpan delay = PayTimer.GetInterval();

            m_PayTimer = new PayTimer( this, delay );
            m_PayTimer.Start();

            m_NextPayTime = DateTime.Now + delay;
        }
Beispiel #33
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);
        }
Beispiel #34
0
 public HouseSign(BaseHouse owner) : base(0xBD2)
 {
     Owner         = owner;
     OriginalOwner = Owner.Owner;
     Movable       = false;
 }
Beispiel #35
0
 public HouseSign(BaseHouse owner) : base(0xBD2)
 {
     m_Owner    = owner;
     m_OrgOwner = m_Owner.Owner;
     Movable    = false;
 }
Beispiel #36
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.Batisseur)
            {
                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);
            }

            // 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
            List <Item>   items   = new List <Item>();
            List <Mobile> mobiles = new List <Mobile>();

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

            /* 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;

                    StaticTile[] 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);

                    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(TempNoHousingRegion)))
                        {
                            return(HousePlacementResult.BadRegionTemp);
                        }

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

                        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;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            return(HousePlacementResult.BadLand);                            // Broke rule #2
                        }
                        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];

                            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 = 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 = 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])
                        {
                            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)
                                {
                                    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;

                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])
                    {
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }

                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];

                    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);
                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;

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

            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)
                {
                    if (b.Contains(yard[i]))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #3
                    }
                }

                /*Point2D yardPoint = yard[i];
                 *
                 * IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );
                 *
                 * foreach ( StaticTile[] tile in eable )
                 * {
                 *      for ( int j = 0; j < tile.Length; ++j )
                 *      {
                 *              if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 )
                 *              {
                 *                      eable.Free();
                 *                      return HousePlacementResult.BadStatic; // Broke rule #3
                 *              }
                 *      }
                 * }
                 *
                 * eable.Free();*/
            }

            return(HousePlacementResult.Valid);
        }