Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -92,9 +92,9 @@ namespace Server.SkillHandlers
AddImage(118, 277, 2081);
AddImage(118, 347, 2083);
AddHtml(147, 108, 210, 18, $"<center><i>{c.Name}</i></center>", false, false);
AddHtml(147, 108, 210, 18, $"<center><i>{c.Name}</i></center>");
AddButton(240, 77, 2093, 2093, 2, GumpButtonType.Reply, 0);
AddButton(240, 77, 2093, 2093, 2);
AddImage(140, 138, 2091);
AddImage(140, 335, 2091);
@ -108,25 +108,25 @@ namespace Server.SkillHandlers
AddPage(++page);
AddImage(128, 152, 2086);
AddHtmlLocalized(147, 150, 160, 18, 1049593, 200, false, false); // Attributes
AddHtmlLocalized(147, 150, 160, 18, 1049593, 200); // Attributes
AddHtmlLocalized(153, 168, 160, 18, 1049578, LabelColor, false, false); // Hits
AddHtml(280, 168, 75, 18, FormatAttributes(c.Hits, c.HitsMax), false, false);
AddHtmlLocalized(153, 168, 160, 18, 1049578, LabelColor); // Hits
AddHtml(280, 168, 75, 18, FormatAttributes(c.Hits, c.HitsMax));
AddHtmlLocalized(153, 186, 160, 18, 1049579, LabelColor, false, false); // Stamina
AddHtml(280, 186, 75, 18, FormatAttributes(c.Stam, c.StamMax), false, false);
AddHtmlLocalized(153, 186, 160, 18, 1049579, LabelColor); // Stamina
AddHtml(280, 186, 75, 18, FormatAttributes(c.Stam, c.StamMax));
AddHtmlLocalized(153, 204, 160, 18, 1049580, LabelColor, false, false); // Mana
AddHtml(280, 204, 75, 18, FormatAttributes(c.Mana, c.ManaMax), false, false);
AddHtmlLocalized(153, 204, 160, 18, 1049580, LabelColor); // Mana
AddHtml(280, 204, 75, 18, FormatAttributes(c.Mana, c.ManaMax));
AddHtmlLocalized(153, 222, 160, 18, 1028335, LabelColor, false, false); // Strength
AddHtml(320, 222, 35, 18, FormatStat(c.Str), false, false);
AddHtmlLocalized(153, 222, 160, 18, 1028335, LabelColor); // Strength
AddHtml(320, 222, 35, 18, FormatStat(c.Str));
AddHtmlLocalized(153, 240, 160, 18, 3000113, LabelColor, false, false); // Dexterity
AddHtml(320, 240, 35, 18, FormatStat(c.Dex), false, false);
AddHtmlLocalized(153, 240, 160, 18, 3000113, LabelColor); // Dexterity
AddHtml(320, 240, 35, 18, FormatStat(c.Dex));
AddHtmlLocalized(153, 258, 160, 18, 3000112, LabelColor, false, false); // Intelligence
AddHtml(320, 258, 35, 18, FormatStat(c.Int), false, false);
AddHtmlLocalized(153, 258, 160, 18, 3000112, LabelColor); // Intelligence
AddHtml(320, 258, 35, 18, FormatStat(c.Int));
if (Core.AOS)
{
@ -138,26 +138,26 @@ namespace Server.SkillHandlers
if (c.Uncalmable)
bd = 0;
AddHtmlLocalized(153, 276, 160, 18, 1070793, LabelColor, false, false); // Barding Difficulty
AddHtml(320, y, 35, 18, FormatDouble(bd), false, false);
AddHtmlLocalized(153, 276, 160, 18, 1070793, LabelColor); // Barding Difficulty
AddHtml(320, y, 35, 18, FormatDouble(bd));
y += 18;
}
AddImage(128, y + 2, 2086);
AddHtmlLocalized(147, y, 160, 18, 1049594, 200, false, false); // Loyalty Rating
AddHtmlLocalized(147, y, 160, 18, 1049594, 200); // Loyalty Rating
y += 18;
AddHtmlLocalized(153, y, 160, 18, !c.Controlled || c.Loyalty == 0 ? 1061643 : 1049595 + c.Loyalty / 10,
LabelColor, false, false);
LabelColor);
}
else
{
AddImage(128, 278, 2086);
AddHtmlLocalized(147, 276, 160, 18, 3001016, 200, false, false); // Miscellaneous
AddHtmlLocalized(147, 276, 160, 18, 3001016, 200); // Miscellaneous
AddHtmlLocalized(153, 294, 160, 18, 1049581, LabelColor, false, false); // Armor Rating
AddHtml(320, 294, 35, 18, FormatStat(c.VirtualArmor), false, false);
AddHtmlLocalized(153, 294, 160, 18, 1049581, LabelColor); // Armor Rating
AddHtml(320, 294, 35, 18, FormatStat(c.VirtualArmor));
}
AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1);
@ -172,22 +172,22 @@ namespace Server.SkillHandlers
AddPage(++page);
AddImage(128, 152, 2086);
AddHtmlLocalized(147, 150, 160, 18, 1061645, 200, false, false); // Resistances
AddHtmlLocalized(147, 150, 160, 18, 1061645, 200); // Resistances
AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor, false, false); // Physical
AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalResistance), false, false);
AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor); // Physical
AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalResistance));
AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor, false, false); // Fire
AddHtml(320, 186, 35, 18, FormatElement(c.FireResistance), false, false);
AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor); // Fire
AddHtml(320, 186, 35, 18, FormatElement(c.FireResistance));
AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor, false, false); // Cold
AddHtml(320, 204, 35, 18, FormatElement(c.ColdResistance), false, false);
AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor); // Cold
AddHtml(320, 204, 35, 18, FormatElement(c.ColdResistance));
AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor, false, false); // Poison
AddHtml(320, 222, 35, 18, FormatElement(c.PoisonResistance), false, false);
AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor); // Poison
AddHtml(320, 222, 35, 18, FormatElement(c.PoisonResistance));
AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor, false, false); // Energy
AddHtml(320, 240, 35, 18, FormatElement(c.EnergyResistance), false, false);
AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor); // Energy
AddHtml(320, 240, 35, 18, FormatElement(c.EnergyResistance));
AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1);
AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1);
@ -202,29 +202,29 @@ namespace Server.SkillHandlers
AddPage(++page);
AddImage(128, 152, 2086);
AddHtmlLocalized(147, 150, 160, 18, 1017319, 200, false, false); // Damage
AddHtmlLocalized(147, 150, 160, 18, 1017319, 200); // Damage
AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor, false, false); // Physical
AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalDamage), false, false);
AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor); // Physical
AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalDamage));
AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor, false, false); // Fire
AddHtml(320, 186, 35, 18, FormatElement(c.FireDamage), false, false);
AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor); // Fire
AddHtml(320, 186, 35, 18, FormatElement(c.FireDamage));
AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor, false, false); // Cold
AddHtml(320, 204, 35, 18, FormatElement(c.ColdDamage), false, false);
AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor); // Cold
AddHtml(320, 204, 35, 18, FormatElement(c.ColdDamage));
AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor, false, false); // Poison
AddHtml(320, 222, 35, 18, FormatElement(c.PoisonDamage), false, false);
AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor); // Poison
AddHtml(320, 222, 35, 18, FormatElement(c.PoisonDamage));
AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor, false, false); // Energy
AddHtml(320, 240, 35, 18, FormatElement(c.EnergyDamage), false, false);
AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor); // Energy
AddHtml(320, 240, 35, 18, FormatElement(c.EnergyDamage));
#region Mondain's Legacy
if (Core.ML)
{
AddHtmlLocalized(153, 258, 160, 18, 1076750, LabelColor, false, false); // Base Damage
AddHtml(300, 258, 55, 18, FormatDamage(c.DamageMin, c.DamageMax), false, false);
AddHtmlLocalized(153, 258, 160, 18, 1076750, LabelColor); // Base Damage
AddHtml(300, 258, 55, 18, FormatDamage(c.DamageMin, c.DamageMax));
}
#endregion
@ -240,46 +240,46 @@ namespace Server.SkillHandlers
AddPage(++page);
AddImage(128, 152, 2086);
AddHtmlLocalized(147, 150, 160, 18, 3001030, 200, false, false); // Combat Ratings
AddHtmlLocalized(147, 150, 160, 18, 3001030, 200); // Combat Ratings
AddHtmlLocalized(153, 168, 160, 18, 1044103, LabelColor, false, false); // Wrestling
AddHtml(320, 168, 35, 18, FormatSkill(c, SkillName.Wrestling), false, false);
AddHtmlLocalized(153, 168, 160, 18, 1044103, LabelColor); // Wrestling
AddHtml(320, 168, 35, 18, FormatSkill(c, SkillName.Wrestling));
AddHtmlLocalized(153, 186, 160, 18, 1044087, LabelColor, false, false); // Tactics
AddHtml(320, 186, 35, 18, FormatSkill(c, SkillName.Tactics), false, false);
AddHtmlLocalized(153, 186, 160, 18, 1044087, LabelColor); // Tactics
AddHtml(320, 186, 35, 18, FormatSkill(c, SkillName.Tactics));
AddHtmlLocalized(153, 204, 160, 18, 1044086, LabelColor, false, false); // Magic Resistance
AddHtml(320, 204, 35, 18, FormatSkill(c, SkillName.MagicResist), false, false);
AddHtmlLocalized(153, 204, 160, 18, 1044086, LabelColor); // Magic Resistance
AddHtml(320, 204, 35, 18, FormatSkill(c, SkillName.MagicResist));
AddHtmlLocalized(153, 222, 160, 18, 1044061, LabelColor, false, false); // Anatomy
AddHtml(320, 222, 35, 18, FormatSkill(c, SkillName.Anatomy), false, false);
AddHtmlLocalized(153, 222, 160, 18, 1044061, LabelColor); // Anatomy
AddHtml(320, 222, 35, 18, FormatSkill(c, SkillName.Anatomy));
#region Mondain's Legacy
if (c is CuSidhe)
{
AddHtmlLocalized(153, 240, 160, 18, 1044077, LabelColor, false, false); // Healing
AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Healing), false, false);
AddHtmlLocalized(153, 240, 160, 18, 1044077, LabelColor); // Healing
AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Healing));
}
else
{
AddHtmlLocalized(153, 240, 160, 18, 1044090, LabelColor, false, false); // Poisoning
AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Poisoning), false, false);
AddHtmlLocalized(153, 240, 160, 18, 1044090, LabelColor); // Poisoning
AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Poisoning));
}
#endregion
AddImage(128, 260, 2086);
AddHtmlLocalized(147, 258, 160, 18, 3001032, 200, false, false); // Lore & Knowledge
AddHtmlLocalized(147, 258, 160, 18, 3001032, 200); // Lore & Knowledge
AddHtmlLocalized(153, 276, 160, 18, 1044085, LabelColor, false, false); // Magery
AddHtml(320, 276, 35, 18, FormatSkill(c, SkillName.Magery), false, false);
AddHtmlLocalized(153, 276, 160, 18, 1044085, LabelColor); // Magery
AddHtml(320, 276, 35, 18, FormatSkill(c, SkillName.Magery));
AddHtmlLocalized(153, 294, 160, 18, 1044076, LabelColor, false, false); // Evaluating Intelligence
AddHtml(320, 294, 35, 18, FormatSkill(c, SkillName.EvalInt), false, false);
AddHtmlLocalized(153, 294, 160, 18, 1044076, LabelColor); // Evaluating Intelligence
AddHtml(320, 294, 35, 18, FormatSkill(c, SkillName.EvalInt));
AddHtmlLocalized(153, 312, 160, 18, 1044106, LabelColor, false, false); // Meditation
AddHtml(320, 312, 35, 18, FormatSkill(c, SkillName.Meditation), false, false);
AddHtmlLocalized(153, 312, 160, 18, 1044106, LabelColor); // Meditation
AddHtml(320, 312, 35, 18, FormatSkill(c, SkillName.Meditation));
AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1);
AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1);
@ -291,7 +291,7 @@ namespace Server.SkillHandlers
AddPage(++page);
AddImage(128, 152, 2086);
AddHtmlLocalized(147, 150, 160, 18, 1049563, 200, false, false); // Preferred Foods
AddHtmlLocalized(147, 150, 160, 18, 1049563, 200); // Preferred Foods
int foodPref = 3000340;
@ -306,10 +306,10 @@ namespace Server.SkillHandlers
else if ((c.FavoriteFood & FoodType.Eggs) != 0)
foodPref = 1044477; // Eggs
AddHtmlLocalized(153, 168, 160, 18, foodPref, LabelColor, false, false);
AddHtmlLocalized(153, 168, 160, 18, foodPref, LabelColor);
AddImage(128, 188, 2086);
AddHtmlLocalized(147, 186, 160, 18, 1049569, 200, false, false); // Pack Instincts
AddHtmlLocalized(147, 186, 160, 18, 1049569, 200); // Pack Instincts
int packInstinct = 3000340;
@ -330,15 +330,15 @@ namespace Server.SkillHandlers
else if ((c.PackInstinct & PackInstinct.Bull) != 0)
packInstinct = 1049577; // Bull
AddHtmlLocalized(153, 204, 160, 18, packInstinct, LabelColor, false, false);
AddHtmlLocalized(153, 204, 160, 18, packInstinct, LabelColor);
if (!Core.AOS)
{
AddImage(128, 224, 2086);
AddHtmlLocalized(147, 222, 160, 18, 1049594, 200, false, false); // Loyalty Rating
AddHtmlLocalized(147, 222, 160, 18, 1049594, 200); // Loyalty Rating
AddHtmlLocalized(153, 240, 160, 18, !c.Controlled || c.Loyalty == 0 ? 1061643 : 1049595 + c.Loyalty / 10,
LabelColor, false, false);
LabelColor);
}
AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, 1);
@ -401,4 +401,4 @@ namespace Server.SkillHandlers
#endregion
}
}
}

