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.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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue