#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; Mobile from = e.Mobile;
// 1. Check if the player is already bandaging to avoid resetting the timer
if (BandageContext.GetContext(from) != null) if (BandageContext.GetContext(from) != null)
{ {
from.SendMessage("You are already applying a bandage."); from.SendMessage( 33, "You are already applying a bandage." );
return; return;
} }
// 2. Search for the custom Enchanted Bandage first
EnchantedBandage enchanted = from.Backpack.FindItemByType<EnchantedBandage>(); EnchantedBandage enchanted = from.Backpack.FindItemByType<EnchantedBandage>();
if (enchanted != null && enchanted.Charges > 0) if (enchanted != null && enchanted.Charges > 0)
{ {
// The 50% chance check if ( EnchantedBandage.CooldownTable.ContainsKey( from ) && EnchantedBandage.CooldownTable[from] > DateTime.UtcNow )
if (Utility.RandomDouble() < 0.50) {
from.SendMessage( 33, "You must wait a moment before using an enchanted bandage again." );
return;
}
if (Utility.RandomDouble() < 0.30)
{ {
from.Poison = null; from.Poison = null;
from.Hits = from.HitsMax; from.Hits = from.HitsMax;
@ -40,26 +43,24 @@ namespace Server.Commands
from.PlaySound(0x1F2); from.PlaySound(0x1F2);
from.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); from.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist);
from.SendMessage(63, "The enchanted bandage glows brightly, instantly curing and fully healing you!"); from.SendMessage(63, "The enchanted bandage glows brightly, instantly curing and fully healing you!");
EnchantedBandage.CooldownTable[from] = DateTime.UtcNow + TimeSpan.FromSeconds( 5 );
} }
else else
{ {
// Failed 50% check. Trigger normal heal using the custom charges.
if (BandageContext.BeginHeal(from, from) != null) if (BandageContext.BeginHeal(from, from) != null)
{ {
enchanted.Charges--; enchanted.Charges--;
} }
} }
// Return here so we don't accidentally consume a regular bandage below
return; return;
} }
// 3. Fallback: Search for a standard bandage in the backpack
Bandage bandage = from.Backpack.FindItemByType<Bandage>(); Bandage bandage = from.Backpack.FindItemByType<Bandage>();
if (bandage != null) if (bandage != null)
{ {
// We call BeginHeal which handles the timer, skill checks, and target logic
if (BandageContext.BeginHeal(from, from) != null) if (BandageContext.BeginHeal(from, from) != null)
{ {
bandage.Consume(); bandage.Consume();