fix: Cleans up more spells (#1121)

This commit is contained in:
Kamron Batman 2022-07-16 22:32:51 -07:00 • committed by GitHub
parent fa3515f930
commit 068bafd9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 339 additions and 439 deletions

View file

@ -1,5 +1,5 @@
using System;
using System.Collections.Generic;
using Server.Collections;
using Server.Items;
using Server.Mobiles;
@ -13,8 +13,7 @@ namespace Server.Spells.Spellweaving
-1
);
public ArcaneCircleSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public ArcaneCircleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -27,13 +26,12 @@ namespace Server.Spells.Spellweaving
{
if (!IsValidLocation(Caster.Location, Caster.Map))
{
Caster.SendLocalizedMessage(
1072705
); // You must be standing on an arcane circle, pentagram or abbatoir to use this spell.
// You must be standing on an arcane circle, pentagram or abattoir to use this spell.
Caster.SendLocalizedMessage(1072705);
return false;
}
if (GetArcanists().Count < 2)
if (!CheckArcanists())
{
Caster.SendLocalizedMessage(1080452); // There are not enough spellweavers present to create an Arcane Focus.
return false;
@ -49,21 +47,18 @@ namespace Server.Spells.Spellweaving
Caster.FixedParticles(0x3779, 10, 20, 0x0, EffectLayer.Waist);
Caster.PlaySound(0x5C0);
var Arcanists = GetArcanists();
var spellWeaving = Caster.Skills.Spellweaving.Value;
using var pool = GetArcanists(spellWeaving);
var duration = TimeSpan.FromHours(Math.Max(1, (int)(Caster.Skills.Spellweaving.Value / 24)));
var duration = TimeSpan.FromHours(Math.Max(1, (int)(spellWeaving / 24)));
var strengthBonus =
Math.Min(
Arcanists.Count,
IsSanctuary(Caster.Location, Caster.Map)
? 6
: 5
); // The Sanctuary is a special, single location place
Math.Min(pool.Count, IsSanctuary(Caster.Location, Caster.Map) ? 6 : 5);
for (var i = 0; i < Arcanists.Count; i++)
while (pool.Count > 0)
{
GiveArcaneFocus(Arcanists[i], duration, strengthBonus);
var m = pool.Dequeue();
GiveArcaneFocus(m, duration, strengthBonus);
}
}
@ -108,6 +103,7 @@ namespace Server.Spells.Spellweaving
{
if (item.Z + item.ItemData.CalcHeight == location.Z && IsValidTile(item.ItemID))
{
eable.Free();
return true;
}
}
@ -120,27 +116,43 @@ namespace Server.Spells.Spellweaving
public static bool IsValidTile(int itemID) =>
itemID is 0xFEA or 0x1216 or 0x307F or 0x1D10 or 0x1D0F or 0x1D1F or 0x1D12;
private List<Mobile> GetArcanists()
private bool CheckArcanists()
{
var weavers = new List<Mobile> { Caster };
var spellWeaving = Caster.Skills.Spellweaving.Value;
var eable = Caster.GetMobilesInRange(1);
foreach (var m in eable)
{
if (m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) &&
Math.Abs(spellWeaving - m.Skills.Spellweaving.Value) <= 20)
{
eable.Free();
return true;
}
}
eable.Free();
return false;
}
private PooledRefQueue<Mobile> GetArcanists(double spellWeaving)
{
// OSI Verified: Even enemies/combatants count
// Everyone gets the Arcane Focus, power capped elsewhere
var pool = PooledRefQueue<Mobile>.Create();
var eable = Caster.GetMobilesInRange(1);
foreach (var m in eable)
{
if (m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) &&
Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20)
Math.Abs(spellWeaving - m.Skills.Spellweaving.Value) <= 20)
{
weavers.Add(m);
pool.Enqueue(m);
}
}
eable.Free();
return weavers;
return pool;
}
private void GiveArcaneFocus(Mobile to, TimeSpan duration, int strengthBonus)

View file

@ -29,15 +29,7 @@ namespace Server.Spells.Spellweaving
{
}
public override bool CheckCast()
{
if (!TransformationSpellHelper.CheckCast(Caster, this))
{
return false;
}
return base.CheckCast();
}
public override bool CheckCast() => TransformationSpellHelper.CheckCast(Caster, this) && base.CheckCast();
public override void OnCast()
{

View file

@ -8,8 +8,7 @@ namespace Server.Spells.Spellweaving
{
private int m_CastTimeFocusLevel;
public ArcanistSpell(Mobile caster, Item scroll, SpellInfo info)
: base(caster, scroll, info)
public ArcanistSpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
{
}
@ -47,9 +46,8 @@ namespace Server.Spells.Spellweaving
if (!CheckExpansion(caster))
{
caster.SendLocalizedMessage(
1072176
); // You must upgrade to the Mondain's Legacy Expansion Pack before using that ability
// You must upgrade to the Mondain's Legacy Expansion Pack before using that ability
caster.SendLocalizedMessage(1072176);
return false;
}
@ -59,9 +57,8 @@ namespace Server.Spells.Spellweaving
if (context?.Spellweaving != true)
{
mobile.SendLocalizedMessage(
1073220
); // You must have completed the epic arcanist quest to use this ability.
// You must have completed the epic arcanist quest to use this ability.
mobile.SendLocalizedMessage(1073220);
return false;
}
}
@ -70,19 +67,15 @@ namespace Server.Spells.Spellweaving
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)
{
caster.SendLocalizedMessage(
1063013,
$"{RequiredSkill:F1}\t{"#1044114"}"
); // 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{"#1044114"}");
return false;
}
@ -137,17 +130,12 @@ namespace Server.Spells.Spellweaving
(50 + 2 * (GetResistSkill(m) - GetDamageSkill(Caster))) /
100; // TODO: According to the guide this is it.. but.. is it correct per OSI?
if (percent <= 0)
return percent switch
{
return false;
}
if (percent >= 1.0)
{
return true;
}
return percent >= Utility.RandomDouble();
<= 0 => false,
>= 1.0 => true,
_ => percent >= Utility.RandomDouble()
};
}
}
}

View file

@ -83,10 +83,8 @@ namespace Server.Spells.Spellweaving
damage -= absorbed;
defender.MeleeDamageAbsorb -= absorbed;
defender.SendLocalizedMessage(
1075127,
$"{absorbed}\t{defender.MeleeDamageAbsorb}"
); // ~1_damage~ point(s) of damage have been absorbed. A total of ~2_remaining~ point(s) of shielding remain.
// ~1_damage~ point(s) of damage have been absorbed. A total of ~2_remaining~ point(s) of shielding remain.
defender.SendLocalizedMessage(1075127, $"{absorbed}\t{defender.MeleeDamageAbsorb}");
if (defender.MeleeDamageAbsorb <= 0)
{

View file

@ -60,13 +60,7 @@ namespace Server.Spells.Spellweaving
BuffInfo.AddBuff(
m,
new BuffInfo(
BuffIcon.EssenceOfWind,
1075802,
duration,
m,
$"{fcMalus.ToString()}\t{ssiMalus.ToString()}"
)
new BuffInfo(BuffIcon.EssenceOfWind, 1075802, duration, m, $"{fcMalus}\t{ssiMalus}")
);
}
@ -82,19 +76,19 @@ namespace Server.Spells.Spellweaving
public static bool IsDebuffed(Mobile m) => _table.ContainsKey(m);
public static void StopDebuffing(Mobile m, bool message)
public static void StopDebuffing(Mobile m)
{
if (_table.TryGetValue(m, out var timer))
{
timer.DoExpire(message);
timer.DoExpire();
}
}
private class EssenceOfWindTimer : Timer
{
private readonly Mobile _defender;
internal readonly int _fcMalus;
internal readonly int _ssiMalus;
private Mobile _defender;
internal int _fcMalus;
internal int _ssiMalus;
internal EssenceOfWindTimer(Mobile defender, int fcMalus, int ssiMalus, TimeSpan duration) : base(duration)
{
@ -108,7 +102,7 @@ namespace Server.Spells.Spellweaving
DoExpire();
}
internal void DoExpire(bool message = true)
internal void DoExpire()
{
Stop();
_table.Remove(_defender);

View file

@ -10,8 +10,7 @@ namespace Server.Spells.Spellweaving
-1
);
public EtherealVoyageSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public EtherealVoyageSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -69,9 +68,8 @@ namespace Server.Spells.Spellweaving
Timer.StartTimer(duration, () => RemoveEffect(Caster));
Caster.BeginAction(
typeof(EtherealVoyageSpell)
); // Cannot cast this spell for another 5 minutes(300sec) after effect removed.
// Cannot cast this spell for another 5 minutes(300sec) after effect removed.
Caster.BeginAction<EtherealVoyageSpell>();
BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.EtherealVoyage, 1031613, 1075805, duration, Caster));
}

