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
|
|
@ -94,7 +94,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, List<Mobile>> m_Table = new Dictionary<Mobile, List<Mobile>>();
|
||||
|
||||
public AnimateDeadSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public AnimateDeadSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace Server.Spells.Necromancy
|
|||
{
|
||||
QuestObjective objective = qs.FindObjective<AnimateMaabusCorpseObjective>();
|
||||
|
||||
if (objective != null && !objective.Completed)
|
||||
if (objective?.Completed == false)
|
||||
{
|
||||
addon.Awake(Caster);
|
||||
objective.Complete();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
|
@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy
|
|||
private static Dictionary<Mobile, Mobile> m_OathTable = new Dictionary<Mobile, Mobile>();
|
||||
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
|
||||
|
||||
public BloodOathSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public BloodOathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -17,7 +16,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
|
||||
|
||||
public CorpseSkinSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public CorpseSkinSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<BaseWeapon, ExpireTimer> m_Table = new Dictionary<BaseWeapon, ExpireTimer>();
|
||||
|
||||
public CurseWeaponSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public CurseWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
|
@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, DefaultSkillMod> m_Table = new Dictionary<Mobile, DefaultSkillMod>();
|
||||
|
||||
public EvilOmenSpell(Mobile caster, Item scroll)
|
||||
public EvilOmenSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Engines.CannedEvil;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Factions;
|
||||
|
|
@ -57,7 +58,7 @@ namespace Server.Spells.Necromancy
|
|||
new Point3D(295, 712, 55)
|
||||
};
|
||||
|
||||
public ExorcismSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public ExorcismSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -98,17 +99,11 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
if (map != null)
|
||||
{
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
IEnumerable<Mobile> targets = r.ChampionSpawn.GetMobilesInRange(Range).Where(IsValidTarget);
|
||||
|
||||
foreach (Mobile m in r.ChampionSpawn.GetMobilesInRange(Range))
|
||||
if (IsValidTarget(m))
|
||||
targets.Add(m);
|
||||
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
foreach (Mobile m in targets)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
|
||||
//Suprisingly, no sparkle type effects
|
||||
//Surprisingly, no sparkle type effects
|
||||
|
||||
m.Location = GetNearestShrine(m);
|
||||
}
|
||||
|
|
@ -126,7 +121,7 @@ namespace Server.Spells.Necromancy
|
|||
Corpse c = m.Corpse as Corpse;
|
||||
Map map = m.Map;
|
||||
|
||||
if (c != null && !c.Deleted && map != null && c.Map == map)
|
||||
if (c?.Deleted == false && map != null && c.Map == map)
|
||||
{
|
||||
if (SpellHelper.IsAnyT2A(map, c.Location) && SpellHelper.IsAnyT2A(map, m.Location))
|
||||
return false; //Same Map, both in T2A, ie, same 'sub server'.
|
||||
|
|
@ -134,12 +129,10 @@ namespace Server.Spells.Necromancy
|
|||
if (m.Region.IsPartOf<DungeonRegion>() == Region.Find(c.Location, map).IsPartOf<DungeonRegion>())
|
||||
return false; //Same Map, both in Dungeon region OR They're both NOT in a dungeon region.
|
||||
|
||||
//Just an approximation cause RunUO doens't divide up the world the same way OSI does ;p
|
||||
//Just an approximation cause RunUO doesn't divide up the world the same way OSI does ;p
|
||||
}
|
||||
|
||||
Party p = Party.Get(m);
|
||||
|
||||
if (p != null && p.Contains(Caster))
|
||||
if (Party.Get(m)?.Contains(Caster) == true)
|
||||
return false;
|
||||
|
||||
if (m.Guild != null && Caster.Guild != null)
|
||||
|
|
@ -156,10 +149,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
Faction f = Faction.Find(m);
|
||||
|
||||
if (Faction.Facet == m.Map && f != null && f == Faction.Find(Caster))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Faction.Facet != m.Map || f == null || f != Faction.Find(Caster);
|
||||
}
|
||||
|
||||
private static Point3D GetNearestShrine(Mobile m)
|
||||
|
|
@ -198,4 +188,4 @@ namespace Server.Spells.Necromancy
|
|||
return closest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.DaemonBlood
|
||||
);
|
||||
|
||||
public HorrificBeastSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public HorrificBeastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -37,4 +37,4 @@ namespace Server.Spells.Necromancy
|
|||
m.Delta(MobileDelta.WeaponDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.NoxCrystal
|
||||
);
|
||||
|
||||
public LichFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public LichFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -41,4 +41,4 @@ namespace Server.Spells.Necromancy
|
|||
--m.Hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, MRBucket> m_Table = new Dictionary<Mobile, MRBucket>();
|
||||
|
||||
public MindRotSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public MindRotSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Misc;
|
||||
using Server.Targeting;
|
||||
|
|
@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
|
||||
|
||||
public PainSpikeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public PainSpikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
|
@ -15,7 +16,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.NoxCrystal
|
||||
);
|
||||
|
||||
public PoisonStrikeSpell(Mobile caster, Item scroll)
|
||||
public PoisonStrikeSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -67,11 +68,8 @@ namespace Server.Spells.Necromancy
|
|||
if (Caster.CanBeHarmful(m, false))
|
||||
targets.Add(m);
|
||||
|
||||
foreach (Mobile targ in m.GetMobilesInRange(2))
|
||||
if (!(Caster is BaseCreature && targ is BaseCreature))
|
||||
if (targ != Caster && m != targ && SpellHelper.ValidIndirectTarget(Caster, targ) &&
|
||||
Caster.CanBeHarmful(targ, false))
|
||||
targets.Add(targ);
|
||||
targets.AddRange(m.GetMobilesInRange(2)
|
||||
.Where(targ => !(Caster is BaseCreature && targ is BaseCreature && targ != Caster && m != targ && SpellHelper.ValidIndirectTarget(Caster, targ) && Caster.CanBeHarmful(targ, false))));
|
||||
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
{
|
||||
|
|
@ -117,4 +115,4 @@ namespace Server.Spells.Necromancy
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -17,7 +16,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
|
||||
|
||||
public StrangleSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public StrangleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.DaemonBlood
|
||||
);
|
||||
|
||||
public SummonFamiliarSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public SummonFamiliarSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +110,7 @@ namespace Server.Spells.Necromancy
|
|||
AddItem(8, 15, 6882);
|
||||
AddItem(2, 168, 6880);
|
||||
|
||||
AddHtmlLocalized(30, 26, 200, 20, 1060147, EnabledColor16, false, false); // Chose thy familiar...
|
||||
AddHtmlLocalized(30, 26, 200, 20, 1060147, EnabledColor16); // Chose thy familiar...
|
||||
|
||||
double necro = from.Skills.Necromancy.Value;
|
||||
double spirit = from.Skills.SpiritSpeak.Value;
|
||||
|
|
@ -122,15 +121,13 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
bool enabled = necro >= entries[i].ReqNecromancy && spirit >= entries[i].ReqSpiritSpeak;
|
||||
|
||||
AddButton(27, 53 + i * 21, 9702, 9703, i + 1, GumpButtonType.Reply, 0);
|
||||
AddButton(27, 53 + i * 21, 9702, 9703, i + 1);
|
||||
|
||||
if (name is int intName)
|
||||
AddHtmlLocalized(50, 51 + i * 21, 150, 20, intName, enabled ? EnabledColor16 : DisabledColor16, false,
|
||||
false);
|
||||
AddHtmlLocalized(50, 51 + i * 21, 150, 20, intName, enabled ? EnabledColor16 : DisabledColor16);
|
||||
else if (name is string strName)
|
||||
AddHtml(50, 51 + i * 21, 150, 20,
|
||||
$"<BASEFONT COLOR=#{(enabled ? EnabledColor32 : DisabledColor32):X6}>{strName}</BASEFONT>", false,
|
||||
false);
|
||||
$"<BASEFONT COLOR=#{(enabled ? EnabledColor32 : DisabledColor32):X6}>{strName}</BASEFONT>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.PigIron
|
||||
);
|
||||
|
||||
public VampiricEmbraceSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public VampiricEmbraceSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -50,4 +50,4 @@ namespace Server.Spells.Necromancy
|
|||
Effects.PlaySound(m.Location, m.Map, 0x4B1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.PigIron
|
||||
);
|
||||
|
||||
public VengefulSpiritSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public VengefulSpiritSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -92,4 +92,4 @@ namespace Server.Spells.Necromancy
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.PigIron
|
||||
);
|
||||
|
||||
public WitherSpell(Mobile caster, Item scroll)
|
||||
public WitherSpell(Mobile caster, Item scroll = null)
|
||||
: base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace Server.Spells.Necromancy
|
|||
List<Mobile> targets = new List<Mobile>();
|
||||
|
||||
BaseCreature cbc = Caster as BaseCreature;
|
||||
bool isMonster = cbc != null && !cbc.Controlled && !cbc.Summoned;
|
||||
bool isMonster = cbc?.Controlled == false && !cbc.Summoned;
|
||||
|
||||
foreach (Mobile m in Caster.GetMobilesInRange(Core.ML ? 4 : 5))
|
||||
if (Caster != m && Caster.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(Caster, m)) &&
|
||||
|
|
@ -104,4 +104,4 @@ namespace Server.Spells.Necromancy
|
|||
FinishSequence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Spells.Necromancy
|
|||
Reagent.PigIron
|
||||
);
|
||||
|
||||
public WraithFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public WraithFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -46,4 +46,4 @@ namespace Server.Spells.Necromancy
|
|||
mobile.IgnoreMobiles = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue