#W# Added House limit to Settings.cs. Statichouses can now be odd shapes the statichouse.cfg can take more that 1 set of xy coords.
This commit is contained in:
parent
dc5e0577fd
commit
eea0f9defb
8 changed files with 246 additions and 80 deletions
|
|
@ -3,19 +3,20 @@ using Server;
|
|||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Custom.StaticHousing
|
||||
{
|
||||
public class StaticHouseSign : Item
|
||||
{
|
||||
private Rectangle2D m_HouseArea;
|
||||
private Rectangle2D[] m_HouseAreas;
|
||||
private int m_MinZ;
|
||||
private int m_MaxZ;
|
||||
private int m_Price;
|
||||
private int m_CustomLockdowns;
|
||||
private int m_CustomSecures;
|
||||
|
||||
public Rectangle2D HouseArea { get { return m_HouseArea; } }
|
||||
public Rectangle2D[] HouseAreas { get { return m_HouseAreas; } }
|
||||
public int MinZ { get { return m_MinZ; } }
|
||||
public int MaxZ { get { return m_MaxZ; } }
|
||||
public int Price { get { return m_Price; } }
|
||||
|
|
@ -23,12 +24,12 @@ namespace Server.Custom.StaticHousing
|
|||
public int CustomSecures { get { return m_CustomSecures; } }
|
||||
|
||||
[Constructable]
|
||||
public StaticHouseSign(int itemID, Rectangle2D area, int minZ, int maxZ, int price, int locks, int secures) : base(itemID)
|
||||
public StaticHouseSign(int itemID, Rectangle2D[] areas, int minZ, int maxZ, int price, int locks, int secures) : base(itemID)
|
||||
{
|
||||
Name = "A Vacant House For Sale";
|
||||
Movable = false;
|
||||
|
||||
m_HouseArea = area;
|
||||
m_HouseAreas = areas;
|
||||
m_MinZ = minZ;
|
||||
m_MaxZ = maxZ;
|
||||
m_Price = price;
|
||||
|
|
@ -48,16 +49,36 @@ namespace Server.Custom.StaticHousing
|
|||
list.Add(1060660, "Secures\t{0}", m_CustomSecures);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
/*public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);
|
||||
return;
|
||||
}
|
||||
|
||||
if (from is PlayerMobile)
|
||||
{
|
||||
from.SendGump(new StaticPurchaseGump((PlayerMobile)from, this));
|
||||
}
|
||||
}*/
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);
|
||||
return;
|
||||
}
|
||||
|
||||
if (from is PlayerMobile)
|
||||
{
|
||||
if (BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
from.SendMessage(33, "You already own the maximum number of houses allowed on this account.");
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendGump(new StaticPurchaseGump((PlayerMobile)from, this));
|
||||
}
|
||||
}
|
||||
|
|
@ -68,19 +89,38 @@ namespace Server.Custom.StaticHousing
|
|||
|
||||
if (Banker.Withdraw(pm, m_Price))
|
||||
{
|
||||
StaticHouse newHouse = new StaticHouse(pm, m_HouseArea, m_MinZ, m_MaxZ, m_CustomLockdowns, m_CustomSecures, m_Price);
|
||||
StaticHouse newHouse = new StaticHouse(pm, m_HouseAreas, m_MinZ, m_MaxZ, m_CustomLockdowns, m_CustomSecures, m_Price);
|
||||
|
||||
Point3D houseLoc = new Point3D(m_HouseArea.Start.X, m_HouseArea.Start.Y, m_MinZ);
|
||||
// 1. Move the house controller to the exact top-left corner of the property
|
||||
int minX = m_HouseAreas[0].Start.X;
|
||||
int minY = m_HouseAreas[0].Start.Y;
|
||||
foreach (Rectangle2D rect in m_HouseAreas)
|
||||
{
|
||||
if (rect.Start.X < minX) minX = rect.Start.X;
|
||||
if (rect.Start.Y < minY) minY = rect.Start.Y;
|
||||
}
|
||||
|
||||
Point3D houseLoc = new Point3D(minX, minY, m_MinZ);
|
||||
newHouse.MoveToWorld(houseLoc, this.Map);
|
||||
|
||||
// 2. Snap the brass House Sign back and match the orientation
|
||||
if (newHouse.Sign != null)
|
||||
{
|
||||
newHouse.Sign.Location = this.Location;
|
||||
|
||||
if (this.ItemID == 0xC0B)
|
||||
newHouse.Sign.ItemID = 0xBD1; // East Facing
|
||||
else
|
||||
newHouse.Sign.ItemID = 0xBD2; // North Facing
|
||||
}
|
||||
|
||||
// 3. Set the eviction drop point 1 step south of the sign
|
||||
newHouse.BanLocation = new Point3D(this.X, this.Y + 1, this.Z);
|
||||
|
||||
pm.PlaySound(0x249);
|
||||
pm.SendMessage(68, $"You have purchased this home for {m_Price} gold.");
|
||||
|
||||
// Destroy the "For Sale" sign now that the real house sign has spawned!
|
||||
this.Delete();
|
||||
}
|
||||
else
|
||||
|
|
@ -92,8 +132,12 @@ namespace Server.Custom.StaticHousing
|
|||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0);
|
||||
writer.Write(m_HouseArea);
|
||||
writer.Write((int)1); // Version bumped to 1 to support arrays!
|
||||
|
||||
writer.Write(m_HouseAreas.Length);
|
||||
for (int i = 0; i < m_HouseAreas.Length; i++)
|
||||
writer.Write(m_HouseAreas[i]);
|
||||
|
||||
writer.Write(m_MinZ);
|
||||
writer.Write(m_MaxZ);
|
||||
writer.Write(m_Price);
|
||||
|
|
@ -105,7 +149,20 @@ namespace Server.Custom.StaticHousing
|
|||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
m_HouseArea = reader.ReadRect2D();
|
||||
|
||||
if (version >= 1)
|
||||
{
|
||||
int count = reader.ReadInt();
|
||||
m_HouseAreas = new Rectangle2D[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
m_HouseAreas[i] = reader.ReadRect2D();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Backwards compatibility for the original houses
|
||||
m_HouseAreas = new Rectangle2D[] { reader.ReadRect2D() };
|
||||
}
|
||||
|
||||
m_MinZ = reader.ReadInt();
|
||||
m_MaxZ = reader.ReadInt();
|
||||
m_Price = reader.ReadInt();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue