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

@ -97,7 +97,7 @@ namespace Server.Spells.Spellweaving
{
ItemData id = item.ItemData;
if (item == null || item.Z + id.CalcHeight != location.Z)
if (item.Z + id.CalcHeight != location.Z)
continue;
if (IsValidTile(item.ItemID))
{
@ -120,14 +120,12 @@ namespace Server.Spells.Spellweaving
private List<Mobile> GetArcanists()
{
List<Mobile> weavers = new List<Mobile>();
weavers.Add(Caster);
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 && !(m is Clone))
Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20)
weavers.Add(m);
// Everyone gets the Arcane Focus, power capped elsewhere
@ -143,15 +141,15 @@ namespace Server.Spells.Spellweaving
if (focus == null)
{
ArcaneFocus f = new ArcaneFocus(duration, strengthBonus);
if (to.PlaceInBackpack(f))
focus = new ArcaneFocus(duration, strengthBonus);
if (to.PlaceInBackpack(focus))
{
f.SendTimeRemainingMessage(to);
focus.SendTimeRemainingMessage(to);
to.SendLocalizedMessage(1072740); // An arcane focus appears in your backpack.
}
else
{
f.Delete();
focus.Delete();
}
}
else //OSI renewal rules: the new one will override the old one, always.

View file

@ -69,13 +69,13 @@ namespace Server.Spells.Spellweaving
return false;
}
if (caster is PlayerMobile)
if (caster is PlayerMobile mobile)
{
MLQuestContext context = MLQuestSystem.GetContext((PlayerMobile)caster);
MLQuestContext context = MLQuestSystem.GetContext(mobile);
if (context == null || !context.Spellweaving)
{
caster.SendLocalizedMessage(
mobile.SendLocalizedMessage(
1073220); // You must have completed the epic arcanist quest to use this ability.
return false;
}
@ -93,7 +93,7 @@ namespace Server.Spells.Spellweaving
if (caster.Skills[CastSkill].Value < RequiredSkill)
{
caster.SendLocalizedMessage(1063013,
$"{RequiredSkill.ToString("F1")}\t{"#1044114"}"); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
$"{RequiredSkill:F1}\t{"#1044114"}"); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
return false;
}

View file

@ -39,8 +39,6 @@ namespace Server.Spells.Spellweaving
public void Target(Mobile m)
{
BaseCreature bc = m as BaseCreature;
if (!Caster.CanSee(m))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
@ -49,7 +47,7 @@ namespace Server.Spells.Spellweaving
{
// As per Osi: Nothing happens.
}
else if (m != Caster && (bc == null || !bc.IsBonded || bc.ControlMaster != Caster))
else if (m != Caster && !(m is BaseCreature bc && bc.IsBonded && bc.ControlMaster == Caster))
{
Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}
@ -101,9 +99,8 @@ namespace Server.Spells.Spellweaving
{
double hitsScalar = timer.Spell.HitsScalar;
if (m is BaseCreature && m.IsDeadBondedPet)
if (m is BaseCreature pet && pet.IsDeadBondedPet)
{
BaseCreature pet = (BaseCreature)m;
Mobile master = pet.GetMaster();
if (master?.NetState != null && Utility.InUpdateRange(pet, master))
@ -190,8 +187,8 @@ namespace Server.Spells.Spellweaving
protected override void OnTarget(Mobile m, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
else
m.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet.
}

View file

@ -166,7 +166,8 @@ namespace Server.Spells.Spellweaving
protected override void OnTarget(Mobile m, 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 m)

View file

@ -26,9 +26,7 @@ namespace Server.Spells.Spellweaving
public override bool CheckCast()
{
BaseWeapon weapon = Caster.Weapon as BaseWeapon;
if (weapon == null || weapon is Fists || weapon is BaseRanged)
if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists || weapon is BaseRanged)
{
Caster.SendLocalizedMessage(1060179); // You must be wielding a weapon to use this ability!
return false;
@ -39,9 +37,7 @@ namespace Server.Spells.Spellweaving
public override void OnCast()
{
BaseWeapon weapon = Caster.Weapon as BaseWeapon;
if (weapon == null || weapon is Fists || weapon is BaseRanged)
if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists || weapon is BaseRanged)
{
Caster.SendLocalizedMessage(1060179); // You must be wielding a weapon to use this ability!
}

View file

@ -84,8 +84,8 @@ namespace Server.Spells.Spellweaving
protected override void OnTarget(Mobile from, object o)
{
if (o is IPoint3D)
m_Owner.Target((IPoint3D)o);
if (o is IPoint3D d)
m_Owner.Target(d);
}
protected override void OnTargetFinish(Mobile from)

View file

@ -28,13 +28,13 @@ namespace Server.Spells.Spellweaving
Mobile caster = Caster;
// This is done after casting completes
if (caster is PlayerMobile)
if (caster is PlayerMobile mobile)
{
MLQuestContext context = MLQuestSystem.GetContext((PlayerMobile)caster);
MLQuestContext context = MLQuestSystem.GetContext(mobile);
if (context == null || !context.SummonFey)
{
caster.SendLocalizedMessage(
mobile.SendLocalizedMessage(
1074563); // You haven't forged a friendship with the fey and are unable to summon their aid.
return false;
}

View file

@ -28,13 +28,13 @@ namespace Server.Spells.Spellweaving
Mobile caster = Caster;
// This is done after casting completes
if (caster is PlayerMobile)
if (caster is PlayerMobile mobile)
{
MLQuestContext context = MLQuestSystem.GetContext((PlayerMobile)caster);
MLQuestContext context = MLQuestSystem.GetContext(mobile);
if (context == null || !context.SummonFiend)
{
caster.SendLocalizedMessage(1074564); // You haven't demonstrated mastery to summon a fiend.
mobile.SendLocalizedMessage(1074564); // You haven't demonstrated mastery to summon a fiend.
return false;
}
}

View file

@ -58,11 +58,7 @@ namespace Server.Spells.Spellweaving
damage /= 100;
}
int[] types = new int[4];
types[Utility.Random(types.Length)] = 100;
SpellHelper.Damage(this, m, damage, 0, types[0], types[1], types[2],
types[3]); //Chaos damage. Random elemental damage
SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100);
}
FinishSequence();
@ -79,7 +75,8 @@ namespace Server.Spells.Spellweaving
protected override void OnTarget(Mobile m, 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 m)