74 lines
2.2 KiB
C#
74 lines
2.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 the custom Enchanted Bandage first
|
|
EnchantedBandage enchanted = from.Backpack.FindItemByType<EnchantedBandage>();
|
|
|
|
if (enchanted != null && enchanted.Charges > 0)
|
|
{
|
|
// The 50% chance check
|
|
if (Utility.RandomDouble() < 0.50)
|
|
{
|
|
from.Poison = null;
|
|
from.Hits = from.HitsMax;
|
|
|
|
from.PlaySound(0x1F2);
|
|
from.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist);
|
|
from.SendMessage(63, "The enchanted bandage glows brightly, instantly curing and fully healing you!");
|
|
}
|
|
else
|
|
{
|
|
// Failed 50% check. Trigger normal heal using the custom charges.
|
|
if (BandageContext.BeginHeal(from, from) != null)
|
|
{
|
|
enchanted.Charges--;
|
|
}
|
|
}
|
|
|
|
// Return here so we don't accidentally consume a regular bandage below
|
|
return;
|
|
}
|
|
|
|
// 3. Fallback: Search for a standard bandage in the backpack
|
|
Bandage bandage = from.Backpack.FindItemByType<Bandage>();
|
|
|
|
if (bandage != null)
|
|
{
|
|
// 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.");
|
|
}
|
|
}
|
|
}
|
|
}
|