#W# Tweaked BandSelf command to prevent spaming Enchanted Bandage.

This commit is contained in:
WarrentyExpired 2026-07-24 08:13:10 -04:00
parent fc87404332
commit b0bd466ee5

View file

@ -19,20 +19,23 @@ namespace Server.Commands
{
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.");
from.SendMessage( 33, "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)
if ( EnchantedBandage.CooldownTable.ContainsKey( from ) && EnchantedBandage.CooldownTable[from] > DateTime.UtcNow )
{
from.SendMessage( 33, "You must wait a moment before using an enchanted bandage again." );
return;
}
if (Utility.RandomDouble() < 0.30)
{
from.Poison = null;
from.Hits = from.HitsMax;
@ -40,26 +43,24 @@ namespace Server.Commands
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!");
EnchantedBandage.CooldownTable[from] = DateTime.UtcNow + TimeSpan.FromSeconds( 5 );
}
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();