#W# Inn rooms are limited to 1. Also tweaked the weather some.
This commit is contained in:
parent
770b95bb64
commit
72562f1970
4 changed files with 34 additions and 30 deletions
|
|
@ -1,2 +1,3 @@
|
|||
#Bastion Inn
|
||||
Vaelen 835 666 0 Vaelen 7147 4075 0 1779
|
||||
#Vaelen 835 661 0 Vaelen 7151 4063 0 1775
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ namespace Server.Custom.InnRooms
|
|||
private Point3D m_RoomLocation;
|
||||
private Map m_RoomMap;
|
||||
|
||||
// --- NEW VARIABLES ---
|
||||
private bool m_AutoRenew;
|
||||
private int m_RentCost = 5000;
|
||||
private TimeSpan m_RentDuration = TimeSpan.FromDays(7);
|
||||
|
||||
// --- PUBLIC PROPERTIES EXPOSED FOR THE GUMP ---
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool AutoRenew { get { return m_AutoRenew; } set { m_AutoRenew = value; } }
|
||||
|
||||
|
|
@ -59,6 +57,24 @@ namespace Server.Custom.InnRooms
|
|||
{
|
||||
}
|
||||
|
||||
public static bool HasAccountInnRoom(Mobile m)
|
||||
{
|
||||
if (m == null || m.Account == null)
|
||||
return false;
|
||||
|
||||
foreach (Item item in World.Items.Values)
|
||||
{
|
||||
if (item is InnDoor)
|
||||
{
|
||||
InnDoor door = (InnDoor)item;
|
||||
|
||||
if (door.Renter != null && door.Renter.Account == m.Account)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
|
|
@ -67,7 +83,6 @@ namespace Server.Custom.InnRooms
|
|||
return;
|
||||
}
|
||||
|
||||
// SCENARIO A: The room is VACANT
|
||||
if (m_Renter == null)
|
||||
{
|
||||
if (RoomLocation == Point3D.Zero || RoomMap == null)
|
||||
|
|
@ -75,13 +90,16 @@ namespace Server.Custom.InnRooms
|
|||
from.SendMessage(33, "This door is out of order (No Room Linked).");
|
||||
return;
|
||||
}
|
||||
|
||||
// Swapped to Banker.Withdraw to support AccountGold out of the gate
|
||||
if (HasAccountInnRoom(from))
|
||||
{
|
||||
from.SendMessage(33, "You already have an active inn room rental on this account.");
|
||||
return;
|
||||
}
|
||||
if (Banker.Withdraw(from, m_RentCost))
|
||||
{
|
||||
m_Renter = from;
|
||||
m_RentExpires = DateTime.UtcNow + m_RentDuration;
|
||||
m_AutoRenew = true; // Automatically turn it on for new renters!
|
||||
m_AutoRenew = true;
|
||||
Name = from.Name + "'s Inn Room";
|
||||
|
||||
m_House = new InnRoomHouse(from);
|
||||
|
|
@ -97,19 +115,15 @@ namespace Server.Custom.InnRooms
|
|||
from.SendMessage(33, $"You need {m_RentCost} gold in your bank to rent this room.");
|
||||
}
|
||||
}
|
||||
// SCENARIO B: The room is RENTED
|
||||
else
|
||||
{
|
||||
// Check if the rent has expired
|
||||
if (DateTime.UtcNow > m_RentExpires)
|
||||
{
|
||||
// MAGIC AUTO-RENEW CHECK
|
||||
if (m_AutoRenew && m_Renter != null && Banker.Withdraw(m_Renter, m_RentCost))
|
||||
{
|
||||
m_RentExpires += m_RentDuration;
|
||||
InvalidateProperties();
|
||||
|
||||
// Let them know it silently renewed behind the scenes
|
||||
if (from == m_Renter)
|
||||
from.SendMessage(68, $"Your auto-renew just processed {m_RentCost} gold from your bank!");
|
||||
}
|
||||
|
|
@ -136,7 +150,6 @@ namespace Server.Custom.InnRooms
|
|||
{
|
||||
Point3D dest = RoomLocation;
|
||||
|
||||
// Scans the void room (up to 12 tiles away from center) to find your physical exit door
|
||||
if (RoomMap != null)
|
||||
{
|
||||
IPooledEnumerable eable = RoomMap.GetItemsInRange(RoomLocation, 12);
|
||||
|
|
@ -144,14 +157,13 @@ namespace Server.Custom.InnRooms
|
|||
{
|
||||
if (item is InnExitDoor)
|
||||
{
|
||||
dest = item.Location; // Teleports them exactly where you placed the exit!
|
||||
dest = item.Location;
|
||||
break;
|
||||
}
|
||||
}
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
// Save their exact spot in the tavern so the exit door knows where to return them
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)m;
|
||||
|
|
@ -212,14 +224,12 @@ namespace Server.Custom.InnRooms
|
|||
}
|
||||
|
||||
m_House.Delete();
|
||||
// Kick anyone currently inside the room back to the tavern door
|
||||
List<Mobile> insideMobiles = m_House.GetMobiles();
|
||||
foreach (Mobile m in insideMobiles)
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)m;
|
||||
// Send them right back to this physical InnDoor in the town
|
||||
pm.MoveToWorld(this.Location, this.Map);
|
||||
pm.LastInnLocation = Point3D.Zero;
|
||||
pm.LastInnMap = null;
|
||||
|
|
@ -252,7 +262,6 @@ namespace Server.Custom.InnRooms
|
|||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
// Bumped to version 1 to safely save the AutoRenew toggle!
|
||||
writer.Write((int)1);
|
||||
|
||||
writer.Write(m_AutoRenew);
|
||||
|
|
@ -281,14 +290,12 @@ namespace Server.Custom.InnRooms
|
|||
m_RoomMap = reader.ReadMap();
|
||||
}
|
||||
|
||||
// --- NEW CONTEXT MENU FOR THE GUMP ---
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (from.Alive && m_Renter == from)
|
||||
{
|
||||
// Cliloc 1063490 is "Manage"
|
||||
list.Add(new ManageRoomEntry(from, this));
|
||||
}
|
||||
}
|
||||
|
|
@ -313,7 +320,6 @@ namespace Server.Custom.InnRooms
|
|||
}
|
||||
}
|
||||
|
||||
// --- BONUS: DRAG AND DROP RENEWAL ---
|
||||
public override bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
if (from == m_Renter && dropped is Gold)
|
||||
|
|
|
|||
|
|
@ -23,14 +23,9 @@ namespace Server.Misc
|
|||
*/
|
||||
|
||||
// ice island
|
||||
AddWeather( -15, 100, 5, new Rectangle2D( 1479, 47, 865, 319 ) );
|
||||
|
||||
// covetous entrance, around vesper and minoc
|
||||
//AddWeather( +15, 50, 5, new Rectangle2D( 2425, 725, 250, 250 ) );
|
||||
|
||||
// despise entrance, north of britain
|
||||
//AddWeather( +15, 50, 5, new Rectangle2D( 1245, 1045, 250, 250 ) );
|
||||
|
||||
AddWeather( -15, 75, 10, new Rectangle2D( 1479, 47, 865, 319 ) );
|
||||
// desert island
|
||||
AddWeather( +15, 0, 5, new Rectangle2D(791, 1619, 140, 64 ) );
|
||||
|
||||
/* Dynamic weather:
|
||||
*
|
||||
|
|
@ -39,7 +34,7 @@ namespace Server.Misc
|
|||
*/
|
||||
|
||||
for ( int i = 0; i < 15; ++i )
|
||||
AddDynamicWeather( +15, 100, 5, 8, 400, 400, new Rectangle2D( 0, 0, 2344, 1991 ) );
|
||||
AddDynamicWeather( +15, 25, 5, 8, 400, 400, new Rectangle2D( 0, 0, 2344, 1991 ) );
|
||||
}
|
||||
|
||||
public static List<Weather> GetWeatherList( Map facet )
|
||||
|
|
|
|||
|
|
@ -3297,8 +3297,10 @@ namespace Server.Multis
|
|||
{
|
||||
for ( int j = 0; j < list.Count; ++j )
|
||||
{
|
||||
if ( !list[j].Deleted )
|
||||
count++;
|
||||
BaseHouse h = list[j];
|
||||
|
||||
if ( !h.Deleted && !(h is Server.Custom.InnRooms.InnRoomHouse) )
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue