From 54da2c94a59c0ea47398035540d4c2954b896a57 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 16 Jul 2022 23:25:48 -0700 Subject: [PATCH] fix: Updates Mysticism to use circles (#1123) --- Projects/UOContent/Spells/Base/MagerySpell.cs | 1 - Projects/UOContent/Spells/Base/SpecialMove.cs | 13 +-- .../UOContent/Spells/Bushido/SamuraiSpell.cs | 2 +- .../Spells/Mysticism/AnimatedWeaponSpell.cs | 5 +- .../Spells/Mysticism/EagleStrikeSpell.cs | 5 +- .../Spells/Mysticism/HailStormSpell.cs | 9 +- .../UOContent/Spells/Mysticism/MysticSpell.cs | 94 +++++++++++++++---- .../Spells/Mysticism/NetherCycloneSpell.cs | 8 +- .../Spells/Mysticism/SpellPlagueSpell.cs | 16 ++-- .../Spells/Mysticism/StoneFormSpell.cs | 8 +- .../UOContent/Spells/Ninjitsu/NinjaSpell.cs | 2 +- 11 files changed, 97 insertions(+), 66 deletions(-) diff --git a/Projects/UOContent/Spells/Base/MagerySpell.cs b/Projects/UOContent/Spells/Base/MagerySpell.cs index f900de32d..c25d8ac6a 100644 --- a/Projects/UOContent/Spells/Base/MagerySpell.cs +++ b/Projects/UOContent/Spells/Base/MagerySpell.cs @@ -12,7 +12,6 @@ namespace Server.Spells * Mana requirements formula: (14 * (circle - 1)) + 2 = 50% probability * Add or subtract 20 for max or min limits */ - private static readonly double[] _requiredSkill = Core.ML ? new[] { -46.0, -32.0, -18.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } : new[] { -50.0, -30.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 }; diff --git a/Projects/UOContent/Spells/Base/SpecialMove.cs b/Projects/UOContent/Spells/Base/SpecialMove.cs index d0b98ac79..4d85f3f14 100644 --- a/Projects/UOContent/Spells/Base/SpecialMove.cs +++ b/Projects/UOContent/Spells/Base/SpecialMove.cs @@ -64,11 +64,8 @@ namespace Server.Spells { if (m.Skills[MoveSkill].Value < RequiredSkill) { - var args = $"{RequiredSkill:F1}\t{MoveSkill.ToString()}\t "; - m.SendLocalizedMessage( - 1063013, - args - ); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. + // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. + m.SendLocalizedMessage(1063013, $"{RequiredSkill:F1}\t{MoveSkill}\t "); return false; } @@ -105,10 +102,8 @@ namespace Server.Spells if (from.Mana < mana) { - from.SendLocalizedMessage( - 1060181, - mana.ToString() - ); // You need ~1_MANA_REQUIREMENT~ mana to perform that attack + // You need ~1_MANA_REQUIREMENT~ mana to perform that attack + from.SendLocalizedMessage(1060181, mana.ToString()); return false; } diff --git a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs index f38fb6c90..3c7d4736a 100644 --- a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs +++ b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs @@ -46,7 +46,7 @@ namespace Server.Spells.Bushido if (Caster.Skills[CastSkill].Value < RequiredSkill) { // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. - Caster.SendLocalizedMessage(1063013, $"{RequiredSkill:0.#}\t{CastSkill.ToString()}\t "); + Caster.SendLocalizedMessage(1063013, $"{RequiredSkill:0.#}\t{CastSkill}\t "); return false; } diff --git a/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs b/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs index f5e7cd101..ec6876850 100644 --- a/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/AnimatedWeaponSpell.cs @@ -20,10 +20,7 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); - - public override double RequiredSkill => 33.0; - public override int RequiredMana => 11; + public override SpellCircle Circle => SpellCircle.Fourth; public void Target(IPoint3D p) { diff --git a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs index 542d911b8..f60095868 100644 --- a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs @@ -20,10 +20,7 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.25); - - public override double RequiredSkill => 20.0; - public override int RequiredMana => 9; + public override SpellCircle Circle => SpellCircle.Third; public void Target(Mobile m) { diff --git a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs index f30fe994e..57c81358c 100644 --- a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Server.Spells.Mysticism { @@ -20,10 +19,8 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); - - public override double RequiredSkill => 70.0; - public override int RequiredMana => 40; + public override SpellCircle Circle => SpellCircle.Seventh; + public override int GetMana() => 50; public void Target(IPoint3D p) { diff --git a/Projects/UOContent/Spells/Mysticism/MysticSpell.cs b/Projects/UOContent/Spells/Mysticism/MysticSpell.cs index 11eebfdca..8e126e22b 100644 --- a/Projects/UOContent/Spells/Mysticism/MysticSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/MysticSpell.cs @@ -1,16 +1,35 @@ using System; +using Server.Items; namespace Server.Spells.Mysticism { public abstract class MysticSpell : Spell { - public MysticSpell(Mobile caster, Item scroll, SpellInfo info) - : base(caster, scroll, info) + private static int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + private static double[] _requiredSkill = { 0.0, 8.0, 20.0, 33.0, 45.0, 58.0, 70.0, 83.0 }; + + public MysticSpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info) { } - public abstract double RequiredSkill { get; } - public abstract int RequiredMana { get; } + public abstract SpellCircle Circle { get; } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.5 + 0.25 * (int)Circle); + + public virtual double RequiredSkill + { + get + { + var circle = (int)Circle; + + if (Scroll != null) + { + circle -= 2; + } + + return _requiredSkill[circle]; + } + } public override SkillName CastSkill => SkillName.Mysticism; @@ -26,14 +45,15 @@ namespace Server.Spells.Mysticism public override void GetCastSkills(out double min, out double max) { + var requiredSkill = RequiredSkill; + // As per Mysticism page at the UO Herald Playguide // This means that we have 25% success chance at min Required Skill - - min = RequiredSkill - 12.5; - max = RequiredSkill + 37.5; + min = requiredSkill - 12.5; + max = requiredSkill + 37.5; } - public override int GetMana() => RequiredMana; + public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle]; public override bool CheckCast() { @@ -42,23 +62,21 @@ namespace Server.Spells.Mysticism return false; } - var mana = ScaleMana(RequiredMana); + var mana = ScaleMana(GetMana()); if (Caster.Mana < mana) { - Caster.SendLocalizedMessage( - 1060174, - mana.ToString() - ); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability. + // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability. + Caster.SendLocalizedMessage(1060174, mana.ToString()); return false; } - if (Caster.Skills[CastSkill].Value < RequiredSkill) + var requiredSkill = RequiredSkill; + + if (Caster.Skills[CastSkill].Value < requiredSkill) { - Caster.SendLocalizedMessage( - 1063013, - $"{RequiredSkill:F1}\t{CastSkill.ToString()}\t " - ); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. + // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. + Caster.SendLocalizedMessage(1063013, $"{requiredSkill:F1}\t{CastSkill}\t "); return false; } @@ -80,5 +98,45 @@ namespace Server.Spells.Mysticism public static double GetBaseSkill(Mobile m) => m.Skills.Mysticism.Value; public static double GetBoostSkill(Mobile m) => Math.Max(m.Skills.Imbuing.Value, m.Skills.Focus.Value); + + public virtual bool CheckResisted(Mobile target) + { + var n = GetResistPercent(target); + + n /= 100.0; + + if (n <= 0.0) + { + return false; + } + + if (n >= 1.0) + { + return true; + } + + var maxSkill = (1 + (int)Circle) * 10; + maxSkill += (1 + (int)Circle / 6) * 25; + + if (target.Skills.MagicResist.Value < maxSkill) + { + target.CheckSkill(SkillName.MagicResist, 0.0, target.Skills.MagicResist.Cap); + } + + return n >= Utility.RandomDouble(); + } + + public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle) + { + 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); + + // 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); } } diff --git a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs index aaf18cf2d..536315e53 100644 --- a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Server.Spells.Mysticism { @@ -20,10 +19,7 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.5); - - public override double RequiredSkill => 83.0; - public override int RequiredMana => 50; + public override SpellCircle Circle => SpellCircle.Eighth; public void Target(IPoint3D p) { diff --git a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs index e2040d65b..07fd59598 100644 --- a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs @@ -23,10 +23,7 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); - - public override double RequiredSkill => 70.0; - public override int RequiredMana => 40; + public override SpellCircle Circle => SpellCircle.Seventh; public static void Initialize() { @@ -201,23 +198,22 @@ namespace Server.Spells.Mysticism private class InternalTarget : Target { - private readonly SpellPlagueSpell m_Owner; + private readonly SpellPlagueSpell _owner; - public InternalTarget(SpellPlagueSpell owner) - : base(12, false, TargetFlags.Harmful) => - m_Owner = owner; + public InternalTarget(SpellPlagueSpell owner) : base(12, false, TargetFlags.Harmful) => + _owner = owner; protected override void OnTarget(Mobile from, object o) { if (o is Mobile mobile) { - m_Owner.Target(mobile); + _owner.Target(mobile); } } protected override void OnTargetFinish(Mobile from) { - m_Owner.FinishSequence(); + _owner.FinishSequence(); } } } diff --git a/Projects/UOContent/Spells/Mysticism/StoneFormSpell.cs b/Projects/UOContent/Spells/Mysticism/StoneFormSpell.cs index 3106e3c54..59507600e 100644 --- a/Projects/UOContent/Spells/Mysticism/StoneFormSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/StoneFormSpell.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Server.Factions; using Server.Spells.Fifth; using Server.Spells.Ninjitsu; @@ -25,10 +24,7 @@ namespace Server.Spells.Mysticism { } - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); - - public override double RequiredSkill => 33.0; - public override int RequiredMana => 11; + public override SpellCircle Circle => SpellCircle.Fourth; public static void Initialize() { diff --git a/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs b/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs index bdf3c1db3..79452f6f9 100644 --- a/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs +++ b/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs @@ -45,7 +45,7 @@ namespace Server.Spells.Ninjitsu if (Caster.Skills[CastSkill].Value < RequiredSkill) { // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability. - Caster.SendLocalizedMessage(1063013, $"{RequiredSkill:F1}\t{CastSkill.ToString()}\t "); + Caster.SendLocalizedMessage(1063013, $"{RequiredSkill:F1}\t{CastSkill}\t "); return false; }