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

@ -5,9 +5,10 @@ namespace Server.Spells
{
public abstract class MagerySpell : Spell
{
private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0;
private static readonly int[] m_ManaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };
private static readonly int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };
private static readonly double[] _requiredSkill = Core.ML ?
new[] { 0.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } :
new[] { 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 };
public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
{
@ -29,13 +30,20 @@ namespace Server.Spells
circle -= 2;
}
var avg = ChanceLength * circle;
// Original RunUO algorithm for required skill
// const double chanceOffset = 20.0
// const double chanceLength = 100.0 / 7.0
// var avg = chanceLength * circle;
// min = avg - chanceOffset;
// max = avg + chanceOffset;
min = avg - ChanceOffset;
max = avg + ChanceOffset;
// Correct algorithm according to OSI.
// TODO: Verify this algorithm on OSI for latest expansion.
min = _requiredSkill[circle];
max = min + 40;
}
public override int GetMana() => Scroll is BaseWand ? 0 : m_ManaTable[(int)Circle];
public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle];
public override double GetResistSkill(Mobile m)
{
@ -79,12 +87,13 @@ namespace Server.Spells
public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle)
{
var firstPercent = target.Skills.MagicResist.Value / 5.0;
var secondPercent = target.Skills.MagicResist.Value -
var magicResist = target.Skills.MagicResist.Value;
var firstPercent = magicResist / 5.0;
var secondPercent = magicResist -
((Caster.Skills[CastSkill].Value - 20.0) / 5.0 + (1 + (int)circle) * 5.0);
return (firstPercent > secondPercent ? firstPercent : secondPercent) /
2.0; // Seems should be about half of what stratics says.
// Seems should be about half of what stratics says.
return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0;
}
public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle);