RunUO/Scripts/Commands/StableMount.cs

63 lines
1.9 KiB
C#

using System;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Items;
namespace Server.Commands
{
public class StableMountCommand
{
public static void Initialize()
{
CommandSystem.Register("StableMount", AccessLevel.Player, new CommandEventHandler(StableMount_OnCommand));
}
[Usage("StableMount")]
[Description("Forces a player off their mount and bypasses stable limits for zone control.")]
public static void StableMount_OnCommand(CommandEventArgs e)
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if (pm != null)
{
ForceDismountAndStore(pm);
}
}
public static void ForceDismountAndStore(PlayerMobile pm)
{
if (pm == null || !pm.Mounted)
return;
IMount mount = pm.Mount;
if (mount == null)
return;
if (mount is BaseMount)
{
BaseMount baseMount = (BaseMount)mount;
BaseCreature mountCreature = baseMount as BaseCreature;
if (mountCreature != null)
{
baseMount.Rider = null;
mountCreature.ControlTarget = null;
mountCreature.ControlOrder = OrderType.Stay;
mountCreature.Internalize();
mountCreature.SetControlMaster(null);
mountCreature.SummonMaster = null;
mountCreature.IsStabled = true;
pm.Stabled.Add(mountCreature);
//pm.SendMessage("Mounts are not allowed here! Your mount has been tucked away.");
}
}
else
{
mount.Rider = null;
pm.SendMessage("Ethereal mounts are not allowed in this zone.");
}
}
}
}