View file

@ -44,8 +44,7 @@ namespace Server.SkillHandlers
public static bool MustBeSubdued(BaseCreature bc)
{
if (bc.Owners.Count > 0) return false;
return bc.SubdueBeforeTame && bc.Hits > bc.HitsMax / 10;
return bc.Owners.Count <= 0 && bc.SubdueBeforeTame && bc.Hits > bc.HitsMax / 10;
}
public static void ScaleStats(BaseCreature bc, double scalar)
@ -316,7 +315,7 @@ namespace Server.SkillHandlers
m_Tamer.NetState); // You must subdue this creature before you can tame it!
Stop();
}
else if (de != null && de.LastDamage > m_StartTime)
else if (de?.LastDamage > m_StartTime)
{
m_BeingTamed.Remove(m_Creature);
m_Tamer.NextSkillTime = Core.TickCount;
@ -418,14 +417,8 @@ namespace Server.SkillHandlers
{
IPoint3D p = m_Tamer;
if (p == null)
return false;
if (m_Creature.InRange(new Point3D(p), 1))
return true;
MovementPath path = new MovementPath(m_Creature, new Point3D(p));
return path.Success;
return p != null && (m_Creature.InRange(new Point3D(p), 1) ||
new MovementPath(m_Creature, new Point3D(p)).Success);
}
}
}

