ModernUO/Projects/UOContent/Spells/Sixth/MassCurse.cs
Kamron Batman 28c06c1cc0
fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553)
### Summary

Eliminates `IPooledEnumerable<T>` and `eable.Free()` from `Map` for mobiles. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var m in m.GetMobilesInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.

- [X] Fixed several locations where an NPC that was damaged would cause a server crash.
- [X] Removed an unnecessary allocation in guard fake calls (NPCs calling guards on you)
- [X] Fixes damage precision loss in Poison Strike Spell
- [X] BogThing no longer attempts to "search" for boglings to eat when it is at full health
2023-10-29 22:42:46 -07:00

66 lines
2 KiB
C#

namespace Server.Spells.Sixth
{
public class MassCurseSpell : MagerySpell, ISpellTargetingPoint3D
{
private static readonly SpellInfo _info = new(
"Mass Curse",
"Vas Des Sanct",
218,
9031,
false,
Reagent.Garlic,
Reagent.Nightshade,
Reagent.MandrakeRoot,
Reagent.SulfurousAsh
);
public MassCurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Sixth;
public void Target(IPoint3D p)
{
if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
{
SpellHelper.Turn(Caster, p);
SpellHelper.GetSurfaceTop(ref p);
var map = Caster.Map;
if (map != null)
{
foreach (var m in map.GetMobilesInRange(new Point3D(p), 2))
{
if (Core.AOS && (m == Caster || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanSee(m) ||
!Caster.CanBeHarmful(m, false)))
{
continue;
}
Caster.DoHarmful(m);
var length = SpellHelper.GetDuration(Caster, m);
SpellHelper.AddStatCurse(Caster, m, StatType.Str, length, false);
SpellHelper.AddStatCurse(Caster, m, StatType.Dex, length);
SpellHelper.AddStatCurse(Caster, m, StatType.Int, length);
m.FixedParticles(0x374A, 10, 15, 5028, EffectLayer.Waist);
m.PlaySound(0x1FB);
HarmfulSpell(m);
}
}
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this, range: Core.ML ? 10 : 12);
}
}
}