47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using Server;
|
|
using Server.Items;
|
|
using Server.Commands;
|
|
using Server.Mobiles;
|
|
|
|
namespace Server.Commands
|
|
{
|
|
public class BandSelf
|
|
{
|
|
public static void Initialize()
|
|
{
|
|
CommandSystem.Register("Bandself", AccessLevel.Player, new CommandEventHandler(Bandself_OnCommand));
|
|
}
|
|
|
|
[Usage("Bandself")]
|
|
[Description("Uses a bandage from the player's backpack on themselves.")]
|
|
public static void Bandself_OnCommand(CommandEventArgs e)
|
|
{
|
|
Mobile from = e.Mobile;
|
|
|
|
// 1. Check if the player is already bandaging to avoid resetting the timer
|
|
if (BandageContext.GetContext(from) != null)
|
|
{
|
|
from.SendMessage("You are already applying a bandage.");
|
|
return;
|
|
}
|
|
|
|
// 2. Search for a bandage in the backpack
|
|
Bandage bandage = from.Backpack.FindItemByType<Bandage>();
|
|
|
|
if (bandage != null)
|
|
{
|
|
// 3. Trigger the healing attempt directly using the established Context logic
|
|
// We call BeginHeal which handles the timer, skill checks, and target logic
|
|
if (BandageContext.BeginHeal(from, from) != null)
|
|
{
|
|
bandage.Consume();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
from.SendMessage("You do not have any bandages in your backpack.");
|
|
}
|
|
}
|
|
}
|
|
}
|