Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ namespace Server.Spells.Spellweaving
|
|||
-1
|
||||
);
|
||||
|
||||
public ArcaneCircleSpell(Mobile caster, Item scroll)
|
||||
public ArcaneCircleSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -91,23 +92,14 @@ namespace Server.Spells.Spellweaving
|
|||
return true;
|
||||
}
|
||||
|
||||
IPooledEnumerable<Item> eable = map.GetItemsInRange(location, 0); // Added Tiles
|
||||
IPooledEnumerable<Item> eable = map.GetItemsInRange(location, 0);
|
||||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
ItemData id = item.ItemData;
|
||||
|
||||
if (item.Z + id.CalcHeight != location.Z)
|
||||
continue;
|
||||
if (IsValidTile(item.ItemID))
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool found = eable.Any(item =>
|
||||
item.Z + item.ItemData.CalcHeight == location.Z && IsValidTile(item.ItemID));
|
||||
|
||||
eable.Free();
|
||||
return false;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public static bool IsValidTile(int itemID)
|
||||
|
|
@ -123,11 +115,10 @@ namespace Server.Spells.Spellweaving
|
|||
List<Mobile> weavers = new List<Mobile> { Caster };
|
||||
|
||||
//OSI Verified: Even enemies/combatants count
|
||||
foreach (Mobile m in Caster.GetMobilesInRange(1)) //Range verified as 1
|
||||
if (m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) &&
|
||||
Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20)
|
||||
weavers.Add(m);
|
||||
// Everyone gets the Arcane Focus, power capped elsewhere
|
||||
weavers.AddRange(Caster.GetMobilesInRange(1)
|
||||
.Where(m => m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) &&
|
||||
Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20));
|
||||
|
||||
return weavers;
|
||||
}
|
||||
|
|
@ -163,4 +154,4 @@ namespace Server.Spells.Spellweaving
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,32 +27,17 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
ArcaneFocus focus = FindArcaneFocus(from);
|
||||
|
||||
if (focus == null || focus.Deleted)
|
||||
return 0;
|
||||
|
||||
return focus.StrengthBonus;
|
||||
return focus?.Deleted != false ? 0 : focus.StrengthBonus;
|
||||
}
|
||||
|
||||
public static ArcaneFocus FindArcaneFocus(Mobile from)
|
||||
{
|
||||
if (from?.Backpack == null)
|
||||
return null;
|
||||
|
||||
if (from.Holding is ArcaneFocus focus)
|
||||
return focus;
|
||||
|
||||
return from.Backpack.FindItemByType<ArcaneFocus>();
|
||||
return from.Holding as ArcaneFocus ?? from.Backpack?.FindItemByType<ArcaneFocus>();
|
||||
}
|
||||
|
||||
public static bool CheckExpansion(Mobile from)
|
||||
{
|
||||
if (!(from is PlayerMobile))
|
||||
return true;
|
||||
|
||||
if (from.NetState == null)
|
||||
return false;
|
||||
|
||||
return from.NetState.SupportsExpansion(Expansion.ML);
|
||||
return !(from is PlayerMobile) || from.NetState?.SupportsExpansion(Expansion.ML) == true;
|
||||
}
|
||||
|
||||
public override bool CheckCast()
|
||||
|
|
@ -158,4 +143,4 @@ namespace Server.Spells.Spellweaving
|
|||
return percent >= Utility.RandomDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
|
||||
|
||||
public AttuneWeaponSpell(Mobile caster, Item scroll)
|
||||
public AttuneWeaponSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Spells.Spellweaving
|
||||
{
|
||||
|
|
@ -9,7 +10,7 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
private static Dictionary<Mobile, EssenceOfWindInfo> m_Table = new Dictionary<Mobile, EssenceOfWindInfo>();
|
||||
|
||||
public EssenceOfWindSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public EssenceOfWindSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -34,29 +35,28 @@ namespace Server.Spells.Spellweaving
|
|||
int fcMalus = FocusLevel + 1;
|
||||
int ssiMalus = 2 * (FocusLevel + 1);
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
IPooledEnumerable<Mobile> eable = Caster.GetMobilesInRange(range);
|
||||
|
||||
foreach (Mobile m in Caster.GetMobilesInRange(range))
|
||||
if (Caster != m && Caster.InLOS(m) && SpellHelper.ValidIndirectTarget(Caster, m) &&
|
||||
Caster.CanBeHarmful(m, false))
|
||||
targets.Add(m);
|
||||
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
if (Caster == m || !Caster.InLOS(m) || !SpellHelper.ValidIndirectTarget(Caster, m) ||
|
||||
!Caster.CanBeHarmful(m, false))
|
||||
continue;
|
||||
|
||||
Caster.DoHarmful(m);
|
||||
|
||||
SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0);
|
||||
|
||||
if (!CheckResisted(m)) //No message on resist
|
||||
{
|
||||
m_Table[m] = new EssenceOfWindInfo(m, fcMalus, ssiMalus, duration);
|
||||
if (CheckResisted(m))
|
||||
continue;
|
||||
|
||||
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EssenceOfWind, 1075802, duration, m,
|
||||
$"{fcMalus.ToString()}\t{ssiMalus.ToString()}"));
|
||||
}
|
||||
m_Table[m] = new EssenceOfWindInfo(m, fcMalus, ssiMalus, duration);
|
||||
|
||||
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EssenceOfWind, 1075802, duration, m,
|
||||
$"{fcMalus.ToString()}\t{ssiMalus.ToString()}"));
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Server.Spells.Spellweaving
|
|||
-1
|
||||
);
|
||||
|
||||
public EtherealVoyageSpell(Mobile caster, Item scroll)
|
||||
public EtherealVoyageSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -73,4 +73,4 @@ namespace Server.Spells.Spellweaving
|
|||
BuffInfo.RemoveBuff(m, BuffIcon.EtherealVoyage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
|
||||
|
||||
public GiftOfLifeSpell(Mobile caster, Item scroll)
|
||||
public GiftOfLifeSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
private static Dictionary<Mobile, GiftOfRenewalInfo> m_Table = new Dictionary<Mobile, GiftOfRenewalInfo>();
|
||||
|
||||
public GiftOfRenewalSpell(Mobile caster, Item scroll)
|
||||
public GiftOfRenewalSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Server.Spells.Spellweaving
|
|||
private static Dictionary<BaseWeapon, ImmolatingWeaponEntry> m_WeaponDamageTable =
|
||||
new Dictionary<BaseWeapon, ImmolatingWeaponEntry>();
|
||||
|
||||
public ImmolatingWeaponSpell(Mobile caster, Item scroll)
|
||||
public ImmolatingWeaponSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Spells.Spellweaving
|
|||
false
|
||||
);
|
||||
|
||||
public NatureFurySpell(Mobile caster, Item scroll)
|
||||
public NatureFurySpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -50,9 +50,7 @@ namespace Server.Spells.Spellweaving
|
|||
if (map == null)
|
||||
return;
|
||||
|
||||
HouseRegion r = Region.Find(p, map).GetRegion<HouseRegion>();
|
||||
|
||||
if (r?.House != null && !r.House.IsFriend(Caster))
|
||||
if (Region.Find(p, map).GetRegion<HouseRegion>()?.House?.IsFriend(Caster) == false)
|
||||
return;
|
||||
|
||||
if (!map.CanSpawnMobile(p.X, p.Y, p.Z))
|
||||
|
|
@ -118,4 +116,4 @@ namespace Server.Spells.Spellweaving
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
private static SpellInfo m_Info = new SpellInfo("Reaper Form", "Tarisstree", -1);
|
||||
|
||||
public ReaperFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public ReaperFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
TransformContext context = TransformationSpellHelper.GetContext(e.Mobile);
|
||||
|
||||
if (context != null && context.Type == typeof(ReaperFormSpell))
|
||||
if (context?.Type == typeof(ReaperFormSpell))
|
||||
e.Mobile.Send(SpeedControl.WalkSpeed);
|
||||
}
|
||||
|
||||
|
|
@ -52,4 +52,4 @@ namespace Server.Spells.Spellweaving
|
|||
m.Send(SpeedControl.Disable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Spells.Spellweaving
|
|||
-1
|
||||
);
|
||||
|
||||
public SummonFeySpell(Mobile caster, Item scroll)
|
||||
public SummonFeySpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ namespace Server.Spells.Spellweaving
|
|||
return base.CheckSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Spells.Spellweaving
|
|||
-1
|
||||
);
|
||||
|
||||
public SummonFiendSpell(Mobile caster, Item scroll)
|
||||
public SummonFiendSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -42,4 +42,4 @@ namespace Server.Spells.Spellweaving
|
|||
return base.CheckSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Spells.Spellweaving
|
||||
{
|
||||
|
|
@ -12,7 +13,7 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
|
||||
|
||||
public ThunderstormSpell(Mobile caster, Item scroll)
|
||||
public ThunderstormSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -46,16 +47,13 @@ namespace Server.Spells.Spellweaving
|
|||
int range = 2 + FocusLevel;
|
||||
TimeSpan duration = TimeSpan.FromSeconds(5 + FocusLevel);
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
IPooledEnumerable<Mobile> eable = Caster.GetMobilesInRange(range);
|
||||
|
||||
foreach (Mobile m in Caster.GetMobilesInRange(range))
|
||||
if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) &&
|
||||
Caster.InLOS(m))
|
||||
targets.Add(m);
|
||||
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) ||
|
||||
!Caster.InLOS(m))
|
||||
continue;
|
||||
|
||||
Caster.DoHarmful(m);
|
||||
|
||||
|
|
@ -63,14 +61,16 @@ namespace Server.Spells.Spellweaving
|
|||
|
||||
SpellHelper.Damage(this, m, m.Player && Caster.Player ? pvpDamage : pvmDamage, 0, 0, 0, 0, 100);
|
||||
|
||||
if (oldSpell != null && oldSpell != m.Spell && !CheckResisted(m))
|
||||
{
|
||||
m_Table[m] = Timer.DelayCall(duration, DoExpire, m);
|
||||
if (oldSpell == null || oldSpell == m.Spell || CheckResisted(m))
|
||||
continue;
|
||||
|
||||
BuffInfo.AddBuff(m,
|
||||
new BuffInfo(BuffIcon.Thunderstorm, 1075800, duration, m, GetCastRecoveryMalus(m)));
|
||||
}
|
||||
m_Table[m] = Timer.DelayCall(duration, DoExpire, m);
|
||||
|
||||
BuffInfo.AddBuff(m,
|
||||
new BuffInfo(BuffIcon.Thunderstorm, 1075800, duration, m, GetCastRecoveryMalus(m)));
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
private static SpellInfo m_Info = new SpellInfo("Word of Death", "Nyraxle", -1);
|
||||
|
||||
public WordOfDeathSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public WordOfDeathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -85,4 +85,4 @@ namespace Server.Spells.Spellweaving
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue