fix(spells): Fixes interruption of spells (#702)

This commit is contained in:
Kamron Batman 2021-08-18 12:17:42 -07:00 • committed by GitHub
parent 50dd7a1146
commit e6de7a5898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 55 deletions

View file

@ -84,10 +84,13 @@ namespace Server.Spells
public virtual void OnCasterHurt()
{
// Confirm: Monsters and pets cannot be disturbed.
if (Caster.Player && IsCasting && ProtectionSpell.Registry.TryGetValue(Caster, out var d) &&
d <= Utility.RandomDouble() * 100.0)
if (Caster.Player && IsCasting)
{
Disturb(DisturbType.Hurt, false, true);
var hasProtection = ProtectionSpell.Registry.TryGetValue(Caster, out var d);
if (!hasProtection || d < 1000 && d < Utility.Random(1000))
{
Disturb(DisturbType.Hurt, false, true);
}
}
}
@ -704,7 +707,7 @@ namespace Server.Spells
{
DoFizzle();
}
else if (Scroll != null && !(Scroll is Runebook) &&
else if (Scroll != null && Scroll is not Runebook &&
(Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || Scroll is BaseWand baseWand &&
(baseWand.Charges <= 0 || baseWand.Parent != Caster)))
{