diff --git a/Projects/UOContent/Spells/Base/MagerySpell.cs b/Projects/UOContent/Spells/Base/MagerySpell.cs index 68c261e8e..7905a7d65 100644 --- a/Projects/UOContent/Spells/Base/MagerySpell.cs +++ b/Projects/UOContent/Spells/Base/MagerySpell.cs @@ -6,9 +6,11 @@ namespace Server.Spells public abstract class MagerySpell : Spell { private static readonly int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + + // Starts at Circle -2 to account for scrolls 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 }; + new[] { -46.0, -32.0, 0.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 }; public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info) { @@ -23,13 +25,6 @@ namespace Server.Spells public override void GetCastSkills(out double min, out double max) { - var circle = (int)Circle; - - if (Scroll != null) - { - circle -= 2; - } - // Original RunUO algorithm for required skill // const double chanceOffset = 20.0 // const double chanceLength = 100.0 / 7.0 @@ -37,9 +32,9 @@ namespace Server.Spells // min = avg - chanceOffset; // max = avg + chanceOffset; - // Correct algorithm according to OSI. + // Correct algorithm according to OSI for UOR/UOML // TODO: Verify this algorithm on OSI for latest expansion. - min = _requiredSkill[circle]; + min = _requiredSkill[(int)(Scroll == null ? Circle + 2 : Circle)]; max = min + 40; } @@ -47,8 +42,9 @@ namespace Server.Spells public override double GetResistSkill(Mobile m) { - var maxSkill = (1 + (int)Circle) * 10; - maxSkill += (1 + (int)Circle / 6) * 25; + var circle = (int)Circle; + + var maxSkill = 1 + circle * 10 + (1 + circle / 6) * 25; if (m.Skills.MagicResist.Value < maxSkill) { @@ -60,9 +56,7 @@ namespace Server.Spells public virtual bool CheckResisted(Mobile target) { - var n = GetResistPercent(target); - - n /= 100.0; + var n = GetResistPercent(target) / 100.0; if (n <= 0.0) { @@ -74,8 +68,10 @@ namespace Server.Spells return true; } - var maxSkill = (1 + (int)Circle) * 10; - maxSkill += (1 + (int)Circle / 6) * 25; + // Even though this calculation matches AOS+, we don't combine with GetResistSkills because of an assumption + // about how it is used. + var circle = (int)Circle; + var maxSkill = (1 + circle) * 10 + (1 + circle / 6) * 25; if (target.Skills.MagicResist.Value < maxSkill) { diff --git a/Projects/UOContent/Spells/Bushido/CounterAttack.cs b/Projects/UOContent/Spells/Bushido/CounterAttack.cs index ea3c07e22..6dacc8e27 100644 --- a/Projects/UOContent/Spells/Bushido/CounterAttack.cs +++ b/Projects/UOContent/Spells/Bushido/CounterAttack.cs @@ -31,17 +31,12 @@ namespace Server.Spells.Bushido return false; } - if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield) - { - return true; - } - if (Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon) { return true; } - if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon) + if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield or BaseWeapon) { return true; } diff --git a/Projects/UOContent/Spells/Bushido/Evasion.cs b/Projects/UOContent/Spells/Bushido/Evasion.cs index a5eab88e2..ec9a77b52 100644 --- a/Projects/UOContent/Spells/Bushido/Evasion.cs +++ b/Projects/UOContent/Spells/Bushido/Evasion.cs @@ -33,7 +33,7 @@ namespace Server.Spells.Bushido return false; } - if (!(caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + if (caster.FindItemOnLayer(Layer.OneHanded) is not BaseWeapon weap) { weap = caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; } @@ -44,15 +44,14 @@ namespace Server.Spells.Bushido { if (messages) { - caster.SendLocalizedMessage( - 1076206 - ); // Your skill with your equipped weapon must be 50 or higher to use Evasion. + // Your skill with your equipped weapon must be 50 or higher to use Evasion. + caster.SendLocalizedMessage(1076206); } return false; } } - else if (!(caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) + else if (caster.FindItemOnLayer(Layer.TwoHanded) is not BaseShield) { if (messages) { @@ -77,7 +76,7 @@ namespace Server.Spells.Bushido public static bool CheckSpellEvasion(Mobile defender) { - if (!(defender.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + if (defender.FindItemOnLayer(Layer.OneHanded) is not BaseWeapon weap) { weap = defender.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; } @@ -96,7 +95,7 @@ namespace Server.Spells.Bushido return false; } } - else if (!(defender.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) + else if (defender.FindItemOnLayer(Layer.TwoHanded) is not BaseShield) { return false; } @@ -162,8 +161,8 @@ namespace Server.Spells.Bushido seconds += (m.Skills.Bushido.Value - 60) / 20; } - if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0 - ) // Bushido being HIGHER than 100 for bonus is intended + // Bushido being HIGHER than 100 for bonus is intended + if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0) { seconds++; } @@ -194,8 +193,8 @@ namespace Server.Spells.Bushido bonus += (m.Skills.Bushido.Value - 60) * .004 + 0.16; } - if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100 - ) // Bushido being HIGHER than 100 for bonus is intended + // Bushido being HIGHER than 100 for bonus is intended + if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100) { bonus += 0.10; } diff --git a/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs b/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs index 01eea62a2..a204fe57c 100644 --- a/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs +++ b/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs @@ -29,7 +29,7 @@ namespace Server.Spells.Chivalry public override void OnCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists) + if (Caster.Weapon is not (BaseWeapon weapon and not Fists)) { Caster.SendLocalizedMessage(501078); // You must be holding a weapon. } diff --git a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs index 8009e46de..9e8e4e4c7 100644 --- a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs +++ b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs @@ -40,7 +40,7 @@ namespace Server.Spells.Chivalry continue; } - if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && !(m is Golem)) + if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && m is not Golem) { targets.Add(m); } diff --git a/Projects/UOContent/Spells/Fifth/DispelField.cs b/Projects/UOContent/Spells/Fifth/DispelField.cs index ac0bfe41e..2db3e4f5b 100644 --- a/Projects/UOContent/Spells/Fifth/DispelField.cs +++ b/Projects/UOContent/Spells/Fifth/DispelField.cs @@ -28,7 +28,7 @@ namespace Server.Spells.Fifth { Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. } - else if (item is Moongate moongate && !moongate.Dispellable) + else if (item is Moongate { Dispellable: false }) { Caster.SendLocalizedMessage(1005047); // That magic is too chaotic } diff --git a/Projects/UOContent/Spells/Fourth/ArchCure.cs b/Projects/UOContent/Spells/Fourth/ArchCure.cs index 9cacd8790..841c03d6d 100644 --- a/Projects/UOContent/Spells/Fourth/ArchCure.cs +++ b/Projects/UOContent/Spells/Fourth/ArchCure.cs @@ -127,7 +127,7 @@ namespace Server.Spells.Fourth return false; } - if (feluccaRules && !(target is PlayerMobile)) + if (feluccaRules && target is not PlayerMobile) { return false; } diff --git a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs index f67cdeb78..13172b7ce 100644 --- a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs @@ -142,7 +142,7 @@ namespace Server.Spells.Necromancy return; } - if (!(item is Corpse c)) + if (item is not Corpse c) { Caster.SendLocalizedMessage(1061084); // You cannot animate that. } diff --git a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs index 0d7969f7d..0b6b1aadf 100644 --- a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs @@ -34,7 +34,7 @@ namespace Server.Spells.Necromancy Caster.SendLocalizedMessage(1060508); // You can't curse that. } // only PlayerMobile and BaseCreature implement blood oath checking - else if (Caster == m || !(m is PlayerMobile || m is BaseCreature)) + else if (Caster == m || m is not (PlayerMobile or BaseCreature)) { Caster.SendLocalizedMessage(1060508); // You can't curse that. } diff --git a/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs b/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs index 96b5fd3ea..737645f75 100644 --- a/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs +++ b/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs @@ -27,7 +27,7 @@ namespace Server.Spells.Necromancy public override void OnCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists) + if (Caster.Weapon is not BaseWeapon weapon || weapon is Fists) { Caster.SendLocalizedMessage(501078); // You must be holding a weapon. } diff --git a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs index ea3cd5335..c9fd172a7 100644 --- a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs +++ b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs @@ -30,7 +30,7 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { - if (!(m is BaseCreature || m is PlayerMobile)) + if (m is not (BaseCreature or PlayerMobile)) { Caster.SendLocalizedMessage(1060508); // You can't curse that. } diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index abb0895ef..bf5c5c019 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -140,7 +140,7 @@ namespace Server.Spells.Seventh public override bool OnMoveOver(Mobile m) { - if (!(m is PlayerMobile)) + if (m is not PlayerMobile) { return base.OnMoveOver(m); } diff --git a/Projects/UOContent/Spells/Third/MagicLock.cs b/Projects/UOContent/Spells/Third/MagicLock.cs index 76b0ef7a6..c9cfef434 100644 --- a/Projects/UOContent/Spells/Third/MagicLock.cs +++ b/Projects/UOContent/Spells/Third/MagicLock.cs @@ -24,7 +24,7 @@ namespace Server.Spells.Third public void Target(Item item) { - if (!(item is LockableContainer cont)) + if (item is not LockableContainer cont) { Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest. } diff --git a/Projects/UOContent/Spells/Third/Teleport.cs b/Projects/UOContent/Spells/Third/Teleport.cs index 9e2b2236a..eda47e8fc 100644 --- a/Projects/UOContent/Spells/Third/Teleport.cs +++ b/Projects/UOContent/Spells/Third/Teleport.cs @@ -98,8 +98,8 @@ namespace Server.Spells.Third foreach (var item in eable) { - if (item is ParalyzeFieldSpell.InternalItem || item is PoisonFieldSpell.InternalItem || - item is FireFieldSpell.FireFieldItem) + if (item is ParalyzeFieldSpell.InternalItem or + PoisonFieldSpell.InternalItem or FireFieldSpell.FireFieldItem) { item.OnMoveOver(m); } diff --git a/Projects/UOContent/Spells/Third/Unlock.cs b/Projects/UOContent/Spells/Third/Unlock.cs index 715cf1e82..a29040d06 100644 --- a/Projects/UOContent/Spells/Third/Unlock.cs +++ b/Projects/UOContent/Spells/Third/Unlock.cs @@ -42,7 +42,7 @@ namespace Server.Spells.Third { Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked. } - else if (!(p is LockableContainer cont)) + else if (p is not LockableContainer cont) { Caster.SendLocalizedMessage(501666); // You can't unlock that! } diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index 0be6b4b9c..98d239a07 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -149,7 +149,7 @@ namespace Server.Spells.Third if (m is PlayerMobile) { var noto = Notoriety.Compute(m_Caster, m); - if (noto == Notoriety.Enemy || noto == Notoriety.Ally) + if (noto is Notoriety.Enemy or Notoriety.Ally) { return false; }