#W# InnExitDoor and go locations.

This commit is contained in:
WarrentyExpired 2026-08-23 15:22:22 -04:00
parent 66c963c885
commit aa8e3e15d8
5 changed files with 170 additions and 257 deletions

View file

@ -134,8 +134,33 @@ namespace Server.Custom.InnRooms
private void TeleportToRoom(Mobile m)
{
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);
foreach (Item item in eable)
{
if (item is InnExitDoor)
{
dest = item.Location; // Teleports them exactly where you placed the exit!
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;
pm.LastInnLocation = m.Location;
pm.LastInnMap = m.Map;
}
m.PlaySound(0x1EA);
m.MoveToWorld(RoomLocation, RoomMap);
m.MoveToWorld(dest, RoomMap);
m.SendMessage(0x3B2, "You enter the inn room.");
}
@ -187,6 +212,20 @@ 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;
pm.SendMessage(33, "The rent has expired and you have been evicted from the room.");
}
}
}
m_Renter = null;

View file

@ -0,0 +1,58 @@
using System;
using Server;
using Server.Mobiles;
namespace Server.Custom.InnRooms
{
public class InnExitDoor : Item
{
[Constructable]
public InnExitDoor() : this(0x6E5)
{
}
[Constructable]
public InnExitDoor(int itemID) : base(itemID)
{
Movable = false;
Name = "Room Exit";
}
public InnExitDoor(Serial serial) : base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
{
from.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045);
return;
}
if (from is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)from;
// Checks if they entered through the town door to get their saved location
if (pm.LastInnMap != null && pm.LastInnMap != Map.Internal && pm.LastInnLocation != Point3D.Zero)
{
pm.PlaySound(0x1EA);
pm.MoveToWorld(pm.LastInnLocation, pm.LastInnMap);
pm.SendMessage(68, "You step out of your room and back into the inn.");
// Clears the return location so they can't exploit it
pm.LastInnLocation = Point3D.Zero;
pm.LastInnMap = null;
}
else
{
from.SendMessage(33, "Your return location was lost. Please use a runebook or page a GameMaster.");
}
}
}
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); }
}
}