fix: Fixes skill requirements and cleans up magery spells (#870)

* Preps damage stacking for mysticism, necromancy fixes, and spellweaving
* Removes extra LINQ allocations
* Fixes skill requirements for magery spells.
This commit is contained in:
Kamron Batman 2021-12-05 09:40:57 -08:00 • committed by GitHub
parent 1cf7b6c056
commit 4f9714818d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 311 additions and 382 deletions

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Collections;
using Server.Mobiles;
namespace Server.Spells.Fourth
@ -34,37 +33,39 @@ namespace Server.Spells.Fourth
SpellHelper.GetSurfaceTop(ref p);
var targets = new List<Mobile>();
var map = Caster.Map;
var directTarget = p as Mobile;
var loc = new Point3D(p);
if (map != null)
{
using var pool = PooledRefQueue<Mobile>.Create();
var directTarget = p as Mobile;
var loc = new Point3D(p);
var feluccaRules = map.Rules == MapRules.FeluccaRules;
// You can target any living mobile directly, beneficial checks apply
if (directTarget != null && Caster.CanBeBeneficial(directTarget, false))
{
targets.Add(directTarget);
pool.Enqueue(directTarget);
}
var eable = map.GetMobilesInRange(loc, 2);
targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules)));
foreach (var m in eable)
{
if (m != directTarget && AreaCanTarget(m, feluccaRules))
{
pool.Enqueue(m);
}
}
eable.Free();
}
Effects.PlaySound(loc, Caster.Map, 0x299);
Effects.PlaySound(loc, Caster.Map, 0x299);
if (targets.Count > 0)
{
var cured = 0;
for (var i = 0; i < targets.Count; ++i)
while (pool.Count > 0)
{
var m = targets[i];
var m = pool.Dequeue();
Caster.DoBeneficial(m);

View file

@ -19,7 +19,7 @@ namespace Server.Spells.Fourth
Reagent.SulfurousAsh
);
private static readonly Dictionary<Mobile, int> _Table = new();
private static readonly Dictionary<Mobile, int> _table = new();
public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
@ -107,12 +107,12 @@ namespace Server.Spells.Fourth
private static void AddEntry(Mobile m, int v)
{
_Table[m] = v;
_table[m] = v;
}
public static void RemoveEntry(Mobile m)
{
if (_Table.Remove(m, out var v))
if (_table.Remove(m, out var v))
{
m.EndAction<ArchProtectionSpell>();
m.VirtualArmorMod -= Math.Min(v, m.VirtualArmorMod);

View file

@ -15,7 +15,7 @@ namespace Server.Spells.Fourth
Reagent.SulfurousAsh
);
private static readonly HashSet<Mobile> m_UnderEffect = new();
private static readonly HashSet<Mobile> _underEffect = new();
public CurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
@ -41,7 +41,7 @@ namespace Server.Spells.Fourth
if (Caster.Player && m.Player /*&& Caster != m */ && !UnderEffect(m))
{
var duration = SpellHelper.GetDuration(Caster, m);
m_UnderEffect.Add(m);
_underEffect.Add(m);
Timer.StartTimer(duration, () => RemoveEffect(m));
m.UpdateResistances();
}
@ -71,13 +71,13 @@ namespace Server.Spells.Fourth
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12);
}
public static void RemoveEffect(Mobile m)
public static bool RemoveEffect(Mobile m)
{
m_UnderEffect.Remove(m);
var effectRemoved = _underEffect.Remove(m);
m.UpdateResistances();
return effectRemoved;
}
public static bool UnderEffect(Mobile m) => m_UnderEffect.Contains(m);
public static bool UnderEffect(Mobile m) => _underEffect.Contains(m);
}
}