public override bool OnMoveInto(Mobile from, Direction d, Point3D newLocation, Point3D oldLocation) { if (!base.OnMoveInto(from, d, newLocation, oldLocation)) { return(false); } if (from is BaseCreature && ((BaseCreature)from).NoHouseRestrictions) { } else if (from is BaseCreature && ((BaseCreature)from).IsHouseSummonable && (BaseCreature.Summoning || m_House.IsInside(oldLocation, 16))) { } else if ((m_House.Public || !m_House.IsAosRules) && m_House.IsBanned(from) && m_House.IsInside(newLocation, 16)) { from.Location = m_House.BanLocation; if (!Core.SE) { from.SendLocalizedMessage(501284); // You may not enter. } return(false); } //else if ( m_House.IsAosRules && !m_House.Public && !m_House.HasAccess( from ) && m_House.IsInside( newLocation, 16 ) ) else if (m_House.IsAosRules && !m_House.Public && m_House.IsBanned(from) && m_House.IsInside(newLocation, 16)) { if (!Core.SE) { from.SendLocalizedMessage(501284); // You may not enter. } return(false); } else if (m_House.IsCombatRestricted(from) && !m_House.IsInside(oldLocation, 16) && m_House.IsInside(newLocation, 16)) { from.SendLocalizedMessage(1061637); // You are not allowed to access this. return(false); } else if (m_House is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)m_House; if (foundation.Customizer != null && foundation.Customizer != from && m_House.IsInside(newLocation, 16)) { return(false); } } if (m_House.InternalizedVendors.Count > 0 && m_House.IsInside(from) && !m_House.IsInside(oldLocation, 16) && m_House.IsOwner(from) && from.Alive && !from.HasGump(typeof(NoticeGump))) { /* This house has been customized recently, and vendors that work out of this * house have been temporarily relocated. You must now put your vendors back to work. * To do this, walk to a location inside the house where you wish to station * your vendor, then activate the context-sensitive menu on your avatar and * select "Get Vendor". */ from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null)); } return(true); }
private void ExtractCustomMulti(HouseFoundation house) { _extractedMultiIds.Add(house.Serial.Value); for (int x = 0; x < house.Components.Width; ++x) { for (int y = 0; y < house.Components.Height; ++y) { Tile[] tiles = house.Components.Tiles[x][y]; for (int i = 0; i < tiles.Length; ++i) { DesignItem designItem = new DesignItem(); designItem.ItemID = (short)(tiles[i].ID ^ 0x4000); designItem.X = x + house.Sign.Location.X; designItem.Y = (y + house.Sign.Location.Y) - (house.Components.Height - 1); designItem.Z = house.Location.Z + tiles[i].Z; _items.Add(designItem); } } } DesignItem sign = new DesignItem(); sign.ItemID = (short)(house.Sign.ItemID); sign.X = house.Sign.Location.X; sign.Y = house.Sign.Location.Y; sign.Z = house.Sign.Location.Z; _items.Add(sign); }
public static DesignInsertResult ProcessInsert(Item item, bool staticsOnly, out HouseFoundation house) { house = null; if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static)) { return(DesignInsertResult.InvalidItem); } house = BaseHouse.FindHouseAt(item) as HouseFoundation; if (house == null) { return(DesignInsertResult.NotInHouse); } int x = item.X - house.X; int y = item.Y - house.Y; int z = item.Z - house.Z; if (!TryInsertIntoState(house.CurrentState, item.ItemID, x, y, z)) { return(DesignInsertResult.OutsideHouseBounds); } TryInsertIntoState(house.DesignState, item.ItemID, x, y, z); item.Delete(); return(DesignInsertResult.Valid); }
public override bool OnMoveInto(Mobile from, Direction d, Point3D newLocation, Point3D oldLocation) { if (from is BaseCreature && ((BaseCreature)from).NoHouseRestrictions) { } else if (from is BaseCreature && ((BaseCreature)from).IsHouseSummonable && (BaseCreature.Summoning || m_House.IsInside(oldLocation, 16))) { } else if ((m_House.Public || !m_House.IsAosRules) && m_House.IsBanned(from) && m_House.IsInside(newLocation, 16)) { from.Location = m_House.BanLocation; from.SendLocalizedMessage(501284); // You may not enter. return(false); } //Adam: no AOS rules here /*else if ( m_House.IsAosRules && !m_House.Public && !m_House.HasAccess( from ) && m_House.IsInside( newLocation, 16 ) ) * { * from.SendLocalizedMessage( 501284 ); // You may not enter. * return false; * }*/ else if (m_House is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)m_House; if (foundation.Customizer != null && foundation.Customizer != from && m_House.IsInside(newLocation, 16) && from.AccessLevel < AccessLevel.GameMaster) { return(false); } } return(true); }
// Use OnLocationChanged instead of OnEnter because it can be that we enter a house region even though we're not actually inside the house public override void OnLocationChanged(Mobile m, Point3D oldLocation) { if (m_Recursion) { return; } base.OnLocationChanged(m, oldLocation); m_Recursion = true; if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions) { } else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && !(BaseCreature.Summoning || m_House.IsInside(oldLocation, 16))) { } //else if ( (m_House.Public || !m_House.IsAosRules) && m_House.IsBanned( m ) && m_House.IsInside( m ) ) //{ // m.Location = m_House.BanLocation; // if( !Core.SE ) // m.SendLocalizedMessage( 501284 ); // You may not enter. //} //else if ( m_House.IsAosRules && !m_House.Public && !m_House.HasAccess( m ) && m_House.IsInside( m ) ) //{ // m.Location = m_House.BanLocation; // if( !Core.SE ) // m.SendLocalizedMessage( 501284 ); // You may not enter. //} else if (m_House.IsCombatRestricted(m) && m_House.IsInside(m) && !m_House.IsInside(oldLocation, 16)) { m.Location = m_House.BanLocation; m.SendLocalizedMessage(1061637); // You are not allowed to access this. } else if (m_House is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)m_House; if (foundation.Customizer != null && foundation.Customizer != m && m_House.IsInside(m)) { m.Location = m_House.BanLocation; } } if (m_House.InternalizedVendors.Count > 0 && m_House.IsInside(m) && !m_House.IsInside(oldLocation, 16) && m_House.IsOwner(m) && m.Alive && !m.HasGump(typeof(NoticeGump))) { /* This house has been customized recently, and vendors that work out of this * house have been temporarily relocated. You must now put your vendors back to work. * To do this, walk to a location inside the house where you wish to station * your vendor, then activate the context-sensitive menu on your avatar and * select "Get Vendor". */ m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null)); } m_Recursion = false; }
public SmallFarm(Mobile owner, int id) : base(owner, id, 125, 2) { uint keyValue = CreateKeys(owner); AddSouthDoors(0, 3, 7, true); MultiComponentList mcl = MultiData.GetComponents(id); if (id >= 0x13EC && id < 0x1D00) { HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs } // AddSouthDoor(0, 3, 7, keyValue); // SetSign(2, 4, 5); }
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) { // controller control if (m_Controller.CannotEnter && !this.Contains(oldLocation)) { m.SendMessage("You cannot enter this area."); return(false); } // HousingRegion control if (m_Controller.IsHouseRegion) { BaseHouse house = BaseHouse.FindHouseAt(m); if (house != null) { if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions) { } else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && (BaseCreature.Summoning || house.IsInside(oldLocation, 16))) { } else if ((house.Public || !house.IsAosRules) && house.IsBanned(m) && house.IsInside(newLocation, 16)) { m.Location = house.BanLocation; m.SendLocalizedMessage(501284); // You may not enter. return(false); } //Adam: no AOS rules here /*else if ( house.IsAosRules && !house.Public && !house.HasAccess( from ) && house.IsInside( newLocation, 16 ) ) * { * from.SendLocalizedMessage( 501284 ); // You may not enter. * return false; * }*/ else if (house is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)house; if (foundation.Customizer != null && foundation.Customizer != m && house.IsInside(newLocation, 16) && m.AccessLevel < AccessLevel.GameMaster) { return(false); } } } } return(true); }
// Use OnLocationChanged instead of OnEnter because it can be that we enter a house region even though we're not actually inside the house public override void OnLocationChanged(Mobile m, Point3D oldLocation) { if (m_Controller.IsHouseRegion) { BaseHouse house = BaseHouse.FindHouseAt(m); if (house != null) { if (m_Recursion) { return; } m_Recursion = true; if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions) { } else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && (BaseCreature.Summoning || house.IsInside(oldLocation, 16))) { } else if ((house.Public || !house.IsAosRules) && house.IsBanned(m) && house.IsInside(m)) { m.Location = house.BanLocation; m.SendLocalizedMessage(501284); // You may not enter. } //Adam: no AOS rules here /*else if ( house.IsAosRules && !house.Public && !house.HasAccess( m ) && house.IsInside( m ) ) * { * m.Location = house.BanLocation; * m.SendLocalizedMessage( 501284 ); // You may not enter. * }*/ else if (house is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)house; if (foundation.Customizer != null && foundation.Customizer != m && house.IsInside(m) && m.AccessLevel < AccessLevel.GameMaster) { m.Location = house.BanLocation; } } m_Recursion = false; } } }
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 || 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)) || reg.IsPartOf(typeof(HouseRegion))) { 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; } 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); }
private void ExtractItems() { foreach (Rect2D rect in _rects) { for (int x = 0; x <= rect.Width; ++x) { for (int y = 0; y <= rect.Height; ++y) { int tileX = rect.TopX + x; int tileY = rect.TopY + y; Sector sector = _map.GetSector(tileX, tileY); if (_args.NonStatic || _args.Static) { for (int i = 0; i < sector.Items.Count; ++i) { Item item = (Item)sector.Items[i]; if (!item.Visible) { continue; } else if ((!_args.NonStatic) && !(item is Static)) { continue; } else if ((!_args.Static) && (item is Static)) { continue; } else if (_args.MinZSet && item.Z < _args.MinZ) { continue; } else if (_args.MaxZSet && item.Z > _args.MaxZ) { continue; } int hue = 0; if (_args.ExtractHues) { hue = item.Hue; } if (item.X == tileX && item.Y == tileY && !((item is BaseMulti) || (item is HouseSign))) { DesignItem designItem = new DesignItem(); designItem.ItemID = (short)item.ItemID; designItem.X = item.X; designItem.Y = item.Y; designItem.Z = item.Z; designItem.Hue = (short)hue; _items.Add(designItem); } // extract multi if (item is HouseFoundation) { HouseFoundation house = (HouseFoundation)item; if (_extractedMultiIds.IndexOf(house.Serial.Value) == -1) { ExtractCustomMulti(house); } } } } } } } ExtractResponse response = new ExtractResponse(_items); if (_args.Frozen) { response.Rects = _rects; response.Map = _map.Name; } // send response back to the UOAR tool SendResponse(response); }
// Use OnLocationChanged instead of OnEnter because it can be that we enter a house region even though we're not actually inside the house public override void OnLocationChanged(Mobile m, Point3D oldLocation) { if (m_Recursion) { return; } base.OnLocationChanged(m, oldLocation); m_Recursion = true; if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions) { } else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && !(BaseCreature.Summoning || m_House.IsInside(oldLocation, 16))) { } else if (m_House.Public && m_House.IsBanned(m) && m_House.IsInside(m)) { m.Location = m_House.BanLocation; } else if (!m_House.Public && !m_House.HasAccess(m) && m_House.IsInside(m)) { m.Location = m_House.BanLocation; } else if (m_House.IsCombatRestricted(m) && m_House.IsInside(m) && !m_House.IsInside(oldLocation, 16)) { m.Location = m_House.BanLocation; m.SendLocalizedMessage(1061637); // You are not allowed to access this. } else if (m_House is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)m_House; if (foundation.Customizer != null && foundation.Customizer != m && m_House.IsInside(m)) { m.Location = m_House.BanLocation; } } // Añadido para Antihousing if (m_House.IsInside(m) && CheckCombat(m, TimeSpan.FromMinutes(2.0))) { for (int i = 0; i < m.Aggressors.Count; i++) { bool found = false; AggressorInfo info = (AggressorInfo)m.Aggressors[i]; Mobile aggressor = info.Attacker; for (int j = 0; j < m.Aggressed.Count; j++) { AggressorInfo info2 = (AggressorInfo)m.Aggressed[j]; Mobile aggressed = info2.Attacker; if (aggressed == m) { found = true; } } if (!found) { m.Aggressed.Add(AggressorInfo.Create(m, aggressor, !m.Criminal)); } } } if (m_House.InternalizedVendors.Count > 0 && m_House.IsInside(m) && !m_House.IsInside(oldLocation, 16) && m_House.IsOwner(m) && m.Alive && !m.HasGump(typeof(NoticeGump))) { /* This house has been customized recently, and vendors that work out of this * house have been temporarily relocated. You must now put your vendors back to work. * To do this, walk to a location inside the house where you wish to station * your vendor, then activate the context-sensitive menu on your avatar and * select "Get Vendor". */ m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null)); } m_Recursion = false; }
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); }
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) { if (IsAngelIslandRules) { // If someone attempting to enter the region is not an Inmate, we deny them entry. // The only way in is via the teleporter, which sets the Inmate flag true. if (m.Player) { if (!((PlayerMobile)m).Inmate && m.AccessLevel == AccessLevel.Player) { return(false); } } return(true); } // HousingRegion control if (IsHouseRules) { BaseHouse house = BaseHouse.FindHouseAt(m); if (house != null) { if (m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions) { } else if (m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && (BaseCreature.Summoning || house.IsInside(oldLocation, 16))) { } else if ((house.Public || !house.IsAosRules) && house.IsBanned(m) && house.IsInside(newLocation, 16)) { m.Location = house.BanLocation; m.SendLocalizedMessage(501284); // You may not enter. return(false); } //Adam: no AOS rules here /*else if ( house.IsAosRules && !house.Public && !house.HasAccess( from ) && house.IsInside( newLocation, 16 ) ) * { * from.SendLocalizedMessage( 501284 ); // You may not enter. * return false; * }*/ else if (house is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)house; if (foundation.Customizer != null && foundation.Customizer != m && house.IsInside(newLocation, 16) && m.AccessLevel < AccessLevel.GameMaster) { return(false); } } } } // controller control if (m_Controller.CannotEnter && !this.Contains(oldLocation)) { m.SendMessage("You cannot enter this area."); return(false); } return(true); }
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; * } * }*/ }
public override bool OnMoveInto(Mobile from, Direction d, Point3D newLocation, Point3D oldLocation) { if (!base.OnMoveInto(from, d, newLocation, oldLocation)) { return(false); } if (from is BaseCreature && ((BaseCreature)from).NoHouseRestrictions) { } /*RedemptionUO Start * else if (from is BaseCreature && !((BaseCreature)from).Controlled) // Untamed creatures cannot enter public houses * { * return false; * } * RedemptionUO End*/ else if (from is BaseCreature && ((BaseCreature)from).IsHouseSummonable && !(BaseCreature.Summoning || House.IsInside(oldLocation, 16))) { /*RedemptionUO Start * return false; * } * else if (from is BaseCreature && !((BaseCreature)from).Controlled && House.IsAosRules && !House.Public) * { * return false; * RedemptionUO End*/ } else if ((House != null) && House.IsBanned(from) && House.IsInside(newLocation, 16)) { from.Location = House.BanLocation; return(false); } /*RedemptionUO Start * else if (!House.Public && !House.HasAccess(from) && House.IsInside(newLocation, 16)) * { * return false; * } * else if (House.IsCombatRestricted(from) && !House.IsInside(oldLocation, 16) && House.IsInside(newLocation, 16)) * { * from.SendLocalizedMessage(1061637); // You are not allowed to access * return false; * } * RedemptionUO End*/ else if (House is HouseFoundation) { HouseFoundation foundation = (HouseFoundation)House; if (foundation.Customizer != null && foundation.Customizer != from && House.IsInside(newLocation, 16)) { return(false); } } if (House.InternalizedVendors.Count > 0 && House.IsInside(from) && !House.IsInside(oldLocation, 16) && House.IsOwner(from) && from.Alive && !from.HasGump(typeof(NoticeGump))) { /* This house has been customized recently, and vendors that work out of this * house have been temporarily relocated. You must now put your vendors back to work. * To do this, walk to a location inside the house where you wish to station * your vendor, then activate the context-sensitive menu on your avatar and * select "Get Vendor". */ from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180, null, null)); } House.AddVisit(from); return(true); }
public override bool OnMoveInto(Mobile from, Direction d, Point3D newLocation, Point3D oldLocation) { if (!base.OnMoveInto(from, d, newLocation, oldLocation)) { return(false); } BaseCreature bc = from as BaseCreature; if (bc?.NoHouseRestrictions == true) { } else if (bc?.Controlled == false) // Untamed creatures cannot enter public houses { return(false); } else if (bc?.IsHouseSummonable == true && !(BaseCreature.Summoning || House.IsInside(oldLocation, 16))) { return(false); } else if (bc?.Controlled == false && House.IsAosRules && !House.Public) { return(false); } else if ((House.Public || !House.IsAosRules) && House.IsBanned(from) && House.IsInside(newLocation, 16)) { from.Location = House.BanLocation; if (!Core.SE) { from.SendLocalizedMessage(501284); // You may not enter. } return(false); } else if (House.IsAosRules && !House.Public && !House.HasAccess(from) && House.IsInside(newLocation, 16)) { if (!Core.SE) { from.SendLocalizedMessage(501284); // You may not enter. } return(false); } else if (House.IsCombatRestricted(from) && !House.IsInside(oldLocation, 16) && House.IsInside(newLocation, 16)) { from.SendLocalizedMessage(1061637); // You are not allowed to access this. return(false); } else { HouseFoundation foundation = House as HouseFoundation; if (foundation?.Customizer != null && foundation.Customizer != from && House.IsInside(newLocation, 16)) { return(false); } } if (House.InternalizedVendors.Count > 0 && House.IsInside(from) && !House.IsInside(oldLocation, 16) && House.IsOwner(from) && from.Alive && !from.HasGump <NoticeGump>()) { from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); } return(true); }
// Use OnLocationChanged instead of OnEnter because it can be that we enter a house region even though we're not actually inside the house public override void OnLocationChanged(Mobile m, Point3D oldLocation) { if (m_Recursion) { return; } base.OnLocationChanged(m, oldLocation); m_Recursion = true; BaseCreature bc = m as BaseCreature; if (bc?.NoHouseRestrictions == true) { } else if (bc?.IsHouseSummonable == true && !(BaseCreature.Summoning || House.IsInside(oldLocation, 16))) { } else if ((House.Public || !House.IsAosRules) && House.IsBanned(m) && House.IsInside(m)) { m.Location = House.BanLocation; if (!Core.SE) { m.SendLocalizedMessage(501284); // You may not enter. } } else if (House.IsAosRules && !House.Public && !House.HasAccess(m) && House.IsInside(m)) { m.Location = House.BanLocation; if (!Core.SE) { m.SendLocalizedMessage(501284); // You may not enter. } } else if (House.IsCombatRestricted(m) && House.IsInside(m) && !House.IsInside(oldLocation, 16)) { m.Location = House.BanLocation; m.SendLocalizedMessage(1061637); // You are not allowed to access this. } else { HouseFoundation foundation = House as HouseFoundation; if (foundation?.Customizer != null && foundation.Customizer != m && House.IsInside(m)) { m.Location = House.BanLocation; } } if (House.InternalizedVendors.Count > 0 && House.IsInside(m) && !House.IsInside(oldLocation, 16) && House.IsOwner(m) && m.Alive && !m.HasGump <NoticeGump>()) { m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); } m_Recursion = false; }
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 } NoHousingRegion noHousingRegion = Region.Find(center, map) as 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 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); Region reg = Region.Find(testPoint, map); if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc { if (reg is TreasureRegion) { return(HousePlacementResult.BadRegionHidden); } return(HousePlacementResult.BadRegion); } 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(); for (int i = 0; i < sector.Items.Count; ++i) { Item 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 = (Mobile)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) { 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]) { 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]) { 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); ArrayList sectorItems = sector.Items; for (int j = 0; j < sectorItems.Count; ++j) { Item 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 } } } 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; * } * }*/ }