Fixes chaos damage bug with the spell system. Fixes various small other bugs. Fixes more merge cast type checks and uses default values.

This commit is contained in:
Kamron Batman 2018-09-16 21:04:36 -07:00
parent 9542c79ea4
commit c155c82325
115 changed files with 644 additions and 1041 deletions

View file

@ -132,9 +132,7 @@ namespace Server.Spells.Necromancy
{
MaabusCoffinComponent comp = obj as MaabusCoffinComponent;
MaabusCoffin addon = comp?.Addon as MaabusCoffin;
if (addon != null)
if (comp?.Addon is MaabusCoffin addon)
{
PlayerMobile pm = Caster as PlayerMobile;
@ -154,9 +152,7 @@ namespace Server.Spells.Necromancy
return;
}
Corpse c = obj as Corpse;
if (c == null)
if (!(obj is Corpse c))
{
Caster.SendLocalizedMessage(1061084); // You cannot animate that.
}
@ -167,8 +163,8 @@ namespace Server.Spells.Necromancy
if (c.Owner != null) type = c.Owner.GetType();
if (c.ItemID != 0x2006 || c.Animated || type == typeof(PlayerMobile) || type == null ||
c.Owner != null && c.Owner.Fame < 100 || c.Owner is BaseCreature &&
(((BaseCreature)c.Owner).Summoned || ((BaseCreature)c.Owner).IsBonded))
c.Owner != null && c.Owner.Fame < 100 || c.Owner is BaseCreature creature &&
(creature.Summoned || creature.IsBonded))
{
Caster.SendLocalizedMessage(1061085); // There's not enough life force there to animate.
}
@ -326,25 +322,20 @@ namespace Server.Spells.Necromancy
if (summoned == null)
return;
if (summoned is BaseCreature)
if (summoned is BaseCreature bc)
{
BaseCreature bc = (BaseCreature)summoned;
// to be sure
bc.Tamable = false;
if (bc is BaseMount)
bc.ControlSlots = 1;
else
bc.ControlSlots = 0;
bc.ControlSlots = bc is BaseMount ? 1 : 0;
Effects.PlaySound(loc, map, bc.GetAngerSound());
BaseCreature.Summon((BaseCreature)summoned, false, caster, loc, 0x28, TimeSpan.FromDays(1.0));
BaseCreature.Summon(bc, false, caster, loc, 0x28, TimeSpan.FromDays(1.0));
}
if (summoned is SkeletalDragon)
Scale((SkeletalDragon)summoned, 50); // lose 50% hp and strength
if (summoned is SkeletalDragon dragon)
Scale(dragon, 50); // lose 50% hp and strength
summoned.Fame = 0;
summoned.Karma = -1500;
@ -359,9 +350,7 @@ namespace Server.Spells.Necromancy
public static void Scale(BaseCreature bc, int scalar)
{
int toScale;
toScale = bc.RawStr;
int toScale = bc.RawStr;
bc.RawStr = AOS.Scale(toScale, scalar);
toScale = bc.HitsMaxSeed;

View file

@ -173,8 +173,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
else
from.SendLocalizedMessage(1060508); // You can't curse that.
}

View file

@ -141,8 +141,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)

View file

@ -26,9 +26,7 @@ namespace Server.Spells.Necromancy
public override void OnCast()
{
BaseWeapon weapon = Caster.Weapon as BaseWeapon;
if (weapon == null || weapon is Fists)
if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists)
{
Caster.SendLocalizedMessage(501078); // You must be holding a weapon.
}

View file

@ -116,8 +116,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
else
from.SendLocalizedMessage(1060508); // You can't curse that.
}

View file

@ -87,9 +87,7 @@ namespace Server.Spells.Necromancy
public override void OnCast()
{
ChampionSpawnRegion r = Caster.Region.GetRegion(typeof(ChampionSpawnRegion)) as ChampionSpawnRegion;
if (r == null || !Caster.InRange(r.ChampionSpawn, Range))
if (!(Caster.Region.GetRegion(typeof(ChampionSpawnRegion)) is ChampionSpawnRegion r) || !Caster.InRange(r.ChampionSpawn, Range))
{
Caster.SendLocalizedMessage(1072111); // You are not in a valid exorcism region.
}

View file

@ -120,8 +120,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
else
from.SendLocalizedMessage(1060508); // You can't curse that.
}
@ -135,14 +135,12 @@ namespace Server.Spells.Necromancy
public class MRExpireTimer : Timer
{
private Mobile m_Caster;
private DateTime m_End;
private Mobile m_Target;
public MRExpireTimer(Mobile caster, Mobile target, TimeSpan delay) : base(TimeSpan.FromSeconds(1.0),
TimeSpan.FromSeconds(1.0))
{
m_Caster = caster;
m_Target = target;
m_End = DateTime.UtcNow + delay;
Priority = TimerPriority.TwoFiftyMS;

View file

@ -39,7 +39,7 @@ namespace Server.Spells.Necromancy
{
SpellHelper.Turn(Caster, m);
//SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent asfter AoS
//SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent after AoS
/* Temporarily causes intense physical pain to the target, dealing direct damage.
* After 10 seconds the spell wears off, and if the target is still alive,
@ -61,9 +61,8 @@ namespace Server.Spells.Necromancy
if (m_Table.Contains(m))
{
damage = Utility.RandomMinMax(3, 7);
Timer t = m_Table[m] as Timer;
if (t != null)
if (m_Table[m] is Timer t)
{
t.Delay += TimeSpan.FromSeconds(2.0);
@ -77,6 +76,7 @@ namespace Server.Spells.Necromancy
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.PainSpike, 1075667, buffTime, m, Convert.ToString((int)damage)));
// TODO: Find a better way to do this
WeightOverloading.DFA = DFAlgorithm.PainSpike;
m.Damage((int)damage, Caster);
SpellHelper.DoLeech((int)damage, Caster, m);
@ -126,8 +126,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)

View file

@ -107,8 +107,8 @@ namespace Server.Spells.Necromancy
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)