#W# Reworking Inn rooms.

This commit is contained in:
WarrentyExpired 2026-08-22 18:14:14 -04:00
parent 7104f56ebf
commit 66eafd3451
15 changed files with 918 additions and 576 deletions

View file

@ -0,0 +1,75 @@
using System;
using System.Xml; // Required for loading from Regions.xml
using System.Collections.Generic;
using Server;
using Server.Mobiles;
using Server.Regions;
using Server.Multis;
namespace Server.Custom.InnRooms
{
public class InnRegion : BaseRegion
{
// Constructor 1: Used if manually generated in a script
public InnRegion(string name, Map map, int priority, params Rectangle2D[] area)
: base(name, map, priority, area)
{
Register();
}
// Constructor 2: Used when loading from Regions.xml (This fixes your crash!)
public InnRegion(XmlElement xml, Map map, Region parent)
: base(xml, map, parent)
{
// Note: We don't call Register() here because the XML loader handles it automatically!
}
public override void OnSpeech(SpeechEventArgs e)
{
base.OnSpeech(e);
if (!e.Handled && e.Mobile is PlayerMobile && e.Mobile.Alive)
{
PlayerMobile pm = (PlayerMobile)e.Mobile;
if (e.Speech.ToLower().Contains("inn room"))
{
e.Handled = true;
InnRoomHouse rentedRoom = GetPlayerRoom(pm);
if (rentedRoom != null)
{
pm.LastInnLocation = pm.Location;
pm.LastInnMap = pm.Map;
Point3D roomLoc = new Point3D(rentedRoom.X, rentedRoom.Y, rentedRoom.Z + 20);
pm.PlaySound(0x1EA);
pm.MoveToWorld(roomLoc, rentedRoom.Map);
pm.SendMessage(68, "You are whisked away to your rented room.");
}
else
{
pm.CloseGump(typeof(InnRentalGump));
pm.SendGump(new InnRentalGump(pm));
}
}
}
}
private InnRoomHouse GetPlayerRoom(Mobile m)
{
List<BaseHouse> houses = BaseHouse.GetHouses(m);
foreach (BaseHouse house in houses)
{
if (house is InnRoomHouse && !house.Deleted)
{
return (InnRoomHouse)house;
}
}
return null;
}
}
}