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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Ethics;
|
||||
using Server.Factions;
|
||||
|
|
@ -117,7 +118,7 @@ namespace Server.Items
|
|||
|
||||
CraftContext context = craftSystem.GetContext(from);
|
||||
|
||||
if (context != null && context.DoNotColor)
|
||||
if (context?.DoNotColor == true)
|
||||
Hue = 0;
|
||||
|
||||
if (tool is BaseRunicTool runicTool)
|
||||
|
|
@ -151,7 +152,7 @@ namespace Server.Items
|
|||
|
||||
CraftContext context = craftSystem.GetContext(from);
|
||||
|
||||
if (context != null && context.DoNotColor)
|
||||
if (context?.DoNotColor == true)
|
||||
Hue = 0;
|
||||
|
||||
switch (thisResource)
|
||||
|
|
@ -247,14 +248,10 @@ namespace Server.Items
|
|||
|
||||
public virtual void OnBeforeSwing(Mobile attacker, Mobile defender)
|
||||
{
|
||||
WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);
|
||||
|
||||
if (a != null && !a.OnBeforeSwing(attacker, defender))
|
||||
if (WeaponAbility.GetCurrentAbility(attacker)?.OnBeforeSwing(attacker, defender) == false)
|
||||
WeaponAbility.ClearCurrentAbility(attacker);
|
||||
|
||||
SpecialMove move = SpecialMove.GetCurrentMove(attacker);
|
||||
|
||||
if (move != null && !move.OnBeforeSwing(attacker, defender))
|
||||
if (SpecialMove.GetCurrentMove(attacker)?.OnBeforeSwing(attacker, defender) == false)
|
||||
SpecialMove.ClearCurrentMove(attacker);
|
||||
}
|
||||
|
||||
|
|
@ -380,10 +377,8 @@ namespace Server.Items
|
|||
|
||||
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
|
||||
{
|
||||
if (!Ethic.CheckTrade(from, to, newOwner, this))
|
||||
return false;
|
||||
|
||||
return base.AllowSecureTrade(from, to, newOwner, accepted);
|
||||
return Ethic.CheckTrade(from, to, newOwner, this) &&
|
||||
base.AllowSecureTrade(from, to, newOwner, accepted);
|
||||
}
|
||||
|
||||
public override bool CanEquip(Mobile from)
|
||||
|
|
@ -419,9 +414,7 @@ namespace Server.Items
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!from.CanBeginAction<BaseWeapon>()) return false;
|
||||
|
||||
return base.CanEquip(from);
|
||||
return from.CanBeginAction<BaseWeapon>() && base.CanEquip(from);
|
||||
}
|
||||
|
||||
public override bool OnEquip(Mobile from)
|
||||
|
|
@ -806,11 +799,8 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
#region Dueling
|
||||
|
||||
if (attacker is PlayerMobile pm)
|
||||
if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
|
||||
canSwing = false;
|
||||
|
||||
if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false)
|
||||
canSwing = false;
|
||||
#endregion
|
||||
|
||||
if (canSwing && attacker.HarmfulCheck(defender))
|
||||
|
|
@ -852,11 +842,11 @@ namespace Server.Items
|
|||
double parry = defender.Skills.Parry.Value;
|
||||
double bushidoNonRacial = defender.Skills.Bushido.NonRacialValue;
|
||||
double bushido = defender.Skills.Bushido.Value;
|
||||
double chance;
|
||||
|
||||
if (shield != null)
|
||||
{
|
||||
double
|
||||
chance = (parry - bushidoNonRacial) /
|
||||
chance = (parry - bushidoNonRacial) /
|
||||
400.0; // As per OSI, no genitive effect from the Racial stuffs, ie, 120 parry and '0' bushido with humans
|
||||
|
||||
if (chance < 0) // chance shouldn't go below 0
|
||||
|
|
@ -877,44 +867,42 @@ namespace Server.Items
|
|||
return defender.CheckSkill(SkillName.Parry, chance);
|
||||
}
|
||||
|
||||
if (!(defender.Weapon is Fists) && !(defender.Weapon is BaseRanged))
|
||||
if (defender.Weapon is Fists || defender.Weapon is BaseRanged)
|
||||
return false;
|
||||
|
||||
BaseWeapon weapon = defender.Weapon as BaseWeapon;
|
||||
|
||||
double divisor = weapon.Layer == Layer.OneHanded ? 48000.0 : 41140.0;
|
||||
|
||||
chance = parry * bushido / divisor;
|
||||
|
||||
double aosChance = parry / 800.0;
|
||||
|
||||
// Parry or Bushido over 100 grant a 5% bonus.
|
||||
if (parry >= 100.0)
|
||||
{
|
||||
BaseWeapon weapon = defender.Weapon as BaseWeapon;
|
||||
|
||||
double divisor = weapon.Layer == Layer.OneHanded ? 48000.0 : 41140.0;
|
||||
|
||||
double chance = parry * bushido / divisor;
|
||||
|
||||
double aosChance = parry / 800.0;
|
||||
|
||||
// Parry or Bushido over 100 grant a 5% bonus.
|
||||
if (parry >= 100.0)
|
||||
{
|
||||
chance += 0.05;
|
||||
aosChance += 0.05;
|
||||
}
|
||||
else if (bushido >= 100.0)
|
||||
{
|
||||
chance += 0.05;
|
||||
}
|
||||
|
||||
// Evasion grants a variable bonus post ML. 50% prior.
|
||||
if (Evasion.IsEvading(defender))
|
||||
chance *= Evasion.GetParryScalar(defender);
|
||||
|
||||
// Low dexterity lowers the chance.
|
||||
if (defender.Dex < 80)
|
||||
chance = chance * (20 + defender.Dex) / 100;
|
||||
|
||||
if (chance > aosChance)
|
||||
return defender.CheckSkill(SkillName.Parry, chance);
|
||||
|
||||
return
|
||||
aosChance > Utility
|
||||
.RandomDouble(); // Only skillcheck if wielding a shield & there's no effect from Bushido
|
||||
chance += 0.05;
|
||||
aosChance += 0.05;
|
||||
}
|
||||
else if (bushido >= 100.0)
|
||||
{
|
||||
chance += 0.05;
|
||||
}
|
||||
|
||||
return false;
|
||||
// Evasion grants a variable bonus post ML. 50% prior.
|
||||
if (Evasion.IsEvading(defender))
|
||||
chance *= Evasion.GetParryScalar(defender);
|
||||
|
||||
// Low dexterity lowers the chance.
|
||||
if (defender.Dex < 80)
|
||||
chance = chance * (20 + defender.Dex) / 100;
|
||||
|
||||
if (chance > aosChance)
|
||||
return defender.CheckSkill(SkillName.Parry, chance);
|
||||
|
||||
return
|
||||
aosChance > Utility
|
||||
.RandomDouble(); // Only skillcheck if wielding a shield & there's no effect from Bushido
|
||||
}
|
||||
|
||||
public virtual int AbsorbDamageAOS(Mobile attacker, Mobile defender, int damage)
|
||||
|
|
@ -1049,44 +1037,18 @@ namespace Server.Items
|
|||
if (!(attacker is BaseCreature bc) || bc.PackInstinct == PackInstinct.None || !bc.Controlled && !bc.Summoned)
|
||||
return 0;
|
||||
|
||||
Mobile master = bc.ControlMaster;
|
||||
|
||||
if (master == null)
|
||||
master = bc.SummonMaster;
|
||||
Mobile master = bc.ControlMaster ?? bc.SummonMaster;
|
||||
|
||||
if (master == null)
|
||||
return 0;
|
||||
|
||||
int inPack = 1;
|
||||
|
||||
IPooledEnumerable<BaseCreature> eable = defender.GetMobilesInRange<BaseCreature>(1);
|
||||
foreach (BaseCreature m in eable)
|
||||
if (m != attacker)
|
||||
{
|
||||
if ((m.PackInstinct & bc.PackInstinct) == 0 || !m.Controlled && !m.Summoned)
|
||||
continue;
|
||||
|
||||
Mobile theirMaster = m.ControlMaster;
|
||||
|
||||
if (theirMaster == null)
|
||||
theirMaster = m.SummonMaster;
|
||||
|
||||
if (master == theirMaster && m.Combatant == defender)
|
||||
++inPack;
|
||||
}
|
||||
int inPack = 1 + eable.Where(m => m != attacker && (m.PackInstinct & bc.PackInstinct) != 0 && (m.Controlled || m.Summoned))
|
||||
.Count(m => master == (m.ControlMaster ?? m.SummonMaster) && m.Combatant == defender);
|
||||
|
||||
eable.Free();
|
||||
|
||||
if (inPack >= 5)
|
||||
return 100;
|
||||
if (inPack >= 4)
|
||||
return 75;
|
||||
if (inPack >= 3)
|
||||
return 50;
|
||||
if (inPack >= 2)
|
||||
return 25;
|
||||
|
||||
return 0;
|
||||
return inPack >= 5 ? 100 : inPack >= 4 ? 75 : inPack >= 3 ? 50 : inPack >= 2 ? 25 : 0;
|
||||
}
|
||||
|
||||
public virtual void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1.0)
|
||||
|
|
@ -1095,7 +1057,7 @@ namespace Server.Items
|
|||
{
|
||||
IPooledEnumerable<Clone> eable = defender.GetMobilesInRange<Clone>(4);
|
||||
foreach (Clone m in eable)
|
||||
if (m != null && m.Summoned && m.SummonMaster == defender)
|
||||
if (m?.Summoned == true && m.SummonMaster == defender)
|
||||
{
|
||||
attacker.SendLocalizedMessage(
|
||||
1063141); // Your attack has been diverted to a nearby mirror image of your target!
|
||||
|
|
@ -1214,7 +1176,7 @@ namespace Server.Items
|
|||
if (!Core.AOS && damage < 1)
|
||||
damage = 1;
|
||||
else if (Core.AOS && damage == 0) // parried
|
||||
if (a != null && a.Validate(attacker) /*&& a.CheckMana( attacker, true )*/
|
||||
if (a?.Validate(attacker) == true /*&& a.CheckMana( attacker, true )*/
|
||||
) // Parried special moves have no mana cost
|
||||
{
|
||||
a = null;
|
||||
|
|
@ -1279,19 +1241,19 @@ namespace Server.Items
|
|||
|
||||
int damageGiven = damage;
|
||||
|
||||
if (a != null && !a.OnBeforeDamage(attacker, defender))
|
||||
if (a?.OnBeforeDamage(attacker, defender) == false)
|
||||
{
|
||||
WeaponAbility.ClearCurrentAbility(attacker);
|
||||
a = null;
|
||||
}
|
||||
|
||||
if (move != null && !move.OnBeforeDamage(attacker, defender))
|
||||
if (move?.OnBeforeDamage(attacker, defender) == false)
|
||||
{
|
||||
SpecialMove.ClearCurrentMove(attacker);
|
||||
move = null;
|
||||
}
|
||||
|
||||
bool ignoreArmor = a is ArmorIgnore || move != null && move.IgnoreArmor(attacker);
|
||||
bool ignoreArmor = a is ArmorIgnore || move?.IgnoreArmor(attacker) == true;
|
||||
|
||||
damageGiven = AOS.Damage(defender, attacker, damage, ignoreArmor, phys, fire, cold, pois, nrgy, chaos, direct,
|
||||
false, this is BaseRanged);
|
||||
|
|
@ -1322,10 +1284,10 @@ namespace Server.Items
|
|||
|
||||
context = TransformationSpellHelper.GetContext(attacker);
|
||||
|
||||
if (context != null && context.Type == typeof(VampiricEmbraceSpell))
|
||||
if (context?.Type == typeof(VampiricEmbraceSpell))
|
||||
lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech
|
||||
|
||||
if (context != null && context.Type == typeof(WraithFormSpell))
|
||||
if (context?.Type == typeof(WraithFormSpell))
|
||||
{
|
||||
wraithLeech =
|
||||
5 + (int)(15 * attacker.Skills.SpiritSpeak.Value /
|
||||
|
|
@ -1516,7 +1478,7 @@ namespace Server.Items
|
|||
if (atkWeapon is ButchersWarCleaver && TalismanSlayer.Slays(TalismanSlayerName.Bovine, defender))
|
||||
return CheckSlayerResult.Slayer;
|
||||
|
||||
if (atkSlayer != null && atkSlayer.Slays(defender) || atkSlayer2 != null && atkSlayer2.Slays(defender))
|
||||
if (atkSlayer?.Slays(defender) == true || atkSlayer2?.Slays(defender) == true)
|
||||
return CheckSlayerResult.Slayer;
|
||||
|
||||
if (attacker.Talisman is BaseTalisman talisman && TalismanSlayer.Slays(talisman.Slayer, defender))
|
||||
|
|
@ -1524,18 +1486,15 @@ namespace Server.Items
|
|||
|
||||
if (!Core.SE)
|
||||
{
|
||||
ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender);
|
||||
|
||||
if (defISlayer == null)
|
||||
defISlayer = defender.Weapon as ISlayer;
|
||||
ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender) ?? defender.Weapon as ISlayer;
|
||||
|
||||
if (defISlayer != null)
|
||||
{
|
||||
SlayerEntry defSlayer = SlayerGroup.GetEntryByName(defISlayer.Slayer);
|
||||
SlayerEntry defSlayer2 = SlayerGroup.GetEntryByName(defISlayer.Slayer2);
|
||||
|
||||
if (defSlayer != null && defSlayer.Group.OppositionSuperSlays(attacker) ||
|
||||
defSlayer2 != null && defSlayer2.Group.OppositionSuperSlays(attacker))
|
||||
if (defSlayer?.Group.OppositionSuperSlays(attacker) == true ||
|
||||
defSlayer2?.Group.OppositionSuperSlays(attacker) == true)
|
||||
return CheckSlayerResult.Opposition;
|
||||
}
|
||||
}
|
||||
|
|
@ -1545,18 +1504,18 @@ namespace Server.Items
|
|||
|
||||
public virtual void AddBlood(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (damage > 0)
|
||||
{
|
||||
new Blood().MoveToWorld(defender.Location, defender.Map);
|
||||
if (damage <= 0)
|
||||
return;
|
||||
|
||||
int extraBlood = Core.SE ? Utility.RandomMinMax(3, 4) : Utility.RandomMinMax(0, 1);
|
||||
new Blood().MoveToWorld(defender.Location, defender.Map);
|
||||
|
||||
for (int i = 0; i < extraBlood; i++)
|
||||
new Blood().MoveToWorld(new Point3D(
|
||||
defender.X + Utility.RandomMinMax(-1, 1),
|
||||
defender.Y + Utility.RandomMinMax(-1, 1),
|
||||
defender.Z), defender.Map);
|
||||
}
|
||||
int extraBlood = Core.SE ? Utility.RandomMinMax(3, 4) : Utility.RandomMinMax(0, 1);
|
||||
|
||||
for (int i = 0; i < extraBlood; i++)
|
||||
new Blood().MoveToWorld(new Point3D(
|
||||
defender.X + Utility.RandomMinMax(-1, 1),
|
||||
defender.Y + Utility.RandomMinMax(-1, 1),
|
||||
defender.Z), defender.Map);
|
||||
}
|
||||
|
||||
public virtual void GetDamageTypes(Mobile wielder, out int phys, out int fire, out int cold, out int pois,
|
||||
|
|
@ -2024,12 +1983,7 @@ namespace Server.Items
|
|||
|
||||
private string GetNameString()
|
||||
{
|
||||
string name = Name;
|
||||
|
||||
if (name == null)
|
||||
name = $"#{LabelNumber}";
|
||||
|
||||
return name;
|
||||
return Name ?? $"#{LabelNumber}";
|
||||
}
|
||||
|
||||
public int GetElementalDamageHue()
|
||||
|
|
@ -3072,7 +3026,7 @@ namespace Server.Items
|
|||
|
||||
attacker.DoHarmful(defender);
|
||||
|
||||
MagerySpell sp = new DispelSpell(attacker, null);
|
||||
MagerySpell sp = new DispelSpell(attacker);
|
||||
|
||||
if (sp.CheckResisted(defender))
|
||||
{
|
||||
|
|
@ -3114,15 +3068,12 @@ namespace Server.Items
|
|||
if (map == null)
|
||||
return;
|
||||
|
||||
List<Mobile> list = new List<Mobile>();
|
||||
|
||||
int range = Core.ML ? 5 : 10;
|
||||
|
||||
IPooledEnumerable<Mobile> eable = from.GetMobilesInRange(range);
|
||||
foreach (Mobile m in eable)
|
||||
if (from != m && defender != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false) &&
|
||||
(!Core.ML || from.InLOS(m)))
|
||||
list.Add(m);
|
||||
List<Mobile> list = eable.Where(m =>
|
||||
from != m && defender != m && SpellHelper.ValidIndirectTarget(from, m)
|
||||
&& from.CanBeHarmful(m, false) && (!Core.ML || from.InLOS(m))).ToList();
|
||||
eable.Free();
|
||||
|
||||
if (list.Count == 0)
|
||||
|
|
|
|||
|
|
@ -115,12 +115,12 @@ 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.
|
||||
}
|
||||
|
|
@ -213,10 +213,7 @@ namespace Server.Items
|
|||
{
|
||||
Item item = m.FindItemOnLayer(Layer.OneHanded);
|
||||
|
||||
if (item != null && !(item is Spellbook))
|
||||
return false;
|
||||
|
||||
return m.FindItemOnLayer(Layer.TwoHanded) == null;
|
||||
return (item == null || item is Spellbook) && m.FindItemOnLayer(Layer.TwoHanded) == null;
|
||||
}
|
||||
|
||||
private static void EventSink_DisarmRequest(DisarmRequestEventArgs e)
|
||||
|
|
@ -313,4 +310,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
|
|||
|
|
@ -7,12 +7,7 @@ namespace Server.Items
|
|||
private int m_Charges;
|
||||
|
||||
[Constructible]
|
||||
public FireworksWand() : this(100)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public FireworksWand(int charges)
|
||||
public FireworksWand(int charges = 100)
|
||||
{
|
||||
m_Charges = charges;
|
||||
LootType = LootType.Blessed;
|
||||
|
|
@ -132,4 +127,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,15 +69,13 @@ namespace Server.Items
|
|||
{
|
||||
canSwing = !attacker.Paralyzed && !attacker.Frozen;
|
||||
|
||||
if (canSwing) canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement;
|
||||
if (canSwing)
|
||||
canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement;
|
||||
}
|
||||
|
||||
#region Dueling
|
||||
|
||||
if (attacker is PlayerMobile pm)
|
||||
if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
|
||||
canSwing = false;
|
||||
|
||||
if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false)
|
||||
canSwing = false;
|
||||
#endregion
|
||||
|
||||
if (canSwing && attacker.HarmfulCheck(defender))
|
||||
|
|
@ -175,9 +173,9 @@ namespace Server.Items
|
|||
if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost)
|
||||
{
|
||||
// consume ammo
|
||||
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
|
||||
if (quiver?.ConsumeTotal(AmmoType) == true)
|
||||
quiver.InvalidateWeight();
|
||||
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
|
||||
else if (pack?.ConsumeTotal(AmmoType) != true)
|
||||
return false;
|
||||
}
|
||||
else if (quiver.FindItemByType(AmmoType) == null && pack?.FindItemByType(AmmoType) == null)
|
||||
|
|
@ -237,4 +235,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace Server.Items
|
|||
{
|
||||
ChampionSpawn spawn = region.ChampionSpawn;
|
||||
|
||||
if (spawn != null && spawn.IsChampionSpawn(bc))
|
||||
if (spawn?.IsChampionSpawn(bc) == true)
|
||||
{
|
||||
Type t = bc.GetType();
|
||||
|
||||
|
|
@ -166,4 +166,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue