From 8f44a3fe503010e03c58e9b9d281fdbf2f23b9fa Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Tue, 25 Aug 2026 13:16:08 -0400 Subject: [PATCH] #W# Inn room size and price now set in inndoors.cfg. --- .gitignore | 1 + Data/Config/inndoors.cfg | 9 +++ Data/Decoration/Towns/Bastion_Doors.cfg | 18 ----- Data/Decoration/Towns/InnExitDoors.cfg | 21 +++++- Data/Decoration/inndoors.cfg | 3 - Scripts/Commands/GenInnDoors.cs | 44 ++++++------ Scripts/Items/Houses/InnRooms/InnDoor.cs | 32 +++++++-- Scripts/Items/Houses/InnRooms/InnRoomHouse.cs | 70 +++++++++---------- 8 files changed, 114 insertions(+), 84 deletions(-) create mode 100644 Data/Config/inndoors.cfg delete mode 100644 Data/Decoration/inndoors.cfg diff --git a/.gitignore b/.gitignore index d88117c..56176bc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.user *.suo +*.bak /.idea /Backups /Saves diff --git a/Data/Config/inndoors.cfg b/Data/Config/inndoors.cfg new file mode 100644 index 0000000..ffefe82 --- /dev/null +++ b/Data/Config/inndoors.cfg @@ -0,0 +1,9 @@ +# TownMap DoorX Y Z RoomMap RoomX Y Z Price ItemID StartX StartY Width Height +#Vaelen 835 666 0 Vaelen 7157 4081 0 5000 1779 7152 4076 10 10 +Vaelen 835 666 0 Vaelen 7157 4081 0 2000 1779 7152 4079 5 6 +Vaelen 835 661 0 Vaelen 7154 4076 0 2000 1779 7152 4074 5 6 +Vaelen 835 656 0 Vaelen 7154 4071 0 2000 1779 7152 4069 5 6 +Vaelen 829 671 0 Vaelen 7146 4084 0 5000 1779 7143 4081 9 8 +Vaelen 836 666 20 Vaelen 7155 4013 20 2000 1779 7153 4011 5 6 +Vaelen 836 661 20 Vaelen 7155 4008 20 2000 1779 7153 4006 5 6 +Vaelen 836 656 20 Vaelen 7155 4003 20 2000 1779 7153 4001 5 6 diff --git a/Data/Decoration/Towns/Bastion_Doors.cfg b/Data/Decoration/Towns/Bastion_Doors.cfg index fcafcb2..52a2a77 100644 --- a/Data/Decoration/Towns/Bastion_Doors.cfg +++ b/Data/Decoration/Towns/Bastion_Doors.cfg @@ -36,24 +36,6 @@ DarkWoodDoor 1711 (Facing=NorthCW) StrongWoodDoor 1775 (Facing=NorthCW) 838 665 0 -DarkWoodDoor 1711 (Facing=NorthCW) -829 671 0 - -DarkWoodDoor 1711 (Facing=NorthCW) -835 661 0 - -DarkWoodDoor 1711 (Facing=NorthCW) -835 656 0 - -DarkWoodDoor 1711 (Facing=NorthCW) -836 666 20 - -DarkWoodDoor 1711 (Facing=NorthCW) -836 661 20 - -DarkWoodDoor 1711 (Facing=NorthCW) -836 656 20 - #Bowyer/Fletcher DarkWoodDoor 1711 (Facing=NorthCW) 824 658 0 diff --git a/Data/Decoration/Towns/InnExitDoors.cfg b/Data/Decoration/Towns/InnExitDoors.cfg index 4994ccc..45d0983 100644 --- a/Data/Decoration/Towns/InnExitDoors.cfg +++ b/Data/Decoration/Towns/InnExitDoors.cfg @@ -1,2 +1,21 @@ +# Bastion Inn InnExitDoor 1775 -7152 4075 0 +7157 4081 0 + +InnExitDoor 1775 +7157 4076 0 + +InnExitDoor 1775 +7157 4071 0 + +InnExitDoor 1775 +7151 4086 0 + +InnExitDoor 1775 +7159 4013 20 + +InnExitDoor 1775 +7159 4008 20 + +InnExitDoor 1775 +7159 4003 20 diff --git a/Data/Decoration/inndoors.cfg b/Data/Decoration/inndoors.cfg deleted file mode 100644 index ababd2d..0000000 --- a/Data/Decoration/inndoors.cfg +++ /dev/null @@ -1,3 +0,0 @@ -#Bastion Inn -Vaelen 835 666 0 Vaelen 7147 4075 0 1779 -#Vaelen 835 661 0 Vaelen 7151 4063 0 1775 diff --git a/Scripts/Commands/GenInnDoors.cs b/Scripts/Commands/GenInnDoors.cs index 8a47ebe..2c413fc 100644 --- a/Scripts/Commands/GenInnDoors.cs +++ b/Scripts/Commands/GenInnDoors.cs @@ -3,7 +3,7 @@ using System.IO; using System.Collections; using Server; using Server.Items; -using Server.Custom.InnRooms; // Ensure it can find our InnDoor! +using Server.Custom.InnRooms; namespace Server.Commands { @@ -30,7 +30,6 @@ namespace Server.Commands private int m_Count; private static Queue m_Queue = new Queue(); - // Finds and deletes existing InnDoors at the target location to prevent stacking public static bool FindExistingDoor(Map map, Point3D p) { IPooledEnumerable eable = map.GetItemsInRange(p, 0); @@ -41,7 +40,7 @@ namespace Server.Commands { int delta = item.Z - p.Z; - if (delta >= -12 && delta <= 12) // Uses your existing Z-delta logic + if (delta >= -12 && delta <= 12) m_Queue.Enqueue(item); } } @@ -54,16 +53,16 @@ namespace Server.Commands return false; } - public void CreateDoor(Point3D loc, Map mapLoc, Point3D roomLoc, Map roomMap, int itemID) + // --- ADDED RECTANGLE2D PARAMETER --- + public void CreateDoor(Point3D loc, Map mapLoc, Point3D roomLoc, Map roomMap, int rentCost, int itemID, Rectangle2D roomArea) { if (!FindExistingDoor(mapLoc, loc)) { m_Count++; - // Uses our new parameterized constructor for custom facings! - InnDoor door = new InnDoor(itemID); + // Passing the custom boundary into the door! + InnDoor door = new InnDoor(itemID, roomArea, rentCost); - // Wire up the void room coordinates automatically door.RoomLocation = roomLoc; door.RoomMap = roomMap; @@ -73,8 +72,7 @@ namespace Server.Commands public int CreateDoors() { - // Reads from the same Decoration directory[cite: 3] - string filePath = Path.Combine(Core.BaseDirectory, "Data", "Decoration", "inndoors.cfg"); + string filePath = Path.Combine(Core.BaseDirectory, "Data", "Config", "inndoors.cfg"); if (!File.Exists(filePath)) { @@ -94,8 +92,8 @@ namespace Server.Commands string[] split = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - // We need at least 8 arguments (Door Map/X/Y/Z and Room Map/X/Y/Z) - if (split.Length >= 8) + // --- EXPANDED TO 13 ARGUMENTS --- + if (split.Length >= 14) { try { @@ -108,21 +106,23 @@ namespace Server.Commands int xRoom = int.Parse(split[5]); int yRoom = int.Parse(split[6]); int zRoom = int.Parse(split[7]); - - // Optional 9th argument: ItemID for custom facings! Defaults to 0x6E5 (1765) if missing. + int rentCost = int.Parse(split[8]); int itemID = 1765; - if (split.Length >= 9) - { - // Handles both hex (0x6F3) and integer (1779) formats - if (split[8].StartsWith("0x", StringComparison.OrdinalIgnoreCase)) - itemID = Convert.ToInt32(split[8], 16); - else - itemID = int.Parse(split[8]); - } + if (split[8].StartsWith("0x", StringComparison.OrdinalIgnoreCase)) + itemID = Convert.ToInt32(split[9], 16); + else + itemID = int.Parse(split[9]); + + // Parsing the new custom boundaries + int startX = int.Parse(split[10]); + int startY = int.Parse(split[11]); + int width = int.Parse(split[12]); + int height = int.Parse(split[13]); + Rectangle2D roomArea = new Rectangle2D(startX, startY, width, height); if (mapLoc != null && mapRoom != null) { - CreateDoor(new Point3D(xLoc, yLoc, zLoc), mapLoc, new Point3D(xRoom, yRoom, zRoom), mapRoom, itemID); + CreateDoor(new Point3D(xLoc, yLoc, zLoc), mapLoc, new Point3D(xRoom, yRoom, zRoom), mapRoom, rentCost, itemID, roomArea); } } catch (Exception ex) diff --git a/Scripts/Items/Houses/InnRooms/InnDoor.cs b/Scripts/Items/Houses/InnRooms/InnDoor.cs index 1de5987..e809f87 100644 --- a/Scripts/Items/Houses/InnRooms/InnDoor.cs +++ b/Scripts/Items/Houses/InnRooms/InnDoor.cs @@ -17,9 +17,13 @@ namespace Server.Custom.InnRooms private Point3D m_RoomLocation; private Map m_RoomMap; - private bool m_AutoRenew; - private int m_RentCost = 5000; + private bool m_AutoRenew; private TimeSpan m_RentDuration = TimeSpan.FromDays(7); + private Rectangle2D m_RoomArea; + private int m_RentCost; + + [CommandProperty(AccessLevel.GameMaster)] + public Rectangle2D RoomArea { get { return m_RoomArea; } set { m_RoomArea = value; } } [CommandProperty(AccessLevel.GameMaster)] public bool AutoRenew { get { return m_AutoRenew; } set { m_AutoRenew = value; } } @@ -47,10 +51,12 @@ namespace Server.Custom.InnRooms } [Constructable] - public InnDoor(int itemID) : base(itemID) + public InnDoor(int itemID, Rectangle2D roomArea, int rentCost) : base(itemID) { Movable = false; Name = "A Vacant Inn Room"; + m_RoomArea = roomArea; + m_RentCost = rentCost; } public InnDoor(Serial serial) : base(serial) @@ -102,7 +108,7 @@ namespace Server.Custom.InnRooms m_AutoRenew = true; Name = from.Name + "'s Inn Room"; - m_House = new InnRoomHouse(from); + m_House = new InnRoomHouse(from, m_RoomArea); Point3D buriedLocation = new Point3D(RoomLocation.X, RoomLocation.Y, RoomLocation.Z - 20); m_House.MoveToWorld(buriedLocation, RoomMap); @@ -262,8 +268,11 @@ namespace Server.Custom.InnRooms public override void Serialize(GenericWriter writer) { base.Serialize(writer); - writer.Write((int)1); + writer.Write((int)3); + writer.Write(m_RentCost); + + writer.Write(m_RoomArea); writer.Write(m_AutoRenew); writer.Write(m_Renter); @@ -278,6 +287,19 @@ namespace Server.Custom.InnRooms base.Deserialize(reader); int version = reader.ReadInt(); + if (version >= 3) + { + m_RentCost = reader.ReadInt(); + } + else + { + m_RentCost = 5000; + } + + if (version >= 2) + { + m_RoomArea = reader.ReadRect2D(); + } if (version >= 1) { m_AutoRenew = reader.ReadBool(); diff --git a/Scripts/Items/Houses/InnRooms/InnRoomHouse.cs b/Scripts/Items/Houses/InnRooms/InnRoomHouse.cs index bb7851b..fbfa6af 100644 --- a/Scripts/Items/Houses/InnRooms/InnRoomHouse.cs +++ b/Scripts/Items/Houses/InnRooms/InnRoomHouse.cs @@ -6,9 +6,15 @@ namespace Server.Custom.InnRooms { public class InnRoomHouse : BaseHouse { + private Rectangle2D m_CustomArea; + + // Dynamically computes the relative coordinates for the core engine public override Rectangle2D[] Area { - get { return new Rectangle2D[] { new Rectangle2D(-5, -5, 10, 10) }; } + get + { + return new Rectangle2D[] { new Rectangle2D(m_CustomArea.Start.X - this.X, m_CustomArea.Start.Y - this.Y, m_CustomArea.Width, m_CustomArea.Height) }; + } } public override Point3D BaseBanLocation @@ -16,58 +22,37 @@ namespace Server.Custom.InnRooms get { return new Point3D(this.X, this.Y - 5, this.Z + 20); } } - // --- THE STORAGE FIXES --- - - // 1. Negate the 20% Mondain's Legacy bonus so they get exactly 250 items! public override double BonusStorageScalar { get { return 1.0; } } - // 2. Both base values are passed as 250 - public InnRoomHouse(Mobile owner) : base(0xA26, owner, 250, 250) + // Added the Rectangle2D area parameter to the constructor + public InnRoomHouse(Mobile owner, Rectangle2D area) : base(0xA26, owner, 250, 250) { RestrictDecay = true; - // Force the initial properties to 250 + m_CustomArea = area; + MaxLockDowns = 250; MaxSecures = 250; + + // Stretches the internal physical footprint to match your .cfg + Components.Resize(area.Width, area.Height); + Components.Add(0x520, area.Width - 1, area.Height - 1, -5); } public InnRoomHouse(Serial serial) : base(serial) { } - // The absolute maximum number of floor items - public override int GetAosMaxLockdowns() - { - return 250; - } - - // The absolute maximum number of total items (chests + floor items + inside chests) - public override int GetAosMaxSecures() - { - return 250; - } - - // ------------------------- + public override int GetAosMaxLockdowns() { return 250; } + public override int GetAosMaxSecures() { return 250; } public override bool IsInside(Point3D p, int height) { if (Deleted) return false; - int rx = p.X - this.X; - int ry = p.Y - this.Y; - - bool inArea = false; - foreach (Rectangle2D rect in Area) - { - if (rect.Contains(new Point2D(rx, ry))) - { - inArea = true; - break; - } - } - - if (!inArea) + // Absolute map bounds check ensures exact precision and stops bleeding! + if (!m_CustomArea.Contains(new Point2D(p.X, p.Y))) return false; if (p.Z >= this.Z && (p.Z + height) <= this.Z + 40) @@ -79,13 +64,28 @@ namespace Server.Custom.InnRooms public override void Serialize(GenericWriter writer) { base.Serialize(writer); - writer.Write((int)0); + writer.Write((int)1); // Version bumped to 1 + writer.Write(m_CustomArea); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); + + if (version >= 1) + { + m_CustomArea = reader.ReadRect2D(); + } + else + { + // Safety net for existing rooms using the old hardcoded offsets + m_CustomArea = new Rectangle2D(this.X - 5, this.Y - 5, 6, 5); + } + + // Restores the stretched footprint on server restart + Components.Resize(m_CustomArea.Width, m_CustomArea.Height); + Components.Add(0x520, m_CustomArea.Width - 1, m_CustomArea.Height - 1, -5); } } }