View file

@ -49,7 +49,7 @@ namespace Server.SkillHandlers
BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16);
bool inHouse = house != null && house.IsFriend(src);
bool inHouse = house?.IsFriend(src) == true;
if (inHouse)
range = 22;
@ -103,4 +103,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;

View file

@ -1,4 +1,5 @@
using System;
using System.Linq;
using Server.Multis;
using Server.Network;
using Server.Targeting;
@ -28,23 +29,17 @@ namespace Server.SkillHandlers
BaseHouse house = BaseHouse.FindHouseAt(m);
if (house != null && house.IsFriend(m))
if (house?.IsFriend(m) == true)
{
bonus = 100.0;
}
else if (!Core.AOS)
{
if (house == null)
house = BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16);
if (house == null)
house = BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16);
if (house == null)
house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16);
if (house == null)
house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16);
house = BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16) ??
BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16) ??
BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16) ??
BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16);
if (house != null)
bonus = 50.0;
@ -61,13 +56,10 @@ namespace Server.SkillHandlers
if (ok)
{
if (!CombatOverride)
foreach (Mobile check in m.GetMobilesInRange(range))
if (check.InLOS(m) && check.Combatant == m)
{
badCombat = true;
ok = false;
break;
}
if (m.GetMobilesInRange(range).Any(check => check.InLOS(m) && check.Combatant == m))
{
badCombat = true;
}
ok = !badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus);
}
@ -97,4 +89,4 @@ namespace Server.SkillHandlers
return TimeSpan.FromSeconds(10.0);
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Targeting;
@ -42,11 +43,7 @@ namespace Server.SkillHandlers
public static bool IsEmpty(BaseBook book)
{
foreach (BookPageInfo page in book.Pages)
foreach (string line in page.Lines)
if (line.Trim().Length != 0)
return false;
return true;
return book.Pages.SelectMany(page => page.Lines).All(line => line.Trim().Length == 0);
}
public static void Copy(BaseBook bookSrc, BaseBook bookDst)

View file

@ -81,7 +81,7 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(
1010538); // You may not disarm faction traps unless you are in an opposing faction
}
else if (faction == trap.Faction && trap.Faction != null && !isOwner)
else if (trap.Faction != null && faction == trap.Faction && !isOwner)
{
from.SendLocalizedMessage(1010537); // You may not disarm traps set by your own faction!
}
@ -126,4 +126,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -20,18 +20,15 @@ namespace Server.SkillHandlers
if (to.Player)
return from.CanBeHarmful(to, false, true); // normal restrictions
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
return true; // felucca you can snoop anybody
GuardedRegion reg = to.Region.GetRegion<GuardedRegion>();
if (reg == null || reg.IsDisabled())
if (reg?.IsDisabled() != true)
return true; // not in town? we can snoop any npc
if (to.Body.IsHuman && (!(to is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
return false; // in town we cannot snoop blue human npcs
return true;
return !to.Body.IsHuman || to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer);
}
public static void Container_Snoop(Container cont, Mobile from)
@ -40,22 +37,22 @@ namespace Server.SkillHandlers
{
Mobile root = cont.RootParent as Mobile;
if (root != null && !root.Alive)
if (root?.Alive == false)
return;
if (root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
{
from.SendLocalizedMessage(500209); // You can not peek into the container.
return;
}
if (root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
{
from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
return;
}
if (root != null && from.AccessLevel == AccessLevel.Player &&
if (root?.AccessLevel == AccessLevel.Player &&
from.Skills.Snooping.Value < Utility.Random(100))
{
Map map = from.Map;
@ -98,4 +95,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -136,22 +136,21 @@ namespace Server.SkillHandlers
public override void OnCast()
{
IPooledEnumerable<Corpse> eable = Caster.GetItemsInRange<Corpse>(3);
Corpse toChannel = eable.ToList().Find(item => item is Corpse corpse && !corpse.Channeled);
Corpse toChannel = eable.FirstOrDefault(item => item is Corpse corpse && !corpse.Channeled);
eable.Free();
int max, min, mana, number;
int min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25);
int max = min + 4;
int mana, number;
if (toChannel != null)
{
min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25);
max = min + 4;
mana = 0;
number = 1061287; // You channel energy from a nearby corpse to heal your wounds.
}
else
{
min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25);
max = min + 4;
mana = 10;
number = 1061286; // You channel your own spiritual energy to heal your wounds.
}
@ -192,4 +191,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -115,7 +115,7 @@ namespace Server.SkillHandlers
{
m_Thief.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true))
else if (m_Thief.Backpack?.CheckHold(m_Thief, toSteal, false, true) != true)
{
m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else.
}
@ -177,7 +177,7 @@ namespace Server.SkillHandlers
m_Thief.SendLocalizedMessage(
1010258); // The sigil has gone back to its home location because you already have a sigil.
}
else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true))
else if (m_Thief?.Backpack.CheckHold(m_Thief, sig, false, true) != true)
{
m_Thief.SendLocalizedMessage(
1010259); // The sigil has gone home because your backpack is full
@ -289,10 +289,7 @@ namespace Server.SkillHandlers
if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5,
pileWeight + 27.5))
{
stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount);
if (stolen == null)
stolen = toSteal;
stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount) ?? toSteal;
}
}
}
@ -344,7 +341,7 @@ namespace Server.SkillHandlers
{
Container pack = mobile.Backpack;
if (pack != null && pack.Items.Count > 0)
if (pack?.Items.Count > 0)
{
int randomIndex = Utility.Random(pack.Items.Count);

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Gumps;
using Server.Network;
using Server.Spells;
@ -91,20 +92,20 @@ namespace Server.SkillHandlers
AddBackground(10, 85, 420, 25, 3000);
AddItem(20, 20, 9682);
AddButton(20, 110, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(20, 90, 100, 20, 1018087, false, false); // Animals
AddButton(20, 110, 4005, 4007, 1);
AddHtmlLocalized(20, 90, 100, 20, 1018087); // Animals
AddItem(120, 20, 9607);
AddButton(120, 110, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(120, 90, 100, 20, 1018088, false, false); // Monsters
AddButton(120, 110, 4005, 4007, 2);
AddHtmlLocalized(120, 90, 100, 20, 1018088); // Monsters
AddItem(220, 20, 8454);
AddButton(220, 110, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddHtmlLocalized(220, 90, 100, 20, 1018089, false, false); // Human NPCs
AddButton(220, 110, 4005, 4007, 3);
AddHtmlLocalized(220, 90, 100, 20, 1018089); // Human NPCs
AddItem(320, 20, 8455);
AddButton(320, 110, 4005, 4007, 4, GumpButtonType.Reply, 0);
AddHtmlLocalized(320, 90, 100, 20, 1018090, false, false); // Players
AddButton(320, 110, 4005, 4007, 4);
AddHtmlLocalized(320, 90, 100, 20, 1018090); // Players
}
public override void OnResponse(NetState state, RelayInfo info)
@ -165,10 +166,10 @@ namespace Server.SkillHandlers
Mobile m = list[i];
AddItem(20 + i % 4 * 100, 20 + i / 4 * 155, ShrinkTable.Lookup(m));
AddButton(20 + i % 4 * 100, 130 + i / 4 * 155, 4005, 4007, i + 1, GumpButtonType.Reply, 0);
AddButton(20 + i % 4 * 100, 130 + i / 4 * 155, 4005, 4007, i + 1);
if (m.Name != null)
AddHtml(20 + i % 4 * 100, 90 + i / 4 * 155, 90, 40, m.Name, false, false);
AddHtml(20 + i % 4 * 100, 90 + i / 4 * 155, 90, 40, m.Name);
}
}
@ -191,14 +192,9 @@ namespace Server.SkillHandlers
int range = 10 + (int)(from.Skills.Tracking.Value / 10);
List<Mobile> list = new List<Mobile>();
foreach (Mobile m in from.GetMobilesInRange(range))
// Ghosts can no longer be tracked
if (m != from && (!Core.AOS || m.Alive) &&
(!m.Hidden || m.AccessLevel == AccessLevel.Player || from.AccessLevel > m.AccessLevel) && check(m) &&
CheckDifficulty(from, m))
list.Add(m);
List<Mobile> list = from.GetMobilesInRange(range)
.Where(m => m != from && (!Core.AOS || m.Alive) && (!m.Hidden || m.AccessLevel == AccessLevel.Player || from.AccessLevel > m.AccessLevel) && check(m) && CheckDifficulty(from, m))
.ToList();
if (list.Count > 0)
{