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,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Seventh
|
||||
|
|
@ -16,7 +17,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SulfurousAsh
|
||||
);
|
||||
|
||||
public ChainLightningSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public ChainLightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -52,32 +53,25 @@ namespace Server.Spells.Seventh
|
|||
{
|
||||
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(new Point3D(p), 2);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
targets.AddRange(eable.Where(m =>
|
||||
{
|
||||
if (Core.AOS && m == Caster)
|
||||
continue;
|
||||
if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || !SpellHelper.ValidIndirectTarget(Caster, m) ||
|
||||
!Caster.CanBeHarmful(m, false))
|
||||
return false;
|
||||
|
||||
if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false))
|
||||
{
|
||||
if (Core.AOS && !Caster.InLOS(m))
|
||||
continue;
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
|
||||
targets.Add(m);
|
||||
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).ToList());
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
double damage;
|
||||
|
||||
if (Core.AOS)
|
||||
damage = GetNewAosDamage(51, 1, 5, playerVsPlayer);
|
||||
else
|
||||
damage = Utility.Random(27, 22);
|
||||
damage = Core.AOS ? GetNewAosDamage(51, 1, 5, playerVsPlayer)
|
||||
: Utility.Random(27, 22);
|
||||
|
||||
if (targets.Count > 0)
|
||||
{
|
||||
|
|
@ -135,4 +129,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SulfurousAsh
|
||||
);
|
||||
|
||||
public EnergyFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public EnergyFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -198,4 +198,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SulfurousAsh
|
||||
);
|
||||
|
||||
public FlameStrikeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public FlameStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -87,4 +87,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,7 @@ namespace Server.Spells.Seventh
|
|||
|
||||
private RunebookEntry m_Entry;
|
||||
|
||||
public GateTravelSpell(Mobile caster, Item scroll) : this(caster, scroll, null)
|
||||
{
|
||||
}
|
||||
|
||||
public GateTravelSpell(Mobile caster, Item scroll, RunebookEntry entry) : base(caster, scroll, m_Info)
|
||||
public GateTravelSpell(Mobile caster, RunebookEntry entry = null, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
m_Entry = entry;
|
||||
}
|
||||
|
|
@ -246,4 +242,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SpidersSilk
|
||||
);
|
||||
|
||||
public ManaVampireSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public ManaVampireSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -113,4 +113,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
|
@ -17,7 +18,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SulfurousAsh
|
||||
);
|
||||
|
||||
public MassDispelSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public MassDispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -40,46 +41,38 @@ namespace Server.Spells.Seventh
|
|||
|
||||
SpellHelper.GetSurfaceTop(ref p);
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
|
||||
Map map = Caster.Map;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
IPooledEnumerable<BaseCreature> eable = map.GetMobilesInRange<BaseCreature>(new Point3D(p), 8);
|
||||
|
||||
foreach (BaseCreature m in eable)
|
||||
if (m.IsDispellable && Caster.CanBeHarmful(m, false))
|
||||
targets.Add(m);
|
||||
foreach (BaseCreature bc in eable)
|
||||
{
|
||||
if (!(bc.IsDispellable && Caster.CanBeHarmful(bc, false)))
|
||||
continue;
|
||||
|
||||
double dispelChance =
|
||||
(50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100;
|
||||
|
||||
if (dispelChance > Utility.RandomDouble())
|
||||
{
|
||||
Effects.SendLocationParticles(EffectItem.Create(bc.Location, bc.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 8, 20, 5042);
|
||||
Effects.PlaySound(bc, bc.Map, 0x201);
|
||||
|
||||
bc.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
Caster.DoHarmful(bc);
|
||||
|
||||
bc.FixedEffect(0x3779, 10, 20);
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
|
||||
if (!(m is BaseCreature bc))
|
||||
continue;
|
||||
|
||||
double dispelChance =
|
||||
(50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100;
|
||||
|
||||
if (dispelChance > Utility.RandomDouble())
|
||||
{
|
||||
Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration),
|
||||
0x3728, 8, 20, 5042);
|
||||
Effects.PlaySound(m, m.Map, 0x201);
|
||||
|
||||
m.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
Caster.DoHarmful(m);
|
||||
|
||||
m.FixedEffect(0x3779, 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
|
|
@ -106,4 +99,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Seventh
|
||||
|
|
@ -16,7 +17,7 @@ namespace Server.Spells.Seventh
|
|||
Reagent.SpidersSilk
|
||||
);
|
||||
|
||||
public MeteorSwarmSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
public MeteorSwarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ namespace Server.Spells.Seventh
|
|||
if (p is Item item)
|
||||
p = item.GetWorldLocation();
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
List<Mobile> targets;
|
||||
|
||||
Map map = Caster.Map;
|
||||
|
||||
|
|
@ -52,27 +53,29 @@ namespace Server.Spells.Seventh
|
|||
{
|
||||
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(new Point3D(p), 2);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false))
|
||||
{
|
||||
if (Core.AOS && !Caster.InLOS(m))
|
||||
continue;
|
||||
targets = eable.Where(m =>
|
||||
{
|
||||
if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) ||
|
||||
Core.AOS && !Caster.InLOS(m))
|
||||
return false;
|
||||
|
||||
targets.Add(m);
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
|
||||
if (m.Player)
|
||||
playerVsPlayer = true;
|
||||
}
|
||||
return true;
|
||||
}).ToList();
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = new List<Mobile>();
|
||||
}
|
||||
|
||||
double damage;
|
||||
|
||||
if (Core.AOS)
|
||||
damage = GetNewAosDamage(51, 1, 5, playerVsPlayer);
|
||||
else
|
||||
damage = Utility.Random(27, 22);
|
||||
damage = Core.AOS ? GetNewAosDamage(51, 1, 5, playerVsPlayer)
|
||||
: Utility.Random(27, 22);
|
||||
|
||||
if (targets.Count > 0)
|
||||
{
|
||||
|
|
@ -83,12 +86,11 @@ namespace Server.Spells.Seventh
|
|||
else if (!Core.AOS)
|
||||
damage /= targets.Count;
|
||||
|
||||
double toDeal;
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
|
||||
toDeal = damage;
|
||||
double toDeal = damage;
|
||||
|
||||
if (!Core.AOS && CheckResisted(m))
|
||||
{
|
||||
|
|
@ -130,4 +132,4 @@ namespace Server.Spells.Seventh
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue