public static int DecayAllTownshipWalls() { int deleted = 0; try { List <BaseFortificationWall> listcopy = new List <BaseFortificationWall>(); foreach (BaseFortificationWall wall in TownshipWallList) { listcopy.Add(wall); } foreach (BaseFortificationWall wall in listcopy) { wall.Hits -= TownshipSettings.WallHitsDecay; TownshipRegion tr = TownshipRegion.GetTownshipAt(wall.Location, wall.Map); if (tr == null || wall.Hits < 0) { deleted++; wall.Delete(); } } } catch (Exception e) { Server.Commands.LogHelper.LogException(e); } return(deleted); }
public static bool IsEnemyOfTownship(Mobile vendor, Mobile b) { if (b == null || vendor == null || !(b is PlayerMobile)) { return(true); } TownshipRegion tr = TownshipRegion.GetTownshipAt(vendor); if (tr != null) { if (tr.TStone != null) { return(tr.TStone.IsEnemy(b as PlayerMobile)); } } return(true); //if we can't find the township, don't interact with anyone }
public static bool IsTownshipNPCOwner(Mobile a, Mobile vendor) { if (a != null) { BaseHouse house = BaseHouse.FindHouseAt(vendor); if (house != null) { TownshipRegion tr = TownshipRegion.GetTownshipAt(vendor); if (tr != null && tr.TStone != null) { if (house.IsOwner(a) && a.Guild != null && tr.TStone.Guild != null && a.Guild == tr.TStone.Guild) { return(true); } } } } return(false); }
public override void OnDoubleClick(Mobile from) { BaseHouse house = BaseHouse.FindHouseAt(from); TownshipRegion tr = TownshipRegion.GetTownshipAt(from); if (house == null) { from.SendMessage("You must be in a house to place this vendor."); } else if (tr == null) { from.SendMessage("You must be in a township to place this vendor."); } else if (!house.IsCoOwner(from)) { from.SendMessage("You must be a coowner of the house to place this vendor."); } else if (!tr.CanBuildHouseInTownship(from)) { from.SendMessage("You must be a guildmate to place this vendor."); } else if (!tr.CanBuildHouseInTownship(house.Owner)) { from.SendMessage("The house must be owned by a guildmember to place this vendor."); } else if (!house.Public) { from.SendMessage("This vendor must be placed in a public house."); } else if (tr.TStone.Guild.Abbreviation != this.m_GuildAbbr) { from.SendMessage("This vendor must be placed in your guild's town."); } else { bool bCanPlace = true; int playervendorCount = 0; int tsnpcCount = 0; foreach (Mobile mx in house.Region.Mobiles.Values) { if (mx is PlayerVendor) { playervendorCount++; } Type type = mx.GetType(); TownshipNPCAttribute[] attributearray = (TownshipNPCAttribute[])type.GetCustomAttributes(typeof(TownshipNPCAttribute), false); if (attributearray.Length > 0) { tsnpcCount++; //it's a townshipNPC if (TownshipHelper.IsRestrictedTownshipNPC(mx)) { bCanPlace = false; } } } if ( (playervendorCount > 0 || tsnpcCount > 0) && (TownshipHelper.IsRestrictedTownshipNPCDeed(this)) ) { bCanPlace = false; } if (!bCanPlace) { from.SendMessage("You cannot place this vendor in a house with the other vendors that are present."); } else { //now check that the total TownshipNPC count is under what the house can hold. if (house.MaxSecures <= tsnpcCount) { from.SendMessage("You can't have any more Township NPCs in this house"); } else { if (this.Place(from)) { this.Delete(); } else { from.SendMessage("Placement failed"); } } } } }