View file

@ -16,8 +16,7 @@ namespace Server.Spells.Spellweaving
private static readonly Dictionary<Mobile, ExpireTimer> _table = new();
public GiftOfLifeSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public GiftOfLifeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -34,7 +33,7 @@ namespace Server.Spells.Spellweaving
{
// As per Osi: Nothing happens.
}
else if (m != Caster && !(m is BaseCreature bc && bc.IsBonded && bc.ControlMaster == Caster))
else if (m != Caster && !(m is BaseCreature { IsBonded: true } bc && bc.ControlMaster == Caster))
{
Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
@ -148,12 +147,11 @@ namespace Server.Spells.Spellweaving
private class ExpireTimer : Timer
{
private readonly Mobile m_Mobile;
private Mobile _mobile;
public ExpireTimer(Mobile m, TimeSpan delay, GiftOfLifeSpell spell)
: base(delay)
public ExpireTimer(Mobile m, TimeSpan delay, GiftOfLifeSpell spell) : base(delay)
{
m_Mobile = m;
_mobile = m;
Spell = spell;
}
@ -168,10 +166,10 @@ namespace Server.Spells.Spellweaving
{
Stop();
m_Mobile.SendLocalizedMessage(1074776); // You are no longer protected with Gift of Life.
_table.Remove(m_Mobile);
_mobile.SendLocalizedMessage(1074776); // You are no longer protected with Gift of Life.
_table.Remove(_mobile);
BuffInfo.RemoveBuff(m_Mobile, BuffIcon.GiftOfLife);
BuffInfo.RemoveBuff(_mobile, BuffIcon.GiftOfLife);
}
}
}

View file

@ -14,8 +14,7 @@ namespace Server.Spells.Spellweaving
private static readonly Dictionary<Mobile, GiftOfRenewalTimer> _table = new();
public GiftOfRenewalSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public GiftOfRenewalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -82,7 +81,7 @@ namespace Server.Spells.Spellweaving
if (_table.Remove(m, out var timer))
{
timer.Stop();
Timer.StartTimer(TimeSpan.FromSeconds(60), timer.m_Caster.EndAction<GiftOfRenewalSpell>);
Timer.StartTimer(TimeSpan.FromSeconds(60), timer._caster.EndAction<GiftOfRenewalSpell>);
return true;
}
@ -91,52 +90,50 @@ namespace Server.Spells.Spellweaving
private class GiftOfRenewalTimer : Timer
{
public readonly Mobile m_Caster;
public readonly int m_HitsPerRound;
public readonly Mobile m_Mobile;
public Mobile _caster;
public int _hitsPerRound;
public Mobile _mobile;
internal GiftOfRenewalTimer(Mobile caster, Mobile mobile, int hitsPerRound, int duration)
: base(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0), duration / 2)
{
m_Caster = caster;
m_Mobile = mobile;
m_HitsPerRound = hitsPerRound;
_caster = caster;
_mobile = mobile;
_hitsPerRound = hitsPerRound;
}
protected override void OnTick()
{
if (Index + 1 == Count)
{
StopEffect(m_Mobile);
m_Mobile.PlaySound(0x455);
m_Mobile.SendLocalizedMessage(1075071); // The Gift of Renewal has faded.
StopEffect(_mobile);
_mobile.PlaySound(0x455);
_mobile.SendLocalizedMessage(1075071); // The Gift of Renewal has faded.
return;
}
var m = m_Mobile;
if (!_table.ContainsKey(m))
if (!_table.ContainsKey(_mobile))
{
Stop();
return;
}
if (!m.Alive)
if (!_mobile.Alive)
{
Stop();
StopEffect(m);
StopEffect(_mobile);
return;
}
if (m.Hits >= m.HitsMax)
if (_mobile.Hits >= _mobile.HitsMax)
{
return;
}
var toHeal = m_HitsPerRound;
var toHeal = _hitsPerRound;
SpellHelper.Heal(toHeal, m, m_Caster);
m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
SpellHelper.Heal(toHeal, _mobile, _caster);
_mobile.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
}
}
}

