fix(spells): Fixes interruption of spells (#702)
This commit is contained in:
parent
50dd7a1146
commit
e6de7a5898
6 changed files with 64 additions and 55 deletions
|
|
@ -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)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Collections;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Spells.Second;
|
||||
using Server.Targeting;
|
||||
|
|
@ -53,15 +53,26 @@ namespace Server.Spells.Fourth
|
|||
return;
|
||||
}
|
||||
|
||||
var targets = Caster.Map.GetMobilesInRange(loc, Core.AOS ? 2 : 3)
|
||||
.Where(m => Caster.CanBeBeneficial(m, false));
|
||||
var eable = Caster.Map.GetMobilesInRange(loc, Core.AOS ? 2 : 3);
|
||||
using var targets = PooledRefQueue<Mobile>.Create();
|
||||
|
||||
foreach (var m in eable)
|
||||
{
|
||||
if (Caster.CanBeBeneficial(m, false))
|
||||
{
|
||||
targets.Enqueue(m);
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
var party = Party.Get(Caster);
|
||||
|
||||
foreach (var m in targets)
|
||||
while (targets.Count > 0)
|
||||
{
|
||||
var m = targets.Dequeue();
|
||||
if (m == Caster || party?.Contains(m) == true)
|
||||
{
|
||||
Caster.DoBeneficial(m);
|
||||
|
|
@ -73,8 +84,9 @@ namespace Server.Spells.Fourth
|
|||
{
|
||||
var val = (int)(Caster.Skills.Magery.Value / 10.0 + 1);
|
||||
|
||||
foreach (var m in targets)
|
||||
while (targets.Count > 0)
|
||||
{
|
||||
var m = targets.Dequeue();
|
||||
if (m.BeginAction<ArchProtectionSpell>())
|
||||
{
|
||||
Caster.DoBeneficial(m);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.Items;
|
||||
using Server.Misc;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Server.Spells.Second
|
|||
{
|
||||
}
|
||||
|
||||
public static Dictionary<Mobile, double> Registry { get; } = new();
|
||||
public static Dictionary<Mobile, int> Registry { get; } = new();
|
||||
|
||||
public override SpellCircle Circle => SpellCircle.Second;
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ namespace Server.Spells.Second
|
|||
return false;
|
||||
}
|
||||
|
||||
// AOS+ only
|
||||
public static void Toggle(Mobile caster, Mobile target)
|
||||
{
|
||||
/* Players under the protection spell effect can no longer have their spells "disrupted" when hit.
|
||||
|
|
@ -89,7 +90,7 @@ namespace Server.Spells.Second
|
|||
);
|
||||
|
||||
m_Table[target] = mods;
|
||||
Registry[target] = 100.0;
|
||||
Registry[target] = 1000; // 100.0% protection from disruption
|
||||
|
||||
target.AddResistanceMod(mods.Item1);
|
||||
target.AddSkillMod(mods.Item2);
|
||||
|
|
@ -141,12 +142,11 @@ namespace Server.Spells.Second
|
|||
{
|
||||
if (Caster.BeginAction<DefensiveSpell>())
|
||||
{
|
||||
double value = (int)(Caster.Skills.EvalInt.Value +
|
||||
Caster.Skills.Meditation.Value +
|
||||
Caster.Skills.Inscribe.Value);
|
||||
value /= 4;
|
||||
int value = (Caster.Skills.EvalInt.Fixed +
|
||||
Caster.Skills.Meditation.Fixed +
|
||||
Caster.Skills.Inscribe.Fixed) / 4;
|
||||
|
||||
Registry.Add(Caster, Math.Clamp(value, 0.0, 75.0));
|
||||
Registry.Add(Caster, Math.Clamp(value, 0, 750)); // 75.0% protection from disruption
|
||||
new InternalTimer(Caster).Start();
|
||||
|
||||
Caster.FixedParticles(0x375A, 9, 20, 5016, EffectLayer.Waist);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue