fix: Cleans up more spells (#1121)

This commit is contained in:
Kamron Batman 2022-07-16 22:32:51 -07:00 • committed by GitHub
parent fa3515f930
commit 068bafd9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 339 additions and 439 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Server.Collections;
using Server.Items;
using Server.Mobiles;
@ -42,35 +43,40 @@ namespace Server.Spells.Necromancy
if (map != null)
{
var targets = new List<Mobile>();
using var pool = PooledRefQueue<Mobile>.Create();
var cbc = Caster as BaseCreature;
var isMonster = cbc?.Controlled == false && !cbc.Summoned;
foreach (var m in Caster.GetMobilesInRange(Core.ML ? 4 : 5))
var eable = Caster.GetMobilesInRange(Core.ML ? 4 : 5);
foreach (var m in eable)
{
if (Caster != m && Caster.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(Caster, m)) &&
Caster.CanBeHarmful(m, false))
if (Caster == m || !Caster.InLOS(m) || (!isMonster && !SpellHelper.ValidIndirectTarget(Caster, m)) ||
!Caster.CanBeHarmful(m, false))
{
if (isMonster)
continue;
}
if (isMonster)
{
if (m is BaseCreature bc)
{
if (m is BaseCreature bc)
{
if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team)
{
continue;
}
}
else if (!m.Player)
if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team)
{
continue;
}
}
targets.Add(m);
else if (!m.Player)
{
continue;
}
}
pool.Enqueue(m);
}
eable.Free();
Effects.PlaySound(Caster.Location, map, 0x1FB);
Effects.PlaySound(Caster.Location, map, 0x10B);
Effects.SendLocationParticles(
@ -84,9 +90,9 @@ namespace Server.Spells.Necromancy
0
);
for (var i = 0; i < targets.Count; ++i)
while (pool.Count > 0)
{
var m = targets[i];
var m = pool.Dequeue();
Caster.DoHarmful(m);
m.FixedParticles(0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255);