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,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Server.Items
|
|||
|
||||
Skill skill = from.Skills.ArmsLore;
|
||||
|
||||
if ( skill != null && skill.Base >= 80.0 )
|
||||
if ( skill?.Base >= 80.0 )
|
||||
return true;
|
||||
|
||||
from.SendLocalizedMessage( 1061812 ); // You lack the required skill in armslore to perform that attack!
|
||||
|
|
@ -48,16 +48,16 @@ namespace Server.Items
|
|||
|
||||
Item toDisarm = defender.FindItemOnLayer(Layer.OneHanded);
|
||||
|
||||
if (toDisarm == null || !toDisarm.Movable)
|
||||
if (toDisarm?.Movable == false)
|
||||
toDisarm = defender.FindItemOnLayer(Layer.TwoHanded);
|
||||
|
||||
Container pack = defender.Backpack;
|
||||
|
||||
if (pack == null || toDisarm != null && !toDisarm.Movable)
|
||||
if (pack == null || toDisarm?.Movable == false)
|
||||
{
|
||||
attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent.
|
||||
}
|
||||
else if (toDisarm == null || toDisarm is BaseShield || toDisarm is Spellbook && !Core.ML)
|
||||
else if (!Core.ML && toDisarm == null || toDisarm is BaseShield || toDisarm is Spellbook)
|
||||
{
|
||||
attacker.SendLocalizedMessage(1060849); // Your target is already unarmed!
|
||||
}
|
||||
|
|
@ -75,4 +75,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ namespace Server.Items
|
|||
ClearCurrentAbility(attacker);
|
||||
Item toDisrobe = defender.FindItemOnLayer(Layer.InnerTorso);
|
||||
|
||||
if (toDisrobe == null || !toDisrobe.Movable)
|
||||
if (toDisrobe?.Movable == false)
|
||||
toDisrobe = defender.FindItemOnLayer(Layer.OuterTorso);
|
||||
|
||||
Container pack = defender.Backpack;
|
||||
|
||||
if (pack == null || toDisrobe == null || !toDisrobe.Movable)
|
||||
if (pack == null || toDisrobe?.Movable == false)
|
||||
{
|
||||
attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent.
|
||||
}
|
||||
|
|
@ -42,4 +42,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,19 +34,13 @@ namespace Server.Items
|
|||
|
||||
IWeapon weapon = attacker.Weapon;
|
||||
|
||||
if (weapon == null)
|
||||
if (!(weapon != null && attacker.InRange(defender, weapon.MaxRange) &&attacker.InLOS(defender)))
|
||||
return;
|
||||
|
||||
if (!attacker.InRange(defender, weapon.MaxRange))
|
||||
return;
|
||||
|
||||
if (attacker.InLOS(defender))
|
||||
{
|
||||
BaseWeapon.InDoubleStrike = true;
|
||||
attacker.RevealingAction();
|
||||
attacker.NextCombatTime = Core.TickCount + (int)weapon.OnSwing(attacker, defender).TotalMilliseconds;
|
||||
BaseWeapon.InDoubleStrike = false;
|
||||
}
|
||||
BaseWeapon.InDoubleStrike = true;
|
||||
attacker.RevealingAction();
|
||||
attacker.NextCombatTime = Core.TickCount + (int)weapon.OnSwing(attacker, defender).TotalMilliseconds;
|
||||
BaseWeapon.InDoubleStrike = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -38,30 +38,10 @@ namespace Server.Items
|
|||
if (!(map != null && attacker.Weapon is BaseWeapon weapon))
|
||||
return;
|
||||
|
||||
List<Mobile> list = new List<Mobile>();
|
||||
|
||||
foreach (Mobile m in attacker.GetMobilesInRange(1))
|
||||
list.Add(m);
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
Mobile m = list[i];
|
||||
|
||||
if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m))
|
||||
{
|
||||
if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) ||
|
||||
!attacker.CanBeHarmful(m))
|
||||
continue;
|
||||
|
||||
if (!attacker.InRange(m, weapon.MaxRange))
|
||||
continue;
|
||||
|
||||
if (attacker.InLOS(m))
|
||||
targets.Add(m);
|
||||
}
|
||||
}
|
||||
List<Mobile> targets = attacker.GetMobilesInRange(1).Where(m =>
|
||||
m?.Deleted == false && m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m) &&
|
||||
m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) &&
|
||||
attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m)).ToList();
|
||||
|
||||
if (targets.Count == 0 || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -29,7 +28,7 @@ namespace Server.Items
|
|||
|
||||
Skill skill = from.Skills.Anatomy;
|
||||
|
||||
if ( skill != null && skill.Base >= 80.0 )
|
||||
if ( skill?.Base >= 80.0 )
|
||||
return true;
|
||||
|
||||
from.SendLocalizedMessage( 1061811 ); // You lack the required anatomy skill to perform that attack!
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Server.Items
|
|||
|
||||
Skill skill = from.Skills.Stealth;
|
||||
|
||||
if (skill != null && skill.Value >= 80.0)
|
||||
if (skill?.Value >= 80.0)
|
||||
return true;
|
||||
|
||||
from.SendLocalizedMessage(1060183); // You lack the required stealth to perform that attack
|
||||
|
|
@ -51,4 +51,4 @@ namespace Server.Items
|
|||
attacker.Hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -184,7 +183,7 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
if (skill != null && skill.Base >= reqSkill)
|
||||
if (skill?.Base >= reqSkill)
|
||||
return true;
|
||||
|
||||
/* <UBWS> */
|
||||
|
|
@ -209,15 +208,7 @@ namespace Server.Items
|
|||
return CheckWeaponSkill(from);
|
||||
}
|
||||
|
||||
public virtual double GetSkill(Mobile from, SkillName skillName)
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if (skill == null)
|
||||
return 0.0;
|
||||
|
||||
return skill.Value;
|
||||
}
|
||||
public virtual double GetSkill(Mobile from, SkillName skillName) => from.Skills[skillName]?.Value ?? 0.0;
|
||||
|
||||
public virtual bool CheckMana(Mobile from, bool consume)
|
||||
{
|
||||
|
|
@ -381,7 +372,7 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
if (a != null && !a.Validate(m))
|
||||
if (a?.Validate(m) == false)
|
||||
{
|
||||
ClearCurrentAbility(m);
|
||||
return false;
|
||||
|
|
@ -394,7 +385,6 @@ namespace Server.Items
|
|||
else
|
||||
{
|
||||
SpecialMove.ClearCurrentMove(m);
|
||||
|
||||
Table[m] = a;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -34,51 +34,31 @@ namespace Server.Items
|
|||
attacker.FixedEffect(0x3728, 10, 15);
|
||||
attacker.PlaySound(0x2A1);
|
||||
|
||||
List<Mobile> list = new List<Mobile>();
|
||||
List<Mobile> targets = attacker.GetMobilesInRange(1).Where(m =>
|
||||
m?.Deleted == false && m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m) &&
|
||||
m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) &&
|
||||
attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m)).ToList();
|
||||
|
||||
foreach (Mobile m in attacker.GetMobilesInRange(1))
|
||||
list.Add(m);
|
||||
if (targets.Count <= 0)
|
||||
return;
|
||||
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
double bushido = attacker.Skills.Bushido.Value;
|
||||
double damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100;
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (damageBonus > 2.0)
|
||||
damageBonus = 2.0;
|
||||
|
||||
attacker.RevealingAction();
|
||||
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
{
|
||||
Mobile m = list[i];
|
||||
Mobile m = targets[i];
|
||||
|
||||
if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m))
|
||||
{
|
||||
if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) ||
|
||||
!attacker.CanBeHarmful(m))
|
||||
continue;
|
||||
attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target!
|
||||
m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage!
|
||||
|
||||
if (!attacker.InRange(m, weapon.MaxRange))
|
||||
continue;
|
||||
|
||||
if (attacker.InLOS(m))
|
||||
targets.Add(m);
|
||||
}
|
||||
}
|
||||
|
||||
if (targets.Count > 0)
|
||||
{
|
||||
double bushido = attacker.Skills.Bushido.Value;
|
||||
double damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100;
|
||||
|
||||
if (damageBonus > 2.0)
|
||||
damageBonus = 2.0;
|
||||
|
||||
attacker.RevealingAction();
|
||||
|
||||
for (int i = 0; i < targets.Count; ++i)
|
||||
{
|
||||
Mobile m = targets[i];
|
||||
|
||||
attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target!
|
||||
m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage!
|
||||
|
||||
weapon.OnHit(attacker, m, damageBonus);
|
||||
}
|
||||
weapon.OnHit(attacker, m, damageBonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue