From 56c97ca84adefa51d3b325ece1e25f9919937b09 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 15 Jul 2022 12:49:14 -0700 Subject: [PATCH] fix: Fixes spell durations for older expansions (#1119) --- Projects/UOContent/Spells/Base/SpellHelper.cs | 5 +- Projects/UOContent/Spells/Fifth/Incognito.cs | 7 +- .../UOContent/Spells/Fifth/PoisonField.cs | 7 +- .../UOContent/Spells/Fifth/SummonCreature.cs | 13 ++-- Projects/UOContent/Spells/Fourth/FireField.cs | 9 ++- .../UOContent/Spells/Seventh/GateTravel.cs | 8 +-- .../UOContent/Spells/Seventh/Polymorph.cs | 69 ++++++++++--------- .../UOContent/Spells/Sixth/ParalyzeField.cs | 9 ++- 8 files changed, 68 insertions(+), 59 deletions(-) diff --git a/Projects/UOContent/Spells/Base/SpellHelper.cs b/Projects/UOContent/Spells/Base/SpellHelper.cs index 787fddb03..d04a16c10 100644 --- a/Projects/UOContent/Spells/Base/SpellHelper.cs +++ b/Projects/UOContent/Spells/Base/SpellHelper.cs @@ -353,9 +353,8 @@ namespace Server.Spells } public static TimeSpan GetDuration(Mobile caster, Mobile target) => - Core.AOS - ? TimeSpan.FromSeconds(6 * caster.Skills.EvalInt.Fixed / 50 + 1) - : TimeSpan.FromSeconds(caster.Skills.Magery.Value * 1.2); + // TODO: Is this accurate for Curse? Sources say it is magery. Should confirm at least for newest era. + TimeSpan.FromSeconds(6 * (Core.AOS ? caster.Skills.EvalInt.Value : caster.Skills.Magery.Value) / 5.0); public static double GetOffsetScalar(Mobile caster, Mobile target, bool curse) { diff --git a/Projects/UOContent/Spells/Fifth/Incognito.cs b/Projects/UOContent/Spells/Fifth/Incognito.cs index 978af3dfa..39028b68d 100644 --- a/Projects/UOContent/Spells/Fifth/Incognito.cs +++ b/Projects/UOContent/Spells/Fifth/Incognito.cs @@ -108,13 +108,12 @@ namespace Server.Spells.Fifth StopTimer(Caster); - var timeVal = Math.Min(6 * Caster.Skills.Magery.Fixed / 50 + 1, 144); + var duration = TimeSpan.FromSeconds(Math.Min(6 * Caster.Skills.Magery.Value / 5.0, 144)); - var length = TimeSpan.FromSeconds(timeVal); - Timer.StartTimer(length, () => EndIncognito(Caster), out var timerToken); + Timer.StartTimer(duration, () => EndIncognito(Caster), out var timerToken); _table[Caster] = timerToken; - BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.Incognito, 1075819, length, Caster)); + BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.Incognito, 1075819, duration, Caster)); } else { diff --git a/Projects/UOContent/Spells/Fifth/PoisonField.cs b/Projects/UOContent/Spells/Fifth/PoisonField.cs index 80bada423..116dabeab 100644 --- a/Projects/UOContent/Spells/Fifth/PoisonField.cs +++ b/Projects/UOContent/Spells/Fifth/PoisonField.cs @@ -38,7 +38,12 @@ namespace Server.Spells.Fifth Effects.PlaySound(loc, Caster.Map, 0x20B); var itemID = eastToWest ? 0x3915 : 0x3922; - var duration = TimeSpan.FromSeconds(3 + Caster.Skills.Magery.Fixed / 25); + var duration = Core.Expansion switch + { + Expansion.None => TimeSpan.FromSeconds(20), + < Expansion.LBR => TimeSpan.FromSeconds(15 + Caster.Skills.Magery.Value * 0.4), + _ => TimeSpan.FromSeconds(3 + Caster.Skills.Magery.Fixed * 0.4) + }; for (var i = -2; i <= 2; ++i) { diff --git a/Projects/UOContent/Spells/Fifth/SummonCreature.cs b/Projects/UOContent/Spells/Fifth/SummonCreature.cs index b8a4103e1..639b82d86 100644 --- a/Projects/UOContent/Spells/Fifth/SummonCreature.cs +++ b/Projects/UOContent/Spells/Fifth/SummonCreature.cs @@ -72,16 +72,11 @@ namespace Server.Spells.Fifth // creature.ControlSlots = 2; - TimeSpan duration; - - if (Core.AOS) + var duration = Core.Expansion switch { - duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5.0); - } - else - { - duration = TimeSpan.FromSeconds(4.0 * Caster.Skills.Magery.Value); - } + Expansion.None => TimeSpan.FromSeconds(Caster.Skills.Magery.Value), + _ => TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5.0) + }; SpellHelper.Summon(creature, Caster, 0x215, duration, false, false); } diff --git a/Projects/UOContent/Spells/Fourth/FireField.cs b/Projects/UOContent/Spells/Fourth/FireField.cs index 91ca1b8bb..f412369f6 100644 --- a/Projects/UOContent/Spells/Fourth/FireField.cs +++ b/Projects/UOContent/Spells/Fourth/FireField.cs @@ -41,9 +41,12 @@ namespace Server.Spells.Fourth var itemID = eastToWest ? 0x398C : 0x3996; - var duration = Core.AOS - ? TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5.0) / 4.0) - : TimeSpan.FromSeconds(4.0 + Caster.Skills.Magery.Value * 0.5); + var duration = Core.Expansion switch + { + Expansion.None => TimeSpan.FromSeconds(20), + < Expansion.LBR => TimeSpan.FromSeconds(Caster.Skills.Magery.Value), + _ => TimeSpan.FromSeconds(4.0 + Caster.Skills.Magery.Value * 0.5) + }; for (var i = -2; i <= 2; ++i) { diff --git a/Projects/UOContent/Spells/Seventh/GateTravel.cs b/Projects/UOContent/Spells/Seventh/GateTravel.cs index 5377ddb22..83d46565c 100644 --- a/Projects/UOContent/Spells/Seventh/GateTravel.cs +++ b/Projects/UOContent/Spells/Seventh/GateTravel.cs @@ -69,8 +69,8 @@ namespace Server.Spells.Seventh { Caster.SendLocalizedMessage(501942); // That location is blocked. } - else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location)) - ) // SE restricted stacking gates + // SE restricted stacking gates + else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location))) { Caster.SendLocalizedMessage(1071242); // There is already a gate there. } @@ -127,7 +127,7 @@ namespace Server.Spells.Seventh return SpellHelper.CheckTravel(Caster, TravelCheckType.GateFrom); } - private bool GateExistsAt(Map map, Point3D loc) + private static bool GateExistsAt(Map map, Point3D loc) { var eable = map.GetItemsInRange(loc, 0); @@ -182,7 +182,7 @@ namespace Server.Spells.Seventh { private readonly Item m_Item; - public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0)) + public InternalTimer(Item item) : base(TimeSpan.FromSeconds(Core.T2A ? 30.0 : 10.0)) { m_Item = item; } diff --git a/Projects/UOContent/Spells/Seventh/Polymorph.cs b/Projects/UOContent/Spells/Seventh/Polymorph.cs index e4631aec0..c8eb67b10 100644 --- a/Projects/UOContent/Spells/Seventh/Polymorph.cs +++ b/Projects/UOContent/Spells/Seventh/Polymorph.cs @@ -142,41 +142,44 @@ namespace Server.Spells.Seventh if (CheckSequence()) { - if (caster.BeginAction()) - { - if (m_NewBody != 0) - { - if (!((Body)m_NewBody).IsHuman) - { - var mt = caster.Mount; - - if (mt != null) - { - mt.Rider = null; - } - } - - caster.BodyMod = m_NewBody; - - caster.HueMod = m_NewBody is 400 or 401 ? caster.Race.RandomSkinHue() : 0; - - BaseArmor.ValidateMobile(caster); - BaseClothing.ValidateMobile(caster); - - if (!Core.ML) - { - StopTimer(caster); - - var duration = Math.Max((int)caster.Skills.Magery.Value, 120); - - Timer.StartTimer(TimeSpan.FromSeconds(duration), () => EndPolymorph(caster), out var timerToken); - _table[caster] = timerToken; - } - } - } - else + if (!caster.BeginAction()) { caster.SendLocalizedMessage(1005559); // This spell is already in effect. + return; + } + + if (m_NewBody != 0) + { + if (!((Body)m_NewBody).IsHuman) + { + var mt = caster.Mount; + + if (mt != null) + { + mt.Rider = null; + } + } + + caster.BodyMod = m_NewBody; + + caster.HueMod = m_NewBody is 400 or 401 ? caster.Race.RandomSkinHue() : 0; + + BaseArmor.ValidateMobile(caster); + BaseClothing.ValidateMobile(caster); + + if (!Core.ML) + { + StopTimer(caster); + + var duration = Core.Expansion switch + { + Expansion.None => TimeSpan.FromSeconds(6 * caster.Skills.Magery.Value / 5.0), + _ => TimeSpan.FromSeconds(Math.Max(caster.Skills.Magery.Value, 120)) + }; + + Timer.StartTimer(duration, () => EndPolymorph(caster), out var timerToken); + _table[caster] = timerToken; + } } } diff --git a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs index 0edd387b3..ac20ce7dd 100644 --- a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs +++ b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs @@ -38,7 +38,12 @@ namespace Server.Spells.Sixth var itemID = eastToWest ? 0x3967 : 0x3979; - var duration = TimeSpan.FromSeconds(3.0 + Caster.Skills.Magery.Value / 3.0); + var duration = Core.Expansion switch + { + Expansion.None => TimeSpan.FromSeconds(20), + < Expansion.LBR => TimeSpan.FromSeconds(15.0 + Caster.Skills.Magery.Value / 3.0), + _ => TimeSpan.FromSeconds(3.0 + Caster.Skills.Magery.Value / 3.0) + }; for (var i = -2; i <= 2; ++i) { @@ -179,7 +184,7 @@ namespace Server.Spells.Sixth } else { - duration = 7.0 + m_Caster.Skills.Magery.Value * 0.2; + duration = 7.0 + m_Caster.Skills.Magery.Value / 5; } m.Paralyze(TimeSpan.FromSeconds(duration));