fix: Fixes splitting potions before error (#1862)

### Summary

Most potions have various checks, such as a cooldown. This fixes an edge case where potions get split from their stack before erroring.
This commit is contained in:
Kamron Batman 2024-07-06 16:39:47 -07:00 • committed by GitHub
parent e6bfc45228
commit 38731d98b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 169 additions and 99 deletions

View file

@ -14,8 +14,13 @@ public abstract partial class BaseStrengthPotion : BasePotion
public abstract int StrOffset { get; }
public abstract TimeSpan Duration { get; }
public bool DoStrength(Mobile from)
public bool CanDrink(Mobile from)
{
if (!base.CanDrink(from))
{
return false;
}
// TODO: Verify scaled; is it offset, duration, or both?
if (SpellHelper.AddStatOffset(from, StatType.Str, Scale(from, StrOffset), Duration))
{
@ -30,9 +35,6 @@ public abstract partial class BaseStrengthPotion : BasePotion
public override void Drink(Mobile from)
{
if (DoStrength(from))
{
PlayDrinkEffect(from);
}
PlayDrinkEffect(from);
}
}