#W# InnExitDoor and go locations.
This commit is contained in:
parent
66c963c885
commit
aa8e3e15d8
5 changed files with 170 additions and 257 deletions
|
|
@ -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;
|
||||
|
|
|
|||
58
Scripts/Engines/InnRooms/InnExitDoor.cs
Normal file
58
Scripts/Engines/InnRooms/InnExitDoor.cs
Normal 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(); }
|
||||
}
|
||||
}
|
||||
|
|
@ -201,6 +201,11 @@ namespace Server.Mobiles
|
|||
private List<Mobile> m_AllFollowers;
|
||||
private List<Mobile> m_RecentlyReported;
|
||||
|
||||
// -- Inn Room Start
|
||||
private Point3D m_LastInnLocation;
|
||||
private Map m_LastInnMap;
|
||||
// -- Inn Room End
|
||||
|
||||
#region Getters & Setters
|
||||
|
||||
public List<Mobile> RecentlyReported
|
||||
|
|
@ -374,6 +379,22 @@ namespace Server.Mobiles
|
|||
set { CandyCane.SetToothAche( this, value ); }
|
||||
}
|
||||
|
||||
// -- Inn Room Start
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Point3D LastInnLocation
|
||||
{
|
||||
get { return m_LastInnLocation; }
|
||||
set { m_LastInnLocation = value; }
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Map LastInnMap
|
||||
{
|
||||
get { return m_LastInnMap; }
|
||||
set { m_LastInnMap = value; }
|
||||
}
|
||||
// -- Inn Room End
|
||||
|
||||
#endregion
|
||||
|
||||
#region PlayerFlags
|
||||
|
|
@ -3358,6 +3379,12 @@ namespace Server.Mobiles
|
|||
|
||||
switch ( version )
|
||||
{
|
||||
case 30:
|
||||
{
|
||||
m_LastInnLocation = reader.ReadPoint3D();
|
||||
m_LastInnMap = reader.ReadMap();
|
||||
goto case 29;
|
||||
}
|
||||
case 29:
|
||||
{
|
||||
if (reader.ReadBool())
|
||||
|
|
@ -3667,7 +3694,12 @@ namespace Server.Mobiles
|
|||
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 29 ); // version
|
||||
writer.Write( (int) 30 ); // version
|
||||
|
||||
// -- Inn Room Start
|
||||
writer.Write(m_LastInnLocation);
|
||||
writer.Write(m_LastInnMap);
|
||||
// -- Inn Room End
|
||||
|
||||
if (m_StuckMenuUses != null)
|
||||
{
|
||||
|
|
@ -5175,4 +5207,4 @@ namespace Server.Mobiles
|
|||
m_AutoStabled.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue