Fixes dictionary uses (#7)

This commit is contained in:
Kamron Batman 2018-11-02 08:16:42 -07:00 • committed by GitHub
parent d4a52344f2
commit 916d404c51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 1211 additions and 1722 deletions

View file

@ -79,11 +79,7 @@ namespace Server.Misc
if (a.LoginIPs.Length > 0) if (a.LoginIPs.Length > 0)
{ {
IPAddress ip = a.LoginIPs[0]; IPAddress ip = a.LoginIPs[0];
m_IPTable[ip] = (m_IPTable.TryGetValue(ip, out int value) ? value : 0) + 1;
if (m_IPTable.ContainsKey(ip))
m_IPTable[ip]++;
else
m_IPTable[ip] = 1;
} }
} }

View file

@ -91,12 +91,9 @@ namespace Server.Commands
continue; continue;
Type type = obj.GetType(); Type type = obj.GetType();
PropertyInfo[] chain = propertyChains[type];
string failReason = ""; string failReason = "";
if (chain == null) if (!propertyChains.TryGetValue(type, out PropertyInfo[] chain))
propertyChains[type] = chain = Properties.GetPropertyInfoChain(e.Mobile, type, bc.Object, propertyChains[type] = chain = Properties.GetPropertyInfoChain(e.Mobile, type, bc.Object,
PropertyAccess.Read, ref failReason); PropertyAccess.Read, ref failReason);

View file

@ -69,9 +69,7 @@ namespace Server.Commands
TypeInfo info = new TypeInfo(type); TypeInfo info = new TypeInfo(type);
m_Types[type] = info; m_Types[type] = info;
m_Namespaces.TryGetValue(nspace, out List<TypeInfo> nspaces); if (!m_Namespaces.TryGetValue(nspace, out List<TypeInfo> nspaces))
if (nspaces == null)
m_Namespaces[nspace] = nspaces = new List<TypeInfo>(); m_Namespaces[nspace] = nspaces = new List<TypeInfo>();
nspaces.Add(info); nspaces.Add(info);
@ -682,9 +680,8 @@ namespace Server.Commands
m_Types = new Dictionary<Type, TypeInfo>(); m_Types = new Dictionary<Type, TypeInfo>();
m_Namespaces = new Dictionary<string, List<TypeInfo>>(); m_Namespaces = new Dictionary<string, List<TypeInfo>>();
List<Assembly> assemblies = new List<Assembly>(); List<Assembly> assemblies = new List<Assembly> { Core.Assembly };
assemblies.Add(Core.Assembly);
foreach (Assembly asm in ScriptCompiler.Assemblies) foreach (Assembly asm in ScriptCompiler.Assemblies)
assemblies.Add(asm); assemblies.Add(asm);
@ -1882,9 +1879,7 @@ namespace Server.Commands
lastIndex = index; lastIndex = index;
table.TryGetValue(index, out SpeechEntry entry); if (!table.TryGetValue(index, out SpeechEntry entry))
if (entry == null)
table[index] = entry = new SpeechEntry(index); table[index] = entry = new SpeechEntry(index);
entry.Strings.Add(text); entry.Strings.Add(text);
@ -2290,9 +2285,7 @@ namespace Server.Commands
{ {
html.Write(" <a "); html.Write(" <a ");
m_Types.TryGetValue(parms[j].ParameterType, out TypeInfo typeInfo); if (m_Types.TryGetValue(parms[j].ParameterType, out TypeInfo typeInfo))
if (typeInfo != null)
html.Write("href=\"types/{0}\" ", typeInfo.FileName); html.Write("href=\"types/{0}\" ", typeInfo.FileName);
html.Write("title=\"{0}\">{1}</a>", GetTooltipFor(parms[j]), parms[j].Name); html.Write("title=\"{0}\">{1}</a>", GetTooltipFor(parms[j]), parms[j].Name);

View file

@ -251,9 +251,7 @@ namespace Server.Commands.Generic
{ {
if (e.Length >= 1) if (e.Length >= 1)
{ {
Commands.TryGetValue(e.GetString(0), out BaseCommand command); if (!Commands.TryGetValue(e.GetString(0), out BaseCommand command))
if (command == null)
{ {
e.Mobile.SendMessage( e.Mobile.SendMessage(
"That is either an invalid command name or one that does not support this modifier."); "That is either an invalid command name or one that does not support this modifier.");

View file

@ -99,10 +99,7 @@ namespace Server.Commands
{ {
Type type = item.GetType(); Type type = item.GetType();
if (table.ContainsKey(type)) table[type] = (table.TryGetValue(type, out int value) ? value : 0) + 1;
table[type] = 1 + table[type];
else
table[type] = 1;
} }
List<KeyValuePair<Type, int>> items = table.ToList(); List<KeyValuePair<Type, int>> items = table.ToList();
@ -112,10 +109,7 @@ namespace Server.Commands
{ {
Type type = m.GetType(); Type type = m.GetType();
if (table.ContainsKey(type)) table[type] = (table.TryGetValue(type, out int value) ? value : 0) + 1;
table[type] = 1 + table[type];
else
table[type] = 1;
} }
List<KeyValuePair<Type, int>> mobiles = table.ToList(); List<KeyValuePair<Type, int>> mobiles = table.ToList();
@ -161,10 +155,8 @@ namespace Server.Commands
do do
{ {
typeTable.TryGetValue(itemType, out int[] countTable); if (!typeTable.TryGetValue(itemType, out int[] countTable))
typeTable[itemType] = countTable = new int[9];
if (countTable == null)
countTable = new int[9];
if ((flags & ExpandFlag.Name) != 0) if ((flags & ExpandFlag.Name) != 0)
++countTable[0]; ++countTable[0];
@ -253,13 +245,13 @@ namespace Server.Commands
++totalCount; ++totalCount;
Type type = item.GetType(); Type type = item.GetType();
int[] parms = table[type];
if (parms == null) if (table.TryGetValue(type, out int[] parms))
table[type] = parms = new[] { 0, 0 }; {
parms[0]++;
parms[0]++; parms[1] += item.Amount;
parms[1] += item.Amount; } else
table[type] = new[] { 1, item.Amount };
} }
using (StreamWriter op = new StreamWriter("internal.log")) using (StreamWriter op = new StreamWriter("internal.log"))
@ -319,13 +311,9 @@ namespace Server.Commands
int length = bin.ReadInt32(); int length = bin.ReadInt32();
Type objType = types[typeID]; Type objType = types[typeID];
while (objType != typeof(object)) while (objType != null && objType != typeof(object))
{ {
if (table.ContainsKey(objType)) table[objType] = length + (table.TryGetValue(objType, out int value) ? value : 0);
table[objType] = length + table[objType];
else
table[objType] = length;
objType = objType.BaseType; objType = objType.BaseType;
total += length; total += length;
} }
@ -362,10 +350,7 @@ namespace Server.Commands
int v = -aCount.CompareTo(bCount); int v = -aCount.CompareTo(bCount);
if (v != 0) return v != 0 ? v : x.Key.FullName.CompareTo(y.Key.FullName);
return v;
return x.Key.FullName.CompareTo(y.Key.FullName);
} }
} }
@ -378,10 +363,7 @@ namespace Server.Commands
int v = -aCount.CompareTo(bCount); int v = -aCount.CompareTo(bCount);
if (v != 0) return v != 0 ? v : x.Key.FullName.CompareTo(y.Key.FullName);
return v;
return x.Key.FullName.CompareTo(y.Key.FullName);
} }
} }
} }

View file

@ -125,16 +125,12 @@ namespace Server
if (itemMap == null || itemMap == Map.Internal) if (itemMap == null || itemMap == Map.Internal)
continue; continue;
Dictionary<Point2D, DeltaState> table = mapTable[itemMap]; if (!mapTable.TryGetValue(itemMap, out Dictionary<Point2D, DeltaState> table))
if (table == null)
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>(); mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
Point2D p = new Point2D(item.X >> 3, item.Y >> 3); Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
DeltaState state = table[p]; if (!table.TryGetValue(p, out DeltaState state))
if (state == null)
table[p] = state = new DeltaState(p); table[p] = state = new DeltaState(p);
state.m_List.Add(item); state.m_List.Add(item);
@ -159,16 +155,12 @@ namespace Server
if (itemMap == null || itemMap == Map.Internal) if (itemMap == null || itemMap == Map.Internal)
continue; continue;
Dictionary<Point2D, DeltaState> table = mapTable[itemMap]; if (!mapTable.TryGetValue(itemMap, out Dictionary<Point2D, DeltaState> table))
if (table == null)
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>(); mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
Point2D p = new Point2D(item.X >> 3, item.Y >> 3); Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
DeltaState state = table[p]; if (!table.TryGetValue(p, out DeltaState state))
if (state == null)
table[p] = state = new DeltaState(p); table[p] = state = new DeltaState(p);
state.m_List.Add(item); state.m_List.Add(item);

View file

@ -953,10 +953,7 @@ namespace Server.Engines.CannedEvil
if (from == null || !from.Player) if (from == null || !from.Player)
return; return;
if (m_DamageEntries.ContainsKey(from)) m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0);
m_DamageEntries[from] += amount;
else
m_DamageEntries.Add(from, amount);
} }
public void AwardArtifact(Item artifact) public void AwardArtifact(Item artifact)
@ -1073,12 +1070,10 @@ namespace Server.Engines.CannedEvil
case 5: case 5:
{ {
int entries = reader.ReadInt(); int entries = reader.ReadInt();
Mobile m;
int damage;
for (int i = 0; i < entries; ++i) for (int i = 0; i < entries; ++i)
{ {
m = reader.ReadMobile(); Mobile m = reader.ReadMobile();
damage = reader.ReadInt(); int damage = reader.ReadInt();
if (m == null) if (m == null)
continue; continue;

View file

@ -117,9 +117,7 @@ namespace Server.Engines.ConPVP
public static void BeginIgnore(Mobile source, Mobile toIgnore) public static void BeginIgnore(Mobile source, Mobile toIgnore)
{ {
List<IgnoreEntry> list = m_IgnoreLists[source]; if (!m_IgnoreLists.TryGetValue(source, out List<IgnoreEntry> list))
if (list == null)
m_IgnoreLists[source] = list = new List<IgnoreEntry>(); m_IgnoreLists[source] = list = new List<IgnoreEntry>();
for (int i = 0; i < list.Count; ++i) for (int i = 0; i < list.Count; ++i)
@ -141,9 +139,7 @@ namespace Server.Engines.ConPVP
public static bool IsIgnored(Mobile source, Mobile check) public static bool IsIgnored(Mobile source, Mobile check)
{ {
List<IgnoreEntry> list = m_IgnoreLists[source]; if (!m_IgnoreLists.TryGetValue(source, out List<IgnoreEntry> list))
if (list == null)
return false; return false;
for (int i = 0; i < list.Count; ++i) for (int i = 0; i < list.Count; ++i)

View file

@ -1247,7 +1247,7 @@ namespace Server.Engines.ConPVP
if (mob == null) if (mob == null)
return null; return null;
if (!(Players[mob] is BRPlayerInfo val)) if (!Players.TryGetValue(mob, out BRPlayerInfo val))
Players[mob] = val = new BRPlayerInfo(this, mob); Players[mob] = val = new BRPlayerInfo(this, mob);
return val; return val;

View file

@ -604,7 +604,7 @@ namespace Server.Engines.ConPVP
if (mob == null) if (mob == null)
return null; return null;
if (!(Players[mob] is KHPlayerInfo val)) if (!Players.TryGetValue(mob, out KHPlayerInfo val))
Players[mob] = val = new KHPlayerInfo(this, mob); Players[mob] = val = new KHPlayerInfo(this, mob);
return val; return val;

View file

@ -269,9 +269,7 @@ namespace Server.Engines.ConPVP
public LadderEntry Find(Mobile mob) public LadderEntry Find(Mobile mob)
{ {
LadderEntry entry = m_Table[mob]; if (m_Table.TryGetValue(mob, out LadderEntry entry))
if (entry == null)
{ {
m_Table[mob] = entry = new LadderEntry(mob, this); m_Table[mob] = entry = new LadderEntry(mob, this);
entry.Index = Entries.Count; entry.Index = Entries.Count;
@ -283,7 +281,8 @@ namespace Server.Engines.ConPVP
public LadderEntry FindNoCreate(Mobile mob) public LadderEntry FindNoCreate(Mobile mob)
{ {
return m_Table[mob]; m_Table.TryGetValue(mob, out LadderEntry entry);
return entry;
} }
public void Serialize(GenericWriter writer) public void Serialize(GenericWriter writer)

View file

@ -107,9 +107,7 @@ namespace Server.Engines.ConPVP
public PreferencesEntry Find(Mobile mob) public PreferencesEntry Find(Mobile mob)
{ {
PreferencesEntry entry = m_Table[mob]; if (m_Table.TryGetValue(mob, out PreferencesEntry entry))
if (entry == null)
{ {
m_Table[mob] = entry = new PreferencesEntry(mob); m_Table[mob] = entry = new PreferencesEntry(mob);
Entries.Add(entry); Entries.Add(entry);

View file

@ -110,50 +110,50 @@ namespace Server.Engines.Craft
public static int ItemIDOf(Type type) public static int ItemIDOf(Type type)
{ {
if (!_itemIds.TryGetValue(type, out int itemId)) if (_itemIds.TryGetValue(type, out int itemId))
return itemId;
if (type == typeof(FactionExplosionTrap))
itemId = 14034;
else if (type == typeof(FactionGasTrap))
itemId = 4523;
else if (type == typeof(FactionSawTrap))
itemId = 4359;
else if (type == typeof(FactionSpikeTrap)) itemId = 4517;
if (itemId == 0)
{ {
if (type == typeof(FactionExplosionTrap)) object[] attrs = type.GetCustomAttributes(typeof(CraftItemIDAttribute), false);
itemId = 14034;
else if (type == typeof(FactionGasTrap))
itemId = 4523;
else if (type == typeof(FactionSawTrap))
itemId = 4359;
else if (type == typeof(FactionSpikeTrap)) itemId = 4517;
if (itemId == 0) if (attrs.Length > 0)
{ {
object[] attrs = type.GetCustomAttributes(typeof(CraftItemIDAttribute), false); CraftItemIDAttribute craftItemID = (CraftItemIDAttribute)attrs[0];
itemId = craftItemID.ItemID;
if (attrs.Length > 0)
{
CraftItemIDAttribute craftItemID = (CraftItemIDAttribute)attrs[0];
itemId = craftItemID.ItemID;
}
} }
if (itemId == 0)
{
Item item = null;
try
{
item = Activator.CreateInstance(type) as Item;
}
catch
{
// ignored
}
if (item != null)
{
itemId = item.ItemID;
item.Delete();
}
}
_itemIds[type] = itemId;
} }
if (itemId == 0)
{
Item item = null;
try
{
item = Activator.CreateInstance(type) as Item;
}
catch
{
// ignored
}
if (item != null)
{
itemId = item.ItemID;
item.Delete();
}
}
_itemIds[type] = itemId;
return itemId; return itemId;
} }

View file

@ -81,9 +81,7 @@ namespace Server.Engines.Craft
return null; return null;
} }
m_ContextTable.TryGetValue(m, out CraftContext c); if (!m_ContextTable.TryGetValue(m, out CraftContext c))
if (c == null)
m_ContextTable[m] = c = new CraftContext(); m_ContextTable[m] = c = new CraftContext();
return c; return c;
@ -91,9 +89,7 @@ namespace Server.Engines.Craft
public void OnMade(Mobile m, CraftItem item) public void OnMade(Mobile m, CraftItem item)
{ {
CraftContext c = GetContext(m); GetContext(m)?.OnMade(item);
c?.OnMade(item);
} }
public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem) public virtual bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem)
@ -104,8 +100,8 @@ namespace Server.Engines.Craft
public void CreateItem(Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem) public void CreateItem(Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem)
{ {
// Verify if the type is in the list of the craftable item // Verify if the type is in the list of the craftable item
CraftItem craftItem = CraftItems.SearchFor(type); if (CraftItems.SearchFor(type) != null)
if (craftItem != null) realCraftItem.Craft(from, this, typeRes, tool); realCraftItem.Craft(from, this, typeRes, tool);
} }
public int RandomRecipe() public int RandomRecipe()

View file

@ -5,11 +5,6 @@ namespace Server.Engines.Harvest
{ {
public class HarvestDefinition public class HarvestDefinition
{ {
public HarvestDefinition()
{
Banks = new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
}
public int BankWidth{ get; set; } public int BankWidth{ get; set; }
public int BankHeight{ get; set; } public int BankHeight{ get; set; }
@ -70,7 +65,8 @@ namespace Server.Engines.Harvest
public bool RandomizeVeins{ get; set; } public bool RandomizeVeins{ get; set; }
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get; set; } public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get; }
= new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
public void SendMessageTo(Mobile from, object message) public void SendMessageTo(Mobile from, object message)
{ {
@ -88,15 +84,12 @@ namespace Server.Engines.Harvest
x /= BankWidth; x /= BankWidth;
y /= BankHeight; y /= BankHeight;
Banks.TryGetValue(map, out Dictionary<Point2D, HarvestBank> banks); if (!Banks.TryGetValue(map, out Dictionary<Point2D, HarvestBank> banks))
if (banks == null)
Banks[map] = banks = new Dictionary<Point2D, HarvestBank>(); Banks[map] = banks = new Dictionary<Point2D, HarvestBank>();
Point2D key = new Point2D(x, y); Point2D key = new Point2D(x, y);
banks.TryGetValue(key, out HarvestBank bank);
if (bank == null) if (!banks.TryGetValue(key, out HarvestBank bank))
banks[key] = bank = new HarvestBank(this, GetVeinAt(map, x, y)); banks[key] = bank = new HarvestBank(this, GetVeinAt(map, x, y));
return bank; return bank;

View file

@ -199,9 +199,7 @@ namespace Server.Engines.Help
[Description("Opens the page queue menu.")] [Description("Opens the page queue menu.")]
private static void Pages_OnCommand(CommandEventArgs e) private static void Pages_OnCommand(CommandEventArgs e)
{ {
PageEntry entry = (PageEntry)m_KeyedByHandler[e.Mobile]; if (m_KeyedByHandler.TryGetValue(e.Mobile, out PageEntry entry))
if (entry != null)
e.Mobile.SendGump(new PageEntryGump(e.Mobile, entry)); e.Mobile.SendGump(new PageEntryGump(e.Mobile, entry));
else if (List.Count > 0) else if (List.Count > 0)
e.Mobile.SendGump(new PageQueueGump()); e.Mobile.SendGump(new PageQueueGump());
@ -224,11 +222,6 @@ namespace Server.Engines.Help
return List.IndexOf(e); return List.IndexOf(e);
} }
public static void Cancel(Mobile sender)
{
Remove((PageEntry)m_KeyedBySender[sender]);
}
public static void Remove(PageEntry e) public static void Remove(PageEntry e)
{ {
if (e == null) if (e == null)
@ -245,7 +238,8 @@ namespace Server.Engines.Help
public static PageEntry GetEntry(Mobile sender) public static PageEntry GetEntry(Mobile sender)
{ {
return (PageEntry)m_KeyedBySender[sender]; m_KeyedBySender.TryGetValue(sender, out PageEntry entry);
return entry;
} }
public static void Remove(Mobile sender) public static void Remove(Mobile sender)
@ -285,9 +279,10 @@ namespace Server.Engines.Help
Mobile sender = entry.Sender; Mobile sender = entry.Sender;
DateTime time = DateTime.UtcNow; DateTime time = DateTime.UtcNow;
MailMessage mail = new MailMessage(Email.FromAddress, Email.SpeechLogPageAddresses); MailMessage mail = new MailMessage(Email.FromAddress, Email.SpeechLogPageAddresses)
{
mail.Subject = "RunUO Speech Log Page Forwarding"; Subject = "RunUO Speech Log Page Forwarding"
};
using (StringWriter writer = new StringWriter()) using (StringWriter writer = new StringWriter())
{ {

View file

@ -108,7 +108,7 @@ namespace Server.Engines.MLQuests.Gumps
private static void Timeout(NetState ns) private static void Timeout(NetState ns)
{ {
if (m_Pending.ContainsKey(ns)) if (IsPending(ns))
{ {
m_Pending.Remove(ns); m_Pending.Remove(ns);
ns.Send(CloseRaceChanger.Instance); ns.Send(CloseRaceChanger.Instance);

View file

@ -26,12 +26,7 @@ namespace Server.Engines.MLQuests
object[] attributes = t.GetCustomAttributes(m_Type, false); object[] attributes = t.GetCustomAttributes(m_Type, false);
if (attributes.Length != 0) return m_Cache[t] = attributes.Length != 0 ? ((QuesterNameAttribute)attributes[0]).QuesterName : t.Name;
result = ((QuesterNameAttribute)attributes[0]).QuesterName;
else
result = t.Name;
return m_Cache[t] = result;
} }
} }
} }

View file

@ -17,8 +17,7 @@ namespace Server.Engines.PartySystem
public static void Start(Mobile m, Mobile leader) public static void Start(Mobile m, Mobile leader)
{ {
DeclineTimer t = m_Table[m]; m_Table.TryGetValue(m, out DeclineTimer t);
t?.Stop(); t?.Stop();
m_Table[m] = t = new DeclineTimer(m, leader); m_Table[m] = t = new DeclineTimer(m, leader);

View file

@ -87,12 +87,13 @@ namespace Server.Items
private static OrangePetalsContext GetContext(Mobile m) private static OrangePetalsContext GetContext(Mobile m)
{ {
return m_Table[m] as OrangePetalsContext; m_Table.TryGetValue(m, out OrangePetalsContext context);
return context;
} }
public static bool UnderEffect(Mobile m) public static bool UnderEffect(Mobile m)
{ {
return GetContext(m) != null; return m_Table.ContainsKey(m);
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -43,27 +43,29 @@ namespace Server.Engines.Plants
static PlantHueInfo() static PlantHueInfo()
{ {
m_Table = new Dictionary<PlantHue, PlantHueInfo>(); m_Table = new Dictionary<PlantHue, PlantHueInfo>
{
[PlantHue.Plain] = new PlantHueInfo(0, 1060813, PlantHue.Plain, 0x835),
[PlantHue.Red] = new PlantHueInfo(0x66D, 1060814, PlantHue.Red, 0x24),
[PlantHue.Blue] = new PlantHueInfo(0x53D, 1060815, PlantHue.Blue, 0x6),
[PlantHue.Yellow] = new PlantHueInfo(0x8A5, 1060818, PlantHue.Yellow, 0x38),
[PlantHue.BrightRed] = new PlantHueInfo(0x21, 1060814, PlantHue.BrightRed, 0x21),
[PlantHue.BrightBlue] = new PlantHueInfo(0x5, 1060815, PlantHue.BrightBlue, 0x6),
[PlantHue.BrightYellow] = new PlantHueInfo(0x38, 1060818, PlantHue.BrightYellow, 0x35),
[PlantHue.Purple] = new PlantHueInfo(0xD, 1060816, PlantHue.Purple, 0x10),
[PlantHue.Green] = new PlantHueInfo(0x59B, 1060819, PlantHue.Green, 0x42),
[PlantHue.Orange] = new PlantHueInfo(0x46F, 1060817, PlantHue.Orange, 0x2E),
[PlantHue.BrightPurple] = new PlantHueInfo(0x10, 1060816, PlantHue.BrightPurple, 0xD),
[PlantHue.BrightGreen] = new PlantHueInfo(0x42, 1060819, PlantHue.BrightGreen, 0x3F),
[PlantHue.BrightOrange] = new PlantHueInfo(0x2B, 1060817, PlantHue.BrightOrange, 0x2B),
[PlantHue.Black] = new PlantHueInfo(0x455, 1060820, PlantHue.Black, 0),
[PlantHue.White] = new PlantHueInfo(0x481, 1060821, PlantHue.White, 0x481),
[PlantHue.Pink] = new PlantHueInfo(0x48E, 1061854, PlantHue.Pink),
[PlantHue.Magenta] = new PlantHueInfo(0x486, 1061852, PlantHue.Magenta),
[PlantHue.Aqua] = new PlantHueInfo(0x495, 1061853, PlantHue.Aqua),
[PlantHue.FireRed] = new PlantHueInfo(0x489, 1061855, PlantHue.FireRed)
};
m_Table[PlantHue.Plain] = new PlantHueInfo(0, 1060813, PlantHue.Plain, 0x835);
m_Table[PlantHue.Red] = new PlantHueInfo(0x66D, 1060814, PlantHue.Red, 0x24);
m_Table[PlantHue.Blue] = new PlantHueInfo(0x53D, 1060815, PlantHue.Blue, 0x6);
m_Table[PlantHue.Yellow] = new PlantHueInfo(0x8A5, 1060818, PlantHue.Yellow, 0x38);
m_Table[PlantHue.BrightRed] = new PlantHueInfo(0x21, 1060814, PlantHue.BrightRed, 0x21);
m_Table[PlantHue.BrightBlue] = new PlantHueInfo(0x5, 1060815, PlantHue.BrightBlue, 0x6);
m_Table[PlantHue.BrightYellow] = new PlantHueInfo(0x38, 1060818, PlantHue.BrightYellow, 0x35);
m_Table[PlantHue.Purple] = new PlantHueInfo(0xD, 1060816, PlantHue.Purple, 0x10);
m_Table[PlantHue.Green] = new PlantHueInfo(0x59B, 1060819, PlantHue.Green, 0x42);
m_Table[PlantHue.Orange] = new PlantHueInfo(0x46F, 1060817, PlantHue.Orange, 0x2E);
m_Table[PlantHue.BrightPurple] = new PlantHueInfo(0x10, 1060816, PlantHue.BrightPurple, 0xD);
m_Table[PlantHue.BrightGreen] = new PlantHueInfo(0x42, 1060819, PlantHue.BrightGreen, 0x3F);
m_Table[PlantHue.BrightOrange] = new PlantHueInfo(0x2B, 1060817, PlantHue.BrightOrange, 0x2B);
m_Table[PlantHue.Black] = new PlantHueInfo(0x455, 1060820, PlantHue.Black, 0);
m_Table[PlantHue.White] = new PlantHueInfo(0x481, 1060821, PlantHue.White, 0x481);
m_Table[PlantHue.Pink] = new PlantHueInfo(0x48E, 1061854, PlantHue.Pink);
m_Table[PlantHue.Magenta] = new PlantHueInfo(0x486, 1061852, PlantHue.Magenta);
m_Table[PlantHue.Aqua] = new PlantHueInfo(0x495, 1061853, PlantHue.Aqua);
m_Table[PlantHue.FireRed] = new PlantHueInfo(0x489, 1061855, PlantHue.FireRed);
} }
private PlantHueInfo(int hue, int name, PlantHue plantHue) : this(hue, name, plantHue, hue) private PlantHueInfo(int hue, int name, PlantHue plantHue) : this(hue, name, plantHue, hue)
@ -88,9 +90,7 @@ namespace Server.Engines.Plants
public static PlantHueInfo GetInfo(PlantHue plantHue) public static PlantHueInfo GetInfo(PlantHue plantHue)
{ {
if (m_Table.TryGetValue(plantHue, out PlantHueInfo info)) return m_Table.TryGetValue(plantHue, out PlantHueInfo info) ? info : m_Table[PlantHue.Plain];
return info;
return m_Table[PlantHue.Plain];
} }
public static PlantHue RandomFirstGeneration() public static PlantHue RandomFirstGeneration()

View file

@ -118,14 +118,14 @@ namespace Server.Engines.Quests.Necro
public override void CheckProgress() public override void CheckProgress()
{ {
if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(1076, 450, -84), 5)) if (System.From.Map != Map.Malas || !System.From.InRange(new Point3D(1076, 450, -84), 5) ||
if (SummonFamiliarSpell.Table[System.From] is HordeMinionFamiliar hmf && hmf.InRange(System.From, 5) && !SummonFamiliarSpell.Table.TryGetValue(System.From, out BaseCreature bc) || !(bc is HordeMinionFamiliar hmf) ||
hmf.TargetLocation == null) !hmf.InRange(System.From, 5) || hmf.TargetLocation != null)
{ return;
System.From.SendLocalizedMessage(
1060113); // You instinctively will your familiar to fetch the scroll for you. System.From.SendLocalizedMessage(
hmf.TargetLocation = new Point2D(1076, 450); 1060113); // You instinctively will your familiar to fetch the scroll for you.
} hmf.TargetLocation = new Point2D(1076, 450);
} }
public override void OnComplete() public override void OnComplete()

View file

@ -45,7 +45,7 @@ namespace Server.Engines.Reports
if (string.IsNullOrEmpty(account)) if (string.IsNullOrEmpty(account))
return null; return null;
if (!(StaffInfo[account] is StaffInfo info)) if (!StaffInfo.TryGetValue(account, out StaffInfo info))
StaffInfo[account] = info = new StaffInfo(account); StaffInfo[account] = info = new StaffInfo(account);
return info; return info;
@ -57,7 +57,7 @@ namespace Server.Engines.Reports
if (string.IsNullOrEmpty(account)) if (string.IsNullOrEmpty(account))
return null; return null;
if (!(UserInfo[account] is UserInfo info)) if (!UserInfo.TryGetValue(account, out UserInfo info))
UserInfo[account] = info = new UserInfo(account); UserInfo[account] = info = new UserInfo(account);
return info; return info;

View file

@ -32,7 +32,8 @@ namespace Server.Engines.Reports
public static PersistableType Find(string name) public static PersistableType Find(string name)
{ {
return m_Table[name]; m_Table.TryGetValue(name, out PersistableType value);
return value;
} }
public static void Register(PersistableType type) public static void Register(PersistableType type)

View file

@ -209,12 +209,7 @@ namespace Server.Mobiles
false); false);
} }
public SpawnerEntry AddEntry(string creaturename, int probability, int amount) public SpawnerEntry AddEntry(string creaturename, int probability, int amount, bool dotimer = true)
{
return AddEntry(creaturename, probability, amount, true);
}
public SpawnerEntry AddEntry(string creaturename, int probability, int amount, bool dotimer)
{ {
SpawnerEntry entry = new SpawnerEntry(creaturename, probability, amount); SpawnerEntry entry = new SpawnerEntry(creaturename, probability, amount);
Entries.Add(entry); Entries.Add(entry);

View file

@ -77,9 +77,7 @@ namespace Server
return; return;
} }
m_Callbacks.TryGetValue(e.GumpID, out OnVirtueUsed callback); if (m_Callbacks.TryGetValue(e.GumpID, out OnVirtueUsed callback))
if (callback != null)
callback(e.Beholder); callback(e.Beholder);
else else
e.Beholder.SendLocalizedMessage(1052066); // That virtue is not active yet. e.Beholder.SendLocalizedMessage(1052066); // That virtue is not active yet.

View file

@ -181,9 +181,7 @@ namespace Server.Gumps
else else
tree = Tokuno; tree = Tokuno;
tree.LastBranch.TryGetValue(from, out ParentNode branch); if (!tree.LastBranch.TryGetValue(from, out ParentNode branch))
if (branch == null)
branch = tree.Root; branch = tree.Root;
if (branch != null) if (branch != null)

View file

@ -15,9 +15,7 @@ namespace Server.Gumps
if (File.Exists(path)) if (File.Exists(path))
{ {
XmlTextReader xml = new XmlTextReader(new StreamReader(path)); XmlTextReader xml = new XmlTextReader(new StreamReader(path)) { WhitespaceHandling = WhitespaceHandling.None };
xml.WhitespaceHandling = WhitespaceHandling.None;
Root = Parse(xml); Root = Parse(xml);

View file

@ -250,10 +250,8 @@ namespace Server.Engines.Events
{ {
if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted ) if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted )
{ {
if ( HalloweenHauntings.ReAnimated.Count > 0 && HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) ) if ( HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) )
{
HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer ); HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer );
}
} }
} }
} }
@ -261,7 +259,7 @@ namespace Server.Engines.Events
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( ( int )0 ); writer.Write( 0 );
writer.WriteMobile( m_DeadPlayer ); writer.WriteMobile( m_DeadPlayer );
} }
@ -271,7 +269,7 @@ namespace Server.Engines.Events
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadInt(); int version = reader.ReadInt();
m_DeadPlayer = ( PlayerMobile )reader.ReadMobile(); m_DeadPlayer = reader.ReadMobile<PlayerMobile>();
} }
} }
} }

View file

@ -95,9 +95,7 @@ namespace Server.Items
if ( m_Entries == null ) if ( m_Entries == null )
m_Entries = new Dictionary<Mobile, ScoreEntry>(); m_Entries = new Dictionary<Mobile, ScoreEntry>();
ScoreEntry e = m_Entries[from]; if (!m_Entries.TryGetValue(from, out ScoreEntry e))
if ( e == null )
m_Entries[from] = e = new ScoreEntry(); m_Entries[from] = e = new ScoreEntry();
return e; return e;

View file

@ -1529,7 +1529,7 @@ namespace Server.Items
!(nearest is Cobbler && mob is Provisioner)) !(nearest is Cobbler && mob is Provisioner))
continue; continue;
if (m_AcquireTable[mob.GetType()] is FillableContent check) if (m_AcquireTable.TryGetValue(mob.GetType(), out FillableContent check))
{ {
nearest = mob; nearest = mob;
content = check; content = check;

View file

@ -390,9 +390,7 @@ namespace Server.Items
public static void Close(Container c) public static void Close(Container c)
{ {
m_Table.TryGetValue(c, out Timer t); if (m_Table.TryGetValue(c, out Timer t))
if (t != null)
{ {
t.Stop(); t.Stop();
m_Table.Remove(c); m_Table.Remove(c);

View file

@ -219,7 +219,11 @@ namespace Server.Items
public static StealableInstance GetStealableInstance(Item item) public static StealableInstance GetStealableInstance(Item item)
{ {
return (StealableInstance)Instance?.m_Table[item]; if (Instance == null)
return null;
Instance.m_Table.TryGetValue(item, out StealableInstance value);
return value;
} }
public override void OnDelete() public override void OnDelete()

View file

@ -1106,30 +1106,23 @@ namespace Server.Items
{ {
if (from.BAC > 0 && from.Map != Map.Internal && !from.Deleted) if (from.BAC > 0 && from.Map != Map.Internal && !from.Deleted)
{ {
Timer t = m_Table[from]; if (m_Table.ContainsKey(from))
return;
if (t == null) if (from.BAC > 60)
{ from.BAC = 60;
if (from.BAC > 60)
from.BAC = 60;
t = new HeaveTimer(from); Timer t = new HeaveTimer(from);
t.Start(); t.Start();
m_Table[from] = t; m_Table[from] = t;
}
} }
else else if (m_Table.TryGetValue(from, out Timer t))
{ {
Timer t = m_Table[from]; t.Stop();
m_Table.Remove(from);
if (t != null) from.SendLocalizedMessage(500850); // You feel sober.
{
t.Stop();
m_Table.Remove(from);
from.SendLocalizedMessage(500850); // You feel sober.
}
} }
} }

View file

@ -342,9 +342,9 @@ namespace Server.Items
if (!m.Player || m.AccessLevel > AccessLevel.Player) //Staff and creatures not subject to instancing. if (!m.Player || m.AccessLevel > AccessLevel.Player) //Staff and creatures not subject to instancing.
return true; return true;
if (m_InstancedItems != null) if (m_InstancedItems != null && m_InstancedItems.TryGetValue(child, out InstancedItemInfo info)
if (m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) && (InstancedCorpse || info.Perpetual)) && (InstancedCorpse || info.Perpetual))
return info.IsOwner(m); //IsOwner checks Party stuff. return info.IsOwner(m); //IsOwner checks Party stuff.
return true; return true;
} }
@ -830,7 +830,7 @@ namespace Server.Items
if (!Looters.Contains(from)) if (!Looters.Contains(from))
Looters.Add(from); Looters.Add(from);
if (m_InstancedItems != null && m_InstancedItems.ContainsKey(item)) if (m_InstancedItems?.ContainsKey(item) == true)
m_InstancedItems.Remove(item); m_InstancedItems.Remove(item);
} }
@ -847,7 +847,7 @@ namespace Server.Items
if (!Looters.Contains(from)) if (!Looters.Contains(from))
Looters.Add(from); Looters.Add(from);
if (m_InstancedItems != null && m_InstancedItems.ContainsKey(item)) if (m_InstancedItems?.ContainsKey(item) == true)
m_InstancedItems.Remove(item); m_InstancedItems.Remove(item);
} }
@ -891,12 +891,7 @@ namespace Server.Items
if (!IsCriminalAction(from)) if (!IsCriminalAction(from))
return true; return true;
Map map = Map; return Map != null && (Map.Rules & MapRules.HarmfulRestrictions) == 0;
if (map == null || (map.Rules & MapRules.HarmfulRestrictions) != 0)
return false;
return true;
} }
public bool CheckLoot(Mobile from, Item item) public bool CheckLoot(Mobile from, Item item)

View file

@ -58,7 +58,7 @@ namespace Server.Items
{ {
private static readonly TimeSpan m_UseTimeout = TimeSpan.FromMinutes(2.0); private static readonly TimeSpan m_UseTimeout = TimeSpan.FromMinutes(2.0);
private Dictionary<Mobile, DamageTimer> m_DamageTable = new Dictionary<Mobile, DamageTimer>(); private HashSet<Mobile> m_DamageTable = new HashSet<Mobile>();
private DateTime m_LastUse; private DateTime m_LastUse;
private int m_SideLength; private int m_SideLength;
@ -217,12 +217,12 @@ namespace Server.Items
if (!to.Alive) if (!to.Alive)
return; return;
if (m_DamageTable[to] == null) if (!m_DamageTable.Contains(to))
{ {
to.Frozen = true; to.Frozen = true;
DamageTimer timer = new DamageTimer(this, to); DamageTimer timer = new DamageTimer(this, to);
m_DamageTable[to] = timer; m_DamageTable.Add(to);
timer.Start(); timer.Start();
} }

View file

@ -690,7 +690,7 @@ namespace Server.Items
m.SendLocalizedMessage(ProgressNumber); m.SendLocalizedMessage(ProgressNumber);
if (ShowTimeRemaining) if (ShowTimeRemaining)
m.SendMessage("Time remaining: {0}", FormatTime(m_Table[m].Timer.Next - DateTime.UtcNow)); m.SendMessage("Time remaining: {0}", FormatTime(info.Timer.Next - DateTime.UtcNow));
Timer.DelayCall(TimeSpan.FromSeconds(5), EndLock, m); Timer.DelayCall(TimeSpan.FromSeconds(5), EndLock, m);
} }
@ -764,19 +764,12 @@ namespace Server.Items
private Dictionary<Mobile, Timer> m_Teleporting; private Dictionary<Mobile, Timer> m_Teleporting;
[Constructible] [Constructible]
public TimeoutTeleporter() public TimeoutTeleporter() : this(new Point3D(0, 0, 0))
: this(new Point3D(0, 0, 0), null, false)
{ {
} }
[Constructible] [Constructible]
public TimeoutTeleporter(Point3D pointDest, Map mapDest) public TimeoutTeleporter(Point3D pointDest, Map mapDest = null, bool creatures = false)
: this(pointDest, mapDest, false)
{
}
[Constructible]
public TimeoutTeleporter(Point3D pointDest, Map mapDest, bool creatures)
: base(pointDest, mapDest, creatures) : base(pointDest, mapDest, creatures)
{ {
m_Teleporting = new Dictionary<Mobile, Timer>(); m_Teleporting = new Dictionary<Mobile, Timer>();

View file

@ -46,7 +46,7 @@ namespace Server.Items
{ {
CampfireEntry entry = Campfire.GetEntry(from); CampfireEntry entry = Campfire.GetEntry(from);
if (entry != null && entry.Safe) if (entry?.Safe == true)
from.SendGump(new LogoutGump(entry, this)); from.SendGump(new LogoutGump(entry, this));
} }
} }

View file

@ -86,7 +86,8 @@ namespace Server.Items
public static CampfireEntry GetEntry(Mobile player) public static CampfireEntry GetEntry(Mobile player)
{ {
return m_Table[player]; m_Table.TryGetValue(player, out CampfireEntry value);
return value;
} }
public static void RemoveEntry(CampfireEntry entry) public static void RemoveEntry(CampfireEntry entry)

View file

@ -288,14 +288,14 @@ namespace Server.Items
public static void AddDelay(Mobile m) public static void AddDelay(Mobile m)
{ {
m_Delay[m]?.Stop(); m_Delay.TryGetValue(m, out Timer timer);
timer?.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), EndDelay, m); m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), EndDelay, m);
} }
public static int GetDelay(Mobile m) public static int GetDelay(Mobile m)
{ {
Timer timer = m_Delay[m]; if (m_Delay.TryGetValue(m, out Timer timer) && timer.Next > DateTime.UtcNow)
if (timer?.Next > DateTime.UtcNow)
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
return 0; return 0;
@ -303,9 +303,7 @@ namespace Server.Items
public static void EndDelay(Mobile m) public static void EndDelay(Mobile m)
{ {
Timer timer = m_Delay[m]; if (m_Delay.TryGetValue(m, out Timer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
m_Delay.Remove(m); m_Delay.Remove(m);

View file

@ -153,14 +153,14 @@ namespace Server.Items
public static void AddDelay(Mobile m) public static void AddDelay(Mobile m)
{ {
m_Delay[m]?.Stop(); m_Delay.TryGetValue(m, out Timer timer);
timer?.Stop();
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(60), EndDelay, m); m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(60), EndDelay, m);
} }
public static int GetDelay(Mobile m) public static int GetDelay(Mobile m)
{ {
Timer timer = m_Delay[m]; if (m_Delay.TryGetValue(m, out Timer timer) && timer.Next > DateTime.UtcNow)
if (timer?.Next > DateTime.UtcNow)
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
return 0; return 0;
@ -168,8 +168,7 @@ namespace Server.Items
public static void EndDelay(Mobile m) public static void EndDelay(Mobile m)
{ {
Timer timer = m_Delay[m]; if (m_Delay.TryGetValue(m, out Timer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
m_Delay.Remove(m); m_Delay.Remove(m);

View file

@ -63,26 +63,20 @@ namespace Server.Items
public static bool HasTimer(Mobile m) public static bool HasTimer(Mobile m)
{ {
return m_Table[m] != null; return m_Table.ContainsKey(m);
} }
public static void RemoveTimer(Mobile m) public static void RemoveTimer(Mobile m, bool interrupted = false)
{ {
Timer timer = m_Table[m]; if (m_Table.TryGetValue(m, out Timer timer))
if (timer != null)
{ {
if (interrupted)
m.SendLocalizedMessage(1073187); // The invisibility effect is interrupted.
timer.Stop(); timer.Stop();
m_Table.Remove(m); m_Table.Remove(m);
} }
} }
public static void Iterrupt(Mobile m)
{
m.SendLocalizedMessage(1073187); // The invisibility effect is interrupted.
RemoveTimer(m);
}
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
{ {
base.Serialize(writer); base.Serialize(writer);

View file

@ -435,11 +435,9 @@ namespace Server.Items
return null; return null;
} }
m_Table.TryGetValue(from, out List<Spellbook> list);
bool searchAgain = false; bool searchAgain = false;
if (list == null) if (!m_Table.TryGetValue(from, out List<Spellbook> list))
m_Table[from] = list = FindAllSpellbooks(from); m_Table[from] = list = FindAllSpellbooks(from);
else else
searchAgain = true; searchAgain = true;

View file

@ -42,10 +42,8 @@ namespace Server.Items
{ {
get get
{ {
if (Recipe.Recipes.ContainsKey(m_RecipeID)) Recipe.Recipes.TryGetValue(m_RecipeID, out Recipe recipe);
return Recipe.Recipes[m_RecipeID]; return recipe;
return null;
} }
} }

View file

@ -203,12 +203,8 @@ namespace Server.Items
public static BaseInstrument GetInstrument(Mobile from) public static BaseInstrument GetInstrument(Mobile from)
{ {
BaseInstrument item = m_Instruments[from]; if (m_Instruments.TryGetValue(from, out BaseInstrument instrument) && instrument.IsChildOf(from.Backpack))
if (item == null) return instrument;
return null;
if (item.IsChildOf(from.Backpack))
return item;
m_Instruments.Remove(from); m_Instruments.Remove(from);
return null; return null;
@ -222,7 +218,6 @@ namespace Server.Items
public static void PickInstrument(Mobile from, InstrumentPickedCallback callback) public static void PickInstrument(Mobile from, InstrumentPickedCallback callback)
{ {
BaseInstrument instrument = GetInstrument(from); BaseInstrument instrument = GetInstrument(from);
if (instrument != null) if (instrument != null)
{ {
callback?.Invoke(from, instrument); callback?.Invoke(from, instrument);
@ -531,7 +526,7 @@ namespace Server.Items
{ {
SetInstrument(from, this); SetInstrument(from, this);
// Delay of 7 second before beign able to play another instrument again // Delay of 7 second before being able to play another instrument again
new InternalTimer(from).Start(); new InternalTimer(from).Start();
if (CheckMusicianship(from)) if (CheckMusicianship(from))

View file

@ -65,7 +65,7 @@ namespace Server.Items
ConsumeUse(weapon); ConsumeUse(weapon);
if (CombatCheck(from, target)) if (CombatCheck(from, target))
Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnHit, new object[] { from, target, weapon }); Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => OnHit(from, target, weapon));
Timer.DelayCall(TimeSpan.FromSeconds(2.5), ResetUsing, from); Timer.DelayCall(TimeSpan.FromSeconds(2.5), ResetUsing, from);
} }
@ -187,15 +187,15 @@ namespace Server.Items
BaseWeapon defWeapon = defender.Weapon as BaseWeapon; BaseWeapon defWeapon = defender.Weapon as BaseWeapon;
Skill atkSkill = defender.Skills.Ninjitsu; Skill atkSkill = defender.Skills.Ninjitsu;
Skill defSkill = defender.Skills[defWeapon.Skill]; // Skill defSkill = defender.Skills[defWeapon.Skill];
double atSkillValue = attacker.Skills.Ninjitsu.Value; double atSkillValue = attacker.Skills.Ninjitsu.Value;
double defSkillValue = defWeapon.GetDefendSkillValue(attacker, defender); double defSkillValue = defWeapon?.GetDefendSkillValue(attacker, defender) ?? 0.0;
double attackValue = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);
if (defSkillValue <= -20.0) defSkillValue = -19.9; if (defSkillValue <= -20.0) defSkillValue = -19.9;
double attackValue = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);
if (DivineFurySpell.UnderEffect(attacker)) attackValue += 10; if (DivineFurySpell.UnderEffect(attacker)) attackValue += 10;
if (AnimalForm.UnderTransformation(attacker, typeof(GreyWolf)) || if (AnimalForm.UnderTransformation(attacker, typeof(GreyWolf)) ||
@ -230,29 +230,24 @@ namespace Server.Items
return attacker.CheckSkill(atkSkill.SkillName, chance); return attacker.CheckSkill(atkSkill.SkillName, chance);
} }
private static void OnHit(object[] states) private static void OnHit(Mobile from, Mobile target, INinjaWeapon weapon)
{ {
Mobile from = states[0] as Mobile; if (!from.CanBeHarmful(target))
Mobile target = states[1] as Mobile; return;
INinjaWeapon weapon = states[2] as INinjaWeapon; from.DoHarmful(target);
if (from.CanBeHarmful(target)) AOS.Damage(target, from, weapon.WeaponDamage, 100, 0, 0, 0, 0);
if (weapon.Poison != null && weapon.PoisonCharges > 0)
{ {
from.DoHarmful(target); if (EvilOmenSpell.TryEndEffect(target))
target.ApplyPoison(from, Poison.GetPoison(weapon.Poison.Level + 1));
else
target.ApplyPoison(from, weapon.Poison);
AOS.Damage(target, from, weapon.WeaponDamage, 100, 0, 0, 0, 0); weapon.PoisonCharges--;
if (weapon.Poison != null && weapon.PoisonCharges > 0) if (weapon.PoisonCharges < 1) weapon.Poison = null;
{
if (EvilOmenSpell.TryEndEffect(target))
target.ApplyPoison(from, Poison.GetPoison(weapon.Poison.Level + 1));
else
target.ApplyPoison(from, weapon.Poison);
weapon.PoisonCharges--;
if (weapon.PoisonCharges < 1) weapon.Poison = null;
}
} }
} }

View file

@ -259,15 +259,13 @@ namespace Server.Items
public static void CreateTimer(Mobile m, TimeSpan delay) public static void CreateTimer(Mobile m, TimeSpan delay)
{ {
if (m != null) if (m != null && !IsDisguised(m))
if (!Timers.ContainsKey(m)) Timers[m] = new InternalTimer(m, delay);
Timers[m] = new InternalTimer(m, delay);
} }
public static void StartTimer(Mobile m) public static void StartTimer(Mobile m)
{ {
Timers.TryGetValue(m, out Timer t); Timers.TryGetValue(m, out Timer t);
t?.Start(); t?.Start();
} }
@ -276,43 +274,31 @@ namespace Server.Items
return Timers.ContainsKey(m); return Timers.ContainsKey(m);
} }
public static bool StopTimer(Mobile m) public static void StopTimer(Mobile m)
{ {
Timers.TryGetValue(m, out Timer t); if (!Timers.TryGetValue(m, out Timer t))
return;
if (t != null) TimeSpan ts = t.Next - DateTime.UtcNow;
{ if (ts < TimeSpan.Zero)
TimeSpan ts = t.Next - DateTime.UtcNow; ts = TimeSpan.Zero;
if (ts < TimeSpan.Zero)
ts = TimeSpan.Zero;
t.Delay = ts; t.Delay = ts;
t.Stop(); t.Stop();
}
return t != null;
} }
public static bool RemoveTimer(Mobile m) public static void RemoveTimer(Mobile m)
{ {
Timers.TryGetValue(m, out Timer t); if (Timers.TryGetValue(m, out Timer t))
if (t != null)
{ {
t.Stop(); t.Stop();
Timers.Remove(m); Timers.Remove(m);
} }
return t != null;
} }
public static TimeSpan TimeRemaining(Mobile m) public static TimeSpan TimeRemaining(Mobile m)
{ {
Timers.TryGetValue(m, out Timer t); return Timers.TryGetValue(m, out Timer t) ? t.Next - DateTime.UtcNow : TimeSpan.Zero;
if (t != null) return t.Next - DateTime.UtcNow;
return TimeSpan.Zero;
} }
private class InternalTimer : Timer private class InternalTimer : Timer

View file

@ -20,7 +20,7 @@ namespace Server.Items
[Flippable(0x2AF9, 0x2AFD)] [Flippable(0x2AF9, 0x2AFD)]
public class DawnsMusicBox : Item, ISecurable public class DawnsMusicBox : Item, ISecurable
{ {
private static Dictionary<MusicName, DawnsMusicInfo> m_Info = new Dictionary<MusicName, DawnsMusicInfo>(); private static Dictionary<MusicName, DawnsMusicInfo> m_Info;
public static MusicName[] m_CommonTracks = public static MusicName[] m_CommonTracks =
{ {
@ -231,76 +231,78 @@ namespace Server.Items
public static void Initialize() public static void Initialize()
{ {
m_Info.Add(MusicName.Samlethe, new DawnsMusicInfo(1075152, DawnsMusicRarity.Common)); m_Info = new Dictionary<MusicName, DawnsMusicInfo>
m_Info.Add(MusicName.Sailing, new DawnsMusicInfo(1075163, DawnsMusicRarity.Common)); {
m_Info.Add(MusicName.Britain2, new DawnsMusicInfo(1075145, DawnsMusicRarity.Common)); { MusicName.Samlethe, new DawnsMusicInfo(1075152, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Britain1, new DawnsMusicInfo(1075144, DawnsMusicRarity.Common)); { MusicName.Sailing, new DawnsMusicInfo(1075163, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Bucsden, new DawnsMusicInfo(1075146, DawnsMusicRarity.Common)); { MusicName.Britain2, new DawnsMusicInfo(1075145, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Forest_a, new DawnsMusicInfo(1075161, DawnsMusicRarity.Common)); { MusicName.Britain1, new DawnsMusicInfo(1075144, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Cove, new DawnsMusicInfo(1075176, DawnsMusicRarity.Common)); { MusicName.Bucsden, new DawnsMusicInfo(1075146, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Death, new DawnsMusicInfo(1075171, DawnsMusicRarity.Common)); { MusicName.Forest_a, new DawnsMusicInfo(1075161, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Dungeon9, new DawnsMusicInfo(1075160, DawnsMusicRarity.Common)); { MusicName.Cove, new DawnsMusicInfo(1075176, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Dungeon2, new DawnsMusicInfo(1075175, DawnsMusicRarity.Common)); { MusicName.Death, new DawnsMusicInfo(1075171, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Cave01, new DawnsMusicInfo(1075159, DawnsMusicRarity.Common)); { MusicName.Dungeon9, new DawnsMusicInfo(1075160, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Combat3, new DawnsMusicInfo(1075170, DawnsMusicRarity.Common)); { MusicName.Dungeon2, new DawnsMusicInfo(1075175, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Combat1, new DawnsMusicInfo(1075168, DawnsMusicRarity.Common)); { MusicName.Cave01, new DawnsMusicInfo(1075159, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Combat2, new DawnsMusicInfo(1075169, DawnsMusicRarity.Common)); { MusicName.Combat3, new DawnsMusicInfo(1075170, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Jhelom, new DawnsMusicInfo(1075147, DawnsMusicRarity.Common)); { MusicName.Combat1, new DawnsMusicInfo(1075168, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Linelle, new DawnsMusicInfo(1075185, DawnsMusicRarity.Common)); { MusicName.Combat2, new DawnsMusicInfo(1075169, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.LBCastle, new DawnsMusicInfo(1075148, DawnsMusicRarity.Common)); { MusicName.Jhelom, new DawnsMusicInfo(1075147, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Minoc, new DawnsMusicInfo(1075150, DawnsMusicRarity.Common)); { MusicName.Linelle, new DawnsMusicInfo(1075185, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Moonglow, new DawnsMusicInfo(1075177, DawnsMusicRarity.Common)); { MusicName.LBCastle, new DawnsMusicInfo(1075148, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Magincia, new DawnsMusicInfo(1075149, DawnsMusicRarity.Common)); { MusicName.Minoc, new DawnsMusicInfo(1075150, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Nujelm, new DawnsMusicInfo(1075174, DawnsMusicRarity.Common)); { MusicName.Moonglow, new DawnsMusicInfo(1075177, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.BTCastle, new DawnsMusicInfo(1075173, DawnsMusicRarity.Common)); { MusicName.Magincia, new DawnsMusicInfo(1075149, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Tavern04, new DawnsMusicInfo(1075167, DawnsMusicRarity.Common)); { MusicName.Nujelm, new DawnsMusicInfo(1075174, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Skarabra, new DawnsMusicInfo(1075154, DawnsMusicRarity.Common)); { MusicName.BTCastle, new DawnsMusicInfo(1075173, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Stones2, new DawnsMusicInfo(1075143, DawnsMusicRarity.Common)); { MusicName.Tavern04, new DawnsMusicInfo(1075167, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Serpents, new DawnsMusicInfo(1075153, DawnsMusicRarity.Common)); { MusicName.Skarabra, new DawnsMusicInfo(1075154, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Taiko, new DawnsMusicInfo(1075180, DawnsMusicRarity.Common)); { MusicName.Stones2, new DawnsMusicInfo(1075143, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Tavern01, new DawnsMusicInfo(1075164, DawnsMusicRarity.Common)); { MusicName.Serpents, new DawnsMusicInfo(1075153, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Tavern02, new DawnsMusicInfo(1075165, DawnsMusicRarity.Common)); { MusicName.Taiko, new DawnsMusicInfo(1075180, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Tavern03, new DawnsMusicInfo(1075166, DawnsMusicRarity.Common)); { MusicName.Tavern01, new DawnsMusicInfo(1075164, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.TokunoDungeon, new DawnsMusicInfo(1075179, DawnsMusicRarity.Common)); { MusicName.Tavern02, new DawnsMusicInfo(1075165, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Trinsic, new DawnsMusicInfo(1075155, DawnsMusicRarity.Common)); { MusicName.Tavern03, new DawnsMusicInfo(1075166, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.OldUlt01, new DawnsMusicInfo(1075142, DawnsMusicRarity.Common)); { MusicName.TokunoDungeon, new DawnsMusicInfo(1075179, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Ocllo, new DawnsMusicInfo(1075151, DawnsMusicRarity.Common)); { MusicName.Trinsic, new DawnsMusicInfo(1075155, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Vesper, new DawnsMusicInfo(1075156, DawnsMusicRarity.Common)); { MusicName.OldUlt01, new DawnsMusicInfo(1075142, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Victory, new DawnsMusicInfo(1075172, DawnsMusicRarity.Common)); { MusicName.Ocllo, new DawnsMusicInfo(1075151, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Mountn_a, new DawnsMusicInfo(1075162, DawnsMusicRarity.Common)); { MusicName.Vesper, new DawnsMusicInfo(1075156, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Wind, new DawnsMusicInfo(1075157, DawnsMusicRarity.Common)); { MusicName.Victory, new DawnsMusicInfo(1075172, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Yew, new DawnsMusicInfo(1075158, DawnsMusicRarity.Common)); { MusicName.Mountn_a, new DawnsMusicInfo(1075162, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.Zento, new DawnsMusicInfo(1075178, DawnsMusicRarity.Common)); { MusicName.Wind, new DawnsMusicInfo(1075157, DawnsMusicRarity.Common) },
{ MusicName.Yew, new DawnsMusicInfo(1075158, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.GwennoConversation, new DawnsMusicInfo(1075131, DawnsMusicRarity.Uncommon)); { MusicName.Zento, new DawnsMusicInfo(1075178, DawnsMusicRarity.Common) },
m_Info.Add(MusicName.DreadHornArea, new DawnsMusicInfo(1075181, DawnsMusicRarity.Uncommon)); { MusicName.GwennoConversation, new DawnsMusicInfo(1075131, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.ElfCity, new DawnsMusicInfo(1075182, DawnsMusicRarity.Uncommon)); { MusicName.DreadHornArea, new DawnsMusicInfo(1075181, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.GoodEndGame, new DawnsMusicInfo(1075132, DawnsMusicRarity.Uncommon)); { MusicName.ElfCity, new DawnsMusicInfo(1075182, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.GoodVsEvil, new DawnsMusicInfo(1075133, DawnsMusicRarity.Uncommon)); { MusicName.GoodEndGame, new DawnsMusicInfo(1075132, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.GreatEarthSerpents, new DawnsMusicInfo(1075134, DawnsMusicRarity.Uncommon)); { MusicName.GoodVsEvil, new DawnsMusicInfo(1075133, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.GrizzleDungeon, new DawnsMusicInfo(1075186, DawnsMusicRarity.Uncommon)); { MusicName.GreatEarthSerpents, new DawnsMusicInfo(1075134, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.Humanoids_U9, new DawnsMusicInfo(1075135, DawnsMusicRarity.Uncommon)); { MusicName.GrizzleDungeon, new DawnsMusicInfo(1075186, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.MelisandesLair, new DawnsMusicInfo(1075183, DawnsMusicRarity.Uncommon)); { MusicName.Humanoids_U9, new DawnsMusicInfo(1075135, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.MinocNegative, new DawnsMusicInfo(1075136, DawnsMusicRarity.Uncommon)); { MusicName.MelisandesLair, new DawnsMusicInfo(1075183, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.ParoxysmusLair, new DawnsMusicInfo(1075184, DawnsMusicRarity.Uncommon)); { MusicName.MinocNegative, new DawnsMusicInfo(1075136, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.Paws, new DawnsMusicInfo(1075137, DawnsMusicRarity.Uncommon)); { MusicName.ParoxysmusLair, new DawnsMusicInfo(1075184, DawnsMusicRarity.Uncommon) },
{ MusicName.Paws, new DawnsMusicInfo(1075137, DawnsMusicRarity.Uncommon) },
m_Info.Add(MusicName.SelimsBar, new DawnsMusicInfo(1075138, DawnsMusicRarity.Rare)); { MusicName.SelimsBar, new DawnsMusicInfo(1075138, DawnsMusicRarity.Rare) },
m_Info.Add(MusicName.SerpentIsleCombat_U7, new DawnsMusicInfo(1075139, DawnsMusicRarity.Rare)); { MusicName.SerpentIsleCombat_U7, new DawnsMusicInfo(1075139, DawnsMusicRarity.Rare) },
m_Info.Add(MusicName.ValoriaShips, new DawnsMusicInfo(1075140, DawnsMusicRarity.Rare)); { MusicName.ValoriaShips, new DawnsMusicInfo(1075140, DawnsMusicRarity.Rare) }
};
} }
public static DawnsMusicInfo GetInfo(MusicName name) public static DawnsMusicInfo GetInfo(MusicName name)
{ {
if (m_Info.ContainsKey(name)) if (m_Info == null) // sanity
return m_Info[name]; return null;
return null; m_Info.TryGetValue(name, out DawnsMusicInfo info);
return info;
} }
public static MusicName RandomTrack(DawnsMusicRarity rarity) public static MusicName RandomTrack(DawnsMusicRarity rarity)
{ {
MusicName[] list = null; MusicName[] list;
switch (rarity) switch (rarity)
{ {

View file

@ -23,27 +23,19 @@ namespace Server.Items
{ {
} }
public static Dictionary<Mobile, CandyCaneTimer> ToothAches{ get; set; } private static Dictionary<Mobile, CandyCaneTimer> m_ToothAches = new Dictionary<Mobile, CandyCaneTimer>();
public static void Initialize()
{
ToothAches = new Dictionary<Mobile, CandyCaneTimer>();
}
private static CandyCaneTimer EnsureTimer(Mobile from) private static CandyCaneTimer EnsureTimer(Mobile from)
{ {
if (!ToothAches.TryGetValue(from, out CandyCaneTimer timer)) if (!m_ToothAches.TryGetValue(from, out CandyCaneTimer timer))
ToothAches[from] = timer = new CandyCaneTimer(from); m_ToothAches[from] = timer = new CandyCaneTimer(from);
return timer; return timer;
} }
public static int GetToothAche(Mobile from) public static int GetToothAche(Mobile from)
{ {
if (ToothAches.TryGetValue(from, out CandyCaneTimer timer)) return m_ToothAches.TryGetValue(from, out CandyCaneTimer timer) ? timer.Eaten : 0;
return timer.Eaten;
return 0;
} }
public static void SetToothAche(Mobile from, int value) public static void SetToothAche(Mobile from, int value)
@ -92,7 +84,7 @@ namespace Server.Items
if (Eater == null || Eater.Deleted || Eaten <= 0) if (Eater == null || Eater.Deleted || Eaten <= 0)
{ {
Stop(); Stop();
ToothAches.Remove(Eater); m_ToothAches.Remove(Eater);
} }
else if (Eater.Map != Map.Internal && Eater.Alive) else if (Eater.Map != Map.Internal && Eater.Alive)
{ {

View file

@ -20,84 +20,70 @@ namespace Server.Items
public static class TalismanSlayer public static class TalismanSlayer
{ {
private static Dictionary<TalismanSlayerName, Type[]> m_Table = new Dictionary<TalismanSlayerName, Type[]>(); private static Dictionary<TalismanSlayerName, Type[]> m_Table;
public static void Initialize() public static void Initialize()
{ {
m_Table[TalismanSlayerName.Bear] = new[] m_Table = new Dictionary<TalismanSlayerName, Type[]>
{ {
typeof(GrizzlyBear), typeof(BlackBear), typeof(BrownBear), typeof(PolarBear) //, typeof( Grobu ) [TalismanSlayerName.Bear] = new[]
}; {
typeof(GrizzlyBear), typeof(BlackBear), typeof(BrownBear), typeof(PolarBear) //, typeof( Grobu )
},
[TalismanSlayerName.Vermin] = new[]
{
typeof(RatmanMage), typeof(RatmanMage), typeof(RatmanArcher), typeof(Barracoon), typeof(Ratman), typeof(SewerRat),
typeof(Rat), typeof(GiantRat) //, typeof( Chiikkaha )
},
[TalismanSlayerName.Bat] = new[] { typeof(Mongbat), typeof(StrongMongbat), typeof(VampireBat) },
[TalismanSlayerName.Mage] =
new[]
{
typeof(EvilMage), typeof(EvilMageLord), typeof(AncientLich), typeof(Lich), typeof(LichLord),
typeof(SkeletalMage), typeof(BoneMagi), typeof(OrcishMage), typeof(KhaldunZealot), typeof(JukaMage)
},
[TalismanSlayerName.Beetle] =
new[]
{
typeof(Beetle), typeof(RuneBeetle), typeof(FireBeetle), typeof(DeathwatchBeetle),
typeof(DeathwatchBeetleHatchling)
},
[TalismanSlayerName.Bird] = new[]
{
typeof(Bird), typeof(TropicalBird), typeof(Chicken), typeof(Crane), typeof(DesertOstard), typeof(Eagle),
typeof(ForestOstard), typeof(FrenziedOstard),
typeof(Phoenix), /*typeof( Pyre ), typeof( Swoop ), typeof( Saliva ),*/ typeof(Harpy), typeof(StoneHarpy) // ?????
},
[TalismanSlayerName.Ice] = new[]
{
typeof(ArcticOgreLord), typeof(IceElemental), typeof(SnowElemental), typeof(FrostOoze),
typeof(IceFiend), /*typeof( UnfrozenMummy ),*/ typeof(FrostSpider), typeof(LadyOfTheSnow), typeof(FrostTroll),
m_Table[TalismanSlayerName.Vermin] = new[] // TODO WinterReaper, check
{ typeof(IceSnake), typeof(SnowLeopard), typeof(PolarBear), typeof(IceSerpent), typeof(GiantIceWorm)
typeof(RatmanMage), typeof(RatmanMage), typeof(RatmanArcher), typeof(Barracoon), },
typeof(Ratman), typeof(SewerRat), typeof(Rat), typeof(GiantRat) //, typeof( Chiikkaha ) [TalismanSlayerName.Flame] = new[]
}; {
typeof(FireBeetle), typeof(HellHound), typeof(LavaSerpent), typeof(FireElemental), typeof(PredatorHellCat),
typeof(Phoenix), typeof(FireGargoyle), typeof(HellCat),
/*typeof( Pyre ),*/ typeof(FireSteed), typeof(LavaLizard),
m_Table[TalismanSlayerName.Bat] = new[] // TODO check
{ typeof(LavaSnake)
typeof(Mongbat), typeof(StrongMongbat), typeof(VampireBat) },
}; [TalismanSlayerName.Bovine] = new[]
{
m_Table[TalismanSlayerName.Mage] = new[] typeof(Cow), typeof(Bull), typeof(Gaman) /*, typeof( MinotaurCaptain ),
{ typeof( MinotaurScout ), typeof( Minotaur )*/
typeof(EvilMage), typeof(EvilMageLord), typeof(AncientLich), typeof(Lich), typeof(LichLord), // TODO TormentedMinotaur
typeof(SkeletalMage), typeof(BoneMagi), typeof(OrcishMage), typeof(KhaldunZealot), typeof(JukaMage) }
};
m_Table[TalismanSlayerName.Beetle] = new[]
{
typeof(Beetle), typeof(RuneBeetle), typeof(FireBeetle), typeof(DeathwatchBeetle),
typeof(DeathwatchBeetleHatchling)
};
m_Table[TalismanSlayerName.Bird] = new[]
{
typeof(Bird), typeof(TropicalBird), typeof(Chicken), typeof(Crane),
typeof(DesertOstard), typeof(Eagle), typeof(ForestOstard), typeof(FrenziedOstard),
typeof(Phoenix), /*typeof( Pyre ), typeof( Swoop ), typeof( Saliva ),*/ typeof(Harpy),
typeof(StoneHarpy) // ?????
};
m_Table[TalismanSlayerName.Ice] = new[]
{
typeof(ArcticOgreLord), typeof(IceElemental), typeof(SnowElemental), typeof(FrostOoze),
typeof(IceFiend), /*typeof( UnfrozenMummy ),*/ typeof(FrostSpider), typeof(LadyOfTheSnow),
typeof(FrostTroll),
// TODO WinterReaper, check
typeof(IceSnake), typeof(SnowLeopard), typeof(PolarBear), typeof(IceSerpent), typeof(GiantIceWorm)
};
m_Table[TalismanSlayerName.Flame] = new[]
{
typeof(FireBeetle), typeof(HellHound), typeof(LavaSerpent), typeof(FireElemental),
typeof(PredatorHellCat), typeof(Phoenix), typeof(FireGargoyle), typeof(HellCat),
/*typeof( Pyre ),*/ typeof(FireSteed), typeof(LavaLizard),
// TODO check
typeof(LavaSnake)
};
m_Table[TalismanSlayerName.Bovine] = new[]
{
typeof(Cow), typeof(Bull), typeof(Gaman) /*, typeof( MinotaurCaptain ),
typeof( MinotaurScout ), typeof( Minotaur )*/
// TODO TormentedMinotaur
}; };
} }
public static bool Slays(TalismanSlayerName name, Mobile m) public static bool Slays(TalismanSlayerName name, Mobile m)
{ {
if (!m_Table.ContainsKey(name)) if (m == null || !m_Table.TryGetValue(name, out Type[] types) || types == null)
return false; return false;;
Type[] types = m_Table[name];
if (types == null || m == null)
return false;
Type type = m.GetType(); Type type = m.GetType();

View file

@ -59,11 +59,10 @@ namespace Server.Items
public static void BeginBleed(Mobile m, Mobile from) public static void BeginBleed(Mobile m, Mobile from)
{ {
Timer t = m_Table[m]; m_Table.TryGetValue(m, out Timer t);
t?.Stop(); t?.Stop();
m_Table[m] = t = new InternalTimer(from, m); m_Table[m] = t = new InternalTimer(from, m);
t.Start(); t.Start();
} }
@ -90,9 +89,7 @@ namespace Server.Items
public static void EndBleed(Mobile m, bool message) public static void EndBleed(Mobile m, bool message)
{ {
Timer t = m_Table[m]; if (!m_Table.TryGetValue(m, out Timer t))
if (t == null)
return; return;
t.Stop(); t.Stop();

View file

@ -45,8 +45,7 @@ namespace Server.Items
public static bool GetBonus(Mobile targ, ref int bonus) public static bool GetBonus(Mobile targ, ref int bonus)
{ {
BlockInfo info = m_Table[targ]; if (!m_Table.TryGetValue(targ, out BlockInfo info))
if (info == null)
return false; return false;
bonus = info.m_Bonus; bonus = info.m_Bonus;
@ -61,9 +60,7 @@ namespace Server.Items
public static void EndBlock(Mobile m) public static void EndBlock(Mobile m)
{ {
BlockInfo info = m_Table[m]; if (!m_Table.TryGetValue(m, out BlockInfo info))
if (info == null)
return; return;
info.m_Timer?.Stop(); info.m_Timer?.Stop();

View file

@ -41,9 +41,7 @@ namespace Server.Items
((Math.Max(attacker.Skills.Bushido.Value, attacker.Skills.Ninjitsu.Value) - ((Math.Max(attacker.Skills.Bushido.Value, attacker.Skills.Ninjitsu.Value) -
50.0) / 70.0)); 50.0) / 70.0));
DefenseMasteryInfo info = m_Table[attacker]; if (m_Table.TryGetValue(attacker, out DefenseMasteryInfo info))
if (info != null)
EndDefense(info); EndDefense(info);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, 50 + modifier); ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, 50 + modifier);
@ -59,9 +57,7 @@ namespace Server.Items
public static bool GetMalus(Mobile targ, ref int damageMalus) public static bool GetMalus(Mobile targ, ref int damageMalus)
{ {
DefenseMasteryInfo info = m_Table[targ]; if (!m_Table.TryGetValue(targ, out DefenseMasteryInfo info))
if (info == null)
return false; return false;
damageMalus = info.m_DamageMalus; damageMalus = info.m_DamageMalus;

View file

@ -30,8 +30,7 @@ namespace Server.Items
if (!Validate(attacker) || !CheckMana(attacker, true)) if (!Validate(attacker) || !CheckMana(attacker, true))
return; return;
DualWieldTimer timer = Registry[attacker]; if (Registry.TryGetValue(attacker, out DualWieldTimer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
Registry.Remove(attacker); Registry.Remove(attacker);

View file

@ -30,8 +30,7 @@ namespace Server.Items
if (!Validate(attacker) || !CheckMana(attacker, true)) if (!Validate(attacker) || !CheckMana(attacker, true))
return; return;
FeintTimer timer = Registry[defender]; if (Registry.TryGetValue(defender, out FeintTimer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
Registry.Remove(defender); Registry.Remove(defender);

View file

@ -78,9 +78,7 @@ namespace Server.Items
Mobile m = targets[i]; Mobile m = targets[i];
attacker.DoHarmful(m, true); attacker.DoHarmful(m, true);
FrenziedWirlwindTimer timer = Registry[m]; if (Registry.TryGetValue(m, out FrenziedWirlwindTimer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
Registry.Remove(m); Registry.Remove(m);

View file

@ -41,8 +41,8 @@ namespace Server.Items
public static void BeginWound(Mobile m, TimeSpan duration) public static void BeginWound(Mobile m, TimeSpan duration)
{ {
InternalTimer timer = m_Table[m]; if (m_Table.TryGetValue(m, out InternalTimer timer))
timer?.Stop(); timer?.Stop();
m_Table[m] = timer = new InternalTimer(m, duration); m_Table[m] = timer = new InternalTimer(m, duration);
timer.Start(); timer.Start();
@ -52,9 +52,7 @@ namespace Server.Items
public static void EndWound(Mobile m) public static void EndWound(Mobile m)
{ {
Timer timer = m_Table[m]; if (m_Table.TryGetValue(m, out InternalTimer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
m_Table.Remove(m); m_Table.Remove(m);

View file

@ -88,18 +88,20 @@ namespace Server.Items
public static void BeginImmunity(Mobile m, TimeSpan duration) public static void BeginImmunity(Mobile m, TimeSpan duration)
{ {
InternalTimer timer = m_Table[m]; if (m_Table.TryGetValue(m, out InternalTimer timer))
timer?.Stop();
timer?.Stop();
m_Table[m] = timer = new InternalTimer(m, duration); m_Table[m] = timer = new InternalTimer(m, duration);
timer.Start(); timer.Start();
} }
public static void EndImmunity(Mobile m) public static void EndImmunity(Mobile m)
{ {
InternalTimer timer = m_Table[m]; if (m_Table.TryGetValue(m, out InternalTimer timer))
timer?.Stop(); {
m_Table.Remove(m); timer?.Stop();
m_Table.Remove(m);
}
} }
private class InternalTimer : Timer private class InternalTimer : Timer

View file

@ -8,7 +8,7 @@ namespace Server.Items
/// </summary> /// </summary>
public class TalonStrike : WeaponAbility public class TalonStrike : WeaponAbility
{ {
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>(); private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
public override int BaseMana => 30; public override int BaseMana => 30;
public override double DamageScalar => 1.2; public override double DamageScalar => 1.2;
@ -27,7 +27,7 @@ namespace Server.Items
public override void OnHit(Mobile attacker, Mobile defender, int damage) public override void OnHit(Mobile attacker, Mobile defender, int damage)
{ {
if (m_Table.ContainsKey(defender) || !Validate(attacker) || !CheckMana(attacker, true)) if (m_Table.Contains(defender) || !Validate(attacker) || !CheckMana(attacker, true))
return; return;
ClearCurrentAbility(attacker); ClearCurrentAbility(attacker);
@ -42,7 +42,7 @@ namespace Server.Items
timer.Start(); timer.Start();
m_Table.Add(defender, timer); m_Table.Add(defender);
} }
private class InternalTimer : Timer private class InternalTimer : Timer

View file

@ -350,7 +350,7 @@ namespace Server.Items
return null; return null;
} }
WeaponAbility a = Table[m]; Table.TryGetValue(m, out WeaponAbility a);
if (!IsWeaponAbility(m, a)) if (!IsWeaponAbility(m, a))
{ {
@ -446,7 +446,8 @@ namespace Server.Items
private static WeaponAbilityContext GetContext(Mobile m) private static WeaponAbilityContext GetContext(Mobile m)
{ {
return m_PlayersTable[m]; m_PlayersTable.TryGetValue(m, out WeaponAbilityContext context);
return context;
} }
private class WeaponAbilityTimer : Timer private class WeaponAbilityTimer : Timer

View file

@ -9,12 +9,12 @@ namespace Server.Items
public static readonly TimeSpan AttackEffectDuration = TimeSpan.FromSeconds(10.0); public static readonly TimeSpan AttackEffectDuration = TimeSpan.FromSeconds(10.0);
public static readonly TimeSpan DefenseEffectDuration = TimeSpan.FromSeconds(8.0); public static readonly TimeSpan DefenseEffectDuration = TimeSpan.FromSeconds(8.0);
private static Dictionary<Mobile, AttackTimer> m_AttackTable = new Dictionary<Mobile, AttackTimer>(); private static HashSet<Mobile> m_AttackTable = new HashSet<Mobile>();
private static Dictionary<Mobile, DefenseTimer> m_DefenseTable = new Dictionary<Mobile, DefenseTimer>(); private static HashSet<Mobile> m_DefenseTable = new HashSet<Mobile>();
public static bool IsUnderAttackEffect(Mobile m) public static bool IsUnderAttackEffect(Mobile m)
{ {
return m_AttackTable.ContainsKey(m); return m_AttackTable.Contains(m);
} }
public static bool ApplyAttack(Mobile m) public static bool ApplyAttack(Mobile m)
@ -22,7 +22,9 @@ namespace Server.Items
if (IsUnderAttackEffect(m)) if (IsUnderAttackEffect(m))
return false; return false;
m_AttackTable[m] = new AttackTimer(m); m_AttackTable.Add(m);
AttackTimer timer = new AttackTimer(m);
timer.Start();
m.SendLocalizedMessage(1062319); // Your attack chance has been reduced! m.SendLocalizedMessage(1062319); // Your attack chance has been reduced!
return true; return true;
} }
@ -35,7 +37,7 @@ namespace Server.Items
public static bool IsUnderDefenseEffect(Mobile m) public static bool IsUnderDefenseEffect(Mobile m)
{ {
return m_DefenseTable.ContainsKey(m); return m_DefenseTable.Contains(m);
} }
public static bool ApplyDefense(Mobile m) public static bool ApplyDefense(Mobile m)
@ -43,7 +45,9 @@ namespace Server.Items
if (IsUnderDefenseEffect(m)) if (IsUnderDefenseEffect(m))
return false; return false;
m_DefenseTable[m] = new DefenseTimer(m); m_DefenseTable.Add(m);
DefenseTimer timer = new DefenseTimer(m);
timer.Start();
m.SendLocalizedMessage(1062318); // Your defense chance has been reduced! m.SendLocalizedMessage(1062318); // Your defense chance has been reduced!
return true; return true;
} }
@ -61,10 +65,7 @@ namespace Server.Items
public AttackTimer(Mobile player) : base(AttackEffectDuration) public AttackTimer(Mobile player) : base(AttackEffectDuration)
{ {
m_Player = player; m_Player = player;
Priority = TimerPriority.TwoFiftyMS; Priority = TimerPriority.TwoFiftyMS;
Start();
} }
protected override void OnTick() protected override void OnTick()
@ -80,10 +81,7 @@ namespace Server.Items
public DefenseTimer(Mobile player) : base(DefenseEffectDuration) public DefenseTimer(Mobile player) : base(DefenseEffectDuration)
{ {
m_Player = player; m_Player = player;
Priority = TimerPriority.TwoFiftyMS; Priority = TimerPriority.TwoFiftyMS;
Start();
} }
protected override void OnTick() protected override void OnTick()

View file

@ -107,7 +107,7 @@ namespace Server.Misc
m.Send(new BeginHandshake()); m.Send(new BeginHandshake());
if (m_Dictionary.TryGetValue(m, out Timer t)) if (m_Dictionary.TryGetValue(m, out Timer t))
t?.Stop(); t.Stop();
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout, m); m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout, m);
t.Start(); t.Start();
@ -124,7 +124,7 @@ namespace Server.Misc
Mobile m = state.Mobile; Mobile m = state.Mobile;
if (m_Dictionary.TryGetValue(m, out Timer t)) if (m_Dictionary.TryGetValue(m, out Timer t))
{ {
t?.Stop(); t.Stop();
m_Dictionary.Remove(m); m_Dictionary.Remove(m);
} }

View file

@ -114,14 +114,14 @@ namespace Server
if (!m_Temps.TryGetValue( localType, out Queue<LocalBuilder> list )) if (!m_Temps.TryGetValue( localType, out Queue<LocalBuilder> list ))
m_Temps[localType] = list = new Queue<LocalBuilder>(); m_Temps[localType] = list = new Queue<LocalBuilder>();
if ( list.Count > 0 ) return list.Count > 0 ? list.Dequeue() : CreateLocal( localType );
return list.Dequeue();
return CreateLocal( localType );
} }
public void ReleaseTemp( LocalBuilder local ) public void ReleaseTemp( LocalBuilder local )
{ {
if (local.LocalType == null)
return;
if (!m_Temps.TryGetValue( local.LocalType, out Queue<LocalBuilder> list )) if (!m_Temps.TryGetValue( local.LocalType, out Queue<LocalBuilder> list ))
m_Temps[local.LocalType] = list = new Queue<LocalBuilder>(); m_Temps[local.LocalType] = list = new Queue<LocalBuilder>();

View file

@ -242,18 +242,11 @@ namespace Server.Guilds
for (int i = 0; i < m_Members.Count; i++) for (int i = 0; i < m_Members.Count; i++)
m_Members[i].Alliance = null; m_Members[i].Alliance = null;
Alliances.TryGetValue(Name.ToLower(), out AllianceInfo aInfo); if (Alliances.TryGetValue(Name.ToLower(), out AllianceInfo aInfo) && aInfo == this)
if (aInfo == this)
Alliances.Remove(Name.ToLower()); Alliances.Remove(Name.ToLower());
} }
public void InvalidateMemberProperties() public void InvalidateMemberProperties(bool onlyOPL = false)
{
InvalidateMemberProperties(false);
}
public void InvalidateMemberProperties(bool onlyOPL)
{ {
for (int i = 0; i < m_Members.Count; i++) for (int i = 0; i < m_Members.Count; i++)
{ {
@ -1449,11 +1442,7 @@ namespace Server.Guilds
if (m == null) if (m == null)
continue; continue;
if (!votes.TryGetValue(m, out int v)) votes[m] = 1 + (votes.TryGetValue(m, out int v) ? v : 0);
votes[m] = 1;
else
votes[m] = v + 1;
votingMembers++; votingMembers++;
} }

View file

@ -405,9 +405,7 @@ namespace Server.Misc
for ( int i = 0; i < split.Length; ++i ) for ( int i = 0; i < split.Length; ++i )
{ {
m_KeywordHash.TryGetValue( split[i], out string keyword ); if (m_KeywordHash.TryGetValue( split[i], out string keyword ))
if ( keyword != null )
keywordsFound.Add( keyword ); keywordsFound.Add( keyword );
} }

View file

@ -199,17 +199,17 @@ namespace Server.Misc
string lang = mob?.Language; string lang = mob?.Language;
if (lang != null) if (lang == null)
{ continue;
lang = lang.ToUpper();
if (!ht.ContainsKey(lang)) lang = lang.ToUpper();
ht[lang] = new InternationalCodeCounter(lang);
else
ht[lang].Increase();
break; if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
} codes.Increase();
else
ht[lang] = new InternationalCodeCounter(lang);
break;
} }
else else
foreach (Mobile mob in World.Mobiles.Values) foreach (Mobile mob in World.Mobiles.Values)
@ -217,15 +217,15 @@ namespace Server.Misc
{ {
string lang = mob.Language; string lang = mob.Language;
if (lang != null) if (lang == null)
{ continue;
lang = lang.ToUpper();
if (!ht.ContainsKey(lang)) lang = lang.ToUpper();
ht[lang] = new InternationalCodeCounter(lang);
else if (ht.TryGetValue(lang, out InternationalCodeCounter codes))
ht[lang].Increase(); codes.Increase();
} else
ht[lang] = new InternationalCodeCounter(lang);
} }
writer.WriteLine( writer.WriteLine(

View file

@ -45,12 +45,7 @@ namespace Server
public static string RandomName( string type ) public static string RandomName( string type )
{ {
NameList list = GetNameList( type ); return GetNameList( type )?.GetRandomName() ?? "";
if ( list != null )
return list.GetRandomName();
return "";
} }
private static Dictionary<string, NameList> m_Table; private static Dictionary<string, NameList> m_Table;

View file

@ -488,10 +488,7 @@ namespace Server.Items
if ( m_TypeTable == null ) if ( m_TypeTable == null )
return CraftResource.None; return CraftResource.None;
if (!m_TypeTable.TryGetValue(resourceType, out CraftResource res)) return m_TypeTable.TryGetValue(resourceType, out CraftResource res) ? res : CraftResource.None;
return CraftResource.None;
return res;
} }
/// <summary> /// <summary>

View file

@ -392,9 +392,10 @@ namespace Server
if (flags != ShopFlags.None) if (flags != ShopFlags.None)
{ {
Point2D p = new Point2D(x, y); Point2D p = new Point2D(x, y);
ShopInfo si = m_ShopTable[p];
if (si == null) if (m_ShopTable.TryGetValue(p, out ShopInfo si))
si.m_Flags |= flags;
else
{ {
List<Point2D> floor = new List<Point2D>(); List<Point2D> floor = new List<Point2D>();
@ -409,10 +410,6 @@ namespace Server
for (int i = 0; i < floor.Count; ++i) for (int i = 0; i < floor.Count; ++i)
m_ShopTable[floor[i]] = si; m_ShopTable[floor[i]] = si;
} }
else
{
si.m_Flags |= flags;
}
} }
} }

View file

@ -45,9 +45,7 @@ namespace Server.Misc
if ( facet == null ) if ( facet == null )
return null; return null;
m_WeatherByFacet.TryGetValue( facet, out List<Weather> list ); if (!m_WeatherByFacet.TryGetValue( facet, out List<Weather> list ))
if ( list == null )
m_WeatherByFacet[facet] = list = new List<Weather>(); m_WeatherByFacet[facet] = list = new List<Weather>();
return list; return list;
@ -74,10 +72,8 @@ namespace Server.Misc
if ( !isValid ) if ( !isValid )
continue; continue;
Weather w = new Weather( m_Facets[i], new[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) ); new Weather(m_Facets[i], new[] { area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature,
TimeSpan.FromSeconds(30.0)) { Bounds = bounds, MoveSpeed = moveSpeed };
w.Bounds = bounds;
w.MoveSpeed = moveSpeed;
} }
} }
@ -127,36 +123,13 @@ namespace Server.Misc
public static bool CheckIntersection( Rectangle2D r1, Rectangle2D r2 ) public static bool CheckIntersection( Rectangle2D r1, Rectangle2D r2 )
{ {
if ( r1.X >= (r2.X + r2.Width) ) return r1.X < r2.X + r2.Width && r2.X < r1.X + r1.Width && r1.Y < r2.Y + r2.Height && r2.Y < r1.Y + r1.Height;
return false;
if ( r2.X >= (r1.X + r1.Width) )
return false;
if ( r1.Y >= (r2.Y + r2.Height) )
return false;
if ( r2.Y >= (r1.Y + r1.Height) )
return false;
return true;
} }
public static bool CheckContains( Rectangle2D big, Rectangle2D small ) public static bool CheckContains( Rectangle2D big, Rectangle2D small )
{ {
if ( small.X < big.X ) return small.X >= big.X && small.Y >= big.Y && small.X + small.Width <= big.X + big.Width
return false; && small.Y + small.Height <= big.Y + big.Height;
if ( small.Y < big.Y )
return false;
if ( (small.X + small.Width) > (big.X + big.Width) )
return false;
if ( (small.Y + small.Height) > (big.Y + big.Height) )
return false;
return true;
} }
public virtual bool IntersectsWith( Rectangle2D area ) public virtual bool IntersectsWith( Rectangle2D area )
@ -182,7 +155,7 @@ namespace Server.Misc
list?.Add( this ); list?.Add( this );
Timer.DelayCall( TimeSpan.FromSeconds( (0.2+(Utility.RandomDouble()*0.8)) * interval.TotalSeconds ), interval, OnTick ); Timer.DelayCall( TimeSpan.FromSeconds( (0.2+Utility.RandomDouble()*0.8) * interval.TotalSeconds ), interval, OnTick );
} }
public virtual void Reposition() public virtual void Reposition()
@ -231,8 +204,8 @@ namespace Server.Misc
for ( int i = 0; i < 5; ++i ) // try 5 times to find a valid spot for ( int i = 0; i < 5; ++i ) // try 5 times to find a valid spot
{ {
int xOffset = (MoveSpeed * MoveAngleX) / 100; int xOffset = MoveSpeed * MoveAngleX / 100;
int yOffset = (MoveSpeed * MoveAngleY) / 100; int yOffset = MoveSpeed * MoveAngleY / 100;
Rectangle2D oldArea = Area[0]; Rectangle2D oldArea = Area[0];
Rectangle2D newArea = new Rectangle2D( oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height ); Rectangle2D newArea = new Rectangle2D( oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height );
@ -255,8 +228,8 @@ namespace Server.Misc
{ {
if ( m_Stage == 0 ) if ( m_Stage == 0 )
{ {
m_Active = ( ChanceOfPercipitation > Utility.Random( 100 ) ); m_Active = ChanceOfPercipitation > Utility.Random( 100 );
m_ExtremeTemperature = ( ChanceOfExtremeTemperature > Utility.Random( 100 ) ); m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random( 100 );
if ( MoveSpeed > 0 ) if ( MoveSpeed > 0 )
{ {
@ -270,9 +243,8 @@ namespace Server.Misc
if ( m_Stage > 0 && MoveSpeed > 0 ) if ( m_Stage > 0 && MoveSpeed > 0 )
MoveForward(); MoveForward();
int type, density, temperature; int type, density;
int temperature = Temperature;
temperature = Temperature;
if ( m_ExtremeTemperature ) if ( m_ExtremeTemperature )
temperature *= -1; temperature *= -1;
@ -283,7 +255,7 @@ namespace Server.Misc
} }
else else
{ {
density = 150 - (m_Stage * 5); density = 150 - m_Stage * 5;
if ( density < 10 ) if ( density < 10 )
density = 10; density = 10;
@ -310,7 +282,7 @@ namespace Server.Misc
if ( mob == null || mob.Map != Facet ) if ( mob == null || mob.Map != Facet )
continue; continue;
bool contains = ( Area.Length == 0 ); bool contains = Area.Length == 0;
for ( int j = 0; !contains && j < Area.Length; ++j ) for ( int j = 0; !contains && j < Area.Length; ++j )
contains = Area[j].Contains( mob.Location ); contains = Area[j].Contains( mob.Location );
@ -358,7 +330,7 @@ namespace Server.Misc
Weather w = list[i]; Weather w = list[i];
for ( int j = 0; j < w.Area.Length; ++j ) for ( int j = 0; j < w.Area.Length; ++j )
AddWorldPin( w.Area[j].X + (w.Area[j].Width/2), w.Area[j].Y + (w.Area[j].Height/2) ); AddWorldPin( w.Area[j].X + w.Area[j].Width/2, w.Area[j].Y + w.Area[j].Height/2 );
} }
base.OnDoubleClick( from ); base.OnDoubleClick( from );

View file

@ -169,9 +169,9 @@ namespace Server
if (m_Table == null) if (m_Table == null)
LoadTable(); LoadTable();
m_Table.TryGetValue(obj.GetType(), out SpeedInfo sp); ;
return sp != null; return m_Table.ContainsKey(obj.GetType());
} }
public static bool GetSpeeds(object obj, ref double activeSpeed, ref double passiveSpeed) public static bool GetSpeeds(object obj, ref double activeSpeed, ref double passiveSpeed)
@ -182,9 +182,7 @@ namespace Server
if (m_Table == null) if (m_Table == null)
LoadTable(); LoadTable();
m_Table.TryGetValue(obj.GetType(), out SpeedInfo sp); if (!m_Table.TryGetValue(obj.GetType(), out SpeedInfo sp))
if (sp == null)
return false; return false;
activeSpeed = sp.ActiveSpeed; activeSpeed = sp.ActiveSpeed;

View file

@ -167,39 +167,37 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble()) if (0.1 <= Utility.RandomDouble())
{ return;
/* Grasping Claw
/* Grasping Claw
* Start cliloc: 1070836 * Start cliloc: 1070836
* Effect: Physical resistance -15% for 5 seconds * Effect: Physical resistance -15% for 5 seconds
* End cliloc: 1070838 * End cliloc: 1070838
* Effect: Type: "3" - From: "0x57D4F5B" (player) - To: "0x0" - ItemId: "0x37B9" - ItemIdName: "glow" - FromLocation: "(1149 808, 32)" - ToLocation: "(1149 808, 32)" - Speed: "10" - Duration: "5" - FixedDirection: "True" - Explode: "False" * Effect: Type: "3" - From: "0x57D4F5B" (player) - To: "0x0" - ItemId: "0x37B9" - ItemIdName: "glow" - FromLocation: "(1149 808, 32)" - ToLocation: "(1149 808, 32)" - Speed: "10" - Duration: "5" - FixedDirection: "True" - Explode: "False"
*/ */
ExpireTimer timer = m_Table[defender]; if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{
if (timer != null) timer.DoExpire();
{ defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
timer.DoExpire();
defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
}
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -161,39 +161,37 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble()) if (0.1 <= Utility.RandomDouble())
{ return;
/* Grasping Claw
/* Grasping Claw
* Start cliloc: 1070836 * Start cliloc: 1070836
* Effect: Physical resistance -15% for 5 seconds * Effect: Physical resistance -15% for 5 seconds
* End cliloc: 1070838 * End cliloc: 1070838
* Effect: Type: "3" - From: "0x57D4F5B" (player) - To: "0x0" - ItemId: "0x37B9" - ItemIdName: "glow" - FromLocation: "(1149 808, 32)" - ToLocation: "(1149 808, 32)" - Speed: "10" - Duration: "5" - FixedDirection: "True" - Explode: "False" * Effect: Type: "3" - From: "0x57D4F5B" (player) - To: "0x0" - ItemId: "0x37B9" - ItemIdName: "glow" - FromLocation: "(1149 808, 32)" - ToLocation: "(1149 808, 32)" - Speed: "10" - Duration: "5" - FixedDirection: "True" - Explode: "False"
*/ */
ExpireTimer timer = m_Table[defender]; if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{
if (timer != null) timer.DoExpire();
{ defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
timer.DoExpire();
defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
}
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -415,7 +415,10 @@ namespace Server.Mobiles
} }
} }
public virtual bool IsNecroFamiliar => Summoned && m_ControlMaster != null && SummonFamiliarSpell.Table[m_ControlMaster] == this; public virtual bool IsNecroFamiliar => Summoned && m_ControlMaster != null &&
SummonFamiliarSpell.Table.TryGetValue(m_ControlMaster, out BaseCreature bc) &&
bc == this;
public virtual bool DeleteCorpseOnDeath => !Core.AOS && m_bSummoned; public virtual bool DeleteCorpseOnDeath => !Core.AOS && m_bSummoned;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
@ -2317,7 +2320,7 @@ namespace Server.Mobiles
} }
if (DeathAdderCharmable && from.CanBeHarmful(this, false)) if (DeathAdderCharmable && from.CanBeHarmful(this, false))
if (SummonFamiliarSpell.Table[from] is DeathAdder da && !da.Deleted) if (SummonFamiliarSpell.Table.TryGetValue(from, out BaseCreature bc) && (bc as DeathAdder)?.Deleted == false)
{ {
from.SendAsciiMessage("You charm the snake. Select a target to attack."); from.SendAsciiMessage("You charm the snake. Select a target to attack.");
from.Target = new DeathAdderCharmTarget(this); from.Target = new DeathAdderCharmTarget(this);
@ -2345,7 +2348,7 @@ namespace Server.Mobiles
list.Add(1080078); // guarding list.Add(1080078); // guarding
} }
if (Summoned && !IsAnimatedDead && !IsNecroFamiliar && !(this is Clone)) if (Summoned && !(IsAnimatedDead || IsNecroFamiliar || this is Clone))
{ {
list.Add(1049646); // (summoned) list.Add(1049646); // (summoned)
} }
@ -3296,7 +3299,7 @@ namespace Server.Mobiles
if (!m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful(m_Charmed, false)) if (!m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful(m_Charmed, false))
return; return;
if (!(SummonFamiliarSpell.Table[from] is DeathAdder da) || da.Deleted) if (!(SummonFamiliarSpell.Table.TryGetValue(from, out BaseCreature bc) && (bc as DeathAdder)?.Deleted == false))
return; return;
if (!(targeted is Mobile targ && from.CanBeHarmful(targ, false))) if (!(targeted is Mobile targ && from.CanBeHarmful(targ, false)))

View file

@ -165,9 +165,7 @@ namespace Server.Mobiles
public static void StopEffect(Mobile m, bool message) public static void StopEffect(Mobile m, bool message)
{ {
Timer timer = m_Table[m]; if (m_Table.TryGetValue(m, out Timer timer))
if (timer != null)
{ {
if (message) if (message)
m.PublicOverheadMessage(MessageType.Emote, m.SpeechHue, true, m.PublicOverheadMessage(MessageType.Emote, m.SpeechHue, true,
@ -181,15 +179,11 @@ namespace Server.Mobiles
public void DoEffect(Mobile m, int count) public void DoEffect(Mobile m, int count)
{ {
if (!m.Alive) if (!m.Alive)
{
StopEffect(m, false); StopEffect(m, false);
}
else else
{ {
if (m.FindItemOnLayer(Layer.TwoHanded) is Torch torch && torch.Burning) if (m.FindItemOnLayer(Layer.TwoHanded) is Torch torch && torch.Burning)
{
StopEffect(m, true); StopEffect(m, true);
}
else else
{ {
if (count % 4 == 0) if (count % 4 == 0)

View file

@ -73,22 +73,22 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (Utility.RandomDouble() < 0.1) if (Utility.RandomDouble() >= 0.1)
{ return;
if (m_Table.TryGetValue(defender, out ExpireTimer timer))
timer.DoExpire();
defender.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot); if (m_Table.TryGetValue(defender, out ExpireTimer timer))
defender.PlaySound(0x208); timer.DoExpire();
defender.SendLocalizedMessage(
1070833); // The creature fans you with fire, reducing your resistance to fire attacks.
ResistanceMod mod = new ResistanceMod(ResistanceType.Fire, -10); defender.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot);
defender.AddResistanceMod(mod); defender.PlaySound(0x208);
defender.SendLocalizedMessage(
1070833); // The creature fans you with fire, reducing your resistance to fire attacks.
m_Table[defender] = timer = new ExpireTimer(defender, mod); ResistanceMod mod = new ResistanceMod(ResistanceType.Fire, -10);
timer.Start(); defender.AddResistanceMod(mod);
}
m_Table[defender] = timer = new ExpireTimer(defender, mod);
timer.Start();
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -140,7 +140,10 @@ namespace Server.Mobiles
public static void SuppressRemove(Mobile target) public static void SuppressRemove(Mobile target)
{ {
if (target != null && m_Suppressed[target] is Timer t) if (target == null)
return;
if (m_Suppressed.TryGetValue(target, out Timer t))
{ {
if (t.Running) if (t.Running)
t.Stop(); t.Stop();
@ -199,7 +202,7 @@ namespace Server.Mobiles
{ {
Item item = m.FindItemOnLayer(layer); Item item = m.FindItemOnLayer(layer);
if (item != null && item.Movable) if (item?.Movable == true)
m.PlaceInBackpack(item); m.PlaceInBackpack(item);
} }

View file

@ -9,7 +9,7 @@ namespace Server.Mobiles
{ {
public class Ilhenir : BaseChampion public class Ilhenir : BaseChampion
{ {
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>(); private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
[Constructible] [Constructible]
public Ilhenir() public Ilhenir()
@ -230,13 +230,14 @@ namespace Server.Mobiles
public virtual void CacophonicAttack(Mobile to) public virtual void CacophonicAttack(Mobile to)
{ {
if (to.Alive && to.Player && !m_Table.ContainsKey(to)) if (to.Alive && to.Player && !UnderCacophonicAttack(to))
{ {
to.Send(SpeedControl.WalkSpeed); to.Send(SpeedControl.WalkSpeed);
to.SendLocalizedMessage(1072069); // A cacophonic sound lambastes you, suppressing your ability to move. to.SendLocalizedMessage(1072069); // A cacophonic sound lambastes you, suppressing your ability to move.
to.PlaySound(0x584); to.PlaySound(0x584);
m_Table[to] = Timer.DelayCall(TimeSpan.FromSeconds(30), CacophonicEnd, to); m_Table.Add(to);
Timer.DelayCall(TimeSpan.FromSeconds(30), CacophonicEnd, to);
} }
} }
@ -248,7 +249,7 @@ namespace Server.Mobiles
public static bool UnderCacophonicAttack(Mobile from) public static bool UnderCacophonicAttack(Mobile from)
{ {
return m_Table.ContainsKey(from); return m_Table.Contains(from);
} }
public virtual void DropOoze() public virtual void DropOoze()

View file

@ -101,32 +101,30 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble()) if (0.1 <= Utility.RandomDouble())
return;
if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{ {
ExpireTimer timer = m_Table[defender]; timer.DoExpire();
defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
if (timer != null)
{
timer.DoExpire();
defender.SendLocalizedMessage(1070837); // The creature lands another blow in your weakened state.
}
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(
1070836); // The blow from the creature's claws has made you more susceptible to physical attacks.
}
int effect = -(defender.PhysicalResistance * 15 / 100);
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, effect);
defender.FixedEffect(0x37B9, 10, 5);
defender.AddResistanceMod(mod);
timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -89,7 +89,7 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (!(0.1 > Utility.RandomDouble())) if (0.1 <= Utility.RandomDouble())
return; return;
/* Blood Bath /* Blood Bath
@ -100,9 +100,7 @@ namespace Server.Mobiles
* End cliloc: 1070824 * End cliloc: 1070824
*/ */
ExpireTimer timer = m_Table[defender]; if (m_Table.TryGetValue(defender, out ExpireTimer timer))
if (timer != null)
{ {
timer.DoExpire(); timer.DoExpire();
defender.SendLocalizedMessage(1070825); // The creature continues to rage! defender.SendLocalizedMessage(1070825); // The creature continues to rage!
@ -254,7 +252,6 @@ namespace Server.Mobiles
AddItem(new Robe(Utility.RandomNondyedHue())); AddItem(new Robe(Utility.RandomNondyedHue()));
m_DisguiseTimer = null;
m_DisguiseTimer = Timer.DelayCall(TimeSpan.FromSeconds(75), RemoveDisguise); m_DisguiseTimer = Timer.DelayCall(TimeSpan.FromSeconds(75), RemoveDisguise);
} }
@ -280,9 +277,7 @@ namespace Server.Mobiles
public void DeleteItemOnLayer(Layer layer) public void DeleteItemOnLayer(Layer layer)
{ {
Item item = FindItemOnLayer(layer); FindItemOnLayer(layer)?.Delete();
item?.Delete();
} }
#endregion #endregion

View file

@ -9,7 +9,7 @@ namespace Server.Mobiles
{ {
public class FanDancer : BaseCreature public class FanDancer : BaseCreature
{ {
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>(); private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
[Constructible] [Constructible]
public FanDancer() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) public FanDancer() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
@ -143,13 +143,13 @@ namespace Server.Mobiles
ExpireTimer timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(10.0)); ExpireTimer timer = new ExpireTimer(defender, mod, TimeSpan.FromSeconds(10.0));
timer.Start(); timer.Start();
m_Table[defender] = timer; m_Table.Add(defender);
} }
} }
public bool IsFanned(Mobile m) public bool IsFanned(Mobile m)
{ {
return m_Table.ContainsKey(m); return m_Table.Contains(m);
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -116,8 +116,7 @@ namespace Server.Mobiles
public static void BeginLifeDrain(Mobile m, Mobile from) public static void BeginLifeDrain(Mobile m, Mobile from)
{ {
InternalTimer timer = m_Table[m]; m_Table.TryGetValue(m, out InternalTimer timer);
timer?.Stop(); timer?.Stop();
m_Table[m] = timer = new InternalTimer(from, m); m_Table[m] = timer = new InternalTimer(from, m);
@ -139,12 +138,12 @@ namespace Server.Mobiles
public static void EndLifeDrain(Mobile m) public static void EndLifeDrain(Mobile m)
{ {
Timer timer = m_Table[m]; if (m_Table.TryGetValue(m, out InternalTimer timer))
timer?.Stop(); {
timer?.Stop();
m_Table.Remove(m); m_Table.Remove(m);
m.SendLocalizedMessage(1070849); // The drain on your life force is gone.
m.SendLocalizedMessage(1070849); // The drain on your life force is gone. }
} }
public override void OnDamage(int amount, Mobile from, bool willKill) public override void OnDamage(int amount, Mobile from, bool willKill)

View file

@ -74,9 +74,7 @@ namespace Server.Mobiles
* Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(1048 779, 6)" ToLocation: "(1048 779, 6)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False" * Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(1048 779, 6)" ToLocation: "(1048 779, 6)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
*/ */
ExpireTimer timer = m_FlurryOfTwigsTable[defender]; if (m_FlurryOfTwigsTable.TryGetValue(defender, out ExpireTimer timer))
if (timer != null)
{ {
timer.DoExpire(); timer.DoExpire();
defender.SendLocalizedMessage(1070851); // The creature lands another blow in your weakened state. defender.SendLocalizedMessage(1070851); // The creature lands another blow in your weakened state.
@ -97,8 +95,10 @@ namespace Server.Mobiles
timer = new ExpireTimer(defender, mod, m_FlurryOfTwigsTable, TimeSpan.FromSeconds(5.0)); timer = new ExpireTimer(defender, mod, m_FlurryOfTwigsTable, TimeSpan.FromSeconds(5.0));
timer.Start(); timer.Start();
m_FlurryOfTwigsTable[defender] = timer; m_FlurryOfTwigsTable[defender] = timer;
return;
} }
else if (0.05 > Utility.RandomDouble())
if (0.05 > Utility.RandomDouble())
{ {
/* Chlorophyl Blast /* Chlorophyl Blast
* Start cliloc: 1070827 * Start cliloc: 1070827
@ -107,9 +107,7 @@ namespace Server.Mobiles
* Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(1048 779, 6)" ToLocation: "(1048 779, 6)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False" * Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(1048 779, 6)" ToLocation: "(1048 779, 6)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
*/ */
ExpireTimer timer = m_ChlorophylBlastTable[defender]; if (m_ChlorophylBlastTable.TryGetValue(defender, out ExpireTimer timer))
if (timer != null)
{ {
timer.DoExpire(); timer.DoExpire();
defender.SendLocalizedMessage(1070828); // The creature continues to hinder your energy resistance! defender.SendLocalizedMessage(1070828); // The creature continues to hinder your energy resistance!

View file

@ -81,32 +81,30 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble()) if (0.1 <= Utility.RandomDouble())
return;
/* Cold Wind
* Graphics: Message - Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(928 164, 34)" ToLocation: "(928 164, 34)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
* Start cliloc: 1070832
* Damage: 1hp per second for 5 seconds
* End cliloc: 1070830
* Reset cliloc: 1070831
*/
if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{ {
/* Cold Wind timer.DoExpire();
* Graphics: Message - Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(928 164, 34)" ToLocation: "(928 164, 34)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False" defender.SendLocalizedMessage(1070831); // The freezing wind continues to blow!
* Start cliloc: 1070832
* Damage: 1hp per second for 5 seconds
* End cliloc: 1070830
* Reset cliloc: 1070831
*/
ExpireTimer timer = m_Table[defender];
if (timer != null)
{
timer.DoExpire();
defender.SendLocalizedMessage(1070831); // The freezing wind continues to blow!
}
else
{
defender.SendLocalizedMessage(1070832); // An icy wind surrounds you, freezing your lungs as you breathe!
}
timer = new ExpireTimer(defender, this);
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(1070832); // An icy wind surrounds you, freezing your lungs as you breathe!
}
timer = new ExpireTimer(defender, this);
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -6,7 +6,7 @@ namespace Server.Mobiles
{ {
public class RaiJu : BaseCreature public class RaiJu : BaseCreature
{ {
private static Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>(); private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
[Constructible] [Constructible]
public RaiJu() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) public RaiJu() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
@ -61,33 +61,28 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble() && !IsStunned(defender)) if (0.1 <= Utility.RandomDouble() || m_Table.Contains(defender))
{ return;
/* Lightning Fist
* Cliloc: 1070839
* Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(884 715, 10)" ToLocation: "(884 715, 10)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
* Damage: 35-65, 100% energy, resistable
* Freezes for 4 seconds
* Effect cannot stack
*/
defender.FixedEffect(0x37B9, 10, 5); /* Lightning Fist
defender.SendLocalizedMessage(1070839); // The creature attacks with stunning force! * Cliloc: 1070839
* Effect: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x37B9" ItemIdName: "glow" FromLocation: "(884 715, 10)" ToLocation: "(884 715, 10)" Speed: "10" Duration: "5" FixedDirection: "True" Explode: "False"
* Damage: 35-65, 100% energy, resistable
* Freezes for 4 seconds
* Effect cannot stack
*/
// This should be done in place of the normal attack damage. defender.FixedEffect(0x37B9, 10, 5);
//AOS.Damage( defender, this, Utility.RandomMinMax( 35, 65 ), 0, 0, 0, 0, 100 ); defender.SendLocalizedMessage(1070839); // The creature attacks with stunning force!
defender.Frozen = true; // This should be done in place of the normal attack damage.
//AOS.Damage( defender, this, Utility.RandomMinMax( 35, 65 ), 0, 0, 0, 0, 100 );
ExpireTimer timer = new ExpireTimer(defender, TimeSpan.FromSeconds(4.0)); defender.Frozen = true;
timer.Start();
m_Table[defender] = timer;
}
}
public bool IsStunned(Mobile m) ExpireTimer timer = new ExpireTimer(defender, TimeSpan.FromSeconds(4.0));
{ timer.Start();
return m_Table.ContainsKey(m); m_Table.Add(defender);
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -138,77 +138,75 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.05 > Utility.RandomDouble()) if (0.05 <= Utility.RandomDouble())
return;
/* Rune Corruption
* Start cliloc: 1070846 "The creature magically corrupts your armor!"
* Effect: All resistances -70 (lowest 0) for 5 seconds
* End ASCII: "The corruption of your armor has worn off"
*/
if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{ {
/* Rune Corruption timer.DoExpire();
* Start cliloc: 1070846 "The creature magically corrupts your armor!" defender.SendLocalizedMessage(1070845); // The creature continues to corrupt your armor!
* Effect: All resistances -70 (lowest 0) for 5 seconds
* End ASCII: "The corruption of your armor has worn off"
*/
ExpireTimer timer = m_Table[defender];
if (timer != null)
{
timer.DoExpire();
defender.SendLocalizedMessage(1070845); // The creature continues to corrupt your armor!
}
else
{
defender.SendLocalizedMessage(1070846); // The creature magically corrupts your armor!
}
List<ResistanceMod> mods = new List<ResistanceMod>();
if (Core.ML)
{
if (defender.PhysicalResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Physical, -(defender.PhysicalResistance / 2)));
if (defender.FireResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Fire, -(defender.FireResistance / 2)));
if (defender.ColdResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Cold, -(defender.ColdResistance / 2)));
if (defender.PoisonResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Poison, -(defender.PoisonResistance / 2)));
if (defender.EnergyResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Energy, -(defender.EnergyResistance / 2)));
}
else
{
if (defender.PhysicalResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Physical,
defender.PhysicalResistance > 70 ? -70 : -defender.PhysicalResistance));
if (defender.FireResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Fire,
defender.FireResistance > 70 ? -70 : -defender.FireResistance));
if (defender.ColdResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Cold,
defender.ColdResistance > 70 ? -70 : -defender.ColdResistance));
if (defender.PoisonResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Poison,
defender.PoisonResistance > 70 ? -70 : -defender.PoisonResistance));
if (defender.EnergyResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Energy,
defender.EnergyResistance > 70 ? -70 : -defender.EnergyResistance));
}
for (int i = 0; i < mods.Count; ++i)
defender.AddResistanceMod(mods[i]);
defender.FixedEffect(0x37B9, 10, 5);
timer = new ExpireTimer(defender, mods, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(1070846); // The creature magically corrupts your armor!
}
List<ResistanceMod> mods = new List<ResistanceMod>();
if (Core.ML)
{
if (defender.PhysicalResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Physical, -(defender.PhysicalResistance / 2)));
if (defender.FireResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Fire, -(defender.FireResistance / 2)));
if (defender.ColdResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Cold, -(defender.ColdResistance / 2)));
if (defender.PoisonResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Poison, -(defender.PoisonResistance / 2)));
if (defender.EnergyResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Energy, -(defender.EnergyResistance / 2)));
}
else
{
if (defender.PhysicalResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Physical,
defender.PhysicalResistance > 70 ? -70 : -defender.PhysicalResistance));
if (defender.FireResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Fire,
defender.FireResistance > 70 ? -70 : -defender.FireResistance));
if (defender.ColdResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Cold,
defender.ColdResistance > 70 ? -70 : -defender.ColdResistance));
if (defender.PoisonResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Poison,
defender.PoisonResistance > 70 ? -70 : -defender.PoisonResistance));
if (defender.EnergyResistance > 0)
mods.Add(new ResistanceMod(ResistanceType.Energy,
defender.EnergyResistance > 70 ? -70 : -defender.EnergyResistance));
}
for (int i = 0; i < mods.Count; ++i)
defender.AddResistanceMod(mods[i]);
defender.FixedEffect(0x37B9, 10, 5);
timer = new ExpireTimer(defender, mods, TimeSpan.FromSeconds(5.0));
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -103,9 +103,10 @@ namespace Server.Mobiles
{ {
base.OnGaveMeleeAttack(defender); base.OnGaveMeleeAttack(defender);
if (0.1 > Utility.RandomDouble()) if (0.1 <= Utility.RandomDouble())
{ return;
/* Blood Bath
/* Blood Bath
* Start cliloc 1070826 * Start cliloc 1070826
* Sound: 0x52B * Sound: 0x52B
* 2-3 blood spots * 2-3 blood spots
@ -113,22 +114,19 @@ namespace Server.Mobiles
* End cliloc: 1070824 * End cliloc: 1070824
*/ */
ExpireTimer timer = m_Table[defender]; if (m_Table.TryGetValue(defender, out ExpireTimer timer))
{
if (timer != null) timer.DoExpire();
{ defender.SendLocalizedMessage(1070825); // The creature continues to rage!
timer.DoExpire();
defender.SendLocalizedMessage(1070825); // The creature continues to rage!
}
else
{
defender.SendLocalizedMessage(1070826); // The creature goes into a rage, inflicting heavy damage!
}
timer = new ExpireTimer(defender, this);
timer.Start();
m_Table[defender] = timer;
} }
else
{
defender.SendLocalizedMessage(1070826); // The creature goes into a rage, inflicting heavy damage!
}
timer = new ExpireTimer(defender, this);
timer.Start();
m_Table[defender] = timer;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -2139,12 +2139,10 @@ namespace Server.Mobiles
if (obj == null || m_AntiMacroTable == null || AccessLevel != AccessLevel.Player) if (obj == null || m_AntiMacroTable == null || AccessLevel != AccessLevel.Player)
return true; return true;
Dictionary<object, CountAndTimeStamp> tbl = m_AntiMacroTable[skill]; if (!m_AntiMacroTable.TryGetValue(skill, out Dictionary<object, CountAndTimeStamp> tbl))
if (tbl == null)
m_AntiMacroTable[skill] = tbl = new Dictionary<object, CountAndTimeStamp>(); m_AntiMacroTable[skill] = tbl = new Dictionary<object, CountAndTimeStamp>();
CountAndTimeStamp count = tbl[obj]; if (tbl.TryGetValue(obj, out CountAndTimeStamp count))
if (count != null)
{ {
if (count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow) if (count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow)
{ {
@ -4738,10 +4736,8 @@ namespace Server.Mobiles
public virtual bool HasRecipe(int recipeID) public virtual bool HasRecipe(int recipeID)
{ {
if (m_AcquiredRecipes != null && m_AcquiredRecipes.ContainsKey(recipeID)) m_AcquiredRecipes?.TryGetValue(recipeID, out bool value);
return m_AcquiredRecipes[recipeID]; return value;
return false;
} }
public virtual void AcquireRecipe(Recipe r) public virtual void AcquireRecipe(Recipe r)
@ -4764,16 +4760,7 @@ namespace Server.Mobiles
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int KnownRecipes public int KnownRecipes => m_AcquiredRecipes?.Count ?? 0;
{
get
{
if (m_AcquiredRecipes == null)
return 0;
return m_AcquiredRecipes.Count;
}
}
#endregion #endregion
@ -4784,11 +4771,9 @@ namespace Server.Mobiles
if (!BuffInfo.Enabled || m_BuffTable == null) if (!BuffInfo.Enabled || m_BuffTable == null)
return; return;
NetState state = NetState; if (NetState?.BuffIcon == true)
if (state != null && state.BuffIcon)
foreach (BuffInfo info in m_BuffTable.Values) foreach (BuffInfo info in m_BuffTable.Values)
state.Send(new AddBuffPacket(this, info)); NetState.Send(new AddBuffPacket(this, info));
} }
private Dictionary<BuffIcon, BuffInfo> m_BuffTable; private Dictionary<BuffIcon, BuffInfo> m_BuffTable;
@ -4805,9 +4790,8 @@ namespace Server.Mobiles
m_BuffTable.Add(b.ID, b); m_BuffTable.Add(b.ID, b);
NetState state = NetState; if (NetState?.BuffIcon == true)
NetState.Send(new AddBuffPacket(this, b));
if (state != null && state.BuffIcon) state.Send(new AddBuffPacket(this, b));
} }
public void RemoveBuff(BuffInfo b) public void RemoveBuff(BuffInfo b)
@ -4830,9 +4814,8 @@ namespace Server.Mobiles
m_BuffTable.Remove(b); m_BuffTable.Remove(b);
NetState state = NetState; if (NetState?.BuffIcon == true)
NetState.Send(new RemoveBuffPacket(this, b));
if (state != null && state.BuffIcon) state.Send(new RemoveBuffPacket(this, b));
if (m_BuffTable.Count <= 0) if (m_BuffTable.Count <= 0)
m_BuffTable = null; m_BuffTable = null;

View file

@ -391,10 +391,7 @@ namespace Server.Mobiles
if (from == null || !from.Player) if (from == null || !from.Player)
return; return;
if (m_DamageEntries.ContainsKey(from)) m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0);
m_DamageEntries[from] += amount;
else
m_DamageEntries.Add(from, amount);
from.SendMessage($"Total Damage: {m_DamageEntries[from]}"); from.SendMessage($"Total Damage: {m_DamageEntries[from]}");
} }

View file

@ -258,14 +258,10 @@ namespace Server.Mobiles
if (dest == null) if (dest == null)
return false; return false;
Mobile escorter = GetEscorter(); if (GetEscorter() != null || !m.Alive)
if (escorter != null || !m.Alive)
return false; return false;
BaseEscortable escortable = EscortTable[m]; if (EscortTable.TryGetValue(m, out BaseEscortable escortable) && escortable?.Deleted == false && escortable.GetEscorter() == m)
if (escortable?.Deleted == false && escortable.GetEscorter() == m)
{ {
Say("I see you already have an escort."); Say("I see you already have an escort.");
return false; return false;
@ -693,7 +689,8 @@ namespace Server.Mobiles
if (name == null || m_Table == null) if (name == null || m_Table == null)
return null; return null;
return m_Table[name]; m_Table.TryGetValue(name, out EscortDestinationInfo info);
return info;
} }
} }

View file

@ -924,27 +924,25 @@ namespace Server.Mobiles
IShopSellInfo[] info = GetSellInfo(); IShopSellInfo[] info = GetSellInfo();
Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>(); List<SellItemState> list = new List<SellItemState>();
foreach (IShopSellInfo ssi in info) foreach (IShopSellInfo ssi in info)
{ {
Item[] items = pack.FindItemsByType(ssi.Types); foreach (Item item in pack.FindItemsByType(ssi.Types))
foreach (Item item in items)
{ {
if (item is Container container && container.Items.Count != 0) if (item is Container container && container.Items.Count != 0)
continue; continue;
if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item)) if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
table[item] = new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)); list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item)));
} }
} }
if (table.Count > 0) if (list.Count > 0)
{ {
SendPacksTo(from); SendPacksTo(from);
from.Send(new VendorSellList(this, table.Values)); from.Send(new VendorSellList(this, list));
} }
else else
{ {

View file

@ -9,10 +9,6 @@ namespace Server.Mobiles
private Dictionary<Type, int> m_Table = new Dictionary<Type, int>(); private Dictionary<Type, int> m_Table = new Dictionary<Type, int>();
private Type[] m_Types; private Type[] m_Types;
public GenericSellInfo()
{
}
public void Add( Type type, int price ) public void Add( Type type, int price )
{ {
m_Table[type] = price; m_Table[type] = price;

View file

@ -351,7 +351,8 @@ namespace Server.Mobiles
if (BaseHouse.NewVendorSystem) return ChargePerRealWorldDay / 12; if (BaseHouse.NewVendorSystem) return ChargePerRealWorldDay / 12;
long total = 0; long total = 0;
foreach (VendorItem vi in m_SellItems.Values) total += vi.Price; foreach (VendorItem vi in m_SellItems.Values)
total += vi.Price;
total -= 500; total -= 500;
@ -369,7 +370,8 @@ namespace Server.Mobiles
if (BaseHouse.NewVendorSystem) if (BaseHouse.NewVendorSystem)
{ {
long total = 0; long total = 0;
foreach (VendorItem vi in m_SellItems.Values) total += vi.Price; foreach (VendorItem vi in m_SellItems.Values)
total += vi.Price;
return (int)(60 + total / 500 * 3); return (int)(60 + total / 500 * 3);
} }

View file

@ -71,9 +71,7 @@ namespace Server.Multis
if (owner != null) if (owner != null)
{ {
m_Table.TryGetValue(owner, out List<BaseHouse> list); if (!m_Table.TryGetValue(owner, out List<BaseHouse> list))
if (list == null)
m_Table[owner] = list = new List<BaseHouse>(); m_Table[owner] = list = new List<BaseHouse>();
list.Add(this); list.Add(this);
@ -276,9 +274,7 @@ namespace Server.Multis
{ {
if (m_Owner != null) if (m_Owner != null)
{ {
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list); if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
if (list == null)
m_Table[m_Owner] = list = new List<BaseHouse>(); m_Table[m_Owner] = list = new List<BaseHouse>();
list.Remove(this); list.Remove(this);
@ -289,9 +285,7 @@ namespace Server.Multis
if (m_Owner != null) if (m_Owner != null)
{ {
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list); if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
if (list == null)
m_Table[m_Owner] = list = new List<BaseHouse>(); m_Table[m_Owner] = list = new List<BaseHouse>();
list.Add(this); list.Add(this);
@ -1111,9 +1105,7 @@ namespace Server.Multis
if (m != null) if (m != null)
{ {
m_Table.TryGetValue(m, out List<BaseHouse> exists); if (m_Table.TryGetValue(m, out List<BaseHouse> exists))
if (exists != null)
for (int i = 0; i < exists.Count; ++i) for (int i = 0; i < exists.Count; ++i)
{ {
BaseHouse house = exists[i]; BaseHouse house = exists[i];
@ -2616,9 +2608,7 @@ namespace Server.Multis
if (m_Owner != null) if (m_Owner != null)
{ {
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list); if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
if (list == null)
m_Table[m_Owner] = list = new List<BaseHouse>(); m_Table[m_Owner] = list = new List<BaseHouse>();
list.Add(this); list.Add(this);
@ -2745,9 +2735,7 @@ namespace Server.Multis
if (m_Owner != null) if (m_Owner != null)
{ {
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list); if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
if (list == null)
m_Table[m_Owner] = list = new List<BaseHouse>(); m_Table[m_Owner] = list = new List<BaseHouse>();
list.Remove(this); list.Remove(this);
@ -2888,12 +2876,7 @@ namespace Server.Multis
public static bool HasHouse(Mobile m) public static bool HasHouse(Mobile m)
{ {
if (m == null) if (m == null || !m_Table.TryGetValue(m, out List<BaseHouse> list))
return false;
m_Table.TryGetValue(m, out List<BaseHouse> list);
if (list == null)
return false; return false;
for (int i = 0; i < list.Count; ++i) for (int i = 0; i < list.Count; ++i)

View file

@ -23,12 +23,7 @@ namespace Server.Multis
public static void Register(DecayLevel level, TimeSpan min, TimeSpan max) public static void Register(DecayLevel level, TimeSpan min, TimeSpan max)
{ {
DecayStageInfo info = new DecayStageInfo(min, max); m_Stages[level] = new DecayStageInfo(min, max);
if (m_Stages.ContainsKey(level))
m_Stages[level] = info;
else
m_Stages.Add(level, info);
} }
public static bool Decays(DecayLevel level) public static bool Decays(DecayLevel level)
@ -38,10 +33,9 @@ namespace Server.Multis
public static TimeSpan GetRandomDuration(DecayLevel level) public static TimeSpan GetRandomDuration(DecayLevel level)
{ {
if (!m_Stages.ContainsKey(level)) if (!m_Stages.TryGetValue(level, out DecayStageInfo info))
return TimeSpan.Zero; return TimeSpan.Zero;
DecayStageInfo info = m_Stages[level];
long min = info.MinDuration.Ticks; long min = info.MinDuration.Ticks;
long max = info.MaxDuration.Ticks; long max = info.MaxDuration.Ticks;

View file

@ -803,7 +803,7 @@ namespace Server.Items
public static HousePlacementEntry Find(BaseHouse house) public static HousePlacementEntry Find(BaseHouse house)
{ {
object obj = m_Table[house.GetType()]; m_Table.TryGetValue(house.GetType(), out object obj);
if (obj is HousePlacementEntry entry) if (obj is HousePlacementEntry entry)
return entry; return entry;
@ -825,9 +825,7 @@ namespace Server.Items
{ {
HousePlacementEntry e = entries[i]; HousePlacementEntry e = entries[i];
object obj = m_Table[e.Type]; if (!m_Table.TryGetValue(e.Type, out object obj))
if (obj == null)
{ {
m_Table[e.Type] = e; m_Table[e.Type] = e;
} }

View file

@ -258,58 +258,53 @@ namespace Server.Regions
public void CheckGuardCandidate(Mobile m) public void CheckGuardCandidate(Mobile m)
{ {
if (IsDisabled()) if (IsDisabled() || !IsGuardCandidate(m))
return; return;
if (IsGuardCandidate(m)) if (!m_GuardCandidates.TryGetValue(m, out GuardTimer timer))
{ {
m_GuardCandidates.TryGetValue(m, out GuardTimer timer); timer = new GuardTimer(m, m_GuardCandidates);
timer.Start();
if (timer == null) m_GuardCandidates[m] = timer;
{ m.SendLocalizedMessage(502275); // Guards can now be called on you!
timer = new GuardTimer(m, m_GuardCandidates);
timer.Start();
m_GuardCandidates[m] = timer; Map map = m.Map;
m.SendLocalizedMessage(502275); // Guards can now be called on you!
Map map = m.Map; if (map == null)
return;
if (map != null) Mobile fakeCall = null;
double prio = 0.0;
foreach (Mobile v in m.GetMobilesInRange(8))
if (!v.Player && v != m && !IsGuardCandidate(v) &&
((v as BaseCreature)?.IsHumanInTown() ?? v.Body.IsHuman && v.Region.IsPartOf(this)))
{ {
Mobile fakeCall = null; double dist = m.GetDistanceToSqrt(v);
double prio = 0.0;
foreach (Mobile v in m.GetMobilesInRange(8)) if (fakeCall == null || dist < prio)
if (!v.Player && v != m && !IsGuardCandidate(v) &&
((v as BaseCreature)?.IsHumanInTown() ?? v.Body.IsHuman && v.Region.IsPartOf(this)))
{
double dist = m.GetDistanceToSqrt(v);
if (fakeCall == null || dist < prio)
{
fakeCall = v;
prio = dist;
}
}
if (fakeCall != null)
{ {
fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, fakeCall = v;
1013043, 1013052)); prio = dist;
MakeGuard(m);
timer.Stop();
m_GuardCandidates.Remove(m);
m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
} }
} }
}
else if (fakeCall != null)
{ {
fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042,
1013043, 1013052));
MakeGuard(m);
timer.Stop(); timer.Stop();
timer.Start(); m_GuardCandidates.Remove(m);
m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
} }
} }
else
{
timer.Stop();
timer.Start();
}
} }
public void CallGuards(Point3D p) public void CallGuards(Point3D p)
@ -323,9 +318,7 @@ namespace Server.Regions
if (IsGuardCandidate(m) && if (IsGuardCandidate(m) &&
(!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this) || m_GuardCandidates.ContainsKey(m))) (!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this) || m_GuardCandidates.ContainsKey(m)))
{ {
m_GuardCandidates.TryGetValue(m, out GuardTimer timer); if (m_GuardCandidates.TryGetValue(m, out GuardTimer timer))
if (timer != null)
{ {
timer.Stop(); timer.Stop();
m_GuardCandidates.Remove(m); m_GuardCandidates.Remove(m);

View file

@ -36,9 +36,7 @@ namespace Server.Regions
if (!Region.ReadString(xml, "name", ref group)) if (!Region.ReadString(xml, "name", ref group))
return null; return null;
SpawnDefinition def = SpawnGroup.Table[@group]; if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def))
if (def == null)
{ {
Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group); Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group);
return null; return null;
@ -152,9 +150,7 @@ namespace Server.Regions
public static SpawnMobile Get(Type type) public static SpawnMobile Get(Type type)
{ {
SpawnMobile sm = m_Table[type]; if (!m_Table.TryGetValue(type, out SpawnMobile sm))
if (sm == null)
m_Table[type] = sm = new SpawnMobile(type); m_Table[type] = sm = new SpawnMobile(type);
return sm; return sm;
@ -221,9 +217,7 @@ namespace Server.Regions
public static SpawnItem Get(Type type) public static SpawnItem Get(Type type)
{ {
SpawnItem si = m_Table[type]; if (!m_Table.TryGetValue(type, out SpawnItem si))
if (si == null)
m_Table[type] = si = new SpawnItem(type); m_Table[type] = si = new SpawnItem(type);
return si; return si;

View file

@ -209,7 +209,7 @@ namespace Server.Regions
m_SpawnTimer = null; m_SpawnTimer = null;
} }
if (Table[ID] == this) if (Table.TryGetValue(ID, out SpawnEntry entry) && entry == this)
Table.Remove(ID); Table.Remove(ID);
} }
@ -310,6 +310,7 @@ namespace Server.Regions
Mobile from = args.Mobile; Mobile from = args.Mobile;
Region reg; Region reg;
if (args.Length == 0) if (args.Length == 0)
{ {
reg = from.Region; reg = from.Region;
@ -317,29 +318,26 @@ namespace Server.Regions
else else
{ {
string name = args.GetString(0); string name = args.GetString(0);
//reg = if (!from.Map.Regions.TryGetValue( name, out (Region) from.Map.Regions[name] )) if (!from.Map.Regions.TryGetValue(name, out reg))
{ {
from.SendMessage("Could not find region '{0}'.", name); from.SendMessage("Could not find region '{0}'.", name);
return null; return null;
} }
} }
BaseRegion br = reg as BaseRegion; if (reg is BaseRegion br && br.Spawns != null)
return br;
if (br?.Spawns == null) from.SendMessage("There are no spawners in region '{0}'.", reg);
{ return null;
from.SendMessage("There are no spawners in region '{0}'.", reg);
return null;
}
return br;
} }
[Usage("RespawnAllRegions")] [Usage("RespawnAllRegions")]
[Description("Respawns all regions and sets the spawners as running.")] [Description("Respawns all regions and sets the spawners as running.")]
private static void RespawnAllRegions_OnCommand(CommandEventArgs args) private static void RespawnAllRegions_OnCommand(CommandEventArgs args)
{ {
foreach (SpawnEntry entry in Table.Values) entry.Respawn(); foreach (SpawnEntry entry in Table.Values)
entry.Respawn();
args.Mobile.SendMessage("All regions have respawned."); args.Mobile.SendMessage("All regions have respawned.");
} }
@ -363,7 +361,8 @@ namespace Server.Regions
[Description("Deletes all spawned objects of every regions and sets the spawners as not running.")] [Description("Deletes all spawned objects of every regions and sets the spawners as not running.")]
private static void DelAllRegionSpawns_OnCommand(CommandEventArgs args) private static void DelAllRegionSpawns_OnCommand(CommandEventArgs args)
{ {
foreach (SpawnEntry entry in Table.Values) entry.DeleteSpawnedObjects(); foreach (SpawnEntry entry in Table.Values)
entry.DeleteSpawnedObjects();
args.Mobile.SendMessage("All region spawned objects have been deleted."); args.Mobile.SendMessage("All region spawned objects have been deleted.");
} }
@ -388,7 +387,8 @@ namespace Server.Regions
[Description("Sets the region spawners of all regions as running.")] [Description("Sets the region spawners of all regions as running.")]
private static void StartAllRegionSpawns_OnCommand(CommandEventArgs args) private static void StartAllRegionSpawns_OnCommand(CommandEventArgs args)
{ {
foreach (SpawnEntry entry in Table.Values) entry.Start(); foreach (SpawnEntry entry in Table.Values)
entry.Start();
args.Mobile.SendMessage("All region spawners have started."); args.Mobile.SendMessage("All region spawners have started.");
} }
@ -412,7 +412,8 @@ namespace Server.Regions
[Description("Sets the region spawners of all regions as not running.")] [Description("Sets the region spawners of all regions as not running.")]
private static void StopAllRegionSpawns_OnCommand(CommandEventArgs args) private static void StopAllRegionSpawns_OnCommand(CommandEventArgs args)
{ {
foreach (SpawnEntry entry in Table.Values) entry.Stop(); foreach (SpawnEntry entry in Table.Values)
entry.Stop();
args.Mobile.SendMessage("All region spawners have stopped."); args.Mobile.SendMessage("All region spawners have stopped.");
} }

View file

@ -208,7 +208,6 @@
<Compile Include="Engines\ConPVP\Ruleset.cs" /> <Compile Include="Engines\ConPVP\Ruleset.cs" />
<Compile Include="Engines\ConPVP\RulesetLayout.cs" /> <Compile Include="Engines\ConPVP\RulesetLayout.cs" />
<Compile Include="Engines\ConPVP\SafeZone.cs" /> <Compile Include="Engines\ConPVP\SafeZone.cs" />
<Compile Include="Engines\ConPVP\StakesContainer.cs" />
<Compile Include="Engines\ConPVP\Tournament.cs" /> <Compile Include="Engines\ConPVP\Tournament.cs" />
<Compile Include="Engines\ConPVP\TournamentBracketItem.cs" /> <Compile Include="Engines\ConPVP\TournamentBracketItem.cs" />
<Compile Include="Engines\ConPVP\TournamentController.cs" /> <Compile Include="Engines\ConPVP\TournamentController.cs" />

Some files were not shown because too many files have changed in this diff Show more