View file

@ -14,8 +14,7 @@ namespace Server.Spells.Spellweaving
private static readonly Dictionary<BaseWeapon, ImmolatingWeaponTimer> _table = new();
public ImmolatingWeaponSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public ImmolatingWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -97,9 +96,9 @@ namespace Server.Spells.Spellweaving
private class ImmolatingWeaponTimer : Timer
{
public readonly Mobile _caster;
public readonly int _damage;
public readonly BaseWeapon _weapon;
public Mobile _caster;
public int _damage;
public BaseWeapon _weapon;
public ImmolatingWeaponTimer(TimeSpan duration, int damage, Mobile caster, BaseWeapon weapon) : base(duration)
{

View file

@ -14,8 +14,7 @@ namespace Server.Spells.Spellweaving
false
);
public NatureFurySpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public NatureFurySpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -79,22 +78,21 @@ namespace Server.Spells.Spellweaving
private class InternalTimer : Timer
{
private readonly NatureFury m_NatureFury;
private readonly NatureFury _natureFury;
public InternalTimer(NatureFury nf)
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) =>
m_NatureFury = nf;
public InternalTimer(NatureFury nf) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) =>
_natureFury = nf;
protected override void OnTick()
{
if (m_NatureFury.Deleted || !m_NatureFury.Alive || m_NatureFury.DamageMin > 20)
if (_natureFury.Deleted || !_natureFury.Alive || _natureFury.DamageMin > 20)
{
Stop();
}
else
{
++m_NatureFury.DamageMin;
++m_NatureFury.DamageMax;
++_natureFury.DamageMin;
++_natureFury.DamageMax;
}
}
}

View file

@ -12,8 +12,7 @@ namespace Server.Spells.Spellweaving
-1
);
public SummonFeySpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public SummonFeySpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -26,18 +25,15 @@ namespace Server.Spells.Spellweaving
public override bool CheckSequence()
{
var caster = Caster;
// This is done after casting completes
if (caster is PlayerMobile mobile)
if (Caster is PlayerMobile mobile)
{
var context = MLQuestSystem.GetContext(mobile);
if (context?.SummonFey != true)
{
mobile.SendLocalizedMessage(
1074563
); // You haven't forged a friendship with the fey and are unable to summon their aid.
// You haven't forged a friendship with the fey and are unable to summon their aid.
mobile.SendLocalizedMessage(1074563);
return false;
}
}

View file

@ -12,8 +12,7 @@ namespace Server.Spells.Spellweaving
-1
);
public SummonFiendSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public SummonFiendSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
@ -26,10 +25,8 @@ namespace Server.Spells.Spellweaving
public override bool CheckSequence()
{
var caster = Caster;
// This is done after casting completes
if (caster is PlayerMobile mobile)
if (Caster is PlayerMobile mobile)
{
var context = MLQuestSystem.GetContext(mobile);

View file

@ -13,8 +13,7 @@ namespace Server.Spells.Spellweaving
private static readonly Dictionary<Mobile, TimerExecutionToken> _table = new();
public ThunderstormSpell(Mobile caster, Item scroll = null)
: base(caster, scroll, _info)
public ThunderstormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}